| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Return an array containing a read-only truncated view of an input ndarray and a read-only view of the first element(s) along a specified dimension.
var shift = require( '@stdlib/ndarray/shift' );Returns an array containing a read-only truncated view of an input ndarray and a read-only view of the first element(s) along a specified 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 = shift( x );
// returns [ <ndarray>, <ndarray> ]
arr = ndarray2array( y[ 0 ] );
// returns [ [ 2.0 ], [ 4.0 ], [ 6.0 ] ]
arr = ndarray2array( y[ 1 ] );
// returns [ [ 1.0 ], [ 3.0 ], [ 5.0 ] ]The function accepts the following arguments:
The function supports the following options:
By default, the function performs operation along the last dimension of the input ndarray. To perform operation along a specific dimension, provide the dim option.
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 opts = {
'dim': 0
};
var y = shift( x, opts );
// returns [ <ndarray>, <ndarray> ]
arr = ndarray2array( y[ 0 ] );
// returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
arr = ndarray2array( y[ 1 ] );
// returns [ [ 1.0, 2.0 ] ]var array = require( '@stdlib/ndarray/array' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var zeroTo = require( '@stdlib/array/zero-to' );
var shift = require( '@stdlib/ndarray/shift' );
// Create an ndarray:
var x = array( zeroTo( 27 ), {
'shape': [ 3, 3, 3 ]
});
console.log( ndarray2array( x ) );
// Remove the first column from each matrix:
var y = shift( x );
console.log( ndarray2array( y[ 0 ] ) );
console.log( ndarray2array( y[ 1 ] ) );| Back | FazBrowse Home | New Git URL |