Skip to content

Latest commit

 

History

History
124 lines (78 loc) · 3.1 KB

File metadata and controls

124 lines (78 loc) · 3.1 KB

scircshift

Circularly shift the elements of a one-dimensional single-precision floating-point ndarray by a specified number of positions.

Usage

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

scircshift( arrays )

Circularly shifts the elements of a one-dimensional single-precision floating-point ndarray by a specified number of positions.

var Float32Array = require( '@stdlib/array/float32' );
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
var ndarray = require( '@stdlib/ndarray/base/ctor' );

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

var k = scalar2ndarray( 2, {
    'dtype': 'generic'
});

var out = scircshift( [ x, k ] );
// returns <ndarray>[ 4.0, 5.0, 1.0, 2.0, 3.0 ]

The function has the following parameters:

  • arrays: array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray specifying the number of positions to shift.

Notes

  • The input ndarray is shifted in-place (i.e., the input ndarray is mutated).

Examples

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var ndarray = require( '@stdlib/ndarray/base/ctor' );
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' );
var scircshift = require( '@stdlib/blas/ext/base/ndarray/scircshift' );

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

var k = scalar2ndarray( 3, {
    'dtype': 'generic'
});
console.log( 'Shift:', ndarraylike2scalar( k ) );

scircshift( [ x, k ] );
console.log( ndarray2array( x ) );