移位数据
移数据以在给定维度上执行操作。
库::`工程师`
争论
例子:
重新排列魔术广场的尺寸
Details
让我们在魔法广场上换班吧 3×3 通过将第二维度重新排列到第一列中。 让我们使用函数将矩阵返回到原始位置 unshift数据.
让我们定义一个魔术广场 3×3.
import EngeeDSP.Functions: shiftdata
import EngeeDSP.Functions: unshiftdata
x = [2 9 4; 7 5 3; 6 1 8]
3×3 Matrix{Int64}:
8 1 6
3 5 7
4 9 2
让我们转移矩阵沿第二维工作。 让我们返回置换向量,移位数和移位矩阵。
x, perm, nshifts = shiftdata(x, 2)
(x = [8 3 4; 1 5 9; 6 7 2], perm = (2, 1), nshifts = Any[])
让我们将矩阵恢复到原始状态。
y = unshiftdata(x, perm)
3×3 Matrix{Int64}:
8 1 6
3 5 7
4 9 2
重新排列数组以处理第一个非一维
Details
让我们将移位的数据定义为行向量。
import EngeeDSP.Functions: shiftdata
import EngeeDSP.Functions: unshiftdata
x = [1 2 3 4 5]
1×5 Matrix{Int64}:
1 2 3 4 5
要将第一个数据维度(不是数组中的唯一元素)移动到第一列,我们不会指定 [参数:暗淡]. 功能 移位数据 以列向量、排列向量和移位数的形式返回数据。
x, perm, nshifts = shiftdata(x)
(x = [1, 2, 3, 4, 5], perm = Any[], nshifts = 1)
将数据恢复到原始状态。
y = unshiftdata(x, perm, nshifts)
1×5 Matrix{Int64}:
1 2 3 4 5