julia - Julia 中多维数组的子维数组

标签 julia array-indexing

使用 NumPy 我可以访问 subdimensional array from a multidimensional array不知道原始数组的维度:

import numpy as np
a = np.zeros((2, 3, 4))  # A 2-by-3-by-4 array of zeros
a[0]  # A 3-by-4 array of zeros

但是对于 Julia 我却不知所措。看来我必须知道 a 的尺寸才能做到这一点:

a = zeros(2, 3, 4)  # A 2-by-3-by-4 array of zeros
a[1, :, :]  # A 3-by-4 array of zeros

如果我知道a的尺寸该怎么办?

最佳答案

selectdim 给出您正在寻找的内容的 View ,

a = zeros(2, 3, 4)
selectdim(a,1,1)

关于julia - Julia 中多维数组的子维数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71193655/

相关文章:

python - 在不同设备上进行程序间通信的最简洁方法

julia - 允许函数忽略不支持的关键字参数

multithreading - 在 Julia 的多线程循环中设置种子

python - numpy 数组索引技术如何为相同的输入代码提供不同的输出?

package - 如何使平方根适合 Julia 1.0 中的数据

algorithm - 用于一般可迭代集合的 Julia 查找算法

VHDL 2008 : Index in external names containing generated instances

indexing - Bigquery : Find the index at which a specified element is first found within an array

c - 指针是否支持 "array style indexing"?