问问题
62 次
1 回答
1
虽然我不知道 Python,但我知道 APL,并且基于这些知识,我认为这些方法可以解决问题:
从数组索引转换为平面索引
arrayShape = [4, 5, 2, 11]
strides = [5×2×11, 2×11, 11, 1] = [110, 22, 11, 1]
arrayIndex = [1, 2, 1, 3]
flatIndex = ∑[1×110, 2×22, 1×11, 3×1] = 168
从平面索引转换为数组索引
arrayShape = [4, 5, 2, 11]
strides = [5×2×11, 2×11, 11, 1] = [110, 22, 11, 1]
flatIndex = 168
How many times can we subtract 110? 1, using 110 with remainder 58
How many times can we subtract 22? 2, using 44 with remainder 14
How many times can we subtract 11? 1, using 11 with remainder 3
How many times can we subtract 1? 3, using 3 with no remainder
arrayIndex = [1, 2, 1, 3]
于 2022-02-01T15:35:44.073 回答