strides
strides(A)
Returns a tuple of the memory strides in each dimension
Examples

Get the memory strides of a 1dimensional array:
julia> arr = [1, 2, 3, 4, 5]; julia> strides(arr) (1,)
In this example, the
strides
function returns a tuple with a single value(1,)
. This indicates that the arrayarr
has a stride of 1 in the only dimension. 
Get the memory strides of a 2dimensional array:
julia> matrix = [1 2 3; 4 5 6]; julia> strides(matrix) (3, 1)
The
strides
function returns a tuple(3, 1)
for the 2dimensional arraymatrix
. This means that the memory stride in the first dimension is 3 and in the second dimension is 1.  Get the memory strides of a multidimensional array:
julia> tensor = [1 2 3; 4 5 6; 7 8 9]; julia> strides(tensor) (3, 1)
Here, the
strides
function returns a tuple(3, 1)
for the multidimensional arraytensor
. It indicates that the memory stride in the first dimension is 3 and in the second dimension is 1.
Common mistake example:
julia> x = [1 2 3; 4 5 6];
julia> strides(x)
ERROR: MethodError: no method matching strides(::Array{Int64,2})
In this example, the strides
function is used on a 2dimensional array. However, the function does not accept 2dimensional arrays as input. It is important to provide the correct input type to the strides
function to avoid this error.
See Also
User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.