Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

concat1d

Return a one-dimensional ndarray formed by concatenating provided input arguments.

Usage

var concat1d = require( '@stdlib/ndarray/concat1d' );

concat1d( ...arrays )

Returns a one-dimensional ndarray formed by concatenating provided input arguments.

var array = require( '@stdlib/ndarray/array' );

var x = array( [ -1.0, 2.0, 3.0, 4.0 ] );
var y = array( [ -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ] );

var out = concat1d( x, y );
// returns <ndarray>[ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ]

The function accepts the following arguments:

  • ...arrays: inputs to concatenate. May be passed as separate arguments or an array of arguments. Each argument must either be a one-dimensional ndarray, a zero-dimensional ndarray, or a scalar value.

The data type of the output ndarray is determined by applying type promotion rules. If provided ndarrays having different memory layouts or only scalar inputs, the output ndarray has the default memory layout.

concat1d.assign( ...arrays, out )

Concatenates provided input arguments and assigns the result to a provided 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 = array( [ -5.0, 6.0, -7.0, -8.0 ] );
var z = zeros( [ 8 ] );

var out = concat1d.assign( x, y, z );
// returns <ndarray>[ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.0 ]

var bool = ( out === z );
// returns true

The function accepts the following arguments:

  • ...arrays: inputs to concatenate. May be passed as separate arguments or an array of arguments. Each argument must either be a one-dimensional ndarray, a zero-dimensional ndarray, or a scalar value.
  • out: output ndarray.

Examples

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var array = require( '@stdlib/ndarray/array' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var concat1d = require( '@stdlib/ndarray/concat1d' );

var opts = {
    'dtype': 'generic'
};
var x = array( discreteUniform( 6, 0, 10, opts ), opts );
console.log( ndarray2array( x ) );

var y = array( discreteUniform( 8, 0, 10, opts ), opts );
console.log( ndarray2array( y ) );

var out = concat1d( x, y );
console.log( ndarray2array( out ) );