📜  在 Julia 中表示数组的维度——Dims() 方法

📅  最后修改于: 2021-11-25 04:40:35             🧑  作者: Mango

Dims()是 julia 中的一个内置函数,用于表示指定 AbstractArray 的维度。

示例 1:

# Julia program to illustrate 
# the use of Dims() method
  
# Getting the represented dimensions
# of the specified AbstractArray.
A = [1, 2, 3, 4]
println(Dims(A))
  
B = (5, 10, 15, 20)
println(Dims(B))

输出:

(1, 2, 3, 4)
(5, 10, 15, 20)

示例 2:

# Julia program to illustrate 
# the use of Dims() method
  
# Getting the represented dimensions
# of the specified AbstractArray.
A = [1 2 3; 4 5 6]
println(Dims(A))
  
B = cat([1 2; 3 4], [5 6; 7 8], [2 2; 3 4], dims = 3)
println(Dims(B))

输出: