📜  在 Julia 中获取数组的维度 – ndims() 方法

📅  最后修改于: 2022-05-13 01:54:29.684000             🧑  作者: Mango

在 Julia 中获取数组的维度 – ndims() 方法

ndims()是 julia 中的一个内置函数,用于返回指定数组 A 的维数。

示例 1:

# Julia program to illustrate 
# the use of Array ndims() method
  
# Finding the number of dimension of
# the specified array A.
A = fill(1, 3);
println(ndims(A))
  
# Finding the number of dimension of
# the specified array B.
B = fill(1, (3, 3));
println(ndims(B))
  
# Finding the number of dimension of
# the specified array C.
C = fill(1, (3, 1, 2));
println(ndims(C))

输出:

示例 2:

# Julia program to illustrate 
# the use of Array ndims() method
   
# Finding the number of dimension of
# the specified array A.
A = fill(1, 2, 3, 4);
println(ndims(A))
   
# Finding the number of dimension of
# the specified array B.
B = fill((5, 10), (3, 3));
println(ndims(B))
   
# Finding the number of dimension of
# the specified array C.
C = fill((5, 10, 15), (3, 1, 2));
println(ndims(C))

输出: