|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 The Stdlib Authors. |
| 6 | +
|
| 7 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +you may not use this file except in compliance with the License. |
| 9 | +You may obtain a copy of the License at |
| 10 | +
|
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +
|
| 13 | +Unless required by applicable law or agreed to in writing, software |
| 14 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +See the License for the specific language governing permissions and |
| 17 | +limitations under the License. |
| 18 | +
|
| 19 | +--> |
| 20 | + |
| 21 | +# concat1d |
| 22 | + |
| 23 | +> Return a one-dimensional [ndarray][@stdlib/ndarray/ctor] formed by concatenating provided input arguments. |
| 24 | +
|
| 25 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 26 | + |
| 27 | +<section class="intro"> |
| 28 | + |
| 29 | +</section> |
| 30 | + |
| 31 | +<!-- /.intro --> |
| 32 | + |
| 33 | +<!-- Package usage documentation. --> |
| 34 | + |
| 35 | +<section class="usage"> |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +```javascript |
| 40 | +var concat1d = require( '@stdlib/ndarray/concat1d' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### concat1d( ...arrays ) |
| 44 | + |
| 45 | +Returns a one-dimensional [ndarray][@stdlib/ndarray/ctor] formed by concatenating provided input arguments. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var array = require( '@stdlib/ndarray/array' ); |
| 49 | +var ndarray2array = require( '@stdlib/ndarray/to-array' ); |
| 50 | + |
| 51 | +var x = array( [ -1.0, 2.0, 3.0, 4.0 ] ); |
| 52 | +var y = array( [ -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ] ); |
| 53 | + |
| 54 | +var out = concat1d( x, y ); |
| 55 | +// returns <ndarray> |
| 56 | + |
| 57 | +var arr = ndarray2array( out ); |
| 58 | +// returns [ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ] |
| 59 | +``` |
| 60 | + |
| 61 | +The function accepts the following arguments: |
| 62 | + |
| 63 | +- **...arrays**: inputs to concatenate. May be passed as separate arguments or an array of arguments. Each argument must either be a one-dimensional [ndarray][@stdlib/ndarray/ctor], a zero-dimensional[ndarray][@stdlib/ndarray/ctor], or a scalar value. |
| 64 | + |
| 65 | +The data type of the output [ndarray][@stdlib/ndarray/ctor] is determined by applying [type promotion rules][@stdlib/ndarray/promotion-rules]. If provided [ndarrays][@stdlib/ndarray/ctor] having different [memory layouts][@stdlib/ndarray/orders] or only scalar inputs, the output [ndarray][@stdlib/ndarray/ctor] has the [default memory layout][@stdlib/ndarray/defaults]. |
| 66 | + |
| 67 | +#### concat1d.assign( ...arrays, out ) |
| 68 | + |
| 69 | +Concatenates provided input arguments and assigns the result to a provided one-dimensional output [ndarray][@stdlib/ndarray/ctor]. |
| 70 | + |
| 71 | +```javascript |
| 72 | +var array = require( '@stdlib/ndarray/array' ); |
| 73 | +var zeros = require( '@stdlib/ndarray/zeros' ); |
| 74 | +var ndarray2array = require( '@stdlib/ndarray/to-array' ); |
| 75 | + |
| 76 | +var x = array( [ -1.0, 2.0, 3.0, 4.0 ] ); |
| 77 | +var y = array( [ -5.0, 6.0, -7.0, -8.0 ] ); |
| 78 | +var z = zeros( [ 8 ] ); |
| 79 | + |
| 80 | +var out = concat1d.assign( x, y, z ); |
| 81 | +// returns <ndarray> |
| 82 | + |
| 83 | +var bool = ( out === z ); |
| 84 | +// returns true |
| 85 | + |
| 86 | +var arr = ndarray2array( z ); |
| 87 | +// returns [ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.0 ] |
| 88 | +``` |
| 89 | + |
| 90 | +The function accepts the following arguments: |
| 91 | + |
| 92 | +- **...arrays**: inputs to concatenate. May be passed as separate arguments or an array of arguments. Each argument must either be a one-dimensional [ndarray][@stdlib/ndarray/ctor], a zero-dimensional[ndarray][@stdlib/ndarray/ctor], or a scalar value. |
| 93 | +- **out**: output [ndarray][@stdlib/ndarray/ctor]. |
| 94 | + |
| 95 | +</section> |
| 96 | + |
| 97 | +<!-- /.usage --> |
| 98 | + |
| 99 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 100 | + |
| 101 | +<section class="notes"> |
| 102 | + |
| 103 | +</section> |
| 104 | + |
| 105 | +<!-- /.notes --> |
| 106 | + |
| 107 | +<!-- Package usage examples. --> |
| 108 | + |
| 109 | +<section class="examples"> |
| 110 | + |
| 111 | +## Examples |
| 112 | + |
| 113 | +```javascript |
| 114 | +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); |
| 115 | +var array = require( '@stdlib/ndarray/array' ); |
| 116 | +var ndarray2array = require( '@stdlib/ndarray/to-array' ); |
| 117 | +var concat1d = require( '@stdlib/ndarray/concat1d' ); |
| 118 | + |
| 119 | +var opts = { |
| 120 | + 'dtype': 'generic' |
| 121 | +}; |
| 122 | +var x = array( discreteUniform( 6, 0, 10, opts ), opts ); |
| 123 | +console.log( ndarray2array( x ) ); |
| 124 | + |
| 125 | +var y = array( discreteUniform( 8, 0, 10, opts ), opts ); |
| 126 | +console.log( ndarray2array( y ) ); |
| 127 | + |
| 128 | +var out = concat1d( x, y ); |
| 129 | +console.log( ndarray2array( out ) ); |
| 130 | +``` |
| 131 | + |
| 132 | +</section> |
| 133 | + |
| 134 | +<!-- /.examples --> |
| 135 | + |
| 136 | +<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 137 | + |
| 138 | +<section class="references"> |
| 139 | + |
| 140 | +</section> |
| 141 | + |
| 142 | +<!-- /.references --> |
| 143 | + |
| 144 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 145 | + |
| 146 | +<section class="related"> |
| 147 | + |
| 148 | +</section> |
| 149 | + |
| 150 | +<!-- /.related --> |
| 151 | + |
| 152 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 153 | + |
| 154 | +<section class="links"> |
| 155 | + |
| 156 | +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/ctor |
| 157 | + |
| 158 | +[@stdlib/ndarray/orders]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/orders |
| 159 | + |
| 160 | +[@stdlib/ndarray/defaults]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/defaults |
| 161 | + |
| 162 | +[@stdlib/ndarray/promotion-rules]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/promotion-rules |
| 163 | + |
| 164 | +</section> |
| 165 | + |
| 166 | +<!-- /.links --> |
0 commit comments