diff --git a/lib/node_modules/@stdlib/ndarray/base/includes/test/test.1d.js b/lib/node_modules/@stdlib/ndarray/base/includes/test/test.1d.js new file mode 100644 index 000000000000..e516244e11be --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/includes/test/test.1d.js @@ -0,0 +1,104 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var oneTo = require( '@stdlib/array/one-to' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var includes = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof includes, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether a 1-dimensional ndarray contains a specified value', function test( t ) { + var actual; + var x; + var v; + + x = ndarray( 'float64', oneTo( 8, 'float64' ), [ 4 ], [ 2 ], 1, 'row-major' ); + + v = scalar2ndarray( 9.0, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 4.0, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 1-dimensional ndarray contains a specified value (accessors)', function test( t ) { + var actual; + var x; + var v; + + x = ndarray( 'float64', toAccessorArray( oneTo( 8, 'float64' ) ), [ 4 ], [ 2 ], 1, 'row-major' ); + + v = ndarray( 'float64', toAccessorArray( new Float64Array( [ 9.0 ] ) ), [], [ 0 ], 0, 'row-major' ); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = ndarray( 'float64', toAccessorArray( new Float64Array( [ 4.0 ] ) ), [], [ 0 ], 0, 'row-major' ); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 1-dimensional ndarray contains a specified value (complex)', function test( t ) { + var actual; + var xbuf; + var x; + var v; + + xbuf = oneTo( 12, 'float64' ); + x = ndarray( 'complex128', new Complex128Array( xbuf ), [ 4 ], [ 1 ], 1, 'row-major' ); + + v = scalar2ndarray( new Complex128( 1.0, 2.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 9.0, 10.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/includes/test/test.2d.js b/lib/node_modules/@stdlib/ndarray/base/includes/test/test.2d.js new file mode 100644 index 000000000000..1356bc93adf6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/includes/test/test.2d.js @@ -0,0 +1,1423 @@ +/** +* @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 toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var oneTo = require( '@stdlib/array/one-to' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); +var includes = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof includes, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( numel( sh ), dt ), sh, st, o, ord ); + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( numel( sh ), dt ), sh, st, o, ord ); + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( numel( sh ), dt ), sh, st, o, ord ); + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( 8, dt ), sh, st, o, ord ); + + v = scalar2ndarray( 4, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 6, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( 8, dt ), sh, st, o, ord ); + + v = scalar2ndarray( 4, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 6, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( numel( sh )*2, dt ), sh, st, o, ord ); + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ bsize*4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( numel( sh )*2, dt ), sh, st, o, ord ); + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, contiguous, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + xbuf = oneTo( numel( sh )*2, 'float64' ); + + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + v = scalar2ndarray( new Complex128( 1.0, 0.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 5.0, 6.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ -2, -1 ]; + o = strides2offset( sh, st ); + xbuf = oneTo( numel( sh )*2, 'float64' ); + + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + v = scalar2ndarray( new Complex128( 1.0, 0.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 5.0, 6.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, 1 ]; + o = strides2offset( sh, st ); + xbuf = oneTo( 8*2, 'float64' ); + + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + v = scalar2ndarray( new Complex128( 7.0, 8.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 3.0, 4.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, -1 ]; + o = strides2offset( sh, st ); + xbuf = oneTo( 8*2, 'float64' ); + + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + v = scalar2ndarray( new Complex128( 7.0, 8.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 3.0, 4.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -4, 2 ]; + o = strides2offset( sh, st ); + xbuf = oneTo( numel( sh )*4, 'float64' ); + + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + v = scalar2ndarray( new Complex128( 3.0, 4.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 5.0, 6.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ bsize*4, -2 ]; + o = strides2offset( sh, st ); + xbuf = oneTo( numel( sh )*4, 'float64' ); + + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + v = scalar2ndarray( new Complex128( 3.0, 4.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 5.0, 6.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( 8, dt ) ), sh, st, o, ord ); + + v = scalar2ndarray( 4, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 6, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( 8, dt ) ), sh, st, o, ord ); + + v = scalar2ndarray( 4, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 6, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ bsize*4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, singleton dimensions)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( numel( sh ), dt ), sh, st, o, ord ); + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, singleton dimensions, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, contiguous)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( numel( sh ), dt ), sh, st, o, ord ); + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, contiguous, negative strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -1, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( numel( sh ), dt ), sh, st, o, ord ); + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, non-contiguous, same sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( 8, dt ), sh, st, o, ord ); + + v = scalar2ndarray( 4, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 6, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -1, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( 8, dt ), sh, st, o, ord ); + + v = scalar2ndarray( 4, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 6, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ 2, -bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( numel( sh )*2, dt ), sh, st, o, ord ); + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, non-contiguous, large arrays)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ -2, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, oneTo( numel( sh )*2, dt ), sh, st, o, ord ); + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, contiguous, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + xbuf = oneTo( numel( sh )*2, 'float64' ); + + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + v = scalar2ndarray( new Complex128( 1.0, 0.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 5.0, 6.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, contiguous, negative strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -1, -2 ]; + o = strides2offset( sh, st ); + xbuf = oneTo( numel( sh )*2, 'float64' ); + + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + v = scalar2ndarray( new Complex128( 1.0, 0.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 5.0, 6.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, non-contiguous, same sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, 4 ]; + o = strides2offset( sh, st ); + xbuf = oneTo( 8*2, 'float64' ); + + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + v = scalar2ndarray( new Complex128( 7.0, 8.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 3.0, 4.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, non-contiguous, mixed sign strides, complex)', function test( t ) { + var actual; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 4, -1 ]; + o = strides2offset( sh, st ); + xbuf = oneTo( 8*2, 'float64' ); + + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + v = scalar2ndarray( new Complex128( 7.0, 8.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 3.0, 4.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -2, bsize*2 ]; + o = strides2offset( sh, st ); + xbuf = oneTo( numel( sh )*4, 'float64' ); + + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + v = scalar2ndarray( new Complex128( 3.0, 4.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 5.0, 6.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, non-contiguous, large arrays, complex)', function test( t ) { + var actual; + var bsize; + var xbuf; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ 2, -4 ]; + o = strides2offset( sh, st ); + xbuf = oneTo( numel( sh )*4, 'float64' ); + + x = ndarray( dt, new Complex128Array( xbuf ), sh, st, o, ord ); + + v = scalar2ndarray( new Complex128( 3.0, 4.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( new Complex128( 5.0, 6.0 ), { + 'dtype': 'complex128' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, contiguous, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( numel( sh ), dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, contiguous, negative strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -1, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( numel( sh ), dt ) ), sh, st, o, ord ); + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( 8, dt ) ), sh, st, o, ord ); + + v = scalar2ndarray( 4, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 6, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var actual; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 4, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( 8, dt ) ), sh, st, o, ord ); + + v = scalar2ndarray( 4, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 6, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -2, bsize*2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether a 2-dimensional ndarray contains a specified value (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var actual; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + var v; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ 2, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, toAccessorArray( oneTo( numel( sh )*2, dt ) ), sh, st, o, ord ); // eslint-disable-line max-len + + v = scalar2ndarray( 8, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, false, 'returns expected value' ); + + v = scalar2ndarray( 3, { + 'dtype': 'float64' + }); + actual = includes( [ x, v ] ); + t.strictEqual( actual, true, 'returns expected value' ); + + t.end(); +});