diff --git a/lib/node_modules/@stdlib/ndarray/array/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/array/docs/types/index.d.ts index 57de67b6f8b9..e231cb6bed37 100644 --- a/lib/node_modules/@stdlib/ndarray/array/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/array/docs/types/index.d.ts @@ -20,17 +20,37 @@ /// -import { ArrayLike } from '@stdlib/types/array'; -import { DataType, typedndarray, Mode, Order, Shape } from '@stdlib/types/ndarray'; +/* eslint-disable max-lines */ + +import { ArrayLike, AccessorArrayLike, Complex128Array, Complex64Array, BooleanArray } from '@stdlib/types/array'; +import { ndarray, typedndarray, genericndarray, float64ndarray, float32ndarray, complex128ndarray, complex64ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, DataType, Float64DataType, Float32DataType, Complex128DataType, Complex64DataType, Int32DataType, Int16DataType, Int8DataType, Uint32DataType, Uint16DataType, Uint8DataType, Uint8cDataType, BooleanDataType, GenericDataType, Mode, Order, Shape } from '@stdlib/types/ndarray'; /** -* Interface defining function options. +* Data source. +* +* ## Notes +* +* - A data source may be a generic array, a typed array, an accessor array, or an ndarray. */ -interface Options { +type DataSource = ArrayLike | AccessorArrayLike | ndarray; // eslint-disable-line @typescript-eslint/no-explicit-any + +/** +* Interface defining function options which do not affect the output data type. +*/ +interface BaseOptions { /** - * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) (default: 'float64'). + * Array shape. */ - dtype?: DataType; + shape?: Shape; + + /** + * Data source. + * + * ## Notes + * + * - If provided along with a `buffer` argument, the argument takes precedence. + */ + buffer?: DataSource; /** * Specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major'). @@ -74,68 +94,171 @@ interface Options { } /** -* Interface describing function options. +* Interface defining function options. */ -interface OptionsWithShape extends Options { +interface Options extends BaseOptions { /** - * Array shape. + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) (default: 'float64'). */ - shape: Shape; + dtype?: DataType; +} +/** +* Interface defining options when `dtype` is `'float64'`. +*/ +interface Float64Options extends BaseOptions { /** - * Data source. - * - * ## Notes - * - * - If provided along with a `buffer` argument, the argument takes precedence. + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). */ - buffer?: ArrayLike; + dtype: Float64DataType; } /** -* Interface describing function options. +* Interface defining options when `dtype` is `'float32'`. */ -interface OptionsWithBuffer extends Options { +interface Float32Options extends BaseOptions { /** - * Array shape. + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). */ - shape?: Shape; + dtype: Float32DataType; +} +/** +* Interface defining options when `dtype` is `'complex128'`. +*/ +interface Complex128Options extends BaseOptions { /** - * Data source. - * - * ## Notes - * - * - If provided along with a `buffer` argument, the argument takes precedence. + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). + */ + dtype: Complex128DataType; +} + +/** +* Interface defining options when `dtype` is `'complex64'`. +*/ +interface Complex64Options extends BaseOptions { + /** + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). + */ + dtype: Complex64DataType; +} + +/** +* Interface defining options when `dtype` is `'int32'`. +*/ +interface Int32Options extends BaseOptions { + /** + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). + */ + dtype: Int32DataType; +} + +/** +* Interface defining options when `dtype` is `'int16'`. +*/ +interface Int16Options extends BaseOptions { + /** + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). + */ + dtype: Int16DataType; +} + +/** +* Interface defining options when `dtype` is `'int8'`. +*/ +interface Int8Options extends BaseOptions { + /** + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). + */ + dtype: Int8DataType; +} + +/** +* Interface defining options when `dtype` is `'uint32'`. +*/ +interface Uint32Options extends BaseOptions { + /** + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). + */ + dtype: Uint32DataType; +} + +/** +* Interface defining options when `dtype` is `'uint16'`. +*/ +interface Uint16Options extends BaseOptions { + /** + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). + */ + dtype: Uint16DataType; +} + +/** +* Interface defining options when `dtype` is `'uint8'`. +*/ +interface Uint8Options extends BaseOptions { + /** + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). + */ + dtype: Uint8DataType; +} + +/** +* Interface defining options when `dtype` is `'uint8c'`. +*/ +interface Uint8COptions extends BaseOptions { + /** + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). + */ + dtype: Uint8cDataType; +} + +/** +* Interface defining options when `dtype` is `'bool'`. +*/ +interface BoolOptions extends BaseOptions { + /** + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). */ - buffer: ArrayLike; + dtype: BooleanDataType; } /** -* Interface describing function options. +* Interface defining options when `dtype` is `'generic'`. */ -interface ExtendedOptions extends Options { +interface GenericOptions extends BaseOptions { + /** + * Underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data). + */ + dtype: GenericDataType; +} + +/** +* Interface describing options which must include an array shape. +*/ +interface OptionsWithShape { /** * Array shape. */ - shape?: Shape; + shape: Shape; +} +/** +* Interface describing options which must include a data source. +*/ +interface OptionsWithBuffer { /** * Data source. - * - * ## Notes - * - * - If provided along with a `buffer` argument, the argument takes precedence. */ - buffer?: ArrayLike; + buffer: T; } /** -* Returns a multidimensional array. +* Returns a multidimensional array having a data type which is either explicitly specified via a `dtype` option or inferred from a provided typed array data source. * * @param options - function options * @param options.buffer - data source -* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) (default: 'float64') +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) * @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') * @param options.shape - array shape * @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') @@ -152,19 +275,1559 @@ interface ExtendedOptions extends Options { * @returns ndarray instance * * @example -* var opts = { -* 'buffer': [ [ 1, 2 ], [ 3, 4 ] ], -* 'dtype': 'generic', -* 'flatten': false -* }; +* var arr = array({ +* 'shape': [ 2, 2 ], +* 'dtype': 'float32' +* }); +* // returns * -* var arr = array( opts ); +* var dt = arr.dtype; +* // returns 'float32' +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var arr = array({ +* 'buffer': new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ), +* 'shape': [ 2, 2 ] +* }); * // returns * -* var v = arr.get( 0 ); -* // returns [ 1, 2 ] +* var dt = arr.dtype; +* // returns 'float32' +*/ +declare function array( options: ( Float32Options & ( OptionsWithShape | OptionsWithBuffer ) ) | ( BaseOptions & OptionsWithBuffer ) ): float32ndarray; + +/** +* Returns a multidimensional array having a data type which is either explicitly specified via a `dtype` option or inferred from a provided typed array data source. +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var arr = array({ +* 'shape': [ 2 ], +* 'dtype': 'complex128' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'complex128' +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var arr = array({ +* 'buffer': new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ), +* 'shape': [ 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'complex128' +*/ +declare function array( options: ( Complex128Options & ( OptionsWithShape | OptionsWithBuffer ) ) | ( BaseOptions & OptionsWithBuffer ) ): complex128ndarray; + +/** +* Returns a multidimensional array having a data type which is either explicitly specified via a `dtype` option or inferred from a provided typed array data source. +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var arr = array({ +* 'shape': [ 2 ], +* 'dtype': 'complex64' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'complex64' +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var arr = array({ +* 'buffer': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ), +* 'shape': [ 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'complex64' +*/ +declare function array( options: ( Complex64Options & ( OptionsWithShape | OptionsWithBuffer ) ) | ( BaseOptions & OptionsWithBuffer ) ): complex64ndarray; + +/** +* Returns a multidimensional array having a data type which is either explicitly specified via a `dtype` option or inferred from a provided typed array data source. +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var arr = array({ +* 'shape': [ 2, 2 ], +* 'dtype': 'int32' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int32' +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var arr = array({ +* 'buffer': new Int32Array( [ 1, 2, 3, 4 ] ), +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int32' +*/ +declare function array( options: ( Int32Options & ( OptionsWithShape | OptionsWithBuffer ) ) | ( BaseOptions & OptionsWithBuffer ) ): int32ndarray; + +/** +* Returns a multidimensional array having a data type which is either explicitly specified via a `dtype` option or inferred from a provided typed array data source. +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var arr = array({ +* 'shape': [ 2, 2 ], +* 'dtype': 'int16' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int16' +* +* @example +* var Int16Array = require( '@stdlib/array/int16' ); +* +* var arr = array({ +* 'buffer': new Int16Array( [ 1, 2, 3, 4 ] ), +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int16' +*/ +declare function array( options: ( Int16Options & ( OptionsWithShape | OptionsWithBuffer ) ) | ( BaseOptions & OptionsWithBuffer ) ): int16ndarray; + +/** +* Returns a multidimensional array having a data type which is either explicitly specified via a `dtype` option or inferred from a provided typed array data source. +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var arr = array({ +* 'shape': [ 2, 2 ], +* 'dtype': 'int8' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int8' +* +* @example +* var Int8Array = require( '@stdlib/array/int8' ); +* +* var arr = array({ +* 'buffer': new Int8Array( [ 1, 2, 3, 4 ] ), +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int8' +*/ +declare function array( options: ( Int8Options & ( OptionsWithShape | OptionsWithBuffer ) ) | ( BaseOptions & OptionsWithBuffer ) ): int8ndarray; + +/** +* Returns a multidimensional array having a data type which is either explicitly specified via a `dtype` option or inferred from a provided typed array data source. +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var arr = array({ +* 'shape': [ 2, 2 ], +* 'dtype': 'uint32' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint32' +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* +* var arr = array({ +* 'buffer': new Uint32Array( [ 1, 2, 3, 4 ] ), +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint32' +*/ +declare function array( options: ( Uint32Options & ( OptionsWithShape | OptionsWithBuffer ) ) | ( BaseOptions & OptionsWithBuffer ) ): uint32ndarray; + +/** +* Returns a multidimensional array having a data type which is either explicitly specified via a `dtype` option or inferred from a provided typed array data source. +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var arr = array({ +* 'shape': [ 2, 2 ], +* 'dtype': 'uint16' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint16' +* +* @example +* var Uint16Array = require( '@stdlib/array/uint16' ); +* +* var arr = array({ +* 'buffer': new Uint16Array( [ 1, 2, 3, 4 ] ), +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint16' +*/ +declare function array( options: ( Uint16Options & ( OptionsWithShape | OptionsWithBuffer ) ) | ( BaseOptions & OptionsWithBuffer ) ): uint16ndarray; + +/** +* Returns a multidimensional array having a data type which is either explicitly specified via a `dtype` option or inferred from a provided typed array data source. +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var arr = array({ +* 'shape': [ 2, 2 ], +* 'dtype': 'uint8' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint8' +* +* @example +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* var arr = array({ +* 'buffer': new Uint8Array( [ 1, 2, 3, 4 ] ), +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint8' +*/ +declare function array( options: ( Uint8Options & ( OptionsWithShape | OptionsWithBuffer ) ) | ( BaseOptions & OptionsWithBuffer ) ): uint8ndarray; + +/** +* Returns a multidimensional array having a data type which is either explicitly specified via a `dtype` option or inferred from a provided typed array data source. +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var arr = array({ +* 'shape': [ 2, 2 ], +* 'dtype': 'uint8c' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint8c' +* +* @example +* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +* +* var arr = array({ +* 'buffer': new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint8c' +*/ +declare function array( options: ( Uint8COptions & ( OptionsWithShape | OptionsWithBuffer ) ) | ( BaseOptions & OptionsWithBuffer ) ): uint8cndarray; + +/** +* Returns a multidimensional array having a data type which is either explicitly specified via a `dtype` option or inferred from a provided typed array data source. +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var arr = array({ +* 'shape': [ 2, 2 ], +* 'dtype': 'bool' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'bool' +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* +* var arr = array({ +* 'buffer': new BooleanArray( [ true, false, true, false ] ), +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'bool' +*/ +declare function array( options: ( BoolOptions & ( OptionsWithShape | OptionsWithBuffer ) ) | ( BaseOptions & OptionsWithBuffer ) ): boolndarray; + +/** +* Returns a multidimensional array having a generic data type. +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var opts = { +* 'buffer': [ [ 1, 2 ], [ 3, 4 ] ], +* 'dtype': 'generic', +* 'flatten': false +* }; +* +* var arr = array( opts ); +* // returns +* +* var v = arr.get( 0 ); +* // returns [ 1, 2 ] +*/ +declare function array( options: GenericOptions & ( OptionsWithShape | OptionsWithBuffer ) ): genericndarray; + +/** +* Returns a multidimensional array having the same data type as a provided ndarray data source. +* +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* +* var x = zeros( [ 2, 2 ], { +* 'dtype': 'int32' +* }); +* +* var arr = array({ +* 'buffer': x +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int32' +*/ +declare function array( options: BaseOptions & OptionsWithBuffer ): T; + +/** +* Returns a multidimensional array having the default data type. +* +* ## Notes +* +* - When not provided a `dtype` option, generic array data sources are cast to the default data type (`'float64'`). +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) (default: 'float64') +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var arr = array({ +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'float64' +* +* @example +* var arr = array({ +* 'buffer': [ [ 1, 2 ], [ 3, 4 ] ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'float64' +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var arr = array({ +* 'buffer': new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ), +* 'shape': [ 2, 2 ], +* 'dtype': 'float64' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'float64' +*/ +declare function array( options: ( Float64Options | BaseOptions ) & ( OptionsWithShape | OptionsWithBuffer ) ): float64ndarray; + +/** +* Returns a multidimensional array. +* +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) (default: 'float64') +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var opts = { +* 'buffer': [ [ 1, 2 ], [ 3, 4 ] ], +* 'dtype': 'generic', +* 'flatten': false +* }; +* +* var arr = array( opts ); +* // returns +* +* var v = arr.get( 0 ); +* // returns [ 1, 2 ] +*/ +declare function array( options: Options & ( OptionsWithShape | OptionsWithBuffer ) ): typedndarray; + +/** +* Returns a multidimensional array having a specified data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var arr = array( new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ), { +* 'dtype': 'float64' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'float64' +*/ +declare function array( buffer: DataSource, options: Float64Options ): float64ndarray; + +/** +* Returns a multidimensional array having a specified data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var arr = array( new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ), { +* 'dtype': 'float32' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'float32' +*/ +declare function array( buffer: DataSource, options: Float32Options ): float32ndarray; + +/** +* Returns a multidimensional array having a specified data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var arr = array( new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ), { +* 'dtype': 'complex128' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'complex128' +*/ +declare function array( buffer: DataSource, options: Complex128Options ): complex128ndarray; + +/** +* Returns a multidimensional array having a specified data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var arr = array( new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ), { +* 'dtype': 'complex64' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'complex64' +*/ +declare function array( buffer: DataSource, options: Complex64Options ): complex64ndarray; + +/** +* Returns a multidimensional array having a specified data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Int16Array = require( '@stdlib/array/int16' ); +* +* var arr = array( new Int16Array( [ 1, 2, 3, 4 ] ), { +* 'dtype': 'int32' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int32' +*/ +declare function array( buffer: DataSource, options: Int32Options ): int32ndarray; + +/** +* Returns a multidimensional array having a specified data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Int8Array = require( '@stdlib/array/int8' ); +* +* var arr = array( new Int8Array( [ 1, 2, 3, 4 ] ), { +* 'dtype': 'int16' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int16' +*/ +declare function array( buffer: DataSource, options: Int16Options ): int16ndarray; + +/** +* Returns a multidimensional array having a specified data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Int8Array = require( '@stdlib/array/int8' ); +* +* var arr = array( new Int8Array( [ 1, 2, 3, 4 ] ), { +* 'dtype': 'int8' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int8' +*/ +declare function array( buffer: DataSource, options: Int8Options ): int8ndarray; + +/** +* Returns a multidimensional array having a specified data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Uint16Array = require( '@stdlib/array/uint16' ); +* +* var arr = array( new Uint16Array( [ 1, 2, 3, 4 ] ), { +* 'dtype': 'uint32' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint32' +*/ +declare function array( buffer: DataSource, options: Uint32Options ): uint32ndarray; + +/** +* Returns a multidimensional array having a specified data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* var arr = array( new Uint8Array( [ 1, 2, 3, 4 ] ), { +* 'dtype': 'uint16' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint16' +*/ +declare function array( buffer: DataSource, options: Uint16Options ): uint16ndarray; + +/** +* Returns a multidimensional array having a specified data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* var arr = array( new Uint8Array( [ 1, 2, 3, 4 ] ), { +* 'dtype': 'uint8' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint8' +*/ +declare function array( buffer: DataSource, options: Uint8Options ): uint8ndarray; + +/** +* Returns a multidimensional array having a specified data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +* +* var arr = array( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), { +* 'dtype': 'uint8c' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint8c' +*/ +declare function array( buffer: DataSource, options: Uint8COptions ): uint8cndarray; + +/** +* Returns a multidimensional array having a specified data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* +* var arr = array( new BooleanArray( [ true, false, true, false ] ), { +* 'dtype': 'bool' +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'bool' +*/ +declare function array( buffer: DataSource, options: BoolOptions ): boolndarray; + +/** +* Returns a multidimensional array having a generic data type. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.dtype - underlying storage data type (if the input data is not of the same type, this option specifies the data type to which to cast the input data) +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var opts = { +* 'dtype': 'generic', +* 'flatten': false +* }; +* +* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ], opts ); +* // returns +* +* var v = arr.get( 0 ); +* // returns [ 1, 2 ] +*/ +declare function array( buffer: DataSource, options: GenericOptions ): genericndarray; + +/** +* Returns a multidimensional array having the same data type as a provided ndarray data source. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* +* var x = zeros( [ 2, 2 ], { +* 'dtype': 'int32' +* }); +* +* var arr = array( x ); +* // returns +* +* var dt = arr.dtype; +* // returns 'int32' +*/ +declare function array( buffer: T, options?: BaseOptions ): T; + +/** +* Returns a multidimensional array having a data type inferred from a provided typed array data source. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var arr = array( new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ), { +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'float32' +*/ +declare function array( buffer: Float32Array, options?: BaseOptions ): float32ndarray; + +/** +* Returns a multidimensional array having a data type inferred from a provided typed array data source. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var arr = array( new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ), { +* 'shape': [ 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'complex128' +*/ +declare function array( buffer: Complex128Array, options?: BaseOptions ): complex128ndarray; + +/** +* Returns a multidimensional array having a data type inferred from a provided typed array data source. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var arr = array( new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ), { +* 'shape': [ 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'complex64' +*/ +declare function array( buffer: Complex64Array, options?: BaseOptions ): complex64ndarray; + +/** +* Returns a multidimensional array having a data type inferred from a provided typed array data source. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var arr = array( new Int32Array( [ 1, 2, 3, 4 ] ), { +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int32' +*/ +declare function array( buffer: Int32Array, options?: BaseOptions ): int32ndarray; + +/** +* Returns a multidimensional array having a data type inferred from a provided typed array data source. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Int16Array = require( '@stdlib/array/int16' ); +* +* var arr = array( new Int16Array( [ 1, 2, 3, 4 ] ), { +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int16' +*/ +declare function array( buffer: Int16Array, options?: BaseOptions ): int16ndarray; + +/** +* Returns a multidimensional array having a data type inferred from a provided typed array data source. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Int8Array = require( '@stdlib/array/int8' ); +* +* var arr = array( new Int8Array( [ 1, 2, 3, 4 ] ), { +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'int8' +*/ +declare function array( buffer: Int8Array, options?: BaseOptions ): int8ndarray; + +/** +* Returns a multidimensional array having a data type inferred from a provided typed array data source. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* +* var arr = array( new Uint32Array( [ 1, 2, 3, 4 ] ), { +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint32' +*/ +declare function array( buffer: Uint32Array, options?: BaseOptions ): uint32ndarray; + +/** +* Returns a multidimensional array having a data type inferred from a provided typed array data source. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Uint16Array = require( '@stdlib/array/uint16' ); +* +* var arr = array( new Uint16Array( [ 1, 2, 3, 4 ] ), { +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint16' +*/ +declare function array( buffer: Uint16Array, options?: BaseOptions ): uint16ndarray; + +/** +* Returns a multidimensional array having a data type inferred from a provided typed array data source. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* var arr = array( new Uint8Array( [ 1, 2, 3, 4 ] ), { +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint8' +*/ +declare function array( buffer: Uint8Array, options?: BaseOptions ): uint8ndarray; + +/** +* Returns a multidimensional array having a data type inferred from a provided typed array data source. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +* +* var arr = array( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), { +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'uint8c' +*/ +declare function array( buffer: Uint8ClampedArray, options?: BaseOptions ): uint8cndarray; + +/** +* Returns a multidimensional array having a data type inferred from a provided typed array data source. +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* +* var arr = array( new BooleanArray( [ true, false, true, false ] ), { +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'bool' +*/ +declare function array( buffer: BooleanArray, options?: BaseOptions ): boolndarray; + +/** +* Returns a multidimensional array having the default data type. +* +* ## Notes +* +* - When not provided a `dtype` option, generic array data sources are cast to the default data type (`'float64'`). +* +* @param buffer - data source +* @param options - function options +* @param options.buffer - data source +* @param options.order - specifies the memory layout of the array as either row-major (C-style) or column-major (Fortran-style) (default: 'row-major') +* @param options.shape - array shape +* @param options.mode - specifies how to handle indices which exceed array dimensions (default: 'throw') +* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: [options.mode]) +* @param options.copy - boolean indicating whether to copy source data to a new data buffer (default: false) +* @param options.flatten - boolean indicating whether to automatically flatten generic array data sources (default: true) +* @param options.ndmin - minimum number of dimensions (default: 0) +* @param options.casting - casting rule used to determine what constitutes an acceptable cast (default: 'safe') +* @param options.readonly - boolean indicating whether an array should be read-only (default: false) +* @throws must provide valid options +* @throws must provide either an array shape, data source, or both +* @throws invalid cast +* @throws data source must be compatible with specified meta data +* @returns ndarray instance +* +* @example +* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); +* // returns +* +* var v = arr.get( 0, 0 ); +* // returns 1.0 +* +* var dt = arr.dtype; +* // returns 'float64' +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var arr = array( new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ), { +* 'shape': [ 2, 2 ] +* }); +* // returns +* +* var dt = arr.dtype; +* // returns 'float64' */ -declare function array( options: OptionsWithShape | OptionsWithBuffer ): typedndarray; +declare function array( buffer: DataSource, options?: BaseOptions ): float64ndarray; /** * Returns a multidimensional array. @@ -220,7 +1883,7 @@ declare function array( options: OptionsWithShape | OptionsWithBuff * var v = arr.get( 0, 0 ); * // returns 1.0 */ -declare function array( buffer: ArrayLike, options?: ExtendedOptions ): typedndarray; +declare function array( buffer: DataSource, options?: Options ): typedndarray; // EXPORTS // diff --git a/lib/node_modules/@stdlib/ndarray/array/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/array/docs/types/test.ts index b58b3d7cbaf9..b740b6039cce 100644 --- a/lib/node_modules/@stdlib/ndarray/array/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/array/docs/types/test.ts @@ -16,6 +16,10 @@ * limitations under the License. */ +import { DataType } from '@stdlib/types/ndarray'; +import zeros = require( '@stdlib/array/zeros' ); +import BooleanArray = require( '@stdlib/array/bool' ); +import ndzeros = require( '@stdlib/ndarray/zeros' ); import array = require( './index' ); @@ -29,6 +33,169 @@ import array = require( './index' ); array( { 'buffer': [ [ 1, 2 ], [ 3, 4 ] ] } ); // $ExpectType typedndarray } +// The function returns an ndarray having the default data type when not provided a data type... +{ + array( [ [ 1, 2 ], [ 3, 4 ] ] ); // $ExpectType float64ndarray + array( [ 1, 2, 3, 4 ], { 'shape': [ 2, 2 ] } ); // $ExpectType float64ndarray + array( { 'shape': [ 2, 2 ] } ); // $ExpectType float64ndarray + array( { 'buffer': [ [ 1, 2 ], [ 3, 4 ] ] } ); // $ExpectType float64ndarray + array( { 'buffer': [ 1, 2, 3, 4 ], 'shape': [ 2, 2 ] } ); // $ExpectType float64ndarray +} + +// The function returns an ndarray having a specified data type when provided a `dtype` option and a data source argument... +{ + const buffer = [ [ 1, 2 ], [ 3, 4 ] ]; + + array( buffer, { 'dtype': 'float64' } ); // $ExpectType float64ndarray + array( buffer, { 'dtype': 'float32' } ); // $ExpectType float32ndarray + array( buffer, { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray + array( buffer, { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray + array( buffer, { 'dtype': 'int32' } ); // $ExpectType int32ndarray + array( buffer, { 'dtype': 'int16' } ); // $ExpectType int16ndarray + array( buffer, { 'dtype': 'int8' } ); // $ExpectType int8ndarray + array( buffer, { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray + array( buffer, { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray + array( buffer, { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray + array( buffer, { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray + array( [ [ true, false ], [ false, true ] ], { 'dtype': 'bool' } ); // $ExpectType boolndarray + array( buffer, { 'dtype': 'generic' } ); // $ExpectType genericndarray + array( buffer, { 'dtype': 'generic' } ); // $ExpectType genericndarray + + // A `dtype` option overrides the data type of a typed array data source: + array( zeros( 4, 'float64' ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray + array( zeros( 4, 'int32' ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray + + // A `dtype` option overrides the data type of an ndarray data source: + array( ndzeros( [ 2, 2 ], { 'dtype': 'int32' } ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray +} + +// The function returns an ndarray having a specified data type when provided a `dtype` option and an options object containing a data source or shape... +{ + const buffer = [ [ 1, 2 ], [ 3, 4 ] ]; + + array( { 'buffer': buffer, 'dtype': 'float64' } ); // $ExpectType float64ndarray + array( { 'buffer': buffer, 'dtype': 'float32' } ); // $ExpectType float32ndarray + array( { 'buffer': buffer, 'dtype': 'complex128' } ); // $ExpectType complex128ndarray + array( { 'buffer': buffer, 'dtype': 'complex64' } ); // $ExpectType complex64ndarray + array( { 'buffer': buffer, 'dtype': 'int32' } ); // $ExpectType int32ndarray + array( { 'buffer': buffer, 'dtype': 'int16' } ); // $ExpectType int16ndarray + array( { 'buffer': buffer, 'dtype': 'int8' } ); // $ExpectType int8ndarray + array( { 'buffer': buffer, 'dtype': 'uint32' } ); // $ExpectType uint32ndarray + array( { 'buffer': buffer, 'dtype': 'uint16' } ); // $ExpectType uint16ndarray + array( { 'buffer': buffer, 'dtype': 'uint8' } ); // $ExpectType uint8ndarray + array( { 'buffer': buffer, 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray + array( { 'buffer': [ [ true, false ], [ false, true ] ], 'dtype': 'bool' } ); // $ExpectType boolndarray + array( { 'buffer': buffer, 'dtype': 'generic' } ); // $ExpectType genericndarray + array( { 'buffer': buffer, 'dtype': 'generic' } ); // $ExpectType genericndarray + + // A `dtype` option overrides the data type of a typed array or ndarray data source: + array( { 'buffer': zeros( 4, 'float64' ), 'dtype': 'int32' } ); // $ExpectType int32ndarray + array( { 'buffer': zeros( 4, 'int32' ), 'dtype': 'float64' } ); // $ExpectType float64ndarray + array( { 'buffer': ndzeros( [ 2, 2 ], { 'dtype': 'int32' } ), 'dtype': 'float64' } ); // $ExpectType float64ndarray + + array( { 'shape': [ 2, 2 ], 'dtype': 'float64' } ); // $ExpectType float64ndarray + array( { 'shape': [ 2, 2 ], 'dtype': 'float32' } ); // $ExpectType float32ndarray + array( { 'shape': [ 2, 2 ], 'dtype': 'complex128' } ); // $ExpectType complex128ndarray + array( { 'shape': [ 2, 2 ], 'dtype': 'complex64' } ); // $ExpectType complex64ndarray + array( { 'shape': [ 2, 2 ], 'dtype': 'int32' } ); // $ExpectType int32ndarray + array( { 'shape': [ 2, 2 ], 'dtype': 'int16' } ); // $ExpectType int16ndarray + array( { 'shape': [ 2, 2 ], 'dtype': 'int8' } ); // $ExpectType int8ndarray + array( { 'shape': [ 2, 2 ], 'dtype': 'uint32' } ); // $ExpectType uint32ndarray + array( { 'shape': [ 2, 2 ], 'dtype': 'uint16' } ); // $ExpectType uint16ndarray + array( { 'shape': [ 2, 2 ], 'dtype': 'uint8' } ); // $ExpectType uint8ndarray + array( { 'shape': [ 2, 2 ], 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray + array( { 'shape': [ 2, 2 ], 'dtype': 'bool' } ); // $ExpectType boolndarray + array( { 'shape': [ 2, 2 ], 'dtype': 'generic' } ); // $ExpectType genericndarray +} + +// The function infers the output data type from a typed array data source argument when not provided a `dtype` option... +{ + array( zeros( 4, 'float64' ) ); // $ExpectType float64ndarray + array( zeros( 4, 'float32' ) ); // $ExpectType float32ndarray + array( zeros( 4, 'complex128' ) ); // $ExpectType complex128ndarray + array( zeros( 4, 'complex64' ) ); // $ExpectType complex64ndarray + array( zeros( 4, 'int32' ) ); // $ExpectType int32ndarray + array( zeros( 4, 'int16' ) ); // $ExpectType int16ndarray + array( zeros( 4, 'int8' ) ); // $ExpectType int8ndarray + array( zeros( 4, 'uint32' ) ); // $ExpectType uint32ndarray + array( zeros( 4, 'uint16' ) ); // $ExpectType uint16ndarray + array( zeros( 4, 'uint8' ) ); // $ExpectType uint8ndarray + array( zeros( 4, 'uint8c' ) ); // $ExpectType uint8cndarray + array( new BooleanArray( [ true, false, true, false ] ) ); // $ExpectType boolndarray + + array( zeros( 4, 'float64' ), { 'shape': [ 2, 2 ] } ); // $ExpectType float64ndarray + array( zeros( 4, 'float32' ), { 'shape': [ 2, 2 ] } ); // $ExpectType float32ndarray + array( zeros( 4, 'complex128' ), { 'shape': [ 2, 2 ] } ); // $ExpectType complex128ndarray + array( zeros( 4, 'complex64' ), { 'shape': [ 2, 2 ] } ); // $ExpectType complex64ndarray + array( zeros( 4, 'int32' ), { 'shape': [ 2, 2 ] } ); // $ExpectType int32ndarray + array( zeros( 4, 'int16' ), { 'shape': [ 2, 2 ] } ); // $ExpectType int16ndarray + array( zeros( 4, 'int8' ), { 'shape': [ 2, 2 ] } ); // $ExpectType int8ndarray + array( zeros( 4, 'uint32' ), { 'shape': [ 2, 2 ] } ); // $ExpectType uint32ndarray + array( zeros( 4, 'uint16' ), { 'shape': [ 2, 2 ] } ); // $ExpectType uint16ndarray + array( zeros( 4, 'uint8' ), { 'shape': [ 2, 2 ] } ); // $ExpectType uint8ndarray + array( zeros( 4, 'uint8c' ), { 'shape': [ 2, 2 ] } ); // $ExpectType uint8cndarray + array( new BooleanArray( [ true, false, true, false ] ), { 'shape': [ 2, 2 ] } ); // $ExpectType boolndarray + + // Generic array data sources are cast to the default data type: + array( zeros( 4, 'generic' ) ); // $ExpectType float64ndarray +} + +// The function infers the output data type from a typed array data source provided via an options object when not provided a `dtype` option... +{ + array( { 'buffer': zeros( 4, 'float64' ) } ); // $ExpectType float64ndarray + array( { 'buffer': zeros( 4, 'float32' ) } ); // $ExpectType float32ndarray + array( { 'buffer': zeros( 4, 'complex128' ) } ); // $ExpectType complex128ndarray + array( { 'buffer': zeros( 4, 'complex64' ) } ); // $ExpectType complex64ndarray + array( { 'buffer': zeros( 4, 'int32' ) } ); // $ExpectType int32ndarray + array( { 'buffer': zeros( 4, 'int16' ) } ); // $ExpectType int16ndarray + array( { 'buffer': zeros( 4, 'int8' ) } ); // $ExpectType int8ndarray + array( { 'buffer': zeros( 4, 'uint32' ) } ); // $ExpectType uint32ndarray + array( { 'buffer': zeros( 4, 'uint16' ) } ); // $ExpectType uint16ndarray + array( { 'buffer': zeros( 4, 'uint8' ) } ); // $ExpectType uint8ndarray + array( { 'buffer': zeros( 4, 'uint8c' ) } ); // $ExpectType uint8cndarray + array( { 'buffer': new BooleanArray( [ true, false, true, false ] ) } ); // $ExpectType boolndarray + + array( { 'buffer': zeros( 4, 'float64' ), 'shape': [ 2, 2 ] } ); // $ExpectType float64ndarray + array( { 'buffer': zeros( 4, 'int32' ), 'shape': [ 2, 2 ], 'order': 'column-major' } ); // $ExpectType int32ndarray + + // Generic array data sources are cast to the default data type: + array( { 'buffer': zeros( 4, 'generic' ) } ); // $ExpectType float64ndarray +} + +// The function preserves the data type of an ndarray data source when not provided a `dtype` option... +{ + array( ndzeros( [ 2, 2 ], { 'dtype': 'float64' } ) ); // $ExpectType float64ndarray + array( ndzeros( [ 2, 2 ], { 'dtype': 'float32' } ) ); // $ExpectType float32ndarray + array( ndzeros( [ 2, 2 ], { 'dtype': 'complex128' } ) ); // $ExpectType complex128ndarray + array( ndzeros( [ 2, 2 ], { 'dtype': 'int32' } ) ); // $ExpectType int32ndarray + array( ndzeros( [ 2, 2 ], { 'dtype': 'uint8c' } ) ); // $ExpectType uint8cndarray + array( ndzeros( [ 2, 2 ], { 'dtype': 'generic' } ) ); // $ExpectType genericndarray + + array( ndzeros( [ 2, 2 ], { 'dtype': 'int32' } ), { 'copy': true } ); // $ExpectType int32ndarray + array( ndzeros( [ 2, 2 ], { 'dtype': 'int32' } ), { 'shape': [ 4 ] } ); // $ExpectType int32ndarray + + array( { 'buffer': ndzeros( [ 2, 2 ], { 'dtype': 'float32' } ) } ); // $ExpectType float32ndarray + array( { 'buffer': ndzeros( [ 2, 2 ], { 'dtype': 'int32' } ), 'shape': [ 4 ] } ); // $ExpectType int32ndarray + array( { 'buffer': ndzeros( [ 2, 2 ], { 'dtype': 'generic' } ) } ); // $ExpectType genericndarray +} + +// The function returns a generic typed ndarray when a `dtype` option cannot be narrowed to a single data type... +{ + const dt = 'float64' as DataType; + + array( [ 1, 2, 3, 4 ], { 'dtype': dt } ); // $ExpectType typedndarray + array( [ 1, 2, 3, 4 ], { 'dtype': dt } ); // $ExpectType typedndarray + array( { 'buffer': [ 1, 2, 3, 4 ], 'dtype': dt } ); // $ExpectType typedndarray + array( { 'shape': [ 2, 2 ], 'dtype': dt } ); // $ExpectType typedndarray +} + +// The compiler throws an error if the function is provided an options object which has neither a shape nor a data source... +{ + array( {} ); // $ExpectError + array( { 'dtype': 'float64' } ); // $ExpectError + array( { 'dtype': 'int32', 'order': 'row-major' } ); // $ExpectError +} + // The compiler throws an error if the function is provided a first argument which is not an array, buffer, or options object... { array( true ); // $ExpectError