isRowMajor

Given a stride array, determine whether an array is row-major.

Usage

var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' );

isRowMajor( strides )

Returns a boolean indicating if an array is row-major based on a provided stride array.

var bool = isRowMajor( [ 2, 1 ] );
// returns true

bool = isRowMajor( [ 1, 2 ] );
// returns false

Examples

var shape2strides = require( '@stdlib/ndarray/base/shape2strides' );
var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' );

var shape = [ 10, 10, 10 ];

var strides = shape2strides( shape, 'row-major' );
// returns [ 100, 10, 1 ]

var bool = isRowMajor( strides );
// returns true

strides = shape2strides( shape, 'column-major' );
// returns [ 1, 10, 100 ]

bool = isRowMajor( strides );
// returns false
Did you find this page helpful?