Skip to content

Latest commit

 

History

History
172 lines (103 loc) · 5.56 KB

File metadata and controls

172 lines (103 loc) · 5.56 KB

vconcat

Concatenate a list of ndarrays along the second-to-last dimension.

Usage

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

vconcat( arrays )

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:

vconcat.assign( arrays, out )

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 true

The function accepts the following arguments:

  • Input ndarrays must have more than one dimension.

Examples

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