Skip to content

Latest commit

 

History

History
108 lines (67 loc) · 2.28 KB

File metadata and controls

108 lines (67 loc) · 2.28 KB

srev

Reverse the elements of a one-dimensional single-precision floating-point ndarray.

Usage

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

srev( arrays )

Reverses the elements of a one-dimensional single-precision floating-point ndarray in-place.

var Float32Array = require( '@stdlib/array/float32' );
var ndarray = require( '@stdlib/ndarray/base/ctor' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );

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

srev( [ x ] );
// x => <ndarray>[ 3.0, 2.0, 1.0 ]

var arr = ndarray2array( x );
// returns [ 3.0, 2.0, 1.0 ]

The function has the following parameters:

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

Examples

var Float32Array = require( '@stdlib/array/float32' );
var ndarray = require( '@stdlib/ndarray/base/ctor' );
var srev = require( '@stdlib/blas/ext/base/ndarray/srev' );

var xbuf;
var x;
var i;

xbuf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
x = new ndarray( 'float32', xbuf, [ 6 ], [ -1 ], 5, 'row-major' );

srev( [ x ] );

console.log( 'x:' );
for ( i = 0; i < 6; i++ ) {
    console.log( x.get( i ) );
}