How do you tile a pattern as differently weighted blocks?

kron scales a second array by each entry of the first, then arranges the resulting blocks in the first array's layout.

numpy.kron in practice

Combine a 2×2 switch pattern with a 1×2 stripe. Lit tiles carry the stripe and dark tiles become zeros. Output dimensions multiply along each axis.

import numpy as np
np.kron([[1,0],[0,2]],[[1,3]])

Result [[1, 3, 0, 0], [0, 0, 2, 6]]

中文

怎样把小图案扩展为带权重的块矩阵?

kron 用第一个数组的每个元素缩放第二个数组,并将这些块按照第一个数组的布局排列。

numpy.kron 算例

2×2 开关图乘一个 1×2 条纹,可把亮格扩为条纹、暗格扩为零块。每个方向的输出长度都是相应轴长之积。

import numpy as np
np.kron([[1,0],[0,2]],[[1,3]])

结果 [[1, 3, 0, 0], [0, 0, 2, 6]]

References / 参考来源

Keep reading / 继续阅读