diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/README.md b/lib/node_modules/@stdlib/blas/ext/zero-to/README.md new file mode 100644 index 000000000000..b2e2b2113656 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/README.md @@ -0,0 +1,166 @@ + + +# zeroTo + +> Return a new [ndarray][@stdlib/ndarray/ctor] filled with linearly spaced numeric elements which increment by `1` starting from zero along one or more [ndarray][@stdlib/ndarray/ctor] dimensions. + +
+ +## Usage + +```javascript +var zeroTo = require( '@stdlib/blas/ext/zero-to' ); +``` + +#### zeroTo( shape\[, options] ) + +Returns a new [ndarray][@stdlib/ndarray/ctor] filled with linearly spaced numeric elements which increment by `1` starting from zero along one or more [ndarray][@stdlib/ndarray/ctor] dimensions. + +```javascript +var x = zeroTo( [ 2, 3 ] ); +// returns [ [ 0.0, 1.0, 2.0 ], [ 0.0, 1.0, 2.0 ] ] +``` + +The function has the following parameters: + +- **shape**: array shape. +- **options**: function options (_optional_). + +The function accepts the following options: + +- **dims**: list of dimensions over which to perform operation. If not provided, the function generates values along the last dimension. Default: `[-1]`. +- **dtype**: output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes]. Must be a numeric or "generic" [data type][@stdlib/ndarray/dtypes]. Default: `'float64'`. +- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`. +- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`. +- **submode**: a mode array which specifies for each dimension how to handle subscripts which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). If provided fewer modes than dimensions, the function recycles modes using modulo arithmetic. Default: `[ options.mode ]`. + +By default, the function generates values along the last dimension of an output [ndarray][@stdlib/ndarray/ctor]. To perform the operation over specific dimensions, provide a `dims` option. + +```javascript +var x = zeroTo( [ 2, 2 ], { + 'dims': [ 0, 1 ] +}); +// returns [ [ 0.0, 1.0 ], [ 2.0, 3.0 ] ] +``` + +To specify the output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes], provide a `dtype` option. + +```javascript +var x = zeroTo( [ 3 ], { + 'dtype': 'float32' +}); +// returns [ 0.0, 1.0, 2.0 ] +``` + +#### zeroTo.assign( x\[, options] ) + +Fills an [ndarray][@stdlib/ndarray/ctor] with linearly spaced numeric elements which increment by `1` starting from zero along one or more [ndarray][@stdlib/ndarray/ctor] dimensions. + +```javascript +var zeros = require( '@stdlib/ndarray/zeros' ); + +var x = zeros( [ 2, 3 ] ); +// returns [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] + +var out = zeroTo.assign( x ); +// returns [ [ 0.0, 1.0, 2.0 ], [ 0.0, 1.0, 2.0 ] ] + +var bool = ( x === out ); +// returns true +``` + +The function has the following parameters: + +- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a numeric or "generic" [data type][@stdlib/ndarray/dtypes]. +- **options**: function options (_optional_). + +The function accepts the following options: + +- **dims**: list of dimensions over which to perform operation. If not provided, the function generates values along the last dimension. Default: `[-1]`. + +
+ + + +
+ +## Notes + +- The function iterates over [ndarray][@stdlib/ndarray/ctor] elements according to the memory layout of the input [ndarray][@stdlib/ndarray/ctor]. Accordingly, performance degradation is possible when operating over multiple dimensions of a large non-contiguous multi-dimensional input [ndarray][@stdlib/ndarray/ctor]. In such scenarios, one may want to copy an input [ndarray][@stdlib/ndarray/ctor] to contiguous memory before performing the operation. + +
+ + + +
+ +## Examples + + + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var zeroTo = require( '@stdlib/blas/ext/zero-to' ); + +// Create a new ndarray: +var x = zeroTo( [ 5, 5 ], { + 'dtype': 'generic' +}); +console.log( ndarray2array( x ) ); + +// Generate values over a specific dimension: +x = zeroTo( [ 5, 5 ], { + 'dtype': 'generic', + 'dims': [ 0 ] +}); +console.log( ndarray2array( x ) ); + +// Generate values over all dimensions: +x = zeroTo( [ 5, 5 ], { + 'dtype': 'generic', + 'dims': [ 0, 1 ] +}); +console.log( ndarray2array( x ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/blas/ext/zero-to/benchmark/benchmark.assign.js new file mode 100644 index 000000000000..0087b9a7c7da --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/benchmark/benchmark.assign.js @@ -0,0 +1,103 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var assign = require( './../lib/assign.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = zeros( [ len ], options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var o; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + o = assign( x ); + if ( typeof o !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( x.get( i%len ) ) ) { + b.fail( 'should not return NaN' ); + } + 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:assign:dtype=%s,len=%d', pkg, options.dtype, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/zero-to/benchmark/benchmark.js new file mode 100644 index 000000000000..dfdc4bb36380 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/benchmark/benchmark.js @@ -0,0 +1,101 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var zeroTo = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// 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 o; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + o = zeroTo( [ len ], options ); + if ( typeof o !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( o.get( i%len ) ) ) { + b.fail( 'should not return NaN' ); + } + 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=%s,len=%d', pkg, options.dtype, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/zero-to/docs/repl.txt new file mode 100644 index 000000000000..eec9301746d7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/docs/repl.txt @@ -0,0 +1,92 @@ + +{{alias}}( shape[, options] ) + Returns a new ndarray filled with linearly spaced numeric elements which + increment by 1 starting from zero along one or more ndarray dimensions. + + Parameters + ---------- + shape: Array|integer + Array shape. + + options: Object (optional) + Function options. + + options.dims: Array (optional) + List of dimensions over which to perform operation. If not provided, + the function generates values along the last dimension. Default: [-1]. + + options.dtype: string (optional) + Output ndarray data type. Must be a numeric or "generic" data type. + Default: 'float64'. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.submode: Array (optional) + Specifies how to handle subscripts which exceed array dimensions. If a + mode for a corresponding dimension is equal to 'throw', an ndarray + instance throws an error when a subscript exceeds array dimensions. If + equal to 'normalize', an ndarray instance normalizes negative + subscripts and throws an error when a subscript exceeds array + dimensions. If equal to 'wrap', an ndarray instance wraps around + subscripts exceeding array dimensions using modulo arithmetic. If equal + to 'clamp', an ndarray instance sets a subscript exceeding array + dimensions to either `0` (minimum index) or the maximum index. If the + number of modes is fewer than the number of dimensions, the function + recycles modes using modulo arithmetic. Default: [ options.mode ]. + + Returns + ------- + out: ndarray + Output array. + + Examples + -------- + > var out = {{alias}}( [ 2, 3 ] ) + [ [ 0.0, 1.0, 2.0 ], [ 0.0, 1.0, 2.0 ] ] + + +{{alias}}.assign( x[, options] ) + Fills an ndarray with linearly spaced numeric elements which increment by + 1 starting from zero along one or more ndarray dimensions. + + The function fills an ndarray in-place and thus mutates the input ndarray. + + Parameters + ---------- + x: ndarray + Input array. Must have a numeric or "generic" data type. + + options: Object (optional) + Function options. + + options.dims: Array (optional) + List of dimensions over which to perform operation. If not provided, + the function generates values along the last dimension. Default: [-1]. + + Returns + ------- + out: ndarray + Input array. + + Examples + -------- + > var x = {{alias:@stdlib/ndarray/zeros}}( [ 2, 3 ] ); + > var out = {{alias}}.assign( x ) + [ [ 0.0, 1.0, 2.0 ], [ 0.0, 1.0, 2.0 ] ] + > var bool = ( out === x ) + true + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/zero-to/docs/types/index.d.ts new file mode 100644 index 000000000000..1f28a866994c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/docs/types/index.d.ts @@ -0,0 +1,137 @@ +/* +* @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 { ArrayLike } from '@stdlib/types/array'; +import { NumericAndGenericDataType as DataType, typedndarray, genericndarray, Mode, Order } from '@stdlib/types/ndarray'; + +/** +* Output array. +*/ +type OutputArray = typedndarray | genericndarray; + +/** +* Interface defining "base" options. +*/ +interface BaseOptions { + /** + * List of dimensions over which to perform operation. + */ + dims?: ArrayLike; +} + +/** +* Interface defining options. +*/ +interface Options extends BaseOptions { + /** + * Output ndarray data type. + */ + dtype?: DataType; + + /** + * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). + */ + order?: Order; + + /** + * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). + */ + mode?: Mode; + + /** + * Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']). + */ + submode?: Array; +} + +/** +* Interface for performing an operation on an ndarray. +*/ +interface ZeroTo { + /** + * Returns a new ndarray filled with linearly spaced numeric elements which increment by 1 starting from zero along one or more ndarray dimensions. + * + * @param shape - array shape + * @param options - function options + * @returns output ndarray + * + * @example + * var out = zeroTo( [ 2, 3 ] ); + * // returns [ [ 0.0, 1.0, 2.0 ], [ 0.0, 1.0, 2.0 ] ] + */ + ( shape: number | ArrayLike, options?: Options ): OutputArray; + + /** + * Fills an ndarray with linearly spaced numeric elements which increment by 1 starting from zero along one or more ndarray dimensions. + * + * ## Notes + * + * - The input ndarray is filled **in-place** (i.e., the input ndarray is **mutated**). + * + * @param x - input ndarray + * @param options - function options + * @returns output ndarray + * + * @example + * var zeros = require( '@stdlib/ndarray/zeros' ); + * + * var x = zeros( [ 2, 3 ] ); + * // returns [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] + * + * var out = zeroTo.assign( x ); + * // returns [ [ 0.0, 1.0, 2.0 ], [ 0.0, 1.0, 2.0 ] ] + * + * var bool = ( out === x ); + * // returns true + */ + assign( x: T, options?: BaseOptions ): T; +} + +/** +* Returns a new ndarray filled with linearly spaced numeric elements which increment by 1 starting from zero along one or more ndarray dimensions. +* +* @param shape - array shape +* @param options - function options +* @returns output ndarray +* +* @example +* var out = zeroTo( [ 2, 3 ] ); +* // returns [ [ 0.0, 1.0, 2.0 ], [ 0.0, 1.0, 2.0 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* +* var x = zeros( [ 2, 3 ] ); +* // returns [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] +* +* var out = zeroTo.assign( x ); +* // returns [ [ 0.0, 1.0, 2.0 ], [ 0.0, 1.0, 2.0 ] ] +* +* var bool = ( out === x ); +* // returns true +*/ +declare const zeroTo: ZeroTo; + + +// EXPORTS // + +export = zeroTo; diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/zero-to/docs/types/test.ts new file mode 100644 index 000000000000..35bf4e48930f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/docs/types/test.ts @@ -0,0 +1,166 @@ +/* +* @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. +*/ + +/* eslint-disable space-in-parens */ + +/// + +import zeros = require( '@stdlib/ndarray/zeros' ); +import zeroTo = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + zeroTo( [ 3 ] ); // $ExpectType OutputArray + zeroTo( [ 2, 2 ] ); // $ExpectType OutputArray + zeroTo( 3 ); // $ExpectType OutputArray + zeroTo( [ 3 ], {} ); // $ExpectType OutputArray + zeroTo( [ 3 ], { 'dtype': 'float32' } ); // $ExpectType OutputArray +} + +// The compiler throws an error if the function is provided a first argument which is not a number or an array of numbers... +{ + zeroTo( '5' ); // $ExpectError + zeroTo( true ); // $ExpectError + zeroTo( false ); // $ExpectError + zeroTo( null ); // $ExpectError + zeroTo( void 0 ); // $ExpectError + zeroTo( {} ); // $ExpectError + zeroTo( ( x: number ): number => x ); // $ExpectError + + zeroTo( '5', {} ); // $ExpectError + zeroTo( true, {} ); // $ExpectError + zeroTo( false, {} ); // $ExpectError + zeroTo( null, {} ); // $ExpectError + zeroTo( void 0, {} ); // $ExpectError + zeroTo( {}, {} ); // $ExpectError + zeroTo( ( x: number ): number => x, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an options argument which is not an object... +{ + zeroTo( [ 3 ], '5' ); // $ExpectError + zeroTo( [ 3 ], 5 ); // $ExpectError + zeroTo( [ 3 ], true ); // $ExpectError + zeroTo( [ 3 ], false ); // $ExpectError + zeroTo( [ 3 ], null ); // $ExpectError + zeroTo( [ 3 ], [] ); // $ExpectError + zeroTo( [ 3 ], ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid `dtype` option... +{ + zeroTo( [ 3 ], { 'dtype': '5' } ); // $ExpectError + zeroTo( [ 3 ], { 'dtype': 5 } ); // $ExpectError + zeroTo( [ 3 ], { 'dtype': true } ); // $ExpectError + zeroTo( [ 3 ], { 'dtype': false } ); // $ExpectError + zeroTo( [ 3 ], { 'dtype': null } ); // $ExpectError + zeroTo( [ 3 ], { 'dtype': [] } ); // $ExpectError + zeroTo( [ 3 ], { 'dtype': {} } ); // $ExpectError + zeroTo( [ 3 ], { 'dtype': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid `dims` option... +{ + zeroTo( [ 3 ], { 'dims': '5' } ); // $ExpectError + zeroTo( [ 3 ], { 'dims': 5 } ); // $ExpectError + zeroTo( [ 3 ], { 'dims': true } ); // $ExpectError + zeroTo( [ 3 ], { 'dims': false } ); // $ExpectError + zeroTo( [ 3 ], { 'dims': null } ); // $ExpectError + zeroTo( [ 3 ], { 'dims': {} } ); // $ExpectError + zeroTo( [ 3 ], { 'dims': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + zeroTo(); // $ExpectError + zeroTo( [ 3 ], {}, {} ); // $ExpectError +} + +// Attached to the function is an `assign` method which returns an ndarray... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + zeroTo.assign( x ); // $ExpectType float64ndarray + zeroTo.assign( x, {} ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... +{ + zeroTo.assign( '5' ); // $ExpectError + zeroTo.assign( 5 ); // $ExpectError + zeroTo.assign( true ); // $ExpectError + zeroTo.assign( false ); // $ExpectError + zeroTo.assign( null ); // $ExpectError + zeroTo.assign( void 0 ); // $ExpectError + zeroTo.assign( {} ); // $ExpectError + zeroTo.assign( ( x: number ): number => x ); // $ExpectError + + zeroTo.assign( '5', {} ); // $ExpectError + zeroTo.assign( 5, {} ); // $ExpectError + zeroTo.assign( true, {} ); // $ExpectError + zeroTo.assign( false, {} ); // $ExpectError + zeroTo.assign( null, {} ); // $ExpectError + zeroTo.assign( void 0, {} ); // $ExpectError + zeroTo.assign( {}, {} ); // $ExpectError + zeroTo.assign( ( x: number ): number => x, {} ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an options argument which is not an object... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + zeroTo.assign( x, '5' ); // $ExpectError + zeroTo.assign( x, 5 ); // $ExpectError + zeroTo.assign( x, true ); // $ExpectError + zeroTo.assign( x, false ); // $ExpectError + zeroTo.assign( x, null ); // $ExpectError + zeroTo.assign( x, [] ); // $ExpectError + zeroTo.assign( x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an invalid `dims` option... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + zeroTo.assign( x, { 'dims': '5' } ); // $ExpectError + zeroTo.assign( x, { 'dims': 5 } ); // $ExpectError + zeroTo.assign( x, { 'dims': true } ); // $ExpectError + zeroTo.assign( x, { 'dims': false } ); // $ExpectError + zeroTo.assign( x, { 'dims': null } ); // $ExpectError + zeroTo.assign( x, { 'dims': {} } ); // $ExpectError + zeroTo.assign( x, { 'dims': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + zeroTo.assign(); // $ExpectError + zeroTo.assign( x, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/examples/index.js b/lib/node_modules/@stdlib/blas/ext/zero-to/examples/index.js new file mode 100644 index 000000000000..a2f04c93ede8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/examples/index.js @@ -0,0 +1,42 @@ +/** +* @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 ndarray2array = require( '@stdlib/ndarray/to-array' ); +var zeroTo = require( './../lib' ); + +// Create a new ndarray: +var x = zeroTo( [ 5, 5 ], { + 'dtype': 'generic' +}); +console.log( ndarray2array( x ) ); + +// Generate values over a specific dimension: +x = zeroTo( [ 5, 5 ], { + 'dtype': 'generic', + 'dims': [ 0 ] +}); +console.log( ndarray2array( x ) ); + +// Generate values over all dimensions: +x = zeroTo( [ 5, 5 ], { + 'dtype': 'generic', + 'dims': [ 0, 1 ] +}); +console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/lib/assign.js b/lib/node_modules/@stdlib/blas/ext/zero-to/lib/assign.js new file mode 100644 index 000000000000..3e287f2b6ce7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/lib/assign.js @@ -0,0 +1,105 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isPlainObject = require( '@stdlib/assert/is-plain-object' ); +var isEmptyCollection = require( '@stdlib/assert/is-empty-collection' ); +var isIntegerArray = require( '@stdlib/assert/is-integer-array' ).primitives; +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var contains = require( '@stdlib/array/base/assert/contains' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var DTYPES = require( './dtypes.js' ); +var defaults = require( './defaults.js' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Fills an ndarray with linearly spaced numeric elements which increment by 1 starting from zero along one or more ndarray dimensions. +* +* @param {ndarrayLike} x - input ndarray +* @param {Options} [options] - function options +* @param {IntegerArray} [options.dims=[-1]] - list of dimensions over which to perform operation +* @throws {TypeError} first argument must be an ndarray-like object having at least one dimension +* @throws {TypeError} first argument must have a supported data type +* @throws {TypeError} options argument must be an object +* @throws {TypeError} must provide valid options +* @throws {RangeError} dimension indices must not exceed input ndarray bounds +* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions +* @returns {ndarray} input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* +* var x = zeros( [ 2, 3 ] ); +* // returns [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] +* +* var out = assign( x ); +* // returns [ [ 0.0, 1.0, 2.0 ], [ 0.0, 1.0, 2.0 ] ] +* +* var bool = ( out === x ); +* // returns true +*/ +function assign( x ) { + var options; + var opts; + var sh; + var dt; + + if ( !isndarrayLike( x ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + } + sh = getShape( x ); + if ( sh.length < 1 ) { + throw new TypeError( 'invalid argument. First argument must be an ndarray having at least one dimension.' ); + } + dt = resolveStr( getDType( x ) ); + if ( !contains( DTYPES.odtypes, dt ) ) { + throw new TypeError( format( 'invalid argument. First argument must have one of the following data types: "%s". Data type: `%s`.', join( DTYPES.odtypes, '", "' ), dt ) ); + } + options = defaults(); + + if ( arguments.length > 1 ) { + opts = arguments[ 1 ]; + if ( !isPlainObject( opts ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + } + if ( hasOwnProp( opts, 'dims' ) ) { + if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { // eslint-disable-line max-len + throw new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); + } + options.dims = opts.dims; + } + } + // Perform operation: + return base( x, options ); +} + + +// EXPORTS // + +module.exports = assign; diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/lib/base.js b/lib/node_modules/@stdlib/blas/ext/zero-to/lib/base.js new file mode 100644 index 000000000000..b3dfd12ca75a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/lib/base.js @@ -0,0 +1,87 @@ +/** +* @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 gzeroTo = require( '@stdlib/blas/ext/base/ndarray/gzero-to' ); +var dzeroTo = require( '@stdlib/blas/ext/base/ndarray/dzero-to' ); +var szeroTo = require( '@stdlib/blas/ext/base/ndarray/szero-to' ); +var czeroTo = require( '@stdlib/blas/ext/base/ndarray/czero-to' ); +var zzeroTo = require( '@stdlib/blas/ext/base/ndarray/zzero-to' ); +var factory = require( '@stdlib/ndarray/base/nullary-strided1d-dispatch-factory' ); +var DTYPES = require( './dtypes.js' ); + + +// VARIABLES // + +var table = { + 'types': [ + 'float64', // output + 'float32', // output + 'complex128', // output + 'complex64' // output + ], + 'fcns': [ + dzeroTo, + szeroTo, + zzeroTo, + czeroTo + ], + 'default': gzeroTo +}; +var options = { + 'strictTraversalOrder': true +}; + + +// MAIN // + +/** +* Fills an ndarray with linearly spaced numeric elements which increment by 1 starting from zero. +* +* @private +* @name zeroTo +* @type {Function} +* @param {ndarray} x - input ndarray +* @param {Options} [options] - function options +* @param {IntegerArray} [options.dims] - list of dimensions over which to perform operation +* @throws {TypeError} first argument must be an ndarray-like object +* @throws {TypeError} first argument must have a supported data type +* @throws {TypeError} options argument must be an object +* @throws {RangeError} dimension indices must not exceed input ndarray bounds +* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions +* @throws {Error} must provide valid options +* @returns {ndarray} input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* +* var x = zeros( [ 2, 3 ] ); +* // returns [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] +* +* var y = zeroTo( x ); +* // returns [ [ 0.0, 1.0, 2.0 ], [ 3.0, 4.0, 5.0 ] ] +*/ +var zeroTo = factory( table, [], DTYPES.odtypes, options ); + + +// EXPORTS // + +module.exports = zeroTo; diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/lib/defaults.js b/lib/node_modules/@stdlib/blas/ext/zero-to/lib/defaults.js new file mode 100644 index 000000000000..a8ac5148b369 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/lib/defaults.js @@ -0,0 +1,38 @@ +/** +* @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'; + +// MAIN // + +/** +* Returns default options. +* +* @private +* @returns {Object} default options +*/ +function defaults() { + return { + 'dims': [ -1 ] // by default, generate values along the last dimension + }; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/lib/dtypes.js b/lib/node_modules/@stdlib/blas/ext/zero-to/lib/dtypes.js new file mode 100644 index 000000000000..1b5a26cdd918 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/lib/dtypes.js @@ -0,0 +1,36 @@ +/** +* @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 dtypes2strings = require( '@stdlib/ndarray/base/dtypes2strings' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); + + +// MAIN // + +var dt = { + 'odtypes': dtypes2strings( dtypes( 'numeric_and_generic' ) ) +}; + + +// EXPORTS // + +module.exports = dt; diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/lib/index.js b/lib/node_modules/@stdlib/blas/ext/zero-to/lib/index.js new file mode 100644 index 000000000000..efcfccacb5f5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/lib/index.js @@ -0,0 +1,62 @@ +/** +* @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 filled with linearly spaced numeric elements which increment by 1 starting from zero along one or more ndarray dimensions. +* +* @module @stdlib/blas/ext/zero-to +* +* @example +* var zeroTo = require( '@stdlib/blas/ext/zero-to' ); +* +* var out = zeroTo( [ 2, 3 ] ); +* // returns [ [ 0.0, 1.0, 2.0 ], [ 0.0, 1.0, 2.0 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var zeroTo = require( '@stdlib/blas/ext/zero-to' ); +* +* var x = zeros( [ 2, 3 ] ); +* // returns [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] +* +* var out = zeroTo.assign( x ); +* // returns [ [ 0.0, 1.0, 2.0 ], [ 0.0, 1.0, 2.0 ] ] +* +* var bool = ( out === x ); +* // returns true +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var assign = require( './assign.js' ); + + +// MAIN // + +setReadOnly( main, 'assign', assign ); + + +// EXPORTS // + +module.exports = main; + +// exports: { "assign": "main.assign" } diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/lib/main.js b/lib/node_modules/@stdlib/blas/ext/zero-to/lib/main.js new file mode 100644 index 000000000000..9f30dfb834c0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/lib/main.js @@ -0,0 +1,126 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isPlainObject = require( '@stdlib/assert/is-plain-object' ); +var isNonNegativeIntegerArray = require( '@stdlib/assert/is-nonnegative-integer-array' ).primitives; +var isEmptyCollection = require( '@stdlib/assert/is-empty-collection' ); +var isIntegerArray = require( '@stdlib/assert/is-integer-array' ).primitives; +var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var isOrder = require( '@stdlib/ndarray/base/assert/is-order' ); +var isDataType = require( '@stdlib/ndarray/base/assert/is-data-type' ); +var resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' ); +var contains = require( '@stdlib/array/base/assert/contains' ); +var empty = require( '@stdlib/ndarray/empty' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var DTYPES = require( './dtypes.js' ); +var defaults = require( './defaults.js' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Returns a new ndarray filled with linearly spaced numeric elements which increment by 1 starting from zero along one or more ndarray dimensions. +* +* @param {(NonNegativeInteger|NonNegativeIntegerArray)} shape - array shape +* @param {Options} [options] - function options +* @param {IntegerArray} [options.dims=[-1]] - list of dimensions over which to perform operation +* @param {*} [options.dtype] - output ndarray data type +* @param {string} [options.order] - ndarray order +* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed ndarray dimensions +* @param {ArrayLikeObject} [options.submode=["throw"]] - specifies how to handle subscripts which exceed ndarray dimensions on a per dimension basis +* @throws {TypeError} first argument must be either a nonnegative integer or an array of nonnegative integers +* @throws {TypeError} options argument must be an object +* @throws {TypeError} must provide valid options +* @throws {RangeError} dimension indices must not exceed input ndarray bounds +* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions +* @returns {ndarray} output ndarray +* +* @example +* var out = zeroTo( [ 2, 3 ] ); +* // returns [ [ 0.0, 1.0, 2.0 ], [ 0.0, 1.0, 2.0 ] ] +*/ +function zeroTo( shape ) { + var options; + var opts; + var out; + var sh; + var dt; + + if ( isNonNegativeInteger( shape ) ) { + sh = [ shape ]; + } else if ( isNonNegativeIntegerArray( shape ) ) { + sh = shape; // Note: empty shape (i.e., a shape for a zero-dimensional ndarray) is not allowed + } else { + throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer or an array of nonnegative integers. Value: `%s`.', shape ) ); + } + options = defaults(); + + if ( arguments.length > 1 ) { + opts = arguments[ 1 ]; + if ( !isPlainObject( opts ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + } + if ( hasOwnProp( opts, 'dtype' ) ) { + dt = resolveStr( opts.dtype ); + if ( !isDataType( opts.dtype ) || !contains( DTYPES.odtypes, dt ) ) { // eslint-disable-line max-len + throw new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'dtype', join( DTYPES.odtypes, '", "' ), opts.dtype ) ); + } + options.dtype = dt; + } + if ( hasOwnProp( opts, 'order' ) ) { + if ( !isOrder( opts.order ) ) { + throw new TypeError( format( 'invalid option. `%s` option must be a supported order. Option: `%s`.', 'order', opts.order ) ); + } + options.order = opts.order; + } + if ( hasOwnProp( opts, 'mode' ) ) { + // Defer to `empty` to validate below... + options.mode = opts.mode; + } + if ( hasOwnProp( opts, 'submode' ) ) { + // Defer to `empty` to validate below... + options.submode = opts.submode; + } + if ( hasOwnProp( opts, 'dims' ) ) { + if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { // eslint-disable-line max-len + throw new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); + } + options.dims = opts.dims; + } + } + // Set the default data type if not provided: + options.dtype = options.dtype || 'float64'; + + // Create an output ndarray: + out = empty( sh, options ); + + // Perform operation: + return base( out, options ); +} + + +// EXPORTS // + +module.exports = zeroTo; diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/package.json b/lib/node_modules/@stdlib/blas/ext/zero-to/package.json new file mode 100644 index 000000000000..290fd10db05f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/blas/ext/zero-to", + "version": "0.0.0", + "description": "Return a new ndarray filled with linearly spaced numeric elements which increment by 1 starting from zero along one or more ndarray dimensions.", + "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", + "stdmath", + "mathematics", + "math", + "blas", + "extended", + "zero", + "fill", + "iota", + "sequence", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/test/test.assign.js b/lib/node_modules/@stdlib/blas/ext/zero-to/test/test.assign.js new file mode 100644 index 000000000000..81017816b81e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/test/test.assign.js @@ -0,0 +1,478 @@ +/** +* @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 ndarray = require( '@stdlib/ndarray/ctor' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var empty = require( '@stdlib/ndarray/empty' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var assign = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof assign, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + 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() { + assign( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + 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() { + assign( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type', function test( t ) { + var values; + var i; + + values = [ + empty( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + 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() { + assign( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (options)', function test( t ) { + var values; + var i; + + values = [ + empty( [ 2, 2 ], { + 'dtype': 'bool' + }) + ]; + 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() { + assign( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an object', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + 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() { + assign( x, value ); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + 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() { + assign( x, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ 5 ], + [ -5 ], + [ 2 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains too many indices', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ 0, 1, 0 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains duplicate indices', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + [ 0, 0 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + assign( x, { + 'dims': value + }); + }; + } +}); + +tape( 'the function fills an ndarray with linearly spaced values incrementing by 1 from zero', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + x = new ndarray( 'float64', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); + expected = [ 0.0, 1.0, 2.0 ]; + + actual = assign( x ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function fills an ndarray with linearly spaced values incrementing by 1 from zero (row-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + expected = [ [ 0.0, 1.0 ], [ 0.0, 1.0 ] ]; + + actual = assign( x ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function fills an ndarray with linearly spaced values incrementing by 1 from zero (column-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + expected = [ [ 0.0, 1.0 ], [ 0.0, 1.0 ] ]; + + actual = assign( x ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function fills an ndarray with linearly spaced values incrementing by 1 from zero (all dimensions, row-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + expected = [ [ 0.0, 1.0 ], [ 2.0, 3.0 ] ]; + + actual = assign( x, { + 'dims': [ 0, 1 ] + }); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function fills an ndarray with linearly spaced values incrementing by 1 from zero (all dimensions, column-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + expected = [ [ 0.0, 2.0 ], [ 1.0, 3.0 ] ]; + + actual = assign( x, { + 'dims': [ 0, 1 ] + }); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function fills an ndarray with linearly spaced values incrementing by 1 from zero (no dimensions, row-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + expected = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; + + actual = assign( x, { + 'dims': [] + }); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function fills an ndarray with linearly spaced values incrementing by 1 from zero (no dimensions, column-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + expected = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; + + actual = assign( x, { + 'dims': [] + }); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying operation dimensions (row-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + expected = [ [ 0.0, 0.0 ], [ 1.0, 1.0 ] ]; + + actual = assign( x, { + 'dims': [ 0 ] + }); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + expected = [ [ 0.0, 1.0 ], [ 0.0, 1.0 ] ]; + + actual = assign( x, { + 'dims': [ 1 ] + }); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying operation dimensions (column-major)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + expected = [ [ 0.0, 0.0 ], [ 1.0, 1.0 ] ]; + + actual = assign( x, { + 'dims': [ 0 ] + }); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + xbuf = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + expected = [ [ 0.0, 1.0 ], [ 0.0, 1.0 ] ]; + + actual = assign( x, { + 'dims': [ 1 ] + }); + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/test/test.js b/lib/node_modules/@stdlib/blas/ext/zero-to/test/test.js new file mode 100644 index 000000000000..f01239ae22f6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/test/test.js @@ -0,0 +1,39 @@ +/** +* @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 isMethod = require( '@stdlib/assert/is-method' ); +var zeroTo = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zeroTo, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( isMethod( zeroTo, 'assign' ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/zero-to/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/zero-to/test/test.main.js new file mode 100644 index 000000000000..a0a957671fae --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/zero-to/test/test.main.js @@ -0,0 +1,432 @@ +/** +* @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 ndarray2array = require( '@stdlib/ndarray/to-array' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getOrder = require( '@stdlib/ndarray/order' ); +var zeroTo = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zeroTo, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not a nonnegative integer or an array of nonnegative integers', function test( t ) { + var values; + var i; + + values = [ + '5', + -1, + 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() { + zeroTo( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not a nonnegative integer or an array of nonnegative integers (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -1, + 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() { + zeroTo( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an object', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + 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() { + zeroTo( [ 2, 2 ], value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid `dtype` option', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bool', + 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() { + zeroTo( [ 2, 2 ], { + 'dtype': value + }); + }; + } +}); + +tape( 'the function throws an error if provided an invalid `order` option', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 5, + 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() { + zeroTo( [ 2, 2 ], { + 'order': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + 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() { + zeroTo( [ 2, 2 ], { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices', function test( t ) { + var values; + var i; + + values = [ + [ 5 ], + [ -5 ], + [ 2 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + zeroTo( [ 2, 2 ], { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains too many indices', function test( t ) { + var values; + var i; + + values = [ + [ 0, 1, 0 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + zeroTo( [ 2, 2 ], { + 'dims': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dims` option which contains duplicate indices', function test( t ) { + var values; + var i; + + values = [ + [ 0, 0 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + zeroTo( [ 2, 2 ], { + 'dims': value + }); + }; + } +}); + +tape( 'the function returns an ndarray containing linearly spaced values incrementing by 1 from zero', function test( t ) { + var expected; + var actual; + + expected = [ 0.0, 1.0, 2.0 ]; + actual = zeroTo( 3 ); + + t.strictEqual( String( getDType( actual ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 3 ], 'returns expected value' ); + t.strictEqual( getOrder( actual ), 'row-major', 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + expected = [ 0.0, 1.0, 2.0 ]; + actual = zeroTo( [ 3 ] ); + + t.strictEqual( String( getDType( actual ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 3 ], 'returns expected value' ); + t.strictEqual( getOrder( actual ), 'row-major', 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + expected = [ [ 0.0, 1.0 ], [ 0.0, 1.0 ] ]; + actual = zeroTo( [ 2, 2 ] ); + + t.strictEqual( String( getDType( actual ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( getOrder( actual ), 'row-major', 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an output data type', function test( t ) { + var expected; + var actual; + + expected = [ 0.0, 1.0, 2.0 ]; + actual = zeroTo( [ 3 ], { + 'dtype': 'float32' + }); + + t.strictEqual( String( getDType( actual ) ), 'float32', 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 3 ], 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an output array order', function test( t ) { + var expected; + var actual; + + expected = [ [ 0.0, 1.0 ], [ 0.0, 1.0 ] ]; + actual = zeroTo( [ 2, 2 ], { + 'order': 'row-major' + }); + + t.strictEqual( String( getDType( actual ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( getOrder( actual ), 'row-major', 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + expected = [ [ 0.0, 1.0 ], [ 0.0, 1.0 ] ]; + actual = zeroTo( [ 2, 2 ], { + 'order': 'column-major' + }); + + t.strictEqual( String( getDType( actual ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 2, 2 ], 'returns expected value' ); + t.strictEqual( getOrder( actual ), 'column-major', 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying operation dimensions', function test( t ) { + var expected; + var actual; + + expected = [ [ 0.0, 1.0 ], [ 0.0, 1.0 ] ]; + actual = zeroTo( [ 2, 2 ], { + 'dims': [ -1 ] + }); + + t.strictEqual( String( getDType( actual ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 2, 2 ], 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + expected = [ [ 0.0, 0.0 ], [ 1.0, 1.0 ] ]; + actual = zeroTo( [ 2, 2 ], { + 'dims': [ 0 ] + }); + + t.strictEqual( String( getDType( actual ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 2, 2 ], 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + expected = [ [ 0.0, 1.0 ], [ 2.0, 3.0 ] ]; + actual = zeroTo( [ 2, 2 ], { + 'dims': [ 0, 1 ] + }); + + t.strictEqual( String( getDType( actual ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 2, 2 ], 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + expected = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; + actual = zeroTo( [ 2, 2 ], { + 'dims': [] + }); + + t.strictEqual( String( getDType( actual ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 2, 2 ], 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying array index modes and submodes', function test( t ) { + var expected; + var actual; + var opts; + + opts = { + 'mode': 'clamp', + 'submode': [ 'wrap' ] + }; + actual = zeroTo( [ 2, 2, 3 ], opts ); + expected = [ + [ + // 0 1 2 + [ 0.0, 1.0, 2.0 ], + + // 3 4 5 + [ 0.0, 1.0, 2.0 ] + ], + [ + // 6 7 8 + [ 0.0, 1.0, 2.0 ], + + // 9 10 11 + [ 0.0, 1.0, 2.0 ] + ] + ]; + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + // Clamped: + t.strictEqual( actual.iget( actual.length+10 ), 2.0, 'returns expected value' ); + actual.iset( actual.length+10, 10.0 ); + t.strictEqual( actual.iget( actual.length+10 ), 10.0, 'returns expected value' ); + + // Wrapped: + t.strictEqual( actual.get( 2, 2, 3 ), 0.0, 'returns expected value' ); + actual.set( 2, 2, 3, 30.0 ); + t.strictEqual( actual.get( 0, 0, 0 ), 30.0, 'returns expected value' ); + t.strictEqual( actual.get( 2, 2, 3 ), 30.0, 'returns expected value' ); + + t.end(); +});