From 641aa5e397120b6c1c82d4e3dc9c464228d91d82 Mon Sep 17 00:00:00 2001 From: LoayAhmed304 Date: Tue, 17 Mar 2026 06:15:21 +0200 Subject: [PATCH 1/4] feat: add initial files --- .../@stdlib/ndarray/base/full/README.md | 127 +++ .../@stdlib/ndarray/base/full/docs/repl.txt | 44 ++ .../ndarray/base/full/docs/types/index.d.ts | 323 ++++++++ .../ndarray/base/full/docs/types/test.ts | 108 +++ .../@stdlib/ndarray/base/full/ex.ts | 17 + .../@stdlib/ndarray/base/full/lib/index.js | 47 ++ .../@stdlib/ndarray/base/full/lib/main.js | 68 ++ .../@stdlib/ndarray/base/full/package.json | 61 ++ .../@stdlib/ndarray/base/full/test/test.js | 747 ++++++++++++++++++ 9 files changed, 1542 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/ex.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/base/full/README.md b/lib/node_modules/@stdlib/ndarray/base/full/README.md new file mode 100644 index 000000000000..8b75e8b5df32 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/README.md @@ -0,0 +1,127 @@ + + +# full + +> Return a new ndarray having a specified shape, data type, and filled with a specified value. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var full = require( '@stdlib/ndarray/base/full' ); +``` + +#### full( shape, value, dtype ) + +Returns a new ndarray having a specified `shape`, `dtype`, and filled with `value`. + +```javascript +var array = require( '@stdlib/ndarray/array' ); + +var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] ); +// returns [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] + +var out = full( x.shape, 10.0 ); +// returns [ [ [ 10.0, 10.0 ] ], [ [ 10.0, 10.0 ] ], [ [ 10.0, 10.0 ] ] ] + +var bool = ( out === x ); +// returns true +``` + +This function accepts the following arguments: +- **shape**: input shape ndarray. +- **value**: scalar fill value. + +
+ + + + + +
+ +## Notes + +- A `value` must be able to safely cast to the input `dtype`. + +- If `value` is a number and `dtype` is a complex [data type][@stdlib/ndarray/dtypes], the function returns a filled ndarray with a complex number whose real component equals the provided scalar `value` and whose imaginary component is zero. + +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var full = require( '@stdlib/ndarray/base/full' ); + +full( [ 5, 2 ], 10.0, 'float64' ); +console.log( ndarray2array( x ) ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt new file mode 100644 index 000000000000..72bcda7b846c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt @@ -0,0 +1,44 @@ + +{{alias}}( dtype, shape, order, value ) + Returns a new ndarray having a specified shape, data type, and filled with a specified value. + + If `value` is a number and `dtype` is a complex data type, the function returns + a filled ndarray with a complex number whose real component equals the + provided scalar `value` and whose imaginary component is zero. + + Parameters + ---------- + dtype: string|DataType + Underlying data type. + + shape: ArrayLikeObject + Array shape. + + order: string + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). + + value: any + Scalar value. Must be able to safely cast to `dtype`. + Scalar values having floating-point data types (both real and + complex) are allowed to downcast to a lower precision data type of the + same kind (e.g., a scalar double-precision floating-point number can be + used to fill a 'float32' ndarray). + + Returns + ------- + out: ndarray + Output ndarray. + + Examples + -------- + > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major', 10.0 ) + + > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) + [ 2, 2 ] + > var dt = String( {{alias:@stdlib/ndarray/dtype}}( arr ) ) + 'float64' + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts new file mode 100644 index 000000000000..04e4fc3a31cd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts @@ -0,0 +1,323 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, complexndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; +import { ComplexLike } from '@stdlib/types/complex'; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'float64', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float64' +*/ +declare function full( dtype: 'float64', shape: Shape, order: Order, value: number | ComplexLike ): float64ndarray; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float32' +*/ +declare function full( dtype: 'float32', shape: Shape, order: Order, value: number | ComplexLike ): float32ndarray; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'complex128', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'complex128' +*/ +declare function full( dtype: 'complex128', shape: Shape, order: Order, value: number | ComplexLike ): complex128ndarray; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'complex64', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'complex64' +*/ +declare function full( dtype: 'complex64', shape: Shape, order: Order, value: number | ComplexLike ): complex64ndarray; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'int32', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'int32' +*/ +declare function full( dtype: 'int32', shape: Shape, order: Order, value: number | ComplexLike ): int32ndarray; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'int16', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'int16' +*/ +declare function full( dtype: 'int16', shape: Shape, order: Order, value: number | ComplexLike ): int16ndarray; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'int8', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'int8' +*/ +declare function full( dtype: 'int8', shape: Shape, order: Order, value: number | ComplexLike ): int8ndarray; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'uint32', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint32' +*/ +declare function full( dtype: 'uint32', shape: Shape, order: Order, value: number | ComplexLike ): uint32ndarray; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'uint16', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint16' +*/ +declare function full( dtype: 'uint16', shape: Shape, order: Order, value: number | ComplexLike ): uint16ndarray; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'uint8', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint8' +*/ +declare function full( dtype: 'uint8', shape: Shape, order: Order, value: number | ComplexLike ): uint8ndarray; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'uint8c', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint8c' +*/ +declare function full( dtype: 'uint8c', shape: Shape, order: Order, value: number | ComplexLike ): uint8cndarray; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'bool', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'bool' +*/ +declare function full( dtype: 'bool', shape: Shape, order: Order, value: number | ComplexLike ): boolndarray; + +/** +* Creates a zero-filled array having a specified shape and data type. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'generic', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'generic' +*/ +declare function full( dtype: 'generic', shape: Shape, order: Order, value: number | ComplexLike ): genericndarray; + +/** +* Creates an ndarray having a specified shape and data type, filled with a specified value. +* +* @param dtype - underlying data type +* @param shape - array shape +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @param value - fill value +* @returns output array +* +* @example +* var arr = full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float32' +*/ +declare function full( dtype: DataType, shape: Shape, order: Order, value: number | ComplexLike ): typedndarray; + + +// EXPORTS // + +export = full; diff --git a/lib/node_modules/@stdlib/ndarray/base/full/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/test.ts new file mode 100644 index 000000000000..7420673fc7cb --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/test.ts @@ -0,0 +1,108 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import full = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + full( 'float64', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType float64ndarray + full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType float32ndarray + full( 'complex128', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType complex128ndarray + full( 'complex64', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType complex64ndarray + full( 'int32', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType int32ndarray + full( 'int16', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType int16ndarray + full( 'int8', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType int8ndarray + full( 'uint32', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType uint32ndarray + full( 'uint16', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType uint16ndarray + full( 'uint8', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType uint8ndarray + full( 'uint8c', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType uint8cndarray + full( 'bool', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType boolndarray + full( 'generic', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType genericndarray + + full( 'float64', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType float64ndarray + full( 'float32', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType float32ndarray + full( 'complex128', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType complex128ndarray + full( 'complex64', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType complex64ndarray + full( 'int32', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType int32ndarray + full( 'int16', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType int16ndarray + full( 'int8', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType int8ndarray + full( 'uint32', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType uint32ndarray + full( 'uint16', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType uint16ndarray + full( 'uint8', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType uint8ndarray + full( 'uint8c', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType uint8cndarray + full( 'bool', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType boolndarray + full( 'generic', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType genericndarray +} + +// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... +{ + full( '10', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError + full( 10, [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError + full( false, [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError + full( true, [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError + full( null, [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError + full( [], [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError + full( {}, [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError + full( ( x: number ): number => x, [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError +} + +// The compiler throws an error if the function is not provided a valid shape for the second argument... +{ + full( 'float32', '5', 'row-major', 10.0 ); // $ExpectError + full( 'float32', false, 'row-major', 10.0 ); // $ExpectError + full( 'float32', true, 'row-major', 10.0 ); // $ExpectError + full( 'float32', null, 'row-major', 10.0 ); // $ExpectError + full( 'float32', undefined, 'row-major', 10.0 ); // $ExpectError + full( 'float32', [ '5' ], 'row-major', 10.0 ); // $ExpectError + full( 'float32', {}, 'row-major', 10.0 ); // $ExpectError + full( 'float32', ( x: number ): number => x, 'row-major', 10.0 ); // $ExpectError +} + +// The compiler throws an error if the function is not provided a valid order for the third argument... +{ + full( 'float32', [ 2, 2 ], '5', 10.0 ); // $ExpectError + full( 'float32', [ 2, 2 ], false, 10.0 ); // $ExpectError + full( 'float32', [ 2, 2 ], true, 10.0 ); // $ExpectError + full( 'float32', [ 2, 2 ], null, 10.0 ); // $ExpectError + full( 'float32', [ 2, 2 ], undefined, 10.0 ); // $ExpectError + full( 'float32', [ 2, 2 ], [ '5' ], 10.0 ); // $ExpectError + full( 'float32', [ 2, 2 ], {}, 10.0 ); // $ExpectError + full( 'float32', [ 2, 2 ], ( x: number ): number => x, 10.0 ); // $ExpectError +} + +// The compiler throws an error if the function is not provided a valid value for the fourth argument... +{ + full( 'float32', [ 2, 2 ], 'row-major', '5' ); // $ExpectError + full( 'float32', [ 2, 2 ], 'row-major', false ); // $ExpectError + full( 'float32', [ 2, 2 ], 'row-major', true ); // $ExpectError + full( 'float32', [ 2, 2 ], 'row-major', null ); // $ExpectError + full( 'float32', [ 2, 2 ], 'row-major', undefined ); // $ExpectError + full( 'float32', [ 2, 2 ], 'row-major', [ '5' ] ); // $ExpectError + full( 'float32', [ 2, 2 ], 'row-major', {} ); // $ExpectError + full( 'float32', [ 2, 2 ], 'row-major', ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + full( 'float64' ); // $ExpectError + full( 'float64', [ 2, 2 ] ); // $ExpectError + full( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/base/full/ex.ts b/lib/node_modules/@stdlib/ndarray/base/full/ex.ts new file mode 100644 index 000000000000..e5495c18da98 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/ex.ts @@ -0,0 +1,17 @@ +var full = require( '@stdlib/ndarray/base/full' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); + +var arr = full( 'complex64', [ 2, 2 ], 'row-major', 10.0 ); +// returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] + +var sh = getShape( arr ); +// returns [ 2, 2 ] +console.log(sh); + +var dt = String( getDType( arr ) ); +// returns 'float32' +console.log(dt); + +console.log( ndarray2array(arr) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js new file mode 100644 index 000000000000..3c8b4cb94119 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Return a new ndarray having a specified shape, data type, and filled with a specified value. +* +* @module @stdlib/ndarray/base/full +* +* @example +* var getShape = require( '@stdlib/ndarray/shape' ); +* var getDType = require( '@stdlib/ndarray/dtype' ); +* +* var arr = full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); +* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] +* +* var sh = getShape( arr ); +* // returns [ 2, 2 ] +* +* var dt = String( getDType( arr ) ); +* // returns 'float32' +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js new file mode 100644 index 000000000000..d4f090df529b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isScalarMostlySafeCompatible = require( '@stdlib/ndarray/base/assert/is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length +var empty = require( '@stdlib/ndarray/base/empty' ); +var fill = require( '@stdlib/ndarray/base/fill' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Return a new ndarray having a specified shape, data type, and filled with a specified value. +* +* @param {*} dtype - data type +* @param {NonNegativeIntegerArray} shape - array shape +* @param {string} order - array order +* @param {*} value - fill value +* @throws {TypeError} first argument must be a recognized data type +* @returns {ndarray} ndarray +* +* @example +* var getShape = require( '@stdlib/ndarray/shape' ); +* var getDType = require( '@stdlib/ndarray/dtype' ); +* +* var arr = full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); +* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] +* +* var sh = getShape( arr ); +* // returns [ 2, 2 ] +* +* var dt = String( getDType( arr ) ); +* // returns 'float32' +*/ +function full( dtype, shape, order, value ) { + var arr; + + if ( !isScalarMostlySafeCompatible( value, dtype ) ) { + throw new TypeError( format( 'invalid argument. Fill value is not compatible with the specified data type. Value: %s, Data Type: %s', value, dtype ) ); + } + + arr = empty( dtype, shape, order ); + return fill( arr, value ); +} + + +// EXPORTS // + +module.exports = full; diff --git a/lib/node_modules/@stdlib/ndarray/base/full/package.json b/lib/node_modules/@stdlib/ndarray/base/full/package.json new file mode 100644 index 000000000000..7942f7010773 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/package.json @@ -0,0 +1,61 @@ +{ + "name": "@stdlib/ndarray/base/full", + "version": "0.0.0", + "description": "Return a new ndarray having a specified shape and filled with a specified value.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "base", + "strided", + "array", + "ndarray", + "fill", + "full" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/ndarray/base/full/test/test.js b/lib/node_modules/@stdlib/ndarray/base/full/test/test.js new file mode 100644 index 000000000000..08cfe459cc87 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/test/test.js @@ -0,0 +1,747 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var Int16Array = require( '@stdlib/array/int16' ); +var Uint16Array = require( '@stdlib/array/uint16' ); +var Int8Array = require( '@stdlib/array/int8' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var Buffer = require( '@stdlib/buffer/ctor' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var getShape = require( '@stdlib/ndarray/base/shape' ); +var getOrder = require( '@stdlib/ndarray/base/order' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var getDType = require( '@stdlib/ndarray/base/dtype' ); +var full = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof full, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a second argument which cannot be safely cast to the input ndarray data type', function test( t ) { + var values; + var dtype; + var i; + + dtype = 'int32'; + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + full( dtype, [ 2, 2 ], 'row-major', value ); + }; + } +}); + +tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'empty', + 'Int32', + 'Uint32', + 'Int16', + 'Uint16', + 'Int8', + 'Uint8', + 'Uint8c', + 'uint8_clamped', + 'Float64', + 'Float32', + 'FLOAT64', + 'FLOAT32', + 'GENERIC' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + full( value, 10, 'row-major', 10.0 ); + }; + } +}); + +tape( 'the function returns an initialized array (dtype=float64, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'float64', [ 2, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=float64, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'float64', [ 2, 2 ], 'column-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=float32, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new Float32Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=float32, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new Float32Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'float32', [ 2, 2 ], 'column-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Float32Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=int32, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new Int32Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'int32', [ 2, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=int32, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new Int32Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'int32', [ 2, 2 ], 'column-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Int32Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=int16, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new Int16Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'int16', [ 2, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=int16, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new Int16Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'int16', [ 2, 2 ], 'column-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Int16Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=int8, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new Int8Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'int8', [ 2, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=int8, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new Int8Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'int8', [ 2, 2 ], 'column-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Int8Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=uint32, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new Uint32Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'uint32', [ 2, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=uint32, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new Uint32Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'uint32', [ 2, 2 ], 'column-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Uint32Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=uint16, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new Uint16Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'uint16', [ 2, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=uint16, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new Uint16Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'uint16', [ 2, 2 ], 'column-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Uint16Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=uint8, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new Uint8Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'uint8', [ 2, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=uint8, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new Uint8Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'uint8', [ 2, 2 ], 'column-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Uint8Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=uint8c, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new Uint8ClampedArray([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'uint8c', [ 2, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=uint8c, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new Uint8ClampedArray([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + + arr = full( 'uint8c', [ 2, 2 ], 'column-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Uint8ClampedArray ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=binary, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new Buffer( [ 1, 1, 1, 1 ] ); + + arr = full( 'binary', [ 2, 2 ], 'row-major', 1 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=binary, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new Buffer([ + 1, + 1, + 1, + 1 + ]); + + arr = full( 'binary', [ 2, 2 ], 'column-major', 1 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Buffer ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=complex128, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new Complex128Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0 + ]); + + arr = full( 'complex128', [ 2, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=complex128, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new Complex128Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0 + ]); + + arr = full( 'complex128', [ 2, 2 ], 'column-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Complex128Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=complex64, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new Complex64Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0 + ]); + + arr = full( 'complex64', [ 2, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=complex64, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new Complex64Array( [ [10.0, 0.0], [10.0, 0.0] ] ); + + arr = full( 'complex64', [ 2, 2 ], 'column-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Complex64Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=bool, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = new BooleanArray( [ [true, true], [true, true] ] ); + + arr = full( 'bool', [ 2, 2 ], 'row-major', true ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns an initialized array (dtype=bool, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = new BooleanArray( [ [true, true], [true, true] ] ); + + arr = full( 'bool', [ 2, 2 ], 'column-major', true ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), BooleanArray ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=generic, order=row-major)', function test( t ) { + var expected; + var arr; + + expected = [ 10.0, 10.0, 10.0, 10.0 ]; + + arr = full( 'generic', [ 2, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=generic, order=column-major)', function test( t ) { + var expected; + var arr; + + expected = [ 10.0, 10.0, 10.0, 10.0 ]; + + arr = full( 'generic', [ 2, 2 ], 'column-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports zero-dimensional arrays', function test( t ) { + var arr; + + arr = full( 'float64', [], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( arr ), [], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), new Float64Array( [ 10.0 ] ), 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports full arrays', function test( t ) { + var expected; + var arr; + + expected = new Float64Array( 0 ); + + arr = full( 'float64', [ 2, 0, 2 ], 'row-major', 10.0 ); + t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); + t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' ); + t.strictEqual( instanceOf( getData( arr ), Float64Array ), true, 'returns expected value' ); + t.deepEqual( getData( arr ), expected, 'returns expected value' ); + t.strictEqual( getOrder( arr ), 'row-major', 'returns expected value' ); + + t.end(); +}); From 41a9d4343b00739d2023f6122c4f2aa8c361b0b6 Mon Sep 17 00:00:00 2001 From: LoayAhmed304 Date: Wed, 18 Mar 2026 04:31:26 +0200 Subject: [PATCH 2/4] feat: update current docs and add new package files --- .../@stdlib/ndarray/base/full/README.md | 45 +-- .../ndarray/base/full/benchmark/benchmark.js | 264 ++++++++++++++++++ .../full/benchmark/benchmark.size.bool.js | 94 +++++++ .../benchmark/benchmark.size.complex128.js | 94 +++++++ .../benchmark/benchmark.size.complex64.js | 94 +++++++ .../full/benchmark/benchmark.size.float32.js | 94 +++++++ .../full/benchmark/benchmark.size.float64.js | 94 +++++++ .../full/benchmark/benchmark.size.generic.js | 94 +++++++ .../full/benchmark/benchmark.size.int16.js | 94 +++++++ .../full/benchmark/benchmark.size.int32.js | 94 +++++++ .../full/benchmark/benchmark.size.int8.js | 94 +++++++ .../full/benchmark/benchmark.size.uint16.js | 94 +++++++ .../full/benchmark/benchmark.size.uint8.js | 94 +++++++ .../full/benchmark/benchmark.size.uint8c.js | 94 +++++++ .../base/full/benchmark/benchmark.uint32.js | 94 +++++++ .../@stdlib/ndarray/base/full/docs/repl.txt | 10 +- .../ndarray/base/full/docs/types/index.d.ts | 40 +-- .../ndarray/base/full/docs/types/test.ts | 4 +- .../@stdlib/ndarray/base/full/ex.ts | 17 -- .../ndarray/base/full/examples/index.js | 34 +++ .../@stdlib/ndarray/base/full/lib/index.js | 3 +- .../@stdlib/ndarray/base/full/lib/main.js | 3 +- .../@stdlib/ndarray/base/full/test/test.js | 2 +- 23 files changed, 1582 insertions(+), 62 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.bool.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex128.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex64.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float32.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float64.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.generic.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int16.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int32.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int8.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint16.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8c.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.uint32.js delete mode 100644 lib/node_modules/@stdlib/ndarray/base/full/ex.ts create mode 100644 lib/node_modules/@stdlib/ndarray/base/full/examples/index.js diff --git a/lib/node_modules/@stdlib/ndarray/base/full/README.md b/lib/node_modules/@stdlib/ndarray/base/full/README.md index 8b75e8b5df32..93729261f0c4 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/full/README.md @@ -40,26 +40,30 @@ limitations under the License. var full = require( '@stdlib/ndarray/base/full' ); ``` -#### full( shape, value, dtype ) +#### full( dtype, shape, order, value ) -Returns a new ndarray having a specified `shape`, `dtype`, and filled with `value`. +Returns a new [ndarray][@stdlib/ndarray/base/ctor] with a specified `shape`, `dtype`, `order`, and filled with `value`. ```javascript -var array = require( '@stdlib/ndarray/array' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getDType = require( '@stdlib/ndarray/dtype' ); -var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] ); -// returns [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] +var arr = full( 'float64', [ 2, 2 ], 'row-major', 10.0 ); +// returns -var out = full( x.shape, 10.0 ); -// returns [ [ [ 10.0, 10.0 ] ], [ [ 10.0, 10.0 ] ], [ [ 10.0, 10.0 ] ] ] +var sh = getShape( arr ); +// returns [ 2, 2 ] -var bool = ( out === x ); -// returns true +var dt = String( getDType( arr ) ); +// returns 'float64' ``` This function accepts the following arguments: -- **shape**: input shape ndarray. -- **value**: scalar fill value. + +- **dtype**: Underlying [data type][@stdlib/ndarray/dtypes]. +- **shape**: array shape. +- **order**: specifies whether an [ndarray][@stdlib/ndarray/base/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). +- **value**: scalar fill value. @@ -72,8 +76,7 @@ This function accepts the following arguments: ## Notes - A `value` must be able to safely cast to the input `dtype`. - -- If `value` is a number and `dtype` is a complex [data type][@stdlib/ndarray/dtypes], the function returns a filled ndarray with a complex number whose real component equals the provided scalar `value` and whose imaginary component is zero. +- If `value` is a real and `dtype` is a complex [data type][@stdlib/ndarray/dtypes], the function returns a filled ndarray with a complex number whose real component equals the provided scalar `value` and whose imaginary component is zero. @@ -88,12 +91,20 @@ This function accepts the following arguments: ```javascript -var discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); var full = require( '@stdlib/ndarray/base/full' ); -full( [ 5, 2 ], 10.0, 'float64' ); -console.log( ndarray2array( x ) ); +// Get a list of data types: +var dt = dtypes( 'integer_and_generic' ); + +// Generate fully initialized arrays... +var arr; +var i; +for ( i = 0; i < dt.length; i++ ) { + arr = full( dt[ i ], [ 2, 2 ], 'row-major', 10 ); + console.log( ndarray2array( arr ) ); +} ``` @@ -120,6 +131,8 @@ console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.js new file mode 100644 index 000000000000..0511092417ee --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.js @@ -0,0 +1,264 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'float64', [ 0 ], 'row-major', 10.0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'float32', [ 0 ], 'row-major', 10.0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'complex128', [ 0 ], 'row-major', 10.0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'complex64', [ 0 ], 'row-major', 10.0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'int32', [ 0 ], 'row-major', -10 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'uint32', [ 0 ], 'row-major', 10 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'int16', [ 0 ], 'row-major', -10 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'uint16', [ 0 ], 'row-major', 10 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'int8', [ 0 ], 'row-major', -10 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'uint8', [ 0 ], 'row-major', 10 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'uint8c', [ 0 ], 'row-major', 10 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'bool', [ 0 ], 'row-major', true ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'generic', [ 0 ], 'row-major', 10.0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.bool.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.bool.js new file mode 100644 index 000000000000..1011b98568ee --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.bool.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'bool', [ len ], 'row-major', true ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=bool,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex128.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex128.js new file mode 100644 index 000000000000..2f384a53faef --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex128.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'complex128', [ len ], 'row-major', 10.0 ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=complex128,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex64.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex64.js new file mode 100644 index 000000000000..e9873ef56493 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex64.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'complex64', [ len ], 'row-major', 10.0 ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=complex64,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float32.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float32.js new file mode 100644 index 000000000000..185b4fc2a17e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float32.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'float32', [ len ], 'row-major', 10.0 ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=float32,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float64.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float64.js new file mode 100644 index 000000000000..8fd1ed81123e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float64.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'float64', [ len ], 'row-major', 10.0 ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=float64,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.generic.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.generic.js new file mode 100644 index 000000000000..cc9e7c05a188 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.generic.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'generic', [ len ], 'row-major', 10.0 ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=generic,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int16.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int16.js new file mode 100644 index 000000000000..5151d586582b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int16.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'int16', [ len ], 'row-major', 10 ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=int16,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int32.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int32.js new file mode 100644 index 000000000000..82ba2dead4e8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int32.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'int32', [ len ], 'row-major', 10 ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=int32,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int8.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int8.js new file mode 100644 index 000000000000..3f8c19dcb1bd --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int8.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'int8', [ len ], 'row-major', 10 ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=int8,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint16.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint16.js new file mode 100644 index 000000000000..23a5df0be093 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint16.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'uint16', [ len ], 'row-major', 10 ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=uint16,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8.js new file mode 100644 index 000000000000..06d69983bc89 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'uint8', [ len ], 'row-major', 10 ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=uint8,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8c.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8c.js new file mode 100644 index 000000000000..abe82c635596 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8c.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'uint8c', [ len ], 'row-major', 10 ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=uint8c,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.uint32.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.uint32.js new file mode 100644 index 000000000000..f0a6c4b0976d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.uint32.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var full = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = full( 'uint32', [ len ], 'row-major', 10 ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:dtype=uint32,size=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt index 72bcda7b846c..ba2033c921e1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt @@ -1,10 +1,12 @@ {{alias}}( dtype, shape, order, value ) - Returns a new ndarray having a specified shape, data type, and filled with a specified value. + Returns a new ndarray having a specified shape, data type, and filled + with a specified value. - If `value` is a number and `dtype` is a complex data type, the function returns - a filled ndarray with a complex number whose real component equals the - provided scalar `value` and whose imaginary component is zero. + If `value` is a number and `dtype` is a complex data type, + the function returns a filled ndarray with a complex number + whose real component equals the provided scalar `value` + and whose imaginary component is zero. Parameters ---------- diff --git a/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts index 04e4fc3a31cd..fbb02816b399 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, complexndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; +import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, complex128ndarray, complex64ndarray, genericndarray, DataType } from '@stdlib/types/ndarray'; import { ComplexLike } from '@stdlib/types/complex'; /** @@ -42,7 +42,7 @@ import { ComplexLike } from '@stdlib/types/complex'; * var dt = arr.dtype; * // returns 'float64' */ -declare function full( dtype: 'float64', shape: Shape, order: Order, value: number | ComplexLike ): float64ndarray; +declare function full( dtype: 'float64', shape: Shape, order: Order, value: number ): float64ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. @@ -63,7 +63,7 @@ declare function full( dtype: 'float64', shape: Shape, order: Order, value: numb * var dt = arr.dtype; * // returns 'float32' */ -declare function full( dtype: 'float32', shape: Shape, order: Order, value: number | ComplexLike ): float32ndarray; +declare function full( dtype: 'float32', shape: Shape, order: Order, value: number ): float32ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. @@ -96,7 +96,7 @@ declare function full( dtype: 'complex128', shape: Shape, order: Order, value: n * @returns output array * * @example -* var arr = full( 'complex64', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 'complex64', [ 2, 2 ], 'row-major', { 're': 10, 'im': 5 } ); * // returns * * var sh = arr.shape; @@ -117,7 +117,7 @@ declare function full( dtype: 'complex64', shape: Shape, order: Order, value: nu * @returns output array * * @example -* var arr = full( 'int32', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 'int32', [ 2, 2 ], 'row-major', 10 ); * // returns * * var sh = arr.shape; @@ -126,7 +126,7 @@ declare function full( dtype: 'complex64', shape: Shape, order: Order, value: nu * var dt = arr.dtype; * // returns 'int32' */ -declare function full( dtype: 'int32', shape: Shape, order: Order, value: number | ComplexLike ): int32ndarray; +declare function full( dtype: 'int32', shape: Shape, order: Order, value: number ): int32ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. @@ -138,7 +138,7 @@ declare function full( dtype: 'int32', shape: Shape, order: Order, value: number * @returns output array * * @example -* var arr = full( 'int16', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 'int16', [ 2, 2 ], 'row-major', 10 ); * // returns * * var sh = arr.shape; @@ -147,7 +147,7 @@ declare function full( dtype: 'int32', shape: Shape, order: Order, value: number * var dt = arr.dtype; * // returns 'int16' */ -declare function full( dtype: 'int16', shape: Shape, order: Order, value: number | ComplexLike ): int16ndarray; +declare function full( dtype: 'int16', shape: Shape, order: Order, value: number ): int16ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. @@ -159,7 +159,7 @@ declare function full( dtype: 'int16', shape: Shape, order: Order, value: number * @returns output array * * @example -* var arr = full( 'int8', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 'int8', [ 2, 2 ], 'row-major', 10 ); * // returns * * var sh = arr.shape; @@ -168,7 +168,7 @@ declare function full( dtype: 'int16', shape: Shape, order: Order, value: number * var dt = arr.dtype; * // returns 'int8' */ -declare function full( dtype: 'int8', shape: Shape, order: Order, value: number | ComplexLike ): int8ndarray; +declare function full( dtype: 'int8', shape: Shape, order: Order, value: number ): int8ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. @@ -180,7 +180,7 @@ declare function full( dtype: 'int8', shape: Shape, order: Order, value: number * @returns output array * * @example -* var arr = full( 'uint32', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 'uint32', [ 2, 2 ], 'row-major', 10 ); * // returns * * var sh = arr.shape; @@ -189,7 +189,7 @@ declare function full( dtype: 'int8', shape: Shape, order: Order, value: number * var dt = arr.dtype; * // returns 'uint32' */ -declare function full( dtype: 'uint32', shape: Shape, order: Order, value: number | ComplexLike ): uint32ndarray; +declare function full( dtype: 'uint32', shape: Shape, order: Order, value: number ): uint32ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. @@ -201,7 +201,7 @@ declare function full( dtype: 'uint32', shape: Shape, order: Order, value: numbe * @returns output array * * @example -* var arr = full( 'uint16', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 'uint16', [ 2, 2 ], 'row-major', 10 ); * // returns * * var sh = arr.shape; @@ -210,7 +210,7 @@ declare function full( dtype: 'uint32', shape: Shape, order: Order, value: numbe * var dt = arr.dtype; * // returns 'uint16' */ -declare function full( dtype: 'uint16', shape: Shape, order: Order, value: number | ComplexLike ): uint16ndarray; +declare function full( dtype: 'uint16', shape: Shape, order: Order, value: number ): uint16ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. @@ -222,7 +222,7 @@ declare function full( dtype: 'uint16', shape: Shape, order: Order, value: numbe * @returns output array * * @example -* var arr = full( 'uint8', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 'uint8', [ 2, 2 ], 'row-major', 10 ); * // returns * * var sh = arr.shape; @@ -231,7 +231,7 @@ declare function full( dtype: 'uint16', shape: Shape, order: Order, value: numbe * var dt = arr.dtype; * // returns 'uint8' */ -declare function full( dtype: 'uint8', shape: Shape, order: Order, value: number | ComplexLike ): uint8ndarray; +declare function full( dtype: 'uint8', shape: Shape, order: Order, value: number ): uint8ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. @@ -243,7 +243,7 @@ declare function full( dtype: 'uint8', shape: Shape, order: Order, value: number * @returns output array * * @example -* var arr = full( 'uint8c', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 'uint8c', [ 2, 2 ], 'row-major', 10 ); * // returns * * var sh = arr.shape; @@ -252,7 +252,7 @@ declare function full( dtype: 'uint8', shape: Shape, order: Order, value: number * var dt = arr.dtype; * // returns 'uint8c' */ -declare function full( dtype: 'uint8c', shape: Shape, order: Order, value: number | ComplexLike ): uint8cndarray; +declare function full( dtype: 'uint8c', shape: Shape, order: Order, value: number ): uint8cndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. @@ -264,7 +264,7 @@ declare function full( dtype: 'uint8c', shape: Shape, order: Order, value: numbe * @returns output array * * @example -* var arr = full( 'bool', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 'bool', [ 2, 2 ], 'row-major', true ); * // returns * * var sh = arr.shape; @@ -273,7 +273,7 @@ declare function full( dtype: 'uint8c', shape: Shape, order: Order, value: numbe * var dt = arr.dtype; * // returns 'bool' */ -declare function full( dtype: 'bool', shape: Shape, order: Order, value: number | ComplexLike ): boolndarray; +declare function full( dtype: 'bool', shape: Shape, order: Order, value: number | boolean ): boolndarray; /** * Creates a zero-filled array having a specified shape and data type. diff --git a/lib/node_modules/@stdlib/ndarray/base/full/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/test.ts index 7420673fc7cb..55d4b78ade45 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/test.ts @@ -34,7 +34,7 @@ import full = require( './index' ); full( 'uint16', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType uint16ndarray full( 'uint8', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType uint8ndarray full( 'uint8c', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType uint8cndarray - full( 'bool', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType boolndarray + full( 'bool', [ 2, 2 ], 'row-major', true ); // $ExpectType boolndarray full( 'generic', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType genericndarray full( 'float64', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType float64ndarray @@ -48,7 +48,7 @@ import full = require( './index' ); full( 'uint16', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType uint16ndarray full( 'uint8', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType uint8ndarray full( 'uint8c', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType uint8cndarray - full( 'bool', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType boolndarray + full( 'bool', [ 2, 2 ], 'column-major', true ); // $ExpectType boolndarray full( 'generic', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType genericndarray } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/ex.ts b/lib/node_modules/@stdlib/ndarray/base/full/ex.ts deleted file mode 100644 index e5495c18da98..000000000000 --- a/lib/node_modules/@stdlib/ndarray/base/full/ex.ts +++ /dev/null @@ -1,17 +0,0 @@ -var full = require( '@stdlib/ndarray/base/full' ); -var getShape = require( '@stdlib/ndarray/shape' ); -var getDType = require( '@stdlib/ndarray/dtype' ); -var ndarray2array = require( '@stdlib/ndarray/to-array' ); - -var arr = full( 'complex64', [ 2, 2 ], 'row-major', 10.0 ); -// returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] - -var sh = getShape( arr ); -// returns [ 2, 2 ] -console.log(sh); - -var dt = String( getDType( arr ) ); -// returns 'float32' -console.log(dt); - -console.log( ndarray2array(arr) ); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/full/examples/index.js new file mode 100644 index 000000000000..cd6e2ccb3258 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/examples/index.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var full = require( './../lib' ); + +// Get a list of data types: +var dt = dtypes( 'integer_and_generic' ); + +// Generate fully initialized arrays... +var arr; +var i; +for ( i = 0; i < dt.length; i++ ) { + arr = full( dt[ i ], [ 2, 2 ], 'row-major', 10 ); + console.log( ndarray2array( arr ) ); +} diff --git a/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js index 3c8b4cb94119..1a669174671f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js @@ -26,9 +26,10 @@ * @example * var getShape = require( '@stdlib/ndarray/shape' ); * var getDType = require( '@stdlib/ndarray/dtype' ); +* var full = require( '@stdlib/ndarray/base/full' ); * * var arr = full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); -* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] +* // returns * * var sh = getShape( arr ); * // returns [ 2, 2 ] diff --git a/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js index d4f090df529b..e58a387f3023 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js @@ -36,6 +36,7 @@ var format = require( '@stdlib/string/format' ); * @param {string} order - array order * @param {*} value - fill value * @throws {TypeError} first argument must be a recognized data type +* @throws {TypeError} fill value is not compatible with the specified data type * @returns {ndarray} ndarray * * @example @@ -43,7 +44,7 @@ var format = require( '@stdlib/string/format' ); * var getDType = require( '@stdlib/ndarray/dtype' ); * * var arr = full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); -* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] +* // returns * * var sh = getShape( arr ); * // returns [ 2, 2 ] diff --git a/lib/node_modules/@stdlib/ndarray/base/full/test/test.js b/lib/node_modules/@stdlib/ndarray/base/full/test/test.js index 08cfe459cc87..b1d39ee70c49 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/test/test.js @@ -51,7 +51,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function throws an error if provided a second argument which cannot be safely cast to the input ndarray data type', function test( t ) { +tape( 'the function throws an error if provided a value which cannot be safely cast to the input data type', function test( t ) { var values; var dtype; var i; From e28a7fc5ff067d731328e4cbd240d56f3f53766a Mon Sep 17 00:00:00 2001 From: LoayAhmed304 Date: Wed, 18 Mar 2026 05:54:23 +0200 Subject: [PATCH 3/4] docs: update the package description --- lib/node_modules/@stdlib/ndarray/base/full/README.md | 4 ++-- lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt | 4 ++-- .../@stdlib/ndarray/base/full/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/ndarray/base/full/lib/index.js | 2 +- lib/node_modules/@stdlib/ndarray/base/full/lib/main.js | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/full/README.md b/lib/node_modules/@stdlib/ndarray/base/full/README.md index 93729261f0c4..e92d4e6231f7 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/full/README.md @@ -20,7 +20,7 @@ limitations under the License. # full -> Return a new ndarray having a specified shape, data type, and filled with a specified value. +> Create an [ndarray][@stdlib/ndarray/base/ctor] having a specified shape, [data type][@stdlib/ndarray/dtypes], and filled with a specified value. @@ -42,7 +42,7 @@ var full = require( '@stdlib/ndarray/base/full' ); #### full( dtype, shape, order, value ) -Returns a new [ndarray][@stdlib/ndarray/base/ctor] with a specified `shape`, `dtype`, `order`, and filled with `value`. +Creates an [ndarray][@stdlib/ndarray/base/ctor] having a specified shape, [data type][@stdlib/ndarray/dtypes], and filled with a specified value. ```javascript var getShape = require( '@stdlib/ndarray/shape' ); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt index ba2033c921e1..06d78045fc96 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( dtype, shape, order, value ) - Returns a new ndarray having a specified shape, data type, and filled - with a specified value. + Creates an ndarray having a specified shape, + data type, and filled with a specified value. If `value` is a number and `dtype` is a complex data type, the function returns a filled ndarray with a complex number diff --git a/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts index fbb02816b399..18874d987596 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts @@ -24,7 +24,7 @@ import { Shape, Order, typedndarray, float64ndarray, float32ndarray, int32ndarra import { ComplexLike } from '@stdlib/types/complex'; /** -* Creates an ndarray having a specified shape and data type, filled with a specified value. +* Creates an ndarray having a specified shape, data type, and filled with a specified value. * * @param dtype - underlying data type * @param shape - array shape diff --git a/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js index 1a669174671f..861eaeb41b78 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Return a new ndarray having a specified shape, data type, and filled with a specified value. +* Create an ndarray having a specified shape, data type, and filled with a specified value. * * @module @stdlib/ndarray/base/full * diff --git a/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js index e58a387f3023..73522481bf6b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js @@ -29,7 +29,7 @@ var format = require( '@stdlib/string/format' ); // MAIN // /** -* Return a new ndarray having a specified shape, data type, and filled with a specified value. +* Creates an ndarray having a specified shape, data type, and filled with a specified value. * * @param {*} dtype - data type * @param {NonNegativeIntegerArray} shape - array shape From 6075171089aa029dc1c24a32d279f2932bac4e5a Mon Sep 17 00:00:00 2001 From: LoayAhmed304 Date: Wed, 18 Mar 2026 23:09:27 +0200 Subject: [PATCH 4/4] feat: apply requested changes --- .../@stdlib/ndarray/base/full/README.md | 8 +- .../ndarray/base/full/benchmark/benchmark.js | 26 ++-- .../full/benchmark/benchmark.size.bool.js | 2 +- .../benchmark/benchmark.size.complex128.js | 2 +- .../benchmark/benchmark.size.complex64.js | 2 +- .../full/benchmark/benchmark.size.float32.js | 2 +- .../full/benchmark/benchmark.size.float64.js | 2 +- .../full/benchmark/benchmark.size.generic.js | 2 +- .../full/benchmark/benchmark.size.int16.js | 2 +- .../full/benchmark/benchmark.size.int32.js | 2 +- .../full/benchmark/benchmark.size.int8.js | 2 +- .../full/benchmark/benchmark.size.uint16.js | 2 +- .../full/benchmark/benchmark.size.uint8.js | 2 +- .../full/benchmark/benchmark.size.uint8c.js | 2 +- .../base/full/benchmark/benchmark.uint32.js | 2 +- .../@stdlib/ndarray/base/full/docs/repl.txt | 29 ++-- .../ndarray/base/full/docs/types/index.d.ts | 86 ++++++------ .../ndarray/base/full/docs/types/test.ts | 130 +++++++++--------- .../ndarray/base/full/examples/index.js | 2 +- .../@stdlib/ndarray/base/full/lib/index.js | 2 +- .../@stdlib/ndarray/base/full/lib/main.js | 21 ++- .../@stdlib/ndarray/base/full/test/test.js | 64 ++++----- 22 files changed, 201 insertions(+), 193 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/full/README.md b/lib/node_modules/@stdlib/ndarray/base/full/README.md index e92d4e6231f7..42254ec13759 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/README.md +++ b/lib/node_modules/@stdlib/ndarray/base/full/README.md @@ -40,7 +40,7 @@ limitations under the License. var full = require( '@stdlib/ndarray/base/full' ); ``` -#### full( dtype, shape, order, value ) +#### full( value, dtype, shape, order ) Creates an [ndarray][@stdlib/ndarray/base/ctor] having a specified shape, [data type][@stdlib/ndarray/dtypes], and filled with a specified value. @@ -48,7 +48,7 @@ Creates an [ndarray][@stdlib/ndarray/base/ctor] having a specified shape, [data var getShape = require( '@stdlib/ndarray/shape' ); var getDType = require( '@stdlib/ndarray/dtype' ); -var arr = full( 'float64', [ 2, 2 ], 'row-major', 10.0 ); +var arr = full( 10.0, 'float64', [ 2, 2 ], 'row-major' ); // returns var sh = getShape( arr ); @@ -60,10 +60,10 @@ var dt = String( getDType( arr ) ); This function accepts the following arguments: +- **value**: scalar fill value. - **dtype**: Underlying [data type][@stdlib/ndarray/dtypes]. - **shape**: array shape. - **order**: specifies whether an [ndarray][@stdlib/ndarray/base/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). -- **value**: scalar fill value. @@ -102,7 +102,7 @@ var dt = dtypes( 'integer_and_generic' ); var arr; var i; for ( i = 0; i < dt.length; i++ ) { - arr = full( dt[ i ], [ 2, 2 ], 'row-major', 10 ); + arr = full( 10, dt[ i ], [ 2, 2 ], 'row-major' ); console.log( ndarray2array( arr ) ); } ``` diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.js index 0511092417ee..184bfb1a094a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.js @@ -34,7 +34,7 @@ bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'float64', [ 0 ], 'row-major', 10.0 ); + arr = full( 10.0, 'float64', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } @@ -52,7 +52,7 @@ bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'float32', [ 0 ], 'row-major', 10.0 ); + arr = full( 10.0, 'float32', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } @@ -70,7 +70,7 @@ bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'complex128', [ 0 ], 'row-major', 10.0 ); + arr = full( 10.0, 'complex128', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } @@ -88,7 +88,7 @@ bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'complex64', [ 0 ], 'row-major', 10.0 ); + arr = full( 10.0, 'complex64', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } @@ -106,7 +106,7 @@ bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'int32', [ 0 ], 'row-major', -10 ); + arr = full( -10, 'int32', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } @@ -124,7 +124,7 @@ bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'uint32', [ 0 ], 'row-major', 10 ); + arr = full( 10, 'uint32', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } @@ -142,7 +142,7 @@ bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'int16', [ 0 ], 'row-major', -10 ); + arr = full( -10, 'int16', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } @@ -160,7 +160,7 @@ bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'uint16', [ 0 ], 'row-major', 10 ); + arr = full( 10, 'uint16', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } @@ -178,7 +178,7 @@ bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'int8', [ 0 ], 'row-major', -10 ); + arr = full( -10, 'int8', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } @@ -196,7 +196,7 @@ bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'uint8', [ 0 ], 'row-major', 10 ); + arr = full( 10, 'uint8', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } @@ -214,7 +214,7 @@ bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'uint8c', [ 0 ], 'row-major', 10 ); + arr = full( 10, 'uint8c', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } @@ -232,7 +232,7 @@ bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'bool', [ 0 ], 'row-major', true ); + arr = full( true, 'bool', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } @@ -250,7 +250,7 @@ bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'generic', [ 0 ], 'row-major', 10.0 ); + arr = full( 10.0, 'generic', [ 0 ], 'row-major' ); if ( arr.length !== 0 ) { b.fail( 'should have length 0' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.bool.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.bool.js index 1011b98568ee..829f77c1ebd8 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.bool.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.bool.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'bool', [ len ], 'row-major', true ); + arr = full( true, 'bool', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex128.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex128.js index 2f384a53faef..2916b8424411 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex128.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex128.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'complex128', [ len ], 'row-major', 10.0 ); + arr = full( 10.0, 'complex128', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex64.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex64.js index e9873ef56493..153fef30b688 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex64.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.complex64.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'complex64', [ len ], 'row-major', 10.0 ); + arr = full( 10.0, 'complex64', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float32.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float32.js index 185b4fc2a17e..f3a2dc3b2300 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float32.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float32.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'float32', [ len ], 'row-major', 10.0 ); + arr = full( 10.0, 'float32', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float64.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float64.js index 8fd1ed81123e..88bb3a9a3e94 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float64.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.float64.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'float64', [ len ], 'row-major', 10.0 ); + arr = full( 10.0, 'float64', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.generic.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.generic.js index cc9e7c05a188..912efa9dc6f8 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.generic.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.generic.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'generic', [ len ], 'row-major', 10.0 ); + arr = full( 10.0, 'generic', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int16.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int16.js index 5151d586582b..a3328c96515b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int16.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int16.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'int16', [ len ], 'row-major', 10 ); + arr = full( 10, 'int16', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int32.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int32.js index 82ba2dead4e8..6682544b7f4d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int32.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int32.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'int32', [ len ], 'row-major', 10 ); + arr = full( 10, 'int32', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int8.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int8.js index 3f8c19dcb1bd..1eb8a72360cd 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int8.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.int8.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'int8', [ len ], 'row-major', 10 ); + arr = full( 10, 'int8', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint16.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint16.js index 23a5df0be093..68149d1306db 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint16.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint16.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'uint16', [ len ], 'row-major', 10 ); + arr = full( 10, 'uint16', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8.js index 06d69983bc89..5ac7c91b740c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'uint8', [ len ], 'row-major', 10 ); + arr = full( 10, 'uint8', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8c.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8c.js index abe82c635596..5306ad956f47 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8c.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.size.uint8c.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'uint8c', [ len ], 'row-major', 10 ); + arr = full( 10, 'uint8c', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.uint32.js b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.uint32.js index f0a6c4b0976d..01bf4d560131 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.uint32.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/benchmark/benchmark.uint32.js @@ -52,7 +52,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - arr = full( 'uint32', [ len ], 'row-major', 10 ); + arr = full( 10, 'uint32', [ len ], 'row-major' ); if ( arr.length !== len ) { b.fail( 'unexpected length' ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt index 06d78045fc96..487f965bd8e1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt +++ b/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt @@ -1,15 +1,21 @@ -{{alias}}( dtype, shape, order, value ) - Creates an ndarray having a specified shape, - data type, and filled with a specified value. +{{alias}}( value, dtype, shape, order ) + Creates an ndarray having a specified shape, data type, and filled with a + specified value. - If `value` is a number and `dtype` is a complex data type, - the function returns a filled ndarray with a complex number - whose real component equals the provided scalar `value` - and whose imaginary component is zero. + If `value` is a number and `dtype` is a complex data type, the function + returns a filled ndarray with a complex number whose real component equals + the provided scalar `value` and whose imaginary component is zero. Parameters ---------- + value: any + Scalar value. Must be able to safely cast to `dtype`. Scalar values + having floating-point data types (both real and complex) are allowed to + downcast to a lower precision data type of the same kind (e.g., a + scalar double-precision floating-point number can be used to fill a + 'float32' ndarray). + dtype: string|DataType Underlying data type. @@ -20,13 +26,6 @@ Specifies whether an array is row-major (C-style) or column-major (Fortran-style). - value: any - Scalar value. Must be able to safely cast to `dtype`. - Scalar values having floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., a scalar double-precision floating-point number can be - used to fill a 'float32' ndarray). - Returns ------- out: ndarray @@ -34,7 +33,7 @@ Examples -------- - > var arr = {{alias}}( 'float64', [ 2, 2 ], 'row-major', 10.0 ) + > var arr = {{alias}}( 10.0, 'float64', [ 2, 2 ], 'row-major' ) > var sh = {{alias:@stdlib/ndarray/shape}}( arr ) [ 2, 2 ] diff --git a/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts index 18874d987596..f0ba5c13c4d8 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/index.d.ts @@ -26,14 +26,14 @@ import { ComplexLike } from '@stdlib/types/complex'; /** * Creates an ndarray having a specified shape, data type, and filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'float64', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 10.0, 'float64', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -42,19 +42,19 @@ import { ComplexLike } from '@stdlib/types/complex'; * var dt = arr.dtype; * // returns 'float64' */ -declare function full( dtype: 'float64', shape: Shape, order: Order, value: number ): float64ndarray; +declare function full( value: number, dtype: 'float64', shape: Shape, order: Order ): float64ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 10.0, 'float32', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -63,19 +63,19 @@ declare function full( dtype: 'float64', shape: Shape, order: Order, value: numb * var dt = arr.dtype; * // returns 'float32' */ -declare function full( dtype: 'float32', shape: Shape, order: Order, value: number ): float32ndarray; +declare function full( value: number, dtype: 'float32', shape: Shape, order: Order ): float32ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'complex128', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 10.0, 'complex128', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -84,19 +84,19 @@ declare function full( dtype: 'float32', shape: Shape, order: Order, value: numb * var dt = arr.dtype; * // returns 'complex128' */ -declare function full( dtype: 'complex128', shape: Shape, order: Order, value: number | ComplexLike ): complex128ndarray; +declare function full( value: number | ComplexLike, dtype: 'complex128', shape: Shape, order: Order ): complex128ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'complex64', [ 2, 2 ], 'row-major', { 're': 10, 'im': 5 } ); +* var arr = full( { 're': 10, 'im': 5 }, 'complex64', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -105,19 +105,19 @@ declare function full( dtype: 'complex128', shape: Shape, order: Order, value: n * var dt = arr.dtype; * // returns 'complex64' */ -declare function full( dtype: 'complex64', shape: Shape, order: Order, value: number | ComplexLike ): complex64ndarray; +declare function full( value: number | ComplexLike, dtype: 'complex64', shape: Shape, order: Order ): complex64ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'int32', [ 2, 2 ], 'row-major', 10 ); +* var arr = full( 10, 'int32', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -126,19 +126,19 @@ declare function full( dtype: 'complex64', shape: Shape, order: Order, value: nu * var dt = arr.dtype; * // returns 'int32' */ -declare function full( dtype: 'int32', shape: Shape, order: Order, value: number ): int32ndarray; +declare function full( value: number, dtype: 'int32', shape: Shape, order: Order ): int32ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'int16', [ 2, 2 ], 'row-major', 10 ); +* var arr = full( 10, 'int16', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -147,19 +147,19 @@ declare function full( dtype: 'int32', shape: Shape, order: Order, value: number * var dt = arr.dtype; * // returns 'int16' */ -declare function full( dtype: 'int16', shape: Shape, order: Order, value: number ): int16ndarray; +declare function full( value: number, dtype: 'int16', shape: Shape, order: Order ): int16ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'int8', [ 2, 2 ], 'row-major', 10 ); +* var arr = full( 10, 'int8', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -168,19 +168,19 @@ declare function full( dtype: 'int16', shape: Shape, order: Order, value: number * var dt = arr.dtype; * // returns 'int8' */ -declare function full( dtype: 'int8', shape: Shape, order: Order, value: number ): int8ndarray; +declare function full( value: number, dtype: 'int8', shape: Shape, order: Order ): int8ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'uint32', [ 2, 2 ], 'row-major', 10 ); +* var arr = full( 10, 'uint32', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -189,19 +189,19 @@ declare function full( dtype: 'int8', shape: Shape, order: Order, value: number * var dt = arr.dtype; * // returns 'uint32' */ -declare function full( dtype: 'uint32', shape: Shape, order: Order, value: number ): uint32ndarray; +declare function full( value: number, dtype: 'uint32', shape: Shape, order: Order ): uint32ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'uint16', [ 2, 2 ], 'row-major', 10 ); +* var arr = full( 10, 'uint16', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -210,19 +210,19 @@ declare function full( dtype: 'uint32', shape: Shape, order: Order, value: numbe * var dt = arr.dtype; * // returns 'uint16' */ -declare function full( dtype: 'uint16', shape: Shape, order: Order, value: number ): uint16ndarray; +declare function full( value: number, dtype: 'uint16', shape: Shape, order: Order ): uint16ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'uint8', [ 2, 2 ], 'row-major', 10 ); +* var arr = full( 10, 'uint8', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -231,19 +231,19 @@ declare function full( dtype: 'uint16', shape: Shape, order: Order, value: numbe * var dt = arr.dtype; * // returns 'uint8' */ -declare function full( dtype: 'uint8', shape: Shape, order: Order, value: number ): uint8ndarray; +declare function full( value: number, dtype: 'uint8', shape: Shape, order: Order ): uint8ndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'uint8c', [ 2, 2 ], 'row-major', 10 ); +* var arr = full( 10, 'uint8c', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -252,19 +252,19 @@ declare function full( dtype: 'uint8', shape: Shape, order: Order, value: number * var dt = arr.dtype; * // returns 'uint8c' */ -declare function full( dtype: 'uint8c', shape: Shape, order: Order, value: number ): uint8cndarray; +declare function full( value: number, dtype: 'uint8c', shape: Shape, order: Order ): uint8cndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'bool', [ 2, 2 ], 'row-major', true ); +* var arr = full( true, 'bool', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -273,19 +273,19 @@ declare function full( dtype: 'uint8c', shape: Shape, order: Order, value: numbe * var dt = arr.dtype; * // returns 'bool' */ -declare function full( dtype: 'bool', shape: Shape, order: Order, value: number | boolean ): boolndarray; +declare function full( value: number | boolean, dtype: 'bool', shape: Shape, order: Order ): boolndarray; /** -* Creates a zero-filled array having a specified shape and data type. +* Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'generic', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 10.0, 'generic', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -294,19 +294,19 @@ declare function full( dtype: 'bool', shape: Shape, order: Order, value: number * var dt = arr.dtype; * // returns 'generic' */ -declare function full( dtype: 'generic', shape: Shape, order: Order, value: number | ComplexLike ): genericndarray; +declare function full( value: number | ComplexLike, dtype: 'generic', shape: Shape, order: Order ): genericndarray; /** * Creates an ndarray having a specified shape and data type, filled with a specified value. * +* @param value - fill value * @param dtype - underlying data type * @param shape - array shape * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param value - fill value * @returns output array * * @example -* var arr = full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 10.0, 'float32', [ 2, 2 ], 'row-major' ); * // returns * * var sh = arr.shape; @@ -315,7 +315,7 @@ declare function full( dtype: 'generic', shape: Shape, order: Order, value: numb * var dt = arr.dtype; * // returns 'float32' */ -declare function full( dtype: DataType, shape: Shape, order: Order, value: number | ComplexLike ): typedndarray; +declare function full( value: number | ComplexLike, dtype: DataType, shape: Shape, order: Order ): typedndarray; // EXPORTS // diff --git a/lib/node_modules/@stdlib/ndarray/base/full/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/test.ts index 55d4b78ade45..2dcb03925950 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/docs/types/test.ts +++ b/lib/node_modules/@stdlib/ndarray/base/full/docs/types/test.ts @@ -23,86 +23,86 @@ import full = require( './index' ); // The function returns an ndarray... { - full( 'float64', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType float64ndarray - full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType float32ndarray - full( 'complex128', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType complex128ndarray - full( 'complex64', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType complex64ndarray - full( 'int32', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType int32ndarray - full( 'int16', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType int16ndarray - full( 'int8', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType int8ndarray - full( 'uint32', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType uint32ndarray - full( 'uint16', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType uint16ndarray - full( 'uint8', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType uint8ndarray - full( 'uint8c', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType uint8cndarray - full( 'bool', [ 2, 2 ], 'row-major', true ); // $ExpectType boolndarray - full( 'generic', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectType genericndarray + full( 10.0, 'float64', [ 2, 2 ], 'row-major' ); // $ExpectType float64ndarray + full( 10.0, 'float32', [ 2, 2 ], 'row-major' ); // $ExpectType float32ndarray + full( 10.0, 'complex128', [ 2, 2 ], 'row-major' ); // $ExpectType complex128ndarray + full( 10.0, 'complex64', [ 2, 2 ], 'row-major' ); // $ExpectType complex64ndarray + full( 10.0, 'int32', [ 2, 2 ], 'row-major' ); // $ExpectType int32ndarray + full( 10.0, 'int16', [ 2, 2 ], 'row-major' ); // $ExpectType int16ndarray + full( 10.0, 'int8', [ 2, 2 ], 'row-major' ); // $ExpectType int8ndarray + full( 10.0, 'uint32', [ 2, 2 ], 'row-major' ); // $ExpectType uint32ndarray + full( 10.0, 'uint16', [ 2, 2 ], 'row-major' ); // $ExpectType uint16ndarray + full( 10.0, 'uint8', [ 2, 2 ], 'row-major' ); // $ExpectType uint8ndarray + full( 10.0, 'uint8c', [ 2, 2 ], 'row-major' ); // $ExpectType uint8cndarray + full( true, 'bool', [ 2, 2 ], 'row-major' ); // $ExpectType boolndarray + full( 10.0, 'generic', [ 2, 2 ], 'row-major' ); // $ExpectType genericndarray - full( 'float64', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType float64ndarray - full( 'float32', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType float32ndarray - full( 'complex128', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType complex128ndarray - full( 'complex64', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType complex64ndarray - full( 'int32', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType int32ndarray - full( 'int16', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType int16ndarray - full( 'int8', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType int8ndarray - full( 'uint32', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType uint32ndarray - full( 'uint16', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType uint16ndarray - full( 'uint8', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType uint8ndarray - full( 'uint8c', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType uint8cndarray - full( 'bool', [ 2, 2 ], 'column-major', true ); // $ExpectType boolndarray - full( 'generic', [ 2, 2 ], 'column-major', 10.0 ); // $ExpectType genericndarray + full( 10.0, 'float64', [ 2, 2 ], 'column-major' ); // $ExpectType float64ndarray + full( 10.0, 'float32', [ 2, 2 ], 'column-major' ); // $ExpectType float32ndarray + full( 10.0, 'complex128', [ 2, 2 ], 'column-major' ); // $ExpectType complex128ndarray + full( 10.0, 'complex64', [ 2, 2 ], 'column-major' ); // $ExpectType complex64ndarray + full( 10.0, 'int32', [ 2, 2 ], 'column-major' ); // $ExpectType int32ndarray + full( 10.0, 'int16', [ 2, 2 ], 'column-major' ); // $ExpectType int16ndarray + full( 10.0, 'int8', [ 2, 2 ], 'column-major' ); // $ExpectType int8ndarray + full( 10.0, 'uint32', [ 2, 2 ], 'column-major' ); // $ExpectType uint32ndarray + full( 10.0, 'uint16', [ 2, 2 ], 'column-major' ); // $ExpectType uint16ndarray + full( 10.0, 'uint8', [ 2, 2 ], 'column-major' ); // $ExpectType uint8ndarray + full( 10.0, 'uint8c', [ 2, 2 ], 'column-major' ); // $ExpectType uint8cndarray + full( true, 'bool', [ 2, 2 ], 'column-major' ); // $ExpectType boolndarray + full( 10.0, 'generic', [ 2, 2 ], 'column-major' ); // $ExpectType genericndarray } -// The compiler throws an error if the function is provided a first argument which is an unrecognized/unsupported data type... +// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... { - full( '10', [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError - full( 10, [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError - full( false, [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError - full( true, [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError - full( null, [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError - full( [], [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError - full( {}, [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError - full( ( x: number ): number => x, [ 2, 2 ], 'row-major', 10.0 ); // $ExpectError + full( 10.0, '10', [ 2, 2 ], 'row-major' ); // $ExpectError + full( 10.0, 10, [ 2, 2 ], 'row-major' ); // $ExpectError + full( 10.0, false, [ 2, 2 ], 'row-major' ); // $ExpectError + full( 10.0, true, [ 2, 2 ], 'row-major' ); // $ExpectError + full( 10.0, null, [ 2, 2 ], 'row-major' ); // $ExpectError + full( 10.0, [], [ 2, 2 ], 'row-major' ); // $ExpectError + full( 10.0, {}, [ 2, 2 ], 'row-major' ); // $ExpectError + full( 10.0, ( x: number ): number => x, [ 2, 2 ], 'row-major' ); // $ExpectError } -// The compiler throws an error if the function is not provided a valid shape for the second argument... +// The compiler throws an error if the function is not provided a valid shape for the third argument... { - full( 'float32', '5', 'row-major', 10.0 ); // $ExpectError - full( 'float32', false, 'row-major', 10.0 ); // $ExpectError - full( 'float32', true, 'row-major', 10.0 ); // $ExpectError - full( 'float32', null, 'row-major', 10.0 ); // $ExpectError - full( 'float32', undefined, 'row-major', 10.0 ); // $ExpectError - full( 'float32', [ '5' ], 'row-major', 10.0 ); // $ExpectError - full( 'float32', {}, 'row-major', 10.0 ); // $ExpectError - full( 'float32', ( x: number ): number => x, 'row-major', 10.0 ); // $ExpectError + full( 10.0, 'float32', '5', 'row-major' ); // $ExpectError + full( 10.0, 'float32', false, 'row-major' ); // $ExpectError + full( 10.0, 'float32', true, 'row-major' ); // $ExpectError + full( 10.0, 'float32', null, 'row-major' ); // $ExpectError + full( 10.0, 'float32', undefined, 'row-major' ); // $ExpectError + full( 10.0, 'float32', [ '5' ], 'row-major' ); // $ExpectError + full( 10.0, 'float32', {}, 'row-major' ); // $ExpectError + full( 10.0, 'float32', ( x: number ): number => x, 'row-major' ); // $ExpectError } -// The compiler throws an error if the function is not provided a valid order for the third argument... +// The compiler throws an error if the function is not provided a valid order for the fourth argument... { - full( 'float32', [ 2, 2 ], '5', 10.0 ); // $ExpectError - full( 'float32', [ 2, 2 ], false, 10.0 ); // $ExpectError - full( 'float32', [ 2, 2 ], true, 10.0 ); // $ExpectError - full( 'float32', [ 2, 2 ], null, 10.0 ); // $ExpectError - full( 'float32', [ 2, 2 ], undefined, 10.0 ); // $ExpectError - full( 'float32', [ 2, 2 ], [ '5' ], 10.0 ); // $ExpectError - full( 'float32', [ 2, 2 ], {}, 10.0 ); // $ExpectError - full( 'float32', [ 2, 2 ], ( x: number ): number => x, 10.0 ); // $ExpectError + full( 10.0, 'float32', [ 2, 2 ], '5' ); // $ExpectError + full( 10.0, 'float32', [ 2, 2 ], false ); // $ExpectError + full( 10.0, 'float32', [ 2, 2 ], true ); // $ExpectError + full( 10.0, 'float32', [ 2, 2 ], null ); // $ExpectError + full( 10.0, 'float32', [ 2, 2 ], undefined ); // $ExpectError + full( 10.0, 'float32', [ 2, 2 ], [ '5' ] ); // $ExpectError + full( 10.0, 'float32', [ 2, 2 ], {} ); // $ExpectError + full( 10.0, 'float32', [ 2, 2 ], ( x: number ): number => x ); // $ExpectError } -// The compiler throws an error if the function is not provided a valid value for the fourth argument... +// The compiler throws an error if the function is not provided a valid value for the first argument... { - full( 'float32', [ 2, 2 ], 'row-major', '5' ); // $ExpectError - full( 'float32', [ 2, 2 ], 'row-major', false ); // $ExpectError - full( 'float32', [ 2, 2 ], 'row-major', true ); // $ExpectError - full( 'float32', [ 2, 2 ], 'row-major', null ); // $ExpectError - full( 'float32', [ 2, 2 ], 'row-major', undefined ); // $ExpectError - full( 'float32', [ 2, 2 ], 'row-major', [ '5' ] ); // $ExpectError - full( 'float32', [ 2, 2 ], 'row-major', {} ); // $ExpectError - full( 'float32', [ 2, 2 ], 'row-major', ( x: number ): number => x ); // $ExpectError + full( '5', 'float32', [ 2, 2 ], 'row-major' ); // $ExpectError + full( false, 'float32', [ 2, 2 ], 'row-major' ); // $ExpectError + full( true, 'float32', [ 2, 2 ], 'row-major' ); // $ExpectError + full( null, 'float32', [ 2, 2 ], 'row-major' ); // $ExpectError + full( undefined, 'float32', [ 2, 2 ], 'row-major' ); // $ExpectError + full( [ '5' ], 'float32', [ 2, 2 ], 'row-major' ); // $ExpectError + full( {}, 'float32', [ 2, 2 ], 'row-major' ); // $ExpectError + full( ( x: number ): number => x, 'float32', [ 2, 2 ], 'row-major' ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { - full( 'float64' ); // $ExpectError - full( 'float64', [ 2, 2 ] ); // $ExpectError - full( 'float64', [ 2, 2 ], 'row-major' ); // $ExpectError + full( 10.0 ); // $ExpectError + full( 10.0, 'float64' ); // $ExpectError + full( 10.0, 'float64', [ 2, 2 ] ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/full/examples/index.js index cd6e2ccb3258..6f81ff099a08 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/examples/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/examples/index.js @@ -29,6 +29,6 @@ var dt = dtypes( 'integer_and_generic' ); var arr; var i; for ( i = 0; i < dt.length; i++ ) { - arr = full( dt[ i ], [ 2, 2 ], 'row-major', 10 ); + arr = full( 10, dt[ i ], [ 2, 2 ], 'row-major' ); console.log( ndarray2array( arr ) ); } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js index 861eaeb41b78..025d6c46d49a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js @@ -28,7 +28,7 @@ * var getDType = require( '@stdlib/ndarray/dtype' ); * var full = require( '@stdlib/ndarray/base/full' ); * -* var arr = full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 10.0, 'float32', [ 2, 2 ], 'row-major' ); * // returns * * var sh = getShape( arr ); diff --git a/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js index 73522481bf6b..decbccccaee1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js @@ -22,7 +22,8 @@ var isScalarMostlySafeCompatible = require( '@stdlib/ndarray/base/assert/is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length var empty = require( '@stdlib/ndarray/base/empty' ); -var fill = require( '@stdlib/ndarray/base/fill' ); +var broadcastScalar = require( '@stdlib/ndarray/base/broadcast-scalar' ); +var assign = require( '@stdlib/ndarray/base/assign' ); var format = require( '@stdlib/string/format' ); @@ -31,11 +32,11 @@ var format = require( '@stdlib/string/format' ); /** * Creates an ndarray having a specified shape, data type, and filled with a specified value. * +* @param {*} value - fill value * @param {*} dtype - data type * @param {NonNegativeIntegerArray} shape - array shape * @param {string} order - array order -* @param {*} value - fill value -* @throws {TypeError} first argument must be a recognized data type +* @throws {TypeError} second argument must be a recognized data type * @throws {TypeError} fill value is not compatible with the specified data type * @returns {ndarray} ndarray * @@ -43,7 +44,7 @@ var format = require( '@stdlib/string/format' ); * var getShape = require( '@stdlib/ndarray/shape' ); * var getDType = require( '@stdlib/ndarray/dtype' ); * -* var arr = full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); +* var arr = full( 10.0, 'float32', [ 2, 2 ], 'row-major' ); * // returns * * var sh = getShape( arr ); @@ -52,15 +53,23 @@ var format = require( '@stdlib/string/format' ); * var dt = String( getDType( arr ) ); * // returns 'float32' */ -function full( dtype, shape, order, value ) { +function full( value, dtype, shape, order ) { var arr; + var v; if ( !isScalarMostlySafeCompatible( value, dtype ) ) { throw new TypeError( format( 'invalid argument. Fill value is not compatible with the specified data type. Value: %s, Data Type: %s', value, dtype ) ); } arr = empty( dtype, shape, order ); - return fill( arr, value ); + + // Broadcast the fill value to an ndarray of same shape and data type as the input ndarray: + v = broadcastScalar( value, dtype, shape, order ); + + // Assign the fill value to each element of the input ndarray: + assign( [ v, arr ] ); // TODO: consider replacing with ndarray/base/assign-scalar in order to avoid zero-dimensional ndarray creation and subsequent broadcasting + + return arr; } diff --git a/lib/node_modules/@stdlib/ndarray/base/full/test/test.js b/lib/node_modules/@stdlib/ndarray/base/full/test/test.js index b1d39ee70c49..d4827b77de92 100644 --- a/lib/node_modules/@stdlib/ndarray/base/full/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/base/full/test/test.js @@ -77,7 +77,7 @@ tape( 'the function throws an error if provided a value which cannot be safely c function badValue( value ) { return function badValue() { - full( dtype, [ 2, 2 ], 'row-major', value ); + full( value, dtype, [ 2, 2 ], 'row-major' ); }; } }); @@ -112,7 +112,7 @@ tape( 'the function throws an error if provided an unrecognized data type', func function badValue( value ) { return function badValue() { - full( value, 10, 'row-major', 10.0 ); + full( 10.0, value, 10, 'row-major' ); }; } }); @@ -128,7 +128,7 @@ tape( 'the function returns an initialized array (dtype=float64, order=row-major 10.0 ]); - arr = full( 'float64', [ 2, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'float64', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -150,7 +150,7 @@ tape( 'the function returns an initialized array (dtype=float64, order=column-ma 10.0 ]); - arr = full( 'float64', [ 2, 2 ], 'column-major', 10.0 ); + arr = full( 10.0, 'float64', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -172,7 +172,7 @@ tape( 'the function returns an initialized array (dtype=float32, order=row-major 10.0 ]); - arr = full( 'float32', [ 2, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'float32', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -194,7 +194,7 @@ tape( 'the function returns an initialized array (dtype=float32, order=column-ma 10.0 ]); - arr = full( 'float32', [ 2, 2 ], 'column-major', 10.0 ); + arr = full( 10.0, 'float32', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'float32', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -216,7 +216,7 @@ tape( 'the function returns an initialized array (dtype=int32, order=row-major)' 10.0 ]); - arr = full( 'int32', [ 2, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'int32', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -238,7 +238,7 @@ tape( 'the function returns an initialized array (dtype=int32, order=column-majo 10.0 ]); - arr = full( 'int32', [ 2, 2 ], 'column-major', 10.0 ); + arr = full( 10.0, 'int32', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'int32', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -260,7 +260,7 @@ tape( 'the function returns an initialized array (dtype=int16, order=row-major)' 10.0 ]); - arr = full( 'int16', [ 2, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'int16', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -282,7 +282,7 @@ tape( 'the function returns an initialized array (dtype=int16, order=column-majo 10.0 ]); - arr = full( 'int16', [ 2, 2 ], 'column-major', 10.0 ); + arr = full( 10.0, 'int16', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'int16', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -304,7 +304,7 @@ tape( 'the function returns an initialized array (dtype=int8, order=row-major)', 10.0 ]); - arr = full( 'int8', [ 2, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'int8', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -326,7 +326,7 @@ tape( 'the function returns an initialized array (dtype=int8, order=column-major 10.0 ]); - arr = full( 'int8', [ 2, 2 ], 'column-major', 10.0 ); + arr = full( 10.0, 'int8', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'int8', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -348,7 +348,7 @@ tape( 'the function returns an initialized array (dtype=uint32, order=row-major) 10.0 ]); - arr = full( 'uint32', [ 2, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'uint32', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -370,7 +370,7 @@ tape( 'the function returns an initialized array (dtype=uint32, order=column-maj 10.0 ]); - arr = full( 'uint32', [ 2, 2 ], 'column-major', 10.0 ); + arr = full( 10.0, 'uint32', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'uint32', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -392,7 +392,7 @@ tape( 'the function returns an initialized array (dtype=uint16, order=row-major) 10.0 ]); - arr = full( 'uint16', [ 2, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'uint16', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -414,7 +414,7 @@ tape( 'the function returns an initialized array (dtype=uint16, order=column-maj 10.0 ]); - arr = full( 'uint16', [ 2, 2 ], 'column-major', 10.0 ); + arr = full( 10.0, 'uint16', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'uint16', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -436,7 +436,7 @@ tape( 'the function returns an initialized array (dtype=uint8, order=row-major)' 10.0 ]); - arr = full( 'uint8', [ 2, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'uint8', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -458,7 +458,7 @@ tape( 'the function returns an initialized array (dtype=uint8, order=column-majo 10.0 ]); - arr = full( 'uint8', [ 2, 2 ], 'column-major', 10.0 ); + arr = full( 10.0, 'uint8', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'uint8', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -480,7 +480,7 @@ tape( 'the function returns an initialized array (dtype=uint8c, order=row-major) 10.0 ]); - arr = full( 'uint8c', [ 2, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'uint8c', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -502,7 +502,7 @@ tape( 'the function returns an initialized array (dtype=uint8c, order=column-maj 10.0 ]); - arr = full( 'uint8c', [ 2, 2 ], 'column-major', 10.0 ); + arr = full( 10.0, 'uint8c', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'uint8c', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -519,7 +519,7 @@ tape( 'the function returns an initialized array (dtype=binary, order=row-major) expected = new Buffer( [ 1, 1, 1, 1 ] ); - arr = full( 'binary', [ 2, 2 ], 'row-major', 1 ); + arr = full( 1, 'binary', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -541,7 +541,7 @@ tape( 'the function returns an initialized array (dtype=binary, order=column-maj 1 ]); - arr = full( 'binary', [ 2, 2 ], 'column-major', 1 ); + arr = full( 1, 'binary', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'binary', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -567,7 +567,7 @@ tape( 'the function returns an initialized array (dtype=complex128, order=row-ma 0.0 ]); - arr = full( 'complex128', [ 2, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'complex128', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -593,7 +593,7 @@ tape( 'the function returns an initialized array (dtype=complex128, order=column 0.0 ]); - arr = full( 'complex128', [ 2, 2 ], 'column-major', 10.0 ); + arr = full( 10.0, 'complex128', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'complex128', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -619,7 +619,7 @@ tape( 'the function returns an initialized array (dtype=complex64, order=row-maj 0.0 ]); - arr = full( 'complex64', [ 2, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'complex64', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -636,7 +636,7 @@ tape( 'the function returns an initialized array (dtype=complex64, order=column- expected = new Complex64Array( [ [10.0, 0.0], [10.0, 0.0] ] ); - arr = full( 'complex64', [ 2, 2 ], 'column-major', 10.0 ); + arr = full( 10.0, 'complex64', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'complex64', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -653,7 +653,7 @@ tape( 'the function returns an initialized array (dtype=bool, order=row-major)', expected = new BooleanArray( [ [true, true], [true, true] ] ); - arr = full( 'bool', [ 2, 2 ], 'row-major', true ); + arr = full( true, 'bool', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -670,7 +670,7 @@ tape( 'the function returns an initialized array (dtype=bool, order=column-major expected = new BooleanArray( [ [true, true], [true, true] ] ); - arr = full( 'bool', [ 2, 2 ], 'column-major', true ); + arr = full( true, 'bool', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'bool', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -687,7 +687,7 @@ tape( 'the function returns a filled array (dtype=generic, order=row-major)', fu expected = [ 10.0, 10.0, 10.0, 10.0 ]; - arr = full( 'generic', [ 2, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'generic', [ 2, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -704,7 +704,7 @@ tape( 'the function returns a filled array (dtype=generic, order=column-major)', expected = [ 10.0, 10.0, 10.0, 10.0 ]; - arr = full( 'generic', [ 2, 2 ], 'column-major', 10.0 ); + arr = full( 10.0, 'generic', [ 2, 2 ], 'column-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'generic', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 2 ], 'returns expected value' ); @@ -718,7 +718,7 @@ tape( 'the function returns a filled array (dtype=generic, order=column-major)', tape( 'the function supports zero-dimensional arrays', function test( t ) { var arr; - arr = full( 'float64', [], 'row-major', 10.0 ); + arr = full( 10.0, 'float64', [], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); t.deepEqual( getShape( arr ), [], 'returns expected value' ); @@ -735,7 +735,7 @@ tape( 'the function supports full arrays', function test( t ) { expected = new Float64Array( 0 ); - arr = full( 'float64', [ 2, 0, 2 ], 'row-major', 10.0 ); + arr = full( 10.0, 'float64', [ 2, 0, 2 ], 'row-major' ); t.strictEqual( instanceOf( arr, ndarray ), true, 'returns expected value' ); t.strictEqual( String( getDType( arr ) ), 'float64', 'returns expected value' ); t.deepEqual( getShape( arr ), [ 2, 0, 2 ], 'returns expected value' );