From f1221cf4a30a973714349a831a067477f19fe7c6 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Tue, 21 May 2024 20:10:36 +0530 Subject: [PATCH 01/14] feat: add BLAS Level 1 routine for csrot --- .../@stdlib/blas/base/csrot/README.md | 385 ++++++++++++ .../blas/base/csrot/benchmark/benchmark.js | 113 ++++ .../base/csrot/benchmark/benchmark.native.js | 118 ++++ .../base/csrot/benchmark/benchmark.ndarray.js | 113 ++++ .../benchmark/benchmark.ndarray.native.js | 118 ++++ .../blas/base/csrot/benchmark/c/Makefile | 146 +++++ .../base/csrot/benchmark/c/benchmark.length.c | 153 +++++ .../base/csrot/benchmark/fortran/Makefile | 141 +++++ .../benchmark/fortran/benchmark.length.f | 211 +++++++ .../@stdlib/blas/base/csrot/binding.gyp | 265 +++++++++ .../blas/base/csrot/docs/types/index.d.ts | 189 ++++++ .../blas/base/csrot/docs/types/test.ts | 312 ++++++++++ .../blas/base/csrot/examples/c/Makefile | 146 +++++ .../blas/base/csrot/examples/c/example.c | 41 ++ .../@stdlib/blas/base/csrot/examples/index.js | 39 ++ .../@stdlib/blas/base/csrot/include.gypi | 70 +++ .../csrot/include/stdlib/blas/base/csrot.h | 43 ++ .../include/stdlib/blas/base/csrot_cblas.h | 43 ++ .../include/stdlib/blas/base/csrot_fortran.h | 41 ++ .../@stdlib/blas/base/csrot/lib/csrot.js | 128 ++++ .../blas/base/csrot/lib/csrot.native.js | 79 +++ .../@stdlib/blas/base/csrot/lib/index.js | 108 ++++ .../@stdlib/blas/base/csrot/lib/main.js | 35 ++ .../@stdlib/blas/base/csrot/lib/native.js | 35 ++ .../@stdlib/blas/base/csrot/lib/ndarray.js | 108 ++++ .../blas/base/csrot/lib/ndarray.native.js | 89 +++ .../@stdlib/blas/base/csrot/manifest.json | 417 +++++++++++++ .../@stdlib/blas/base/csrot/package.json | 81 +++ .../@stdlib/blas/base/csrot/src/Makefile | 70 +++ .../@stdlib/blas/base/csrot/src/addon.c | 49 ++ .../@stdlib/blas/base/csrot/src/csrot.c | 86 +++ .../@stdlib/blas/base/csrot/src/csrot.f | 102 ++++ .../@stdlib/blas/base/csrot/src/csrot_cblas.c | 36 ++ .../@stdlib/blas/base/csrot/src/csrot_f.c | 36 ++ .../blas/base/csrot/test/test.csrot.js | 486 +++++++++++++++ .../blas/base/csrot/test/test.csrot.native.js | 495 +++++++++++++++ .../@stdlib/blas/base/csrot/test/test.js | 82 +++ .../blas/base/csrot/test/test.ndarray.js | 554 +++++++++++++++++ .../base/csrot/test/test.ndarray.native.js | 563 ++++++++++++++++++ 39 files changed, 6326 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/benchmark/fortran/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/benchmark/fortran/benchmark.length.f create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.native.js diff --git a/lib/node_modules/@stdlib/blas/base/csrot/README.md b/lib/node_modules/@stdlib/blas/base/csrot/README.md new file mode 100644 index 000000000000..01d691e6398f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/README.md @@ -0,0 +1,385 @@ + + +# csrot + +> Applies a plane rotation. + +
+ +## Usage + +```javascript +var csrot = require( '@stdlib/blas/base/csrot' ); +``` + +#### csrot( N, cx, strideX, cy, strideY, c, s ) + +Applies a plane rotation. + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); +var realf = require( '@stdlib/complex/realf' ); +var imagf = require( '@stdlib/complex/imagf' ); + +var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +csrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); + +var z = cy.get( 0 ); +// returns + +var re = realf( z ); +// returns ~-0.6 + +var im = imagf( z ); +// returns ~-1.2 + +z = cx.get( 0 ); +// returns + +re = realf( z ); +// returns ~0.8 + +im = imagf( z ); +// returns ~1.6 +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **cx**: first input [`Complex64Array`][@stdlib/array/complex64]. +- **strideX**: index increment for `cx`. +- **cy**: second input [`Complex64Array`][@stdlib/array/complex64]. +- **strideY**: index increment for `cy`. + +The `N` and stride parameters determine how values from `cx` and `cy` are rotated. For example, to apply a plane rotation to every other element, + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); +var realf = require( '@stdlib/complex/realf' ); +var imagf = require( '@stdlib/complex/imagf' ); + +var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +csrot( 2, cx, 2, cy, 2, 0.8, 0.6 ); + +var z = cy.get( 0 ); +// returns + +var re = realf( z ); +// returns ~-0.6 + +var im = imagf( z ); +// returns ~-1.2 + +z = cx.get( 0 ); +// returns + +re = realf( z ); +// returns ~0.8 + +im = imagf( 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 Complex64Array = require( '@stdlib/array/complex64' ); +var realf = require( '@stdlib/complex/realf' ); +var imagf = require( '@stdlib/complex/imagf' ); + +// Initial arrays... +var cx0 = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var cy0 = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Create offset views... +var cx1 = new Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var cy1 = new Complex64Array( cy0.buffer, cy0.BYTES_PER_ELEMENT*2 ); // start at 3rd element + +csrot( 2, cx1, -2, cy1, 1, 0.8, 0.6 ); + +var z = cy0.get( 2 ); +// returns + +var re = realf( z ); +// returns ~-4.2 + +var im = imagf( z ); +// returns ~-4.8 + +z = cx0.get( 3 ); +// returns + +re = realf( z ); +// returns ~5.6 + +im = imagf( z ); +// returns ~6.4 +``` + +#### csrot.ndarray( N, cx, strideX, offsetX, cy, strideY, offsetY, c, s ) + +Applies a plane rotation using alternative indexing semantics. + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); +var realf = require( '@stdlib/complex/realf' ); +var imagf = require( '@stdlib/complex/imagf' ); + +var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + +var z = cy.get( 0 ); +// returns + +var re = realf( z ); +// returns ~-0.6 + +var im = imagf( z ); +// returns ~-1.2 + +z = cx.get( 0 ); +// returns + +re = realf( z ); +// returns ~0.8 + +im = imagf( z ); +// returns ~1.6 +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `cx`. +- **offsetY**: starting index for `cy`. + +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 Complex64Array = require( '@stdlib/array/complex64' ); +var realf = require( '@stdlib/complex/realf' ); +var imagf = require( '@stdlib/complex/imagf' ); + +var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +csrot.ndarray( 2, cx, 2, 1, cy, 2, 1, 0.8, 0.6 ); + +var z = cy.get( 3 ); +// returns + +var re = realf( z ); +// returns ~-4.2 + +var im = imagf( z ); +// returns ~-4.8 + +z = cx.get( 1 ); +// returns + +re = realf( z ); +// returns ~2.4 + +im = imagf( z ); +// returns ~3.2 +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions leave `cx` and `cy` unchanged. +- `csrot()` corresponds to the [BLAS][blas] level 1 function [`csrot`][csrot]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex64 = require( '@stdlib/complex/float32' ); +var csrot = require( '@stdlib/blas/base/csrot' ); + +function rand() { + return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var cx = filledarrayBy( 10, 'complex64', rand ); +console.log( cx.get( 0 ).toString() ); + +var cy = filledarrayBy( 10, 'complex64', rand ); +console.log( cy.get( 0 ).toString() ); + +// Apply a plane rotation: +csrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); +console.log( cx.get( cx.length-1 ).toString() ); +console.log( cy.get( cy.length-1 ).toString() ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/csrot.h" +``` + +#### c_csrot( N, \*X, strideX, \*Y, strideY, c, s ) + +Applies a plane rotation. + +```c +float x[] = { 1.0f, 2.0f, 3.0f, 4.0f }; // interleaved real and imaginary components +float y[] = { 5.0f, 6.0f, 7.0f, 8.0f }; + +c_csrot( 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. +- **CX**: `[inout] void*` first input array. +- **strideX**: `[in] CBLAS_INT` index increment for `CX`. +- **CY**: `[inout] void*` first input array. +- **strideY**: `[in] CBLAS_INT` index increment for `CY`. +- **c**: `[in] float` cosine of the angle of rotation. +- **s**: `[in] float` sine of the angle of rotation. + +```c +void c_csrot( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const float c, const float s ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/csrot.h" +#include + +int main( void ) { + // Create strided arrays: + float cx[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + float cy[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + + // Specify the number of elements: + const int N = 4; + + // Specify stride lengths: + const int strideX = 1; + const int strideY = -1; + + // Copy elements: + c_csrot( N, (void *)cx, strideX, (void *)cy, strideY, 0.8, 0.6 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "cx[ %i ] = %f + %fj\n", i, cx[ i*2 ], cx[ (i*2)+1 ] ); + printf( "cy[ %i ] = %f + %fj\n", i, cy[ i*2 ], cy[ (i*2)+1 ] ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.js new file mode 100644 index 000000000000..4222249b9551 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 Complex64Array = require( '@stdlib/array/complex64' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +var pkg = require( './../package.json' ).name; +var csrot = require( './../lib/csrot.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var cx; + var cy; + + cx = uniform( len*2, -100.0, 100.0, options ); + cx = new Complex64Array( cx.buffer ); + + cy = uniform( len*2, -100.0, 100.0, options ); + cy = new Complex64Array( cy.buffer ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var viewX; + var i; + + viewX = reinterpret( cx, 0 ); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + csrot( cx.length, cx, 1, cy, 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/csrot/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.native.js new file mode 100644 index 000000000000..fc4326d0ee71 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 Complex64Array = require( '@stdlib/array/complex64' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var csrot = tryRequire( resolve( __dirname, './../lib/csrot.native.js' ) ); +var opts = { + 'skip': ( csrot instanceof Error ) +}; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var cx; + var cy; + + cx = uniform( len*2, -100.0, 100.0, options ); + cx = new Complex64Array( cx.buffer ); + + cy = uniform( len*2, -100.0, 100.0, options ); + cy = new Complex64Array( cy.buffer ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var viewX; + var i; + + viewX = reinterpret( cx, 0 ); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + csrot( cx.length, cx, 1, cy, 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/csrot/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..6f150c0277cd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 Complex64Array = require( '@stdlib/array/complex64' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +var pkg = require( './../package.json' ).name; +var csrot = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var cx; + var cy; + + cx = uniform( len*2, -100.0, 100.0, options ); + cx = new Complex64Array( cx.buffer ); + + cy = uniform( len*2, -100.0, 100.0, options ); + cy = new Complex64Array( cy.buffer ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var viewX; + var i; + + viewX = reinterpret( cx, 0 ); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + csrot( cx.length, cx, 1, 0, cy, 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/csrot/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..9759af4ae47e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 Complex64Array = require( '@stdlib/array/complex64' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var csrot = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( csrot instanceof Error ) +}; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var cx; + var cy; + + cx = uniform( len*2, -100.0, 100.0, options ); + cx = new Complex64Array( cx.buffer ); + + cy = uniform( len*2, -100.0, 100.0, options ); + cy = new Complex64Array( cy.buffer ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var viewX; + var i; + + viewX = reinterpret( cx, 0 ); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + csrot( cx.length, cx, 1, 0, cy, 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/csrot/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/c/Makefile new file mode 100644 index 000000000000..9f97140e7cb0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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/csrot/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..f258dfdf0e79 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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/csrot.h" +#include +#include +#include +#include +#include + +#define NAME "csrot" +#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 +*/ +float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* 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; + float x[ len*2 ]; + float y[ len*2 ]; + double t; + int i; + + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_float()*10000.0f ) - 5000.0f; + x[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f; + y[ i ] = ( rand_float()*10000.0f ) - 5000.0f; + y[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_csrot( 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/csrot/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/fortran/Makefile new file mode 100644 index 000000000000..c93ba96c589e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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/csrot.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/csrot/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/fortran/benchmark.length.f new file mode 100644 index 000000000000..c4937c810ffb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 = 'csrot' ! 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 csrot( N, cx, strideX, cy, strideY, c, s ) + complex :: cx(*), cy(*) + integer :: strideX, strideY, N + real :: c, s + end subroutine csrot + end interface + ! .. + ! Scalar arguments: + integer, intent(in) :: iterations, len + ! .. + ! Local scalars: + double precision :: elapsed, r1, r2 + real :: t1, t2 + integer :: i + ! .. + ! Local arrays: + complex, 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( (real(r1)*10000.0)-5000.0, (real(r2)*1000.0)-5000.0 ) + y( i ) = cmplx( (real(r1)*10000.0)-5000.0, (real(r2)*1000.0)-5000.0 ) + end do + ! .. + call cpu_time( t1 ) + ! .. + do i = 1, iterations + call csrot( len, x, 1, y, 1, 0.8, 0.6 ); + 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/csrot/binding.gyp b/lib/node_modules/@stdlib/blas/base/csrot/binding.gyp new file mode 100644 index 000000000000..02a2799da097 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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/csrot/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts new file mode 100644 index 000000000000..08a87d31caf1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 { Complex64Array } from '@stdlib/types/array'; + +/** +* Interface describing `csrot`. +*/ +interface Routine { + /** + * Applies a plane rotation. + * + * @param N - number of indexed elements + * @param cx - first input array + * @param strideX - `cx` stride length + * @param cy - second input array + * @param strideY - `cy` stride length + * @param c - cosine of the angle of rotation + * @param s - sine of the angle of rotation + * @returns `cy` + * + * @example + * var Complex64Array = require( '@stdlib/array/complex64' ); + * var realf = require( '@stdlib/complex/realf' ); + * var imagf = require( '@stdlib/complex/imagf' ); + * + * var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + * var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + * + * csrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); + * + * var z = cy.get( 0 ); + * // returns + * + * var re = realf( z ); + * // returns -0.6 + * + * var im = imagf( z ); + * // returns -1.2 + * + * z = cx.get( 0 ); + * // returns + * + * re = realf( z ); + * // returns 0.8 + * + * im = imagf( z ); + * // returns 1.6 + */ + ( N: number, cx: Complex64Array, strideX: number, cy: Complex64Array, strideY: number, c: number, s: number ): Complex64Array; + + /** + * Applies a plane rotation using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param cx - first input array + * @param strideX - `cx` stride length + * @param offsetX - starting index for `cx` + * @param cy - second input array + * @param strideY - `cy` stride length + * @param offsetY - starting index for `cy` + * @param c - cosine of the angle of rotation + * @param s - sine of the angle of rotation + * @returns `cy` + * + * @example + * var Complex64Array = require( '@stdlib/array/complex64' ); + * var realf = require( '@stdlib/complex/realf' ); + * var imagf = require( '@stdlib/complex/imagf' ); + * + * var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + * var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + * + * csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + * + * var z = cy.get( 0 ); + * // returns + * + * var re = realf( z ); + * // returns -0.6 + * + * var im = imagf( z ); + * // returns -1.2 + * + * z = cx.get( 0 ); + * // returns + * + * re = realf( z ); + * // returns 0.8 + * + * im = imagf( z ); + * // returns 1.6 + */ + ndarray( N: number, cx: Complex64Array, strideX: number, offsetX: number, cy: Complex64Array, strideY: number, offsetY: number, c: number, s: number ): Complex64Array; +} + +/** +* Applies a plane rotation. +* +* @param N - number of indexed elements +* @param cx - first input array +* @param strideX - `cx` stride length +* @param cy - second input array +* @param strideY - `cy` stride length +* @param c - cosine of the angle of rotation +* @param s - sine of the angle of rotation +* @returns `cy` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* csrot( 2, cx, 2, cy, 1, 0.8, 0.6 ); +* +* var z = cy.get( 0 ); +* // returns +* +* var re = realf( z ); +* // returns -0.6 +* +* var im = imagf( z ); +* // returns -1.2 +* +* z = cx.get( 0 ); +* // returns +* +* re = realf( z ); +* // returns 0.8 +* +* im = imagf( z ); +* // returns 1.6 +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* csrot.ndarray( 2, cx, 2, 0, cy, 1, 0, 0.8, 0.6 ); +* +* var z = cy.get( 0 ); +* // returns +* +* var re = realf( z ); +* // returns -0.6 +* +* var im = imagf( z ); +* // returns -1.2 +* +* z = cx.get( 0 ); +* // returns +* +* re = realf( z ); +* // returns 0.8 +* +* im = imagf( z ); +* // returns 1.6 +*/ +declare var csrot: Routine; + + +// EXPORTS // + +export = csrot; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/csrot/docs/types/test.ts new file mode 100644 index 000000000000..ac30896fcfba --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 Complex64Array = require( '@stdlib/array/complex64' ); +import csrot = require( './index' ); + + +// TESTS // + +// The function returns a Complex64Array... +{ + const cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); // $ExpectType Complex64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot( '10', cx, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( true, cx, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( false, cx, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( null, cx, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( undefined, cx, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( [], cx, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( {}, cx, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( ( cx: number ): number => cx, cx, 1, cy, 1, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Complex64Array... +{ + const cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot( cx.length, 10, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, '10', 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, true, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, false, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, null, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, undefined, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, [ '1' ], 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, {}, 1, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, ( cx: number ): number => cx, 1, cy, 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 cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot( cx.length, cx, '10', cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, true, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, false, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, null, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, undefined, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, [], cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, {}, cy, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, ( cx: number ): number => cx, cy, 1, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Complex64Array... +{ + const cx = new Complex64Array( 10 ); + + csrot( cx.length, cx, 1, 10, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, '10', 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, true, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, false, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, null, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, undefined, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, [ '1' ], 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, {}, 1, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, ( cx: number ): number => cx, 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 cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot( cx.length, cx, 1, cy, '10', 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, cy, true, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, cy, false, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, cy, null, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, cy, undefined, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, cy, [], 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, cy, {}, 0.8, 0.6 ); // $ExpectError + csrot( cx.length, cx, 1, cy, ( cx: number ): number => cx, 0.8, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot( cx.length, cx, 1, cy, 1, '10', 0.8 ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, true, 0.8 ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, false, 0.8 ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, null, 0.8 ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, undefined, 0.8 ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, [], 0.8 ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, {}, 0.8 ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, ( cx: number ): number => cx, 0.8 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot( cx.length, cx, 1, cy, 1, 0.8, '10' ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, 0.8, true ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, 0.8, false ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, 0.8, null ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, 0.8, undefined ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, 0.8, [] ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, 0.8, {} ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, 0.8, ( cx: number ): number => cx ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot(); // $ExpectError + csrot( cx.length ); // $ExpectError + csrot( cx.length, cx ); // $ExpectError + csrot( cx.length, cx, 1 ); // $ExpectError + csrot( cx.length, cx, 1, cy ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, 0.8 ); // $ExpectError + csrot( cx.length, cx, 1, cy, 1, 0.8, 0.6, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Complex64Array... +{ + const cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectType Complex64Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot.ndarray( '10', cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( true, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( false, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( null, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( undefined, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( [], cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( {}, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( ( cx: number ): number => cx, cx, 1, 0, cy, 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 Complex64Array... +{ + const cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot.ndarray( cx.length, 10, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, '10', 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, true, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, false, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, null, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, undefined, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, [ '1' ], 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, {}, 1, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, ( cx: number ): number => cx, 1, 0, cy, 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 cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot.ndarray( cx.length, cx, '10', 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, true, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, false, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, null, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, undefined, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, [], 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, {}, 0, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, ( cx: number ): number => cx, 0, cy, 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 cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot.ndarray( cx.length, cx, 1, '10', cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, true, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, false, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, null, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, undefined, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, [], cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, {}, cy, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, ( cx: number ): number => cx, cy, 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 Complex64Array... +{ + const cx = new Complex64Array( 10 ); + + csrot.ndarray( cx.length, cx, 1, 0, 10, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, '10', 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, true, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, false, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, null, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, undefined, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, [ '1' ], 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, {}, 1, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, ( cx: number ): number => cx, 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 cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot.ndarray( cx.length, cx, 1, 0, cy, '10', 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, true, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, false, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, null, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, undefined, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, [], 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, {}, 0, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, ( cx: number ): number => cx, 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 cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, '10', 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, true, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, false, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, null, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, undefined, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, [], 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, {}, 0.8, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, ( cx: number ): number => cx, 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 cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, '10', 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, true, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, false, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, null, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, undefined, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, [], 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, {}, 0.6 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, ( cx: number ): number => cx, 0.6 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... +{ + const cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, '10' ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, true ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, false ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, null ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, undefined ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, [] ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, {} ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, ( cx: number ): number => cx ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const cx = new Complex64Array( 10 ); + const cy = new Complex64Array( 10 ); + + csrot.ndarray(); // $ExpectError + csrot.ndarray( cx.length ); // $ExpectError + csrot.ndarray( cx.length, cx ); // $ExpectError + csrot.ndarray( cx.length, cx, 1 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8 ); // $ExpectError + csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/csrot/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/csrot/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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/csrot/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/csrot/examples/c/example.c new file mode 100644 index 000000000000..07c6ddfb812d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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/csrot.h" +#include + +int main( void ) { + // Create strided arrays: + float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + float y[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + + // Specify the number of elements: + const int N = 4; + + // Specify stride lengths: + const int strideX = 1; + const int strideY = -1; + + c_csrot( N, (void *)x, strideX, (void *)y, strideY, 0.8, 0.6 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "x[ %i ] = %f + %fj\n", i, x[ i*2 ], x[ (i*2)+1 ] ); + printf( "y[ %i ] = %f + %fj\n", i, y[ i*2 ], y[ (i*2)+1 ] ); + } +} diff --git a/lib/node_modules/@stdlib/blas/base/csrot/examples/index.js b/lib/node_modules/@stdlib/blas/base/csrot/examples/index.js new file mode 100644 index 000000000000..fcbad08b9fea --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 Complex64 = require( '@stdlib/complex/float32' ); +var csrot = require( './../lib' ); + +function rand() { + return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var cx = filledarrayBy( 10, 'complex64', rand ); +console.log( cx.get( 0 ).toString() ); + +var cy = filledarrayBy( 10, 'complex64', rand ); +console.log( cy.get( 0 ).toString() ); + +// Applies a plane rotation: +csrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); +console.log( cx.get( cx.length-1 ).toString() ); +console.log( cy.get( cy.length-1 ).toString() ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/include.gypi b/lib/node_modules/@stdlib/blas/base/csrot/include.gypi new file mode 100644 index 000000000000..497aeca15320 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 = realf( z ); +* // returns ~-0.6 +* +* var im = imagf( z ); +* // returns ~-1.2 +* +* z = cx.get( 0 ); +* // returns +* +* re = realf( z ); +* // returns ~0.8 +* +* im = imagf( z ); +* // returns ~1.6 +*/ +function csrot( N, cx, strideX, cy, 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 cy; + } + viewX = reinterpret( cx, 0 ); + viewY = reinterpret( cy, 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 cy; + } + 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 cy; +} + + +// EXPORTS // + +module.exports = csrot; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js new file mode 100644 index 000000000000..a66e639334e8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.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-complex64' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Applies a plane rotation. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex64Array} cx - first input array +* @param {integer} strideX - `cx` stride length +* @param {Complex64Array} cy - second input array +* @param {integer} strideY - `cy` stride length +* @param {number} c - cosine of the angle of rotation +* @param {number} s - sine of the angle of rotation +* @returns {Complex64Array} `cy` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* csrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); +* +* var z = cy.get( 0 ); +* // returns +* +* var re = realf( z ); +* // returns ~-0.6 +* +* var im = imagf( z ); +* // returns ~-1.2 +* +* z = cx.get( 0 ); +* // returns +* +* re = realf( z ); +* // returns ~0.8 +* +* im = imagf( z ); +* // returns ~1.6 +*/ +function csrot( N, cx, strideX, cy, strideY, c, s ) { + var viewX = reinterpret( cx, 0 ); + var viewY = reinterpret( cy, 0 ); + addon( N, viewX, strideX, viewY, strideY, c, s ); + return cy; +} + + +// EXPORTS // + +module.exports = csrot; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js new file mode 100644 index 000000000000..deb5cca9089c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/index.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'; + +/** +* BLAS level 1 routine to apply plane rotation. +* +* @module @stdlib/blas/base/csrot +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* var csrot = require( '@stdlib/blas/base/csrot' ); +* +* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* csrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); +* +* var z = cy.get( 0 ); +* // returns +* +* var re = realf( z ); +* // returns ~-0.6 +* +* var im = imagf( z ); +* // returns ~-1.2 +* +* z = cx.get( 0 ); +* // returns +* +* re = realf( z ); +* // returns ~0.8 +* +* im = imagf( z ); +* // returns ~1.6 +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* var csrot = require( '@stdlib/blas/base/csrot' ); +* +* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* csrot.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); +* +* var z = cy.get( 0 ); +* // returns +* +* var re = realf( z ); +* // returns ~-0.6 +* +* var im = imagf( z ); +* // returns ~-1.2 +* +* z = cx.get( 0 ); +* // returns +* +* re = realf( z ); +* // returns ~0.8 +* +* im = imagf( 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 csrot; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + csrot = main; +} else { + csrot = tmp; +} + + +// EXPORTS // + +module.exports = csrot; + +// exports: { "ndarray": "csrot.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/main.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/main.js new file mode 100644 index 000000000000..5cdd3bbb3fe1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 csrot = require( './csrot.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( csrot, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = csrot; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/native.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/native.js new file mode 100644 index 000000000000..fcb706429f78 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 csrot = require( './csrot.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( csrot, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = csrot; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js new file mode 100644 index 000000000000..9c20ffbb62f2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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-complex64' ); + + +// MAIN // + +/** +* Applies a plane rotataion. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex64Array} cx - first input array +* @param {integer} strideX - `cx` stride length +* @param {NonNegativeInteger} offsetX - starting `cx` index +* @param {Complex64Array} cy - second input array +* @param {integer} strideY - `cy` stride length +* @param {NonNegativeInteger} offsetY - starting `cy` index +* @param {number} c - cosine of the angle of rotation +* @param {number} s - sine of the angle of rotation +* @returns {Complex64Array} `cy` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* csrot( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); +* +* var z = cy.get( 0 ); +* // returns +* +* var re = realf( z ); +* // returns ~-0.6 +* +* var im = imagf( z ); +* // returns ~-1.2 +* +* z = cx.get( 0 ); +* // returns +* +* re = realf( z ); +* // returns ~0.8 +* +* im = imagf( z ); +* // returns ~1.6 +*/ +function csrot( N, cx, strideX, offsetX, cy, 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 cy; + } + viewX = reinterpret( cx, 0 ); + viewY = reinterpret( cy, 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 cy; +} + + +// EXPORTS // + +module.exports = csrot; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js new file mode 100644 index 000000000000..fa5027e17027 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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-complex64' ); +var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Applies a plane rotation. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex64Array} cx - first input array +* @param {integer} strideX - `cx` stride length +* @param {NonNegativeInteger} offsetX - starting `cx` index +* @param {Complex64Array} cy - second input array +* @param {integer} strideY - `cy` stride length +* @param {NonNegativeInteger} offsetY - starting `cy` index +* @param {number} c - cosine of the angle of rotation +* @param {number} s - sine of the angle of rotation +* @returns {Complex64Array} `cy` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var realf = require( '@stdlib/complex/realf' ); +* var imagf = require( '@stdlib/complex/imagf' ); +* +* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* csrot( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); +* +* var z = cy.get( 0 ); +* // returns +* +* var re = realf( z ); +* // returns ~-0.6 +* +* var im = imagf( z ); +* // returns ~-1.2 +* +* z = cx.get( 0 ); +* // returns +* +* re = realf( z ); +* // returns ~0.8 +* +* im = imagf( z ); +* // returns ~1.6 +*/ +function csrot( N, cx, strideX, offsetX, cy, strideY, offsetY, c, s ) { + var viewX; + var viewY; + + offsetX = minViewBufferIndex( N, strideX, offsetX ); + offsetY = minViewBufferIndex( N, strideY, offsetY ); + + viewX = reinterpret( cx, offsetX ); + viewY = reinterpret( cy, offsetY ); + + addon( N, viewX, strideX, viewY, strideY, c, s ); + return cy; +} + + +// EXPORTS // + +module.exports = csrot; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/manifest.json b/lib/node_modules/@stdlib/blas/base/csrot/manifest.json new file mode 100644 index 000000000000..0580a7b3abfd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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/csrot.f", + "./src/csrot_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-strided-complex64array", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/csrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/csrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/csrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-strided-complex64array", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/csrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/csrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/csrot.f", + "./src/csrot_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-strided-complex64array", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/csrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/csrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/csrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-strided-complex64array", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/csrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/csrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/csrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-strided-complex64array", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/csrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/csrot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/csrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-strided-complex64array", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/csrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/csrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/csrot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/csrot/package.json b/lib/node_modules/@stdlib/blas/base/csrot/package.json new file mode 100644 index 000000000000..cad56b48b88f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/package.json @@ -0,0 +1,81 @@ +{ + "name": "@stdlib/blas/base/csrot", + "version": "0.0.0", + "description": "Apply a plane rotation.", + "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", + "csrot", + "rotation", + "vector", + "typed", + "array", + "ndarray", + "complex", + "complex64", + "float", + "float32", + "single", + "float32array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/Makefile b/lib/node_modules/@stdlib/blas/base/csrot/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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/csrot/src/addon.c b/lib/node_modules/@stdlib/blas/base/csrot/src/addon.c new file mode 100644 index 000000000000..72e873d99482 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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/csrot.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_float.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_complex64array.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_FLOAT( env, c, argv, 5 ); + STDLIB_NAPI_ARGV_FLOAT( env, s, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY( env, Y, N, strideY, argv, 3 ); + API_SUFFIX(c_csrot)( 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/csrot/src/csrot.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c new file mode 100644 index 000000000000..0e9015a41d62 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.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/csrot.h" +#include "stdlib/blas/base/shared.h" + +/** +* Applies a plane rotation. +* +* @param N number of indexed elements +* @param X first input array +* @param strideX X stride length +* @param Y second input array +* @param strideY Y stride length +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const float c, const float s ) { + float *x = (float *)X; + float *y = (float *)Y; + float tmp1; + float 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*x[ i ] + s*y[ i ]; + y[ i ] = c*y[ i ] - s*x[ i ]; + x[ i ] = tmp1; + + j = i + 1; + tmp2 = c*x[ j ] + s*y[ j ]; + y[ j ] = c*y[ j ] - s*x[ j ]; + x[ 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*x[ ix ] + s*y[ iy ]; + y[ iy ] = c*y[ iy ] - s*x[ ix ]; + x[ ix ] = tmp1; + + tmp2 = c*x[ ix+1 ] + s*y[ iy+1 ]; + y[ iy+1 ] = c*y[ iy+1 ] - s*x[ ix+1 ]; + x[ ix+1 ] = tmp2; + + ix += sx; + iy += sy; + } + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f new file mode 100644 index 000000000000..17f5e47f4386 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.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. +! +! ## 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} cx - first input array +! @param {integer} strideX - `cx` stride length +! @param {Array} cy - second input array +! @param {integer} strideY - `cy` stride length +! @param {real} c - cosine of the angle of rotation +! @param {real} s - sine of the angle of rotation +!< +subroutine csrot( N, cx, strideX, cy, strideY, c, s ) + implicit none + ! .. + ! Scalar arguments: + integer :: strideX, strideY, N + real :: c, s + ! .. + ! Array arguments: + complex :: cx(*), cy(*) + ! .. + ! Local scalars: + integer :: ix, iy, i + complex :: ctmp + ! .. + if ( N <= 0 ) then + return + end if + ! .. + if ( strideX == 1 .AND. strideY == 1 ) then + do i = 1, N + ctmp = c*cx( i ) + s*cy( i ) + cy( i ) = c*cy( i ) - s*cx( i ) + cx( i ) = ctmp + 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 + ctmp = c*cx( ix ) + s*cy( iy ) + cy( iy ) = c*cy( iy ) - s*cx( ix ) + cx( ix ) = ctmp + ix = ix + strideX + iy = iy + strideY + end do + end if + return +end subroutine csrot diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c new file mode 100644 index 000000000000..24eaa75d365c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_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/csrot.h" +#include "stdlib/blas/base/csrot_cblas.h" +#include "stdlib/blas/base/shared.h" + +/** +* Applies a plane rotation. +* +* @param N number of indexed elements +* @param X first input array +* @param strideX X stride length +* @param Y second input array +* @param strideY Y stride length +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const float c, const float s ) { + API_SUFFIX(cblas_csrot)( N, X, strideX, Y, strideY, c, s ); +} diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c new file mode 100644 index 000000000000..d2dad71cce95 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c @@ -0,0 +1,36 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 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/csrot.h" +#include "stdlib/blas/base/csrot_fortran.h" +#include "stdlib/blas/base/shared.h" + +/** +* Applies a plane rotation. +* +* @param N number of indexed elements +* @param X first input array +* @param strideX X stride length +* @param Y second input array +* @param strideY Y stride length +* @param c cosine of the angle of rotation +* @param s sine of the angle of rotation +*/ +void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const float c, const float s ) { + csrot( &N, X, &strideX, Y, &strideY, &c, &s ); +} diff --git a/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.js b/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.js new file mode 100644 index 000000000000..484b24729ded --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.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 Float32Array = require( '@stdlib/array/float32' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var csrot = require( './../lib/csrot.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 csrot, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( csrot.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 Complex64Array( [ + 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 Complex64Array( [ + 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 Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 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 Float32Array( [ + -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 = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -0.6, // 1 + -1.2, // 1 + -3.0, // 2 + -3.6, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, // 2 + 4.0, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 1 + 1.6, // 1 + 2.4, // 2 + 3.2, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + -1.8, // 2 + -2.4, // 2 + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + out = csrot( 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 Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cye = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + csrot( -1, cx, 1, cy, 1, 0.8, 0.6 ); + t.deepEqual( viewX, cxe, 'returns expected value' ); + t.deepEqual( viewY, cye, 'returns expected value' ); + + csrot( 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 Complex64Array( [ + 1.0, // 2 + 2.0, // 2 + 3.0, // 1 + 4.0, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 2 + 1.6, // 2 + 2.4, // 1 + 3.2, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -0.6, // 2 + -1.2, // 2 + 0.0, + 0.0, + -1.8, // 1 + -2.4, // 1 + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -3.0, // 2 + -3.6, // 2 + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array([ + 1.0, + 2.0, + 3.0, // 2 + 4.0, // 2 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + cy0 = new Complex64Array([ + 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 Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + cy1 = new Complex64Array( cy0.buffer, cy0.BYTES_PER_ELEMENT*2 ); // begin at the 3rd element + + viewX = new Float32Array( cx0.buffer ); + viewY = new Float32Array( cy0.buffer ); + + cxe = new Float32Array( [ + 1.0, + 2.0, + 2.4, // 2 + 3.2, // 2 + 5.0, + 6.0, + 5.6, // 1 + 6.4 // 1 + ] ); + cye = new Float32Array( [ + 0.0, + 0.0, + 0.0, + 0.0, + -4.2, // 1 + -4.8, // 1 + -1.8, // 2 + -2.4 // 2 + ] ); + + out = csrot( 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/csrot/test/test.csrot.native.js b/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.native.js new file mode 100644 index 000000000000..6a4df7edec09 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.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 Float32Array = require( '@stdlib/array/float32' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var csrot = tryRequire( resolve( __dirname, './../lib/csrot.native.js' ) ); +var opts = { + 'skip': ( csrot 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 csrot, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', opts, function test( t ) { + t.strictEqual( csrot.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 Complex64Array( [ + 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 Complex64Array( [ + 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 Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 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 Float32Array( [ + -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 = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -0.6, // 1 + -1.2, // 1 + -3.0, // 2 + -3.6, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, // 2 + 4.0, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 1 + 1.6, // 1 + 2.4, // 2 + 3.2, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + -1.8, // 2 + -2.4, // 2 + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + out = csrot( 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 Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cye = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + csrot( -1, cx, 1, cy, 1, 0.8, 0.6 ); + t.deepEqual( viewX, cxe, 'returns expected value' ); + t.deepEqual( viewY, cye, 'returns expected value' ); + + csrot( 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 Complex64Array( [ + 1.0, // 2 + 2.0, // 2 + 3.0, // 1 + 4.0, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 2 + 1.6, // 2 + 2.4, // 1 + 3.2, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -0.6, // 2 + -1.2, // 2 + 0.0, + 0.0, + -1.8, // 1 + -2.4, // 1 + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -3.0, // 2 + -3.6, // 2 + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array([ + 1.0, + 2.0, + 3.0, // 2 + 4.0, // 2 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + cy0 = new Complex64Array([ + 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 Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + cy1 = new Complex64Array( cy0.buffer, cy0.BYTES_PER_ELEMENT*2 ); // begin at the 3rd element + + viewX = new Float32Array( cx0.buffer ); + viewY = new Float32Array( cy0.buffer ); + + cxe = new Float32Array( [ + 1.0, + 2.0, + 2.4, // 2 + 3.2, // 2 + 5.0, + 6.0, + 5.6, // 1 + 6.4 // 1 + ] ); + cye = new Float32Array( [ + 0.0, + 0.0, + 0.0, + 0.0, + -4.2, // 1 + -4.8, // 1 + -1.8, // 2 + -2.4 // 2 + ] ); + + out = csrot( 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/csrot/test/test.js b/lib/node_modules/@stdlib/blas/base/csrot/test/test.js new file mode 100644 index 000000000000..e352deb00965 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 csrot = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': isBrowser +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof csrot, '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 csrot.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 csrot = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( csrot, 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 csrot; + var main; + + main = require( './../lib/csrot.js' ); + + csrot = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( csrot, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.js new file mode 100644 index 000000000000..f93590461a6b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 Float32Array = require( '@stdlib/array/float32' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var csrot = 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 csrot, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( csrot.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 Complex64Array( [ + 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 Complex64Array( [ + 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 Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 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 Float32Array( [ + -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 = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -0.6, // 1 + -1.2, // 1 + -3.0, // 2 + -3.6, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ + 1.0, + 2.0, + 3.0, // 1 + 4.0, // 1 + 5.0, // 2 + 6.0, // 2 + 7.0, // 3 + 8.0 // 3 + ] ); + cy = new Complex64Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, // 3 + 0.0, // 3 + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 1.0, + 2.0, + 2.4, // 1 + 3.2, // 1 + 4.0, // 2 + 4.8, // 2 + 5.6, // 3 + 6.4 // 3 + ] ); + cye = new Float32Array( [ + -1.8, // 1 + -2.4, // 1 + -3.0, // 2 + -3.6, // 2 + -4.2, // 3 + -4.8, // 3 + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, // 2 + 4.0, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 1 + 1.6, // 1 + 2.4, // 2 + 3.2, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + -1.8, // 2 + -2.4, // 2 + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + out = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -3.0, // 2 + -3.6, // 2 + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + out = csrot( 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 Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cye = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + csrot( -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' ); + + csrot( 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 Complex64Array( [ + 1.0, // 2 + 2.0, // 2 + 3.0, // 1 + 4.0, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 2 + 1.6, // 2 + 2.4, // 1 + 3.2, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -0.6, // 2 + -1.2, // 2 + 0.0, + 0.0, + -1.8, // 1 + -2.4, // 1 + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 1.0, + 2.0, + 2.4, // 1 + 3.2, // 1 + 5.0, + 6.0, + 5.6, // 2 + 6.4 // 2 + ] ); + cye = new Float32Array( [ + 0.0, + 0.0, + 0.0, + 0.0, + -1.8, // 1 + -2.4, // 1 + -4.2, // 2 + -4.8 // 2 + ] ); + + out = csrot( 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/csrot/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.native.js new file mode 100644 index 000000000000..254d484785e5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/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 Float32Array = require( '@stdlib/array/float32' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var csrot = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( csrot 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 csrot, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', opts, function test( t ) { + t.strictEqual( csrot.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 Complex64Array( [ + 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 Complex64Array( [ + 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 Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 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 Float32Array( [ + -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 = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -0.6, // 1 + -1.2, // 1 + -3.0, // 2 + -3.6, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ + 1.0, + 2.0, + 3.0, // 1 + 4.0, // 1 + 5.0, // 2 + 6.0, // 2 + 7.0, // 3 + 8.0 // 3 + ] ); + cy = new Complex64Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, // 3 + 0.0, // 3 + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 1.0, + 2.0, + 2.4, // 1 + 3.2, // 1 + 4.0, // 2 + 4.8, // 2 + 5.6, // 3 + 6.4 // 3 + ] ); + cye = new Float32Array( [ + -1.8, // 1 + -2.4, // 1 + -3.0, // 2 + -3.6, // 2 + -4.2, // 3 + -4.8, // 3 + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, // 2 + 4.0, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 1 + 1.6, // 1 + 2.4, // 2 + 3.2, // 2 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + -1.8, // 2 + -2.4, // 2 + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 1 + 1.6, // 1 + 3.0, + 4.0, + 4.0, // 2 + 4.8, // 2 + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -3.0, // 2 + -3.6, // 2 + -0.6, // 1 + -1.2, // 1 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + out = csrot( 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 Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + out = csrot( 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 Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + cye = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + csrot( -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' ); + + csrot( 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 Complex64Array( [ + 1.0, // 2 + 2.0, // 2 + 3.0, // 1 + 4.0, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, // 1 + 0.0, // 1 + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 0.8, // 2 + 1.6, // 2 + 2.4, // 1 + 3.2, // 1 + 5.0, + 6.0, + 7.0, + 8.0 + ] ); + cye = new Float32Array( [ + -0.6, // 2 + -1.2, // 2 + 0.0, + 0.0, + -1.8, // 1 + -2.4, // 1 + 0.0, + 0.0 + ] ); + + out = csrot( 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 Complex64Array( [ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0 + ] ); + cy = new Complex64Array( [ + 0.0, // 1 + 0.0, // 1 + 0.0, // 2 + 0.0, // 2 + 0.0, + 0.0, + 0.0, + 0.0 + ] ); + + viewX = new Float32Array( cx.buffer ); + viewY = new Float32Array( cy.buffer ); + + cxe = new Float32Array( [ + 1.0, + 2.0, + 2.4, // 1 + 3.2, // 1 + 5.0, + 6.0, + 5.6, // 2 + 6.4 // 2 + ] ); + cye = new Float32Array( [ + 0.0, + 0.0, + 0.0, + 0.0, + -1.8, // 1 + -2.4, // 1 + -4.2, // 2 + -4.8 // 2 + ] ); + + out = csrot( 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(); +}); From 57f17a943cba50c05b15254589d7ec0c91f82de4 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Tue, 21 May 2024 20:32:14 +0530 Subject: [PATCH 02/14] chore: add repl file --- .../@stdlib/blas/base/csrot/docs/repl.txt | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt diff --git a/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt new file mode 100644 index 000000000000..511128bf9877 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt @@ -0,0 +1,166 @@ + +{{alias}}( N, cx, strideX, cy, strideY, c, s ) + Applies a plane rotation. + + The `N` and stride parameters determine how values from `cx` and `cy` 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. + + cx: Complex64Array + First input array. + + strideX: integer + Index increment for `cx`. + + cy: Complex64Array + Second input array. + + strideY: integer + Index increment for `cy`. + + c: number + Cosine of the angle of rotation. + + s: number + Sine of the angle of rotation. + + Returns + ------- + cy: Complex64Array + Input array `cy`. + + Examples + -------- + // Standard usage: + > var cx = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var cy = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); + > {{alias}}( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); + > var z = cy.get( 0 ); + > var re = {{alias:@stdlib/complex/realf}}( z ) + ~-0.6 + > var im = {{alias:@stdlib/complex/imagf}}( z ) + ~-1.2 + > z = cx.get( 0 ); + > re = {{alias:@stdlib/complex/realf}}( z ) + ~0.8 + > im = {{alias:@stdlib/complex/imagf}}( z ) + ~1.6 + + // Advanced indexing: + > cx = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > cy = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + > {{alias}}( 2, cx, -2, cy, 1, 0.8, 0.6 ); + > z = cy.get( 0 ); + > re = {{alias:@stdlib/complex/realf}}( z ) + ~-3.0 + > im = {{alias:@stdlib/complex/imagf}}( z ) + ~-3.6 + > z = cx.get( 2 ); + > re = {{alias:@stdlib/complex/realf}}( z ) + ~4.0 + > im = {{alias:@stdlib/complex/imagf}}( z ) + ~4.8 + + // Using typed array views: + > var cx0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var cy0 = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + > var cx1 = new {{alias:@stdlib/array/complex64}}( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); + > var cy1 = new {{alias:@stdlib/array/complex64}}( cy0.buffer, cy0.BYTES_PER_ELEMENT*2 ); + > {{alias}}( 1, cx1, 1, cy1, 1, 0.8, 0.6 ); + > z = cy0.get( 2 ); + > re = {{alias:@stdlib/complex/realf}}( z ) + ~-1.8 + > im = {{alias:@stdlib/complex/imagf}}( z ) + ~-2.4 + > z = cx0.get( 1 ); + > re = {{alias:@stdlib/complex/realf}}( z ) + ~2.4 + > im = {{alias:@stdlib/complex/imagf}}( z ) + ~3.2 + + +{{alias}}.ndarray( N, cx, strideX, offsetX, cy, strideY, offsetY, c, s ) + Applies a plane rotation using alternative indexing semantics. + + 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. + + cx: Complex64Array + First input array. + + strideX: integer + Index increment for `cx`. + + offsetX: integer + Starting index for `cx`. + + cy: Complex64Array + Second input array. + + strideY: integer + Index increment for `cy`. + + offsetY: integer + Starting index for `cy`. + + c: number + Cosine of the angle of rotation. + + s: number + Sine of the angle of rotation. + + Returns + ------- + cy: Complex64Array + Input array `cy`. + + Examples + -------- + // Standard usage: + > var cx = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var cy = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); + > {{alias}}.ndarray( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); + > var z = cy.get( 0 ); + > var re = {{alias:@stdlib/complex/realf}}( z ) + ~-0.6 + > var im = {{alias:@stdlib/complex/imagf}}( z ) + ~-1.2 + > z = cx.get( 0 ); + > re = {{alias:@stdlib/complex/realf}}( z ) + ~0.8 + > im = {{alias:@stdlib/complex/imagf}}( z ) + ~1.6 + + // Advanced indexing: + > cx = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > cy = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + > {{alias}}.ndarray( 1, cx, 2, 1, cy, 2, 1, 0.8, 0.6 ); + > z = cy.get( 1 ); + > re = {{alias:@stdlib/complex/realf}}( z ) + ~-1.8 + > im = {{alias:@stdlib/complex/imagf}}( z ) + ~-2.4 + > z = cx.get( 1 ); + > re = {{alias:@stdlib/complex/realf}}( z ) + ~2.4 + > im = {{alias:@stdlib/complex/imagf}}( z ) + ~3.2 + + See Also + -------- + From 9a70c57c3fcce5a8a39ba5a9edadccef8cf2ab4e Mon Sep 17 00:00:00 2001 From: aman-095 Date: Tue, 21 May 2024 20:52:18 +0530 Subject: [PATCH 03/14] chore: update descriptions --- lib/node_modules/@stdlib/blas/base/csrot/README.md | 6 +++--- lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt | 6 ++++-- .../@stdlib/blas/base/csrot/docs/types/index.d.ts | 6 +++--- .../blas/base/csrot/include/stdlib/blas/base/csrot.h | 2 +- .../blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h | 2 +- .../base/csrot/include/stdlib/blas/base/csrot_fortran.h | 2 +- lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js | 2 +- .../@stdlib/blas/base/csrot/lib/csrot.native.js | 2 +- lib/node_modules/@stdlib/blas/base/csrot/lib/index.js | 2 +- lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js | 2 +- .../@stdlib/blas/base/csrot/lib/ndarray.native.js | 2 +- lib/node_modules/@stdlib/blas/base/csrot/package.json | 2 +- lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c | 2 +- lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f | 2 +- lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c | 2 +- lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c | 2 +- 16 files changed, 23 insertions(+), 21 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/csrot/README.md b/lib/node_modules/@stdlib/blas/base/csrot/README.md index 01d691e6398f..3f9f43f1a8b5 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/README.md +++ b/lib/node_modules/@stdlib/blas/base/csrot/README.md @@ -20,7 +20,7 @@ limitations under the License. # csrot -> Applies a plane rotation. +> Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors.
@@ -32,7 +32,7 @@ var csrot = require( '@stdlib/blas/base/csrot' ); #### csrot( N, cx, strideX, cy, strideY, c, s ) -Applies a plane rotation. +Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. ```javascript var Complex64Array = require( '@stdlib/array/complex64' ); @@ -284,7 +284,7 @@ console.log( cy.get( cy.length-1 ).toString() ); #### c_csrot( N, \*X, strideX, \*Y, strideY, c, s ) -Applies a plane rotation. +Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. ```c float x[] = { 1.0f, 2.0f, 3.0f, 4.0f }; // interleaved real and imaginary components diff --git a/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt index 511128bf9877..38e563114613 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt @@ -1,6 +1,7 @@ {{alias}}( N, cx, strideX, cy, strideY, c, s ) - Applies a plane rotation. + Applies a plane rotation where the cos and sin (c and s) are real and the + vectors are single-precision floating-point vectors. The `N` and stride parameters determine how values from `cx` and `cy` are rotated. @@ -89,7 +90,8 @@ {{alias}}.ndarray( N, cx, strideX, offsetX, cy, strideY, offsetY, c, s ) - Applies a plane rotation using alternative indexing semantics. + Applies a plane rotation where the cos and sin (c and s) are real and the + vectors are single-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 diff --git a/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts index 08a87d31caf1..a65561edcdb7 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts @@ -27,7 +27,7 @@ import { Complex64Array } from '@stdlib/types/array'; */ interface Routine { /** - * Applies a plane rotation. + * Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. * * @param N - number of indexed elements * @param cx - first input array @@ -69,7 +69,7 @@ interface Routine { ( N: number, cx: Complex64Array, strideX: number, cy: Complex64Array, strideY: number, c: number, s: number ): Complex64Array; /** - * Applies a plane rotation using alternative indexing semantics. + * Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors using alternative indexing semantics. * * @param N - number of indexed elements * @param cx - first input array @@ -114,7 +114,7 @@ interface Routine { } /** -* Applies a plane rotation. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. * * @param N - number of indexed elements * @param cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h index 5d5599860e65..70aa8628c692 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h +++ b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h @@ -32,7 +32,7 @@ extern "C" { #endif /** -* Applies a plane rotation. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. */ void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const float c, const float s ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h index 04c95419a8cc..3f8266024869 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h @@ -32,7 +32,7 @@ extern "C" { #endif /** -* Applies a plane rotation. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. */ void API_SUFFIX(cblas_csrot)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const float c, const float s ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h index 7958c2bbc718..2ddbc724e133 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h +++ b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h @@ -30,7 +30,7 @@ extern "C" { #endif /** -* Applies a plane rotation. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. */ void csrot( const CBLAS_INT *, void *, const CBLAS_INT *, void *, const CBLAS_INT *, const float *, const float * ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js index ab1c9956a678..b36de3d215dd 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js @@ -26,7 +26,7 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); // MAIN // /** -* Applies a plane rotation. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js index a66e639334e8..b3758c764661 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js @@ -27,7 +27,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Applies a plane rotation. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js index deb5cca9089c..7ff30800aca1 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 1 routine to apply plane rotation. +* BLAS level 1 routine to apply a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. * * @module @stdlib/blas/base/csrot * diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js index 9c20ffbb62f2..ad5035b387b1 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js @@ -26,7 +26,7 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); // MAIN // /** -* Applies a plane rotataion. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js index fa5027e17027..5c94a97beefc 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js @@ -28,7 +28,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Applies a plane rotation. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/package.json b/lib/node_modules/@stdlib/blas/base/csrot/package.json index cad56b48b88f..68b97b3d3f40 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/package.json +++ b/lib/node_modules/@stdlib/blas/base/csrot/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/csrot", "version": "0.0.0", - "description": "Apply a plane rotation.", + "description": "Apply a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c index 0e9015a41d62..e92559f72de3 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c @@ -20,7 +20,7 @@ #include "stdlib/blas/base/shared.h" /** -* Applies a plane rotation. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. * * @param N number of indexed elements * @param X first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f index 17f5e47f4386..9699e0ace60e 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f @@ -16,7 +16,7 @@ ! limitations under the License. !< -!> Applies a plane rotation. +!> Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. ! ! ## Notes ! diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c index 24eaa75d365c..ee681c961907 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c @@ -21,7 +21,7 @@ #include "stdlib/blas/base/shared.h" /** -* Applies a plane rotation. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. * * @param N number of indexed elements * @param X first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c index d2dad71cce95..986bc0ddf826 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c @@ -21,7 +21,7 @@ #include "stdlib/blas/base/shared.h" /** -* Applies a plane rotation. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. * * @param N number of indexed elements * @param X first input array From 454131b263b1a0572f6558a872e7f7c3b7912962 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Wed, 22 May 2024 12:19:29 +0530 Subject: [PATCH 04/14] chore: apply review changes --- .../@stdlib/blas/base/csrot/README.md | 18 +++++++++--------- .../base/csrot/benchmark/c/benchmark.length.c | 2 +- .../blas/base/csrot/examples/c/example.c | 2 +- .../csrot/include/stdlib/blas/base/csrot.h | 4 ++-- .../include/stdlib/blas/base/csrot_cblas.h | 4 ++-- .../include/stdlib/blas/base/csrot_fortran.h | 2 +- .../@stdlib/blas/base/csrot/lib/csrot.js | 2 +- .../blas/base/csrot/lib/csrot.native.js | 2 +- .../@stdlib/blas/base/csrot/lib/index.js | 2 +- .../@stdlib/blas/base/csrot/lib/ndarray.js | 2 +- .../blas/base/csrot/lib/ndarray.native.js | 2 +- .../@stdlib/blas/base/csrot/package.json | 2 +- .../@stdlib/blas/base/csrot/src/addon.c | 6 +++--- .../@stdlib/blas/base/csrot/src/csrot.c | 16 ++++++++-------- .../@stdlib/blas/base/csrot/src/csrot_cblas.c | 14 +++++++------- .../@stdlib/blas/base/csrot/src/csrot_f.c | 14 +++++++------- 16 files changed, 47 insertions(+), 47 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/csrot/README.md b/lib/node_modules/@stdlib/blas/base/csrot/README.md index 3f9f43f1a8b5..b28d31360d64 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/README.md +++ b/lib/node_modules/@stdlib/blas/base/csrot/README.md @@ -20,7 +20,7 @@ limitations under the License. # csrot -> Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +> Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors.
@@ -32,7 +32,7 @@ var csrot = require( '@stdlib/blas/base/csrot' ); #### csrot( N, cx, strideX, cy, strideY, c, s ) -Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. ```javascript var Complex64Array = require( '@stdlib/array/complex64' ); @@ -284,7 +284,7 @@ console.log( cy.get( cy.length-1 ).toString() ); #### c_csrot( N, \*X, strideX, \*Y, strideY, c, s ) -Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. ```c float x[] = { 1.0f, 2.0f, 3.0f, 4.0f }; // interleaved real and imaginary components @@ -304,7 +304,7 @@ The function accepts the following arguments: - **s**: `[in] float` sine of the angle of rotation. ```c -void c_csrot( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const float c, const float s ); +void c_csrot( const CBLAS_INT N, void *CX, const CBLAS_INT strideX, void *CY, const CBLAS_INT strideY, const float c, const float s ); ```
@@ -331,8 +331,8 @@ void c_csrot( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, cons int main( void ) { // Create strided arrays: - float cx[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; - float cy[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + float y[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; // Specify the number of elements: const int N = 4; @@ -342,12 +342,12 @@ int main( void ) { const int strideY = -1; // Copy elements: - c_csrot( N, (void *)cx, strideX, (void *)cy, strideY, 0.8, 0.6 ); + c_csrot( N, (void *)x, strideX, (void *)y, strideY, 0.8f, 0.6f ); // Print the result: for ( int i = 0; i < N; i++ ) { - printf( "cx[ %i ] = %f + %fj\n", i, cx[ i*2 ], cx[ (i*2)+1 ] ); - printf( "cy[ %i ] = %f + %fj\n", i, cy[ i*2 ], cy[ (i*2)+1 ] ); + printf( "x[ %i ] = %f + %fj\n", i, x[ i*2 ], x[ (i*2)+1 ] ); + printf( "y[ %i ] = %f + %fj\n", i, y[ i*2 ], y[ (i*2)+1 ] ); } } ``` diff --git a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/c/benchmark.length.c index f258dfdf0e79..9ddfe727ef37 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/c/benchmark.length.c @@ -109,7 +109,7 @@ double benchmark( int iterations, int len ) { } t = tic(); for ( i = 0; i < iterations; i++ ) { - c_csrot( len, (void *)x, 1, (void *)y, 1, 0.8, 0.6 ); + c_csrot( len, (void *)x, 1, (void *)y, 1, 0.8f, 0.6f ); if ( y[ 0 ] != y[ 0 ] ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/csrot/examples/c/example.c index 07c6ddfb812d..50adbfa5c692 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/examples/c/example.c @@ -31,7 +31,7 @@ int main( void ) { const int strideX = 1; const int strideY = -1; - c_csrot( N, (void *)x, strideX, (void *)y, strideY, 0.8, 0.6 ); + c_csrot( N, (void *)x, strideX, (void *)y, strideY, 0.8f, 0.6f ); // Print the result: for ( int i = 0; i < N; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h index 70aa8628c692..15c5b2dc793e 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h +++ b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h @@ -32,9 +32,9 @@ extern "C" { #endif /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. */ -void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const float c, const float s ); +void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *CX, const CBLAS_INT strideX, void *CY, const CBLAS_INT strideY, const float c, const float s ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h index 3f8266024869..4f6833e19cc1 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h @@ -32,9 +32,9 @@ extern "C" { #endif /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. */ -void API_SUFFIX(cblas_csrot)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const float c, const float s ); +void API_SUFFIX(cblas_csrot)( const CBLAS_INT N, void *CX, const CBLAS_INT strideX, void *CY, const CBLAS_INT strideY, const float c, const float s ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h index 2ddbc724e133..1b9dc8734e92 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h +++ b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h @@ -30,7 +30,7 @@ extern "C" { #endif /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. */ void csrot( const CBLAS_INT *, void *, const CBLAS_INT *, void *, const CBLAS_INT *, const float *, const float * ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js index b36de3d215dd..ac5037ba4c26 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js @@ -26,7 +26,7 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); // MAIN // /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js index b3758c764661..a03055e46566 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js @@ -27,7 +27,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js index 7ff30800aca1..8de8a4bc51fa 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 1 routine to apply a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +* BLAS level 1 routine to apply a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. * * @module @stdlib/blas/base/csrot * diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js index ad5035b387b1..c1c95b1c9671 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js @@ -26,7 +26,7 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); // MAIN // /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js index 5c94a97beefc..e4bc2adab754 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js @@ -28,7 +28,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/package.json b/lib/node_modules/@stdlib/blas/base/csrot/package.json index 68b97b3d3f40..be858e790050 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/package.json +++ b/lib/node_modules/@stdlib/blas/base/csrot/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/csrot", "version": "0.0.0", - "description": "Apply a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors.", + "description": "Apply a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/addon.c b/lib/node_modules/@stdlib/blas/base/csrot/src/addon.c index 72e873d99482..e410525bcd0e 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/addon.c @@ -40,9 +40,9 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 4 ); STDLIB_NAPI_ARGV_FLOAT( env, c, argv, 5 ); STDLIB_NAPI_ARGV_FLOAT( env, s, argv, 6 ); - STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY( env, X, N, strideX, argv, 1 ); - STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY( env, Y, N, strideY, argv, 3 ); - API_SUFFIX(c_csrot)( N, (void *)X, strideX, (void *)Y, strideY, c, s ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY( env, CX, N, strideX, argv, 1 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY( env, CY, N, strideY, argv, 3 ); + API_SUFFIX(c_csrot)( N, (void *)CX, strideX, (void *)CY, strideY, c, s ); return NULL; } diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c index e92559f72de3..43a20111207a 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c @@ -20,19 +20,19 @@ #include "stdlib/blas/base/shared.h" /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. * * @param N number of indexed elements -* @param X first input array -* @param strideX X stride length -* @param Y second input array -* @param strideY Y stride length +* @param CX first input array +* @param strideX CX stride length +* @param CY second input array +* @param strideY CY stride length * @param c cosine of the angle of rotation * @param s sine of the angle of rotation */ -void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const float c, const float s ) { - float *x = (float *)X; - float *y = (float *)Y; +void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *CX, const CBLAS_INT strideX, void *CY, const CBLAS_INT strideY, const float c, const float s ) { + float *x = (float *)CX; + float *y = (float *)CY; float tmp1; float tmp2; CBLAS_INT ix; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c index ee681c961907..ec122c2abebf 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c @@ -21,16 +21,16 @@ #include "stdlib/blas/base/shared.h" /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. * * @param N number of indexed elements -* @param X first input array -* @param strideX X stride length -* @param Y second input array -* @param strideY Y stride length +* @param CX first input array +* @param strideX CX stride length +* @param CY second input array +* @param strideY CY stride length * @param c cosine of the angle of rotation * @param s sine of the angle of rotation */ -void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const float c, const float s ) { - API_SUFFIX(cblas_csrot)( N, X, strideX, Y, strideY, c, s ); +void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *CX, const CBLAS_INT strideX, void *CY, const CBLAS_INT strideY, const float c, const float s ) { + API_SUFFIX(cblas_csrot)( N, CX, strideX, CY, strideY, c, s ); } diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c index 986bc0ddf826..97a484fec127 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c @@ -21,16 +21,16 @@ #include "stdlib/blas/base/shared.h" /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. * * @param N number of indexed elements -* @param X first input array -* @param strideX X stride length -* @param Y second input array -* @param strideY Y stride length +* @param CX first input array +* @param strideX CX stride length +* @param CY second input array +* @param strideY CY stride length * @param c cosine of the angle of rotation * @param s sine of the angle of rotation */ -void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY, const float c, const float s ) { - csrot( &N, X, &strideX, Y, &strideY, &c, &s ); +void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *CX, const CBLAS_INT strideX, void *CY, const CBLAS_INT strideY, const float c, const float s ) { + csrot( &N, CX, &strideX, CY, &strideY, &c, &s ); } From 768cacb7b47621cc4e62ce1d2a9ce4f6a3606cfc Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 11 Jul 2024 19:14:45 +0530 Subject: [PATCH 05/14] refactor: update to use ndarray API as common implementation --- .../@stdlib/blas/base/csrot/lib/csrot.js | 62 ++----------------- .../blas/base/csrot/lib/csrot.native.js | 2 +- .../@stdlib/blas/base/csrot/lib/index.js | 2 +- .../@stdlib/blas/base/csrot/lib/ndarray.js | 2 +- .../blas/base/csrot/lib/ndarray.native.js | 2 +- 5 files changed, 10 insertions(+), 60 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js index ac5037ba4c26..1f97f704557e 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.js @@ -20,13 +20,14 @@ // MODULES // -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); // MAIN // /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +* Applies a plane rotation. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} cx - first input array @@ -66,60 +67,9 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * // returns ~1.6 */ function csrot( N, cx, strideX, cy, 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 cy; - } - viewX = reinterpret( cx, 0 ); - viewY = reinterpret( cy, 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 cy; - } - 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 cy; + var ix = stride2offset( N, strideX ); + var iy = stride2offset( N, strideY ); + return ndarray( N, cx, strideX, ix, cy, strideY, iy, c, s ); } diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js index a03055e46566..a66e639334e8 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/csrot.native.js @@ -27,7 +27,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +* Applies a plane rotation. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js index 8de8a4bc51fa..2aba9873c179 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 1 routine to apply a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +* BLAS level 1 routine to apply a plane rotation. * * @module @stdlib/blas/base/csrot * diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js index c1c95b1c9671..003113d55960 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js @@ -26,7 +26,7 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); // MAIN // /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +* Applies a plane rotation. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js index e4bc2adab754..fa5027e17027 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.native.js @@ -28,7 +28,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +* Applies a plane rotation. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} cx - first input array From 9202da0571db00fb6af9910535ed774bafffa6d0 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 11 Jul 2024 19:19:53 +0530 Subject: [PATCH 06/14] docs: update example and descriptions --- .../@stdlib/blas/base/csrot/docs/types/index.d.ts | 6 +++--- .../@stdlib/blas/base/csrot/examples/index.js | 15 ++++++++++----- .../base/csrot/include/stdlib/blas/base/csrot.h | 2 +- .../csrot/include/stdlib/blas/base/csrot_cblas.h | 2 +- .../include/stdlib/blas/base/csrot_fortran.h | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts index a65561edcdb7..216ac8079913 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts @@ -27,7 +27,7 @@ import { Complex64Array } from '@stdlib/types/array'; */ interface Routine { /** - * Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. + * Applies a plane rotation. * * @param N - number of indexed elements * @param cx - first input array @@ -69,7 +69,7 @@ interface Routine { ( N: number, cx: Complex64Array, strideX: number, cy: Complex64Array, strideY: number, c: number, s: number ): Complex64Array; /** - * Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors using alternative indexing semantics. + * Applies a plane rotation. * * @param N - number of indexed elements * @param cx - first input array @@ -114,7 +114,7 @@ interface Routine { } /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +* Applies a plane rotation. * * @param N - number of indexed elements * @param cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/examples/index.js b/lib/node_modules/@stdlib/blas/base/csrot/examples/index.js index fcbad08b9fea..f798e7c1d79a 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/examples/index.js @@ -21,19 +21,24 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var Complex64 = require( '@stdlib/complex/float32' ); +var ccopy = require( '@stdlib/blas/base/ccopy' ); +var zeros = require( '@stdlib/array/zeros' ); +var logEach = require( '@stdlib/console/log-each' ); var csrot = require( './../lib' ); function rand() { return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); } +// Generate random input arrays: var cx = filledarrayBy( 10, 'complex64', rand ); -console.log( cx.get( 0 ).toString() ); +var cxc = ccopy( cx.length, cx, 1, zeros( cx.length, 'complex64' ), 1 ); var cy = filledarrayBy( 10, 'complex64', rand ); -console.log( cy.get( 0 ).toString() ); +var cyc = ccopy( cy.length, cy, 1, zeros( cy.length, 'complex64' ), 1 ); -// Applies a plane rotation: +// Apply a plane rotation: csrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); -console.log( cx.get( cx.length-1 ).toString() ); -console.log( cy.get( cy.length-1 ).toString() ); + +// Print the results: +logEach( '(%s,%s) => (%s,%s)', cxc, cyc, cx, cy ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h index 15c5b2dc793e..f7a6abafa0de 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h +++ b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot.h @@ -32,7 +32,7 @@ extern "C" { #endif /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +* Applies a plane rotation. */ void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *CX, const CBLAS_INT strideX, void *CY, const CBLAS_INT strideY, const float c, const float s ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h index 4f6833e19cc1..ad8931d6e2dd 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_cblas.h @@ -32,7 +32,7 @@ extern "C" { #endif /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +* Applies a plane rotation. */ void API_SUFFIX(cblas_csrot)( const CBLAS_INT N, void *CX, const CBLAS_INT strideX, void *CY, const CBLAS_INT strideY, const float c, const float s ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h index 1b9dc8734e92..7958c2bbc718 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h +++ b/lib/node_modules/@stdlib/blas/base/csrot/include/stdlib/blas/base/csrot_fortran.h @@ -30,7 +30,7 @@ extern "C" { #endif /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +* Applies a plane rotation. */ void csrot( const CBLAS_INT *, void *, const CBLAS_INT *, void *, const CBLAS_INT *, const float *, const float * ); From 43c648c347ad08f4147003324b8fb60f106ad6c5 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 11 Jul 2024 19:22:33 +0530 Subject: [PATCH 07/14] docs: update descriptions --- lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt | 10 ++++------ .../@stdlib/blas/base/csrot/docs/types/test.ts | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt index 38e563114613..6bc60dfc7d9b 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt @@ -1,10 +1,9 @@ {{alias}}( N, cx, strideX, cy, strideY, c, s ) - Applies a plane rotation where the cos and sin (c and s) are real and the - vectors are single-precision floating-point vectors. + Applies a plane rotation. - The `N` and stride parameters determine how values from `cx` and `cy` are - rotated. + The `N` and stride parameters determine how values in the strided arrays + are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -90,8 +89,7 @@ {{alias}}.ndarray( N, cx, strideX, offsetX, cy, strideY, offsetY, c, s ) - Applies a plane rotation where the cos and sin (c and s) are real and the - vectors are single-precision floating-point vectors. + Applies a plane rotation. While typed array views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting diff --git a/lib/node_modules/@stdlib/blas/base/csrot/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/csrot/docs/types/test.ts index ac30896fcfba..3fc3b0541692 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/csrot/docs/types/test.ts @@ -264,7 +264,7 @@ import csrot = require( './index' ); csrot.ndarray( cx.length, cx, 1, 0, cy, 1, ( cx: number ): number => cx, 0.8, 0.6 ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a eighth argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... { const cx = new Complex64Array( 10 ); const cy = new Complex64Array( 10 ); From 73cff54e3ff922ade27745c150374a7664c9c55f Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 11 Jul 2024 19:24:20 +0530 Subject: [PATCH 08/14] bench: fix description --- .../@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js index 6f150c0277cd..4e7e8091137d 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js @@ -106,7 +106,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':len='+len, f ); + bench( pkg+':ndarray:len='+len, f ); } } From 38572e913ec7296b3dd2d378d5885a554442bd0b Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 11 Jul 2024 19:35:08 +0530 Subject: [PATCH 09/14] refactor: use utility to resolve an index offset --- .../@stdlib/blas/base/csrot/manifest.json | 24 ++++++++---- .../@stdlib/blas/base/csrot/src/csrot.c | 38 ++++++++----------- .../@stdlib/blas/base/csrot/src/csrot.f | 8 +--- .../@stdlib/blas/base/csrot/src/csrot_cblas.c | 6 +-- .../@stdlib/blas/base/csrot/src/csrot_f.c | 6 +-- 5 files changed, 38 insertions(+), 44 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/csrot/manifest.json b/lib/node_modules/@stdlib/blas/base/csrot/manifest.json index 0580a7b3abfd..05257328b566 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/csrot/manifest.json @@ -65,7 +65,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -82,7 +83,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, @@ -189,7 +191,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -206,7 +209,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, @@ -358,7 +362,8 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-float", "@stdlib/napi/argv-strided-complex64array", - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -375,7 +380,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, { @@ -392,7 +398,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] }, @@ -410,7 +417,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" ] } ] diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c index 43a20111207a..8707665f38d0 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c @@ -17,15 +17,16 @@ */ #include "stdlib/blas/base/csrot.h" +#include "stdlib/strided/base/stride2offset.h" #include "stdlib/blas/base/shared.h" /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +* Applies a plane rotation. * * @param N number of indexed elements -* @param CX first input array +* @param CX first input array * @param strideX CX stride length -* @param CY second input array +* @param CY second input array * @param strideY CY stride length * @param c cosine of the angle of rotation * @param s sine of the angle of rotation @@ -33,51 +34,42 @@ void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *CX, const CBLAS_INT strideX, void *CY, const CBLAS_INT strideY, const float c, const float s ) { float *x = (float *)CX; float *y = (float *)CY; - float tmp1; - float tmp2; CBLAS_INT ix; CBLAS_INT iy; CBLAS_INT sx; CBLAS_INT sy; CBLAS_INT i; CBLAS_INT j; + float tmp; if ( N <= 0 ) { return; } if ( strideX == 1 && strideY == 1 ) { for ( i = 0; i < N*2; i += 2 ) { - tmp1 = c*x[ i ] + s*y[ i ]; + tmp = c*x[ i ] + s*y[ i ]; y[ i ] = c*y[ i ] - s*x[ i ]; - x[ i ] = tmp1; + x[ i ] = tmp; j = i + 1; - tmp2 = c*x[ j ] + s*y[ j ]; + tmp = c*x[ j ] + s*y[ j ]; y[ j ] = c*y[ j ] - s*x[ j ]; - x[ j ] = tmp2; + x[ j ] = tmp; } 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; + ix = stdlib_strided_stride2offset( N, strideX ); + iy = stdlib_strided_stride2offset( N, strideY ); for ( i = 0; i < N; i++ ) { - tmp1 = c*x[ ix ] + s*y[ iy ]; + tmp = c*x[ ix ] + s*y[ iy ]; y[ iy ] = c*y[ iy ] - s*x[ ix ]; - x[ ix ] = tmp1; + x[ ix ] = tmp; - tmp2 = c*x[ ix+1 ] + s*y[ iy+1 ]; + tmp = c*x[ ix+1 ] + s*y[ iy+1 ]; y[ iy+1 ] = c*y[ iy+1 ] - s*x[ ix+1 ]; - x[ ix+1 ] = tmp2; + x[ ix+1 ] = tmp; ix += sx; iy += sy; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f index 9699e0ace60e..37dd14196112 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f @@ -16,7 +16,7 @@ ! limitations under the License. !< -!> Applies a plane rotation where the cos and sin (c and s) are real and the vectors are single-precision floating-point vectors. +!> Applies a plane rotation. ! ! ## Notes ! @@ -29,12 +29,6 @@ ! * 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 : diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c index ec122c2abebf..e7db4349dcce 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_cblas.c @@ -21,12 +21,12 @@ #include "stdlib/blas/base/shared.h" /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +* Applies a plane rotation. * * @param N number of indexed elements -* @param CX first input array +* @param CX first input array * @param strideX CX stride length -* @param CY second input array +* @param CY second input array * @param strideY CY stride length * @param c cosine of the angle of rotation * @param s sine of the angle of rotation diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c index 97a484fec127..7242d6851073 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot_f.c @@ -21,12 +21,12 @@ #include "stdlib/blas/base/shared.h" /** -* Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +* Applies a plane rotation. * * @param N number of indexed elements -* @param CX first input array +* @param CX first input array * @param strideX CX stride length -* @param CY second input array +* @param CY second input array * @param strideY CY stride length * @param c cosine of the angle of rotation * @param s sine of the angle of rotation From f99e4f5438dce1d80eafb5877ec11636aaa0ca5e Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 11 Jul 2024 19:44:33 +0530 Subject: [PATCH 10/14] docs: update descriptions --- .../@stdlib/blas/base/csrot/README.md | 23 +++++++++++-------- .../@stdlib/blas/base/csrot/package.json | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/csrot/README.md b/lib/node_modules/@stdlib/blas/base/csrot/README.md index b28d31360d64..2f93acc10372 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/README.md +++ b/lib/node_modules/@stdlib/blas/base/csrot/README.md @@ -20,7 +20,7 @@ limitations under the License. # csrot -> Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +> Applies a plane rotation.
@@ -32,7 +32,7 @@ var csrot = require( '@stdlib/blas/base/csrot' ); #### csrot( N, cx, strideX, cy, strideY, c, s ) -Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +Applies a plane rotation. ```javascript var Complex64Array = require( '@stdlib/array/complex64' ); @@ -71,7 +71,7 @@ The function has the following parameters: - **cy**: second input [`Complex64Array`][@stdlib/array/complex64]. - **strideY**: index increment for `cy`. -The `N` and stride parameters determine how values from `cx` and `cy` are rotated. For example, to apply a plane rotation to every other element, +The `N` and stride parameters determine how values from `cx` and `cy` are accessed at runtime. For example, to apply a plane rotation to every other element, ```javascript var Complex64Array = require( '@stdlib/array/complex64' ); @@ -234,22 +234,27 @@ im = imagf( z ); var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var Complex64 = require( '@stdlib/complex/float32' ); +var ccopy = require( '@stdlib/blas/base/ccopy' ); +var zeros = require( '@stdlib/array/zeros' ); +var logEach = require( '@stdlib/console/log-each' ); var csrot = require( '@stdlib/blas/base/csrot' ); function rand() { return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); } +// Generate random input arrays: var cx = filledarrayBy( 10, 'complex64', rand ); -console.log( cx.get( 0 ).toString() ); +var cxc = ccopy( cx.length, cx, 1, zeros( cx.length, 'complex64' ), 1 ); var cy = filledarrayBy( 10, 'complex64', rand ); -console.log( cy.get( 0 ).toString() ); +var cyc = ccopy( cy.length, cy, 1, zeros( cy.length, 'complex64' ), 1 ); // Apply a plane rotation: csrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); -console.log( cx.get( cx.length-1 ).toString() ); -console.log( cy.get( cy.length-1 ).toString() ); + +// Print the results: +logEach( '(%s,%s) => (%s,%s)', cxc, cyc, cx, cy ); ```
@@ -284,7 +289,7 @@ console.log( cy.get( cy.length-1 ).toString() ); #### c_csrot( N, \*X, strideX, \*Y, strideY, c, s ) -Applies a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors. +Applies a plane rotation. ```c float x[] = { 1.0f, 2.0f, 3.0f, 4.0f }; // interleaved real and imaginary components @@ -298,7 +303,7 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **CX**: `[inout] void*` first input array. - **strideX**: `[in] CBLAS_INT` index increment for `CX`. -- **CY**: `[inout] void*` first input array. +- **CY**: `[inout] void*` second input array. - **strideY**: `[in] CBLAS_INT` index increment for `CY`. - **c**: `[in] float` cosine of the angle of rotation. - **s**: `[in] float` sine of the angle of rotation. diff --git a/lib/node_modules/@stdlib/blas/base/csrot/package.json b/lib/node_modules/@stdlib/blas/base/csrot/package.json index be858e790050..cad56b48b88f 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/package.json +++ b/lib/node_modules/@stdlib/blas/base/csrot/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/csrot", "version": "0.0.0", - "description": "Apply a plane rotation where the cos and sin (c and s) are real and the vectors are complex single-precision floating-point vectors.", + "description": "Apply a plane rotation.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From fcccad1286b35cd201dbfd29f012012faeb064b8 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 11 Jul 2024 19:46:15 +0530 Subject: [PATCH 11/14] test: remove duplicate tests and update descriptions --- .../@stdlib/blas/base/csrot/test/test.csrot.js | 2 +- .../blas/base/csrot/test/test.csrot.native.js | 2 +- .../@stdlib/blas/base/csrot/test/test.ndarray.js | 16 +--------------- .../blas/base/csrot/test/test.ndarray.native.js | 16 +--------------- 4 files changed, 4 insertions(+), 32 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.js b/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.js index 484b24729ded..745ba363bb67 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.js @@ -451,7 +451,7 @@ tape( 'the function supports view offsets', function test( t ) { ]); // Create offset views... - cx1 = new Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + cx1 = new Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // begin at the 2nd element cy1 = new Complex64Array( cy0.buffer, cy0.BYTES_PER_ELEMENT*2 ); // begin at the 3rd element viewX = new Float32Array( cx0.buffer ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.native.js b/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.native.js index 6a4df7edec09..04590973af36 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.native.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/test/test.csrot.native.js @@ -460,7 +460,7 @@ tape( 'the function supports view offsets', opts, function test( t ) { ]); // Create offset views... - cx1 = new Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + cx1 = new Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // begin at the 2nd element cy1 = new Complex64Array( cy0.buffer, cy0.BYTES_PER_ELEMENT*2 ); // begin at the 3rd element viewX = new Float32Array( cx0.buffer ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.js index f93590461a6b..0d9db71b4727 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.js @@ -314,20 +314,6 @@ tape( 'the function supports a `y` stride', function test( t ) { t.end(); }); -tape( 'the function returns a reference to the destination array', function test( t ) { - var out; - var cx; - var cy; - - cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - out = csrot( 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; @@ -543,7 +529,7 @@ tape( 'the function supports complex access patterns', function test( t ) { -1.8, // 1 -2.4, // 1 -4.2, // 2 - -4.8 // 2 + -4.8 // 2 ] ); out = csrot( 2, cx, 2, 1, cy, 1, 2, 0.8, 0.6 ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.native.js index 254d484785e5..4f1ef061e22c 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/test/test.ndarray.native.js @@ -398,20 +398,6 @@ tape( 'the function returns a reference to the destination array', opts, functio t.end(); }); -tape( 'the function returns a reference to the destination array', opts, function test( t ) { - var out; - var cx; - var cy; - - cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - cy = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - out = csrot( 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; @@ -552,7 +538,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) -1.8, // 1 -2.4, // 1 -4.2, // 2 - -4.8 // 2 + -4.8 // 2 ] ); out = csrot( 2, cx, 2, 1, cy, 1, 2, 0.8, 0.6 ); From 8a20361740489516421449b8561f0d04d66895f1 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 11 Jul 2024 20:00:46 +0530 Subject: [PATCH 12/14] refactor: apply float32 emulation --- .../@stdlib/blas/base/csrot/lib/ndarray.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js index 003113d55960..5e76ea8a4803 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/lib/ndarray.js @@ -20,6 +20,7 @@ // MODULES // +var f32 = require( '@stdlib/number/float64/base/to-float32' ); var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); @@ -70,8 +71,7 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); function csrot( N, cx, strideX, offsetX, cy, strideY, offsetY, c, s ) { var viewX; var viewY; - var tmp1; - var tmp2; + var tmp; var sx; var sy; var ix; @@ -83,18 +83,20 @@ function csrot( N, cx, strideX, offsetX, cy, strideY, offsetY, c, s ) { } viewX = reinterpret( cx, 0 ); viewY = reinterpret( cy, 0 ); + c = f32( c ); + s = f32( s ); 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; + tmp = f32( c*viewX[ ix ] ) + f32( s*viewY[ iy ] ); + viewY[ iy ] = f32( c*viewY[ iy ] ) - f32( s*viewX[ ix ] ); + viewX[ ix ] = tmp; - tmp2 = ( c*viewX[ ix+1 ] ) + ( s*viewY[ iy+1 ] ); - viewY[ iy+1 ] = ( c*viewY[ iy+1 ] ) - ( s*viewX[ ix+1 ] ); - viewX[ ix+1 ] = tmp2; + tmp = f32( c*viewX[ ix+1 ] ) + f32( s*viewY[ iy+1 ] ); + viewY[ iy+1 ] = f32( c*viewY[ iy+1 ] ) - f32( s*viewX[ ix+1 ] ); + viewX[ ix+1 ] = tmp; ix += sx; iy += sy; From 040f0d915a0a33a4312fa9e2c66ab8b13675dc8b Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 11 Jul 2024 21:41:56 +0530 Subject: [PATCH 13/14] refactor: update paths and refactor array creation --- lib/node_modules/@stdlib/blas/base/csrot/README.md | 2 +- .../@stdlib/blas/base/csrot/benchmark/benchmark.js | 7 ++----- .../@stdlib/blas/base/csrot/benchmark/benchmark.native.js | 7 ++----- .../@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js | 7 ++----- .../blas/base/csrot/benchmark/benchmark.ndarray.native.js | 7 ++----- lib/node_modules/@stdlib/blas/base/csrot/examples/index.js | 2 +- 6 files changed, 10 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/csrot/README.md b/lib/node_modules/@stdlib/blas/base/csrot/README.md index 2f93acc10372..e46bee476a5a 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/README.md +++ b/lib/node_modules/@stdlib/blas/base/csrot/README.md @@ -233,7 +233,7 @@ im = imagf( z ); ```javascript var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); -var Complex64 = require( '@stdlib/complex/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); var ccopy = require( '@stdlib/blas/base/ccopy' ); var zeros = require( '@stdlib/array/zeros' ); var logEach = require( '@stdlib/console/log-each' ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.js index 4222249b9551..422d7cc6b885 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.js @@ -50,11 +50,8 @@ function createBenchmark( len ) { var cx; var cy; - cx = uniform( len*2, -100.0, 100.0, options ); - cx = new Complex64Array( cx.buffer ); - - cy = uniform( len*2, -100.0, 100.0, options ); - cy = new Complex64Array( cy.buffer ); + cx = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) ); + cy = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) ); return benchmark; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.native.js index fc4326d0ee71..ce7542e7e200 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.native.js @@ -55,11 +55,8 @@ function createBenchmark( len ) { var cx; var cy; - cx = uniform( len*2, -100.0, 100.0, options ); - cx = new Complex64Array( cx.buffer ); - - cy = uniform( len*2, -100.0, 100.0, options ); - cy = new Complex64Array( cy.buffer ); + cx = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) ); + cy = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) ); return benchmark; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js index 4e7e8091137d..8900dd8012d0 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js @@ -50,11 +50,8 @@ function createBenchmark( len ) { var cx; var cy; - cx = uniform( len*2, -100.0, 100.0, options ); - cx = new Complex64Array( cx.buffer ); - - cy = uniform( len*2, -100.0, 100.0, options ); - cy = new Complex64Array( cy.buffer ); + cx = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) ); + cy = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) ); return benchmark; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.native.js index 9759af4ae47e..73c19b57840b 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.native.js @@ -55,11 +55,8 @@ function createBenchmark( len ) { var cx; var cy; - cx = uniform( len*2, -100.0, 100.0, options ); - cx = new Complex64Array( cx.buffer ); - - cy = uniform( len*2, -100.0, 100.0, options ); - cy = new Complex64Array( cy.buffer ); + cx = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) ); + cy = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) ); return benchmark; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/examples/index.js b/lib/node_modules/@stdlib/blas/base/csrot/examples/index.js index f798e7c1d79a..0fd3fbc5eba5 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/examples/index.js @@ -20,7 +20,7 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); -var Complex64 = require( '@stdlib/complex/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); var ccopy = require( '@stdlib/blas/base/ccopy' ); var zeros = require( '@stdlib/array/zeros' ); var logEach = require( '@stdlib/console/log-each' ); From 38c794685c729e6ef6905a1303ae5cdf75a70541 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 13 Jul 2024 17:09:57 -0700 Subject: [PATCH 14/14] chore: clean-up docs, benchmarks, and native implementations --- .../blas/base/csrot/benchmark/benchmark.js | 6 +++--- .../base/csrot/benchmark/benchmark.native.js | 6 +++--- .../base/csrot/benchmark/benchmark.ndarray.js | 6 +++--- .../csrot/benchmark/benchmark.ndarray.native.js | 6 +++--- .../@stdlib/blas/base/csrot/docs/repl.txt | 6 +++--- .../blas/base/csrot/docs/types/index.d.ts | 2 +- .../@stdlib/blas/base/csrot/src/csrot.c | 16 ++++++++-------- .../@stdlib/blas/base/csrot/src/csrot.f | 10 +++++----- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.js index 422d7cc6b885..9c58e4b31fb7 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.js @@ -22,7 +22,7 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Complex64Array = require( '@stdlib/array/complex64' ); var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); @@ -69,12 +69,12 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { csrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnanf( viewX[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnanf( viewX[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.native.js index ce7542e7e200..1d332777e761 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.native.js @@ -23,7 +23,7 @@ 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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Complex64Array = require( '@stdlib/array/complex64' ); var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); @@ -74,12 +74,12 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { csrot( cx.length, cx, 1, cy, 1, 0.8, 0.6 ); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnanf( viewX[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnanf( viewX[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js index 8900dd8012d0..f5a2add8b887 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.js @@ -22,7 +22,7 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Complex64Array = require( '@stdlib/array/complex64' ); var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); @@ -69,12 +69,12 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { csrot( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnanf( viewX[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnanf( viewX[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.native.js index 73c19b57840b..229b0f5402fa 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/csrot/benchmark/benchmark.ndarray.native.js @@ -23,7 +23,7 @@ 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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var Complex64Array = require( '@stdlib/array/complex64' ); var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); @@ -74,12 +74,12 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { csrot( cx.length, cx, 1, 0, cy, 1, 0, 0.8, 0.6 ); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnanf( viewX[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnanf( viewX[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt index 6bc60dfc7d9b..fbed649a70f9 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/csrot/docs/repl.txt @@ -2,8 +2,8 @@ {{alias}}( N, cx, strideX, cy, strideY, c, s ) Applies a plane rotation. - The `N` and stride parameters determine how values in the strided arrays - are accessed at runtime. + The `N` and stride parameters determine how values in the strided arrays are + accessed at runtime. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -89,7 +89,7 @@ {{alias}}.ndarray( N, cx, strideX, offsetX, cy, strideY, offsetY, c, s ) - Applies a plane rotation. + Applies a plane rotation using alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting diff --git a/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts index 216ac8079913..08a87d31caf1 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/csrot/docs/types/index.d.ts @@ -69,7 +69,7 @@ interface Routine { ( N: number, cx: Complex64Array, strideX: number, cy: Complex64Array, strideY: number, c: number, s: number ): Complex64Array; /** - * Applies a plane rotation. + * Applies a plane rotation using alternative indexing semantics. * * @param N - number of indexed elements * @param cx - first input array diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c index 8707665f38d0..beba6c32cd9f 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.c @@ -47,13 +47,13 @@ void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *CX, const CBLAS_INT strideX, } if ( strideX == 1 && strideY == 1 ) { for ( i = 0; i < N*2; i += 2 ) { - tmp = c*x[ i ] + s*y[ i ]; - y[ i ] = c*y[ i ] - s*x[ i ]; + tmp = ( c*x[ i ] ) + ( s*y[ i ] ); + y[ i ] = ( c*y[ i ] ) - ( s*x[ i ] ); x[ i ] = tmp; j = i + 1; - tmp = c*x[ j ] + s*y[ j ]; - y[ j ] = c*y[ j ] - s*x[ j ]; + tmp = ( c*x[ j ] ) + ( s*y[ j ] ); + y[ j ] = ( c*y[ j ] ) - ( s*x[ j ] ); x[ j ] = tmp; } return; @@ -63,12 +63,12 @@ void API_SUFFIX(c_csrot)( const CBLAS_INT N, void *CX, const CBLAS_INT strideX, ix = stdlib_strided_stride2offset( N, strideX ); iy = stdlib_strided_stride2offset( N, strideY ); for ( i = 0; i < N; i++ ) { - tmp = c*x[ ix ] + s*y[ iy ]; - y[ iy ] = c*y[ iy ] - s*x[ ix ]; + tmp = ( c*x[ ix ] ) + ( s*y[ iy ] ); + y[ iy ] = ( c*y[ iy ] ) - ( s*x[ ix ] ); x[ ix ] = tmp; - tmp = c*x[ ix+1 ] + s*y[ iy+1 ]; - y[ iy+1 ] = c*y[ iy+1 ] - s*x[ ix+1 ]; + tmp = ( c*x[ ix+1 ] ) + ( s*y[ iy+1 ] ); + y[ iy+1 ] = ( c*y[ iy+1 ] ) - ( s*x[ ix+1 ] ); x[ ix+1 ] = tmp; ix += sx; diff --git a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f index 37dd14196112..5999d8d39198 100644 --- a/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f +++ b/lib/node_modules/@stdlib/blas/base/csrot/src/csrot.f @@ -69,8 +69,8 @@ subroutine csrot( N, cx, strideX, cy, strideY, c, s ) ! .. if ( strideX == 1 .AND. strideY == 1 ) then do i = 1, N - ctmp = c*cx( i ) + s*cy( i ) - cy( i ) = c*cy( i ) - s*cx( i ) + ctmp = ( c*cx( i ) ) + ( s*cy( i ) ) + cy( i ) = ( c*cy( i ) ) - ( s*cx( i ) ) cx( i ) = ctmp end do else @@ -85,12 +85,12 @@ subroutine csrot( N, cx, strideX, cy, strideY, c, s ) iy = 1 end if do i = 1, N - ctmp = c*cx( ix ) + s*cy( iy ) - cy( iy ) = c*cy( iy ) - s*cx( ix ) + ctmp = ( c*cx( ix ) ) + ( s*cy( iy ) ) + cy( iy ) = ( c*cy( iy ) ) - ( s*cx( ix ) ) cx( ix ) = ctmp ix = ix + strideX iy = iy + strideY end do end if return -end subroutine csrot +end subroutine csrot \ No newline at end of file