/* * @license Apache-2.0 * * Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // TypeScript Version: 4.1 /// import { ArrayLike } from '@stdlib/types/array'; import { typedndarray } from '@stdlib/types/ndarray'; /** * Input argument. */ type Input = typedndarray | T; /** * Interface describing `concat1d`. */ interface Concat1d { /** * Returns a one-dimensional ndarray formed by concatenating provided input arguments. * * @param arrays - input arguments * @returns output ndarray * * @example * var array = require( './../../../array' ); * var ndarray2array = require( './../../../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 [ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ] */ ( arrays: Array> ): typedndarray; // FIXME: this is a tricky one to type correctly, as the actual output dtype depends on type promotion rules /** * Returns a one-dimensional ndarray formed by concatenating provided input arguments. * * @param arg - first argument * @param arrays - remaining input arguments * @returns output ndarray * * @example * var array = require( './../../../array' ); * var ndarray2array = require( './../../../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 [ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ] */ ( arg: Input, ...arrays: Array> ): typedndarray; // FIXME: this is a tricky one to type correctly, as the actual output dtype depends on type promotion rules /** * Concatenates provided input arguments and assigns the result to a provided one-dimensional output ndarray. * * @param args - input arguments * @param out - output ndarray * @returns output ndarray * * @example * var array = require( './../../../array' ); * var empty = require( './../../../empty' ); * var ndarray2array = require( './../../../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 z = empty( [ 10 ] ); * * var out = concat1d.assign( [ x, y ], z ); * // returns [ -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 */ assign = typedndarray>( args: ArrayLike>, out: V ): V; /** * Concatenates provided input arguments and assigns the result to a provided one-dimensional output ndarray. * * @param arg1 - first argument * @param arg2 - second argument * @param args - remaining input arguments * @param out - output ndarray * @returns output ndarray * * @example * var array = require( './../../../array' ); * var empty = require( './../../../empty' ); * var ndarray2array = require( './../../../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 z = empty( [ 10 ] ); * * var out = concat1d.assign( x, y, z ); * // returns [ -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 */ assign = typedndarray>( arg1: Input, arg2: Input | V, ...args: Array | V> ): V; // FIXME: in order to more robustly return a correct output type here, we'd likely need to use overloads with varying arity. The issue here is that `V` needs to be the last argument, which is not captured here. } /** * Returns a one-dimensional ndarray formed by concatenating provided input arguments. * * @param arrays - input arguments * @returns output ndarray * * @example * 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 [ -1.0, 2.0, 3.0, 4.0, -5.0, 6.0, -7.0, -8.0, 9.0, -10.0 ] * * @example * var array = require( '@stdlib/ndarray/array' ); * var empty = require( '@stdlib/ndarray/empty' ); * 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 z = empty( [ 10 ] ); * * var out = concat1d.assign( [ x, y ], z ); * // returns [ -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 */ declare var concat1d: Concat1d; // EXPORTS // export = concat1d;