Skip to content

Latest commit

 

History

History
110 lines (66 loc) · 2.49 KB

File metadata and controls

110 lines (66 loc) · 2.49 KB

goneTo

Fill a one-dimensional ndarray with linearly spaced numeric elements which increment by 1 starting from one.

Usage

var goneTo = require( '@stdlib/blas/ext/base/ndarray/gone-to' );

goneTo( arrays )

Fills a one-dimensional ndarray with linearly spaced numeric elements which increment by 1 starting from one.

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

var xbuf = [ 0.0, 0.0, 0.0, 0.0 ];
var x = new ndarray( 'generic', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
// returns <ndarray>[ 0.0, 0.0, 0.0, 0.0 ]

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

The function has the following parameters:

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

Notes

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

Examples

var zeros = require( '@stdlib/array/zeros' );
var ndarray = require( '@stdlib/ndarray/base/ctor' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var goneTo = require( '@stdlib/blas/ext/base/ndarray/gone-to' );

var xbuf = zeros( 10, 'generic' );
var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
console.log( ndarray2array( x ) );

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