Skip to content

Latest commit

 

History

History
111 lines (66 loc) · 2.3 KB

File metadata and controls

111 lines (66 loc) · 2.3 KB

grev

Reverse a one-dimensional ndarray in-place.

Usage

var grev = require( '@stdlib/blas/ext/base/ndarray/grev' );

grev( arrays )

Reverses a one-dimensional ndarray in-place.

var Float64Array = require( '@stdlib/array/float64' );
var ndarray = require( '@stdlib/ndarray/base/ctor' );

var xbuf = new Float64Array( [ 1.0, 2.0, 3.0 ] );
var x = new ndarray( 'float64', xbuf, [ 3 ], [ 1 ], 0, 'row-major' );

var out = grev( [ x ] );
// returns <ndarray>[ 3.0, 2.0, 1.0 ]

var bool = ( out === x );
// returns true

The function has the following parameters:

  • arrays: array-like object containing a one-dimensional input ndarray.

Notes

  • If provided an empty one-dimensional input ndarray, the function returns the output ndarray unchanged.

Examples

var uniform = require( '@stdlib/random/uniform' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var grev = require( '@stdlib/blas/ext/base/ndarray/grev' );

var x = uniform( [10], -50, 50 );
console.log( ndarray2array( x ) );

grev( [ x ] );
console.log( ndarray2array( x ) );