Concatenate a list of ndarrays along the second-to-last dimension.
var vconcat = require( '@stdlib/ndarray/vconcat' );Concatenates a list of ndarrays along the second-to-last dimension.
var array = require( '@stdlib/ndarray/array' );
var x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] );
// returns <ndarray>[ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]
var y = array( [ [ 5.0, 6.0 ], [ 7.0, 8.0 ], [ 9.0, 10.0 ] ] );
// returns <ndarray>[ [ 5.0, 6.0 ], [ 7.0, 8.0 ], [ 9.0, 10.0 ] ]
var out = vconcat( [ 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: a list of input ndarrays. The data type of the output ndarray is determined by applying type promotion rules to the list of input ndarrays. If provided ndarrays having different memory layouts, the output ndarray has the default order.
Concatenates a list of ndarrays along the second-to-last dimension and assigns results to a provided 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 ] ] );
// returns <ndarray>[ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]
var y = array( [ [ 5.0, 6.0 ], [ 7.0, 8.0 ], [ 9.0, 10.0 ] ] );
// returns <ndarray>[ [ 5.0, 6.0 ], [ 7.0, 8.0 ], [ 9.0, 10.0 ] ]
var z = zeros( [ 5, 2 ] );
// returns <ndarray>[ [ 0.0, 0.0 ], [ 0.0, 0.0 ], [ 0.0, 0.0 ], [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]
var out = vconcat.assign( [ x, y ], z );
// returns <ndarray>[ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ], [ 7.0, 8.0 ], [ 9.0, 10.0 ] ]
var bool = ( out === z );
// returns trueThe function accepts the following arguments:
- Input ndarrays must have more than one dimension.
var discreteUniform = require( '@stdlib/random/discrete-uniform' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var vconcat = require( '@stdlib/ndarray/vconcat' );
var x = discreteUniform( [ 2, 3 ], 0, 10, {
'dtype': 'generic'
});
console.log( ndarray2array( x ) );
var y = discreteUniform( [ 3, 3 ], 0, 10, {
'dtype': 'generic'
});
console.log( ndarray2array( y ) );
var out = vconcat( [ x, y ] );
console.log( ndarray2array( out ) );