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..42254ec13759 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/README.md @@ -0,0 +1,140 @@ + + +# full + +> Create an [ndarray][@stdlib/ndarray/base/ctor] having a specified shape, [data type][@stdlib/ndarray/dtypes], and filled with a specified value. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var full = require( '@stdlib/ndarray/base/full' ); +``` + +#### 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. + +```javascript +var getShape = require( '@stdlib/ndarray/shape' ); +var getDType = require( '@stdlib/ndarray/dtype' ); + +var arr = full( 10.0, 'float64', [ 2, 2 ], 'row-major' ); +// returns + +var sh = getShape( arr ); +// returns [ 2, 2 ] + +var dt = String( getDType( arr ) ); +// returns 'float64' +``` + +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). + +
+ + + + + +
+ +## Notes + +- A `value` must be able to safely cast to the input `dtype`. +- 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. + +
+ + + + + +
+ +## Examples + + + +```javascript +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var full = require( '@stdlib/ndarray/base/full' ); + +// 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( 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 new file mode 100644 index 000000000000..184bfb1a094a --- /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( 10.0, 'float64', [ 0 ], 'row-major' ); + 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( 10.0, 'float32', [ 0 ], 'row-major' ); + 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( 10.0, 'complex128', [ 0 ], 'row-major' ); + 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( 10.0, 'complex64', [ 0 ], 'row-major' ); + 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( -10, 'int32', [ 0 ], 'row-major' ); + 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( 10, 'uint32', [ 0 ], 'row-major' ); + 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( -10, 'int16', [ 0 ], 'row-major' ); + 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( 10, 'uint16', [ 0 ], 'row-major' ); + 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( -10, 'int8', [ 0 ], 'row-major' ); + 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( 10, 'uint8', [ 0 ], 'row-major' ); + 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( 10, 'uint8c', [ 0 ], 'row-major' ); + 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( true, 'bool', [ 0 ], 'row-major' ); + 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( 10.0, 'generic', [ 0 ], 'row-major' ); + 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..829f77c1ebd8 --- /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( true, 'bool', [ len ], 'row-major' ); + 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..2916b8424411 --- /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( 10.0, 'complex128', [ len ], 'row-major' ); + 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..153fef30b688 --- /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( 10.0, 'complex64', [ len ], 'row-major' ); + 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..f3a2dc3b2300 --- /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( 10.0, 'float32', [ len ], 'row-major' ); + 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..88bb3a9a3e94 --- /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( 10.0, 'float64', [ len ], 'row-major' ); + 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..912efa9dc6f8 --- /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( 10.0, 'generic', [ len ], 'row-major' ); + 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..a3328c96515b --- /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( 10, 'int16', [ len ], 'row-major' ); + 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..6682544b7f4d --- /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( 10, 'int32', [ len ], 'row-major' ); + 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..1eb8a72360cd --- /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( 10, 'int8', [ len ], 'row-major' ); + 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..68149d1306db --- /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( 10, 'uint16', [ len ], 'row-major' ); + 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..5ac7c91b740c --- /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( 10, 'uint8', [ len ], 'row-major' ); + 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..5306ad956f47 --- /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( 10, 'uint8c', [ len ], 'row-major' ); + 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..01bf4d560131 --- /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( 10, 'uint32', [ len ], 'row-major' ); + 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 new file mode 100644 index 000000000000..487f965bd8e1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/docs/repl.txt @@ -0,0 +1,45 @@ + +{{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. + + 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. + + shape: ArrayLikeObject + Array shape. + + order: string + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). + + Returns + ------- + out: ndarray + Output ndarray. + + Examples + -------- + > var arr = {{alias}}( 10.0, 'float64', [ 2, 2 ], 'row-major' ) + + > 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..f0ba5c13c4d8 --- /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, genericndarray, DataType } from '@stdlib/types/ndarray'; +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) +* @returns output array +* +* @example +* var arr = full( 10.0, 'float64', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float64' +*/ +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) +* @returns output array +* +* @example +* var arr = full( 10.0, 'float32', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float32' +*/ +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) +* @returns output array +* +* @example +* var arr = full( 10.0, 'complex128', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'complex128' +*/ +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) +* @returns output array +* +* @example +* var arr = full( { 're': 10, 'im': 5 }, 'complex64', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'complex64' +*/ +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) +* @returns output array +* +* @example +* var arr = full( 10, 'int32', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'int32' +*/ +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) +* @returns output array +* +* @example +* var arr = full( 10, 'int16', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'int16' +*/ +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) +* @returns output array +* +* @example +* var arr = full( 10, 'int8', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'int8' +*/ +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) +* @returns output array +* +* @example +* var arr = full( 10, 'uint32', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint32' +*/ +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) +* @returns output array +* +* @example +* var arr = full( 10, 'uint16', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint16' +*/ +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) +* @returns output array +* +* @example +* var arr = full( 10, 'uint8', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint8' +*/ +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) +* @returns output array +* +* @example +* var arr = full( 10, 'uint8c', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'uint8c' +*/ +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) +* @returns output array +* +* @example +* var arr = full( true, 'bool', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'bool' +*/ +declare function full( value: number | boolean, dtype: 'bool', shape: Shape, order: Order ): boolndarray; + +/** +* 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) +* @returns output array +* +* @example +* var arr = full( 10.0, 'generic', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'generic' +*/ +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) +* @returns output array +* +* @example +* var arr = full( 10.0, 'float32', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = arr.shape; +* // returns [ 2, 2 ] +* +* var dt = arr.dtype; +* // returns 'float32' +*/ +declare function full( value: number | ComplexLike, dtype: DataType, shape: Shape, order: Order ): 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..2dcb03925950 --- /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( 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( 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 second argument which is an unrecognized/unsupported data type... +{ + 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 third argument... +{ + 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 fourth argument... +{ + 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 first argument... +{ + 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( 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 new file mode 100644 index 000000000000..6f81ff099a08 --- /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( 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 new file mode 100644 index 000000000000..025d6c46d49a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/lib/index.js @@ -0,0 +1,48 @@ +/** +* @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'; + +/** +* Create an 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 full = require( '@stdlib/ndarray/base/full' ); +* +* var arr = full( 10.0, 'float32', [ 2, 2 ], 'row-major' ); +* // returns +* +* 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..decbccccaee1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/full/lib/main.js @@ -0,0 +1,78 @@ +/** +* @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 broadcastScalar = require( '@stdlib/ndarray/base/broadcast-scalar' ); +var assign = require( '@stdlib/ndarray/base/assign' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* 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 +* @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 +* +* @example +* var getShape = require( '@stdlib/ndarray/shape' ); +* var getDType = require( '@stdlib/ndarray/dtype' ); +* +* var arr = full( 10.0, 'float32', [ 2, 2 ], 'row-major' ); +* // returns +* +* var sh = getShape( arr ); +* // returns [ 2, 2 ] +* +* var dt = String( getDType( arr ) ); +* // returns 'float32' +*/ +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 ); + + // 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; +} + + +// 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..d4827b77de92 --- /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 value which cannot be safely cast to the input 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( value, dtype, [ 2, 2 ], 'row-major' ); + }; + } +}); + +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( 10.0, value, 10, 'row-major' ); + }; + } +}); + +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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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( 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' ); + 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(); +});