Skip to content

Return a one-dimensional ndarray formed by concatenating provided input arguments.

License

Notifications You must be signed in to change notification settings

stdlib-js/ndarray-concat1d

 
 

Repository files navigation

About stdlib...

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

concat1d

NPM version Build Status Coverage Status

Return a one-dimensional ndarray formed by concatenating provided input arguments.

Usage

To use in Observable,

concat1d = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-concat1d@umd/browser.js' )

To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:

var concat1d = require( 'path/to/vendor/umd/ndarray-concat1d/index.js' )

To include the bundle in a webpage,

<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-concat1d@umd/browser.js"></script>

If no recognized module system is present, access bundle contents via the global scope:

<script type="text/javascript">
(function () {
    window.concat1d;
})();
</script>

concat1d( ...arrays )

Returns a one-dimensional ndarray formed by concatenating provided input arguments.

var array = require( '@stdlib/ndarray-array' );
var ndarray2array = require( '@stdlib/ndarray-to-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>

var arr = ndarray2array( out );
// returns [ -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 ndarray2array = require( '@stdlib/ndarray-to-array' );

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>

var bool = ( out === z );
// returns true

var arr = ndarray2array( z );
// returns [ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.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.
  • out: output ndarray.

Examples

<!DOCTYPE html>
<html lang="en">
<body>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/stdlib-js/random-array-discrete-uniform@umd/browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-array@umd/browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@umd/browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-concat1d@umd/browser.js"></script>
<script type="text/javascript">
(function () {

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

})();
</script>
</body>
</html>

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

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2025. The Stdlib Authors.