diff --git a/lib/node_modules/@stdlib/ndarray/fill-slice/README.md b/lib/node_modules/@stdlib/ndarray/fill-slice/README.md new file mode 100644 index 000000000000..4a888c2a08c8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/fill-slice/README.md @@ -0,0 +1,226 @@ + + +# fillSlice + +> Fill an input [`ndarray`][@stdlib/ndarray/ctor] slice with a specified value. + +
+ +
+ + + +
+ +## Usage + +```javascript +var fillSlice = require( '@stdlib/ndarray/fill-slice' ); +``` + +#### fillSlice( x, value, ...s\[, options] ) + +Fills an input [`ndarray`][@stdlib/ndarray/ctor] slice with a specified value. + +```javascript +var zeros = require( '@stdlib/ndarray/zeros' ); +var MultiSlice = require( '@stdlib/slice/multi' ); +var Slice = require( '@stdlib/slice/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); + +var x = zeros( [ 3, 4 ], { + 'dtype': 'float64' +}); + +// Define the fill region: +var s0 = new Slice( 1, 3 ); +var s1 = new Slice( 2, 4 ); +var s = new MultiSlice( s0, s1 ); + +// Fill the region with a scalar value: +var y = fillSlice( x, 5.0, s ); +// returns + +var bool = ( y === x ); +// returns true + +var arr = ndarray2array( x ); +// returns [ [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 5.0, 5.0 ], [ 0.0, 0.0, 5.0, 5.0 ] ] +``` + +The function accepts the following arguments: + +- **x**: array-like object containing an input [`ndarray`][@stdlib/ndarray/ctor]. +- **value**: scalar value. +- **s**: [`MultiSlice`][@stdlib/slice/multi] instance, an array of slice arguments, or slice arguments as separate arguments. +- **options**: function options. + +The function supports three (mutually exclusive) means for providing slice arguments: + +1. providing a single [`MultiSlice`][@stdlib/slice/multi] instance. +2. providing a single array of slice arguments. +3. providing slice arguments as separate arguments. + +The following example demonstrates each invocation style achieving equivalent results. + +```javascript +var zeros = require( '@stdlib/ndarray/zeros' ); +var MultiSlice = require( '@stdlib/slice/multi' ); +var Slice = require( '@stdlib/slice/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); + +var opts = { + 'dtype': 'float64' +}; + +// 1. Using a MultiSlice: +var x = zeros( [ 3, 4 ], opts ); + +var s0 = new Slice( 1, 3 ); +var s1 = new Slice( 2, 4 ); +var s = new MultiSlice( s0, s1 ); + +var out = fillSlice( x, 5.0, s ); +// returns + +var arr = ndarray2array( out ); +// returns [ [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 5.0, 5.0 ], [ 0.0, 0.0, 5.0, 5.0 ] ] + +// 2. Using an array of slice arguments: +x = zeros( [ 3, 4 ], opts ); + +out = fillSlice( x, 5.0, [ s0, s1 ] ); +// returns + +arr = ndarray2array( out ); +// returns [ [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 5.0, 5.0 ], [ 0.0, 0.0, 5.0, 5.0 ] ] + +// 3. Providing separate arguments: +x = zeros( [ 3, 4 ], opts ); + +out = fillSlice( x, 5.0, s0, s1 ); +// returns + +arr = ndarray2array( out ); +// returns [ [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 5.0, 5.0 ], [ 0.0, 0.0, 5.0, 5.0 ] ] +``` + +The function supports the following options: + +- **strict**: boolean indicating whether to enforce strict bounds checking. + +By default, the function throws an error when provided a slice which exceeds array bounds. To ignore slice indices exceeding array bounds, set the `strict` option to `false`. + +```javascript +var zeros = require( '@stdlib/ndarray/zeros' ); +var MultiSlice = require( '@stdlib/slice/multi' ); +var Slice = require( '@stdlib/slice/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); + +var x = zeros( [ 3, 4 ], { + 'dtype': 'float64' +}); + +// Define the fill region: +var s0 = new Slice( 1, null, 1 ); +var s1 = new Slice( 10, 20, 1 ); +var s = new MultiSlice( s0, s1 ); + +// Fill the region with a scalar value: +var y = fillSlice( x, 5.0, s, { + 'strict': false +}); +// returns + +var arr = ndarray2array( x ); +// returns [ [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] +``` + +
+ + + +
+ +## Notes + +- An input [`ndarray`][@stdlib/ndarray/ctor] **must** be writable. If provided a **read-only** [`ndarray`][@stdlib/ndarray/ctor], the function throws an error. +- If an input `value` is a number and `x` has a complex [data type][@stdlib/ndarray/dtypes], the function fills an input [`ndarray`][@stdlib/ndarray/ctor] with a complex number whose real component equals the provided scalar `value` and whose imaginary component is zero. +- An input `value` must be able to safely cast to the input [`ndarray`][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes]. Scalar values having floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., a scalar double-precision floating-point number can be used to fill a `'float32'` input [`ndarray`][@stdlib/ndarray/ctor]). +- The function **mutates** the input [`ndarray`][@stdlib/ndarray/ctor]. + +
+ + + +
+ +## Examples + + + +```javascript +var zeros = require( '@stdlib/ndarray/zeros' ); +var MultiSlice = require( '@stdlib/slice/multi' ); +var Slice = require( '@stdlib/slice/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var fillSlice = require( '@stdlib/ndarray/fill-slice' ); + +// Create a zero-filled ndarray: +var x = zeros( [ 2, 3, 4 ], { + 'dtype': 'generic' +}); +console.log( ndarray2array( x ) ); + +// Define a fill region: +var s0 = new Slice( 1, 2 ); +var s1 = new Slice( null, null ); +var s2 = new Slice( 2, 4 ); +var s = new MultiSlice( s0, s1, s2 ); + +// Fill the region with a scalar value: +fillSlice( x, 10.0, s ); +console.log( ndarray2array( x ) ); +``` + +
+ + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/fill-slice/benchmark/benchmark.1d.js b/lib/node_modules/@stdlib/ndarray/fill-slice/benchmark/benchmark.1d.js new file mode 100644 index 000000000000..c5144999c929 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/fill-slice/benchmark/benchmark.1d.js @@ -0,0 +1,122 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 MultiSlice = require( '@stdlib/slice/multi' ); +var pkg = require( './../package.json' ).name; +var fillSlice = require( './../lib' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var orders = [ 'row-major', 'column-major' ]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - input ndarray data type +* @param {string} order - memory layout +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype, order ) { + var x; + + x = zeros( shape, { + 'dtype': xtype, + 'order': order + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + fillSlice( x, i, new MultiSlice( null ) ); + if ( isnan( x.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( x.data[ 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 ord; + var sh; + var t1; + var f; + var i; + var j; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < orders.length; k++ ) { + ord = orders[ k ]; + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len ]; + f = createBenchmark( len, sh, t1, ord ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1, f ); + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/fill-slice/benchmark/benchmark.2d.js b/lib/node_modules/@stdlib/ndarray/fill-slice/benchmark/benchmark.2d.js new file mode 100644 index 000000000000..31cea248d37f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/fill-slice/benchmark/benchmark.2d.js @@ -0,0 +1,134 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 floor = require( '@stdlib/math/base/special/floor' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var MultiSlice = require( '@stdlib/slice/multi' ); +var pkg = require( './../package.json' ).name; +var fillSlice = require( './../lib' ); + + +// VARIABLES // + +var types = [ 'float64' ]; +var orders = [ 'row-major', 'column-major' ]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - ndarray length +* @param {NonNegativeIntegerArray} shape - ndarray shape +* @param {string} xtype - input ndarray data type +* @param {string} order - memory layout +* @returns {Function} benchmark function +*/ +function createBenchmark( len, shape, xtype, order ) { + var x; + + x = zeros( shape, { + 'dtype': xtype, + 'order': order + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + fillSlice( x, i, new MultiSlice( null, null ) ); + if ( isnan( x.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( x.data[ 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 ord; + var sh; + var t1; + var f; + var i; + var j; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < orders.length; k++ ) { + ord = orders[ k ]; + for ( j = 0; j < types.length; j++ ) { + t1 = types[ j ]; + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + sh = [ len/2, 2 ]; + f = createBenchmark( len, sh, t1, ord ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1, f ); + + sh = [ 2, len/2 ]; + f = createBenchmark( len, sh, t1, ord ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1, f ); + + len = floor( sqrt( len ) ); + sh = [ len, len ]; + len *= len; + f = createBenchmark( len, sh, t1, ord ); + bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1, f ); + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/fill-slice/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/fill-slice/docs/repl.txt new file mode 100644 index 000000000000..ab65639fc05f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/fill-slice/docs/repl.txt @@ -0,0 +1,63 @@ + +{{alias}}( x, value, ...s[, options] ) + Fills an input ndarray slice with a specified value. + + The function supports three (mutually exclusive) means of providing slice + arguments: + + 1. Providing a single MultiSlice object. + 2. Providing a single array containing slice arguments. + 3. Providing slice arguments as separate arguments. + + An individual slice argument must be either a Slice, an integer, null, or + undefined. + + If providing a MultiSlice object or an array of slice arguments, no other + slice arguments should be provided. + + Mixing function invocation styles (e.g., providing multiple MultiSlice + objects or providing an array of slice arguments followed by additional + slice arguments) is not supported. + + Parameters + ---------- + x: ndarray + Input ndarray. + + value: any + Scalar value. Must be able to safely cast to the input ndarray data + type. Scalar values having floating-point data types (both real and + complex) are allowed to downcast to a lower precision data type of the + same kind (e.g., a scalar double-precision floating-point number can be + used to fill a 'float32' input ndarray). + + s: ...MultiSlice|Slice|null|undefined|integer|ArrayLike + Slice arguments. + + options: Object (optional) + Options. + + options.strict: boolean (optional) + Boolean indicating whether to enforce strict bounds checking. + Default: true. + + Returns + ------- + out: ndarray + Input ndarray. + + Examples + -------- + > var x = {{alias:@stdlib/ndarray/zeros}}( [ 2, 2 ], { 'dtype': 'float64' } ); + > x.get( 0, 0 ) + 0.0 + > var s0 = new {{alias:@stdlib/slice/ctor}}( 0, 1 ); + > var s1 = new {{alias:@stdlib/slice/ctor}}( null, null ); + > var s = new {{alias:@stdlib/slice/multi}}( s0, s1 ); + > {{alias}}( x, 10.0, s ); + > x.get( 0, 0 ) + 10.0 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/fill-slice/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/fill-slice/docs/types/index.d.ts new file mode 100644 index 000000000000..d84d4f666c2a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/fill-slice/docs/types/index.d.ts @@ -0,0 +1,1314 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 max-lines */ + +// TypeScript Version: 4.1 + +/// + +import { typedndarray, genericndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray } from '@stdlib/types/ndarray'; +import { MultiSlice, Slice } from '@stdlib/types/slice'; +import { ComplexLike } from '@stdlib/types/complex'; + +/** +* Interface defining function options. +*/ +interface Options { + /** + * Boolean indicating whether to enforce strict bounds checking (default: true). + */ + strict?: boolean; +} + +/** +* Slice argument. +*/ +type SliceArgument = Slice | number | null | undefined; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'float64' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'float64' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: float64ndarray, value: number, s: MultiSlice | ArrayLike, options?: Options ): float64ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'float64' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: float64ndarray, value: number, ...slices: Array ): float64ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'float32' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'float32' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: float32ndarray, value: number, s: MultiSlice | ArrayLike, options?: Options ): float32ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'float32' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: float32ndarray, value: number, ...slices: Array ): float32ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'int32' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'int32' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: int32ndarray, value: number, s: MultiSlice | ArrayLike, options?: Options ): int32ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'int32' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: int32ndarray, value: number, ...slices: Array ): int32ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'int16' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'float64' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: int16ndarray, value: number, s: MultiSlice | ArrayLike, options?: Options ): int16ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'int16' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: int16ndarray, value: number, ...slices: Array ): int16ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'int8' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'int8' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: int8ndarray, value: number, s: MultiSlice | ArrayLike, options?: Options ): int8ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'int8' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: int8ndarray, value: number, ...slices: Array ): int8ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'uint32' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'uint32' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: uint32ndarray, value: number, s: MultiSlice | ArrayLike, options?: Options ): uint32ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'uint32' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: uint32ndarray, value: number, ...slices: Array ): uint32ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'uint16' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'uint16' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: uint16ndarray, value: number, s: MultiSlice | ArrayLike, options?: Options ): uint16ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'uint16' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: uint16ndarray, value: number, ...slices: Array ): uint16ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'uint8' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'uint8' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: uint8ndarray, value: number, s: MultiSlice | ArrayLike, options?: Options ): uint8ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'uint8' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: uint8ndarray, value: number, ...slices: Array ): uint8ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'uint8c' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'uint8c' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: uint8cndarray, value: number, s: MultiSlice | ArrayLike, options?: Options ): uint8cndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'uint8c' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5, s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: uint8cndarray, value: number, ...slices: Array ): uint8cndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'complex128' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, new Complex128( 5.0, 0.0 ), s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'complex128' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, new Complex128( 5.0, 0.0 ), [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0 ] ] +*/ +declare function fillSlice( x: complex128ndarray, value: ComplexLike, s: MultiSlice | ArrayLike, options?: Options ): complex128ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'complex128' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, new Complex128( 5.0, 0.0 ), s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0 ] ] +*/ +declare function fillSlice( x: complex128ndarray, value: ComplexLike, ...slices: Array ): complex128ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'complex64' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, new Complex64( 5.0, 0.0 ), s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'complex64' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, new Complex64( 5.0, 0.0 ), [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0 ] ] +*/ +declare function fillSlice( x: complex64ndarray, value: ComplexLike, s: MultiSlice | ArrayLike, options?: Options ): complex64ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'complex64' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, new Complex64( 5.0, 0.0 ), s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0 ] ] +*/ +declare function fillSlice( x: complex64ndarray, value: ComplexLike, ...slices: Array ): complex64ndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'generic' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'generic' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: genericndarray, value: number, s: MultiSlice | ArrayLike, options?: Options ): genericndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'generic' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: genericndarray, value: number, ...slices: Array ): genericndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param s - slice argument +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'generic' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'generic' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, [ s0, s1 ] ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ], [ 0, 0, 0, 0, 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: typedndarray, value: number, s: MultiSlice | ArrayLike, options?: Options ): typedndarray; + +/** +* Fills an input ndarray slice with a specified value. +* +* @param x - input ndarray +* @param value - scalar value +* @param slices - slice arguments +* @param options - function options +* @param options.strict - boolean indicating whether to enforce strict bounds checking +* @returns input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'generic' +* }); +* +* // Create a MultiSlice to specify the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, s0, s1 ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ +declare function fillSlice( x: typedndarray, value: number, ...slices: Array ): typedndarray; + + +// EXPORTS // + +export = fillSlice; diff --git a/lib/node_modules/@stdlib/ndarray/fill-slice/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/fill-slice/docs/types/test.ts new file mode 100644 index 000000000000..d71ed3589710 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/fill-slice/docs/types/test.ts @@ -0,0 +1,176 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import MultiSlice = require( '@stdlib/slice/multi' ); +import fillSlice = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const s = new MultiSlice( null, null ); + + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), 10.0, s ); // $ExpectType float64ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'float32' } ), 10.0, s ); // $ExpectType float32ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), { 're': 10.0, 'im': 0.0 }, s ); // $ExpectType complex128ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'complex64' } ), { 're': 10.0, 'im': 0.0 }, s ); // $ExpectType complex64ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'int32' } ), 10.0, s ); // $ExpectType int32ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'int16' } ), 10.0, s ); // $ExpectType int16ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'int8' } ), 10.0, s ); // $ExpectType int8ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'uint32' } ), 10.0, s ); // $ExpectType uint32ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'uint16' } ), 10.0, s ); // $ExpectType uint16ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'uint8' } ), 10.0, s ); // $ExpectType uint8ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ), 10.0, s ); // $ExpectType uint8cndarray + + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), 10.0, s, { 'strict': false } ); // $ExpectType float64ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'float32' } ), 10.0, s, { 'strict': false } ); // $ExpectType float32ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), { 're': 10.0, 'im': 0.0 }, s, { 'strict': false } ); // $ExpectType complex128ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'complex64' } ), { 're': 10.0, 'im': 0.0 }, s, { 'strict': false } ); // $ExpectType complex64ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'int32' } ), 10.0, s, { 'strict': false } ); // $ExpectType int32ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'int16' } ), 10.0, s, { 'strict': false } ); // $ExpectType int16ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'int8' } ), 10.0, s, { 'strict': false } ); // $ExpectType int8ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'uint32' } ), 10.0, s, { 'strict': false } ); // $ExpectType uint32ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'uint16' } ), 10.0, s, { 'strict': false } ); // $ExpectType uint16ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'uint8' } ), 10.0, s, { 'strict': false } ); // $ExpectType uint8ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ), 10.0, s, { 'strict': false } ); // $ExpectType uint8cndarray + + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'float64' } ), 10.0, s, { 'strict': true } ); // $ExpectType float64ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'float32' } ), 10.0, s, { 'strict': true } ); // $ExpectType float32ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'complex128' } ), { 're': 10.0, 'im': 0.0 }, s, { 'strict': true } ); // $ExpectType complex128ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'complex64' } ), { 're': 10.0, 'im': 0.0 }, s, { 'strict': true } ); // $ExpectType complex64ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'int32' } ), 10.0, s, { 'strict': true } ); // $ExpectType int32ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'int16' } ), 10.0, s, { 'strict': true } ); // $ExpectType int16ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'int8' } ), 10.0, s, { 'strict': true } ); // $ExpectType int8ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'uint32' } ), 10.0, s, { 'strict': true } ); // $ExpectType uint32ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'uint16' } ), 10.0, s, { 'strict': true } ); // $ExpectType uint16ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'uint8' } ), 10.0, s, { 'strict': true } ); // $ExpectType uint8ndarray + fillSlice( zeros( [ 2, 2 ], { 'dtype': 'uint8c' } ), 10.0, s, { 'strict': true } ); // $ExpectType uint8cndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an ndarray... +{ + const s = new MultiSlice( null, null ); + + fillSlice( '10', 10.0, s ); // $ExpectError + fillSlice( 10, 10.0, s ); // $ExpectError + fillSlice( false, 10.0, s ); // $ExpectError + fillSlice( true, 10.0, s ); // $ExpectError + fillSlice( null, 10.0, s ); // $ExpectError + fillSlice( [], 10.0, s ); // $ExpectError + fillSlice( {}, 10.0, s ); // $ExpectError + fillSlice( ( x: number ): number => x, 10.0, s ); // $ExpectError + + fillSlice( '10', 10.0, s, {} ); // $ExpectError + fillSlice( 10, 10.0, s, {} ); // $ExpectError + fillSlice( false, 10.0, s, {} ); // $ExpectError + fillSlice( true, 10.0, s, {} ); // $ExpectError + fillSlice( null, 10.0, s, {} ); // $ExpectError + fillSlice( [], 10.0, s, {} ); // $ExpectError + fillSlice( {}, 10.0, s, {} ); // $ExpectError + fillSlice( ( x: number ): number => x, 10.0, s, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = zeros( [ 2, 2 ] ); + const s = new MultiSlice( null, null ); + + fillSlice( x, '10', s ); // $ExpectError + fillSlice( x, false, s ); // $ExpectError + fillSlice( x, true, s ); // $ExpectError + fillSlice( x, null, s ); // $ExpectError + fillSlice( x, [], s ); // $ExpectError + fillSlice( x, {}, s ); // $ExpectError + fillSlice( x, ( x: number ): number => x, s ); // $ExpectError + + fillSlice( x, '10', s, {} ); // $ExpectError + fillSlice( x, false, s, {} ); // $ExpectError + fillSlice( x, true, s, {} ); // $ExpectError + fillSlice( x, null, s, {} ); // $ExpectError + fillSlice( x, [], s, {} ); // $ExpectError + fillSlice( x, {}, s, {} ); // $ExpectError + fillSlice( x, ( x: number ): number => x, s, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid slice argument... +{ + const x = zeros( [ 2, 2 ] ); + + fillSlice( x, 10.0, '5' ); // $ExpectError + fillSlice( x, 10.0, false ); // $ExpectError + fillSlice( x, 10.0, true ); // $ExpectError + fillSlice( x, 10.0, [ '5' ] ); // $ExpectError + fillSlice( x, 10.0, ( x: number ): number => x ); // $ExpectError + + fillSlice( x, 10.0, null, '5' ); // $ExpectError + fillSlice( x, 10.0, null, false ); // $ExpectError + fillSlice( x, 10.0, null, true ); // $ExpectError + fillSlice( x, 10.0, null, [ '5' ] ); // $ExpectError + fillSlice( x, 10.0, null, ( x: number ): number => x ); // $ExpectError + + fillSlice( x, 10.0, '5', {} ); // $ExpectError + fillSlice( x, 10.0, false, {} ); // $ExpectError + fillSlice( x, 10.0, true, {} ); // $ExpectError + fillSlice( x, 10.0, [ '5' ], {} ); // $ExpectError + fillSlice( x, 10.0, ( x: number ): number => x, {} ); // $ExpectError + + fillSlice( x, 10.0, null, '5', {} ); // $ExpectError + fillSlice( x, 10.0, null, false, {} ); // $ExpectError + fillSlice( x, 10.0, null, true, {} ); // $ExpectError + fillSlice( x, 10.0, null, [ '5' ], {} ); // $ExpectError + fillSlice( x, 10.0, null, ( 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 ] ); + const s = new MultiSlice( null, null ); + + fillSlice( x, 10.0, s, '5' ); // $ExpectError + fillSlice( x, 10.0, s, 5 ); // $ExpectError + fillSlice( x, 10.0, s, null ); // $ExpectError + fillSlice( x, 10.0, s, true ); // $ExpectError + fillSlice( x, 10.0, s, false ); // $ExpectError + fillSlice( x, 10.0, s, [ '5' ] ); // $ExpectError + fillSlice( x, 10.0, s, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided a `strict` option which is not a boolean... +{ + const x = zeros( [ 2, 2 ] ); + const s = new MultiSlice( null, null ); + + fillSlice( x, 10.0, s, { 'strict': '5' } ); // $ExpectError + fillSlice( x, 10.0, s, { 'strict': 5 } ); // $ExpectError + fillSlice( x, 10.0, s, { 'strict': null } ); // $ExpectError + fillSlice( x, 10.0, s, { 'strict': [ '5' ] } ); // $ExpectError + fillSlice( x, 10.0, s, { 'strict': {} } ); // $ExpectError + fillSlice( x, 10.0, s, { 'strict': ( 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 ] ); + const s = new MultiSlice( null, null ); + + fillSlice(); // $ExpectError + fillSlice( x ); // $ExpectError + fillSlice( x, 10.0, s, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/fill-slice/examples/index.js b/lib/node_modules/@stdlib/ndarray/fill-slice/examples/index.js new file mode 100644 index 000000000000..a1b7d4de01db --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/fill-slice/examples/index.js @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 zeros = require( '@stdlib/ndarray/zeros' ); +var MultiSlice = require( '@stdlib/slice/multi' ); +var Slice = require( '@stdlib/slice/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var fillSlice = require( './../lib' ); + +// Create a zero-filled ndarray: +var x = zeros( [ 2, 3, 4 ], { + 'dtype': 'generic' +}); +console.log( ndarray2array( x ) ); + +// Create a MultiSlice to specify the fill region: +var s0 = new Slice( 1, 2 ); +var s1 = new Slice( null, null ); +var s2 = new Slice( 2, 4 ); +var s = new MultiSlice( s0, s1, s2 ); + +// Fill the ndarray with a scalar value: +fillSlice( x, 10.0, s ); +console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/ndarray/fill-slice/lib/index.js b/lib/node_modules/@stdlib/ndarray/fill-slice/lib/index.js new file mode 100644 index 000000000000..e8f182cd4dc5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/fill-slice/lib/index.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 slice with a specified value. +* +* @module @stdlib/ndarray/fill-slice +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var fillSlice = require( '@stdlib/ndarray/fill-slice' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'float64' +* }); +* +* // Define the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/fill-slice/lib/main.js b/lib/node_modules/@stdlib/ndarray/fill-slice/lib/main.js new file mode 100644 index 000000000000..c1e9122ba4ea --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/fill-slice/lib/main.js @@ -0,0 +1,164 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isScalarMostlySafeCompatible = require( '@stdlib/ndarray/base/assert/is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length +var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); +var isPlainObject = require( '@stdlib/assert/is-plain-object' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var MultiSlice = require( '@stdlib/slice/multi' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var args2multislice = require( '@stdlib/slice/base/args2multislice' ); +var broadcastScalar = require( '@stdlib/ndarray/base/broadcast-scalar' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var getDtype = require( '@stdlib/ndarray/base/dtype' ); +var getShape = require( '@stdlib/ndarray/base/shape' ); +var getOrder = require( '@stdlib/ndarray/base/order' ); +var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); +var isMultiSlice = require( '@stdlib/assert/is-multi-slice' ); +var slice = require( '@stdlib/ndarray/base/slice' ); +var format = require( '@stdlib/string/format' ); +var base = require( '@stdlib/ndarray/slice-assign' ); + + +// MAIN // + +/** +* Fills an input ndarray slice with a specified value. +* +* @param {ndarray} x - input ndarray +* @param {*} value - scalar value +* @param {...*} s - slice arguments +* @param {Options} [options] - options +* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking +* @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} options argument must be an object +* @throws {TypeError} must provide valid options +* @throws {Error} too many arguments +* @throws {Error} cannot write to a read-only ndarray +* @returns {ndarray} input ndarray +* +* @example +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var MultiSlice = require( '@stdlib/slice/multi' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var x = zeros( [ 3, 4 ], { +* 'dtype': 'float64' +* }); +* +* // Define the fill region: +* var s0 = new Slice( 1, 3 ); +* var s1 = new Slice( 2, 4 ); +* var s = new MultiSlice( s0, s1 ); +* +* // Fill the ndarray with a scalar value: +* var y = fillSlice( x, 5.0, s ); +* // returns +* +* var bool = ( y === x ); +* // returns true +* +* var arr = ndarray2array( x ); +* // returns [ [ 0, 0, 0, 0 ], [ 0, 0, 5, 5 ], [ 0, 0, 5, 5 ] ] +*/ +function fillSlice( x, value, s ) { + var options; + var nargs; + var args; + var opts; + var view; + var dt; + var S; + var v; + var i; + + opts = { + 'strict': true + }; + nargs = arguments.length; + if ( !isndarrayLike( x ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + } + if ( isReadOnly( x ) ) { + throw new Error( 'invalid argument. Cannot write to a read-only array.' ); + } + if ( isPlainObject( arguments[ nargs-1 ] ) ) { + nargs -= 1; + options = arguments[ nargs ]; + if ( hasOwnProp( options, 'strict' ) ) { + if ( !isBoolean( options.strict ) ) { + throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', options.strict ) ); + } + opts.strict = options.strict; + } + } + if ( isMultiSlice( s ) ) { + S = s; + if ( nargs > 3 ) { + throw new Error( 'invalid invocation. Too many arguments.' ); + } + } else { + if ( isArrayLikeObject( s ) ) { + args = s; + if ( nargs > 3 ) { + throw new Error( 'invalid invocation. Too many arguments.' ); + } + } else { + args = []; + for ( i = 2; i < nargs; i++ ) { + args.push( arguments[ i ] ); + } + } + try { + S = args2multislice( args ); + } catch ( err ) { // eslint-disable-line no-unused-vars + // Search for the first offending value... + for ( i = 0; i < args.length; i++ ) { + try { + new MultiSlice( args[ i ] ); // eslint-disable-line no-new + } catch ( err ) { // eslint-disable-line no-unused-vars + throw new TypeError( format( 'invalid argument. Slice arguments must be either a Slice, integer, null, or undefined. Value: `%s`.', String( args[ i ] ) ) ); + } + } + } + } + dt = getDtype( x ); + + // Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the output data type is floating-point... + if ( !isScalarMostlySafeCompatible( value, dt ) ) { + throw new TypeError( format( 'invalid argument. Third argument cannot be safely cast to the input array data type. Data type: %s. Value: `%s`.', dt, value ) ); + } + // Resolve the slice view: + view = slice( x, S, opts.strict, true ); + + // Broadcast the fill value to an ndarray of same shape and data type as the input ndarray: + v = broadcastScalar( value, dt, getShape( view, true ), getOrder( x ) ); + + return base( v, x, S, opts ); +} + + +// EXPORTS // + +module.exports = fillSlice; diff --git a/lib/node_modules/@stdlib/ndarray/fill-slice/package.json b/lib/node_modules/@stdlib/ndarray/fill-slice/package.json new file mode 100644 index 000000000000..2b43da25a16d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/fill-slice/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/ndarray/fill-slice", + "version": "0.0.0", + "description": "Fill an input ndarray with a specified value in the region defined by a MultiSlice.", + "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", + "strided", + "array", + "ndarray", + "fill", + "slice", + "multislice", + "multi-slice", + "fill-slice", + "slice-fill", + "transform" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/ndarray/fill-slice/test/test.js b/lib/node_modules/@stdlib/ndarray/fill-slice/test/test.js new file mode 100644 index 000000000000..5779a2d5b6d8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/fill-slice/test/test.js @@ -0,0 +1,1879 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var zeros = require( '@stdlib/array/zeros' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var Slice = require( '@stdlib/slice/ctor' ); +var MultiSlice = require( '@stdlib/slice/multi' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var fillSlice = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof fillSlice, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray', 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() { + fillSlice( value, 10.0, new MultiSlice( null, null ) ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is a read-only ndarray', function test( t ) { + var x = scalar2ndarray( 0.0, { + 'dtype': 'float64', + 'readonly': true + }); + t.throws( badValue( x ), Error, 'throws an error' ); + t.end(); + + function badValue( value ) { + return function badValue() { + fillSlice( value, 10.0, new MultiSlice( null, null ) ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which cannot be safely cast to the input ndarray data type', function test( t ) { + var values; + var x; + var i; + + x = scalar2ndarray( 0.0, { + 'dtype': 'int32' + }); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + fillSlice( x, value, new MultiSlice( null, null) ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { + var values; + var x; + var s; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + x = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + s = new MultiSlice( null ); + + 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() { + fillSlice( x, 10.0, s, value ); + }; + } +}); + +tape( 'the function throws an error if provided a `strict` option which is not a boolean (multislice)', function test( t ) { + var values; + var x; + var s; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + [], + function noop() {} + ]; + x = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + s = new MultiSlice( null ); + + 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() { + fillSlice( x, 10.0, s, { + 'strict': value + }); + }; + } +}); + +tape( 'the function throws an error if provided an invalid slice argument', function test( t ) { + var values; + var x; + var s; + var i; + + values = [ + '5', + NaN, + [], + function noop() {} + ]; + x = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + s = null; + + 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() { + fillSlice( x, 10.0, s, value ); + }; + } +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, 10.0, s ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, 10.0, [ s0, s1, s2 ] ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, 10.0, s0, s1, s2 ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, contiguous, options)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, 10.0, s, { + 'strict': false + }); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, 10.0, s ); + + expected = new Complex128Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + fillSlice( x, new Complex128( -10.0, -20.0 ), s ); + + expected = new Complex128Array([ + -10.0, + -20.0, + -10.0, + -20.0, + -10.0, + -20.0, + -10.0, + -20.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, 10.0, [ s0, s1, s2 ] ); + + expected = new Complex128Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + fillSlice( x, new Complex128( -10.0, -20.0 ), [ s0, s1, s2 ] ); + + expected = new Complex128Array([ + -10.0, + -20.0, + -10.0, + -20.0, + -10.0, + -20.0, + -10.0, + -20.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, 10.0, s0, s1, s2 ); + + expected = new Complex128Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + fillSlice( x, new Complex128( -10.0, -20.0 ), [ s0, s1, s2 ] ); + + expected = new Complex128Array([ + -10.0, + -20.0, + -10.0, + -20.0, + -10.0, + -20.0, + -10.0, + -20.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, contiguous, accessors, options)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, 10.0, s, { + 'strict': false + }); + + expected = new Complex128Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + fillSlice( x, new Complex128( -10.0, -20.0 ), s, { + 'strict': false + }); + + expected = new Complex128Array([ + -10.0, + -20.0, + -10.0, + -20.0, + -10.0, + -20.0, + -10.0, + -20.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, 10.0, s ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 10.0, + 10.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, 10.0, [ s0, s1, s2 ] ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 10.0, + 10.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, 10.0, s0, s1, s2 ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 10.0, + 10.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, contiguous, options)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, 10.0, s, { + 'strict': false + }); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 10.0, + 10.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, new Complex128( 10.0, 0.0 ), s ); + + expected = new Complex128Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + fillSlice( x, new Complex128( -10.0, -20.0 ), s ); + + expected = new Complex128Array([ + -10.0, + -20.0, + -10.0, + -20.0, + 0.0, + 0.0, + -10.0, + -20.0, + -10.0, + -20.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, new Complex128( 10.0, 0.0 ), [ s0, s1, s2 ] ); + + expected = new Complex128Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + fillSlice( x, new Complex128( -10.0, -20.0 ), [ s0, s1, s2 ] ); + + expected = new Complex128Array([ + -10.0, + -20.0, + -10.0, + -20.0, + 0.0, + 0.0, + -10.0, + -20.0, + -10.0, + -20.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, new Complex128( 10.0, 0.0 ), s0, s1, s2 ); + + expected = new Complex128Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + fillSlice( x, new Complex128( -10.0, -20.0 ), s0, s1, s2 ); + + expected = new Complex128Array([ + -10.0, + -20.0, + -10.0, + -20.0, + 0.0, + 0.0, + -10.0, + -20.0, + -10.0, + -20.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, contiguous, accessors, options)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, new Complex128( 10.0, 0.0 ), s, { + 'strict': false + }); + + expected = new Complex128Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + fillSlice( x, new Complex128( -10.0, -20.0 ), s, { + 'strict': false + }); + + expected = new Complex128Array([ + -10.0, + -20.0, + -10.0, + -20.0, + 0.0, + 0.0, + -10.0, + -20.0, + -10.0, + -20.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, non-contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = [ 4, 4, 1 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, 10.0, s ); + + expected = new Float64Array([ + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, non-contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = [ 4, 4, 1 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, 10.0, [ s0, s1, s2 ] ); + + expected = new Float64Array([ + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, non-contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = [ 4, 4, 1 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, 10.0, s0, s1, s2 ); + + expected = new Float64Array([ + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, non-contiguous, options)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = [ 4, 4, 1 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, 10.0, s, { + 'strict': false + }); + + expected = new Float64Array([ + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, non-contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = [ 4, 4, 1 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, new Complex128( 10.0, 0.0 ), s ); + + expected = new Complex128Array([ + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, non-contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = [ 4, 4, 1 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, new Complex128( 10.0, 0.0 ), [ s0, s1, s2 ] ); + + expected = new Complex128Array([ + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, non-contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = [ 4, 4, 1 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, new Complex128( 10.0, 0.0 ), s0, s1, s2 ); + + expected = new Complex128Array([ + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (row-major, non-contiguous, accessors, options)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 3, 1, 2 ]; + st = [ 4, 4, 1 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, new Complex128( 10.0, 0.0 ), s, { + 'strict': false + }); + + expected = new Complex128Array([ + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, non-contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = [ 1, 6, 6 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, 10.0, s ); + + expected = new Float64Array([ + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, non-contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = [ 1, 6, 6 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, 10.0, [ s0, s1, s2 ] ); + + expected = new Float64Array([ + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, non-contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = [ 1, 6, 6 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, 10.0, s0, s1, s2 ); + + expected = new Float64Array([ + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, non-contiguous, options)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = [ 1, 6, 6 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, 10.0, s, { + 'strict': false + }); + + expected = new Float64Array([ + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, non-contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var s; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = [ 1, 6, 6 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, new Complex128( 10.0, 0.0 ), s ); + + expected = new Complex128Array([ + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, non-contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = [ 1, 6, 6 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, new Complex128( 10.0, 0.0 ), [ s0, s1, s2 ] ); + + expected = new Complex128Array([ + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, non-contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = [ 1, 6, 6 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + + fillSlice( x, new Complex128( 10.0, 0.0 ), s0, s1, s2 ); + + expected = new Complex128Array([ + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills an input ndarray slice with a specified value (column-major, non-contiguous, accessors, options)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var s0; + var s1; + var s2; + var s; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 3, 1, 2 ]; + st = [ 1, 6, 6 ]; + o = 1; + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + s0 = new Slice( 0, 2 ); + s1 = new Slice( null, null ); + s2 = new Slice( null, null ); + s = new MultiSlice( s0, s1, s2 ); + + fillSlice( x, new Complex128( 10.0, 0.0 ), s, { + 'strict': false + }); + + expected = new Complex128Array([ + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + t.end(); +});