這個parent()
是 julia 中的一個內置函數,用於返回指定數組視圖類型(即子數組)的父數組或數組本身(如果它不是視圖)。
用法: parent(A)
參數:
- A:指定的數組或數組視圖類型。
返回值:它返回指定數組視圖類型(即子數組)的父數組或數組本身,如果它不是視圖。
範例1:
# Julia program to illustrate
# the use of Array parent() method
# Getting the parent array of the
# specified 1D array view type (i.e, SubArray)
# or the array itself if it is not a view.
A = [1, 2, 3, 4];
B = view(A, 2)
println(parent(B))
# Getting the parent array of the
# specified 2D array view type (i.e, SubArray)
# or the array itself if it is not a view.
C = [1 2; 3 4];
D = view(C, 1:2,:)
println(parent(D))
輸出:
範例2:
# Julia program to illustrate
# the use of Array parent() method
# Getting the parent array of the
# specified 1D array view type (i.e, SubArray)
# or the array itself if it is not a view.
A = [1, 2, 3, 4];
println(parent(A))
# Getting the parent array of the
# specified 2D array view type (i.e, SubArray)
# or the array itself if it is not a view.
B = [1 2; 3 4];
println(parent(B))
# Getting the parent array of the
# specified 3D array view type (i.e, SubArray)
# or the array itself if it is not a view.
C = cat([1 2; 3 4], [5 6; 7 8], [2 2; 3 4], dims = 3);
println(parent(C))
輸出:
相關用法
- Julia findlast()用法及代碼示例
- Julia SubString()用法及代碼示例
- Julia findfirst()用法及代碼示例
- Julia startswith()用法及代碼示例
- Julia endswith()用法及代碼示例
- Julia collect()用法及代碼示例
- Julia first()用法及代碼示例
- Julia last()用法及代碼示例
- Julia ceil()用法及代碼示例
- Julia floor()用法及代碼示例
- Julia min()用法及代碼示例
- Julia axes()用法及代碼示例
- Julia findmin()用法及代碼示例
- Julia typeof()用法及代碼示例
- Julia pairs()用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 Getting parent array of a specified array in Julia – parent() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。