From bfc956f7e6bf74cdb7b0a821e3843ba2e6c98921 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Wed, 22 May 2024 12:04:51 +0530 Subject: [PATCH] feat: add BLAS Level 1 routine for zdrot --- .../@stdlib/blas/base/zdrot/README.md | 385 ++++++++++++ .../blas/base/zdrot/benchmark/benchmark.js | 113 ++++ .../base/zdrot/benchmark/benchmark.native.js | 118 ++++ .../base/zdrot/benchmark/benchmark.ndarray.js | 113 ++++ .../benchmark/benchmark.ndarray.native.js | 118 ++++ .../blas/base/zdrot/benchmark/c/Makefile | 146 +++++ .../base/zdrot/benchmark/c/benchmark.length.c | 153 +++++ .../base/zdrot/benchmark/fortran/Makefile | 141 +++++ .../benchmark/fortran/benchmark.length.f | 211 +++++++ .../@stdlib/blas/base/zdrot/binding.gyp | 265 +++++++++ .../@stdlib/blas/base/zdrot/docs/repl.txt | 168 ++++++ .../blas/base/zdrot/docs/types/index.d.ts | 189 ++++++ .../blas/base/zdrot/docs/types/test.ts | 312 ++++++++++ .../blas/base/zdrot/examples/c/Makefile | 146 +++++ .../blas/base/zdrot/examples/c/example.c | 41 ++ .../@stdlib/blas/base/zdrot/examples/index.js | 39 ++ .../@stdlib/blas/base/zdrot/include.gypi | 70 +++ .../zdrot/include/stdlib/blas/base/zdrot.h | 43 ++ .../include/stdlib/blas/base/zdrot_cblas.h | 43 ++ .../include/stdlib/blas/base/zdrot_fortran.h | 41 ++ .../@stdlib/blas/base/zdrot/lib/index.js | 108 ++++ .../@stdlib/blas/base/zdrot/lib/main.js | 35 ++ .../@stdlib/blas/base/zdrot/lib/native.js | 35 ++ .../@stdlib/blas/base/zdrot/lib/ndarray.js | 108 ++++ .../blas/base/zdrot/lib/ndarray.native.js | 89 +++ .../@stdlib/blas/base/zdrot/lib/zdrot.js | 128 ++++ .../blas/base/zdrot/lib/zdrot.native.js | 79 +++ .../@stdlib/blas/base/zdrot/manifest.json | 417 +++++++++++++ .../@stdlib/blas/base/zdrot/package.json | 80 +++ .../@stdlib/blas/base/zdrot/src/Makefile | 70 +++ .../@stdlib/blas/base/zdrot/src/addon.c | 49 ++ .../@stdlib/blas/base/zdrot/src/zdrot.c | 86 +++ .../@stdlib/blas/base/zdrot/src/zdrot.f | 102 ++++ .../@stdlib/blas/base/zdrot/src/zdrot_cblas.c | 36 ++ .../@stdlib/blas/base/zdrot/src/zdrot_f.c | 36 ++ .../@stdlib/blas/base/zdrot/test/test.js | 82 +++ .../blas/base/zdrot/test/test.ndarray.js | 554 +++++++++++++++++ .../base/zdrot/test/test.ndarray.native.js | 563 ++++++++++++++++++ .../blas/base/zdrot/test/test.zdrot.js | 486 +++++++++++++++ .../blas/base/zdrot/test/test.zdrot.native.js | 495 +++++++++++++++ 40 files changed, 6493 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/benchmark/fortran/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/benchmark/fortran/benchmark.length.f create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/include/stdlib/blas/base/zdrot.h create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/include/stdlib/blas/base/zdrot_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/include/stdlib/blas/base/zdrot_fortran.h create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/lib/zdrot.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/lib/zdrot.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot.c create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot.f create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot_f.c create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/test/test.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/test/test.zdrot.js create mode 100644 lib/node_modules/@stdlib/blas/base/zdrot/test/test.zdrot.native.js diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/README.md b/lib/node_modules/@stdlib/blas/base/zdrot/README.md new file mode 100644 index 00000000000..ec48c74ee7b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/README.md @@ -0,0 +1,385 @@ + + +# zdrot + +> Applies a plane rotation on complex double-precision floating-point vectors. + +
+ +## Usage + +```javascript +var zdrot = require( '@stdlib/blas/base/zdrot' ); +``` + +#### zdrot( N, zx, strideX, zy, strideY, c, s ) + +Applies a plane rotation on complex double-precision floating-point vectors. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); + +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +zdrot( zx.length, zx, 1, zy, 1, 0.8, 0.6 ); + +var z = zy.get( 0 ); +// returns + +var re = real( z ); +// returns ~-0.6 + +var im = imag( z ); +// returns ~-1.2 + +z = zx.get( 0 ); +// returns + +re = real( z ); +// returns ~0.8 + +im = imag( z ); +// returns ~1.6 +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **zx**: first input [`Complex128Array`][@stdlib/array/complex128]. +- **strideX**: index increment for `zx`. +- **zy**: second input [`Complex128Array`][@stdlib/array/complex128]. +- **strideY**: index increment for `zy`. + +The `N` and stride parameters determine how values from `zx` and `zy` are rotated. For example, to apply a plane rotation to every other element, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); + +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +zdrot( 2, zx, 2, zy, 2, 0.8, 0.6 ); + +var z = zy.get( 0 ); +// returns + +var re = real( z ); +// returns ~-0.6 + +var im = imag( z ); +// returns ~-1.2 + +z = zx.get( 0 ); +// returns + +re = real( z ); +// returns ~0.8 + +im = imag( z ); +// returns ~1.6 +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); + +// Initial arrays... +var zx0 = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var zy0 = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Create offset views... +var zx1 = new Complex128Array( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var zy1 = new Complex128Array( zy0.buffer, zy0.BYTES_PER_ELEMENT*2 ); // start at 3rd element + +zdrot( 2, zx1, -2, zy1, 1, 0.8, 0.6 ); + +var z = zy0.get( 2 ); +// returns + +var re = real( z ); +// returns ~-4.2 + +var im = imag( z ); +// returns ~-4.8 + +z = zx0.get( 3 ); +// returns + +re = real( z ); +// returns ~5.6 + +im = imag( z ); +// returns ~6.4 +``` + +#### zdrot.ndarray( N, zx, strideX, offsetX, zy, strideY, offsetY, c, s ) + +Applies a plane rotation on complex double-precision floating-point vectors using alternative indexing semantics. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); + +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); + +var z = zy.get( 0 ); +// returns + +var re = real( z ); +// returns ~-0.6 + +var im = imag( z ); +// returns ~-1.2 + +z = zx.get( 0 ); +// returns + +re = real( z ); +// returns ~0.8 + +im = imag( z ); +// returns ~1.6 +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `zx`. +- **offsetY**: starting index for `zy`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to apply a plane rotation to every other element starting from the second element, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); + +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +zdrot.ndarray( 2, zx, 2, 1, zy, 2, 1, 0.8, 0.6 ); + +var z = zy.get( 3 ); +// returns + +var re = real( z ); +// returns ~-4.2 + +var im = imag( z ); +// returns ~-4.8 + +z = zx.get( 1 ); +// returns + +re = real( z ); +// returns ~2.4 + +im = imag( z ); +// returns ~3.2 +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions leave `zx` and `zy` unchanged. +- `zdrot()` corresponds to the [BLAS][blas] level 1 function [`zdrot`][zdrot]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var zdrot = require( '@stdlib/blas/base/zdrot' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var zx = filledarrayBy( 10, 'complex128', rand ); +console.log( zx.get( 0 ).toString() ); + +var zy = filledarrayBy( 10, 'complex128', rand ); +console.log( zy.get( 0 ).toString() ); + +// Apply a plane rotation: +zdrot( zx.length, zx, 1, zy, 1, 0.8, 0.6 ); +console.log( zx.get( zx.length-1 ).toString() ); +console.log( zy.get( zy.length-1 ).toString() ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/zdrot.h" +``` + +#### c_zdrot( N, \*X, strideX, \*Y, strideY, c, s ) + +Applies a plane rotation on complex double-precision floating-point vectors. + +```c +double x[] = { 1.0, 2.0, 3.0, 4.0 }; // interleaved real and imaginary components +double y[] = { 5.0, 6.0, 7.0, 8.0 }; + +c_zdrot( 2, (void *)x, 1, (void *)Y, 1, 0.8, 0.6 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **zx**: `[inout] void*` first input array. +- **strideX**: `[in] CBLAS_INT` index increment for `zx`. +- **zy**: `[inout] void*` first input array. +- **strideY**: `[in] CBLAS_INT` index increment for `zy`. +- **c**: `[in] double` cosine of the angle of rotation. +- **s**: `[in] double` sine of the angle of rotation. + +```c +void c_zdrot( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const double c, const double s ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/zdrot.h" +#include + +int main( void ) { + // Create strided arrays: + double zx[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + double zy[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + + // Specify the number of elements: + const int N = 4; + + // Specify stride lengths: + const int strideX = 1; + const int strideY = -1; + + // Copy elements: + c_zdrot( N, (void *)zx, strideX, (void *)zy, strideY, 0.8, 0.6 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "zx[ %i ] = %lf + %lfj\n", i, zx[ i*2 ], zx[ (i*2)+1 ] ); + printf( "zy[ %i ] = %lf + %lfj\n", i, zy[ i*2 ], zy[ (i*2)+1 ] ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.js new file mode 100644 index 00000000000..69f909373b7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.js @@ -0,0 +1,113 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var pkg = require( './../package.json' ).name; +var zdrot = require( './../lib/zdrot.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var zx; + var zy; + + zx = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zx.buffer ); + + zy = uniform( len*2, -100.0, 100.0, options ); + zy = new Complex128Array( zy.buffer ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var viewX; + var i; + + viewX = reinterpret( zx, 0 ); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zdrot( zx.length, zx, 1, zy, 1, 0.8, 0.6 ); + if ( isnan( viewX[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( viewX[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.native.js new file mode 100644 index 00000000000..1ad0dc0cdfb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.native.js @@ -0,0 +1,118 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var zdrot = tryRequire( resolve( __dirname, './../lib/zdrot.native.js' ) ); +var opts = { + 'skip': ( zdrot instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var zx; + var zy; + + zx = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zx.buffer ); + + zy = uniform( len*2, -100.0, 100.0, options ); + zy = new Complex128Array( zy.buffer ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var viewX; + var i; + + viewX = reinterpret( zx, 0 ); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zdrot( zx.length, zx, 1, zy, 1, 0.8, 0.6 ); + if ( isnan( viewX[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( viewX[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+'::native:len='+len, opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.ndarray.js new file mode 100644 index 00000000000..f3a408c14a9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.ndarray.js @@ -0,0 +1,113 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var pkg = require( './../package.json' ).name; +var zdrot = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var zx; + var zy; + + zx = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zx.buffer ); + + zy = uniform( len*2, -100.0, 100.0, options ); + zy = new Complex128Array( zy.buffer ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var viewX; + var i; + + viewX = reinterpret( zx, 0 ); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zdrot( zx.length, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); + if ( isnan( viewX[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( viewX[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.ndarray.native.js new file mode 100644 index 00000000000..e19c1b7febc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,118 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var zdrot = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( zdrot instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var zx; + var zy; + + zx = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zx.buffer ); + + zy = uniform( len*2, -100.0, 100.0, options ); + zy = new Complex128Array( zy.buffer ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var viewX; + var i; + + viewX = reinterpret( zx, 0 ); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zdrot( zx.length, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); + if ( isnan( viewX[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( viewX[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+'::native:ndarray:len='+len, opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/c/Makefile new file mode 100644 index 00000000000..9f97140e7cb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/c/benchmark.length.c new file mode 100644 index 00000000000..5c3fa04ed14 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/c/benchmark.length.c @@ -0,0 +1,153 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/zdrot.h" +#include +#include +#include +#include +#include + +#define NAME "zdrot" +#define ITERATIONS 10000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +void print_results( int iterations, double elapsed ) { + double rate = (double)iterations / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", iterations ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1]. +* +* @return random number +*/ +double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +double benchmark( int iterations, int len ) { + double elapsed; + double x[ len*2 ]; + double y[ len*2 ]; + double t; + int i; + + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_double()*10000.0 ) - 5000.0; + x[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0; + y[ i ] = ( rand_double()*10000.0 ) - 5000.0; + y[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_zdrot( len, (void *)x, 1, (void *)y, 1, 0.8, 0.6 ); + if ( y[ 0 ] != y[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y[ 0 ] != y[ 0 ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int len; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:len=%d\n", NAME, len ); + elapsed = benchmark( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/fortran/Makefile new file mode 100644 index 00000000000..22405312ef4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/fortran/Makefile @@ -0,0 +1,141 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling Fortran source files: +ifdef FORTRAN_COMPILER + FC := $(FORTRAN_COMPILER) +else + FC := gfortran +endif + +# Define the command-line options when compiling Fortran files: +FFLAGS ?= \ + -std=f95 \ + -ffree-form \ + -O3 \ + -Wall \ + -Wextra \ + -Wno-compare-reals \ + -Wimplicit-interface \ + -fno-underscoring \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop`): +INCLUDE ?= + +# List of Fortran source files: +SOURCE_FILES ?= ../../src/zdrot.f + +# List of Fortran targets: +f_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles Fortran source files. +# +# @param {string} SOURCE_FILES - list of Fortran source files +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} [FORTRAN_COMPILER] - Fortran compiler +# @param {string} [FFLAGS] - Fortran compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @example +# make +# +# @example +# make all +#/ +all: $(f_targets) + +.PHONY: all + +#/ +# Compiles Fortran source files. +# +# @private +# @param {string} SOURCE_FILES - list of Fortran source files +# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} FC - Fortran compiler +# @param {string} FFLAGS - Fortran compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(f_targets): %.out: %.f + $(QUIET) $(FC) $(FFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(f_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/fortran/benchmark.length.f new file mode 100644 index 00000000000..8a8104a9ccd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/fortran/benchmark.length.f @@ -0,0 +1,211 @@ +!> +! @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. +!< + +program bench + implicit none + ! .. + ! Local constants: + character(5), parameter :: name = 'zdrot' ! if changed, be sure to adjust length + integer, parameter :: iterations = 10000000 + integer, parameter :: repeats = 3 + integer, parameter :: min = 1 + integer, parameter :: max = 6 + ! .. + ! Run the benchmarks: + call main() + ! .. + ! Functions: +contains + ! .. + ! Prints the TAP version. + ! .. + subroutine print_version() + print '(A)', 'TAP version 13' + end subroutine print_version + ! .. + ! Prints the TAP summary. + ! + ! @param {integer} total - total number of tests + ! @param {integer} passing - total number of passing tests + ! .. + subroutine print_summary( total, passing ) + ! .. + ! Scalar arguments: + integer, intent(in) :: total, passing + ! .. + ! Local variables: + character(len=999) :: str, tmp + ! .. + ! Intrinsic functions: + intrinsic adjustl, trim + ! .. + print '(A)', '#' + ! .. + write (str, '(I15)') total ! TAP plan + tmp = adjustl( str ) + print '(A,A)', '1..', trim( tmp ) + ! .. + print '(A,A)', '# total ', trim( tmp ) + ! .. + write (str, '(I15)') passing + tmp = adjustl( str ) + print '(A,A)', '# pass ', trim( tmp ) + ! .. + print '(A)', '#' + print '(A)', '# ok' + end subroutine print_summary + ! .. + ! Prints benchmarks results. + ! + ! @param {integer} iterations - number of iterations + ! @param {double} elapsed - elapsed time in seconds + ! .. + subroutine print_results( iterations, elapsed ) + ! .. + ! Scalar arguments: + double precision, intent(in) :: elapsed + integer, intent(in) :: iterations + ! .. + ! Local variables: + double precision :: rate + character(len=999) :: str, tmp + ! .. + ! Intrinsic functions: + intrinsic dble, adjustl, trim + ! .. + rate = dble( iterations ) / elapsed + ! .. + print '(A)', ' ---' + ! .. + write (str, '(I15)') iterations + tmp = adjustl( str ) + print '(A,A)', ' iterations: ', trim( tmp ) + ! .. + write (str, '(f0.9)') elapsed + tmp = adjustl( str ) + print '(A,A)', ' elapsed: ', trim( tmp ) + ! .. + write( str, '(f0.9)') rate + tmp = adjustl( str ) + print '(A,A)', ' rate: ', trim( tmp ) + ! .. + print '(A)', ' ...' + end subroutine print_results + ! .. + ! Runs a benchmark. + ! + ! @param {integer} iterations - number of iterations + ! @param {integer} len - array length + ! @return {double} elapsed time in seconds + ! .. + double precision function benchmark( iterations, len ) + ! .. + ! External functions: + interface + subroutine zdrot( N, zx, strideX, zy, strideY, c, s ) + complex(kind=kind(0.0d0)) :: zx(*), zy(*) + integer :: strideX, strideY, N + double precision :: c, s + end subroutine zdrot + end interface + ! .. + ! Scalar arguments: + integer, intent(in) :: iterations, len + ! .. + ! Local scalars: + double precision :: elapsed, r1, r2 + real :: t1, t2 + integer :: i + ! .. + ! Local arrays: + complex(kind=kind(0.0d0)), allocatable :: x(:), y(:) + ! .. + ! Intrinsic functions: + intrinsic random_number, cpu_time, cmplx + ! .. + ! Allocate arrays: + allocate( x(len), y(len) ) + ! .. + do i = 1, len + call random_number( r1 ) + call random_number( r2 ) + x( i ) = cmplx( (r1*10000.0d0)-5000.0d0, (r2*10000.0d0)-5000.0d0, kind=kind(0.0d0) ) + y( i ) = cmplx( (r1*10000.0d0)-5000.0d0, (r2*10000.0d0)-5000.0d0, kind=kind(0.0d0) ) + end do + ! .. + call cpu_time( t1 ) + ! .. + do i = 1, iterations + call zdrot( len, x, 1, y, 1, 0.8d0, 0.6d0 ); + if ( y( 1 ) /= y( 1 ) ) then + print '(A)', 'should not return NaN' + exit + end if + end do + ! .. + call cpu_time( t2 ) + ! .. + elapsed = t2 - t1 + ! .. + if ( y( 1 ) /= y( 1 ) ) then + print '(A)', 'should not return NaN' + end if + ! .. + ! Deallocate arrays: + deallocate( x, y ) + ! .. + benchmark = elapsed + return + end function benchmark + ! .. + ! Main execution sequence. + ! .. + subroutine main() + ! .. + ! Local variables: + integer :: count, iter, len, i, j + double precision :: elapsed + character(len=999) :: str, tmp + ! .. + ! Intrinsic functions: + intrinsic adjustl, trim + ! .. + call print_version() + count = 0 + do i = min, max + len = 10**i + iter = iterations / 10**(i-1) + do j = 1, repeats + count = count + 1 + ! .. + write (str, '(I15)') len + tmp = adjustl( str ) + print '(A,A,A,A)', '# fortran::', name, ':len=', trim( tmp ) + ! .. + elapsed = benchmark( iter, len ) + ! .. + call print_results( iter, elapsed ) + ! .. + write (str, '(I15)') count + tmp = adjustl( str ) + print '(A,A,A)', 'ok ', trim( tmp ), ' benchmark finished' + end do + end do + call print_summary( count, count ) + end subroutine main +end program bench \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/binding.gyp b/lib/node_modules/@stdlib/blas/base/zdrot/binding.gyp new file mode 100644 index 00000000000..02a2799da09 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/binding.gyp @@ -0,0 +1,265 @@ +# @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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Fortran compiler (to override -Dfortran_compiler=): + 'fortran_compiler%': 'gfortran', + + # Fortran compiler flags: + 'fflags': [ + # Specify the Fortran standard to which a program is expected to conform: + '-std=f95', + + # Indicate that the layout is free-form source code: + '-ffree-form', + + # Aggressive optimization: + '-O3', + + # Enable commonly used warning options: + '-Wall', + + # Warn if source code contains problematic language features: + '-Wextra', + + # Warn if a procedure is called without an explicit interface: + '-Wimplicit-interface', + + # Do not transform names of entities specified in Fortran source files by appending underscores (i.e., don't mangle names, thus allowing easier usage in C wrappers): + '-fno-underscoring', + + # Warn if source code contains Fortran 95 extensions and C-language constructs: + '-pedantic', + + # Compile but do not link (output is an object file): + '-c', + ], + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + + # Define custom build actions for particular inputs: + 'rules': [ + { + # Define a rule for processing Fortran files: + 'extension': 'f', + + # Define the pathnames to be used as inputs when performing processing: + 'inputs': [ + # Full path of the current input: + '<(RULE_INPUT_PATH)' + ], + + # Define the outputs produced during processing: + 'outputs': [ + # Store an output object file in a directory for placing intermediate results (only accessible within a single target): + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)' + ], + + # Define the rule for compiling Fortran based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + + # Rule to compile Fortran on Windows: + { + 'rule_name': 'compile_fortran_windows', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Windows...', + + 'process_outputs_as_sources': 0, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + }, + + # Rule to compile Fortran on non-Windows: + { + 'rule_name': 'compile_fortran_linux', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Linux...', + + 'process_outputs_as_sources': 1, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '-fPIC', # generate platform-independent code + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + } + ], # end condition (OS=="win") + ], # end conditions + }, # end rule (extension=="f") + ], # end rules + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/zdrot/docs/repl.txt new file mode 100644 index 00000000000..888c4760603 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/docs/repl.txt @@ -0,0 +1,168 @@ + +{{alias}}( N, zx, strideX, zy, strideY, c, s ) + Applies a plane rotation on complex double-precision floating-point + vectors. + + The `N` and stride parameters determine how values from `zx` and `zy` are + rotated. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N` is less than or equal to `0`, the vectors are unchanged. + + Parameters + ---------- + N: integer + Number of indexed elements. + + zx: Complex128Array + First input array. + + strideX: integer + Index increment for `zx`. + + zy: Complex128Array + Second input array. + + strideY: integer + Index increment for `zy`. + + c: number + Cosine of the angle of rotation. + + s: number + Sine of the angle of rotation. + + Returns + ------- + zy: Complex128Array + Input array `zy`. + + Examples + -------- + // Standard usage: + > var zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var zy = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 0.0, 0.0 ] ); + > {{alias}}( zx.length, zx, 1, zy, 1, 0.8, 0.6 ); + > var z = zy.get( 0 ); + > var re = {{alias:@stdlib/complex/real}}( z ) + ~-0.6 + > var im = {{alias:@stdlib/complex/imag}}( z ) + ~-1.2 + > z = zx.get( 0 ); + > re = {{alias:@stdlib/complex/real}}( z ) + ~0.8 + > im = {{alias:@stdlib/complex/imag}}( z ) + ~1.6 + + // Advanced indexing: + > zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > zy = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + > {{alias}}( 2, zx, -2, zy, 1, 0.8, 0.6 ); + > z = zy.get( 0 ); + > re = {{alias:@stdlib/complex/real}}( z ) + ~-3.0 + > im = {{alias:@stdlib/complex/imag}}( z ) + ~-3.6 + > z = zx.get( 2 ); + > re = {{alias:@stdlib/complex/real}}( z ) + ~4.0 + > im = {{alias:@stdlib/complex/imag}}( z ) + ~4.8 + + // Using typed array views: + > var zx0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var zy0 = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + > var zx1 = new {{alias:@stdlib/array/complex128}}( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); + > var zy1 = new {{alias:@stdlib/array/complex128}}( zy0.buffer, zy0.BYTES_PER_ELEMENT*2 ); + > {{alias}}( 1, zx1, 1, zy1, 1, 0.8, 0.6 ); + > z = zy0.get( 2 ); + > re = {{alias:@stdlib/complex/real}}( z ) + ~-1.8 + > im = {{alias:@stdlib/complex/imag}}( z ) + ~-2.4 + > z = zx0.get( 1 ); + > re = {{alias:@stdlib/complex/real}}( z ) + ~2.4 + > im = {{alias:@stdlib/complex/imag}}( z ) + ~3.2 + + +{{alias}}.ndarray( N, zx, strideX, offsetX, zy, strideY, offsetY, c, s ) + Applies a plane rotation on complex double-precision floating-point + vectors. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + N: integer + Number of indexed elements. + + zx: Complex128Array + First input array. + + strideX: integer + Index increment for `zx`. + + offsetX: integer + Starting index for `zx`. + + zy: Complex128Array + Second input array. + + strideY: integer + Index increment for `zy`. + + offsetY: integer + Starting index for `zy`. + + c: number + Cosine of the angle of rotation. + + s: number + Sine of the angle of rotation. + + Returns + ------- + zy: Complex128Array + Input array `zy`. + + Examples + -------- + // Standard usage: + > var zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var zy = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 0.0, 0.0 ] ); + > {{alias}}.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); + > var z = zy.get( 0 ); + > var re = {{alias:@stdlib/complex/real}}( z ) + ~-0.6 + > var im = {{alias:@stdlib/complex/imag}}( z ) + ~-1.2 + > z = zx.get( 0 ); + > re = {{alias:@stdlib/complex/real}}( z ) + ~0.8 + > im = {{alias:@stdlib/complex/imag}}( z ) + ~1.6 + + // Advanced indexing: + > zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > zy = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + > {{alias}}.ndarray( 1, zx, 2, 1, zy, 2, 1, 0.8, 0.6 ); + > z = zy.get( 1 ); + > re = {{alias:@stdlib/complex/real}}( z ) + ~-1.8 + > im = {{alias:@stdlib/complex/imag}}( z ) + ~-2.4 + > z = zx.get( 1 ); + > re = {{alias:@stdlib/complex/real}}( z ) + ~2.4 + > im = {{alias:@stdlib/complex/imag}}( z ) + ~3.2 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/zdrot/docs/types/index.d.ts new file mode 100644 index 00000000000..b4f2abf9d1f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/docs/types/index.d.ts @@ -0,0 +1,189 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Complex128Array } from '@stdlib/types/array'; + +/** +* Interface describing `zdrot`. +*/ +interface Routine { + /** + * Applies a plane rotation on complex double-precision floating-point vectors. + * + * @param N - number of indexed elements + * @param zx - first input array + * @param strideX - `zx` stride length + * @param zy - second input array + * @param strideY - `zy` stride length + * @param c - cosine of the angle of rotation + * @param s - sine of the angle of rotation + * @returns `zy` + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * var real = require( '@stdlib/complex/real' ); + * var imag = require( '@stdlib/complex/imag' ); + * + * var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + * var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + * + * zdrot( zx.length, zx, 1, zy, 1, 0.8, 0.6 ); + * + * var z = zy.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns -0.6 + * + * var im = imag( z ); + * // returns -1.2 + * + * z = zx.get( 0 ); + * // returns + * + * re = real( z ); + * // returns 0.8 + * + * im = imag( z ); + * // returns 1.6 + */ + ( N: number, zx: Complex128Array, strideX: number, zy: Complex128Array, strideY: number, c: number, s: number ): Complex128Array; + + /** + * Applies a plane rotation on complex double-precision floating-point vectors using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param zx - first input array + * @param strideX - `zx` stride length + * @param offsetX - starting index for `zx` + * @param zy - second input array + * @param strideY - `zy` stride length + * @param offsetY - starting index for `zy` + * @param c - cosine of the angle of rotation + * @param s - sine of the angle of rotation + * @returns `zy` + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * var real = require( '@stdlib/complex/real' ); + * var imag = require( '@stdlib/complex/imag' ); + * + * var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + * var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + * + * zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); + * + * var z = zy.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns -0.6 + * + * var im = imag( z ); + * // returns -1.2 + * + * z = zx.get( 0 ); + * // returns + * + * re = real( z ); + * // returns 0.8 + * + * im = imag( z ); + * // returns 1.6 + */ + ndarray( N: number, zx: Complex128Array, strideX: number, offsetX: number, zy: Complex128Array, strideY: number, offsetY: number, c: number, s: number ): Complex128Array; +} + +/** +* Applies a plane rotation on complex double-precision floating-point vectors. +* +* @param N - number of indexed elements +* @param zx - first input array +* @param strideX - `zx` stride length +* @param zy - second input array +* @param strideY - `zy` stride length +* @param c - cosine of the angle of rotation +* @param s - sine of the angle of rotation +* @returns `zy` +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* zdrot( 2, zx, 2, zy, 1, 0.8, 0.6 ); +* +* var z = zy.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns -0.6 +* +* var im = imag( z ); +* // returns -1.2 +* +* z = zx.get( 0 ); +* // returns +* +* re = real( z ); +* // returns 0.8 +* +* im = imag( z ); +* // returns 1.6 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* zdrot.ndarray( 2, zx, 2, 0, zy, 1, 0, 0.8, 0.6 ); +* +* var z = zy.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns -0.6 +* +* var im = imag( z ); +* // returns -1.2 +* +* z = zx.get( 0 ); +* // returns +* +* re = real( z ); +* // returns 0.8 +* +* im = imag( z ); +* // returns 1.6 +*/ +declare var zdrot: Routine; + + +// EXPORTS // + +export = zdrot; diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/zdrot/docs/types/test.ts new file mode 100644 index 00000000000..7900838660a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/docs/types/test.ts @@ -0,0 +1,312 @@ +/* +* @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. +*/ + +import Complex128Array = require( '@stdlib/array/complex64' ); +import zdrot = require( './index' ); + + +// TESTS // + +// The function returns a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot( zx.length, zx, 1, zy, 1, 0.8, 0.6 ); // $ExpectType Complex128Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot( '10', zx, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( true, zx, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( false, zx, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( null, zx, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( undefined, zx, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( [], zx, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( {}, zx, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( ( zx: number ): number => zx, zx, 1, zy, 1, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot( zx.length, 10, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, '10', 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, true, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, false, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, null, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, undefined, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, [ '1' ], 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, {}, 1, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, ( zx: number ): number => zx, 1, zy, 1, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot( zx.length, zx, '10', zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, true, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, false, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, null, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, undefined, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, [], zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, {}, zy, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, ( zx: number ): number => zx, zy, 1, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + + zdrot( zx.length, zx, 1, 10, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, '10', 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, true, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, false, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, null, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, undefined, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, [ '1' ], 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, {}, 1, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, ( zx: number ): number => zx, 1, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot( zx.length, zx, 1, zy, '10', 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, true, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, false, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, null, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, undefined, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, [], 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, {}, 0.8, 0.6 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, ( zx: number ): number => zx, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot( zx.length, zx, 1, zy, 1, '10', 0.8 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, true, 0.8 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, false, 0.8 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, null, 0.8 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, undefined, 0.8 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, [], 0.8 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, {}, 0.8 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, ( zx: number ): number => zx, 0.8 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot( zx.length, zx, 1, zy, 1, 0.8, '10' ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, 0.8, true ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, 0.8, false ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, 0.8, null ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, 0.8, undefined ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, 0.8, [] ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, 0.8, {} ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, 0.8, ( zx: number ): number => zx ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot(); // $ExpectError + zdrot( zx.length ); // $ExpectError + zdrot( zx.length, zx ); // $ExpectError + zdrot( zx.length, zx, 1 ); // $ExpectError + zdrot( zx.length, zx, 1, zy ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, 0.8 ); // $ExpectError + zdrot( zx.length, zx, 1, zy, 1, 0.8, 0.6, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectType Complex128Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot.ndarray( '10', zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( true, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( false, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( null, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( undefined, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( [], zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( {}, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( ( zx: number ): number => zx, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot.ndarray( zx.length, 10, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, '10', 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, true, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, false, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, null, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, undefined, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, [ '1' ], 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, {}, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, ( zx: number ): number => zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot.ndarray( zx.length, zx, '10', 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, true, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, false, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, null, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, undefined, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, [], 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, {}, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, ( zx: number ): number => zx, 0, zy, 1, 0, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot.ndarray( zx.length, zx, 1, '10', zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, true, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, false, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, null, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, undefined, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, [], zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, {}, zy, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, ( zx: number ): number => zx, zy, 1, 0, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + + zdrot.ndarray( zx.length, zx, 1, 0, 10, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, '10', 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, true, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, false, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, null, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, undefined, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, [ '1' ], 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, {}, 1, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, ( zx: number ): number => zx, 1, 0, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot.ndarray( zx.length, zx, 1, 0, zy, '10', 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, true, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, false, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, null, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, undefined, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, [], 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, {}, 0, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, ( zx: number ): number => zx, 0, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, '10', 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, true, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, false, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, null, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, undefined, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, [], 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, {}, 0.8, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, ( zx: number ): number => zx, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a eighth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, '10', 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, true, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, false, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, null, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, undefined, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, [], 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, {}, 0.6 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, ( zx: number ): number => zx, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, '10' ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, true ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, false ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, null ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, undefined ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, [] ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, {} ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, ( zx: number ): number => zx ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const zx = new Complex128Array( 10 ); + const zy = new Complex128Array( 10 ); + + zdrot.ndarray(); // $ExpectError + zdrot.ndarray( zx.length ); // $ExpectError + zdrot.ndarray( zx.length, zx ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8 ); // $ExpectError + zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, 0.6, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/zdrot/examples/c/Makefile new file mode 100644 index 00000000000..6aed70daf16 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/zdrot/examples/c/example.c new file mode 100644 index 00000000000..cf80bccc3b0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/examples/c/example.c @@ -0,0 +1,41 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/zdrot.h" +#include + +int main( void ) { + // Create strided arrays: + double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + double y[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + + // Specify the number of elements: + const int N = 4; + + // Specify stride lengths: + const int strideX = 1; + const int strideY = -1; + + c_zdrot( N, (void *)x, strideX, (void *)y, strideY, 0.8, 0.6 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "x[ %i ] = %lf + %lfj\n", i, x[ i*2 ], x[ (i*2)+1 ] ); + printf( "y[ %i ] = %lf + %lfj\n", i, y[ i*2 ], y[ (i*2)+1 ] ); + } +} diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/examples/index.js b/lib/node_modules/@stdlib/blas/base/zdrot/examples/index.js new file mode 100644 index 00000000000..c4bbaa0d6b1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/examples/index.js @@ -0,0 +1,39 @@ +/** +* @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'; + +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var zdrot = require( './../lib' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var zx = filledarrayBy( 10, 'complex128', rand ); +console.log( zx.get( 0 ).toString() ); + +var zy = filledarrayBy( 10, 'complex128', rand ); +console.log( zy.get( 0 ).toString() ); + +// Applies a plane rotation: +zdrot( zx.length, zx, 1, zy, 1, 0.8, 0.6 ); +console.log( zx.get( zx.length-1 ).toString() ); +console.log( zy.get( zy.length-1 ).toString() ); diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/include.gypi b/lib/node_modules/@stdlib/blas/base/zdrot/include.gypi new file mode 100644 index 00000000000..497aeca1532 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/include.gypi @@ -0,0 +1,70 @@ +# @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. + +# A GYP include file for building a Node.js native add-on. +# +# Note that nesting variables is required due to how GYP processes a configuration. Any variables defined within a nested 'variables' section is defined in the outer scope. Thus, conditions in the outer variable scope are free to use these variables without running into "variable undefined" errors. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +# +# Variable nesting hacks: +# +# [3]: https://chromium.googlesource.com/external/skia/gyp/+/master/common_variables.gypi +# [4]: https://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + 'variables': { + # Host BLAS library (to override -Dblas=): + 'blas%': '', + + # Path to BLAS library (to override -Dblas_dir=): + 'blas_dir%': '', + }, # end variables + + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<@(blas_dir)', + ' +* +* var re = real( z ); +* // returns ~-0.6 +* +* var im = imag( z ); +* // returns ~-1.2 +* +* z = zx.get( 0 ); +* // returns +* +* re = real( z ); +* // returns ~0.8 +* +* im = imag( z ); +* // returns ~1.6 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* var zdrot = require( '@stdlib/blas/base/zdrot' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* zdrot.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); +* +* var z = zy.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns ~-0.6 +* +* var im = imag( z ); +* // returns ~-1.2 +* +* z = zx.get( 0 ); +* // returns +* +* re = real( z ); +* // returns ~0.8 +* +* im = imag( z ); +* // returns ~1.6 +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var zdrot; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + zdrot = main; +} else { + zdrot = tmp; +} + + +// EXPORTS // + +module.exports = zdrot; + +// exports: { "ndarray": "zdrot.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/lib/main.js b/lib/node_modules/@stdlib/blas/base/zdrot/lib/main.js new file mode 100644 index 00000000000..43aa122fa19 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/lib/main.js @@ -0,0 +1,35 @@ +/** +* @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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var zdrot = require( './zdrot.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( zdrot, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = zdrot; diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/lib/native.js b/lib/node_modules/@stdlib/blas/base/zdrot/lib/native.js new file mode 100644 index 00000000000..29018fddd1b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/lib/native.js @@ -0,0 +1,35 @@ +/** +* @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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var zdrot = require( './zdrot.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( zdrot, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = zdrot; diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/zdrot/lib/ndarray.js new file mode 100644 index 00000000000..ffc33bfa380 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/lib/ndarray.js @@ -0,0 +1,108 @@ +/** +* @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 reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + + +// MAIN // + +/** +* Applies a plane rotation on complex double-precision floating-point vectors. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128Array} zx - first input array +* @param {integer} strideX - `zx` stride length +* @param {NonNegativeInteger} offsetX - starting `zx` index +* @param {Complex128Array} zy - second input array +* @param {integer} strideY - `zy` stride length +* @param {NonNegativeInteger} offsetY - starting `zy` index +* @param {number} c - cosine of the angle of rotation +* @param {number} s - sine of the angle of rotation +* @returns {Complex128Array} `zy` +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* zdrot( zx.length, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); +* +* var z = zy.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns ~-0.6 +* +* var im = imag( z ); +* // returns ~-1.2 +* +* z = zx.get( 0 ); +* // returns +* +* re = real( z ); +* // returns ~0.8 +* +* im = imag( z ); +* // returns ~1.6 +*/ +function zdrot( N, zx, strideX, offsetX, zy, strideY, offsetY, c, s ) { + var viewX; + var viewY; + var tmp1; + var tmp2; + var sx; + var sy; + var ix; + var iy; + var i; + + if ( N <= 0 ) { + return zy; + } + viewX = reinterpret( zx, 0 ); + viewY = reinterpret( zy, 0 ); + sx = strideX * 2; + sy = strideY * 2; + ix = offsetX * 2; + iy = offsetY * 2; + for ( i = 0; i < N; i++ ) { + tmp1 = ( c*viewX[ ix ] ) + ( s*viewY[ iy ] ); + viewY[ iy ] = ( c*viewY[ iy ] ) - ( s*viewX[ ix ] ); + viewX[ ix ] = tmp1; + + tmp2 = ( c*viewX[ ix+1 ] ) + ( s*viewY[ iy+1 ] ); + viewY[ iy+1 ] = ( c*viewY[ iy+1 ] ) - ( s*viewX[ ix+1 ] ); + viewX[ ix+1 ] = tmp2; + + ix += sx; + iy += sy; + } + return zy; +} + + +// EXPORTS // + +module.exports = zdrot; diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zdrot/lib/ndarray.native.js new file mode 100644 index 00000000000..338e4ad4858 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/lib/ndarray.native.js @@ -0,0 +1,89 @@ +/** +* @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 reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Applies a plane rotation on complex double-precision floating-point vectors. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128Array} zx - first input array +* @param {integer} strideX - `zx` stride length +* @param {NonNegativeInteger} offsetX - starting `zx` index +* @param {Complex128Array} zy - second input array +* @param {integer} strideY - `zy` stride length +* @param {NonNegativeInteger} offsetY - starting `zy` index +* @param {number} c - cosine of the angle of rotation +* @param {number} s - sine of the angle of rotation +* @returns {Complex128Array} `zy` +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* zdrot( zx.length, zx, 1, 0, zy, 1, 0, 0.8, 0.6 ); +* +* var z = zy.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns ~-0.6 +* +* var im = imag( z ); +* // returns ~-1.2 +* +* z = zx.get( 0 ); +* // returns +* +* re = real( z ); +* // returns ~0.8 +* +* im = imag( z ); +* // returns ~1.6 +*/ +function zdrot( N, zx, strideX, offsetX, zy, strideY, offsetY, c, s ) { + var viewX; + var viewY; + + offsetX = minViewBufferIndex( N, strideX, offsetX ); + offsetY = minViewBufferIndex( N, strideY, offsetY ); + + viewX = reinterpret( zx, offsetX ); + viewY = reinterpret( zy, offsetY ); + + addon( N, viewX, strideX, viewY, strideY, c, s ); + return zy; +} + + +// EXPORTS // + +module.exports = zdrot; diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/lib/zdrot.js b/lib/node_modules/@stdlib/blas/base/zdrot/lib/zdrot.js new file mode 100644 index 00000000000..e6d2633a7cf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/lib/zdrot.js @@ -0,0 +1,128 @@ +/** +* @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 reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + + +// MAIN // + +/** +* Applies a plane rotation on complex double-precision floating-point vectors. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128Array} zx - first input array +* @param {integer} strideX - `zx` stride length +* @param {Complex128Array} zy - second input array +* @param {integer} strideY - `zy` stride length +* @param {number} c - cosine of the angle of rotation +* @param {number} s - sine of the angle of rotation +* @returns {Complex128Array} `zy` +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* zdrot( zx.length, zx, 1, zy, 1, 0.8, 0.6 ); +* +* var z = zy.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns ~-0.6 +* +* var im = imag( z ); +* // returns ~-1.2 +* +* z = zx.get( 0 ); +* // returns +* +* re = real( z ); +* // returns ~0.8 +* +* im = imag( z ); +* // returns ~1.6 +*/ +function zdrot( N, zx, strideX, zy, strideY, c, s ) { + var viewX; + var viewY; + var tmp1; + var tmp2; + var sx; + var sy; + var ix; + var iy; + var i; + var j; + + if ( N <= 0 ) { + return zy; + } + viewX = reinterpret( zx, 0 ); + viewY = reinterpret( zy, 0 ); + if ( strideX === 1 && strideY === 1 ) { + for ( i = 0; i < N*2; i += 2 ) { + tmp1 = ( c*viewX[ i ] ) + ( s*viewY[ i ] ); + viewY[ i ] = ( c*viewY[ i ] ) - ( s*viewX[ i ] ); + viewX[ i ] = tmp1; + + j = i + 1; + tmp2 = ( c*viewX[ j ] ) + ( s*viewY[ j ] ); + viewY[ j ] = ( c*viewY[ j ] ) - ( s*viewX[ j ] ); + viewX[ j ] = tmp2; + } + return zy; + } + if ( strideX < 0 ) { + ix = 2 * (1-N) * strideX; + } else { + ix = 0; + } + if ( strideY < 0 ) { + iy = 2 * (1-N) * strideY; + } else { + iy = 0; + } + sx = strideX * 2; + sy = strideY * 2; + for ( i = 0; i < N; i++ ) { + tmp1 = ( c*viewX[ ix ] ) + ( s*viewY[ iy ] ); + viewY[ iy ] = ( c*viewY[ iy ] ) - ( s*viewX[ ix ] ); + viewX[ ix ] = tmp1; + + tmp2 = ( c*viewX[ ix+1 ] ) + ( s*viewY[ iy+1 ] ); + viewY[ iy+1 ] = ( c*viewY[ iy+1 ] ) - ( s*viewX[ ix+1 ] ); + viewX[ ix+1 ] = tmp2; + + ix += sx; + iy += sy; + } + return zy; +} + + +// EXPORTS // + +module.exports = zdrot; diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/lib/zdrot.native.js b/lib/node_modules/@stdlib/blas/base/zdrot/lib/zdrot.native.js new file mode 100644 index 00000000000..2d0fbd27343 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/lib/zdrot.native.js @@ -0,0 +1,79 @@ +/** +* @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 reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Applies a plane rotation on complex double-precision floating-point vectors. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128Array} zx - first input array +* @param {integer} strideX - `zx` stride length +* @param {Complex128Array} zy - second input array +* @param {integer} strideY - `zy` stride length +* @param {number} c - cosine of the angle of rotation +* @param {number} s - sine of the angle of rotation +* @returns {Complex128Array} `zy` +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var zy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* zdrot( zx.length, zx, 1, zy, 1, 0.8, 0.6 ); +* +* var z = zy.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns ~-0.6 +* +* var im = imag( z ); +* // returns ~-1.2 +* +* z = zx.get( 0 ); +* // returns +* +* re = real( z ); +* // returns ~0.8 +* +* im = imag( z ); +* // returns ~1.6 +*/ +function zdrot( N, zx, strideX, zy, strideY, c, s ) { + var viewX = reinterpret( zx, 0 ); + var viewY = reinterpret( zy, 0 ); + addon( N, viewX, strideX, viewY, strideY, c, s ); + return zy; +} + + +// EXPORTS // + +module.exports = zdrot; diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/manifest.json b/lib/node_modules/@stdlib/blas/base/zdrot/manifest.json new file mode 100644 index 00000000000..bcc2ce34cac --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/manifest.json @@ -0,0 +1,417 @@ +{ + "options": { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/zdrot.f", + "./src/zdrot_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/zdrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/zdrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zdrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zdrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zdrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/zdrot.f", + "./src/zdrot_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/zdrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/zdrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/zdrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/zdrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/zdrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zdrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zdrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zdrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/zdrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/zdrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/zdrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/zdrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/package.json b/lib/node_modules/@stdlib/blas/base/zdrot/package.json new file mode 100644 index 00000000000..0f82b6d9979 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/package.json @@ -0,0 +1,80 @@ +{ + "name": "@stdlib/blas/base/zdrot", + "version": "0.0.0", + "description": "Apply a plane rotation on complex double-precision floating-point vectors.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "level 1", + "linear", + "algebra", + "subroutines", + "zdrot", + "rotation", + "vector", + "typed", + "array", + "ndarray", + "complex", + "complex128", + "double", + "float64", + "float64array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/src/Makefile b/lib/node_modules/@stdlib/blas/base/zdrot/src/Makefile new file mode 100644 index 00000000000..bcf18aa4665 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/src/addon.c b/lib/node_modules/@stdlib/blas/base/zdrot/src/addon.c new file mode 100644 index 00000000000..5aeaab4cd21 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/src/addon.c @@ -0,0 +1,49 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/zdrot.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_complex128array.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 7 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 4 ); + STDLIB_NAPI_ARGV_DOUBLE( env, c, argv, 5 ); + STDLIB_NAPI_ARGV_DOUBLE( env, s, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, Y, N, strideY, argv, 3 ); + API_SUFFIX(c_zdrot)( N, (void *)X, strideX, (void *)Y, strideY, c, s ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot.c b/lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot.c new file mode 100644 index 00000000000..da90ce51d2a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot.c @@ -0,0 +1,86 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/zdrot.h" +#include "stdlib/blas/base/shared.h" + +/** +* Applies a plane rotation on complex double-precision floating-point vectors. +* +* @param N number of indexed elements +* @param ZX first input array +* @param strideX ZX stride length +* @param ZY second input array +* @param strideY ZY stride length +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_zdrot)( const CBLAS_INT N, void *ZX, const CBLAS_INT strideX, void *ZY, const CBLAS_INT strideY, const double c, const double s ) { + double *zx = (double *)ZX; + double *zy = (double *)ZY; + double tmp1; + double tmp2; + CBLAS_INT ix; + CBLAS_INT iy; + CBLAS_INT sx; + CBLAS_INT sy; + CBLAS_INT i; + CBLAS_INT j; + + if ( N <= 0 ) { + return; + } + if ( strideX == 1 && strideY == 1 ) { + for ( i = 0; i < N*2; i += 2 ) { + tmp1 = c*zx[ i ] + s*zy[ i ]; + zy[ i ] = c*zy[ i ] - s*zx[ i ]; + zx[ i ] = tmp1; + + j = i + 1; + tmp2 = c*zx[ j ] + s*zy[ j ]; + zy[ j ] = c*zy[ j ] - s*zx[ j ]; + zx[ j ] = tmp2; + } + return; + } + if ( strideX < 0 ) { + ix = 2 * (1-N) * strideX; + } else { + ix = 0; + } + if ( strideY < 0 ) { + iy = 2 * (1-N) * strideY; + } else { + iy = 0; + } + sx = strideX * 2; + sy = strideY * 2; + for ( i = 0; i < N; i++ ) { + tmp1 = c*zx[ ix ] + s*zy[ iy ]; + zy[ iy ] = c*zy[ iy ] - s*zx[ ix ]; + zx[ ix ] = tmp1; + + tmp2 = c*zx[ ix+1 ] + s*zy[ iy+1 ]; + zy[ iy+1 ] = c*zy[ iy+1 ] - s*zx[ ix+1 ]; + zx[ ix+1 ] = tmp2; + + ix += sx; + iy += sy; + } + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot.f b/lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot.f new file mode 100644 index 00000000000..b579890cb00 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot.f @@ -0,0 +1,102 @@ +!> +! @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. +!< + +!> Applies a plane rotation on complex double-precision floating-point vectors. +! +! ## Notes +! +! * Modified version of reference BLAS level1 routine (version 3.9.0). Updated to "free form" Fortran 95. +! +! ## Authors +! +! * Univ. of Tennessee +! * Univ. of California Berkeley +! * Univ. of Colorado Denver +! * NAG Ltd. +! +! ## History +! +! * Jack Dongarra, linpack, 3/11/78. +! +! - modified 12/3/93, array(1) declarations changed to array(*) +! +! ## License +! +! From : +! +! > The reference BLAS is a freely-available software package. It is available from netlib via anonymous ftp and the World Wide Web. Thus, it can be included in commercial software packages (and has been). We only ask that proper credit be given to the authors. +! > +! > Like all software, it is copyrighted. It is not trademarked, but we do ask the following: +! > +! > * If you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original. +! > +! > * We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support. +! +! @param {integer} N - number of indexed elements +! @param {Array} zx - first input array +! @param {integer} strideX - `zx` stride length +! @param {Array} zy - second input array +! @param {integer} strideY - `zy` stride length +! @param {double precision} c - cosine of the angle of rotation +! @param {double precision} s - sine of the angle of rotation +!< +subroutine zdrot( N, zx, strideX, zy, strideY, c, s ) + implicit none + ! .. + ! Scalar arguments: + integer :: strideX, strideY, N + double precision :: c, s + ! .. + ! Array arguments: + complex(kind=kind(0.0d0)) :: zx(*), zy(*) + ! .. + ! Local scalars: + integer :: ix, iy, i + complex(kind=kind(0.0d0)) :: ztmp + ! .. + if ( N <= 0 ) then + return + end if + ! .. + if ( strideX == 1 .AND. strideY == 1 ) then + do i = 1, N + ztmp = c*zx( i ) + s*zy( i ) + zy( i ) = c*zy( i ) - s*zx( i ) + zx( i ) = ztmp + end do + else + if ( strideX < 0 ) then + ix = ((1-N)*strideX) + 1 + else + ix = 1 + end if + if ( strideY < 0 ) then + iy = ((1-N)*strideY) + 1 + else + iy = 1 + end if + do i = 1, N + ztmp = c*zx( ix ) + s*zy( iy ) + zy( iy ) = c*zy( iy ) - s*zx( ix ) + zx( ix ) = ztmp + ix = ix + strideX + iy = iy + strideY + end do + end if + return +end subroutine zdrot diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot_cblas.c b/lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot_cblas.c new file mode 100644 index 00000000000..b66c9b39090 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot_cblas.c @@ -0,0 +1,36 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/zdrot.h" +#include "stdlib/blas/base/zdrot_cblas.h" +#include "stdlib/blas/base/shared.h" + +/** +* Applies a plane rotation on complex double-precision floating-point vectors. +* +* @param N number of indexed elements +* @param ZX first input array +* @param strideX ZX stride length +* @param ZY second input array +* @param strideY ZY stride length +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_zdrot)( const CBLAS_INT N, void *ZX, const CBLAS_INT strideX, void *ZY, const CBLAS_INT strideY, const double c, const double s ) { + API_SUFFIX(cblas_zdrot)( N, ZX, strideX, ZY, strideY, c, s ); +} diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot_f.c b/lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot_f.c new file mode 100644 index 00000000000..146a22f1ca0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/src/zdrot_f.c @@ -0,0 +1,36 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/zdrot.h" +#include "stdlib/blas/base/zdrot_fortran.h" +#include "stdlib/blas/base/shared.h" + +/** +* Applies a plane rotation on complex double-precision floating-point vectors. +* +* @param N number of indexed elements +* @param ZX first input array +* @param strideX ZX stride length +* @param ZY second input array +* @param strideY ZY stride length +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_zdrot)( const CBLAS_INT N, void *ZX, const CBLAS_INT strideX, void *ZY, const CBLAS_INT strideY, const double c, const double s ) { + zdrot( &N, ZX, &strideX, ZY, &strideY, &c, &s ); +} diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/test/test.js b/lib/node_modules/@stdlib/blas/base/zdrot/test/test.js new file mode 100644 index 00000000000..0664814195e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/test/test.js @@ -0,0 +1,82 @@ +/** +* @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 proxyquire = require( 'proxyquire' ); +var isBrowser = require( '@stdlib/assert/is-browser' ); +var zdrot = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': isBrowser +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zdrot, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof zdrot.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var zdrot = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zdrot, mock, 'returns native implementation' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var zdrot; + var main; + + main = require( './../lib/zdrot.js' ); + + zdrot = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zdrot, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/zdrot/test/test.ndarray.js new file mode 100644 index 00000000000..f6703e51da9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/test/test.ndarray.js @@ -0,0 +1,554 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var zdrot = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zdrot, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( zdrot.length, 9, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a plane rotation', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, // 2 + 4.0, // 2 + 5.0, // 3 + 6.0, // 3 + 7.0, // 4 + 8.0 // 4 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, // 3 + 0.0, // 3 + 0.0, // 4 + 0.0 // 4 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 2.4, // 2 + 3.2, // 2 + 4.0, // 3 + 4.8, // 3 + 5.6, // 4 + 6.4 // 4 + ] ); + cye = new Float64Array( [ + -0.6, // 1 + -1.2, // 1 + -1.8, // 2 + -2.4, // 2 + -3.0, // 3 + -3.6, // 3 + -4.2, // 4 + -4.8 // 4 + ] ); + + out = zdrot( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -0.6, // 1 + -1.2, // 1 + -3.0, // 2 + -3.6, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, 2, 0, cy, 1, 0, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, + 2.0, + 3.0, // 1 + 4.0, // 1 + 5.0, // 2 + 6.0, // 2 + 7.0, // 3 + 8.0 // 3 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, // 3 + 0.0, // 3 + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 1.0, + 2.0, + 2.4, // 1 + 3.2, // 1 + 4.0, // 2 + 4.8, // 2 + 5.6, // 3 + 6.4 // 3 + ] ); + cye = new Float64Array( [ + -1.8, // 1 + -2.4, // 1 + -3.0, // 2 + -3.6, // 2 + -4.2, // 3 + -4.8, // 3 + 0.0, + 0.0 + ] ); + + out = zdrot( 3, cx, 1, 1, cy, 1, 0, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, // 2 + 4.0, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 2.4, // 2 + 3.2, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + -1.8, // 2 + -2.4, // 2 + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, 1, 0, cy, 2, 0, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the destination array', function test( t ) { + var out; + var cx; + var cy; + + cx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + out = zdrot( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -3.0, // 2 + -3.6, // 2 + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, 2, 0, cy, -1, 1, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the destination array', function test( t ) { + var out; + var cx; + var cy; + + cx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + out = zdrot( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns both vectors unchanged', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var cx; + var cy; + + cx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cye = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + zdrot( -1, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + t.deepEqual( viewX, cxe, 'returns expected value' ); + t.deepEqual( viewY, cye, 'returns expected value' ); + + zdrot( 0, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + t.deepEqual( viewX, cxe, 'returns expected value' ); + t.deepEqual( viewY, cye, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 2 + 2.0, // 2 + 3.0, // 1 + 4.0, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 2 + 1.6, // 2 + 2.4, // 1 + 3.2, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -0.6, // 2 + -1.2, // 2 + 0.0, + 0.0, + -1.8, // 1 + -2.4, // 1 + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, -1, 1, cy, -2, 2, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 1.0, + 2.0, + 2.4, // 1 + 3.2, // 1 + 5.0, + 6.0, + 5.6, // 2 + 6.4 // 2 + ] ); + cye = new Float64Array( [ + 0.0, + 0.0, + 0.0, + 0.0, + -1.8, // 1 + -2.4, // 1 + -4.2, // 2 + -4.8 // 2 + ] ); + + out = zdrot( 2, cx, 2, 1, cy, 1, 2, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zdrot/test/test.ndarray.native.js new file mode 100644 index 00000000000..96c8e946003 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/test/test.ndarray.native.js @@ -0,0 +1,563 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var zdrot = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( zdrot instanceof Error ) +}; + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zdrot, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', opts, function test( t ) { + t.strictEqual( zdrot.length, 9, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a plane rotation', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, // 2 + 4.0, // 2 + 5.0, // 3 + 6.0, // 3 + 7.0, // 4 + 8.0 // 4 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, // 3 + 0.0, // 3 + 0.0, // 4 + 0.0 // 4 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 2.4, // 2 + 3.2, // 2 + 4.0, // 3 + 4.8, // 3 + 5.6, // 4 + 6.4 // 4 + ] ); + cye = new Float64Array( [ + -0.6, // 1 + -1.2, // 1 + -1.8, // 2 + -2.4, // 2 + -3.0, // 3 + -3.6, // 3 + -4.2, // 4 + -4.8 // 4 + ] ); + + out = zdrot( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -0.6, // 1 + -1.2, // 1 + -3.0, // 2 + -3.6, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, 2, 0, cy, 1, 0, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, + 2.0, + 3.0, // 1 + 4.0, // 1 + 5.0, // 2 + 6.0, // 2 + 7.0, // 3 + 8.0 // 3 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, // 3 + 0.0, // 3 + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 1.0, + 2.0, + 2.4, // 1 + 3.2, // 1 + 4.0, // 2 + 4.8, // 2 + 5.6, // 3 + 6.4 // 3 + ] ); + cye = new Float64Array( [ + -1.8, // 1 + -2.4, // 1 + -3.0, // 2 + -3.6, // 2 + -4.2, // 3 + -4.8, // 3 + 0.0, + 0.0 + ] ); + + out = zdrot( 3, cx, 1, 1, cy, 1, 0, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, // 2 + 4.0, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 2.4, // 2 + 3.2, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + -1.8, // 2 + -2.4, // 2 + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, 1, 0, cy, 2, 0, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -3.0, // 2 + -3.6, // 2 + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, 2, 0, cy, -1, 1, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the destination array', opts, function test( t ) { + var out; + var cx; + var cy; + + cx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + out = zdrot( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the destination array', opts, function test( t ) { + var out; + var cx; + var cy; + + cx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + out = zdrot( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns both vectors unchanged', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var cx; + var cy; + + cx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cye = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + zdrot( -1, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + t.deepEqual( viewX, cxe, 'returns expected value' ); + t.deepEqual( viewY, cye, 'returns expected value' ); + + zdrot( 0, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + t.deepEqual( viewX, cxe, 'returns expected value' ); + t.deepEqual( viewY, cye, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 2 + 2.0, // 2 + 3.0, // 1 + 4.0, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 2 + 1.6, // 2 + 2.4, // 1 + 3.2, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -0.6, // 2 + -1.2, // 2 + 0.0, + 0.0, + -1.8, // 1 + -2.4, // 1 + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, -1, 1, cy, -2, 2, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 1.0, + 2.0, + 2.4, // 1 + 3.2, // 1 + 5.0, + 6.0, + 5.6, // 2 + 6.4 // 2 + ] ); + cye = new Float64Array( [ + 0.0, + 0.0, + 0.0, + 0.0, + -1.8, // 1 + -2.4, // 1 + -4.2, // 2 + -4.8 // 2 + ] ); + + out = zdrot( 2, cx, 2, 1, cy, 1, 2, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/test/test.zdrot.js b/lib/node_modules/@stdlib/blas/base/zdrot/test/test.zdrot.js new file mode 100644 index 00000000000..76a9da3564a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/test/test.zdrot.js @@ -0,0 +1,486 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var zdrot = require( './../lib/zdrot.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zdrot, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( zdrot.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a plane rotation', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, // 2 + 4.0, // 2 + 5.0, // 3 + 6.0, // 3 + 7.0, // 4 + 8.0 // 4 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, // 3 + 0.0, // 3 + 0.0, // 4 + 0.0 // 4 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 2.4, // 2 + 3.2, // 2 + 4.0, // 3 + 4.8, // 3 + 5.6, // 4 + 6.4 // 4 + ] ); + cye = new Float64Array( [ + -0.6, // 1 + -1.2, // 1 + -1.8, // 2 + -2.4, // 2 + -3.0, // 3 + -3.6, // 3 + -4.2, // 4 + -4.8 // 4 + ] ); + + out = zdrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -0.6, // 1 + -1.2, // 1 + -3.0, // 2 + -3.6, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, 2, cy, 1, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, // 2 + 4.0, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 2.4, // 2 + 3.2, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + -1.8, // 2 + -2.4, // 2 + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, 1, cy, 2, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the destination array', function test( t ) { + var out; + var cx; + var cy; + + cx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + out = zdrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); + + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns both vectors unchanged', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var cx; + var cy; + + cx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cye = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + zdrot( -1, cx, 1, cy, 1, 0.8, 0.6 ); + t.deepEqual( viewX, cxe, 'returns expected value' ); + t.deepEqual( viewY, cye, 'returns expected value' ); + + zdrot( 0, cx, 1, cy, 1, 0.8, 0.6 ); + t.deepEqual( viewX, cxe, 'returns expected value' ); + t.deepEqual( viewY, cye, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 2 + 2.0, // 2 + 3.0, // 1 + 4.0, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 2 + 1.6, // 2 + 2.4, // 1 + 3.2, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -0.6, // 2 + -1.2, // 2 + 0.0, + 0.0, + -1.8, // 1 + -2.4, // 1 + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, -1, cy, -2, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -3.0, // 2 + -3.6, // 2 + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, 2, cy, -1, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var viewX; + var viewY; + var cx0; + var cy0; + var cx1; + var cy1; + var cxe; + var cye; + var out; + + // Initial arrays... + cx0 = new Complex128Array([ + 1.0, + 2.0, + 3.0, // 2 + 4.0, // 2 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + cy0 = new Complex128Array([ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0 // 2 + ]); + + // Create offset views... + cx1 = new Complex128Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + cy1 = new Complex128Array( cy0.buffer, cy0.BYTES_PER_ELEMENT*2 ); // begin at the 3rd element + + viewX = new Float64Array( cx0.buffer ); + viewY = new Float64Array( cy0.buffer ); + + cxe = new Float64Array( [ + 1.0, + 2.0, + 2.4, // 2 + 3.2, // 2 + 5.0, + 6.0, + 5.6, // 1 + 6.4 // 1 + ] ); + cye = new Float64Array( [ + 0.0, + 0.0, + 0.0, + 0.0, + -4.2, // 1 + -4.8, // 1 + -1.8, // 2 + -2.4 // 2 + ] ); + + out = zdrot( 2, cx1, -2, cy1, 1, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy1, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/test/test.zdrot.native.js b/lib/node_modules/@stdlib/blas/base/zdrot/test/test.zdrot.native.js new file mode 100644 index 00000000000..8e0212b1ebc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdrot/test/test.zdrot.native.js @@ -0,0 +1,495 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var zdrot = tryRequire( resolve( __dirname, './../lib/zdrot.native.js' ) ); +var opts = { + 'skip': ( zdrot instanceof Error ) +}; + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zdrot, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', opts, function test( t ) { + t.strictEqual( zdrot.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a plane rotation', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, // 2 + 4.0, // 2 + 5.0, // 3 + 6.0, // 3 + 7.0, // 4 + 8.0 // 4 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, // 3 + 0.0, // 3 + 0.0, // 4 + 0.0 // 4 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 2.4, // 2 + 3.2, // 2 + 4.0, // 3 + 4.8, // 3 + 5.6, // 4 + 6.4 // 4 + ] ); + cye = new Float64Array( [ + -0.6, // 1 + -1.2, // 1 + -1.8, // 2 + -2.4, // 2 + -3.0, // 3 + -3.6, // 3 + -4.2, // 4 + -4.8 // 4 + ] ); + + out = zdrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -0.6, // 1 + -1.2, // 1 + -3.0, // 2 + -3.6, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, 2, cy, 1, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, // 2 + 4.0, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 2.4, // 2 + 3.2, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + -1.8, // 2 + -2.4, // 2 + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, 1, cy, 2, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the destination array', opts, function test( t ) { + var out; + var cx; + var cy; + + cx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + out = zdrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); + + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns both vectors unchanged', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var cx; + var cy; + + cx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cye = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + zdrot( -1, cx, 1, cy, 1, 0.8, 0.6 ); + t.deepEqual( viewX, cxe, 'returns expected value' ); + t.deepEqual( viewY, cye, 'returns expected value' ); + + zdrot( 0, cx, 1, cy, 1, 0.8, 0.6 ); + t.deepEqual( viewX, cxe, 'returns expected value' ); + t.deepEqual( viewY, cye, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 2 + 2.0, // 2 + 3.0, // 1 + 4.0, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 2 + 1.6, // 2 + 2.4, // 1 + 3.2, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -0.6, // 2 + -1.2, // 2 + 0.0, + 0.0, + -1.8, // 1 + -2.4, // 1 + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, -1, cy, -2, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', opts, function test( t ) { + var viewX; + var viewY; + var cxe; + var cye; + var out; + var cx; + var cy; + + cx = new Complex128Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex128Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float64Array( cx.buffer ); + viewY = new Float64Array( cy.buffer ); + + cxe = new Float64Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float64Array( [ + -3.0, // 2 + -3.6, // 2 + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = zdrot( 2, cx, 2, cy, -1, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var viewX; + var viewY; + var cx0; + var cy0; + var cx1; + var cy1; + var cxe; + var cye; + var out; + + // Initial arrays... + cx0 = new Complex128Array([ + 1.0, + 2.0, + 3.0, // 2 + 4.0, // 2 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + cy0 = new Complex128Array([ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0 // 2 + ]); + + // Create offset views... + cx1 = new Complex128Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + cy1 = new Complex128Array( cy0.buffer, cy0.BYTES_PER_ELEMENT*2 ); // begin at the 3rd element + + viewX = new Float64Array( cx0.buffer ); + viewY = new Float64Array( cy0.buffer ); + + cxe = new Float64Array( [ + 1.0, + 2.0, + 2.4, // 2 + 3.2, // 2 + 5.0, + 6.0, + 5.6, // 1 + 6.4 // 1 + ] ); + cye = new Float64Array( [ + 0.0, + 0.0, + 0.0, + 0.0, + -4.2, // 1 + -4.8, // 1 + -1.8, // 2 + -2.4 // 2 + ] ); + + out = zdrot( 2, cx1, -2, cy1, 1, 0.8, 0.6 ); + isApprox( t, viewX, cxe, 2.0 ); + isApprox( t, viewY, cye, 2.0 ); + t.strictEqual( out, cy1, 'returns expected value' ); + t.end(); +});