Getting parent array of a specified array in Julia – parent() Method
The parent()
is an inbuilt function in julia which is used to return the parent array of a specified array view type (i.e, SubArray) or the array itself if it is not a view.
Syntax: parent(A)
Parameters:
- A: Specified array or an array view type.
Returns: It returns the parent array of a specified array view type (i.e, SubArray) or the array itself if it is not a view.
Example 1:
A = [ 1 , 2 , 3 , 4 ];
B = view(A, 2 )
println(parent(B))
C = [ 1 2 ; 3 4 ];
D = view(C, 1 : 2 ,: )
println(parent(D))
|
Output:
Example 2:
A = [ 1 , 2 , 3 , 4 ];
println(parent(A))
B = [ 1 2 ; 3 4 ];
println(parent(B))
C = cat([ 1 2 ; 3 4 ], [ 5 6 ; 7 8 ], [ 2 2 ; 3 4 ], dims = 3 );
println(parent(C))
|
Output:
Last Updated :
26 Mar, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...