diff --git a/lib/node_modules/@stdlib/blas/ext/fill-range/README.md b/lib/node_modules/@stdlib/blas/ext/fill-range/README.md new file mode 100644 index 000000000000..5f5ab2beb985 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/fill-range/README.md @@ -0,0 +1,152 @@ + + +# fillRange + +> Fill an input [ndarray][@stdlib/ndarray/ctor] with a specified value along an [ndarray][@stdlib/ndarray/ctor] dimension. + +
+ +## Usage + +```javascript +var fillRange = require( '@stdlib/blas/ext/fill-range' ); +``` + +#### fillRange( x, value\[, start\[, end]]\[, options] ) + +Fills an input [ndarray][@stdlib/ndarray/ctor] with a specified value along an [ndarray][@stdlib/ndarray/ctor] dimension. + +```javascript +var array = require( '@stdlib/ndarray/array' ); + +// Create an input ndarray: +var x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +// returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] + +// Perform operation: +var y = fillRange( x, 10.0, 1, 4 ); +// returns [ 1.0, 10.0, 10.0, 10.0, 5.0, 6.0 ] + +var bool = ( x === y ); +// returns true +``` + +The function has the following parameters: + +- **x**: input [ndarray][@stdlib/ndarray/ctor]. +- **value**: fill value. May be either a scalar value or an [ndarray][@stdlib/ndarray/ctor]. Must be able to safely cast to the input [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes]. Values having floating-point [data types][@stdlib/ndarray/dtypes] (both real and complex) are allowed to downcast to a lower precision [data type][@stdlib/ndarray/dtypes] of the same kind (e.g., a scalar double-precision floating-point number can be used to fill a `'float32'` input [ndarray][@stdlib/ndarray/ctor]). If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dim`. For example, given the input shape `[2, 3, 4]` and `options.dim=0`, an [ndarray][@stdlib/ndarray/ctor] fill value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. +- **start**: starting index (inclusive) (_optional_). May be either an integer or an [ndarray][@stdlib/ndarray/ctor] having an integer index or "generic" [data type][@stdlib/ndarray/dtypes] and following the same broadcasting semantics as an [ndarray][@stdlib/ndarray/ctor] `value` argument. Default: `0`. +- **end**: ending index (exclusive) (_optional_). May be either an integer or an [ndarray][@stdlib/ndarray/ctor] having an integer index or "generic" [data type][@stdlib/ndarray/dtypes] and following the same broadcasting semantics as an [ndarray][@stdlib/ndarray/ctor] `value` argument. By default, the ending index is `N`, where `N` is the number of elements along the dimension specified by `options.dim`. +- **options**: function options (_optional_). + +The function accepts the following options: + +- **dim**: dimension over which to perform operation. If provided a negative integer, the dimension along which to perform the operation is determined by counting backward from the last dimension (where `-1` refers to the last dimension). Default: `-1`. + +When a `start` and/or `end` index is negative, the respective index is determined relative to the last indexed element, with out-of-bounds indices clamped to index bounds. + +```javascript +var array = require( '@stdlib/ndarray/array' ); + +var x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +var y = fillRange( x, 10.0, -2 ); +// returns [ 1.0, 2.0, 3.0, 4.0, 10.0, 10.0 ] +``` + +By default, the function performs the operation over elements along the last dimension. To perform the operation over a different dimension, provide a `dim` option. + +```javascript +var array = require( '@stdlib/ndarray/array' ); + +var x = array( [ [ 1.0, 2.0, 3.0, 4.0 ], [ 5.0, 6.0, 7.0, 8.0 ] ] ); + +var y = fillRange( x, array( [ 9.0, 10.0, 11.0, 12.0 ] ), { + 'dim': 0 +}); +// returns [ [ 9.0, 10.0, 11.0, 12.0 ], [ 9.0, 10.0, 11.0, 12.0 ] ] +``` + +
+ + + +
+ +## Notes + +- The input [ndarray][@stdlib/ndarray/ctor] is filled **in-place** (i.e., the input [ndarray][@stdlib/ndarray/ctor] is **mutated**). + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var fillRange = require( '@stdlib/blas/ext/fill-range' ); + +// Generate an ndarray of random numbers: +var x = discreteUniform( [ 5, 5 ], 0, 20, { + 'dtype': 'generic' +}); +console.log( ndarray2array( x ) ); + +// Perform operation: +fillRange( x, 0, 1, 4, { + 'dim': 0 +}); + +// Print the results: +console.log( ndarray2array( x ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/fill-range/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/fill-range/benchmark/benchmark.js new file mode 100644 index 000000000000..a389a4898b5f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/fill-range/benchmark/benchmark.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 uniform = require( '@stdlib/random/uniform' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var fillRange = 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 ) { + var x = uniform( [ len ], -50.0, 50.0, 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 = fillRange( x, ( i%2 ) ? 5.0 : -5.0 ); + 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/fill-range/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/fill-range/docs/repl.txt new file mode 100644 index 000000000000..7cf367af1389 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/fill-range/docs/repl.txt @@ -0,0 +1,64 @@ + +{{alias}}( x, value[, start[, end]][, options] ) + Fills an input ndarray with a specified value along an ndarray dimension. + + When a `start` and/or `end` index is negative, the respective index is + determined relative to the last indexed element, with out-of-bounds indices + clamped to index bounds. + + The function fills an input ndarray in-place and thus mutates an input + ndarray. + + Parameters + ---------- + x: ndarray + Input array. + + value: ndarray|any + Fill value. May be either a scalar value or an ndarray. Must be able to + safely cast to the input ndarray data type. 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' input ndarray). If + provided an ndarray, the value must have a shape which is broadcast + compatible with the complement of the shape defined by `options.dim`. + For example, given the input shape `[2, 3, 4]` and `options.dim=0`, an + ndarray fill value must have a shape which is broadcast compatible with + the shape `[3, 4]`. + + start: ndarray|integer (optional) + Starting index (inclusive). May be either an integer or an ndarray + having an integer index or "generic" data type and following the same + broadcasting semantics as an ndarray `value` argument. Default: `0`. + + end: ndarray|integer (optional) + Ending index (exclusive). May be either an integer or an ndarray having + an integer index or "generic" data type and following the same + broadcasting semantics as an ndarray `value` argument. Default: `N` + where `N` is the number of elements along the operation dimension. + + options: Object (optional) + Function options. + + options.dim: integer (optional) + Dimension over which to perform operation. If provided a negative + integer, the dimension along which to perform the operation is + determined by counting backward from the last dimension (where `-1` + refers to the last dimension). Default: `-1`. + + Returns + ------- + out: ndarray + Input array. + + Examples + -------- + > var x = {{alias:@stdlib/ndarray/array}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var y = {{alias}}( x, 10.0, 2 ) + [ 1.0, 2.0, 10.0, 10.0 ] + > var bool = ( x === y ) + true + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/fill-range/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/fill-range/docs/types/index.d.ts new file mode 100644 index 000000000000..d398a0139663 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/fill-range/docs/types/index.d.ts @@ -0,0 +1,338 @@ +/* +* @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 { typedndarray, complexndarray, genericndarray } from '@stdlib/types/ndarray'; +import { ComplexLike } from '@stdlib/types/complex'; + +/** +* Index argument. +*/ +type IndexArgument = typedndarray | number; + +/** +* Fill value argument. +*/ +type FillValue = typedndarray | T; + +/** +* Interface defining options. +*/ +interface Options { + /** + * Dimension over which to perform operation. Default: `-1`. + * + * ## Notes + * + * - If provided a negative integer, the dimension along which to perform the operation is determined by counting backward from the last dimension (where `-1` refers to the last dimension). + */ + dim?: number; +} + +/** +* Interface for filling an ndarray. +*/ +interface FillRange { + /** + * Fills an input ndarray with a specified value along an ndarray dimension. + * + * ## Notes + * + * - The input ndarray is filled **in-place** (i.e., the input ndarray is **mutated**). + * + * @param x - input ndarray + * @param value - fill value + * @param options - function options + * @returns input ndarray + * + * @example + * var zeros = require( '@stdlib/ndarray/zeros' ); + * + * var x = zeros( [ 2, 2 ], { + * 'dtype': 'complex128' + * }); + * + * var y = fillRange( x, 10.0 ); + * // returns [ [ [ 10.0, 0.0 ], [ 10.0, 0.0 ] ], [ [ 10.0, 0.0 ], [ 10.0, 0.0 ] ] ] + * + * var bool = ( x === y ); + * // returns true + */ + ( x: T, value: FillValue, options?: Options ): T; + + /** + * Fills an input ndarray with a specified value along an ndarray dimension. + * + * ## Notes + * + * - The input ndarray is filled **in-place** (i.e., the input ndarray is **mutated**). + * + * @param x - input ndarray + * @param value - fill value + * @param options - function options + * @returns input ndarray + * + * @example + * var zeros = require( '@stdlib/ndarray/zeros' ); + * + * var x = zeros( [ 2, 2 ], { + * 'dtype': 'generic' + * }); + * + * var y = fillRange( x, 10.0 ); + * // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] + * + * var bool = ( x === y ); + * // returns true + */ + = genericndarray>( x: V, value: FillValue, options?: Options ): V; + + /** + * Fills an input ndarray with a specified value along an ndarray dimension. + * + * ## Notes + * + * - The input ndarray is filled **in-place** (i.e., the input ndarray is **mutated**). + * + * @param x - input ndarray + * @param value - fill value + * @param options - function options + * @returns input ndarray + * + * @example + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * + * var y = fillRange( x, 10.0 ); + * // returns [ 10.0, 10.0, 10.0, 10.0 ] + * + * var bool = ( x === y ); + * // returns true + */ + = typedndarray>( x: U, value: FillValue, options?: Options ): U; + + /** + * Fills an input ndarray with a specified value along an ndarray dimension. + * + * ## Notes + * + * - The input ndarray is filled **in-place** (i.e., the input ndarray is **mutated**). + * - When a `start` index is negative, the index is determined relative to the last indexed element, with out-of-bounds indices clamped to index bounds. + * + * @param x - input ndarray + * @param value - fill value + * @param start - starting index (inclusive) + * @param options - function options + * @returns input ndarray + * + * @example + * var zeros = require( '@stdlib/ndarray/zeros' ); + * + * var x = zeros( [ 4 ], { + * 'dtype': 'complex128' + * }); + * + * var y = fillRange( x, 10.0, 2 ); + * // returns [ [ 0.0, 0.0 ], [ 0.0, 0.0 ], [ 10.0, 0.0 ], [ 10.0, 0.0 ] ] + * + * var bool = ( x === y ); + * // returns true + */ + ( x: T, value: FillValue, start: IndexArgument, options?: Options ): T; + + /** + * Fills an input ndarray with a specified value along an ndarray dimension. + * + * ## Notes + * + * - The input ndarray is filled **in-place** (i.e., the input ndarray is **mutated**). + * - When a `start` index is negative, the index is determined relative to the last indexed element, with out-of-bounds indices clamped to index bounds. + * + * @param x - input ndarray + * @param value - fill value + * @param start - starting index (inclusive) + * @param options - function options + * @returns input ndarray + * + * @example + * var zeros = require( '@stdlib/ndarray/zeros' ); + * + * var x = zeros( [ 4 ], { + * 'dtype': 'generic' + * }); + * + * var y = fillRange( x, 10.0, 2 ); + * // returns [ 0.0, 0.0, 10.0, 10.0 ] + * + * var bool = ( x === y ); + * // returns true + */ + = genericndarray>( x: V, value: FillValue, start: IndexArgument, options?: Options ): V; + + /** + * Fills an input ndarray with a specified value along an ndarray dimension. + * + * ## Notes + * + * - The input ndarray is filled **in-place** (i.e., the input ndarray is **mutated**). + * - When a `start` index is negative, the index is determined relative to the last indexed element, with out-of-bounds indices clamped to index bounds. + * + * @param x - input ndarray + * @param value - fill value + * @param start - starting index (inclusive) + * @param options - function options + * @returns input ndarray + * + * @example + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * + * var y = fillRange( x, 10.0, 2 ); + * // returns [ 1.0, 2.0, 10.0, 10.0 ] + * + * var bool = ( x === y ); + * // returns true + */ + = typedndarray>( x: U, value: FillValue, start: IndexArgument, options?: Options ): U; + + /** + * Fills an input ndarray with a specified value along an ndarray dimension. + * + * ## Notes + * + * - The input ndarray is filled **in-place** (i.e., the input ndarray is **mutated**). + * - When a `start` and/or `end` index is negative, the respective index is determined relative to the last indexed element, with out-of-bounds indices clamped to index bounds. + * + * @param x - input ndarray + * @param value - fill value + * @param start - starting index (inclusive) + * @param end - ending index (exclusive) + * @param options - function options + * @returns input ndarray + * + * @example + * var zeros = require( '@stdlib/ndarray/zeros' ); + * + * var x = zeros( [ 4 ], { + * 'dtype': 'complex128' + * }); + * + * var y = fillRange( x, 10.0, 1, 3 ); + * // returns [ [ 0.0, 0.0 ], [ 10.0, 0.0 ], [ 10.0, 0.0 ], [ 00.0, 0.0 ] ] + * + * var bool = ( x === y ); + * // returns true + */ + ( x: T, value: FillValue, start: IndexArgument, end: IndexArgument, options?: Options ): T; + + /** + * Fills an input ndarray with a specified value along an ndarray dimension. + * + * ## Notes + * + * - The input ndarray is filled **in-place** (i.e., the input ndarray is **mutated**). + * - When a `start` and/or `end` index is negative, the respective index is determined relative to the last indexed element, with out-of-bounds indices clamped to index bounds. + * + * @param x - input ndarray + * @param value - fill value + * @param start - starting index (inclusive) + * @param end - ending index (exclusive) + * @param options - function options + * @returns input ndarray + * + * @example + * var zeros = require( '@stdlib/ndarray/zeros' ); + * + * var x = zeros( [ 4 ], { + * 'dtype': 'generic' + * }); + * + * var y = fillRange( x, 10.0, 1, 3 ); + * // returns [ 0.0, 10.0, 10.0, 0.0 ] + * + * var bool = ( x === y ); + * // returns true + */ + = genericndarray>( x: V, value: FillValue, start: IndexArgument, end: IndexArgument, options?: Options ): V; + + /** + * Fills an input ndarray with a specified value along an ndarray dimension. + * + * ## Notes + * + * - The input ndarray is filled **in-place** (i.e., the input ndarray is **mutated**). + * - When a `start` and/or `end` index is negative, the respective index is determined relative to the last indexed element, with out-of-bounds indices clamped to index bounds. + * + * @param x - input ndarray + * @param value - fill value + * @param start - starting index (inclusive) + * @param end - ending index (exclusive) + * @param options - function options + * @returns input ndarray + * + * @example + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * + * var y = fillRange( x, 10.0, 1, 3 ); + * // returns [ 1.0, 10.0, 10.0, 4.0 ] + * + * var bool = ( x === y ); + * // returns true + */ + = typedndarray>( x: U, value: FillValue, start: IndexArgument, end: IndexArgument, options?: Options ): U; +} + +/** +* Fills an input ndarray with a specified value along an ndarray dimension. +* +* ## Notes +* +* - The input ndarray is filled **in-place** (i.e., the input ndarray is **mutated**). +* - When a `start` and/or `end` index is negative, the respective index is determined relative to the last indexed element, with out-of-bounds indices clamped to index bounds. +* +* @param x - input ndarray +* @param value - fill value +* @param start - starting index (inclusive) +* @param end - ending index (exclusive) +* @param options - function options +* @returns input ndarray +* +* @example +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* var y = fillRange( x, 10.0, 1, 4 ); +* // returns [ 1.0, 10.0, 10.0, 10.0, 5.0, 6.0 ] +* +* var bool = ( x === y ); +* // returns true +*/ +declare const fillRange: FillRange; + + +// EXPORTS // + +export = fillRange; diff --git a/lib/node_modules/@stdlib/blas/ext/fill-range/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/fill-range/docs/types/test.ts new file mode 100644 index 000000000000..ce228012b723 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/fill-range/docs/types/test.ts @@ -0,0 +1,179 @@ +/* +* @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 fillRange = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + fillRange( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), 10.0 ); // $ExpectType float64ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), 10.0, {} ); // $ExpectType float64ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), 10.0, 0 ); // $ExpectType float64ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), 10.0, 0, {} ); // $ExpectType float64ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), 10.0, 0, 2 ); // $ExpectType float64ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), 10.0, 0, 2, {} ); // $ExpectType float64ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'float32' } ), 10.0 ); // $ExpectType float32ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'float32' } ), 10.0, {} ); // $ExpectType float32ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'int32' } ), 10 ); // $ExpectType int32ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'int32' } ), 10, {} ); // $ExpectType int32ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), 10.0 ); // $ExpectType complex128ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), 10.0, {} ); // $ExpectType complex128ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'complex64' } ), 10.0 ); // $ExpectType complex64ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'complex64' } ), 10.0, {} ); // $ExpectType complex64ndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'generic' } ), 10.0 ); // $ExpectType genericndarray + fillRange( zeros( [ 2, 2 ], { 'dtype': 'generic' } ), 10.0, {} ); // $ExpectType genericndarray +} + +// The function returns an ndarray when provided ndarray value and index arguments... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + fillRange( x, x ); // $ExpectType float64ndarray + fillRange( x, x, {} ); // $ExpectType float64ndarray + fillRange( x, x, x ); // $ExpectType float64ndarray + fillRange( x, x, x, {} ); // $ExpectType float64ndarray + fillRange( x, x, x, x ); // $ExpectType float64ndarray + fillRange( x, x, x, x, {} ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an ndarray... +{ + fillRange( '5', 10.0 ); // $ExpectError + fillRange( 5, 10.0 ); // $ExpectError + fillRange( true, 10.0 ); // $ExpectError + fillRange( false, 10.0 ); // $ExpectError + fillRange( null, 10.0 ); // $ExpectError + fillRange( void 0, 10.0 ); // $ExpectError + fillRange( {}, 10.0 ); // $ExpectError + fillRange( ( x: number ): number => x, 10.0 ); // $ExpectError + + fillRange( '5', 10.0, {} ); // $ExpectError + fillRange( 5, 10.0, {} ); // $ExpectError + fillRange( true, 10.0, {} ); // $ExpectError + fillRange( false, 10.0, {} ); // $ExpectError + fillRange( null, 10.0, {} ); // $ExpectError + fillRange( void 0, 10.0, {} ); // $ExpectError + fillRange( {}, 10.0, {} ); // $ExpectError + fillRange( ( x: number ): number => x, 10.0, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided a start index argument which is not an ndarray or integer... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + fillRange( x, 10.0, '5' ); // $ExpectError + fillRange( x, 10.0, true ); // $ExpectError + fillRange( x, 10.0, false ); // $ExpectError + fillRange( x, 10.0, null ); // $ExpectError + fillRange( x, 10.0, [] ); // $ExpectError + fillRange( x, 10.0, ( x: number ): number => x ); // $ExpectError + + fillRange( x, 10.0, '5', {} ); // $ExpectError + fillRange( x, 10.0, true, {} ); // $ExpectError + fillRange( x, 10.0, false, {} ); // $ExpectError + fillRange( x, 10.0, null, {} ); // $ExpectError + fillRange( x, 10.0, [], {} ); // $ExpectError + fillRange( x, 10.0, ( x: number ): number => x, {} ); // $ExpectError + + fillRange( x, 10.0, '5', 2, {} ); // $ExpectError + fillRange( x, 10.0, true, 2, {} ); // $ExpectError + fillRange( x, 10.0, false, 2, {} ); // $ExpectError + fillRange( x, 10.0, null, 2, {} ); // $ExpectError + fillRange( x, 10.0, [], 2, {} ); // $ExpectError + fillRange( x, 10.0, ( x: number ): number => x, 2, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an end index argument which is not an ndarray or integer... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + fillRange( x, 10.0, 0, '5', {} ); // $ExpectError + fillRange( x, 10.0, 0, true, {} ); // $ExpectError + fillRange( x, 10.0, 0, false, {} ); // $ExpectError + fillRange( x, 10.0, 0, null, {} ); // $ExpectError + fillRange( x, 10.0, 0, [], {} ); // $ExpectError + fillRange( x, 10.0, 0, ( x: number ): number => x, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an options argument which is not an object... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + fillRange( x, 10.0, 0, '5' ); // $ExpectError + fillRange( x, 10.0, 0, true ); // $ExpectError + fillRange( x, 10.0, 0, false ); // $ExpectError + fillRange( x, 10.0, 0, null ); // $ExpectError + fillRange( x, 10.0, 0, [] ); // $ExpectError + fillRange( x, 10.0, 0, ( x: number ): number => x ); // $ExpectError + + fillRange( x, 10.0, 0, 2, '5' ); // $ExpectError + fillRange( x, 10.0, 0, 2, true ); // $ExpectError + fillRange( x, 10.0, 0, 2, false ); // $ExpectError + fillRange( x, 10.0, 0, 2, null ); // $ExpectError + fillRange( x, 10.0, 0, 2, [] ); // $ExpectError + fillRange( x, 10.0, 0, 2, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid `dim` option... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + fillRange( x, 10.0, { 'dim': '5' } ); // $ExpectError + fillRange( x, 10.0, { 'dim': true } ); // $ExpectError + fillRange( x, 10.0, { 'dim': false } ); // $ExpectError + fillRange( x, 10.0, { 'dim': null } ); // $ExpectError + fillRange( x, 10.0, { 'dim': [] } ); // $ExpectError + fillRange( x, 10.0, { 'dim': {} } ); // $ExpectError + fillRange( x, 10.0, { 'dim': ( x: number ): number => x } ); // $ExpectError + + fillRange( x, 10.0, 0, 2, { 'dim': '5' } ); // $ExpectError + fillRange( x, 10.0, 0, 2, { 'dim': true } ); // $ExpectError + fillRange( x, 10.0, 0, 2, { 'dim': false } ); // $ExpectError + fillRange( x, 10.0, 0, 2, { 'dim': null } ); // $ExpectError + fillRange( x, 10.0, 0, 2, { 'dim': [] } ); // $ExpectError + fillRange( x, 10.0, 0, 2, { 'dim': {} } ); // $ExpectError + fillRange( x, 10.0, 0, 2, { 'dim': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + fillRange(); // $ExpectError + fillRange( x ); // $ExpectError + fillRange( x, 10.0, 0, 2, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/fill-range/examples/index.js b/lib/node_modules/@stdlib/blas/ext/fill-range/examples/index.js new file mode 100644 index 000000000000..b7b6b85b877b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/fill-range/examples/index.js @@ -0,0 +1,37 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var fillRange = require( './../lib' ); + +// Generate an ndarray of random numbers: +var x = discreteUniform( [ 5, 5 ], 0, 20, { + 'dtype': 'generic' +}); +console.log( ndarray2array( x ) ); + +// Perform operation: +fillRange( x, 0, 1, 4, { + 'dim': 0 +}); + +// Print the results: +console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/fill-range/lib/base.js b/lib/node_modules/@stdlib/blas/ext/fill-range/lib/base.js new file mode 100644 index 000000000000..2f4e1ed9dbe5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/fill-range/lib/base.js @@ -0,0 +1,125 @@ +/** +* @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 dtypes = require( '@stdlib/ndarray/dtypes' ); +var gfill = require( '@stdlib/blas/ext/base/ndarray/gfill' ); +var dfill = require( '@stdlib/blas/ext/base/ndarray/dfill' ); +var sfill = require( '@stdlib/blas/ext/base/ndarray/sfill' ); +var cfill = require( '@stdlib/blas/ext/base/ndarray/cfill' ); +var zfill = require( '@stdlib/blas/ext/base/ndarray/zfill' ); +var factory = require( '@stdlib/ndarray/base/nullary-strided1d-dispatch-factory' ); + + +// VARIABLES // + +var idtypes0 = dtypes( 'all' ); // fill value ndarray +var idtypes1 = dtypes( 'integer_index_and_generic' ); // start/end ndarrays +var odtypes = dtypes( 'all' ); +var table = { + 'types': [ + 'float64', // input/output + 'float32', // input/output + 'complex128', // input/output + 'complex64' // input/output + ], + 'fcns': [ + dfill, + sfill, + zfill, + cfill + ], + 'default': gfill +}; +var options = { + 'strictTraversalOrder': true +}; + + +// MAIN // + +/** +* Fills an input ndarray with a specified value along an ndarray dimension. +* +* @private +* @name fillRange +* @type {Function} +* @param {ndarray} x - input ndarray +* @param {ndarray} value - ndarray containing the fill value +* @param {ndarray} start - ndarray containing the starting index (inclusive) +* @param {ndarray} end - ndarray containing the ending index (exclusive) +* @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} second argument must be an ndarray-like object +* @throws {TypeError} index arguments must be ndarray-like objects +* @throws {TypeError} options argument must be an object +* @throws {RangeError} dimension indices must not exceed input ndarray bounds +* @throws {Error} must provide valid options +* @returns {ndarray} input ndarray +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* // Define the shape of the input array: +* var sh = [ 6 ]; +* +* // Define the array strides: +* var sx = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray: +* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); +* +* // Create an ndarray containing the fill value: +* var value = scalar2ndarray( 10.0, { +* 'dtype': 'float64' +* }); +* +* // Create ndarrays containing the starting and ending indices: +* var opts = { +* 'dtype': 'int32' +* }; +* var start = scalar2ndarray( 1, opts ); +* var end = scalar2ndarray( 4, opts ); +* +* // Perform operation: +* var out = fillRange( x, value, start, end, { +* 'dims': [ 0 ] +* }); +* // returns [ 1.0, 10.0, 10.0, 10.0, 5.0, 6.0 ] +* +* var bool = ( out === x ); +* // returns true +*/ +var fillRange = factory( table, [ idtypes0, idtypes1, idtypes1 ], odtypes, options ); + + +// EXPORTS // + +module.exports = fillRange; diff --git a/lib/node_modules/@stdlib/blas/ext/fill-range/lib/broadcast_index.js b/lib/node_modules/@stdlib/blas/ext/fill-range/lib/broadcast_index.js new file mode 100644 index 000000000000..bade251f2423 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/fill-range/lib/broadcast_index.js @@ -0,0 +1,56 @@ +/** +* @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 isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var broadcastScalar = require( '@stdlib/ndarray/base/broadcast-scalar' ); +var maybeBroadcastArray = require( '@stdlib/ndarray/base/maybe-broadcast-array' ); +var getDefault = require( '@stdlib/ndarray/defaults' ).get; + + +// VARIABLES // + +var DEFAULT_DTYPE = getDefault( 'dtypes.integer_index' ); + + +// MAIN // + +/** +* Broadcasts an index argument to match the shape of the non-core dimensions. +* +* @private +* @param {(ndarray|NonNegativeInteger)} idx - index argument +* @param {NonNegativeIntegerArray} shape - shape of the non-core dimensions +* @param {string} order - memory layout order +* @returns {ndarray} ndarray containing index values +*/ +function broadcastIndex( idx, shape, order ) { + // FIXME: this breaks for large integer/array sizes (e.g., casting idx > 2^32 to int32). We also need to update in the future to accommodate 64-bit integer values. + if ( isInteger( idx ) ) { + return broadcastScalar( idx, DEFAULT_DTYPE, shape, order ); + } + return maybeBroadcastArray( idx, shape ); +} + + +// EXPORTS // + +module.exports = broadcastIndex; diff --git a/lib/node_modules/@stdlib/blas/ext/fill-range/lib/index.js b/lib/node_modules/@stdlib/blas/ext/fill-range/lib/index.js new file mode 100644 index 000000000000..5d6ff07f168e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/fill-range/lib/index.js @@ -0,0 +1,61 @@ +/** +* @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'; + +/** +* Fill an input ndarray with a specified value along an ndarray dimension. +* +* @module @stdlib/blas/ext/fill-range +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var fillRange = require( '@stdlib/blas/ext/fill-range' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* // Define the shape of the input array: +* var sh = [ 6 ]; +* +* // Define the array strides: +* var sx = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray: +* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); +* +* // Perform operation: +* var out = fillRange( x, 10.0, 1, 4 ); +* // returns [ 1.0, 10.0, 10.0, 10.0, 5.0, 6.0 ] +* +* var bool = ( out === x ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/fill-range/lib/main.js b/lib/node_modules/@stdlib/blas/ext/fill-range/lib/main.js new file mode 100644 index 000000000000..a4d78cd35d0e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/fill-range/lib/main.js @@ -0,0 +1,242 @@ +/** +* @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 isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var isScalarMostlySafeCompatible = require( '@stdlib/ndarray/base/assert/is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length +var isMostlySafeCast = require( '@stdlib/ndarray/base/assert/is-mostly-safe-data-type-cast' ); +var isEqualDataType = require( '@stdlib/ndarray/base/assert/is-equal-data-type' ); +var broadcastScalar = require( '@stdlib/ndarray/base/broadcast-scalar' ); +var maybeBroadcastArray = require( '@stdlib/ndarray/base/maybe-broadcast-array' ); +var baseEmpty = require( '@stdlib/ndarray/base/empty' ); +var assign = require( '@stdlib/ndarray/base/assign' ); +var nonCoreShape = require( '@stdlib/ndarray/base/complement-shape' ); +var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getOrder = require( '@stdlib/ndarray/order' ); +var format = require( '@stdlib/string/format' ); +var broadcastIndex = require( './broadcast_index.js' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Fills an input ndarray with a specified value along an ndarray dimension. +* +* ## Notes +* +* - The input ndarray is filled **in-place** (i.e., the input ndarray is **mutated**). +* - When a `start` and/or `end` index is negative, the respective index is determined relative to the last indexed element, with out-of-bounds indices clamped to index bounds. +* +* @param {ndarrayLike} x - input ndarray +* @param {(ndarrayLike|*)} value - fill value +* @param {(ndarrayLike|integer)} [start] - starting index (inclusive) +* @param {(ndarrayLike|integer)} [end] - ending index (exclusive) +* @param {Options} [options] - function options +* @param {integer} [options.dim=-1] - dimension over which to perform operation +* @throws {TypeError} first argument must be an ndarray-like object +* @throws {TypeError} second argument cannot be safely cast to the input ndarray data type +* @throws {TypeError} index arguments must be either ndarray-like objects or integers +* @throws {TypeError} options argument must be an object +* @throws {RangeError} dimension index must not exceed input ndarray bounds +* @throws {RangeError} first argument must have at least one dimension +* @throws {TypeError} must provide valid options +* @returns {ndarray} input ndarray +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* // Create a data buffer: +* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* // Define the shape of the input array: +* var sh = [ 6 ]; +* +* // Define the array strides: +* var sx = [ 1 ]; +* +* // Define the index offset: +* var ox = 0; +* +* // Create an input ndarray: +* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); +* +* // Perform operation: +* var out = fillRange( x, 10.0, 1, 4 ); +* // returns [ 1.0, 10.0, 10.0, 10.0, 5.0, 6.0 ] +* +* var bool = ( out === x ); +* // returns true +*/ +function fillRange( x, value ) { + var hasOptions; + var hasStart; + var options; + var hasEnd; + var nargs; + var start; + var opts; + var end; + var lsh; + var len; + var ord; + var vdt; + var sh; + var dt; + var d; + var e; + var s; + var v; + + nargs = arguments.length; + if ( !isndarrayLike( x ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) ); + } + // Resolve input ndarray meta data: + dt = getDType( x ); + ord = getOrder( x ); + + // Initialize an options object: + opts = { + 'dims': [ -1 ] // default behavior is to perform the operation over the last dimension + }; + + // Initialize flags indicating whether `start`, `end`, and `options` arguments were provided: + hasOptions = false; + hasStart = false; + hasEnd = false; + + // Case: fillRange( x, value, start, end, options ) + if ( nargs > 4 ) { + start = arguments[ 2 ]; + if ( !isInteger( start ) && !isndarrayLike( start ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be either an ndarray or an integer. Value: `%s`.', start ) ); + } + hasStart = true; + end = arguments[ 3 ]; + if ( !isInteger( end ) && !isndarrayLike( end ) ) { + throw new TypeError( format( 'invalid argument. Fourth argument must be either an ndarray or an integer. Value: `%s`.', end ) ); + } + hasEnd = true; + options = arguments[ 4 ]; + hasOptions = true; + } + // Case: fillRange( x, value, start, ??? ) + else if ( nargs === 4 ) { + start = arguments[ 2 ]; + if ( !isInteger( start ) && !isndarrayLike( start ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be either an ndarray or an integer. Value: `%s`.', start ) ); + } + hasStart = true; + + // Case: fillRange( x, value, start, end ) + if ( isInteger( arguments[ 3 ] ) || isndarrayLike( arguments[ 3 ] ) ) { + end = arguments[ 3 ]; + hasEnd = true; + } + // Case: fillRange( x, value, start, options ) + else { + options = arguments[ 3 ]; + hasOptions = true; + } + } + // Case: fillRange( x, value, ??? ) + else if ( nargs === 3 ) { + // Case: fillRange( x, value, start ) + if ( isInteger( arguments[ 2 ] ) || isndarrayLike( arguments[ 2 ] ) ) { + start = arguments[ 2 ]; + hasStart = true; + } + // Case: fillRange( x, value, options ) + else { + options = arguments[ 2 ]; + hasOptions = true; + } + } + if ( hasOptions ) { + if ( !isPlainObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + // Resolve provided options... + if ( hasOwnProp( options, 'dim' ) ) { + if ( !isInteger( options.dim ) ) { + throw new TypeError( format( 'invalid option. `%s` option must be an integer. Option: `%s`.', 'dim', options.dim ) ); + } + opts.dims[ 0 ] = options.dim; + } + } + // Resolve the shape of the non-core dimensions and the number of indexed elements... + sh = getShape( x ); + if ( sh.length < 1 ) { + throw new RangeError( 'invalid argument. First argument must have at least one dimension.' ); + } + d = normalizeIndex( opts.dims[ 0 ], sh.length-1 ); + if ( d === -1 ) { + throw new RangeError( format( 'invalid option. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', sh.length, opts.dims[ 0 ] ) ); + } + opts.dims[ 0 ] = d; + lsh = nonCoreShape( sh, opts.dims ); + len = sh[ d ]; + + // Case: fillRange( x, value_ndarray, ... ) + if ( isndarrayLike( value ) ) { + vdt = getDType( value ); + + // Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the input array data type is floating-point... + if ( !isMostlySafeCast( vdt, dt ) ) { + throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input ndarray data type. Data types: [%s, %s].', vdt, dt ) ); + } + if ( isEqualDataType( vdt, dt ) ) { + v = value; + } else { + // If we have unequal data types, we need to perform a copy... + v = baseEmpty( dt, getShape( value ), getOrder( value ) ); + assign( [ value, v ] ); + } + // The fill value must have a shape which is broadcast compatible with the shape of the non-core dimensions... + v = maybeBroadcastArray( v, lsh ); + } + // Case: fillRange( x, value_scalar, ... ) + else { + // Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the input data type is floating-point... + if ( !isScalarMostlySafeCompatible( value, dt ) ) { + throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input ndarray data type. Data type: %s. Value: `%s`.', dt, value ) ); + } + v = broadcastScalar( value, dt, lsh, ord ); + } + // Broadcast the indices to match the shape of the non-core dimensions... + s = broadcastIndex( ( hasStart ) ? start : 0, lsh, ord ); + e = broadcastIndex( ( hasEnd ) ? end : len, lsh, ord ); + + // Perform operation: + return base( x, v, s, e, opts ); +} + + +// EXPORTS // + +module.exports = fillRange; diff --git a/lib/node_modules/@stdlib/blas/ext/fill-range/package.json b/lib/node_modules/@stdlib/blas/ext/fill-range/package.json new file mode 100644 index 000000000000..ae0cba7eb6a5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/fill-range/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/blas/ext/fill-range", + "version": "0.0.0", + "description": "Fill an input ndarray with a specified value along an ndarray dimension.", + "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", + "fill", + "range", + "set", + "assign", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/fill-range/test/test.js b/lib/node_modules/@stdlib/blas/ext/fill-range/test/test.js new file mode 100644 index 000000000000..d84913be0768 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/fill-range/test/test.js @@ -0,0 +1,1488 @@ +/** +* @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 isSameArray = require( '@stdlib/assert/is-same-array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' ); +var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Int32Array = require( '@stdlib/array/int32' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getOrder = require( '@stdlib/ndarray/order' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var fillRange = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof fillRange, '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() { + fillRange( value, 10.0 ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (start)', 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() { + fillRange( value, 10.0, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (start, end)', 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() { + fillRange( value, 10.0, 0, 2 ); + }; + } +}); + +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() { + fillRange( value, 10.0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (start, 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() { + fillRange( value, 10.0, 0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (start, end, 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() { + fillRange( value, 10.0, 0, 2, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is a zero-dimensional ndarray', function test( t ) { + var values; + var i; + + values = [ + scalar2ndarray( 10.0 ), + scalar2ndarray( -3.0 ), + scalar2ndarray( 0.0 ) + ]; + 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() { + fillRange( value, 10.0 ); + }; + } +}); + +tape( 'the function throws an error if provided a fill value which cannot be safely cast to the input ndarray data type', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'int32' + }); + + values = [ + '5', + 3.14, + true, + false, + null, + void 0, + [], + {}, + new Complex128( 10.0, 12.0 ), + function noop() {}, + scalar2ndarray( 10.0, { + 'dtype': 'float64' + }), + scalar2ndarray( new Complex128( 10.0, 12.0 ), { + 'dtype': 'complex128' + }), + scalar2ndarray( new Complex128( 10.0, 12.0 ), { + 'dtype': 'complex64' + }), + scalar2ndarray( 10.0, { + 'dtype': 'generic' + }), + scalar2ndarray( true, { + '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() { + fillRange( x, value ); + }; + } +}); + +tape( 'the function throws an error if provided a fill value which cannot be safely cast to the input ndarray data type (options)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'int32' + }); + + values = [ + '5', + 3.14, + true, + false, + null, + void 0, + [], + {}, + new Complex128( 10.0, 12.0 ), + function noop() {}, + scalar2ndarray( 10.0, { + 'dtype': 'float64' + }), + scalar2ndarray( new Complex128( 10.0, 12.0 ), { + 'dtype': 'complex128' + }), + scalar2ndarray( new Complex128( 10.0, 12.0 ), { + 'dtype': 'complex64' + }), + scalar2ndarray( 10.0, { + 'dtype': 'generic' + }), + scalar2ndarray( true, { + '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() { + fillRange( x, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a `start` argument which is not an ndarray-like object or an integer (end)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + 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() { + fillRange( x, 10.0, value, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided a `start` argument which is not an ndarray-like object or an integer (options)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + 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() { + fillRange( x, 10.0, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a `start` argument which is not an ndarray-like object or an integer (end, options)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + 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() { + fillRange( x, 10.0, value, 2, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an `end` argument which is not an ndarray-like object or an integer (options)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + 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() { + fillRange( x, 10.0, 0, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a fill value ndarray which is not broadcast-compatible', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + zeros( [ 4 ], opts ), + zeros( [ 2, 2, 2 ], opts ), + zeros( [ 0 ], opts ) + ]; + 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() { + fillRange( x, value ); + }; + } +}); + +tape( 'the function throws an error if provided a fill value ndarray which is not broadcast-compatible (options)', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + zeros( [ 4 ], opts ), + zeros( [ 2, 2, 2 ], opts ), + zeros( [ 0 ], opts ) + ]; + 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() { + fillRange( x, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a fill value ndarray which is not broadcast-compatible (dim)', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + zeros( [ 4 ], opts ), + zeros( [ 2, 2, 2 ], opts ), + zeros( [ 0 ], opts ) + ]; + 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() { + fillRange( x, value, { + 'dim': 0 + }); + }; + } +}); + +tape( 'the function throws an error if provided a `start` argument which is not broadcast-compatible', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + zeros( [ 4 ], opts ), + zeros( [ 2, 2, 2 ], opts ), + zeros( [ 0 ], opts ) + ]; + 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() { + fillRange( x, 10.0, value ); + }; + } +}); + +tape( 'the function throws an error if provided a `start` argument which is not broadcast-compatible (options)', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + zeros( [ 4 ], opts ), + zeros( [ 2, 2, 2 ], opts ), + zeros( [ 0 ], opts ) + ]; + 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() { + fillRange( x, 10.0, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an `end` argument which is not broadcast-compatible', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + zeros( [ 4 ], opts ), + zeros( [ 2, 2, 2 ], opts ), + zeros( [ 0 ], opts ) + ]; + 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() { + fillRange( x, 10.0, 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an `end` argument which is not broadcast-compatible (options)', function test( t ) { + var values; + var opts; + var x; + var i; + + opts = { + 'dtype': 'generic' + }; + x = zeros( [ 2, 2 ], opts ); + + values = [ + zeros( [ 4 ], opts ), + zeros( [ 2, 2, 2 ], opts ), + zeros( [ 0 ], opts ) + ]; + 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() { + fillRange( x, 10.0, 0, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + 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() { + fillRange( x, 10.0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (start)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + 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() { + fillRange( x, 10.0, 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (start, end)', 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() { + fillRange( x, 10.0, 0, 2, value ); + }; + } +}); + +tape( 'the function throws an error if provided a `dim` option which is not an integer', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + NaN, + true, + false, + null, + void 0, + [ 'a' ], + {}, + 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() { + fillRange( x, 10.0, { + 'dim': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dim` option which is not an integer (start, end)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + NaN, + true, + false, + null, + void 0, + [ 'a' ], + {}, + 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() { + fillRange( x, 10.0, 0, 2, { + 'dim': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dim` option which is out-of-bounds', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + -10, + 20 + ]; + 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() { + fillRange( x, 10.0, { + 'dim': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `dim` option which is out-of-bounds (start, end)', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + -10, + 20 + ]; + 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() { + fillRange( x, 10.0, 0, 2, { + 'dim': value + }); + }; + } +}); + +tape( 'the function fills an input ndarray with a specified value (default, row-major)', function test( t ) { + var expected; + var actual; + var x; + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0 ); + expected = [ 10.0, 10.0, 10.0, 10.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function fills an input ndarray with a specified value (default, column-major)', function test( t ) { + var expected; + var actual; + var x; + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = fillRange( x, 10.0 ); + expected = [ 10.0, 10.0, 10.0, 10.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function fills an input ndarray with a specified value (default, float64)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0 ); + expected = new Float64Array( [ 10.0, 10.0, 10.0, 10.0 ] ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'float64', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameFloat64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function fills an input ndarray with a specified value (default, complex128)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + x = new ndarray( 'complex128', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = fillRange( x, new Complex128( 10.0, 12.0 ) ); + expected = new Complex128Array( [ 10.0, 12.0, 10.0, 12.0, 10.0, 12.0, 10.0, 12.0 ] ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'complex128', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports downcasting a floating-point fill value to an input ndarray data type of the same kind (float32)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float32', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0 ); + expected = new Float32Array( [ 10.0, 10.0, 10.0, 10.0 ] ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'float32', 'returns expected value' ); + t.strictEqual( isSameFloat32Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports downcasting a floating-point fill value ndarray to an input ndarray data type of the same kind (float32)', function test( t ) { + var expected; + var actual; + var value; + var xbuf; + var x; + + xbuf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + x = new ndarray( 'float32', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + value = scalar2ndarray( 10.0, { + 'dtype': 'float64' + }); + + actual = fillRange( x, value ); + expected = new Float32Array( [ 10.0, 10.0, 10.0, 10.0 ] ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'float32', 'returns expected value' ); + t.strictEqual( isSameFloat32Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports downcasting a floating-point fill value to an input ndarray data type of the same kind (complex64)', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + x = new ndarray( 'complex64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = fillRange( x, new Complex128( 10.0, 12.0 ) ); + expected = new Complex64Array( [ 10.0, 12.0, 10.0, 12.0, 10.0, 12.0, 10.0, 12.0 ] ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'complex64', 'returns expected value' ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports downcasting a floating-point fill value ndarray to an input ndarray data type of the same kind (complex64)', function test( t ) { + var expected; + var actual; + var value; + var xbuf; + var x; + + xbuf = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + x = new ndarray( 'complex64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + value = scalar2ndarray( new Complex128( 10.0, 12.0 ), { + 'dtype': 'complex128' + }); + + actual = fillRange( x, value ); + expected = new Complex64Array( [ 10.0, 12.0, 10.0, 12.0, 10.0, 12.0, 10.0, 12.0 ] ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'complex64', 'returns expected value' ); + t.strictEqual( isSameComplex64Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports promoting a real-valued fill value when an input ndarray has a complex data type', function test( t ) { + var expected; + var actual; + var xbuf; + var x; + + xbuf = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + x = new ndarray( 'complex128', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0 ); + expected = new Complex128Array( [ 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0 ] ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'complex128', 'returns expected value' ); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports promoting a real-valued fill value ndarray when an input ndarray has a complex data type', function test( t ) { + var expected; + var actual; + var value; + var xbuf; + var x; + + xbuf = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + x = new ndarray( 'complex128', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + value = scalar2ndarray( 10.0, { + 'dtype': 'float64' + }); + + actual = fillRange( x, value ); + expected = new Complex128Array( [ 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0 ] ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'complex128', 'returns expected value' ); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the input ndarray unchanged if provided an empty ndarray', function test( t ) { + var actual; + var x; + + x = zeros( [ 0 ], { + 'dtype': 'float64' + }); + + actual = fillRange( x, 10.0 ); + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( getData( actual ).length, 0, 'returns expected value' ); + + x = zeros( [ 0, 3 ], { + 'dtype': 'float64' + }); + + actual = fillRange( x, 10.0, { + 'dim': 0 + }); + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( getData( actual ).length, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the operation dimension (row-major)', function test( t ) { + var expected; + var actual; + var x; + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, 0, 1, { + 'dim': 0 + }); + expected = [ [ 10.0, 10.0 ], [ 3.0, 4.0 ] ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, 0, 1, { + 'dim': 1 + }); + expected = [ [ 10.0, 2.0 ], [ 10.0, 4.0 ] ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, 0, 1, { + 'dim': -2 + }); + expected = [ [ 10.0, 10.0 ], [ 3.0, 4.0 ] ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the operation dimension (column-major)', function test( t ) { + var expected; + var actual; + var x; + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = fillRange( x, 10.0, 0, 1, { + 'dim': 0 + }); + expected = [ [ 10.0, 10.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = fillRange( x, 10.0, 0, 1, { + 'dim': 1 + }); + expected = [ [ 10.0, 3.0 ], [ 10.0, 4.0 ] ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0 ], [ 2, 2 ], [ 1, 2 ], 0, 'column-major' ); + + actual = fillRange( x, 10.0, 0, 1, { + 'dim': -2 + }); + expected = [ [ 10.0, 10.0 ], [ 2.0, 4.0 ] ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a starting index', function test( t ) { + var expected; + var actual; + var x; + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], [ 6 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, 2 ); + expected = [ 1.0, 2.0, 10.0, 10.0, 10.0, 10.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], [ 6 ], [ 1 ], 0, 'column-major' ); + + actual = fillRange( x, 10.0, 2 ); + expected = [ 1.0, 2.0, 10.0, 10.0, 10.0, 10.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing an ending index', function test( t ) { + var expected; + var actual; + var x; + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], [ 6 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, 1, 4 ); + expected = [ 1.0, 10.0, 10.0, 10.0, 5.0, 6.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], [ 6 ], [ 1 ], 0, 'column-major' ); + + actual = fillRange( x, 10.0, 1, 4 ); + expected = [ 1.0, 10.0, 10.0, 10.0, 5.0, 6.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( String( getDType( actual ) ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing negative indices', function test( t ) { + var expected; + var actual; + var x; + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], [ 6 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, -2 ); + expected = [ 1.0, 2.0, 3.0, 4.0, 10.0, 10.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], [ 6 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, 0, -2 ); + expected = [ 10.0, 10.0, 10.0, 10.0, 5.0, 6.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], [ 6 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, -3, -1 ); + expected = [ 1.0, 2.0, 3.0, 10.0, 10.0, 6.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function clamps out-of-bounds indices', function test( t ) { + var expected; + var actual; + var x; + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], [ 6 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, 10, 3 ); + expected = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], [ 6 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, 0, 100 ); + expected = [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], [ 6 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, -100, 2 ); + expected = [ 10.0, 10.0, 3.0, 4.0, 5.0, 6.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing index arguments as zero-dimensional ndarrays', function test( t ) { + var expected; + var actual; + var opts; + var x; + + opts = { + 'dtype': 'int32' + }; + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], [ 6 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, scalar2ndarray( 1, opts ), scalar2ndarray( 4, opts ) ); // eslint-disable-line max-len + expected = [ 1.0, 10.0, 10.0, 10.0, 5.0, 6.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing index arguments as zero-dimensional ndarrays (broadcasted)', function test( t ) { + var expected; + var actual; + var opts; + var x; + + opts = { + 'dtype': 'int32' + }; + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], [ 2, 4 ], [ 4, 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, scalar2ndarray( 2, opts ), { + 'dim': 1 + }); + expected = [ [ 1.0, 2.0, 10.0, 10.0 ], [ 5.0, 6.0, 10.0, 10.0 ] ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing index arguments as ndarrays', function test( t ) { + var expected; + var actual; + var start; + var x; + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], [ 2, 4 ], [ 4, 1 ], 0, 'row-major' ); + + start = new ndarray( 'int32', new Int32Array( [ 0, 2 ] ), [ 2 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, start, 4, { + 'dim': 1 + }); + expected = [ [ 10.0, 10.0, 10.0, 10.0 ], [ 5.0, 6.0, 10.0, 10.0 ] ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing index arguments as ndarrays containing negative indices', function test( t ) { + var expected; + var actual; + var start; + var x; + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], [ 2, 4 ], [ 4, 1 ], 0, 'row-major' ); + + start = new ndarray( 'int32', new Int32Array( [ -2, 0 ] ), [ 2 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, 10.0, start, { + 'dim': 1 + }); + expected = [ [ 1.0, 2.0, 10.0, 10.0 ], [ 10.0, 10.0, 10.0, 10.0 ] ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a fill value as a zero-dimensional ndarray', function test( t ) { + var expected; + var actual; + var opts; + var x; + + opts = { + 'dtype': 'generic' + }; + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], [ 6 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, scalar2ndarray( 10.0, opts ), 1, 4 ); + expected = [ 1.0, 10.0, 10.0, 10.0, 5.0, 6.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a fill value as an ndarray (broadcasted)', function test( t ) { + var expected; + var actual; + var value; + var x; + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], [ 2, 4 ], [ 4, 1 ], 0, 'row-major' ); + + value = new ndarray( 'generic', [ 10.0, 20.0 ], [ 2 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, value, { + 'dim': 1 + }); + expected = [ [ 10.0, 10.0, 10.0, 10.0 ], [ 20.0, 20.0, 20.0, 20.0 ] ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports filling an input ndarray with non-numeric values', function test( t ) { + var expected; + var actual; + var x; + + x = new ndarray( 'generic', [ 1.0, 2.0, 3.0, 4.0 ], [ 4 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, 'beep', 1, 3 ); + expected = [ 1.0, 'beep', 'beep', 4.0 ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + x = new ndarray( 'generic', [ false, false, false, false ], [ 4 ], [ 1 ], 0, 'row-major' ); + + actual = fillRange( x, true ); + expected = [ true, true, true, true ]; + + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' ); + + t.end(); +});