Concatenate a list of one-dimensional or two-dimensional ndarrays as columns.
var colcat = require( '@stdlib/ndarray/colcat' );Concatenates a list of one-dimensional or two-dimensional ndarrays as columns.
var array = require( '@stdlib/ndarray/array' );
var x = array( [ 1.0, 2.0, 3.0 ] );
// returns <ndarray>[ 1.0, 2.0, 3.0 ]
var y = array( [ [ 4.0, 5.0 ], [ 6.0, 7.0 ], [ 8.0, 9.0 ] ] );
// returns <ndarray>[ [ 4.0, 5.0 ], [ 6.0, 7.0 ], [ 8.0, 9.0 ] ]
var out = colcat( [ x, y ] );
// returns <ndarray>[ [ 1.0, 4.0, 5.0 ], [ 2.0, 6.0, 7.0 ], [ 3.0, 8.0, 9.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 one-dimensional or two-dimensional ndarrays as columns 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 ] );
// returns <ndarray>[ 1.0, 2.0, 3.0 ]
var y = array( [ [ 4.0, 5.0 ], [ 6.0, 7.0 ], [ 8.0, 9.0 ] ] );
// returns <ndarray>[ [ 4.0, 5.0 ], [ 6.0, 7.0 ], [ 8.0, 9.0 ] ]
var z = zeros( [ 3, 3 ] );
// returns <ndarray>[ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ]
var out = colcat.assign( [ x, y ], z );
// returns <ndarray>[ [ 1.0, 4.0, 5.0 ], [ 2.0, 6.0, 7.0 ], [ 3.0, 8.0, 9.0 ] ]
var bool = ( out === z );
// returns trueThe function accepts the following arguments:
var discreteUniform = require( '@stdlib/random/discrete-uniform' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var colcat = require( '@stdlib/ndarray/colcat' );
var x = discreteUniform( [ 3 ], 0, 10, {
'dtype': 'generic'
});
console.log( ndarray2array( x ) );
var y = discreteUniform( [ 3, 2 ], 0, 10, {
'dtype': 'generic'
});
console.log( ndarray2array( y ) );
var out = colcat( [ x, y ] );
console.log( ndarray2array( out ) );