這個axes()
是 julia 中的一個內置函數,用於返回指定數組的元組或有效索引的有效範圍。
用法:
axes(A)
or
axes(A, d)
參數:
- A:指定數組。
- d:指定尺寸。
返回值:它返回指定數組的元組或有效索引的有效範圍。
範例1:
# Julia program to illustrate
# the use of Array axes() method
# Getting tuple for 1D array of size 5
# with each element filled with value 4
println(axes(fill(4, (5))))
# Getting tuple for 2D array of size 2X3
# with each element filled with value 5
println(axes(fill(5, (2, 3))))
# Getting tuple for 3D array of size 2X3X4
# with each element filled with value 4
println(axes(fill(4, (2, 3, 4))))
輸出:
範例2:
# Julia program to illustrate
# the use of Array axes() method
# Getting tuple for 1D array of size 5
# with each element filled with value 4
# along with dimension of 1
A = fill(4, (5));
println(axes(A, 1))
# Getting tuple for 2D array of size 2X3
# with each element filled with value 5
# along with dimension of 2
B = fill(5, (2, 3));
println(axes(B, 2))
# Getting tuple for 3D array of size 2X3X4
# with each element filled with value 4
# along with dimension of 3
C = fill(4, (2, 3, 4));
println(axes(C, 3))
輸出:
相關用法
- Julia ceil()用法及代碼示例
- Julia floor()用法及代碼示例
- Julia min()用法及代碼示例
- Julia findmin()用法及代碼示例
- Julia parent()用法及代碼示例
- Julia typeof()用法及代碼示例
- Julia collect()用法及代碼示例
- Julia first()用法及代碼示例
- Julia last()用法及代碼示例
- Julia pairs()用法及代碼示例
- Julia one()用法及代碼示例
- Julia zero()用法及代碼示例
- Julia conj()用法及代碼示例
- Julia max()用法及代碼示例
- Julia trunc()用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 Getting tuple or range of the valid indices in Julia – axes() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。