Skip to content

Latest commit

 

History

History
115 lines (70 loc) · 2.51 KB

File metadata and controls

115 lines (70 loc) · 2.51 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 ndarray2array = require( '@stdlib/ndarray/to-array' );

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

grev( [ x ] );

console.log( ndarray2array( x ) );
// => [ 3.0, 2.0, 1.0 ]

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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var ndarray = require( '@stdlib/ndarray/base/ctor' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var grev = require( '@stdlib/blas/ext/base/ndarray/grev' );

var xbuf = discreteUniform( 10, -50, 50, {
    'dtype': 'float64'
});
var x = new ndarray( 'float64', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
console.log( ndarray2array( x ) );

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