@stdlib/ndarray-concat1d
v0.1.1
Published
Return a one-dimensional ndarray formed by concatenating provided input arguments.
Readme
concat1d
Return a one-dimensional ndarray formed by concatenating provided input arguments.
Installation
npm install @stdlib/ndarray-concat1dUsage
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 trueThe 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 ) );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.
