Concatenate a list of one-dimensional or two-dimensional ndarrays as rows.
var rowcat = require( '@stdlib/ndarray/rowcat' );Concatenates a list of one-dimensional or two-dimensional ndarrays as rows.
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 = rowcat( [ x, y ] );
// returns <ndarray>[ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ], [ 7.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 rows 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 = rowcat.assign( [ x, y ], z );
// returns <ndarray>[ [ 1.0, 2.0, 3.0 ], [ 4.0, 5.0, 6.0 ], [ 7.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 rowcat = require( '@stdlib/ndarray/rowcat' );
var x = discreteUniform( [ 3 ], 0, 10, {
'dtype': 'generic'
});
console.log( ndarray2array( x ) );
var y = discreteUniform( [ 2, 3 ], 0, 10, {
'dtype': 'generic'
});
console.log( ndarray2array( y ) );
var out = rowcat( [ x, y ] );
console.log( ndarray2array( out ) );