Skip to content

Latest commit

 

History

History
107 lines (66 loc) · 2.36 KB

File metadata and controls

107 lines (66 loc) · 2.36 KB

gfill

Fill a one-dimensional ndarray with a specified value.

Usage

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

gfill( x, alpha )

Fills a one-dimensional ndarray with a specified value.

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

var xbuf = [ 1.0, 2.0, 3.0, 4.0 ];
var x = new ndarray( 'generic', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );

var out = gfill( x, 5.0 );
// returns <ndarray>[ 5.0, 5.0, 5.0, 5.0 ]

The function has the following parameters:

  • x: input ndarray.
  • alpha: fill value.

Notes

  • The function modifies the input ndarray in-place.
  • The function supports ndarrays having non-unit strides and non-zero offsets.

Examples

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var ndarray = require( '@stdlib/ndarray/base/ctor' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var gfill = require( '@stdlib/blas/ext/base/ndarray/gfill' );

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

gfill( x, 5.0 );
console.log( ndarray2array( x ) );