From 3538ad20a52adc87c86a33c4ba69df65676e3332 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:03:53 +0500 Subject: [PATCH 01/54] test(ndarray/base/nullary): add tests for nullary0d --- .../ndarray/base/nullary/test/test.main.js | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js new file mode 100644 index 000000000000..3a2d1a1ca1f2 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 constantFunction = require( '@stdlib/utils/constant-function'); +var Float64Array = require( '@stdlib/array/float64' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var nullary = require( './../lib/main.js' ); +var nullary0d = require( './../lib/0d.js' ); +var accessornullary0d = require( './../lib/0d_accessors.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 0-dimensional ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 1 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [], + 'strides': [ 0 ], + 'offset': 0, + 'order': 'row-major' + }; + + nullary0d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 0-dimensional ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( [ 1.0, 1.0 ] ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [], + 'strides': [ 0 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary0d( x, constantFunction( new Complex64( 10.0, 10.0 ) ) ); + + expected = new Float32Array( [ 10.0, 10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From feeb62687eebb6ff9d72adda27b25c892b7a4600 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:11:08 +0500 Subject: [PATCH 02/54] test(ndarray/base/nullary): add tests for nullary1d --- .../ndarray/base/nullary/test/test.main.js | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 3a2d1a1ca1f2..1e4fc5c34865 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -28,7 +28,9 @@ var Complex64Array = require( '@stdlib/array/complex64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var nullary = require( './../lib/main.js' ); var nullary0d = require( './../lib/0d.js' ); +var nullary1d = require( './../lib/1d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); +var accessornullary1d = require( './../lib/1d_accessors.js' ); // TESTS // @@ -98,3 +100,63 @@ tape( 'the function applies a nullary callback to each indexed element of a 0-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 8 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 4 ], + 'strides': [ 2 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary1d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0 ] ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 2 ], + 'strides': [ 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter] + }; + + accessornullary1d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, -5.0, 6.0, -7.0, 8.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From cd48c03fb1f0012b161aa8c35a18c34d672209e9 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:17:57 +0500 Subject: [PATCH 03/54] test(ndarray/base/nullary): add tests for nullary2d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 1e4fc5c34865..89d3c091726f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -29,8 +29,12 @@ var Complex64 = require( '@stdlib/complex/float32/ctor' ); var nullary = require( './../lib/main.js' ); var nullary0d = require( './../lib/0d.js' ); var nullary1d = require( './../lib/1d.js' ); +var nullary2d = require( './../lib/2d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); +var accessornullary2d = require( './../lib/2d_accessors.js' ); +var blockednullary2d = require( './../lib/2d_blocked.js' ); +var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); // TESTS // @@ -160,3 +164,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 1-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 8 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 2, 2 ], + 'strides': [ 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary2d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 8 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 2, 2 ], + 'strides': [ 1, 4 ], + 'offset': 1, + 'order': 'column-major' + }; + + nullary2d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0 ] ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 2, 2 ], + 'strides': [ 4, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary2d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, -5.0, 6.0, -7.0, 8.0, 1.0, 1.0, 1.0, 1.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0 ] ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 2, 2 ], + 'strides': [ 1, 4 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary2d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, -5.0, 6.0, -7.0, 8.0, 1.0, 1.0, 1.0, 1.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 8 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 2, 2 ], + 'strides': [ 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary2d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0 ] ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary2d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -9.0, 10.0, -11.0, 12.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 8338c6067e1d750ee579620f9e63d6575438a3a2 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:24:11 +0500 Subject: [PATCH 04/54] test(ndarray/base/nullary): add tests for nullary3d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 89d3c091726f..48c737a8343f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -30,11 +30,15 @@ var nullary = require( './../lib/main.js' ); var nullary0d = require( './../lib/0d.js' ); var nullary1d = require( './../lib/1d.js' ); var nullary2d = require( './../lib/2d.js' ); +var nullary3d = require( './../lib/3d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); +var accessornullary3d = require( './../lib/3d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); +var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); +var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); // TESTS // @@ -344,3 +348,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 3, 1, 2 ], + 'strides': [ 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary3d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 3, 1, 2 ], + 'strides': [ 1, 3, 3 ], + 'offset': 1, + 'order': 'column-major' + }; + + nullary3d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 2, 2 ], + 'strides': [ 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary3d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 2, 2 ], + 'strides': [ 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary3d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 3, 1, 2 ], + 'strides': [ 2, 2, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary3d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 2, 2 ], + 'strides': [ 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary3d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From e536428057bf3d29d9aaabac73a95a431ba62e87 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:44:35 +0500 Subject: [PATCH 05/54] test(ndarray/base/nullary): add tests for nullary4d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 48c737a8343f..7fac7de4defb 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -31,14 +31,18 @@ var nullary0d = require( './../lib/0d.js' ); var nullary1d = require( './../lib/1d.js' ); var nullary2d = require( './../lib/2d.js' ); var nullary3d = require( './../lib/3d.js' ); +var nullary4d = require( './../lib/4d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); var accessornullary3d = require( './../lib/3d_accessors.js' ); +var accessornullary4d = require( './../lib/4d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); +var blockednullary4d = require( './../lib/4d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); +var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); // TESTS // @@ -528,3 +532,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 3-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 3, 1, 2 ], + 'strides': [ 12, 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary4d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 3, 1, 2 ], + 'strides': [ 1, 1, 3, 3 ], + 'offset': 1, + 'order': 'column-major' + }; + + nullary4d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary4d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary4d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 3, 1, 2 ], + 'strides': [ 12, 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary4d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary4d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From f3f5ca636ef538ff660cbae1eca80e2d1ee2c7c7 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:50:07 +0500 Subject: [PATCH 06/54] test(ndarray/base/nullary): add tests for nullary5d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 7fac7de4defb..9abd0f6d5a42 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -32,17 +32,21 @@ var nullary1d = require( './../lib/1d.js' ); var nullary2d = require( './../lib/2d.js' ); var nullary3d = require( './../lib/3d.js' ); var nullary4d = require( './../lib/4d.js' ); +var nullary5d = require( './../lib/5d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); var accessornullary3d = require( './../lib/3d_accessors.js' ); var accessornullary4d = require( './../lib/4d_accessors.js' ); +var accessornullary5d = require( './../lib/5d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); +var blockednullary5d = require( './../lib/5d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); +var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); // TESTS // @@ -712,3 +716,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 4-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 4, 4, 1 ], + 'offset': 0, + 'order': 'row-major' + }; + + nullary5d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 3, 1, 2 ], + 'strides': [ 1, 1, 1, 3, 3 ], + 'offset': 0, + 'order': 'column-major' + }; + + nullary5d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 2, 2 ], + 'strides': [ 4, 4, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary5d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary5d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 2, 3 ], + 'strides': [ 6, 6, 6, 3, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary5d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 12 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 2, 1, 1, 1, 1 ], + 'strides': [ 1, 1, 1, 1, 1 ], + 'offset': 1, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary5d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 0.0, 0.0, 10.0, -10.0, 10.0, -10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From c422f32ab7344171ebd9b1ef32e78b977d63fae5 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:56:05 +0500 Subject: [PATCH 07/54] test(ndarray/base/nullary): add tests for nullary6d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 9abd0f6d5a42..fcd4a508bf3d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -33,20 +33,24 @@ var nullary2d = require( './../lib/2d.js' ); var nullary3d = require( './../lib/3d.js' ); var nullary4d = require( './../lib/4d.js' ); var nullary5d = require( './../lib/5d.js' ); +var nullary6d = require( './../lib/6d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); var accessornullary3d = require( './../lib/3d_accessors.js' ); var accessornullary4d = require( './../lib/4d_accessors.js' ); var accessornullary5d = require( './../lib/5d_accessors.js' ); +var accessornullary6d = require( './../lib/6d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); var blockednullary5d = require( './../lib/5d_blocked.js' ); +var blockednullary6d = require( './../lib/6d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); +var blockedaccessornullary6d = require( './../lib/6d_blocked_accessors.js' ); // TESTS // @@ -896,3 +900,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 5-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional (row-major) ndarray ', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 12, 4, 4, 1 ], + 'offset': 0, + 'order': 'row-major' + }; + + nullary6d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 3, 1, 2 ], + 'strides': [ 1, 1, 1, 1, 3, 3 ], + 'offset': 0, + 'order': 'column-major' + }; + + nullary6d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary6d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary6d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 2, 3 ], + 'strides': [ 6, 6, 6, 6, 3, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary6d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary6d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 0f87a7068a1a8d2ac00bfff116761c0ee729d55a Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 15:01:27 +0500 Subject: [PATCH 08/54] test(ndarray/base/nullary): add tests for nullary7d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index fcd4a508bf3d..e4dcdea6dec9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -34,6 +34,7 @@ var nullary3d = require( './../lib/3d.js' ); var nullary4d = require( './../lib/4d.js' ); var nullary5d = require( './../lib/5d.js' ); var nullary6d = require( './../lib/6d.js' ); +var nullary7d = require( './../lib/7d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); @@ -41,16 +42,19 @@ var accessornullary3d = require( './../lib/3d_accessors.js' ); var accessornullary4d = require( './../lib/4d_accessors.js' ); var accessornullary5d = require( './../lib/5d_accessors.js' ); var accessornullary6d = require( './../lib/6d_accessors.js' ); +var accessornullary7d = require( './../lib/7d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); var blockednullary5d = require( './../lib/5d_blocked.js' ); var blockednullary6d = require( './../lib/6d_blocked.js' ); +var blockednullary7d = require( './../lib/7d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); var blockedaccessornullary6d = require( './../lib/6d_blocked_accessors.js' ); +var blockedaccessornullary7d = require( './../lib/7d_blocked_accessors.js' ); // TESTS // @@ -1080,3 +1084,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 6-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 12, 12, 4, 4, 1 ], + 'offset': 0, + 'order': 'row-major' + }; + + nullary7d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 3, 3 ], + 'offset': 0, + 'order': 'column-major' + }; + + nullary7d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional (row-major) ndarray element (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary7d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary7d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 2, 3 ], + 'strides': [ 6, 6, 6, 6, 6, 3, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary7d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary7d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From f6c861b5fdda9defb2be16a86ca1467d34b7ae22 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 15:06:28 +0500 Subject: [PATCH 09/54] test(ndarray/base/nullary): add tests for nullary8d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index e4dcdea6dec9..43890dded826 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -35,6 +35,7 @@ var nullary4d = require( './../lib/4d.js' ); var nullary5d = require( './../lib/5d.js' ); var nullary6d = require( './../lib/6d.js' ); var nullary7d = require( './../lib/7d.js' ); +var nullary8d = require( './../lib/8d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); @@ -43,18 +44,21 @@ var accessornullary4d = require( './../lib/4d_accessors.js' ); var accessornullary5d = require( './../lib/5d_accessors.js' ); var accessornullary6d = require( './../lib/6d_accessors.js' ); var accessornullary7d = require( './../lib/7d_accessors.js' ); +var accessornullary8d = require( './../lib/8d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); var blockednullary5d = require( './../lib/5d_blocked.js' ); var blockednullary6d = require( './../lib/6d_blocked.js' ); var blockednullary7d = require( './../lib/7d_blocked.js' ); +var blockednullary8d = require( './../lib/8d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); var blockedaccessornullary6d = require( './../lib/6d_blocked_accessors.js' ); var blockedaccessornullary7d = require( './../lib/7d_blocked_accessors.js' ); +var blockedaccessornullary8d = require( './../lib/8d_blocked_accessors.js' ); // TESTS // @@ -1264,3 +1268,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 7-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 12, 12, 12, 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary8d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 3, 3 ], + 'offset': 1, + 'order': 'column-major' + }; + + nullary8d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary8d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary8d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 2, 3 ], + 'strides': [ 6, 6, 6, 6, 6, 6, 3, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary8d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary8d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From e3f48e11ddaf0d7751ae0bd21bad03465d8ca164 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 15:11:04 +0500 Subject: [PATCH 10/54] test(ndarray/base/nullary): add tests for nullary9d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 43890dded826..713ef43aafd2 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -36,6 +36,7 @@ var nullary5d = require( './../lib/5d.js' ); var nullary6d = require( './../lib/6d.js' ); var nullary7d = require( './../lib/7d.js' ); var nullary8d = require( './../lib/8d.js' ); +var nullary9d = require( './../lib/9d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); @@ -45,6 +46,7 @@ var accessornullary5d = require( './../lib/5d_accessors.js' ); var accessornullary6d = require( './../lib/6d_accessors.js' ); var accessornullary7d = require( './../lib/7d_accessors.js' ); var accessornullary8d = require( './../lib/8d_accessors.js' ); +var accessornullary9d = require( './../lib/9d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); @@ -52,6 +54,7 @@ var blockednullary5d = require( './../lib/5d_blocked.js' ); var blockednullary6d = require( './../lib/6d_blocked.js' ); var blockednullary7d = require( './../lib/7d_blocked.js' ); var blockednullary8d = require( './../lib/8d_blocked.js' ); +var blockednullary9d = require( './../lib/9d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); @@ -59,6 +62,7 @@ var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); var blockedaccessornullary6d = require( './../lib/6d_blocked_accessors.js' ); var blockedaccessornullary7d = require( './../lib/7d_blocked_accessors.js' ); var blockedaccessornullary8d = require( './../lib/8d_blocked_accessors.js' ); +var blockedaccessornullary9d = require( './../lib/9d_blocked_accessors.js' ); // TESTS // @@ -1448,3 +1452,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 12, 12, 12, 12, 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary9d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 1, 3, 3 ], + 'offset': 1, + 'order': 'column-major' + }; + + nullary9d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary9d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary9d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 2, 3 ], + 'strides': [ 6, 6, 6, 6, 6, 6, 6, 3, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary9d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary9d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 7b9aa260e0a592a373b930576df7b1830932a80d Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 15:20:31 +0500 Subject: [PATCH 11/54] test(ndarray/base/nullary): add tests for nullary10d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 713ef43aafd2..1ac457cc5696 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -37,6 +37,7 @@ var nullary6d = require( './../lib/6d.js' ); var nullary7d = require( './../lib/7d.js' ); var nullary8d = require( './../lib/8d.js' ); var nullary9d = require( './../lib/9d.js' ); +var nullary10d = require( './../lib/10d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); @@ -47,6 +48,7 @@ var accessornullary6d = require( './../lib/6d_accessors.js' ); var accessornullary7d = require( './../lib/7d_accessors.js' ); var accessornullary8d = require( './../lib/8d_accessors.js' ); var accessornullary9d = require( './../lib/9d_accessors.js' ); +var accessornullary10d = require( './../lib/10d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); @@ -55,6 +57,7 @@ var blockednullary6d = require( './../lib/6d_blocked.js' ); var blockednullary7d = require( './../lib/7d_blocked.js' ); var blockednullary8d = require( './../lib/8d_blocked.js' ); var blockednullary9d = require( './../lib/9d_blocked.js' ); +var blockednullary10d = require( './../lib/10d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); @@ -63,6 +66,7 @@ var blockedaccessornullary6d = require( './../lib/6d_blocked_accessors.js' ); var blockedaccessornullary7d = require( './../lib/7d_blocked_accessors.js' ); var blockedaccessornullary8d = require( './../lib/8d_blocked_accessors.js' ); var blockedaccessornullary9d = require( './../lib/9d_blocked_accessors.js' ); +var blockedaccessornullary10d = require( './../lib/10d_blocked_accessors.js' ); // TESTS // @@ -1632,3 +1636,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 9-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary10d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 1, 1, 3, 3 ], + 'offset': 1, + 'order': 'column-major' + }; + + nullary10d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary10d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary10d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3 ], + 'strides': [ 6, 6, 6, 6, 6, 6, 6, 6, 3, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary10d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary10d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 3c14136e307d71de64151b27d08103f4f1b50ea2 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 15:22:21 +0500 Subject: [PATCH 12/54] test(ndarray/base/nullary): add tests for nullarynd --- .../ndarray/base/nullary/test/test.main.js | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 1ac457cc5696..74e39e6ffd5f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -38,6 +38,7 @@ var nullary7d = require( './../lib/7d.js' ); var nullary8d = require( './../lib/8d.js' ); var nullary9d = require( './../lib/9d.js' ); var nullary10d = require( './../lib/10d.js' ); +var nullarynd = require( './../lib/nd.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); @@ -49,6 +50,7 @@ var accessornullary7d = require( './../lib/7d_accessors.js' ); var accessornullary8d = require( './../lib/8d_accessors.js' ); var accessornullary9d = require( './../lib/9d_accessors.js' ); var accessornullary10d = require( './../lib/10d_accessors.js' ); +var accessornullarynd = require( './../lib/nd_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); @@ -1816,3 +1818,63 @@ tape( 'the function applies a nullary callback to each indexed element of a 10-d t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 11-dimensional ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullarynd( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 11-dimensional ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullarynd( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From ce164250281519de385e972c9b0212cc6cddbfc6 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 17:03:21 +0500 Subject: [PATCH 13/54] test(ndarray/base/nullary): add some tests for edge-cases --- .../ndarray/base/nullary/test/test.main.js | 183 ++++++++++++++++++ 1 file changed, 183 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 74e39e6ffd5f..1e7dbcc6932b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -343,6 +343,32 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked edge-case)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 64 ); + + x = { + 'dtype': 'generic', + 'data': xbuf, + 'shape': [ 8, 8 ], + 'strides': [ 8, 1 ], + 'offset': 0, + 'order': 'row-major' + }; + + blockednullary2d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( 64 ); + + expected.fill( 10.0 ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked accessors)', function test( t ) { var complexbuf; var expected; @@ -379,6 +405,41 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked accessors edge-case)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Complex64Array( 64 ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 8, 8 ], + 'strides': [ 8, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary2d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Complex64Array( 64 ); + + expected.fill( new Complex64( 1.0, -1.0 ) ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (row-major) ndarray', function test( t ) { var expected; var xbuf; @@ -523,6 +584,32 @@ tape( 'the function applies a nullary callback to each indexed element of a 3-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked edge-case)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 512 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 8, 8, 8 ], + 'strides': [ 64, 8, 1 ], + 'offset': 0, + 'order': 'row-major' + }; + + blockednullary3d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( 512 ); + + expected.fill( 10.0 ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked accessors)', function test( t ) { var complexbuf; var expected; @@ -559,6 +646,41 @@ tape( 'the function applies a nullary callback to each indexed element of a 3-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked accessors)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Complex64Array( 512 ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 8, 8, 8 ], + 'strides': [ 64, 8, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary3d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Complex64Array( 512 ); + + expected.fill( new Complex64( 1.0, 1.0 ) ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (row-major) ndarray', function test( t ) { var expected; var xbuf; @@ -703,6 +825,32 @@ tape( 'the function applies a nullary callback to each indexed element of a 4-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked edge-case)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 4096 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 8, 8, 8, 8 ], + 'strides': [ 512, 64, 8, 1 ], + 'offset': 0, + 'order': 'row-major' + }; + + blockednullary4d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( 4096 ); + + expected.fill( 10.0 ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked accessors)', function test( t ) { var complexbuf; var expected; @@ -739,6 +887,41 @@ tape( 'the function applies a nullary callback to each indexed element of a 4-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked accessors edge-case)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Complex64Array( 4096 ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 8, 8, 8, 8 ], + 'strides': [ 512, 64, 8, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary4d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Complex64Array( 4096 ); + + expected.fill( new Complex64( 10.0, -10.0 ) ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (row-major) ndarray', function test( t ) { var expected; var xbuf; From 5fd1993fd74484b9eb7ea83c7dc2ef1f98de8829 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 17:08:12 +0500 Subject: [PATCH 14/54] chore(ndarray/base/nullary): remove fixme comment from test file --- lib/node_modules/@stdlib/ndarray/base/nullary/test/test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.js index dbf444497d0e..854cefca7c82 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.js @@ -31,5 +31,3 @@ tape( 'main export is a function', function test( t ) { t.strictEqual( typeof nullary, 'function', 'main export is a function' ); t.end(); }); - -// FIXME: add tests From ca0d5cbb5218d2481a78183266023a630b6069ab Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 8 Jul 2024 02:21:12 -0700 Subject: [PATCH 15/54] test: move 0d tests to separate file --- .../ndarray/base/nullary/test/test.0d.js | 72 +++++++++++++++++++ .../ndarray/base/nullary/test/test.main.js | 62 ---------------- 2 files changed, 72 insertions(+), 62 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js new file mode 100644 index 000000000000..9decfc9dede0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 constantFunction = require( '@stdlib/utils/constant-function' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 0-dimensional ndarray', function test( t ) { + var expected; + var x; + + x = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0 ] ); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 0-dimensional ndarray (accessors)', function test( t ) { + var expected; + var x; + + x = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' + }); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( [ 10.0, 10.0 ] ); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 1e7dbcc6932b..66acf141711d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -27,7 +27,6 @@ var Float32Array = require( '@stdlib/array/float32' ); var Complex64Array = require( '@stdlib/array/complex64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var nullary = require( './../lib/main.js' ); -var nullary0d = require( './../lib/0d.js' ); var nullary1d = require( './../lib/1d.js' ); var nullary2d = require( './../lib/2d.js' ); var nullary3d = require( './../lib/3d.js' ); @@ -39,7 +38,6 @@ var nullary8d = require( './../lib/8d.js' ); var nullary9d = require( './../lib/9d.js' ); var nullary10d = require( './../lib/10d.js' ); var nullarynd = require( './../lib/nd.js' ); -var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); var accessornullary3d = require( './../lib/3d_accessors.js' ); @@ -79,66 +77,6 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 0-dimensional ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 1 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major' - }; - - nullary0d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 10.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 0-dimensional ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( [ 1.0, 1.0 ] ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullary0d( x, constantFunction( new Complex64( 10.0, 10.0 ) ) ); - - expected = new Float32Array( [ 10.0, 10.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray', function test( t ) { var expected; var xbuf; From b9b7894a0f77be1c7de754b33af2aa522f491757 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 8 Jul 2024 02:30:54 -0700 Subject: [PATCH 16/54] test: move 1d tests to separate file --- .../ndarray/base/nullary/test/test.0d.js | 2 +- .../ndarray/base/nullary/test/test.1d.js | 91 +++++++++++++++++++ .../ndarray/base/nullary/test/test.main.js | 62 ------------- 3 files changed, 92 insertions(+), 63 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.1d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js index 9decfc9dede0..1e9a9701a5b9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2024 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. diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.1d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.1d.js new file mode 100644 index 000000000000..9755bce59af0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.1d.js @@ -0,0 +1,91 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray', function test( t ) { + var expected; + var x; + + x = ndarray( 'float64', zeros( 8, 'float64' ), [ 4 ], [ 2 ], 1, 'row-major' ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray (accessors)', function test( t ) { + var expected; + var x; + + x = ndarray( 'complex128', zeros( 6, 'complex128' ), [ 4 ], [ 1 ], 1, 'row-major' ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 66acf141711d..ee677dcc6075 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -27,7 +27,6 @@ var Float32Array = require( '@stdlib/array/float32' ); var Complex64Array = require( '@stdlib/array/complex64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var nullary = require( './../lib/main.js' ); -var nullary1d = require( './../lib/1d.js' ); var nullary2d = require( './../lib/2d.js' ); var nullary3d = require( './../lib/3d.js' ); var nullary4d = require( './../lib/4d.js' ); @@ -38,7 +37,6 @@ var nullary8d = require( './../lib/8d.js' ); var nullary9d = require( './../lib/9d.js' ); var nullary10d = require( './../lib/10d.js' ); var nullarynd = require( './../lib/nd.js' ); -var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); var accessornullary3d = require( './../lib/3d_accessors.js' ); var accessornullary4d = require( './../lib/4d_accessors.js' ); @@ -77,66 +75,6 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 8 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 4 ], - 'strides': [ 2 ], - 'offset': 1, - 'order': 'row-major' - }; - - nullary1d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0 ] ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 2 ], - 'strides': [ 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter] - }; - - accessornullary1d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, -5.0, 6.0, -7.0, 8.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (row-major) ndarray', function test( t ) { var expected; var xbuf; From ace0f99157b86b16627311395953708d45291808 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 8 Jul 2024 03:08:25 -0700 Subject: [PATCH 17/54] test: move 2d tests to separate file --- .../ndarray/base/nullary/test/test.2d.js | 604 ++++++++++++++++++ .../ndarray/base/nullary/test/test.main.js | 245 ------- 2 files changed, 604 insertions(+), 245 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js new file mode 100644 index 000000000000..2c78c90158e4 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js @@ -0,0 +1,604 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index ee677dcc6075..60972159f07c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -27,7 +27,6 @@ var Float32Array = require( '@stdlib/array/float32' ); var Complex64Array = require( '@stdlib/array/complex64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var nullary = require( './../lib/main.js' ); -var nullary2d = require( './../lib/2d.js' ); var nullary3d = require( './../lib/3d.js' ); var nullary4d = require( './../lib/4d.js' ); var nullary5d = require( './../lib/5d.js' ); @@ -37,7 +36,6 @@ var nullary8d = require( './../lib/8d.js' ); var nullary9d = require( './../lib/9d.js' ); var nullary10d = require( './../lib/10d.js' ); var nullarynd = require( './../lib/nd.js' ); -var accessornullary2d = require( './../lib/2d_accessors.js' ); var accessornullary3d = require( './../lib/3d_accessors.js' ); var accessornullary4d = require( './../lib/4d_accessors.js' ); var accessornullary5d = require( './../lib/5d_accessors.js' ); @@ -47,7 +45,6 @@ var accessornullary8d = require( './../lib/8d_accessors.js' ); var accessornullary9d = require( './../lib/9d_accessors.js' ); var accessornullary10d = require( './../lib/10d_accessors.js' ); var accessornullarynd = require( './../lib/nd_accessors.js' ); -var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); var blockednullary5d = require( './../lib/5d_blocked.js' ); @@ -56,7 +53,6 @@ var blockednullary7d = require( './../lib/7d_blocked.js' ); var blockednullary8d = require( './../lib/8d_blocked.js' ); var blockednullary9d = require( './../lib/9d_blocked.js' ); var blockednullary10d = require( './../lib/10d_blocked.js' ); -var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); @@ -75,247 +71,6 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (row-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 8 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 2, 2 ], - 'strides': [ 4, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - nullary2d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (column-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 8 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 2, 2 ], - 'strides': [ 1, 4 ], - 'offset': 1, - 'order': 'column-major' - }; - - nullary2d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (row-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0 ] ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 2, 2 ], - 'strides': [ 4, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullary2d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, -5.0, 6.0, -7.0, 8.0, 1.0, 1.0, 1.0, 1.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (column-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0 ] ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 2, 2 ], - 'strides': [ 1, 4 ], - 'offset': 0, - 'order': 'column-major', - 'accessors': [ getter, setter ] - }; - - accessornullary2d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, -5.0, 6.0, -7.0, 8.0, 1.0, 1.0, 1.0, 1.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 8 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 2, 2 ], - 'strides': [ 4, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - blockednullary2d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked edge-case)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 64 ); - - x = { - 'dtype': 'generic', - 'data': xbuf, - 'shape': [ 8, 8 ], - 'strides': [ 8, 1 ], - 'offset': 0, - 'order': 'row-major' - }; - - blockednullary2d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( 64 ); - - expected.fill( 10.0 ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0 ] ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary2d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -9.0, 10.0, -11.0, 12.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked accessors edge-case)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Complex64Array( 64 ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 8, 8 ], - 'strides': [ 8, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary2d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Complex64Array( 64 ); - - expected.fill( new Complex64( 1.0, -1.0 ) ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (row-major) ndarray', function test( t ) { var expected; var xbuf; From 658bdf2cbae01bf86301fb3438c906eebe0d1dd4 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:03:53 +0500 Subject: [PATCH 18/54] test(ndarray/base/nullary): add tests for nullary0d --- .../ndarray/base/nullary/test/test.main.js | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js new file mode 100644 index 000000000000..3a2d1a1ca1f2 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 constantFunction = require( '@stdlib/utils/constant-function'); +var Float64Array = require( '@stdlib/array/float64' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var nullary = require( './../lib/main.js' ); +var nullary0d = require( './../lib/0d.js' ); +var accessornullary0d = require( './../lib/0d_accessors.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 0-dimensional ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 1 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [], + 'strides': [ 0 ], + 'offset': 0, + 'order': 'row-major' + }; + + nullary0d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 0-dimensional ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( [ 1.0, 1.0 ] ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [], + 'strides': [ 0 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary0d( x, constantFunction( new Complex64( 10.0, 10.0 ) ) ); + + expected = new Float32Array( [ 10.0, 10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From f93fcf96aaacf09370e16d9a327fee5bf7069b31 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:11:08 +0500 Subject: [PATCH 19/54] test(ndarray/base/nullary): add tests for nullary1d --- .../ndarray/base/nullary/test/test.main.js | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 3a2d1a1ca1f2..1e4fc5c34865 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -28,7 +28,9 @@ var Complex64Array = require( '@stdlib/array/complex64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var nullary = require( './../lib/main.js' ); var nullary0d = require( './../lib/0d.js' ); +var nullary1d = require( './../lib/1d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); +var accessornullary1d = require( './../lib/1d_accessors.js' ); // TESTS // @@ -98,3 +100,63 @@ tape( 'the function applies a nullary callback to each indexed element of a 0-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 8 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 4 ], + 'strides': [ 2 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary1d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0 ] ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 2 ], + 'strides': [ 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter] + }; + + accessornullary1d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, -5.0, 6.0, -7.0, 8.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 258d333a3cd5a81c0ce441cb3b57c5583aaaca13 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:17:57 +0500 Subject: [PATCH 20/54] test(ndarray/base/nullary): add tests for nullary2d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 1e4fc5c34865..89d3c091726f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -29,8 +29,12 @@ var Complex64 = require( '@stdlib/complex/float32/ctor' ); var nullary = require( './../lib/main.js' ); var nullary0d = require( './../lib/0d.js' ); var nullary1d = require( './../lib/1d.js' ); +var nullary2d = require( './../lib/2d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); +var accessornullary2d = require( './../lib/2d_accessors.js' ); +var blockednullary2d = require( './../lib/2d_blocked.js' ); +var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); // TESTS // @@ -160,3 +164,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 1-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 8 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 2, 2 ], + 'strides': [ 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary2d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 8 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 2, 2 ], + 'strides': [ 1, 4 ], + 'offset': 1, + 'order': 'column-major' + }; + + nullary2d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0 ] ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 2, 2 ], + 'strides': [ 4, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary2d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, -5.0, 6.0, -7.0, 8.0, 1.0, 1.0, 1.0, 1.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0 ] ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 2, 2 ], + 'strides': [ 1, 4 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary2d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, -5.0, 6.0, -7.0, 8.0, 1.0, 1.0, 1.0, 1.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 8 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 2, 2 ], + 'strides': [ 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary2d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0 ] ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 2, 2 ], + 'strides': [ 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary2d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -9.0, 10.0, -11.0, 12.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 89ddf2094841b3fab106c018b08d43650693bd9d Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:24:11 +0500 Subject: [PATCH 21/54] test(ndarray/base/nullary): add tests for nullary3d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 89d3c091726f..48c737a8343f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -30,11 +30,15 @@ var nullary = require( './../lib/main.js' ); var nullary0d = require( './../lib/0d.js' ); var nullary1d = require( './../lib/1d.js' ); var nullary2d = require( './../lib/2d.js' ); +var nullary3d = require( './../lib/3d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); +var accessornullary3d = require( './../lib/3d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); +var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); +var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); // TESTS // @@ -344,3 +348,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 3, 1, 2 ], + 'strides': [ 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary3d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 3, 1, 2 ], + 'strides': [ 1, 3, 3 ], + 'offset': 1, + 'order': 'column-major' + }; + + nullary3d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 2, 2 ], + 'strides': [ 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary3d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 2, 2 ], + 'strides': [ 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary3d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 3, 1, 2 ], + 'strides': [ 2, 2, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary3d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 2, 2 ], + 'strides': [ 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary3d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From ed4e83064b0f49a908f22abb70e40e11e2430c3c Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:44:35 +0500 Subject: [PATCH 22/54] test(ndarray/base/nullary): add tests for nullary4d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 48c737a8343f..7fac7de4defb 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -31,14 +31,18 @@ var nullary0d = require( './../lib/0d.js' ); var nullary1d = require( './../lib/1d.js' ); var nullary2d = require( './../lib/2d.js' ); var nullary3d = require( './../lib/3d.js' ); +var nullary4d = require( './../lib/4d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); var accessornullary3d = require( './../lib/3d_accessors.js' ); +var accessornullary4d = require( './../lib/4d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); +var blockednullary4d = require( './../lib/4d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); +var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); // TESTS // @@ -528,3 +532,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 3-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 3, 1, 2 ], + 'strides': [ 12, 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary4d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 3, 1, 2 ], + 'strides': [ 1, 1, 3, 3 ], + 'offset': 1, + 'order': 'column-major' + }; + + nullary4d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary4d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary4d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 3, 1, 2 ], + 'strides': [ 12, 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary4d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary4d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 08c3ae3aa3c971551c33ddb437e0a0008cdb5584 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:50:07 +0500 Subject: [PATCH 23/54] test(ndarray/base/nullary): add tests for nullary5d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 7fac7de4defb..9abd0f6d5a42 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -32,17 +32,21 @@ var nullary1d = require( './../lib/1d.js' ); var nullary2d = require( './../lib/2d.js' ); var nullary3d = require( './../lib/3d.js' ); var nullary4d = require( './../lib/4d.js' ); +var nullary5d = require( './../lib/5d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); var accessornullary3d = require( './../lib/3d_accessors.js' ); var accessornullary4d = require( './../lib/4d_accessors.js' ); +var accessornullary5d = require( './../lib/5d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); +var blockednullary5d = require( './../lib/5d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); +var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); // TESTS // @@ -712,3 +716,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 4-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 4, 4, 1 ], + 'offset': 0, + 'order': 'row-major' + }; + + nullary5d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 3, 1, 2 ], + 'strides': [ 1, 1, 1, 3, 3 ], + 'offset': 0, + 'order': 'column-major' + }; + + nullary5d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 2, 2 ], + 'strides': [ 4, 4, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary5d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary5d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 2, 3 ], + 'strides': [ 6, 6, 6, 3, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary5d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 12 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 2, 1, 1, 1, 1 ], + 'strides': [ 1, 1, 1, 1, 1 ], + 'offset': 1, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary5d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 0.0, 0.0, 10.0, -10.0, 10.0, -10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 4ab89052f798a7926c785f10b3d3473f66e9887d Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 14:56:05 +0500 Subject: [PATCH 24/54] test(ndarray/base/nullary): add tests for nullary6d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 9abd0f6d5a42..fcd4a508bf3d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -33,20 +33,24 @@ var nullary2d = require( './../lib/2d.js' ); var nullary3d = require( './../lib/3d.js' ); var nullary4d = require( './../lib/4d.js' ); var nullary5d = require( './../lib/5d.js' ); +var nullary6d = require( './../lib/6d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); var accessornullary3d = require( './../lib/3d_accessors.js' ); var accessornullary4d = require( './../lib/4d_accessors.js' ); var accessornullary5d = require( './../lib/5d_accessors.js' ); +var accessornullary6d = require( './../lib/6d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); var blockednullary5d = require( './../lib/5d_blocked.js' ); +var blockednullary6d = require( './../lib/6d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); +var blockedaccessornullary6d = require( './../lib/6d_blocked_accessors.js' ); // TESTS // @@ -896,3 +900,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 5-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional (row-major) ndarray ', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 12, 4, 4, 1 ], + 'offset': 0, + 'order': 'row-major' + }; + + nullary6d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 3, 1, 2 ], + 'strides': [ 1, 1, 1, 1, 3, 3 ], + 'offset': 0, + 'order': 'column-major' + }; + + nullary6d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary6d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary6d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 2, 3 ], + 'strides': [ 6, 6, 6, 6, 3, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary6d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary6d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From a228d069cf7f678ef9c0446c17fa5e93e71d6857 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 15:01:27 +0500 Subject: [PATCH 25/54] test(ndarray/base/nullary): add tests for nullary7d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index fcd4a508bf3d..e4dcdea6dec9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -34,6 +34,7 @@ var nullary3d = require( './../lib/3d.js' ); var nullary4d = require( './../lib/4d.js' ); var nullary5d = require( './../lib/5d.js' ); var nullary6d = require( './../lib/6d.js' ); +var nullary7d = require( './../lib/7d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); @@ -41,16 +42,19 @@ var accessornullary3d = require( './../lib/3d_accessors.js' ); var accessornullary4d = require( './../lib/4d_accessors.js' ); var accessornullary5d = require( './../lib/5d_accessors.js' ); var accessornullary6d = require( './../lib/6d_accessors.js' ); +var accessornullary7d = require( './../lib/7d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); var blockednullary5d = require( './../lib/5d_blocked.js' ); var blockednullary6d = require( './../lib/6d_blocked.js' ); +var blockednullary7d = require( './../lib/7d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); var blockedaccessornullary6d = require( './../lib/6d_blocked_accessors.js' ); +var blockedaccessornullary7d = require( './../lib/7d_blocked_accessors.js' ); // TESTS // @@ -1080,3 +1084,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 6-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 12, 12, 4, 4, 1 ], + 'offset': 0, + 'order': 'row-major' + }; + + nullary7d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 3, 3 ], + 'offset': 0, + 'order': 'column-major' + }; + + nullary7d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional (row-major) ndarray element (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary7d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary7d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 2, 3 ], + 'strides': [ 6, 6, 6, 6, 6, 3, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary7d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary7d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 45c962f4bf809932fb95790065380c2d27a43296 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 15:06:28 +0500 Subject: [PATCH 26/54] test(ndarray/base/nullary): add tests for nullary8d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index e4dcdea6dec9..43890dded826 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -35,6 +35,7 @@ var nullary4d = require( './../lib/4d.js' ); var nullary5d = require( './../lib/5d.js' ); var nullary6d = require( './../lib/6d.js' ); var nullary7d = require( './../lib/7d.js' ); +var nullary8d = require( './../lib/8d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); @@ -43,18 +44,21 @@ var accessornullary4d = require( './../lib/4d_accessors.js' ); var accessornullary5d = require( './../lib/5d_accessors.js' ); var accessornullary6d = require( './../lib/6d_accessors.js' ); var accessornullary7d = require( './../lib/7d_accessors.js' ); +var accessornullary8d = require( './../lib/8d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); var blockednullary5d = require( './../lib/5d_blocked.js' ); var blockednullary6d = require( './../lib/6d_blocked.js' ); var blockednullary7d = require( './../lib/7d_blocked.js' ); +var blockednullary8d = require( './../lib/8d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); var blockedaccessornullary6d = require( './../lib/6d_blocked_accessors.js' ); var blockedaccessornullary7d = require( './../lib/7d_blocked_accessors.js' ); +var blockedaccessornullary8d = require( './../lib/8d_blocked_accessors.js' ); // TESTS // @@ -1264,3 +1268,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 7-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 12, 12, 12, 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary8d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 3, 3 ], + 'offset': 1, + 'order': 'column-major' + }; + + nullary8d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary8d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary8d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 2, 3 ], + 'strides': [ 6, 6, 6, 6, 6, 6, 3, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary8d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary8d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 6cf778b7ec007edb2ed25df93da200e25006109b Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 15:11:04 +0500 Subject: [PATCH 27/54] test(ndarray/base/nullary): add tests for nullary9d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 43890dded826..713ef43aafd2 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -36,6 +36,7 @@ var nullary5d = require( './../lib/5d.js' ); var nullary6d = require( './../lib/6d.js' ); var nullary7d = require( './../lib/7d.js' ); var nullary8d = require( './../lib/8d.js' ); +var nullary9d = require( './../lib/9d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); @@ -45,6 +46,7 @@ var accessornullary5d = require( './../lib/5d_accessors.js' ); var accessornullary6d = require( './../lib/6d_accessors.js' ); var accessornullary7d = require( './../lib/7d_accessors.js' ); var accessornullary8d = require( './../lib/8d_accessors.js' ); +var accessornullary9d = require( './../lib/9d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); @@ -52,6 +54,7 @@ var blockednullary5d = require( './../lib/5d_blocked.js' ); var blockednullary6d = require( './../lib/6d_blocked.js' ); var blockednullary7d = require( './../lib/7d_blocked.js' ); var blockednullary8d = require( './../lib/8d_blocked.js' ); +var blockednullary9d = require( './../lib/9d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); @@ -59,6 +62,7 @@ var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); var blockedaccessornullary6d = require( './../lib/6d_blocked_accessors.js' ); var blockedaccessornullary7d = require( './../lib/7d_blocked_accessors.js' ); var blockedaccessornullary8d = require( './../lib/8d_blocked_accessors.js' ); +var blockedaccessornullary9d = require( './../lib/9d_blocked_accessors.js' ); // TESTS // @@ -1448,3 +1452,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 12, 12, 12, 12, 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary9d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 1, 3, 3 ], + 'offset': 1, + 'order': 'column-major' + }; + + nullary9d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary9d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary9d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 2, 3 ], + 'strides': [ 6, 6, 6, 6, 6, 6, 6, 3, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary9d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary9d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 6b21d259ac716e784805f9a965920599cac420de Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 15:20:31 +0500 Subject: [PATCH 28/54] test(ndarray/base/nullary): add tests for nullary10d --- .../ndarray/base/nullary/test/test.main.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 713ef43aafd2..1ac457cc5696 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -37,6 +37,7 @@ var nullary6d = require( './../lib/6d.js' ); var nullary7d = require( './../lib/7d.js' ); var nullary8d = require( './../lib/8d.js' ); var nullary9d = require( './../lib/9d.js' ); +var nullary10d = require( './../lib/10d.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); @@ -47,6 +48,7 @@ var accessornullary6d = require( './../lib/6d_accessors.js' ); var accessornullary7d = require( './../lib/7d_accessors.js' ); var accessornullary8d = require( './../lib/8d_accessors.js' ); var accessornullary9d = require( './../lib/9d_accessors.js' ); +var accessornullary10d = require( './../lib/10d_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); @@ -55,6 +57,7 @@ var blockednullary6d = require( './../lib/6d_blocked.js' ); var blockednullary7d = require( './../lib/7d_blocked.js' ); var blockednullary8d = require( './../lib/8d_blocked.js' ); var blockednullary9d = require( './../lib/9d_blocked.js' ); +var blockednullary10d = require( './../lib/10d_blocked.js' ); var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); @@ -63,6 +66,7 @@ var blockedaccessornullary6d = require( './../lib/6d_blocked_accessors.js' ); var blockedaccessornullary7d = require( './../lib/7d_blocked_accessors.js' ); var blockedaccessornullary8d = require( './../lib/8d_blocked_accessors.js' ); var blockedaccessornullary9d = require( './../lib/9d_blocked_accessors.js' ); +var blockedaccessornullary10d = require( './../lib/10d_blocked_accessors.js' ); // TESTS // @@ -1632,3 +1636,183 @@ tape( 'the function applies a nullary callback to each indexed element of a 9-di t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional (row-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullary10d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional (column-major) ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 1, 1, 3, 3 ], + 'offset': 1, + 'order': 'column-major' + }; + + nullary10d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional (row-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullary10d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional (column-major) ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ], + 'offset': 0, + 'order': 'column-major', + 'accessors': [ getter, setter ] + }; + + accessornullary10d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (blocked)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3 ], + 'strides': [ 6, 6, 6, 6, 6, 6, 6, 6, 3, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + blockednullary10d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (blocked accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary10d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 7222b50cee089bcf2c91f624a3a3a2eac1b191a0 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 15:22:21 +0500 Subject: [PATCH 29/54] test(ndarray/base/nullary): add tests for nullarynd --- .../ndarray/base/nullary/test/test.main.js | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 1ac457cc5696..74e39e6ffd5f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -38,6 +38,7 @@ var nullary7d = require( './../lib/7d.js' ); var nullary8d = require( './../lib/8d.js' ); var nullary9d = require( './../lib/9d.js' ); var nullary10d = require( './../lib/10d.js' ); +var nullarynd = require( './../lib/nd.js' ); var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); @@ -49,6 +50,7 @@ var accessornullary7d = require( './../lib/7d_accessors.js' ); var accessornullary8d = require( './../lib/8d_accessors.js' ); var accessornullary9d = require( './../lib/9d_accessors.js' ); var accessornullary10d = require( './../lib/10d_accessors.js' ); +var accessornullarynd = require( './../lib/nd_accessors.js' ); var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); @@ -1816,3 +1818,63 @@ tape( 'the function applies a nullary callback to each indexed element of a 10-d t.deepEqual( complexbuf, expected, 'deep equal' ); t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 11-dimensional ndarray', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 12 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ], + 'strides': [ 12, 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ], + 'offset': 1, + 'order': 'row-major' + }; + + nullarynd( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 11-dimensional ndarray (accessors)', function test( t ) { + var complexbuf; + var expected; + var xbuf; + var x; + + complexbuf = new Float32Array( 8 ); + + xbuf = new Complex64Array( complexbuf.buffer ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], + 'strides': [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + accessornullarynd( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); + + t.deepEqual( complexbuf, expected, 'deep equal' ); + t.end(); +}); From 456e9b062dcc33a129966627761580d30b93e897 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 17:03:21 +0500 Subject: [PATCH 30/54] test(ndarray/base/nullary): add some tests for edge-cases --- .../ndarray/base/nullary/test/test.main.js | 183 ++++++++++++++++++ 1 file changed, 183 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 74e39e6ffd5f..1e7dbcc6932b 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -343,6 +343,32 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked edge-case)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 64 ); + + x = { + 'dtype': 'generic', + 'data': xbuf, + 'shape': [ 8, 8 ], + 'strides': [ 8, 1 ], + 'offset': 0, + 'order': 'row-major' + }; + + blockednullary2d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( 64 ); + + expected.fill( 10.0 ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked accessors)', function test( t ) { var complexbuf; var expected; @@ -379,6 +405,41 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked accessors edge-case)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Complex64Array( 64 ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 8, 8 ], + 'strides': [ 8, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary2d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); + + expected = new Complex64Array( 64 ); + + expected.fill( new Complex64( 1.0, -1.0 ) ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (row-major) ndarray', function test( t ) { var expected; var xbuf; @@ -523,6 +584,32 @@ tape( 'the function applies a nullary callback to each indexed element of a 3-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked edge-case)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 512 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 8, 8, 8 ], + 'strides': [ 64, 8, 1 ], + 'offset': 0, + 'order': 'row-major' + }; + + blockednullary3d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( 512 ); + + expected.fill( 10.0 ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked accessors)', function test( t ) { var complexbuf; var expected; @@ -559,6 +646,41 @@ tape( 'the function applies a nullary callback to each indexed element of a 3-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked accessors)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Complex64Array( 512 ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 8, 8, 8 ], + 'strides': [ 64, 8, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary3d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); + + expected = new Complex64Array( 512 ); + + expected.fill( new Complex64( 1.0, 1.0 ) ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (row-major) ndarray', function test( t ) { var expected; var xbuf; @@ -703,6 +825,32 @@ tape( 'the function applies a nullary callback to each indexed element of a 4-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked edge-case)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float64Array( 4096 ); + + x = { + 'dtype': 'float64', + 'data': xbuf, + 'shape': [ 8, 8, 8, 8 ], + 'strides': [ 512, 64, 8, 1 ], + 'offset': 0, + 'order': 'row-major' + }; + + blockednullary4d( x, constantFunction( 10.0 ) ); + + expected = new Float64Array( 4096 ); + + expected.fill( 10.0 ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked accessors)', function test( t ) { var complexbuf; var expected; @@ -739,6 +887,41 @@ tape( 'the function applies a nullary callback to each indexed element of a 4-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked accessors edge-case)', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Complex64Array( 4096 ); + + function getter( buf, idx ) { + return buf.get( idx ); + } + + function setter( buf, idx, value ) { + buf.set( value, idx ); + } + + x = { + 'dtype': 'complex64', + 'data': xbuf, + 'shape': [ 8, 8, 8, 8 ], + 'strides': [ 512, 64, 8, 1 ], + 'offset': 0, + 'order': 'row-major', + 'accessors': [ getter, setter ] + }; + + blockedaccessornullary4d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); + + expected = new Complex64Array( 4096 ); + + expected.fill( new Complex64( 10.0, -10.0 ) ); + + t.deepEqual( xbuf, expected, 'deep equal' ); + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (row-major) ndarray', function test( t ) { var expected; var xbuf; From 3e9ad2b28509020342bd93f7ce3fc66e26f8654c Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 10 Jun 2024 17:08:12 +0500 Subject: [PATCH 31/54] chore(ndarray/base/nullary): remove fixme comment from test file --- lib/node_modules/@stdlib/ndarray/base/nullary/test/test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.js index dbf444497d0e..854cefca7c82 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.js @@ -31,5 +31,3 @@ tape( 'main export is a function', function test( t ) { t.strictEqual( typeof nullary, 'function', 'main export is a function' ); t.end(); }); - -// FIXME: add tests From 733e7066ad66768df9e22625378c2ce22624cdce Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 8 Jul 2024 02:21:12 -0700 Subject: [PATCH 32/54] test: move 0d tests to separate file --- .../ndarray/base/nullary/test/test.0d.js | 72 +++++++++++++++++++ .../ndarray/base/nullary/test/test.main.js | 62 ---------------- 2 files changed, 72 insertions(+), 62 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js new file mode 100644 index 000000000000..9decfc9dede0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 constantFunction = require( '@stdlib/utils/constant-function' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 0-dimensional ndarray', function test( t ) { + var expected; + var x; + + x = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array( [ 10.0 ] ); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 0-dimensional ndarray (accessors)', function test( t ) { + var expected; + var x; + + x = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' + }); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( [ 10.0, 10.0 ] ); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 1e7dbcc6932b..66acf141711d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -27,7 +27,6 @@ var Float32Array = require( '@stdlib/array/float32' ); var Complex64Array = require( '@stdlib/array/complex64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var nullary = require( './../lib/main.js' ); -var nullary0d = require( './../lib/0d.js' ); var nullary1d = require( './../lib/1d.js' ); var nullary2d = require( './../lib/2d.js' ); var nullary3d = require( './../lib/3d.js' ); @@ -39,7 +38,6 @@ var nullary8d = require( './../lib/8d.js' ); var nullary9d = require( './../lib/9d.js' ); var nullary10d = require( './../lib/10d.js' ); var nullarynd = require( './../lib/nd.js' ); -var accessornullary0d = require( './../lib/0d_accessors.js' ); var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); var accessornullary3d = require( './../lib/3d_accessors.js' ); @@ -79,66 +77,6 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 0-dimensional ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 1 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major' - }; - - nullary0d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 10.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 0-dimensional ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( [ 1.0, 1.0 ] ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [], - 'strides': [ 0 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullary0d( x, constantFunction( new Complex64( 10.0, 10.0 ) ) ); - - expected = new Float32Array( [ 10.0, 10.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray', function test( t ) { var expected; var xbuf; From 4f85adb57c0d34c05e7f8694371cf8d108be0071 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 8 Jul 2024 02:30:54 -0700 Subject: [PATCH 33/54] test: move 1d tests to separate file --- .../ndarray/base/nullary/test/test.0d.js | 2 +- .../ndarray/base/nullary/test/test.1d.js | 91 +++++++++++++++++++ .../ndarray/base/nullary/test/test.main.js | 62 ------------- 3 files changed, 92 insertions(+), 63 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.1d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js index 9decfc9dede0..1e9a9701a5b9 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.0d.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2024 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. diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.1d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.1d.js new file mode 100644 index 000000000000..9755bce59af0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.1d.js @@ -0,0 +1,91 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray', function test( t ) { + var expected; + var x; + + x = ndarray( 'float64', zeros( 8, 'float64' ), [ 4 ], [ 2 ], 1, 'row-major' ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray (accessors)', function test( t ) { + var expected; + var x; + + x = ndarray( 'complex128', zeros( 6, 'complex128' ), [ 4 ], [ 1 ], 1, 'row-major' ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index 66acf141711d..ee677dcc6075 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -27,7 +27,6 @@ var Float32Array = require( '@stdlib/array/float32' ); var Complex64Array = require( '@stdlib/array/complex64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var nullary = require( './../lib/main.js' ); -var nullary1d = require( './../lib/1d.js' ); var nullary2d = require( './../lib/2d.js' ); var nullary3d = require( './../lib/3d.js' ); var nullary4d = require( './../lib/4d.js' ); @@ -38,7 +37,6 @@ var nullary8d = require( './../lib/8d.js' ); var nullary9d = require( './../lib/9d.js' ); var nullary10d = require( './../lib/10d.js' ); var nullarynd = require( './../lib/nd.js' ); -var accessornullary1d = require( './../lib/1d_accessors.js' ); var accessornullary2d = require( './../lib/2d_accessors.js' ); var accessornullary3d = require( './../lib/3d_accessors.js' ); var accessornullary4d = require( './../lib/4d_accessors.js' ); @@ -77,66 +75,6 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 8 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 4 ], - 'strides': [ 2 ], - 'offset': 1, - 'order': 'row-major' - }; - - nullary1d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 0.0, 10.0, 0.0, 10.0, 0.0, 10.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0 ] ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 2 ], - 'strides': [ 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter] - }; - - accessornullary1d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, -5.0, 6.0, -7.0, 8.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (row-major) ndarray', function test( t ) { var expected; var xbuf; From 1f4ef1e1f23d9ac6cd66192e87b22a30815cf309 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 8 Jul 2024 03:08:25 -0700 Subject: [PATCH 34/54] test: move 2d tests to separate file --- .../ndarray/base/nullary/test/test.2d.js | 604 ++++++++++++++++++ .../ndarray/base/nullary/test/test.main.js | 245 ------- 2 files changed, 604 insertions(+), 245 deletions(-) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js new file mode 100644 index 000000000000..2c78c90158e4 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js @@ -0,0 +1,604 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function'); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ 4, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 4, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ 1, -4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js index ee677dcc6075..60972159f07c 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js @@ -27,7 +27,6 @@ var Float32Array = require( '@stdlib/array/float32' ); var Complex64Array = require( '@stdlib/array/complex64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var nullary = require( './../lib/main.js' ); -var nullary2d = require( './../lib/2d.js' ); var nullary3d = require( './../lib/3d.js' ); var nullary4d = require( './../lib/4d.js' ); var nullary5d = require( './../lib/5d.js' ); @@ -37,7 +36,6 @@ var nullary8d = require( './../lib/8d.js' ); var nullary9d = require( './../lib/9d.js' ); var nullary10d = require( './../lib/10d.js' ); var nullarynd = require( './../lib/nd.js' ); -var accessornullary2d = require( './../lib/2d_accessors.js' ); var accessornullary3d = require( './../lib/3d_accessors.js' ); var accessornullary4d = require( './../lib/4d_accessors.js' ); var accessornullary5d = require( './../lib/5d_accessors.js' ); @@ -47,7 +45,6 @@ var accessornullary8d = require( './../lib/8d_accessors.js' ); var accessornullary9d = require( './../lib/9d_accessors.js' ); var accessornullary10d = require( './../lib/10d_accessors.js' ); var accessornullarynd = require( './../lib/nd_accessors.js' ); -var blockednullary2d = require( './../lib/2d_blocked.js' ); var blockednullary3d = require( './../lib/3d_blocked.js' ); var blockednullary4d = require( './../lib/4d_blocked.js' ); var blockednullary5d = require( './../lib/5d_blocked.js' ); @@ -56,7 +53,6 @@ var blockednullary7d = require( './../lib/7d_blocked.js' ); var blockednullary8d = require( './../lib/8d_blocked.js' ); var blockednullary9d = require( './../lib/9d_blocked.js' ); var blockednullary10d = require( './../lib/10d_blocked.js' ); -var blockedaccessornullary2d = require( './../lib/2d_blocked_accessors.js' ); var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); @@ -75,247 +71,6 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (row-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 8 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 2, 2 ], - 'strides': [ 4, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - nullary2d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (column-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 8 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 2, 2 ], - 'strides': [ 1, 4 ], - 'offset': 1, - 'order': 'column-major' - }; - - nullary2d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (row-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0 ] ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 2, 2 ], - 'strides': [ 4, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullary2d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, -5.0, 6.0, -7.0, 8.0, 1.0, 1.0, 1.0, 1.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional (column-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0 ] ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 2, 2 ], - 'strides': [ 1, 4 ], - 'offset': 0, - 'order': 'column-major', - 'accessors': [ getter, setter ] - }; - - accessornullary2d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, -5.0, 6.0, -7.0, 8.0, 1.0, 1.0, 1.0, 1.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 8 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 2, 2 ], - 'strides': [ 4, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - blockednullary2d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked edge-case)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 64 ); - - x = { - 'dtype': 'generic', - 'data': xbuf, - 'shape': [ 8, 8 ], - 'strides': [ 8, 1 ], - 'offset': 0, - 'order': 'row-major' - }; - - blockednullary2d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( 64 ); - - expected.fill( 10.0 ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0 ] ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary2d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -9.0, 10.0, -11.0, 12.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (blocked accessors edge-case)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Complex64Array( 64 ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 8, 8 ], - 'strides': [ 8, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary2d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Complex64Array( 64 ); - - expected.fill( new Complex64( 1.0, -1.0 ) ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (row-major) ndarray', function test( t ) { var expected; var xbuf; From 4b4c130dcdd8c2f0eb2b2dea7fba69fe4e1c3cd0 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 11 Jul 2024 12:14:12 +0500 Subject: [PATCH 35/54] test: add 3d tests to a separate file --- .../ndarray/base/nullary/test/test.3d.js | 580 ++++++++++++++++++ 1 file changed, 580 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.3d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.3d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.3d.js new file mode 100644 index 000000000000..224ccb4711b7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.3d.js @@ -0,0 +1,580 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ 3, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 6, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + 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 applies a nullary callback to each indexed element of a 3-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ -3, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 6, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + 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 applies a nullary callback to each indexed element of a 3-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, -10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ 3, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 6, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2 ]; + st = [ -3, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 6, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ 1, 2, 3 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 6, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + 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 applies a nullary callback to each indexed element of a 3-dimensional ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ -1, -2, 3 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 6, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + 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 applies a nullary callback to each indexed element of a 3-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, -10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ 1, 2, 3 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 6, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2 ]; + st = [ -1, -2, 3 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 6, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); From c6e1d98d9e66c561de44bfa5a198156d6cfb9cfe Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 11 Jul 2024 12:17:37 +0500 Subject: [PATCH 36/54] test: add 4d tests to a separate file --- .../ndarray/base/nullary/test/test.4d.js | 604 ++++++++++++++++++ 1 file changed, 604 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.4d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.4d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.4d.js new file mode 100644 index 000000000000..1efe0eb18e1b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.4d.js @@ -0,0 +1,604 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, 2, 1, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, -2, -1, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, -10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, 2, 1, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 4, -2, -1, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, -10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 1, 2, 4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 1, -2, -4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 1, 2, 4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1 ]; + st = [ 1, 2, -4, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); From a49bce51909f4e947beeac3d16a2bdaf99e5f13a Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 11 Jul 2024 12:19:20 +0500 Subject: [PATCH 37/54] test: add 5d tests to separate file --- .../ndarray/base/nullary/test/test.5d.js | 676 ++++++++++++++++++ 1 file changed, 676 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.5d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.5d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.5d.js new file mode 100644 index 000000000000..4bafca3b2daf --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.5d.js @@ -0,0 +1,676 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 4, 2, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 4, -2, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, -10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 4, 2, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 8, 4, -2, -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 4 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, -10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 1, 2, 2, 4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 1, 2, -2, -4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 1, 2, 2, 4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 1, 2, 1, 2 ]; + st = [ 1, 2, -2, -4, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); From 31b7f2c7ab7d26d22491d0137afedace31ac2263 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 11 Jul 2024 12:21:53 +0500 Subject: [PATCH 38/54] test: add 6d tests to a separate file --- .../ndarray/base/nullary/test/test.6d.js | 652 ++++++++++++++++++ 1 file changed, 652 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.6d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.6d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.6d.js new file mode 100644 index 000000000000..813e3512e66c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.6d.js @@ -0,0 +1,652 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 8, 4, 1, 1, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 0.0, + 10.0, + 10.0, + 10.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, -8, 4, -1, 1, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 0.0, + 10.0, + 10.0, + 10.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, -10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 8, 4, 1, 1, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 8, 4, -1, -1, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 2, 4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 1, -1, 1, -2, 4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, -10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 2, 4, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, -2, -4, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 12, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); From 246927ab51d3bcb95b3c50a967632a96fefd52ec Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 11 Jul 2024 12:24:08 +0500 Subject: [PATCH 39/54] test: add 7d tests to a separate file --- .../ndarray/base/nullary/test/test.7d.js | 724 ++++++++++++++++++ 1 file changed, 724 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.7d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.7d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.7d.js new file mode 100644 index 000000000000..93b6c8d14045 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.7d.js @@ -0,0 +1,724 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -16, 16, -16, 8, -4, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, -10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -16, 16, -16, -8, 4, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 2, 4, 6, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, -1, 2, -4, 6, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0, + 10.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, -10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0, + 10.0, + -10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 2, 4, 6, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -1, 1, -1, -2, 4, -6, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); From 124d0c28a7bd2c35a116ca17b6838ecf48bc8190 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 11 Jul 2024 12:30:07 +0500 Subject: [PATCH 40/54] test: add 8d tests to a separate file --- .../ndarray/base/nullary/test/test.8d.js | 724 ++++++++++++++++++ 1 file changed, 724 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.8d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.8d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.8d.js new file mode 100644 index 000000000000..e1620dc87974 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.8d.js @@ -0,0 +1,724 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, -16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape('the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 4, 6, 8 ]; + o = strides2offset(sh, st); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array( [ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape('the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, -1, -4, 6, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array( [ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (column-major, non-contiguous, same sign strides , accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 4, 6, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( [ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (column-major, non-contiguous, mixed sign strides , accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -1, 1, -1, 1, 1, -4, -6, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); From 4bdb31eb6409b01e4356469ee055209a1513de60 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 11 Jul 2024 12:34:19 +0500 Subject: [PATCH 41/54] test: add 9d tests to a separate file --- .../ndarray/base/nullary/test/test.9d.js | 724 ++++++++++++++++++ 1 file changed, 724 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.9d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.9d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.9d.js new file mode 100644 index 000000000000..4be374051105 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.9d.js @@ -0,0 +1,724 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( [ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ] ); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, -16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape('the function applies a nullary callback to each indexed element of an 9-dimensional ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 4, 6, 8 ]; + o = strides2offset(sh, st); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array( [ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape('the function applies a nullary callback to each indexed element of an 9-dimensional ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, -1, -4, 6, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array( [ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (column-major, non-contiguous, same sign strides , accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 4, 6, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( [ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (column-major, non-contiguous, mixed sign strides , accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, -1, 1, -1, 1, 1, -4, -6, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( [ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); From 7bf4ed970e300529c517d5ea44acfa93ae8d28d6 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 11 Jul 2024 12:40:04 +0500 Subject: [PATCH 42/54] test: add 10d tests to a separate file --- .../ndarray/base/nullary/test/test.10d.js | 724 ++++++++++++++++++ 1 file changed, 724 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.10d.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.10d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.10d.js new file mode 100644 index 000000000000..9ab2dc1357e3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.10d.js @@ -0,0 +1,724 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( [ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ] ); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, -16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape('the function applies a nullary callback to each indexed element of an 10-dimensional ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 4, 6, 8 ]; + o = strides2offset(sh, st); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array( [ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape('the function applies a nullary callback to each indexed element of an 10-dimensional ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, -1, -4, 6, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array( [ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (column-major, non-contiguous, same sign strides , accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 4, 6, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( [ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (column-major, non-contiguous, mixed sign strides , accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, -1, 1, -1, 1, 1, -4, -6, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( [ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); From 61a567c203afecc1d51bae69f437d302d1e24237 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 11 Jul 2024 12:42:30 +0500 Subject: [PATCH 43/54] test: add nd tests to a separate file --- .../ndarray/base/nullary/test/test.nd.js | 724 ++++++++++++++++++ 1 file changed, 724 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js new file mode 100644 index 000000000000..c3d7a42aa9f5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js @@ -0,0 +1,724 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 zeros = require( '@stdlib/array/zeros' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var nullary = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nullary, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( [ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ] ); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, 16, 16, 8, 4, 2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 16, 16, 16, 16, 16, 16, -16, 16, -8, -4, -2, 1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, contiguous)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape('the function applies a nullary callback to each indexed element of an n-dimensional ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 6, 8 ]; + o = strides2offset(sh, st); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape('the function applies a nullary callback to each indexed element of an n-dimensional ndarray (column-major, non-contiguous, mixed sign strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 1, -1, -4, 6, -8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0, + 10.0, + 10.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = shape2strides( sh, ord ); + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, non-contiguous, same sign strides , accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 6, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, non-contiguous, mixed sign strides , accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ 1, 1, 1, 1, -1, 1, -1, 1, 1, -4, -6, 8 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, + 10.0, + 10.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); From 4eceec7d66f6235237d04e0362f7c73cb25426b0 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 11 Jul 2024 13:22:59 +0500 Subject: [PATCH 44/54] chore: delete redundant test.main.js file --- .../ndarray/base/nullary/test/test.main.js | 1694 ----------------- 1 file changed, 1694 deletions(-) delete mode 100644 lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js deleted file mode 100644 index 60972159f07c..000000000000 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.main.js +++ /dev/null @@ -1,1694 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 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 constantFunction = require( '@stdlib/utils/constant-function'); -var Float64Array = require( '@stdlib/array/float64' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64Array = require( '@stdlib/array/complex64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var nullary = require( './../lib/main.js' ); -var nullary3d = require( './../lib/3d.js' ); -var nullary4d = require( './../lib/4d.js' ); -var nullary5d = require( './../lib/5d.js' ); -var nullary6d = require( './../lib/6d.js' ); -var nullary7d = require( './../lib/7d.js' ); -var nullary8d = require( './../lib/8d.js' ); -var nullary9d = require( './../lib/9d.js' ); -var nullary10d = require( './../lib/10d.js' ); -var nullarynd = require( './../lib/nd.js' ); -var accessornullary3d = require( './../lib/3d_accessors.js' ); -var accessornullary4d = require( './../lib/4d_accessors.js' ); -var accessornullary5d = require( './../lib/5d_accessors.js' ); -var accessornullary6d = require( './../lib/6d_accessors.js' ); -var accessornullary7d = require( './../lib/7d_accessors.js' ); -var accessornullary8d = require( './../lib/8d_accessors.js' ); -var accessornullary9d = require( './../lib/9d_accessors.js' ); -var accessornullary10d = require( './../lib/10d_accessors.js' ); -var accessornullarynd = require( './../lib/nd_accessors.js' ); -var blockednullary3d = require( './../lib/3d_blocked.js' ); -var blockednullary4d = require( './../lib/4d_blocked.js' ); -var blockednullary5d = require( './../lib/5d_blocked.js' ); -var blockednullary6d = require( './../lib/6d_blocked.js' ); -var blockednullary7d = require( './../lib/7d_blocked.js' ); -var blockednullary8d = require( './../lib/8d_blocked.js' ); -var blockednullary9d = require( './../lib/9d_blocked.js' ); -var blockednullary10d = require( './../lib/10d_blocked.js' ); -var blockedaccessornullary3d = require( './../lib/3d_blocked_accessors.js' ); -var blockedaccessornullary4d = require( './../lib/4d_blocked_accessors.js' ); -var blockedaccessornullary5d = require( './../lib/5d_blocked_accessors.js' ); -var blockedaccessornullary6d = require( './../lib/6d_blocked_accessors.js' ); -var blockedaccessornullary7d = require( './../lib/7d_blocked_accessors.js' ); -var blockedaccessornullary8d = require( './../lib/8d_blocked_accessors.js' ); -var blockedaccessornullary9d = require( './../lib/9d_blocked_accessors.js' ); -var blockedaccessornullary10d = require( './../lib/10d_blocked_accessors.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nullary, 'function', 'main export is a function'); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (row-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 3, 1, 2 ], - 'strides': [ 4, 4, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - nullary3d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (column-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 3, 1, 2 ], - 'strides': [ 1, 3, 3 ], - 'offset': 1, - 'order': 'column-major' - }; - - nullary3d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (row-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 2, 2 ], - 'strides': [ 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullary3d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional (column-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 2, 2 ], - 'strides': [ 1, 1, 2 ], - 'offset': 0, - 'order': 'column-major', - 'accessors': [ getter, setter ] - }; - - accessornullary3d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 3, 1, 2 ], - 'strides': [ 2, 2, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - blockednullary3d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked edge-case)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 512 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 8, 8, 8 ], - 'strides': [ 64, 8, 1 ], - 'offset': 0, - 'order': 'row-major' - }; - - blockednullary3d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( 512 ); - - expected.fill( 10.0 ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 2, 2 ], - 'strides': [ 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary3d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 3-dimensional ndarray (blocked accessors)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Complex64Array( 512 ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 8, 8, 8 ], - 'strides': [ 64, 8, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary3d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Complex64Array( 512 ); - - expected.fill( new Complex64( 1.0, 1.0 ) ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (row-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 3, 1, 2 ], - 'strides': [ 12, 4, 4, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - nullary4d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (column-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 3, 1, 2 ], - 'strides': [ 1, 1, 3, 3 ], - 'offset': 1, - 'order': 'column-major' - }; - - nullary4d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (row-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 2, 2 ], - 'strides': [ 2, 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullary4d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional (column-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 2, 2 ], - 'strides': [ 1, 1, 1, 2 ], - 'offset': 0, - 'order': 'column-major', - 'accessors': [ getter, setter ] - }; - - accessornullary4d( x, constantFunction( new Complex64( 1.0, 1.0 ) ) ); - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 3, 1, 2 ], - 'strides': [ 12, 4, 4, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - blockednullary4d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked edge-case)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 4096 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 8, 8, 8, 8 ], - 'strides': [ 512, 64, 8, 1 ], - 'offset': 0, - 'order': 'row-major' - }; - - blockednullary4d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( 4096 ); - - expected.fill( 10.0 ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 2, 2 ], - 'strides': [ 2, 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary4d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); - - expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 4-dimensional ndarray (blocked accessors edge-case)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Complex64Array( 4096 ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 8, 8, 8, 8 ], - 'strides': [ 512, 64, 8, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary4d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); - - expected = new Complex64Array( 4096 ); - - expected.fill( new Complex64( 10.0, -10.0 ) ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (row-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 3, 1, 2 ], - 'strides': [ 12, 12, 4, 4, 1 ], - 'offset': 0, - 'order': 'row-major' - }; - - nullary5d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (column-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 3, 1, 2 ], - 'strides': [ 1, 1, 1, 3, 3 ], - 'offset': 0, - 'order': 'column-major' - }; - - nullary5d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (row-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 2, 2 ], - 'strides': [ 4, 4, 4, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullary5d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional (column-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 2, 2 ], - 'strides': [ 1, 1, 1, 1, 2 ], - 'offset': 0, - 'order': 'column-major', - 'accessors': [ getter, setter ] - }; - - accessornullary5d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (blocked)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 2, 3 ], - 'strides': [ 6, 6, 6, 3, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - blockednullary5d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 5-dimensional ndarray (blocked accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 12 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 2, 1, 1, 1, 1 ], - 'strides': [ 1, 1, 1, 1, 1 ], - 'offset': 1, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary5d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); - - expected = new Float32Array( [ 0.0, 0.0, 10.0, -10.0, 10.0, -10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional (row-major) ndarray ', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 3, 1, 2 ], - 'strides': [ 12, 12, 12, 4, 4, 1 ], - 'offset': 0, - 'order': 'row-major' - }; - - nullary6d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional (column-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 3, 1, 2 ], - 'strides': [ 1, 1, 1, 1, 3, 3 ], - 'offset': 0, - 'order': 'column-major' - }; - - nullary6d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional (row-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 2, 2 ], - 'strides': [ 2, 2, 2, 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullary6d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional (column-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 2, 2 ], - 'strides': [ 1, 1, 1, 1, 1, 2 ], - 'offset': 0, - 'order': 'column-major', - 'accessors': [ getter, setter ] - }; - - accessornullary6d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (blocked)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 2, 3 ], - 'strides': [ 6, 6, 6, 6, 3, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - blockednullary6d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 6-dimensional ndarray (blocked accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 2, 2 ], - 'strides': [ 2, 2, 2, 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary6d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); - - expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional (row-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 3, 1, 2 ], - 'strides': [ 12, 12, 12, 12, 4, 4, 1 ], - 'offset': 0, - 'order': 'row-major' - }; - - nullary7d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional (column-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 3, 1, 2 ], - 'strides': [ 1, 1, 1, 1, 1, 3, 3 ], - 'offset': 0, - 'order': 'column-major' - }; - - nullary7d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional (row-major) ndarray element (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 2, 2, 2, 2, 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullary7d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional (column-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 1, 1, 1, 1, 1, 1, 2 ], - 'offset': 0, - 'order': 'column-major', - 'accessors': [ getter, setter ] - }; - - accessornullary7d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (blocked)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 2, 3 ], - 'strides': [ 6, 6, 6, 6, 6, 3, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - blockednullary7d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 7-dimensional ndarray (blocked accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 2, 2, 2, 2, 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary7d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); - - expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional (row-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 3, 1, 2 ], - 'strides': [ 12, 12, 12, 12, 12, 4, 4, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - nullary8d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional (column-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 3, 1, 2 ], - 'strides': [ 1, 1, 1, 1, 1, 1, 3, 3 ], - 'offset': 1, - 'order': 'column-major' - }; - - nullary8d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional (row-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 2, 2, 2, 2, 2, 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullary8d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional (column-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 1, 1, 1, 1, 1, 1, 1, 2 ], - 'offset': 0, - 'order': 'column-major', - 'accessors': [ getter, setter ] - }; - - accessornullary8d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (blocked)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 2, 3 ], - 'strides': [ 6, 6, 6, 6, 6, 6, 3, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - blockednullary8d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (blocked accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 2, 2, 2, 2, 2, 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary8d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); - - expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional (row-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 3, 1, 2 ], - 'strides': [ 12, 12, 12, 12, 12, 12, 4, 4, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - nullary9d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional (column-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 3, 1, 2 ], - 'strides': [ 1, 1, 1, 1, 1, 1, 1, 3, 3 ], - 'offset': 1, - 'order': 'column-major' - }; - - nullary9d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional (row-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullary9d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional (column-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 1, 1, 1, 1, 1, 1, 1, 1, 2 ], - 'offset': 0, - 'order': 'column-major', - 'accessors': [ getter, setter ] - }; - - accessornullary9d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (blocked)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 1, 2, 3 ], - 'strides': [ 6, 6, 6, 6, 6, 6, 6, 3, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - blockednullary9d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (blocked accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 2, 2, 2, 2, 2, 2, 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary9d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); - - expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional (row-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ], - 'strides': [ 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - nullary10d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional (column-major) ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ], - 'strides': [ 1, 1, 1, 1, 1, 1, 1, 1, 3, 3 ], - 'offset': 1, - 'order': 'column-major' - }; - - nullary10d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional (row-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 4, 4, 4, 4, 4, 4, 4, 4, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullary10d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional (column-major) ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ], - 'offset': 0, - 'order': 'column-major', - 'accessors': [ getter, setter ] - }; - - accessornullary10d( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (blocked)', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3 ], - 'strides': [ 6, 6, 6, 6, 6, 6, 6, 6, 3, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - blockednullary10d( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (blocked accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - blockedaccessornullary10d( x, constantFunction( new Complex64( 10.0, -10.0 ) ) ); - - expected = new Float32Array( [ 10.0, -10.0, 10.0, -10.0, 10.0, -10.0, 10.0, -10.0 ] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 11-dimensional ndarray', function test( t ) { - var expected; - var xbuf; - var x; - - xbuf = new Float64Array( 12 ); - - x = { - 'dtype': 'float64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2 ], - 'strides': [ 12, 12, 12, 12, 12, 12, 12, 12, 4, 4, 1 ], - 'offset': 1, - 'order': 'row-major' - }; - - nullarynd( x, constantFunction( 10.0 ) ); - - expected = new Float64Array( [ 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 0.0 ] ); - - t.deepEqual( xbuf, expected, 'deep equal' ); - t.end(); -}); - -tape( 'the function applies a nullary callback to each indexed element of a 11-dimensional ndarray (accessors)', function test( t ) { - var complexbuf; - var expected; - var xbuf; - var x; - - complexbuf = new Float32Array( 8 ); - - xbuf = new Complex64Array( complexbuf.buffer ); - - function getter( buf, idx ) { - return buf.get( idx ); - } - - function setter( buf, idx, value ) { - buf.set( value, idx ); - } - - x = { - 'dtype': 'complex64', - 'data': xbuf, - 'shape': [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], - 'strides': [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ], - 'offset': 0, - 'order': 'row-major', - 'accessors': [ getter, setter ] - }; - - accessornullarynd( x, constantFunction( new Complex64( 1.0, -1.0 ) ) ); - - expected = new Float32Array( [ 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0] ); - - t.deepEqual( complexbuf, expected, 'deep equal' ); - t.end(); -}); From 214f6f346cb2f86e3ad57dfc8a0105d9fa97122b Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 13 Jul 2024 22:40:25 -0700 Subject: [PATCH 45/54] test: fix strides --- .../ndarray/base/nullary/test/test.6d.js | 64 ++++++++++++++++--- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.6d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.6d.js index 813e3512e66c..3238e38622cf 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.6d.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.6d.js @@ -153,21 +153,29 @@ tape( 'the function applies a nullary callback to each indexed element of a 6-di dt = 'float64'; ord = 'row-major'; sh = [ 1, 1, 2, 2, 1, 2 ]; - st = [ 16, 8, 4, 1, 1, 1 ]; + st = [ 16, 16, 8, 4, 4, 1 ]; o = strides2offset( sh, st ); - x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); nullary( [ x ], constantFunction( 10.0 ) ); expected = new Float64Array([ 10.0, 10.0, + 0.0, + 0.0, + 10.0, 10.0, 0.0, + 0.0, + 10.0, 10.0, + 0.0, + 0.0, 10.0, 10.0, + 0.0, 0.0 ]); t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); @@ -187,21 +195,29 @@ tape( 'the function applies a nullary callback to each indexed element of a 6-di dt = 'float64'; ord = 'row-major'; sh = [ 1, 1, 2, 2, 1, 2 ]; - st = [ 16, -8, 4, -1, 1, 1 ]; + st = [ 16, -16, 8, -4, 4, 1 ]; o = strides2offset( sh, st ); - x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); nullary( [ x ], constantFunction( 10.0 ) ); expected = new Float64Array([ 10.0, 10.0, + 0.0, + 0.0, + 10.0, 10.0, 0.0, + 0.0, 10.0, 10.0, + 0.0, + 0.0, + 10.0, 10.0, + 0.0, 0.0 ]); t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); @@ -263,10 +279,10 @@ tape( 'the function applies a nullary callback to each indexed element of a 6-di dt = 'complex128'; ord = 'row-major'; sh = [ 1, 1, 2, 2, 1, 2 ]; - st = [ 16, 8, 4, 1, 1, 1 ]; + st = [ 16, 16, 8, 4, 4, 1 ]; o = strides2offset( sh, st ); - x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); @@ -275,17 +291,33 @@ tape( 'the function applies a nullary callback to each indexed element of a 6-di 10.0, 10.0, 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, 10.0, 10.0, 0.0, 0.0, + 0.0, + 0.0, 10.0, 10.0, 10.0, 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, 10.0, 10.0, 0.0, + 0.0, + 0.0, 0.0 ]); t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); @@ -305,10 +337,10 @@ tape( 'the function applies a nullary callback to each indexed element of a 6-di dt = 'complex128'; ord = 'row-major'; sh = [ 1, 1, 2, 2, 1, 2 ]; - st = [ 16, 8, 4, -1, -1, -1 ]; + st = [ 16, 16, 8, -4, -4, -1 ]; o = strides2offset( sh, st ); - x = ndarray( dt, zeros( 8, dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); @@ -317,17 +349,33 @@ tape( 'the function applies a nullary callback to each indexed element of a 6-di 10.0, 10.0, 10.0, + 0.0, + 0.0, + 0.0, + 0.0, + 10.0, + 10.0, 10.0, 10.0, 0.0, 0.0, + 0.0, + 0.0, + 10.0, + 10.0, 10.0, 10.0, + 0.0, + 0.0, + 0.0, + 0.0, 10.0, 10.0, 10.0, 10.0, 0.0, + 0.0, + 0.0, 0.0 ]); t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); From 39da4b9d61cc337b1c482c6c582c7cdb7874654b Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 13 Jul 2024 22:44:27 -0700 Subject: [PATCH 46/54] test: fix strides --- .../@stdlib/ndarray/base/nullary/test/test.7d.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.7d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.7d.js index 93b6c8d14045..5f89606482a1 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.7d.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.7d.js @@ -493,7 +493,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 7-di dt = 'float64'; ord = 'column-major'; sh = [ 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 2, 4, 6, 8 ]; + st = [ 1, 1, 1, 2, 4, 8, 8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -535,7 +535,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 7-di dt = 'float64'; ord = 'column-major'; sh = [ 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, -1, 2, -4, 6, -8 ]; + st = [ 1, 1, -1, 2, -4, 8, -8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -619,7 +619,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 7-di dt = 'complex128'; ord = 'column-major'; sh = [ 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 2, 4, 6, 8 ]; + st = [ 1, 1, 1, 2, 4, 8, 8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -677,7 +677,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 7-di dt = 'complex128'; ord = 'column-major'; sh = [ 1, 1, 1, 2, 2, 1, 2 ]; - st = [ -1, 1, -1, -2, 4, -6, 8 ]; + st = [ -1, 1, -1, -2, 4, -8, 8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); From f7b0d08f828430628060dbccf86331dd16f705ed Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 13 Jul 2024 22:47:17 -0700 Subject: [PATCH 47/54] test: fix strides --- .../ndarray/base/nullary/test/test.8d.js | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.8d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.8d.js index e1620dc87974..0f51650441d4 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.8d.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.8d.js @@ -43,7 +43,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { var expected; var ord; var sh; @@ -73,7 +73,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { var expected; var ord; var sh; @@ -107,7 +107,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, contiguous)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (row-major, contiguous)', function test( t ) { var expected; var ord; var sh; @@ -141,7 +141,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { var expected; var ord; var sh; @@ -183,7 +183,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { var expected; var ord; var sh; @@ -225,7 +225,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { var expected; var ord; var sh; @@ -267,7 +267,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { var expected; var ord; var sh; @@ -325,7 +325,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { var expected; var ord; var sh; @@ -383,7 +383,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { var expected; var ord; var sh; @@ -413,7 +413,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { var expected; var ord; var sh; @@ -447,7 +447,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (column-major, contiguous)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (column-major, contiguous)', function test( t ) { var expected; var ord; var sh; @@ -493,7 +493,7 @@ tape('the function applies a nullary callback to each indexed element of an 8-di dt = 'float64'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, 4, 6, 8 ]; + st = [ 1, 1, 1, 1, 1, 4, 8, 8 ]; o = strides2offset(sh, st); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -535,7 +535,7 @@ tape('the function applies a nullary callback to each indexed element of an 8-di dt = 'float64'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, -1, -4, 6, -8 ]; + st = [ 1, 1, 1, 1, -1, -4, 8, -8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -565,7 +565,7 @@ tape('the function applies a nullary callback to each indexed element of an 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { var expected; var ord; var sh; @@ -607,7 +607,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (column-major, non-contiguous, same sign strides , accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { var expected; var ord; var sh; @@ -619,7 +619,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di dt = 'complex128'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, 4, 6, 8 ]; + st = [ 1, 1, 1, 1, 1, 4, 8, 8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -665,7 +665,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 8-dimensional ndarray (column-major, non-contiguous, mixed sign strides , accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { var expected; var ord; var sh; @@ -677,7 +677,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 8-di dt = 'complex128'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ -1, 1, -1, 1, 1, -4, -6, 8 ]; + st = [ -1, 1, -1, 1, 1, -4, -8, 8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); From 843fbfbac24c197e98f18c2cf7bad7426beede3e Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 13 Jul 2024 22:49:41 -0700 Subject: [PATCH 48/54] test: fix strides --- .../@stdlib/ndarray/base/nullary/test/test.9d.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.9d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.9d.js index 4be374051105..3abc38954bb2 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.9d.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.9d.js @@ -493,7 +493,7 @@ tape('the function applies a nullary callback to each indexed element of an 9-di dt = 'float64'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, 1, 4, 6, 8 ]; + st = [ 1, 1, 1, 1, 1, 1, 4, 8, 8 ]; o = strides2offset(sh, st); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -535,7 +535,7 @@ tape('the function applies a nullary callback to each indexed element of an 9-di dt = 'float64'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, -1, -4, 6, -8 ]; + st = [ 1, 1, 1, 1, 1, -1, -4, 8, -8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -607,7 +607,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 9-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (column-major, non-contiguous, same sign strides , accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { var expected; var ord; var sh; @@ -619,7 +619,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 9-di dt = 'complex128'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, 1, 4, 6, 8 ]; + st = [ 1, 1, 1, 1, 1, 1, 4, 8, 8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -665,7 +665,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 9-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (column-major, non-contiguous, mixed sign strides , accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of a 9-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { var expected; var ord; var sh; @@ -677,7 +677,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 9-di dt = 'complex128'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, -1, 1, -1, 1, 1, -4, -6, 8 ]; + st = [ 1, -1, 1, -1, 1, 1, -4, -8, 8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); From 7867326ede88680500c06c4ffa64e42d6ffadf87 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 13 Jul 2024 22:50:22 -0700 Subject: [PATCH 49/54] test: fix descriptions --- .../@stdlib/ndarray/base/nullary/test/test.10d.js | 4 ++-- lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.10d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.10d.js index 9ab2dc1357e3..17cef60c2d4f 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.10d.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.10d.js @@ -607,7 +607,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 10-d t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (column-major, non-contiguous, same sign strides , accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { var expected; var ord; var sh; @@ -665,7 +665,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 10-d t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (column-major, non-contiguous, mixed sign strides , accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of a 10-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { var expected; var ord; var sh; diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js index c3d7a42aa9f5..7e8d0ecb5595 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js @@ -607,7 +607,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, non-contiguous, same sign strides , accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { var expected; var ord; var sh; @@ -665,7 +665,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, non-contiguous, mixed sign strides , accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { var expected; var ord; var sh; From 6358e00bbaa27d2d173aa004e2b0c8d4d8f6b025 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 13 Jul 2024 22:53:11 -0700 Subject: [PATCH 50/54] test: fix strides --- .../@stdlib/ndarray/base/nullary/test/test.10d.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.10d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.10d.js index 17cef60c2d4f..3ddf32440509 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.10d.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.10d.js @@ -493,7 +493,7 @@ tape('the function applies a nullary callback to each indexed element of an 10-d dt = 'float64'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, 1, 1, 4, 6, 8 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 4, 8, 8 ]; o = strides2offset(sh, st); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -535,7 +535,7 @@ tape('the function applies a nullary callback to each indexed element of an 10-d dt = 'float64'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, 1, -1, -4, 6, -8 ]; + st = [ 1, 1, 1, 1, 1, 1, -1, -4, 8, -8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -619,7 +619,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 10-d dt = 'complex128'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, 1, 1, 4, 6, 8 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 4, 8, 8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -677,7 +677,7 @@ tape( 'the function applies a nullary callback to each indexed element of a 10-d dt = 'complex128'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, -1, 1, -1, 1, 1, -4, -6, 8 ]; + st = [ 1, 1, -1, 1, -1, 1, 1, -4, -8, 8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); From 5b958e2c68f0eeda6262e8f53c89356ae181c763 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 13 Jul 2024 22:54:53 -0700 Subject: [PATCH 51/54] test: fix strides --- .../ndarray/base/nullary/test/test.nd.js | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js index 7e8d0ecb5595..19d92cc925cb 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.nd.js @@ -43,7 +43,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (row-major, singleton dimensions)', function test( t ) { var expected; var ord; var sh; @@ -73,7 +73,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (row-major, singleton dimensions, accessors)', function test( t ) { var expected; var ord; var sh; @@ -107,7 +107,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, contiguous)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (row-major, contiguous)', function test( t ) { var expected; var ord; var sh; @@ -141,7 +141,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { var expected; var ord; var sh; @@ -183,7 +183,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (row-major, non-contiguous, mixed sign strides)', function test( t ) { var expected; var ord; var sh; @@ -225,7 +225,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { var expected; var ord; var sh; @@ -267,7 +267,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { var expected; var ord; var sh; @@ -325,7 +325,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (row-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { var expected; var ord; var sh; @@ -383,7 +383,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { var expected; var ord; var sh; @@ -413,7 +413,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (column-major, singleton dimensions, accessors)', function test( t ) { var expected; var ord; var sh; @@ -447,7 +447,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, contiguous)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (column-major, contiguous)', function test( t ) { var expected; var ord; var sh; @@ -493,7 +493,7 @@ tape('the function applies a nullary callback to each indexed element of an n-di dt = 'float64'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 6, 8 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 8, 8 ]; o = strides2offset(sh, st); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -535,7 +535,7 @@ tape('the function applies a nullary callback to each indexed element of an n-di dt = 'float64'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, 1, 1, 1, -1, -4, 6, -8 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 1, -1, -4, 8, -8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -565,7 +565,7 @@ tape('the function applies a nullary callback to each indexed element of an n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { var expected; var ord; var sh; @@ -607,7 +607,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { var expected; var ord; var sh; @@ -619,7 +619,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di dt = 'complex128'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 6, 8 ]; + st = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 8, 8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -665,7 +665,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of a n-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { +tape( 'the function applies a nullary callback to each indexed element of an n-dimensional ndarray (column-major, non-contiguous, mixed sign strides, accessors)', function test( t ) { var expected; var ord; var sh; @@ -677,7 +677,7 @@ tape( 'the function applies a nullary callback to each indexed element of a n-di dt = 'complex128'; ord = 'column-major'; sh = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, -1, 1, -1, 1, 1, -4, -6, 8 ]; + st = [ 1, 1, 1, 1, -1, 1, -1, 1, 1, -4, -8, 8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); From 6233c52fc342834cde3912e44d1beacd4ab8bd77 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 13 Jul 2024 23:04:18 -0700 Subject: [PATCH 52/54] test: add tests to increase coverage --- .../ndarray/base/nullary/test/test.1d.js | 23 +++ .../ndarray/base/nullary/test/test.2d.js | 166 ++++++++++++++++++ 2 files changed, 189 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.1d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.1d.js index 9755bce59af0..340538dea5ea 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.1d.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.1d.js @@ -63,6 +63,29 @@ tape( 'the function applies a nullary callback to each indexed element of a 1-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 1-dimensional ndarray (empty array)', function test( t ) { + var expected; + var x; + + x = ndarray( 'float64', zeros( 8, 'float64' ), [ 0 ], [ 1 ], 0, 'row-major' ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 0.0, + 0.0, + 0.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 applies a nullary callback to each indexed element of a 1-dimensional ndarray (accessors)', function test( t ) { var expected; var x; diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js index 2c78c90158e4..607445a05c7e 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js @@ -107,6 +107,25 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, empty)', function test( t ) { + var expected; + var x; + + x = ndarray( 'float64', zeros( 4, 'float64' ), [ 0, 0 ], [ 1, 1 ], 0, 'row-major' ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, contiguous)', function test( t ) { var expected; var ord; @@ -137,6 +156,36 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, contiguous, negative strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, same sign strides)', function test( t ) { var expected; var ord; @@ -239,6 +288,40 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + sh = [ 2, 2 ]; + st = [ -2, -1 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, same sign strides, accessors)', function test( t ) { var expected; var ord; @@ -387,6 +470,25 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, empty)', function test( t ) { + var expected; + var x; + + x = ndarray( 'float64', zeros( 4, 'float64' ), [ 0, 0 ], [ 1, 1 ], 0, 'column-major' ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 0.0, + 0.0, + 0.0, + 0.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, contiguous)', function test( t ) { var expected; var ord; @@ -417,6 +519,36 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, contiguous, negative strides)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -1, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array([ + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, same sign strides)', function test( t ) { var expected; var ord; @@ -519,6 +651,40 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, contiguous, negative strides, accessors)', function test( t ) { + var expected; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + sh = [ 2, 2 ]; + st = [ -1, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array([ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ]); + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, same sign strides, accessors)', function test( t ) { var expected; var ord; From 52f49258ce4d1307c6f580ccf391b94e3cece871 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 13 Jul 2024 23:28:03 -0700 Subject: [PATCH 53/54] test: add non-contiguous tests for large arrays --- .../ndarray/base/nullary/test/test.2d.js | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js index 607445a05c7e..c218e223fb7a 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js @@ -32,6 +32,8 @@ var ndarray = require( '@stdlib/ndarray/ctor' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); var numel = require( '@stdlib/ndarray/base/numel' ); +var dfill = require( '@stdlib/blas/ext/base/dfill' ); +var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); var nullary = require( './../lib' ); @@ -254,6 +256,66 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array( x.length*2 ); + dfill( x.length, 10.0, expected, st[ 1 ] ); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ bsize*4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array( x.length*2 ); + dfill( x.length, 10.0, expected, st[ 1 ] ); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, contiguous, accessors)', function test( t ) { var expected; var ord; @@ -617,6 +679,66 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ 2, -bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array( x.length*2 ); + dfill( x.length, 10.0, expected, st[ 0 ] ); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, large arrays)', function test( t ) { + var expected; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'float64'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ -2, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( 10.0 ) ); + + expected = new Float64Array( x.length*2 ); + dfill( x.length, 10.0, expected, st[ 0 ] ); + + t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, contiguous, accessors)', function test( t ) { var expected; var ord; From 5518f054e75476d9b8611d06db7d7f69a3ecb5ec Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 13 Jul 2024 23:33:37 -0700 Subject: [PATCH 54/54] test: add blocked accessor tests --- .../ndarray/base/nullary/test/test.2d.js | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js index c218e223fb7a..16fcde9f669d 100644 --- a/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js +++ b/lib/node_modules/@stdlib/ndarray/base/nullary/test/test.2d.js @@ -33,6 +33,7 @@ var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); var strides2offset = require( '@stdlib/ndarray/base/strides2offset' ); var numel = require( '@stdlib/ndarray/base/numel' ); var dfill = require( '@stdlib/blas/ext/base/dfill' ); +var gfill = require( '@stdlib/blas/ext/base/gfill' ); var blockSize = require( '@stdlib/ndarray/base/nullary-tiling-block-size' ); var nullary = require( './../lib' ); @@ -468,6 +469,66 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ -4, 2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( x.length*2 ); + gfill( x.length, new Complex128( 10.0, 10.0 ), expected, st[ 1 ] ); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (row-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'row-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ bsize*4, -2 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( x.length*2 ); + gfill( x.length, new Complex128( 10.0, 10.0 ), expected, st[ 1 ] ); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, singleton dimensions)', function test( t ) { var expected; var ord; @@ -890,3 +951,63 @@ tape( 'the function applies a nullary callback to each indexed element of a 2-di t.end(); }); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ bsize*2, 2 ]; + st = [ 2, -bsize*4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( x.length*2 ); + gfill( x.length, new Complex128( 10.0, 10.0 ), expected, st[ 0 ] ); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function applies a nullary callback to each indexed element of a 2-dimensional ndarray (column-major, non-contiguous, large arrays, accessors)', function test( t ) { + var expected; + var bsize; + var ord; + var sh; + var st; + var dt; + var o; + var x; + + dt = 'complex128'; + ord = 'column-major'; + + bsize = blockSize( dt ); + sh = [ 2, bsize*2 ]; + st = [ -2, 4 ]; + o = strides2offset( sh, st ); + + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); + + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); + + expected = new Complex128Array( x.length*2 ); + gfill( x.length, new Complex128( 10.0, 10.0 ), expected, st[ 0 ] ); + + t.strictEqual( isSameComplex128Array( x.data, expected ), true, 'returns expected value' ); + + t.end(); +});