@stdlib/ndarray-push
v0.1.1
Published
Return an ndarray formed by appending provided scalar values to a one-dimensional input ndarray.
Readme
push
Return a one-dimensional ndarray formed by appending provided scalar values to a one-dimensional input ndarray.
Installation
npm install @stdlib/ndarray-pushUsage
var push = require( '@stdlib/ndarray-push' );push( x, ...values )
Returns a one-dimensional ndarray formed by appending provided scalar values to a one-dimensional input ndarray.
var array = require( '@stdlib/ndarray-array' );
var x = array( [ 1.0, 2.0, 3.0, 4.0 ] );
var out = push( x, 5.0, 6.0, 7.0 );
// returns <ndarray>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ]The function accepts the following arguments:
- x: input ndarray. Must be one-dimensional.
- ...values: scalar values to append.
push.assign( x, ...values, out )
Appends scalar values to a one-dimensional input ndarray and assigns the result to a one-dimensional output ndarray.
var array = require( '@stdlib/ndarray-array' );
var zeros = require( '@stdlib/ndarray-zeros' );
var x = array( [ 1.0, 2.0, 3.0, 4.0 ] );
var y = zeros( [ 7 ] );
var out = push.assign( x, 5.0, 6.0, 7.0, y );
// returns <ndarray>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ]
var bool = ( out === y );
// returns trueThe function accepts the following arguments:
- x: input ndarray. Must be one-dimensional.
- ...values: scalar values to append.
- out: output ndarray. Must be one-dimensional.
Notes
Examples
var discreteUniform = require( '@stdlib/random-discrete-uniform' );
var ndarray2array = require( '@stdlib/ndarray-to-array' );
var push = require( '@stdlib/ndarray-push' );
var opts = {
'dtype': 'generic'
};
var x = discreteUniform( [ 6 ], 0, 10, opts );
console.log( ndarray2array( x ) );
var out = push( x, 12, 14 );
console.log( ndarray2array( out ) );Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
