Getting distance in memory between adjacent elements in Julia – stride() and strides() Method
Last Updated :
26 Mar, 2020
The stride()
is an inbuilt function in julia which is used to return the distance in memory between the specified adjacent elements in specified dimension.
Syntax:
stride(A, k::Integer)
Parameters:
- A: Specified array.
- k::Integer: Specified dimension.
Returns: It returns the distance in memory between the specified adjacent elements in specified dimension.
Example:
A = fill( 4 , 5 );
println(stride(A, 1 ))
B = fill( 4 , ( 5 , 6 ));
println(stride(B, 2 ))
C = fill( 4 , ( 5 , 6 , 7 ));
println(stride(C, 3 ))
|
Output:
1
5
30
Array strides() method
The strides()
is an inbuilt function in julia which is used to return a tuple of the memory strides in each dimension.
Syntax:
strides(A)
Parameters:
Returns: It returns a tuple of the memory strides in each dimension.
Example:
A = fill( 4 , 5 );
println(strides(A))
B = fill( 4 , ( 5 , 6 ));
println(strides(B))
C = fill( 4 , ( 5 , 6 , 7 ));
println(strides(C))
|
Output:
(1, )
(1, 5)
(1, 5, 30)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...