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

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

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

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))

输出: