0.2.1 • Published 3 months ago

@stdlib/ndarray-base-assert-is-column-major v0.2.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 months ago

isColumnMajor

NPM version Build Status Coverage Status

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

Installation

npm install @stdlib/ndarray-base-assert-is-column-major

Usage

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

isColumnMajor( strides )

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

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

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

Examples

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

var shape = [ 10, 10, 10 ];

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

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

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

bool = isColumnMajor( strides );
// returns false

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.