diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml index f92a6c5c..f4575e92 100644 --- a/.github/workflows/productionize.yml +++ b/.github/workflows/productionize.yml @@ -94,8 +94,8 @@ jobs: node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" fi - # Configure git: - - name: 'Configure git' + # Configure Git: + - name: 'Configure Git' run: | git config --local user.email "noreply@stdlib.io" git config --local user.name "stdlib-bot" @@ -191,8 +191,8 @@ jobs: # Pin action to full length commit SHA uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - # Configure git: - - name: 'Configure git' + # Configure Git: + - name: 'Configure Git' run: | git config --local user.email "noreply@stdlib.io" git config --local user.name "stdlib-bot" @@ -366,8 +366,8 @@ jobs: # Pin action to full length commit SHA uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - # Configure git: - - name: 'Configure git' + # Configure Git: + - name: 'Configure Git' run: | git config --local user.email "noreply@stdlib.io" git config --local user.name "stdlib-bot" @@ -539,8 +539,8 @@ jobs: # Pin action to full length commit SHA uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - # Configure git: - - name: 'Configure git' + # Configure Git: + - name: 'Configure Git' run: | git config --local user.email "noreply@stdlib.io" git config --local user.name "stdlib-bot" @@ -735,8 +735,8 @@ jobs: echo "bump=true" >> $GITHUB_OUTPUT fi - # Configure git: - - name: 'Configure git' + # Configure Git: + - name: 'Configure Git' if: steps.check-if-bump.outputs.bump run: | git config --local user.email "noreply@stdlib.io" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 027cf188..55320e77 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -72,8 +72,8 @@ jobs: node-version: 20 timeout-minutes: 5 - # Configure git: - - name: 'Configure git' + # Configure Git: + - name: 'Configure Git' run: | git config --local user.email "noreply@stdlib.io" git config --local user.name "stdlib-bot" diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ff3a61e..fb3a74c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@
-## Unreleased (2024-07-22) +## Unreleased (2024-07-24)
@@ -515,12 +515,25 @@ ##### Features -- [`21052a2`](https://github.com/stdlib-js/stdlib/commit/21052a211289b86b0e8a2e1f43a4d4c5b2379ffb) - add boolean dtype support to `ndarray/min-dtype` [(#2552)](https://github.com/stdlib-js/stdlib/pull/2552) +- [`21052a2`](https://github.com/stdlib-js/stdlib/commit/21052a211289b86b0e8a2e1f43a4d4c5b2379ffb) - add boolean dtype support to ndarray/min-dtype [(##2552)](#2552)
+
+ +##### BREAKING CHANGES + +- [`21052a2`](https://github.com/stdlib-js/stdlib/commit/21052a211289b86b0e8a2e1f43a4d4c5b2379ffb): add boolean dtype support to ndarray/min-dtype +- [`21052a2`](https://github.com/stdlib-js/stdlib/commit/21052a211289b86b0e8a2e1f43a4d4c5b2379ffb): return "bool" when provided a boolean + + - To migrate, users explicitly handle "bool" return values. If "generic" is still desired, users should consolidate accordingly. + +
+ + +
@@ -689,6 +702,11 @@ ### BREAKING CHANGES +- [`21052a2`](https://github.com/stdlib-js/stdlib/commit/21052a211289b86b0e8a2e1f43a4d4c5b2379ffb): add boolean dtype support to ndarray/min-dtype +- [`21052a2`](https://github.com/stdlib-js/stdlib/commit/21052a211289b86b0e8a2e1f43a4d4c5b2379ffb): return "bool" when provided a boolean + + - To migrate, users explicitly handle "bool" return values. If "generic" is still desired, users should consolidate accordingly. + - [`0adcae5`](https://github.com/stdlib-js/stdlib/commit/0adcae51386086e2ef5fb5d78402389cff776deb): update namespace TypeScript declarations - [`0adcae5`](https://github.com/stdlib-js/stdlib/commit/0adcae51386086e2ef5fb5d78402389cff776deb): rename exported aliases @@ -739,6 +757,7 @@ A total of 4 people contributed to this release. Thank you to the following cont
+- [`fa34b48`](https://github.com/stdlib-js/stdlib/commit/fa34b48968bddc6eb016fd4991833d7942e2a9a9) - **test:** add tests to `ndarray/base/nullary` [(#2652)](https://github.com/stdlib-js/stdlib/pull/2652) _(by Muhammad Haris, Athan Reines)_ - [`0dfdd7d`](https://github.com/stdlib-js/stdlib/commit/0dfdd7da997c13178f0a2bd7a9895a4618629a46) - **test:** add tests to `ndarray/base/nullary` [(#2645)](https://github.com/stdlib-js/stdlib/pull/2645) _(by Muhammad Haris, Athan Reines)_ - [`14a2930`](https://github.com/stdlib-js/stdlib/commit/14a2930e995e2a92b2886146514c82f637807724) - **test:** add tests to `ndarray/base/nullary` [(#2644)](https://github.com/stdlib-js/stdlib/pull/2644) _(by Muhammad Haris, Athan Reines)_ - [`06b4d43`](https://github.com/stdlib-js/stdlib/commit/06b4d4334a2c56bb39787c902fadfb9bb794779d) - **test:** add tests to `ndarray/base/nullary` [(#2634)](https://github.com/stdlib-js/stdlib/pull/2634) _(by Muhammad Haris, Athan Reines)_ @@ -763,7 +782,7 @@ A total of 4 people contributed to this release. Thank you to the following cont - [`fa118f2`](https://github.com/stdlib-js/stdlib/commit/fa118f279848e1c85ea6e5cf9799f3089649214c) - **feat:** add boolean dtype support to `ndarray/base/buffer` [(#2574)](https://github.com/stdlib-js/stdlib/pull/2574) _(by Jaysukh Makvana, Athan Reines)_ - [`e92152b`](https://github.com/stdlib-js/stdlib/commit/e92152baba61ab358640cba9d0506d75123a5f60) - **feat:** add boolean dtype support to `ndarray/defaults` [(#2551)](https://github.com/stdlib-js/stdlib/pull/2551) _(by Jaysukh Makvana, Athan Reines)_ - [`16e0808`](https://github.com/stdlib-js/stdlib/commit/16e0808004b7bd4f16eea7eced5229ee1120b577) - **feat:** add boolean dtype support to `ndarray/dtypes` [(#2550)](https://github.com/stdlib-js/stdlib/pull/2550) _(by Jaysukh Makvana, Athan Reines)_ -- [`21052a2`](https://github.com/stdlib-js/stdlib/commit/21052a211289b86b0e8a2e1f43a4d4c5b2379ffb) - **feat:** add boolean dtype support to `ndarray/min-dtype` [(#2552)](https://github.com/stdlib-js/stdlib/pull/2552) _(by Jaysukh Makvana, Athan Reines)_ +- [`21052a2`](https://github.com/stdlib-js/stdlib/commit/21052a211289b86b0e8a2e1f43a4d4c5b2379ffb) - **feat:** add boolean dtype support to ndarray/min-dtype [(##2552)](#2552) _(by Jaysukh Makvana, Athan Reines)_ - [`efecd32`](https://github.com/stdlib-js/stdlib/commit/efecd32448520402335cdf8fdb34ee88b96556b9) - **feat:** add boolean dtype support to `ndarray/base/buffer-dtype` [(#2572)](https://github.com/stdlib-js/stdlib/pull/2572) _(by Jaysukh Makvana, Athan Reines)_ - [`0f0dbca`](https://github.com/stdlib-js/stdlib/commit/0f0dbcaa7eddb30c09c8cc394224cd4a409b90a6) - **feat:** add boolean dtype support to `ndarray/base/buffer-ctors` [(#2571)](https://github.com/stdlib-js/stdlib/pull/2571) _(by Jaysukh Makvana, Athan Reines)_ - [`1cb0243`](https://github.com/stdlib-js/stdlib/commit/1cb0243d79c25ae193c058bb15ceeebad6cf3cfd) - **feat:** add boolean dtype support to `ndarray/next-dtype` [(#2553)](https://github.com/stdlib-js/stdlib/pull/2553) _(by Jaysukh Makvana)_ diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 7ec15a74..26a1c461 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -51,6 +51,7 @@ Muhammad Haris Naresh Jagadeesan NightKnight Nithin Katta <88046362+nithinkatta@users.noreply.github.com> +Nourhan Hasan <109472010+TheNourhan@users.noreply.github.com> Ognjen Jevremović Oneday12323 <107678750+Oneday12323@users.noreply.github.com> Philipp Burckhardt diff --git a/base/nullary/test/test.8d.js b/base/nullary/test/test.8d.js index 852b887d..6e2a163d 100644 --- a/base/nullary/test/test.8d.js +++ b/base/nullary/test/test.8d.js @@ -32,6 +32,9 @@ var ndarray = require( './../../../ctor' ); var shape2strides = require( './../../../base/shape2strides' ); var strides2offset = require( './../../../base/strides2offset' ); var numel = require( './../../../base/numel' ); +var dfill = require( '@stdlib/blas/ext/base/dfill' ); +var gfill = require( '@stdlib/blas/ext/base/gfill' ); +var blockSize = require( './../../../base/nullary-tiling-block-size' ); var nullary = require( './../lib' ); @@ -107,6 +110,25 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of an 8-dimensional ndarray (row-major, empty)', function test( t ) { + var expected; + var x; + + x = ndarray( 'float64', zeros( 4, 'float64' ), [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 1, 1, 1, 1, 1, 1, 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 an 8-dimensional ndarray (row-major, contiguous)', function test( t ) { var expected; var ord; @@ -141,6 +163,40 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d t.end(); }); +tape( 'the function applies a nullary callback to each indexed element of an 8-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 = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; + st = [ -8, -8, -8, -8, -4, -2, -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, + 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 (row-major, non-contiguous, same sign strides)', function test( t ) { var expected; var ord; @@ -205,27 +261,1242 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d expected = new Float64Array([ 10.0, 10.0, - 0.0, - 0.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 (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, 2, 1, 1, 2, 1, 2 ]; + st = [ 32, -16, 8, -8, -8, 4, 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[ 7 ] ); + + 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 (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, 2, 1, 1, 2, 1, 2 ]; + st = [ -bsize*32, -16, 8, -8, -8, 4, -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[ 7 ] ); + + 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 (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, 1, bsize*2, 2, 1, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, 16, -8, -8, 4, -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[ 7 ] ); + + 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 (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, 1, 1, bsize*2, 2, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*32, -16, -8, 4, -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[ 7 ] ); + + 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 (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, 1, 2, 1, bsize*2, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*16, -bsize*16, -8, 4, -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[ 7 ] ); + + 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 (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, 1, 2, 1, 1, bsize*2, 2, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*16, -bsize*16, -bsize*16, 8, -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[ 7 ] ); + + 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 (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, 1, 2, 1, 1, 1, bsize*2, 2 ]; + st = [ -bsize*16, -bsize*16, bsize*8, -bsize*8, -bsize*8, bsize*8, -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[ 7 ] ); + + 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 (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, 1, 2, 1, 1, 2, 1, bsize*2 ]; + st = [ + -bsize*16, + -bsize*16, + bsize*8, + -bsize*8, + -bsize*8, + bsize*4, + -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[ 7 ] ); + + 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 (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 an 8-dimensional ndarray (row-major, contiguous, accessors, negative strides)', 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 = [ -8, -8, -8, -8, -4, -2, -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, + 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 an 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 an 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 an 8-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, 2, 1, 1, 2, 1, 2 ]; + st = [ 32, 16, 8, -8, -8, 4, 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[ 7 ] ); + + t.strictEqual( isSameComplex128Array( 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 (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, 2, 1, 1, 2, 1, 2 ]; + st = [ -bsize*32, -16, 8, -8, -8, 4, -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[ 7 ] ); + + t.strictEqual( isSameComplex128Array( 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 (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, 1, bsize*2, 2, 1, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, 16, -8, -8, 4, -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[ 7 ] ); + + t.strictEqual( isSameComplex128Array( 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 (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, 1, 1, bsize*2, 2, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*32, -16, -8, 4, -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[ 7 ] ); + + t.strictEqual( isSameComplex128Array( 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 (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, 1, 2, 1, bsize*2, 2, 1, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*16, -bsize*16, -8, 4, -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[ 7 ] ); + + t.strictEqual( isSameComplex128Array( 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 (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, 1, 2, 1, 1, bsize*2, 2, 2 ]; + st = [ -bsize*32, -bsize*32, bsize*16, -bsize*16, -bsize*16, 8, -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[ 7 ] ); + + t.strictEqual( isSameComplex128Array( 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 (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, 1, 2, 1, 1, 1, bsize*2, 2 ]; + st = [ -bsize*16, -bsize*16, bsize*8, -bsize*8, -bsize*8, bsize*8, -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[ 7 ] ); + + t.strictEqual( isSameComplex128Array( 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 (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, 1, 2, 1, 1, 2, 1, bsize*2 ]; + st = [ + -bsize*16, + -bsize*16, + bsize*8, + -bsize*8, + -bsize*8, + bsize*4, + -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[ 7 ] ); + + t.strictEqual( isSameComplex128Array( 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, 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 an 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 an 8-dimensional ndarray (column-major, empty)', function test( t ) { + var expected; + var x; + + x = ndarray( 'float64', zeros( 4, 'float64' ), [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ 1, 1, 1, 1, 1, 1, 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 an 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, 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 = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -2, -4, -4, -8 ]; + 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, 8, 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, 8, -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, 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, 1, 2, 1, 1, 2, 1, 2 ]; + st = [ 2, bsize*4, bsize*4, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + 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 an 8-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, 1, 1, 1, 2, 1, 2 ]; + st = [ 2, -4, bsize*8, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; + 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 an 8-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, 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ 2, 4, 8, bsize*16, bsize*16, bsize*16, bsize*32, bsize*32 ]; + 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 an 8-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, 1, 2, bsize*2, 1, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*16, bsize*32, bsize*32 ]; + 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 an 8-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, 1, 2, 2, bsize*2, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, 16, bsize*32, bsize*32, bsize*32 ]; + 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 an 8-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, 1, 2, 1, 2, bsize*2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, bsize*32, bsize*32 ]; + 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 an 8-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, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32 ]; + 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 an 8-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, 1, 2, 1, 1, 2, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, 32 ]; + 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 an 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, - 0.0, - 0.0, 10.0, 10.0, - 0.0, - 0.0, 10.0, 10.0, - 0.0, - 0.0 + 10.0, + 10.0, + 10.0, + 10.0 ]); - t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( 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 (row-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, negative strides)', function test( t ) { var expected; var ord; var sh; @@ -235,9 +1506,9 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d var x; dt = 'complex128'; - ord = 'row-major'; - sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = shape2strides( sh, ord ); + ord = 'column-major'; + sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; + st = [ -1, -1, -1, -1, -2, -4, -4, -8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); @@ -267,7 +1538,7 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d t.end(); }); -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 ) { +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; @@ -277,16 +1548,16 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d var x; dt = 'complex128'; - ord = 'row-major'; + ord = 'column-major'; sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 16, 16, 16, 16, 8, 4, 2, 1 ]; + st = [ 1, 1, 1, 1, 1, 4, 8, 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([ + expected = new Complex128Array( [ 10.0, 10.0, 10.0, @@ -325,7 +1596,7 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d t.end(); }); -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 ) { +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; @@ -335,9 +1606,9 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d var x; dt = 'complex128'; - ord = 'row-major'; + ord = 'column-major'; sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 16, 16, -16, 16, -8, -4, -2, 1 ]; + st = [ -1, 1, -1, 1, 1, -4, -8, 8 ]; o = strides2offset( sh, st ); x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); @@ -383,8 +1654,9 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d t.end(); }); -tape( 'the function applies a nullary callback to each indexed element of an 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, non-contiguous, large arrays, accessors)', function test( t ) { var expected; + var bsize; var ord; var sh; var st; @@ -392,29 +1664,29 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d var o; var x; - dt = 'float64'; + dt = 'complex128'; ord = 'column-major'; - sh = [ 4, 1, 1, 1, 1, 1, 1, 1 ]; - st = shape2strides( sh, ord ); + + bsize = blockSize( dt ); + sh = [ bsize*2, 1, 2, 1, 1, 2, 1, 2 ]; + st = [ 2, bsize*4, bsize*4, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; o = strides2offset( sh, st ); - x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); - nullary( [ x ], constantFunction( 10.0 ) ); + nullary( [ x ], constantFunction( new Complex128( 10.0, 10.0 ) ) ); - expected = new Float64Array([ - 10.0, - 10.0, - 10.0, - 10.0 - ]); - t.strictEqual( isSameFloat64Array( x.data, expected ), true, 'returns expected value' ); + 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 an 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, non-contiguous, large arrays, accessors)', function test( t ) { var expected; + var bsize; var ord; var sh; var st; @@ -424,31 +1696,27 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d dt = 'complex128'; ord = 'column-major'; - sh = [ 4, 1, 1, 1, 1, 1, 1, 1 ]; - st = shape2strides( sh, ord ); + + bsize = blockSize( dt ); + sh = [ 2, bsize*2, 1, 1, 1, 2, 1, 2 ]; + st = [ 2, -4, bsize*8, bsize*8, bsize*8, bsize*8, bsize*16, bsize*16 ]; o = strides2offset( sh, st ); - x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( numel( sh )*2, 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 - ]); + 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 an 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, non-contiguous, large arrays, accessors)', function test( t ) { var expected; + var bsize; var ord; var sh; var st; @@ -456,33 +1724,29 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d var o; var x; - dt = 'float64'; + dt = 'complex128'; ord = 'column-major'; - sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; - st = shape2strides( sh, ord ); + + bsize = blockSize( dt ); + sh = [ 2, 2, bsize*2, 1, 1, 2, 1, 2 ]; + st = [ 2, 4, 8, bsize*16, bsize*16, bsize*16, bsize*32, bsize*32 ]; o = strides2offset( sh, st ); - x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); - nullary( [ x ], constantFunction( 10.0 ) ); + nullary( [ x ], constantFunction( new Complex128( 10.0, 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' ); + 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 an 8-dimensional ndarray (column-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 (column-major, non-contiguous, large arrays, accessors)', function test( t ) { var expected; + var bsize; var ord; var sh; var st; @@ -490,41 +1754,29 @@ tape('the function applies a nullary callback to each indexed element of an 8-di var o; var x; - dt = 'float64'; + dt = 'complex128'; ord = 'column-major'; - sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, 4, 8, 8 ]; - o = strides2offset(sh, st); - x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + bsize = blockSize( dt ); + sh = [ 2, 1, 2, bsize*2, 1, 2, 1, 2 ]; + st = [ 2, 4, 4, 8, bsize*16, bsize*16, bsize*32, bsize*32 ]; + o = strides2offset( sh, st ); - nullary( [ x ], constantFunction( 10.0 ) ); + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); - 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' ); + 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 an 8-dimensional ndarray (column-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 (column-major, non-contiguous, large arrays, accessors)', function test( t ) { var expected; + var bsize; var ord; var sh; var st; @@ -532,41 +1784,29 @@ tape('the function applies a nullary callback to each indexed element of an 8-di var o; var x; - dt = 'float64'; + dt = 'complex128'; ord = 'column-major'; - sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, -1, -4, 8, -8 ]; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 2, bsize*2, 1, 1, 2 ]; + st = [ 2, 4, 4, 8, 16, bsize*32, bsize*32, bsize*32 ]; o = strides2offset( sh, st ); - x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( numel( sh )*2, dt ), sh, st, o, ord ); - nullary( [ x ], constantFunction( 10.0 ) ); + nullary( [ x ], constantFunction( new Complex128( 10.0, 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' ); + 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 an 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, non-contiguous, large arrays, accessors)', function test( t ) { var expected; + var bsize; var ord; var sh; var st; @@ -576,39 +1816,27 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d dt = 'complex128'; ord = 'column-major'; - sh = [ 1, 1, 1, 2, 2, 1, 2, 1 ]; - st = shape2strides( sh, ord ); + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 2, bsize*2, 1, 2 ]; + st = [ 2, 4, 4, 8, 8, 16, bsize*32, bsize*32 ]; o = strides2offset( sh, st ); - x = ndarray( dt, zeros( numel( sh ), dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( numel( sh )*2, 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 - ]); + 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 an 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, large arrays, accessors)', function test( t ) { var expected; + var bsize; var ord; var sh; var st; @@ -618,55 +1846,27 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d dt = 'complex128'; ord = 'column-major'; - sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ 1, 1, 1, 1, 1, 4, 8, 8 ]; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, bsize*2, 2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, bsize*32 ]; o = strides2offset( sh, st ); - x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( numel( sh )*2, 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 - ]); + 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 an 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, large arrays, accessors)', function test( t ) { var expected; + var bsize; var ord; var sh; var st; @@ -676,48 +1876,19 @@ tape( 'the function applies a nullary callback to each indexed element of an 8-d dt = 'complex128'; ord = 'column-major'; - sh = [ 1, 1, 1, 1, 2, 2, 1, 2 ]; - st = [ -1, 1, -1, 1, 1, -4, -8, 8 ]; + + bsize = blockSize( dt ); + sh = [ 2, 1, 2, 1, 1, 2, 2, bsize*2 ]; + st = [ 2, 4, 4, 8, 8, 8, 16, 32 ]; o = strides2offset( sh, st ); - x = ndarray( dt, zeros( 16, dt ), sh, st, o, ord ); + x = ndarray( dt, zeros( numel( sh )*2, 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 - ]); + 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();