Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

push

Return a one-dimensional ndarray formed by appending provided scalar values to a one-dimensional input ndarray.

Usage

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 true

The 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 ) );