@stdlib/ndarray-to-reversed
v0.1.1
Published
Return a new ndarray where the order of elements of an input ndarray is reversed along each dimension.
Readme
toReversed
Return a new
ndarraywhere the order of elements of an inputndarrayis reversed along each dimension.
Installation
npm install @stdlib/ndarray-to-reversedUsage
var toReversed = require( '@stdlib/ndarray-to-reversed' );toReversed( x )
Returns a new ndarray where the order of elements of an input ndarray is reversed along each dimension.
var array = require( '@stdlib/ndarray-array' );
var ndarray2array = require( '@stdlib/ndarray-to-array' );
var x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], {
'shape': [ 3, 2 ]
});
// returns <ndarray>
var arr = ndarray2array( x );
// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
var y = toReversed( x );
// returns <ndarray>
arr = ndarray2array( y );
// returns [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ]Examples
var uniform = require( '@stdlib/random-uniform' );
var ndarray2array = require( '@stdlib/ndarray-to-array' );
var toReversed = require( '@stdlib/ndarray-to-reversed' );
var x = uniform( [ 3, 3, 3 ], -10.0, 10.0 );
console.log( ndarray2array( x ) );
var y = toReversed( x );
console.log( ndarray2array( y ) );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
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
