From e6ddd54eefbce2da036feb0d8918ef40c206ab4d Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 20 May 2024 21:46:57 +0530 Subject: [PATCH 1/7] feat: add BLAS Level 1 routine for zscal --- .../@stdlib/blas/base/zscal/README.md | 242 ++++++++++ .../blas/base/zscal/benchmark/benchmark.js | 114 +++++ .../base/zscal/benchmark/benchmark.native.js | 119 +++++ .../base/zscal/benchmark/benchmark.ndarray.js | 114 +++++ .../benchmark/benchmark.ndarray.native.js | 119 +++++ .../blas/base/zscal/benchmark/c/Makefile | 146 ++++++ .../base/zscal/benchmark/c/benchmark.length.c | 156 +++++++ .../base/zscal/benchmark/fortran/Makefile | 141 ++++++ .../benchmark/fortran/benchmark.length.f | 220 +++++++++ .../@stdlib/blas/base/zscal/binding.gyp | 265 +++++++++++ .../@stdlib/blas/base/zscal/docs/repl.txt | 123 ++++++ .../blas/base/zscal/docs/types/index.d.ts | 148 +++++++ .../blas/base/zscal/docs/types/test.ts | 202 +++++++++ .../blas/base/zscal/examples/c/Makefile | 146 ++++++ .../blas/base/zscal/examples/c/example.c | 43 ++ .../@stdlib/blas/base/zscal/examples/index.js | 38 ++ .../@stdlib/blas/base/zscal/include.gypi | 70 +++ .../zscal/include/stdlib/blas/base/zscal.h | 43 ++ .../include/stdlib/blas/base/zscal_cblas.h | 43 ++ .../include/stdlib/blas/base/zscal_fortran.h | 43 ++ .../@stdlib/blas/base/zscal/lib/index.js | 92 ++++ .../@stdlib/blas/base/zscal/lib/main.js | 35 ++ .../@stdlib/blas/base/zscal/lib/native.js | 35 ++ .../@stdlib/blas/base/zscal/lib/ndarray.js | 76 ++++ .../blas/base/zscal/lib/ndarray.native.js | 72 +++ .../@stdlib/blas/base/zscal/lib/zscal.js | 83 ++++ .../blas/base/zscal/lib/zscal.native.js | 67 +++ .../@stdlib/blas/base/zscal/manifest.json | 416 ++++++++++++++++++ .../@stdlib/blas/base/zscal/package.json | 81 ++++ .../@stdlib/blas/base/zscal/src/Makefile | 70 +++ .../@stdlib/blas/base/zscal/src/addon.c | 45 ++ .../@stdlib/blas/base/zscal/src/zscal.c | 56 +++ .../@stdlib/blas/base/zscal/src/zscal.f | 84 ++++ .../@stdlib/blas/base/zscal/src/zscal_cblas.c | 33 ++ .../@stdlib/blas/base/zscal/src/zscal_f.c | 33 ++ .../@stdlib/blas/base/zscal/test/test.js | 82 ++++ .../blas/base/zscal/test/test.ndarray.js | 319 ++++++++++++++ .../base/zscal/test/test.ndarray.native.js | 328 ++++++++++++++ .../blas/base/zscal/test/test.zscal.js | 304 +++++++++++++ .../blas/base/zscal/test/test.zscal.native.js | 313 +++++++++++++ 40 files changed, 5159 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/benchmark/fortran/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/benchmark/fortran/benchmark.length.f create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal.h create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_fortran.h create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/src/zscal.c create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/src/zscal.f create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/src/zscal_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/src/zscal_f.c create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.js create mode 100644 lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.native.js diff --git a/lib/node_modules/@stdlib/blas/base/zscal/README.md b/lib/node_modules/@stdlib/blas/base/zscal/README.md new file mode 100644 index 000000000000..1e03518e142d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/README.md @@ -0,0 +1,242 @@ + + +# zscal + +> Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. + +
+ +## Usage + +```javascript +var zscal = require( '@stdlib/blas/base/zscal' ); +``` + +#### zscal( N, za, zx, strideX ) + +Scales values from `zx` by `za`. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); + +var zx = new Complex128Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +var za = new Complex128( 2.0, 0.0 ); + +zscal( 3, za, zx, 1 ); + +var z = zx.get( 0 ); +// returns + +var re = real( z ); +// returns 2.0 + +var im = imag( z ); +// returns 2.0 +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **za**: scalar [`Complex128`][@stdlib/complex/float64] constant. +- **zx**: input [`Complex128Array`][@stdlib/array/complex128]. +- **strideX**: index increment for `zx`. + +The `N` and stride parameters determine how values from `zx` are scaled by `za`. For example, to scale every other value in `zx` by `za`, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); + +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var za = new Complex128( 2.0, 0.0 ); + +zscal( 2, za, zx, 2 ); + +var z = zx.get( 2 ); +// returns + +var re = real( z ); +// returns 10.0 + +var im = imag( z ); +// returns 12.0 +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); + +// Initial array: +var zx0 = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +// Define a scalar constant: +var za = new Complex128( 2.0, 2.0 ); + +// Create an offset view: +var zx1 = new Complex128Array( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +// Scales every other value from `zx1` by `za`... +zscal( 3, za, zx1, 1 ); + +var z = zx0.get( 1 ); +// returns + +var re = real( z ); +// returns -2.0 + +var im = imag( z ); +// returns 14.0 +``` + +#### zscal.ndarray( N, za, zx, strideX, offsetX ) + +Scales values from `zx` by `za` using alternative indexing semantics. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); + +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var za = new Complex128( 2.0, 2.0 ); + +zscal.ndarray( 3, za, zx, 1, 0 ); + +var z = zx.get( 0 ); +// returns + +var re = real( z ); +// returns -2.0 + +var im = imag( z ); +// returns 6.0 +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `zx`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to scale every other value in the input strided array starting from the second element, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); + +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var za = new Complex128( 2.0, 2.0 ); + +zscal.ndarray( 2, za, zx, 2, 1 ); + +var z = zx.get( 3 ); +// returns + +var re = real( z ); +// returns -2.0 + +var im = imag( z ); +// returns 30.0 +``` + +
+ + + +
+ +## Notes + +- If `N <= 0` or `strideX <= 0` , both functions return `zx` unchanged. +- `zscal()` corresponds to the [BLAS][blas] level 1 function [`zscal`][zscal]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var zscal = require( '@stdlib/blas/base/zscal' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var zx = filledarrayBy( 10, 'complex128', rand ); +console.log( zx.toString() ); + +var za = new Complex128( 2.0, 2.0 ); +console.log( za.toString() ); + +// Scales elements from `zx` by `za`: +zscal( zx.length, za, zx, 1 ); +console.log( zx.get( zx.length-1 ).toString() ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.js new file mode 100644 index 000000000000..756c29e2299e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.js @@ -0,0 +1,114 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var reinterpret = require('@stdlib/strided/base/reinterpret-complex128'); +var pkg = require( './../package.json' ).name; +var zscal = require( './../lib/zscal.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var viewX; + var za; + var zx; + + zx = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zx.buffer ); + + viewX = reinterpret( zx, 0 ); + + za = new Complex128( 1.0, 0.0 ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zscal( zx.length, za, zx, 1 ); + 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/zscal/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.native.js new file mode 100644 index 000000000000..59f8b5f95e56 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.native.js @@ -0,0 +1,119 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var reinterpret = require('@stdlib/strided/base/reinterpret-complex128'); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var zscal = tryRequire( resolve( __dirname, './../lib/zscal.native.js' ) ); +var opts = { + 'skip': ( zscal instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var viewX; + var za; + var zx; + + zx = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zx.buffer ); + + viewX = reinterpret( zx, 0 ); + + za = new Complex128( 1.0, 0.0 ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zscal( zx.length, za, zx, 1 ); + 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/zscal/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..1ac23e787607 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.js @@ -0,0 +1,114 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var reinterpret = require('@stdlib/strided/base/reinterpret-complex128'); +var pkg = require( './../package.json' ).name; +var zscal = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var viewX; + var za; + var zx; + + zx = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zx.buffer ); + + viewX = reinterpret( zx, 0 ); + + za = new Complex128( 1.0, 0.0 ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zscal( zx.length, za, zx, 1, 0 ); + 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+':ndarray:len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..74859a309b15 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,119 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var reinterpret = require('@stdlib/strided/base/reinterpret-complex128'); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var zscal = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( zscal instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var viewX; + var za; + var zx; + + zx = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zx.buffer ); + + viewX = reinterpret( zx, 0 ); + + za = new Complex128( 1.0, 0.0 ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zscal( zx.length, za, zx, 1, 0 ); + 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/zscal/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/Makefile new file mode 100644 index 000000000000..9f97140e7cb0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/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/zscal/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..9975222c1426 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c @@ -0,0 +1,156 @@ +/** +* @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. +*/ + +/** +* Benchmark `zscal`. +*/ +#include "stdlib/blas/base/zscal.h" +#include "stdlib/complex/float64.h" +#include +#include +#include +#include +#include + +#define NAME "zscal" +#define ITERATIONS 10000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +void print_results( int iterations, double elapsed ) { + double rate = (double)iterations / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", iterations ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1]. +* +* @return random number +*/ +double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +double benchmark( int iterations, int len ) { + stdlib_complex128_t za; + double elapsed; + double zx[ len*2 ]; + double t; + int i; + + za = stdlib_complex128( rand_double()*1.0, rand_double()*0.0 ); + for ( i = 0; i < len; i++ ) { + zx[ i ] = ( rand_double()*10000.0 ) - 5000.0; + zx[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_zscal( len, za, (void *)zx, 1 ); + if ( zx[ 0 ] != zx[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( zx[ 0 ] != zx[ 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/zscal/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/fortran/Makefile new file mode 100644 index 000000000000..28b70ff7f607 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/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/zscal.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/zscal/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/fortran/benchmark.length.f new file mode 100644 index 000000000000..0af494d5e905 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/fortran/benchmark.length.f @@ -0,0 +1,220 @@ +!> +! @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. +!< + +!> Benchmark `zscal`. +! +! ## Notes +! +! - Written in "free form" Fortran 95. +! +!< +program bench + implicit none + ! .. + ! Local constants: + character(5), parameter :: name = 'zscal' ! 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 zscal( N, za, zx, strideX ) + complex(kind=kind(0.0d0)) :: za, zx(*) + integer :: strideX, N + end subroutine zscal + end interface + ! .. + ! Scalar arguments: + integer, intent(in) :: iterations, len + ! .. + ! Local scalars: + double precision :: elapsed, r1, r2 + real :: t1, t2 + integer :: i + ! .. + ! Local array: + complex(kind=kind(0.0d0)), allocatable :: x(:) + ! .. + ! Local scalar: + complex(kind=kind(0.0d0)) :: za + ! .. + ! Intrinsic functions: + intrinsic random_number, cpu_time, cmplx + ! .. + ! Allocate array: + allocate( x(len) ) + ! .. + za = cmplx( (r1*1.0d0), (r2*0.0d0), kind=kind(0.0d0) ) + do i = 1, len + call random_number( r1 ) + call random_number( r2 ) + x( i ) = cmplx( (r1*10000.0d0)-5000.0d0, (r2*1000.0d0)-5000.0d0, kind=kind(0.0d0) ) + end do + ! .. + call cpu_time( t1 ) + ! .. + do i = 1, iterations + call zscal( len, za, x, 1 ); + if ( x( 1 ) /= x( 1 ) ) then + print '(A)', 'should not return NaN' + exit + end if + end do + ! .. + call cpu_time( t2 ) + ! .. + elapsed = t2 - t1 + ! .. + if ( x( 1 ) /= x( 1 ) ) then + print '(A)', 'should not return NaN' + end if + ! .. + ! Deallocate array: + deallocate( x ) + ! .. + 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/zscal/binding.gyp b/lib/node_modules/@stdlib/blas/base/zscal/binding.gyp new file mode 100644 index 000000000000..02a2799da097 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/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/zscal/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/zscal/docs/repl.txt new file mode 100644 index 000000000000..4360f9a6542b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/docs/repl.txt @@ -0,0 +1,123 @@ + +{{alias}}( N, za, zx, strideX ) + Scales a double-precision complex floating-point vector by a double- + precision complex floating-point constant. + + The `N` and stride parameters determine how values from `zx` are scaled by + `za`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N` or `strideX` is less than or equal to `0`, the function returns `zx` + unchanged. + + + Parameters + ---------- + N: integer + Number of indexed elements. + + za: Complex128 + Complex constant. + + zx: Complex128Array + Input array. + + strideX: integer + Index increment for `zx`. + + Returns + ------- + zx: Complex128Array + Input array. + + Examples + -------- + // Standard usage: + > var zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var za = new {{alias:@stdlib/complex/float64}}( 1.0, 2.0 ); + > {{alias}}( 2, za, zx, 1 ); + > var z = zx.get( 0 ); + > var re = {{alias:@stdlib/complex/real}}( z ) + -3.0 + > var im = {{alias:@stdlib/complex/imag}}( z ) + 4.0 + + // Advanced indexing: + > zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > za = new {{alias:@stdlib/complex/float64}}( 1.0, 1.0 ); + > {{alias}}( 2, za, zx, 2 ); + > z = zx.get( 0 ); + > re = {{alias:@stdlib/complex/real}}( z ) + -1.0 + > im = {{alias:@stdlib/complex/imag}}( z ) + 3.0 + + // Using typed array views: + > var zx0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var zx1 = new {{alias:@stdlib/array/complex128}}( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); + > var za = new {{alias:@stdlib/complex/float64}}( 2.0, 2.0 ); + > {{alias}}( 2, za, zx1, 1 ); + > z = zx0.get( 1 ); + > re = {{alias:@stdlib/complex/real}}( z ) + -2.0 + > im = {{alias:@stdlib/complex/imag}}( z ) + 14.0 + + +{{alias}}.ndarray( N, za, zx, strideX, offsetX ) + Scales a double-precision complex floating-point vector by a double- + precision complex floating-point constant using alternative indexing + semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameter supports indexing semantics based on a + starting index. + + Parameters + ---------- + N: integer + Number of indexed elements. + + za: Complex128 + Complex constant. + + zx: Complex128Array + Input array. + + strideX: integer + Index increment for `zx`. + + offsetX: integer + Starting index for `zx`. + + Returns + ------- + zx: Complex128Array + Input array. + + Examples + -------- + // Standard usage: + > var zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var za = new {{alias:@stdlib/complex/float64}}( 2.0, 2.0 ); + > {{alias}}.ndarray( 2, za, zx, 1, 0 ); + > var z = zx.get( 0 ); + > var re = {{alias:@stdlib/complex/real}}( z ) + -2.0 + > var im = {{alias:@stdlib/complex/imag}}( z ) + 6.0 + + // Advanced indexing: + > zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > za = new {{alias:@stdlib/complex/float64}}( 1.0, 2.0 ); + > {{alias}}.ndarray( 2, za, zx, 1, 2 ); + > z = zx.get( 2 ); + > re = {{alias:@stdlib/complex/real}}( z ) + -7.0 + > im = {{alias:@stdlib/complex/imag}}( z ) + 16.0 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/zscal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/zscal/docs/types/index.d.ts new file mode 100644 index 000000000000..77d7f7e9310e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/docs/types/index.d.ts @@ -0,0 +1,148 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Complex128Array } from '@stdlib/types/array'; +import { Complex128 } from '@stdlib/types/complex'; + +/** +* Interface describing `zscal`. +*/ +interface Routine { + /** + * Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. + * + * @param N - number of indexed elements + * @param za - scalar constant + * @param zx - input array + * @param strideX - `zx` stride length + * @returns input array + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * var Complex128 = require( '@stdlib/complex/float64' ); + * var real = require( '@stdlib/complex/real' ); + * var imag = require( '@stdlib/complex/imag' ); + * + * var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var za = new Complex128( 2.0, 2.0 ); + * + * zscal( 3, za, zx, 1 ); + * + * var z = zx.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns -2.0 + * + * var im = imag( z ); + * // returns 6.0 + */ + ( N: number, ca: Complex128, cx: Complex128Array, strideX: number ): Complex128Array; + + /** + * Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. + * + * @param N - number of indexed elements + * @param za - scalar constant + * @param zx - input array + * @param strideX - `zx` stride length + * @param offsetX - starting index for `zx` + * @returns input array + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * var Complex128 = require( '@stdlib/complex/float64' ); + * var real = require( '@stdlib/complex/real' ); + * var imag = require( '@stdlib/complex/imag' ); + * + * var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var za = new Complex128( 2.0, 2.0 ); + * + * zscal.ndarray( 3, za, zx, 1, 0 ); + * + * var z = cx.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns -2.0 + * + * var im = imag( z ); + * // returns 6.0 + */ + ndarray( N: number, ca: Complex128, cx: Complex128Array, strideX: number, offsetX: number ): Complex128Array; +} + +/** +* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. +* +* @param N - number of indexed elements +* @param za - scalar constant +* @param zx - input array +* @param strideX - `zx` stride length +* @returns input array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var za = new Complex128( 2.0, 2.0 ); +* +* zscal( 3, za, zx, 1 ); +* +* var z = zx.get( 1 ); +* // returns +* +* var re = real( z ); +* // returns -2.0 +* +* var im = imag( z ); +* // returns 14.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var za = new Complex128( 2.0, 2.0 ); +* +* zscal.ndarray( 2, za, zx, 1, 1 ); +* +* var z = zx.get( 1 ); +* // returns +* +* var re = real( z ); +* // returns -2.0 +* +* var im = imag( z ); +* // returns 14.0 +*/ +declare var zscal: Routine; + + +// EXPORTS // + +export = zscal; diff --git a/lib/node_modules/@stdlib/blas/base/zscal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/zscal/docs/types/test.ts new file mode 100644 index 000000000000..501c3d9e0945 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/docs/types/test.ts @@ -0,0 +1,202 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Complex128Array = require( '@stdlib/array/complex128' ); +import Complex128 = require( '@stdlib/complex/float64' ); +import zscal = require( './index' ); + + +// TESTS // + +// The function returns a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + const za = new Complex128( 2.0, 2.0 ); + + zscal( zx.length, za, zx, 1 ); // $ExpectType Complex128Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const za = new Complex128( 2.0, 2.0 ); + + zscal( '10', za, zx, 1 ); // $EzxpectError + zscal( true, za, zx, 1 ); // $ExpectError + zscal( false, za, zx, 1 ); // $ExpectError + zscal( null, za, zx, 1 ); // $ExpectError + zscal( undefined, za, zx, 1 ); // $ExpectError + zscal( [], za, zx, 1 ); // $ExpectError + zscal( {}, za, zx, 1 ); // $ExpectError + zscal( ( zx: number ): number => zx, za, zx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a complex number... +{ + const zx = new Complex128Array( 10 ); + + zscal( zx.length, 10, zx, 1 ); // $ExpectError + zscal( zx.length, '10', zx, 1 ); // $ExpectError + zscal( zx.length, true, zx, 1 ); // $ExpectError + zscal( zx.length, false, zx, 1 ); // $ExpectError + zscal( zx.length, null, zx, 1 ); // $ExpectError + zscal( zx.length, undefined, zx, 1 ); // $ExpectError + zscal( zx.length, [ '1' ], zx, 1 ); // $ExpectError + zscal( zx.length, {}, zx, 1 ); // $ExpectError + zscal( zx.length, ( zx: number ): number => zx, zx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + const za = new Complex128( 2.0, 2.0 ); + + zscal( zx.length, za, 10, 1 ); // $ExpectError + zscal( zx.length, za, '10', 1 ); // $ExpectError + zscal( zx.length, za, true, 1 ); // $ExpectError + zscal( zx.length, za, false, 1 ); // $ExpectError + zscal( zx.length, za, null, 1 ); // $ExpectError + zscal( zx.length, za, undefined, 1 ); // $ExpectError + zscal( zx.length, za, [ '1' ], 1 ); // $ExpectError + zscal( zx.length, za, {}, 1 ); // $ExpectError + zscal( zx.length, za, ( zx: number ): number => zx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const za = new Complex128( 2.0, 2.0 ); + + zscal( zx.length, za, zx, '10' ); // $ExpectError + zscal( zx.length, za, zx, true ); // $ExpectError + zscal( zx.length, za, zx, false ); // $ExpectError + zscal( zx.length, za, zx, null ); // $ExpectError + zscal( zx.length, za, zx, undefined ); // $ExpectError + zscal( zx.length, za, zx, [] ); // $ExpectError + zscal( zx.length, za, zx, {} ); // $ExpectError + zscal( zx.length, za, zx, ( zx: number ): number => zx ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const zx = new Complex128Array( 10 ); + const za = new Complex128( 2.0, 2.0 ); + + zscal(); // $ExpectError + zscal( zx.length ); // $ExpectError + zscal( zx.length, za ); // $ExpectError + zscal( zx.length, za, zx ); // $ExpectError + zscal( zx.length, za, zx, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + const za = new Complex128( 2.0, 2.0 ); + + zscal.ndarray( zx.length, za, zx, 1, 0 ); // $ExpectType Complex128Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const za = new Complex128( 2.0, 2.0 ); + + zscal.ndarray( '10', za, zx, 1, 0 ); // $ExpectError + zscal.ndarray( true, za, zx, 1, 0 ); // $ExpectError + zscal.ndarray( false, za, zx, 1, 0 ); // $ExpectError + zscal.ndarray( null, za, zx, 1, 0 ); // $ExpectError + zscal.ndarray( undefined, za, zx, 1, 0 ); // $ExpectError + zscal.ndarray( [], za, zx, 1, 0 ); // $ExpectError + zscal.ndarray( {}, za, zx, 1, 0 ); // $ExpectError + zscal.ndarray( ( zx: number ): number => zx, za, zx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a complex number... +{ + const zx = new Complex128Array( 10 ); + + zscal.ndarray( zx.length, 10, zx, 1, 0 ); // $ExpectError + zscal.ndarray( zx.length, '10', zx, 1, 0 ); // $ExpectError + zscal.ndarray( zx.length, true, zx, 1, 0 ); // $ExpectError + zscal.ndarray( zx.length, false, zx, 1, 0 ); // $ExpectError + zscal.ndarray( zx.length, null, zx, 1, 0 ); // $ExpectError + zscal.ndarray( zx.length, undefined, zx, 1, 0 ); // $ExpectError + zscal.ndarray( zx.length, [ '1' ], zx, 1, 0 ); // $ExpectError + zscal.ndarray( zx.length, {}, zx, 1, 0 ); // $ExpectError + zscal.ndarray( zx.length, ( zx: number ): number => zx, zx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + const za = new Complex128( 2.0, 2.0 ); + + zscal( zx.length, za, 10, 1, 0 ); // $ExpectError + zscal( zx.length, za, '10', 1, 0 ); // $ExpectError + zscal( zx.length, za, true, 1, 0 ); // $ExpectError + zscal( zx.length, za, false, 1, 0 ); // $ExpectError + zscal( zx.length, za, null, 1, 0 ); // $ExpectError + zscal( zx.length, za, undefined, 1, 0 ); // $ExpectError + zscal( zx.length, za, [ '1' ], 1, 0 ); // $ExpectError + zscal( zx.length, za, {}, 1, 0 ); // $ExpectError + zscal( zx.length, za, ( zx: number ): number => zx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const za = new Complex128( 2.0, 2.0 ); + + zscal.ndarray( zx.length, za, zx, '10', 0 ); // $ExpectError + zscal.ndarray( zx.length, za, zx, true, 0 ); // $ExpectError + zscal.ndarray( zx.length, za, zx, false, 0 ); // $ExpectError + zscal.ndarray( zx.length, za, zx, null, 0 ); // $ExpectError + zscal.ndarray( zx.length, za, zx, undefined, 0 ); // $ExpectError + zscal.ndarray( zx.length, za, zx, [], 0 ); // $ExpectError + zscal.ndarray( zx.length, za, zx, {}, 0 ); // $ExpectError + zscal.ndarray( zx.length, za, zx, ( zx: number ): number => zx, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + const za = new Complex128( 2.0, 2.0 ); + + zscal.ndarray( zx.length, za, zx, 1, '10' ); // $ExpectError + zscal.ndarray( zx.length, za, zx, 1, true ); // $ExpectError + zscal.ndarray( zx.length, za, zx, 1, false ); // $ExpectError + zscal.ndarray( zx.length, za, zx, 1, null ); // $ExpectError + zscal.ndarray( zx.length, za, zx, 1, undefined ); // $ExpectError + zscal.ndarray( zx.length, za, zx, 1, [] ); // $ExpectError + zscal.ndarray( zx.length, za, zx, 1, {} ); // $ExpectError + zscal.ndarray( zx.length, za, zx, 1, ( zx: number ): number => zx ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const zx = new Complex128Array( 10 ); + const za = new Complex128( 2.0, 2.0 ); + + zscal.ndarray(); // $ExpectError + zscal.ndarray( zx.length ); // $ExpectError + zscal.ndarray( zx.length, za ); // $ExpectError + zscal.ndarray( zx.length, za, zx ); // $ExpectError + zscal.ndarray( zx.length, za, zx, 1 ); // $ExpectError + zscal.ndarray( zx.length, za, zx, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/zscal/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/zscal/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/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/zscal/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/zscal/examples/c/example.c new file mode 100644 index 000000000000..9df2c1c7d0fe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/examples/c/example.c @@ -0,0 +1,43 @@ +/** +* @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/zscal.h" +#include "stdlib/complex/float64.h" +#include + +int main( void ) { + // Create strided array: + double zx[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + + // Create a complex scalar: + const stdlib_complex128_t za = stdlib_complex128( 2.0, 2.0 ); + + // Specify the number of elements: + const int N = 4; + + // Specify stride length: + const int strideX = 1; + + // Scale the elements of the array: + c_zscal( N, za, (void *)zx, strideX ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "zx[ %i ] = %f + %fj\n", i, zx[ i*2 ], zx[ (i*2)+1 ] ); + } +} diff --git a/lib/node_modules/@stdlib/blas/base/zscal/examples/index.js b/lib/node_modules/@stdlib/blas/base/zscal/examples/index.js new file mode 100644 index 000000000000..ddd388916335 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/examples/index.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var zscal = require( '@stdlib/blas/base/zscal' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var zx = filledarrayBy( 10, 'complex128', rand ); +console.log( zx.toString() ); + +var za = new Complex128( 2.0, 2.0 ); +console.log( za.toString() ); + +// Scales elements from `zx` by `za`: +zscal( zx.length, za, zx, 1 ); +console.log( zx.get( zx.length-1 ).toString() ); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/include.gypi b/lib/node_modules/@stdlib/blas/base/zscal/include.gypi new file mode 100644 index 000000000000..497aeca15320 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/include.gypi @@ -0,0 +1,70 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Note that nesting variables is required due to how GYP processes a configuration. Any variables defined within a nested 'variables' section is defined in the outer scope. Thus, conditions in the outer variable scope are free to use these variables without running into "variable undefined" errors. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +# +# Variable nesting hacks: +# +# [3]: https://chromium.googlesource.com/external/skia/gyp/+/master/common_variables.gypi +# [4]: https://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + 'variables': { + # Host BLAS library (to override -Dblas=): + 'blas%': '', + + # Path to BLAS library (to override -Dblas_dir=): + 'blas_dir%': '', + }, # end variables + + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<@(blas_dir)', + ' +* +* var re = real( z ); +* // returns -2.0 +* +* var im = imag( z ); +* // returns 6.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* var zscal = require( '@stdlib/blas/base/zscal' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var za = new Complex128( 2.0, 2.0 ); +* +* zscal.ndarray( 3, za zx, 1, 0 ); +* +* var z = y.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns -2.0 +* +* var im = imag( z ); +* // returns 6.0 +*/ + +// 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 zscal; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + zscal = main; +} else { + zscal = tmp; +} + + +// EXPORTS // + +module.exports = zscal; + +// exports: { "ndarray": "zscal.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/zscal/lib/main.js b/lib/node_modules/@stdlib/blas/base/zscal/lib/main.js new file mode 100644 index 000000000000..e7e50f59e0d2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/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 zscal = require( './zscal.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( zscal, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = zscal; diff --git a/lib/node_modules/@stdlib/blas/base/zscal/lib/native.js b/lib/node_modules/@stdlib/blas/base/zscal/lib/native.js new file mode 100644 index 000000000000..2bd82a0f56a8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/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 zscal = require( './zscal.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( zscal, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = zscal; diff --git a/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.js new file mode 100644 index 000000000000..0e6c61bedd7c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.js @@ -0,0 +1,76 @@ +/** +* @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 cmul = require( '@stdlib/math/base/ops/cmul' ); + + +// MAIN // + +/** +* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128} za - constant +* @param {Complex128Array} zx - input array +* @param {integer} strideX - `zx` stride length +* @param {NonNegativeInteger} offsetX - starting `zx` index +* @returns {Complex128Array} input array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var za = new Complex128( 2.0, 2.0 ); +* +* zscal( 3, za, zx, 1, 0 ); +* +* var z = zx.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns -2.0 +* +* var im = imag( z ); +* // returns 6.0 +*/ +function zscal( N, za, zx, strideX, offsetX ) { + var ix; + var i; + + if ( N <= 0 || strideX <= 0 ) { + return zx; + } + ix = offsetX; + for ( i = 0; i < N; i++ ) { + zx.set( cmul( za, zx.get( ix ) ), ix ); + ix += strideX; + } + return zx; +} + + +// EXPORTS // + +module.exports = zscal; diff --git a/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.native.js new file mode 100644 index 000000000000..637d6281b795 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.native.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Scales a single-precision complex floating-point vector by a single-precision complex floating-point constant. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128} za - scalar constant +* @param {Complex128Array} zx - input array +* @param {integer} strideX - `zx` stride length +* @param {NonNegativeInteger} offsetX - starting `zx` index +* @returns {Complex128Array} input array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var za = new Complex128( 2.0, 2.0 ); +* +* zscal( zx.length, za, zx, 1, 0 ); +* +* var z = zx.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns -2.0 +* +* var im = imag( z ); +* // returns 6.0 +*/ +function zscal( N, za, zx, strideX, offsetX ) { + var viewZX; + + offsetX = minViewBufferIndex( N, strideX, offsetX ); + viewZX = reinterpret( zx, offsetX ); + addon( N, za, viewZX, strideX ); + return zx; +} + + +// EXPORTS // + +module.exports = zscal; diff --git a/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.js b/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.js new file mode 100644 index 000000000000..ddb40188e8ef --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.js @@ -0,0 +1,83 @@ +/** +* @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 cmul = require( '@stdlib/math/base/ops/cmul' ); + + +// MAIN // + +/** +* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128} za - constant +* @param {Complex128Array} zx - input array +* @param {integer} strideX - `cx` stride length +* @returns {Complex128Array} input array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var za = new Complex128( 2.0, 2.0 ); +* +* zscal( 3, za, zx, 1 ); +* +* var z = zx.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns -2.0 +* +* var im = imag( z ); +* // returns 6.0 +*/ +function zscal( N, za, zx, strideX ) { + var ix; + var i; + + if ( N <= 0 || strideX <= 0 ) { + return zx; + } + if ( strideX === 1 ) { + // Code for stride equal to `1`... + for ( i = 0; i < N; i++ ) { + zx.set( cmul( za, zx.get( i ) ), i ); + } + return zx; + } + // Code for stride not equal to `1`... + ix = 0; + for ( i = 0; i < N; i++ ) { + zx.set( cmul( za, zx.get( ix ) ), ix ); + ix += strideX; + } + return zx; +} + + +// EXPORTS // + +module.exports = zscal; diff --git a/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.native.js b/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.native.js new file mode 100644 index 000000000000..5bb1559c2808 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.native.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128} za - scalar constant +* @param {Complex128Array} zx - input array +* @param {integer} strideX - `x` stride length +* @returns {Complex128Array} input array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64' ); +* var real = require( '@stdlib/complex/real' ); +* var imag = require( '@stdlib/complex/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var za = new Complex128( 2.0, 2.0 ); +* +* zscal( zx.length, za, zx, 1 ); +* +* var z = zx.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns -2.0 +* +* var im = imag( z ); +* // returns 6.0 +*/ +function zscal( N, za, zx, strideX ) { + var viewZX = reinterpret( zx, 0 ); + addon( N, za, viewZX, strideX ); + return zx; +} + + +// EXPORTS // + +module.exports = zscal; diff --git a/lib/node_modules/@stdlib/blas/base/zscal/manifest.json b/lib/node_modules/@stdlib/blas/base/zscal/manifest.json new file mode 100644 index 000000000000..df484c6c6a56 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/manifest.json @@ -0,0 +1,416 @@ +{ + "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/zscal.f", + "./src/zscal_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/argv-complex128", + "@stdlib/complex/float64", + "@stdlib/math/base/ops/cmul" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/zscal.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/ops/cmul", + "@stdlib/complex/float64" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/zscal.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/ops/cmul", + "@stdlib/complex/float64" + ] + }, + + { + "task": "build", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zscal_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/argv-complex128", + "@stdlib/complex/float64", + "@stdlib/math/base/ops/cmul" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zscal_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zscal_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [] + }, + + { + "task": "build", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/zscal.f", + "./src/zscal_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/argv-complex128", + "@stdlib/complex/float64", + "@stdlib/math/base/ops/cmul" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/zscal.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/ops/cmul" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/zscal.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/ops/cmul" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/zscal_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/argv-complex128", + "@stdlib/complex/float64", + "@stdlib/math/base/ops/cmul" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/zscal_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/zscal_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [] + }, + + { + "task": "build", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zscal_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/argv-complex128", + "@stdlib/complex/float64", + "@stdlib/math/base/ops/cmul" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zscal_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zscal_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [] + }, + + { + "task": "build", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/zscal.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/argv-complex128", + "@stdlib/complex/float64", + "@stdlib/math/base/ops/cmul" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/zscal.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/ops/cmul", + "@stdlib/complex/float64" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/zscal.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/ops/cmul", + "@stdlib/complex/float64" + ] + }, + + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/zscal.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/ops/cmul", + "@stdlib/complex/float64" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/zscal/package.json b/lib/node_modules/@stdlib/blas/base/zscal/package.json new file mode 100644 index 000000000000..1bd946050155 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/package.json @@ -0,0 +1,81 @@ +{ + "name": "@stdlib/blas/base/zscal", + "version": "0.0.0", + "description": "Scale a double-precision complex floating-point vector by a double-precision complex floating-point constant.", + "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", + "zscal", + "scale", + "cp", + "vector", + "typed", + "array", + "ndarray", + "complex", + "complex128", + "float", + "float64", + "float64array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/blas/base/zscal/src/Makefile b/lib/node_modules/@stdlib/blas/base/zscal/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/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/zscal/src/addon.c b/lib/node_modules/@stdlib/blas/base/zscal/src/addon.c new file mode 100644 index 000000000000..6f4979fd6fd4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/src/addon.c @@ -0,0 +1,45 @@ +/** +* @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/zscal.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_complex128.h" +#include "stdlib/napi/argv_strided_complex128array.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 4 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_COMPLEX128( env, ZA, argv, 1 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, ZX, N, strideX, argv, 2 ); + c_zscal( N, ZA, (void *)ZX, strideX ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.c b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.c new file mode 100644 index 000000000000..4d2939ef0b35 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.c @@ -0,0 +1,56 @@ +/** +* @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/zscal.h" +#include "stdlib/complex/float64.h" +#include "stdlib/math/base/ops/cmul.h" + +/** +* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. +* +* @param N number of indexed elements +* @param ZA scalar constant +* @param ZX input array +* @param strideX ZX stride length +*/ +void c_zscal( const int N, const stdlib_complex128_t ZA, const void *ZX, const int strideX ) { + stdlib_complex128_t za = ZA; + stdlib_complex128_t z; + int i; + + uint8_t *ip1 = (uint8_t *)ZX; + int64_t is1 = 16 * strideX; + + if ( N <= 0 || strideX <= 0 ) { + return; + } + if ( strideX == 1 ) { + // Code for stride equal to `1`... + for ( i = 0; i < N; i++, ip1 += is1 ) { + z = *( (stdlib_complex128_t *)ip1 ); + *( (stdlib_complex128_t *)ip1 ) = stdlib_base_cmul( za, z ); + } + return; + } + // Code for stride not equal to `1`... + for ( i = 0; i < N; i++, ip1 += is1 ) { + z = *( (stdlib_complex128_t *)ip1 ); + *( (stdlib_complex128_t *)ip1 ) = stdlib_base_cmul( za, z ); + } + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.f b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.f new file mode 100644 index 000000000000..78bf05b78f76 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.f @@ -0,0 +1,84 @@ +!> +! @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. +!< + +!> Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. +! +! ## 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 {complex} za - scalar constant +! @param {Array>} zx - input array +! @param {integer} strideX - `zx` stride length +!< +subroutine zscal( N, za, zx, strideX ) + implicit none + ! .. + ! Scalar arguments: + complex(kind=kind(0.0d0)) :: za + integer :: strideX, N + ! .. + ! Array arguments: + complex(kind=kind(0.0d0)) :: zx(*) + ! .. + ! Local scalars: + integer :: ix, i + ! .. + if ( N <= 0 .OR. strideX <= 0 ) then + return + end if + ! .. + if ( strideX == 1 ) then + do i = 1, N + zx(i) = za * zx(i) + end do + else + ix = 1 + do i = 1, N + zx(ix) = za * zx(ix) + ix = ix + strideX + end do + end if + return +end subroutine zscal \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_cblas.c b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_cblas.c new file mode 100644 index 000000000000..bafa0e0430dd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_cblas.c @@ -0,0 +1,33 @@ +/** +* @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/zscal.h" +#include "stdlib/blas/base/zscal_cblas.h" +#include "stdlib/complex/float64.h" + +/** +* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. +* +* @param N number of indexed elements +* @param ZA scalar constant +* @param ZX input array +* @param strideX ZX stride length +*/ +void c_zscal( const int N, const stdlib_complex128_t ZA, const void *ZX, const int strideX ) { + cblas_zscal( N, ZA, ZX, strideX ); +} diff --git a/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_f.c b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_f.c new file mode 100644 index 000000000000..91bfd017648f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_f.c @@ -0,0 +1,33 @@ +/** +* @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/zscal.h" +#include "stdlib/blas/base/zscal_fortran.h" +#include "stdlib/complex/float64.h" + +/** +* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. +* +* @param N number of indexed elements +* @param ZA scalar constant +* @param ZX input array +* @param strideX ZX stride length +*/ +void c_zscal( const int N, const stdlib_complex128_t ZA, const void *ZX, const int strideX ) { + zscal( &N, &ZA, ZX, &strideX ); +} diff --git a/lib/node_modules/@stdlib/blas/base/zscal/test/test.js b/lib/node_modules/@stdlib/blas/base/zscal/test/test.js new file mode 100644 index 000000000000..3758552bb3c0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/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 zscal = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': isBrowser +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zscal, '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 zscal.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 zscal = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zscal, 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 zscal; + var main; + + main = require( './../lib/zscal.js' ); + + zscal = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zscal, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.js new file mode 100644 index 000000000000..fd47c12b3566 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.js @@ -0,0 +1,319 @@ +/** +* @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 Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var zscal = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zscal, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( zscal.length, 5, 'arity of 5' ); + t.end(); +}); + +tape( 'the function scales elements from `zx` by `za`', function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.3, // 1 + 0.1, // 1 + 0.5, // 2 + 0.0, // 2 + 0.0, // 3 + 0.5, // 3 + 0.0, // 4 + 0.2, // 4 + 2.0, + 3.0, + 2.0, + 3.0 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 4, za, zx, 1, 0 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + 0.19, // 1 + -0.17, // 1 + 0.2, // 2 + -0.35, // 2 + 0.35, // 3 + 0.2, // 3 + 0.14, // 4 + 0.08, // 4 + 2.0, + 3.0, + 2.0, + 3.0 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 1.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports a `zx` stride', function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.1, // 1 + 0.1, // 1 + 3.0, + 6.0, + -0.6, // 2 + 0.1, // 2 + 4.0, + 7.0, + 0.1, // 3 + -0.3, // 3 + 7.0, + 2.0 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 3, za, zx, 2, 0 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + 0.11, // 1 + -0.03, // 1 + 3.0, + 6.0, + -0.17, // 2 + 0.46, // 2 + 4.0, + 7.0, + -0.17, // 3 + -0.19, // 3 + 7.0, + 2.0 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 5.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports a `zx` offset', function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 4.0, // 1 + 6.0, // 1 + 0.1, // 2 + -0.3, // 2 + 7.0, // 3 + 2.0 // 3 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 3, za, zx, 1, 3 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 5.8, // 1 + -0.4, // 1 + -0.17, // 2 + -0.19, // 2 + 4.2, // 3 + -4.1 // 3 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 8.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function returns a reference to the input array', function test( t ) { + var out; + var za; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + za = new Complex128( 2.0, 2.0 ); + + out = zscal( 4, za, zx, 1, 0 ); + + t.strictEqual( out, zx, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', function test( t ) { + var expected; + var viewX; + var za; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + za = new Complex128( 2.0, 2.0 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + zscal( -1, za, zx, 1, 0 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + zscal( 0, za, zx, 1, 0 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `strideX` parameter less than or equal to `0`, the function returns the input array unchanged', function test( t ) { + var expected; + var viewX; + var za; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + za = new Complex128( 2.0, 2.0 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + zscal( 4, za, zx, -1, 3 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + zscal( 4, za, zx, 0, 3 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 4.0, // 1 + 6.0, // 1 + 0.1, + -0.3, + 7.0, + 2.0, + 2.0, // 2 + 3.0 // 2 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 2, za, zx, 3, 3 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 5.8, // 1 + -0.4, // 1 + 0.1, + -0.3, + 7.0, + 2.0, + 2.9, // 2 + -0.2 // 2 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 10.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.native.js new file mode 100644 index 000000000000..141c4b030a19 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.native.js @@ -0,0 +1,328 @@ +/** +* @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 Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var zscal = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( zscal instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zscal, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', opts, function test( t ) { + t.strictEqual( zscal.length, 5, 'arity of 5' ); + t.end(); +}); + +tape( 'the function scales elements from `zx` by `za`', opts, function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.3, // 1 + 0.1, // 1 + 0.5, // 2 + 0.0, // 2 + 0.0, // 3 + 0.5, // 3 + 0.0, // 4 + 0.2, // 4 + 2.0, + 3.0, + 2.0, + 3.0 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 4, za, zx, 1, 0 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + 0.19, // 1 + -0.17, // 1 + 0.2, // 2 + -0.35, // 2 + 0.35, // 3 + 0.2, // 3 + 0.14, // 4 + 0.08, // 4 + 2.0, + 3.0, + 2.0, + 3.0 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 1.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports a `zx` stride', opts, function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.1, // 1 + 0.1, // 1 + 3.0, + 6.0, + -0.6, // 2 + 0.1, // 2 + 4.0, + 7.0, + 0.1, // 3 + -0.3, // 3 + 7.0, + 2.0 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 3, za, zx, 2, 0 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + 0.11, // 1 + -0.03, // 1 + 3.0, + 6.0, + -0.17, // 2 + 0.46, // 2 + 4.0, + 7.0, + -0.17, // 3 + -0.19, // 3 + 7.0, + 2.0 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 5.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports a `zx` offset', opts, function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 4.0, // 1 + 6.0, // 1 + 0.1, // 2 + -0.3, // 2 + 7.0, // 3 + 2.0 // 3 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 3, za, zx, 1, 3 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 5.8, // 1 + -0.4, // 1 + -0.17, // 2 + -0.19, // 2 + 4.2, // 3 + -4.1 // 3 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 8.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function returns a reference to the input array', opts, function test( t ) { + var out; + var za; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + za = new Complex128( 2.0, 2.0 ); + + out = zscal( 4, za, zx, 1, 0 ); + + t.strictEqual( out, zx, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', opts, function test( t ) { + var expected; + var viewX; + var za; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + za = new Complex128( 2.0, 2.0 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + zscal( -1, za, zx, 1, 0 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + zscal( 0, za, zx, 1, 0 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `strideX` parameter less than or equal to `0`, the function returns the input array unchanged', opts, function test( t ) { + var expected; + var viewX; + var za; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + za = new Complex128( 2.0, 2.0 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + zscal( 4, za, zx, -1, 3 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + zscal( 4, za, zx, 0, 3 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', opts, function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 4.0, // 1 + 6.0, // 1 + 0.1, + -0.3, + 7.0, + 2.0, + 2.0, // 2 + 3.0 // 2 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 2, za, zx, 3, 3 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 5.8, // 1 + -0.4, // 1 + 0.1, + -0.3, + 7.0, + 2.0, + 2.9, // 2 + -0.2 // 2 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 10.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.js b/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.js new file mode 100644 index 000000000000..dc9ca289fd5f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.js @@ -0,0 +1,304 @@ +/** +* @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 Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var zscal = require( './../lib/zscal.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zscal, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( zscal.length, 4, 'arity of 4' ); + t.end(); +}); + +tape( 'the function scales elements from `zx` by `za`', function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.3, // 1 + 0.1, // 1 + 0.5, // 2 + 0.0, // 2 + 0.0, // 3 + 0.5, // 3 + 0.0, // 4 + 0.2 // 4 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 4, za, zx, 1 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + 0.19, // 1 + -0.17, // 1 + 0.2, // 2 + -0.35, // 2 + 0.35, // 3 + 0.2, // 3 + 0.14, // 4 + 0.08 // 4 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 1.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports a `zx` stride', function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.1, // 1 + 0.1, // 1 + 3.0, + 6.0, + -0.6, // 2 + 0.1, // 2 + 4.0, + 7.0, + 0.1, // 3 + -0.3, // 3 + 7.0, + 2.0 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 3, za, zx, 2 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + 0.11, // 1 + -0.03, // 1 + 3.0, + 6.0, + -0.17, // 2 + 0.46, // 2 + 4.0, + 7.0, + -0.17, // 3 + -0.19, // 3 + 7.0, + 2.0 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 5.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function returns a reference to the input array', function test( t ) { + var out; + var za; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + za = new Complex128( 2.0, 2.0 ); + + out = zscal( 4, za, zx, 1 ); + + t.strictEqual( out, zx, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', function test( t ) { + var expected; + var viewX; + var za; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + za = new Complex128( 2.0, 2.0 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + zscal( -1, za, zx, 1 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + zscal( 0, za, zx, 1 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `strideX` parameter less than or equal to `0`, the function returns the input array unchanged', function test( t ) { + var expected; + var viewX; + var za; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + za = new Complex128( 2.0, 2.0 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + zscal( 4, za, zx, -1 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + zscal( 4, za, zx, 0 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.1, // 1 + -0.3, // 1 + 8.0, + 9.0, + 0.5, // 2 + -0.1, // 2 + 2.0, + 5.0, + 2.0, + 3.0 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 2, za, zx, 2 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + -0.17, // 1 + -0.19, // 1 + 8.0, + 9.0, + 0.13, // 2 + -0.39, // 2 + 2.0, + 5.0, + 2.0, + 3.0 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 1.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var zx0; + var zx1; + var za; + var k; + + // Initial arrays... + zx0 = new Complex128Array( [ + 0.1, + -0.3, + 8.0, // 1 + 9.0, // 1 + 0.5, // 2 + -0.1, // 2 + 2.0, // 3 + 5.0, // 3 + 2.0, + 3.0 + ] ); + za = new Complex128( 0.4, -0.7 ); + + // Create offset views... + zx1 = new Complex128Array( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + + zscal( 3, za, zx1, 1 ); + + viewX = new Float64Array( zx0.buffer ); + expected = new Float64Array( [ + 0.1, + -0.3, + 9.5, // 1 + -2.0, // 1 + 0.13, // 2 + -0.39, // 2 + 4.3, // 3 + 0.6, // 3 + 2.0, + 3.0 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 1.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.native.js b/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.native.js new file mode 100644 index 000000000000..4a0031324106 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.native.js @@ -0,0 +1,313 @@ +/** +* @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 Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var zscal = tryRequire( resolve( __dirname, './../lib/zscal.native.js' ) ); +var opts = { + 'skip': ( zscal instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zscal, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', opts, function test( t ) { + t.strictEqual( zscal.length, 4, 'arity of 4' ); + t.end(); +}); + +tape( 'the function scales elements from `zx` by `za`', opts, function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.3, // 1 + 0.1, // 1 + 0.5, // 2 + 0.0, // 2 + 0.0, // 3 + 0.5, // 3 + 0.0, // 4 + 0.2 // 4 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 4, za, zx, 1 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + 0.19, // 1 + -0.17, // 1 + 0.2, // 2 + -0.35, // 2 + 0.35, // 3 + 0.2, // 3 + 0.14, // 4 + 0.08 // 4 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 1.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports a `zx` stride', opts, function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.1, // 1 + 0.1, // 1 + 3.0, + 6.0, + -0.6, // 2 + 0.1, // 2 + 4.0, + 7.0, + 0.1, // 3 + -0.3, // 3 + 7.0, + 2.0 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 3, za, zx, 2 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + 0.11, // 1 + -0.03, // 1 + 3.0, + 6.0, + -0.17, // 2 + 0.46, // 2 + 4.0, + 7.0, + -0.17, // 3 + -0.19, // 3 + 7.0, + 2.0 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 5.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function returns a reference to the input array', opts, function test( t ) { + var out; + var za; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + za = new Complex128( 2.0, 2.0 ); + + out = zscal( 4, za, zx, 1 ); + + t.strictEqual( out, zx, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', opts, function test( t ) { + var expected; + var viewX; + var za; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + za = new Complex128( 2.0, 2.0 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + zscal( -1, za, zx, 1 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + zscal( 0, za, zx, 1 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `strideX` parameter less than or equal to `0`, the function returns the input array unchanged', opts, function test( t ) { + var expected; + var viewX; + var za; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + za = new Complex128( 2.0, 2.0 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + zscal( 4, za, zx, -1 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + zscal( 4, za, zx, 0 ); + t.deepEqual( viewX, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', opts, function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var za; + var zx; + var k; + + zx = new Complex128Array( [ + 0.1, // 1 + -0.3, // 1 + 8.0, + 9.0, + 0.5, // 2 + -0.1, // 2 + 2.0, + 5.0, + 2.0, + 3.0 + ] ); + za = new Complex128( 0.4, -0.7 ); + + zscal( 2, za, zx, 2 ); + + viewX = new Float64Array( zx.buffer ); + expected = new Float64Array( [ + -0.17, // 1 + -0.19, // 1 + 8.0, + 9.0, + 0.13, // 2 + -0.39, // 2 + 2.0, + 5.0, + 2.0, + 3.0 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 1.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var expected; + var delta; + var viewX; + var tol; + var zx0; + var zx1; + var za; + var k; + + // Initial arrays... + zx0 = new Complex128Array( [ + 0.1, + -0.3, + 8.0, // 1 + 9.0, // 1 + 0.5, // 2 + -0.1, // 2 + 2.0, // 3 + 5.0, // 3 + 2.0, + 3.0 + ] ); + za = new Complex128( 0.4, -0.7 ); + + // Create offset views... + zx1 = new Complex128Array( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + + zscal( 3, za, zx1, 1 ); + + viewX = new Float64Array( zx0.buffer ); + expected = new Float64Array( [ + 0.1, + -0.3, + 9.5, // 1 + -2.0, // 1 + 0.13, // 2 + -0.39, // 2 + 4.3, // 3 + 0.6, // 3 + 2.0, + 3.0 + ] ); + for ( k = 0; k < expected.length; k++ ) { + if ( viewX[ k ] === expected[ k ] ) { + t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); + } else { + delta = abs( viewX[ k ] - expected[ k ] ); + tol = 1.0 * EPS * abs( expected[ k ] ); + t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); From 7aa36d04c798a4c7aaa82d3735b6d6e964191da1 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 20 May 2024 22:05:36 +0530 Subject: [PATCH 2/7] chore: resolve lint errors --- .../@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal.h | 2 +- .../blas/base/zscal/include/stdlib/blas/base/zscal_cblas.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal.h b/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal.h index 2b15a50f1e6a..e2a14b02aaa0 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal.h +++ b/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal.h @@ -34,7 +34,7 @@ extern "C" { /** * Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. */ -void c_zscal( const int N, const stdlib_complex128_t CA, const void *CX, const int strideX ); +void c_zscal( const int N, const stdlib_complex128_t ZA, const void *ZX, const int strideX ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_cblas.h b/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_cblas.h index 7599ecf4bf5e..53c44e5275d3 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_cblas.h @@ -34,7 +34,7 @@ extern "C" { /** * Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. */ -void cblas_zscal( const int N, const stdlib_complex128_t CA, const void *CX, const int strideX ); +void cblas_zscal( const int N, const stdlib_complex128_t ZA, const void *ZX, const int strideX ); #ifdef __cplusplus } From 25937621d983b341547579079491fd0cb5980655 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Tue, 21 May 2024 20:55:53 +0530 Subject: [PATCH 3/7] chore: apply review changes --- lib/node_modules/@stdlib/blas/base/zscal/examples/c/example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/zscal/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/zscal/examples/c/example.c index 9df2c1c7d0fe..ebe815ce7642 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/zscal/examples/c/example.c @@ -38,6 +38,6 @@ int main( void ) { // Print the result: for ( int i = 0; i < N; i++ ) { - printf( "zx[ %i ] = %f + %fj\n", i, zx[ i*2 ], zx[ (i*2)+1 ] ); + printf( "zx[ %i ] = %lf + %lfj\n", i, zx[ i*2 ], zx[ (i*2)+1 ] ); } } From 7945831b164351396497d919c52fe3bcb1826b56 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 10 Jun 2024 14:03:58 +0530 Subject: [PATCH 4/7] chore: apply review changes --- .../@stdlib/blas/base/zscal/README.md | 122 ++++++++++++++++-- .../blas/base/zscal/benchmark/benchmark.js | 15 +-- .../base/zscal/benchmark/benchmark.native.js | 15 +-- .../base/zscal/benchmark/benchmark.ndarray.js | 15 +-- .../benchmark/benchmark.ndarray.native.js | 15 +-- .../base/zscal/benchmark/c/benchmark.length.c | 6 +- .../benchmark/fortran/benchmark.length.f | 2 + .../@stdlib/blas/base/zscal/docs/repl.txt | 10 +- .../blas/base/zscal/docs/types/index.d.ts | 14 +- .../blas/base/zscal/docs/types/test.ts | 2 +- .../blas/base/zscal/examples/c/example.c | 4 +- .../@stdlib/blas/base/zscal/examples/index.js | 2 +- .../zscal/include/stdlib/blas/base/zscal.h | 5 +- .../include/stdlib/blas/base/zscal_cblas.h | 5 +- .../include/stdlib/blas/base/zscal_fortran.h | 4 +- .../@stdlib/blas/base/zscal/lib/index.js | 6 +- .../@stdlib/blas/base/zscal/lib/ndarray.js | 2 +- .../blas/base/zscal/lib/ndarray.native.js | 5 +- .../@stdlib/blas/base/zscal/lib/zscal.js | 4 +- .../blas/base/zscal/lib/zscal.native.js | 4 +- .../@stdlib/blas/base/zscal/manifest.json | 75 +++++++---- .../@stdlib/blas/base/zscal/package.json | 3 +- .../@stdlib/blas/base/zscal/src/addon.c | 4 +- .../@stdlib/blas/base/zscal/src/zscal.c | 20 +-- .../@stdlib/blas/base/zscal/src/zscal.f | 1 + .../@stdlib/blas/base/zscal/src/zscal_cblas.c | 9 +- .../@stdlib/blas/base/zscal/src/zscal_f.c | 9 +- .../blas/base/zscal/test/test.ndarray.js | 2 +- .../base/zscal/test/test.ndarray.native.js | 2 +- .../blas/base/zscal/test/test.zscal.js | 52 +------- .../blas/base/zscal/test/test.zscal.native.js | 52 +------- 31 files changed, 252 insertions(+), 234 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zscal/README.md b/lib/node_modules/@stdlib/blas/base/zscal/README.md index 1e03518e142d..f27ef7888305 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/README.md +++ b/lib/node_modules/@stdlib/blas/base/zscal/README.md @@ -36,7 +36,7 @@ Scales values from `zx` by `za`. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/real' ); var imag = require( '@stdlib/complex/imag' ); @@ -58,7 +58,7 @@ var im = imag( z ); The function has the following parameters: - **N**: number of indexed elements. -- **za**: scalar [`Complex128`][@stdlib/complex/float64] constant. +- **za**: scalar [`Complex128`][@stdlib/complex/float64/ctor] constant. - **zx**: input [`Complex128Array`][@stdlib/array/complex128]. - **strideX**: index increment for `zx`. @@ -66,7 +66,7 @@ The `N` and stride parameters determine how values from `zx` are scaled by `za`. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/real' ); var imag = require( '@stdlib/complex/imag' ); @@ -91,7 +91,7 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/real' ); var imag = require( '@stdlib/complex/imag' ); @@ -123,7 +123,7 @@ Scales values from `zx` by `za` using alternative indexing semantics. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/real' ); var imag = require( '@stdlib/complex/imag' ); @@ -150,7 +150,7 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/real' ); var imag = require( '@stdlib/complex/imag' ); @@ -193,7 +193,7 @@ var im = imag( z ); ```javascript var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var zscal = require( '@stdlib/blas/base/zscal' ); function rand() { @@ -215,6 +215,110 @@ console.log( zx.get( zx.length-1 ).toString() ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/zscal.h" +``` + +#### c_zscal( N, za, \*ZX, strideX ) + +Scales values from `ZX` by `za`. + +```c +#include "stdlib/complex/float64/ctor.h" + +double zx[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; +const stdlib_complex128_t za = stdlib_complex128( 2.0, 2.0 ); + +c_zscal( 4, za, (void *)zx, 1 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **za**: `[in] stdlib_complex128_t` scalar constant. +- **ZX**: `[inout] void*` input array. +- **strideX**: `[in] CBLAS_INT` index increment for `ZX`. + +```c +void c_zscal( const CBLAS_INT N, const stdlib_complex128_t za, void *ZX, const CBLAS_INT strideX ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/zscal.h" +#include "stdlib/complex/float64/ctor.h" +#include + +int main( void ) { + // Create a strided array of interleaved real and imaginary components: + double zx[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + + // Create a complex scalar: + const stdlib_complex128_t ca = stdlib_complex128( 2.0, 2.0 ); + + // Specify the number of elements: + const int N = 4; + + // Specify stride length: + const int strideX = 1; + + // Scale the elements of the array: + c_zscal( N, za, (void *)zx, strideX ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "zx[ %i ] = %f + %fj\n", i, zx[ i*2 ], zx[ (i*2)+1 ] ); + } +} +``` + +
+ + + +
+ + + diff --git a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.js index 756c29e2299e..411fa52eaa30 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.js @@ -25,8 +25,7 @@ var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); -var reinterpret = require('@stdlib/strided/base/reinterpret-complex128'); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var pkg = require( './../package.json' ).name; var zscal = require( './../lib/zscal.js' ); @@ -48,14 +47,12 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var viewX; + var zxbuf; var za; var zx; - zx = uniform( len*2, -100.0, 100.0, options ); - zx = new Complex128Array( zx.buffer ); - - viewX = reinterpret( zx, 0 ); + zxbuf = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zxbuf.buffer ); za = new Complex128( 1.0, 0.0 ); @@ -73,12 +70,12 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { zscal( zx.length, za, zx, 1 ); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnan( zxbuf[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnan( zxbuf[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.native.js index 59f8b5f95e56..4c0b66f05081 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.native.js @@ -26,8 +26,7 @@ var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); -var reinterpret = require('@stdlib/strided/base/reinterpret-complex128'); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -53,14 +52,12 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var viewX; + var zxbuf; var za; var zx; - zx = uniform( len*2, -100.0, 100.0, options ); - zx = new Complex128Array( zx.buffer ); - - viewX = reinterpret( zx, 0 ); + zxbuf = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zxbuf.buffer ); za = new Complex128( 1.0, 0.0 ); @@ -78,12 +75,12 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { zscal( zx.length, za, zx, 1 ); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnan( zxbuf[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnan( zxbuf[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.js index 1ac23e787607..4784b36e9801 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.js @@ -25,8 +25,7 @@ var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); -var reinterpret = require('@stdlib/strided/base/reinterpret-complex128'); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var pkg = require( './../package.json' ).name; var zscal = require( './../lib/ndarray.js' ); @@ -48,14 +47,12 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var viewX; + var zxbuf; var za; var zx; - zx = uniform( len*2, -100.0, 100.0, options ); - zx = new Complex128Array( zx.buffer ); - - viewX = reinterpret( zx, 0 ); + zxbuf = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zxbuf.buffer ); za = new Complex128( 1.0, 0.0 ); @@ -73,12 +70,12 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { zscal( zx.length, za, zx, 1, 0 ); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnan( zxbuf[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnan( zxbuf[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.native.js index 74859a309b15..5b78b2319e67 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/benchmark.ndarray.native.js @@ -26,8 +26,7 @@ var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); -var reinterpret = require('@stdlib/strided/base/reinterpret-complex128'); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -53,14 +52,12 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var viewX; + var zxbuf; var za; var zx; - zx = uniform( len*2, -100.0, 100.0, options ); - zx = new Complex128Array( zx.buffer ); - - viewX = reinterpret( zx, 0 ); + zxbuf = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zxbuf.buffer ); za = new Complex128( 1.0, 0.0 ); @@ -78,12 +75,12 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { zscal( zx.length, za, zx, 1, 0 ); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnan( zxbuf[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( viewX[ i%(len*2) ] ) ) { + if ( isnan( zxbuf[ i%(len*2) ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c index 9975222c1426..41a7b1ed2b58 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c @@ -20,7 +20,7 @@ * Benchmark `zscal`. */ #include "stdlib/blas/base/zscal.h" -#include "stdlib/complex/float64.h" +#include "stdlib/complex/float64/ctor.h" #include #include #include @@ -100,13 +100,13 @@ double rand_double( void ) { */ double benchmark( int iterations, int len ) { stdlib_complex128_t za; - double elapsed; double zx[ len*2 ]; + double elapsed; double t; int i; za = stdlib_complex128( rand_double()*1.0, rand_double()*0.0 ); - for ( i = 0; i < len; i++ ) { + for ( i = 0; i < len*2; i+=2 ) { zx[ i ] = ( rand_double()*10000.0 ) - 5000.0; zx[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0; } diff --git a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/fortran/benchmark.length.f index 0af494d5e905..be01acef38b8 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/fortran/benchmark.length.f +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/fortran/benchmark.length.f @@ -150,6 +150,8 @@ end subroutine zscal ! Allocate array: allocate( x(len) ) ! .. + call random_number( r1 ) + call random_number( r2 ) za = cmplx( (r1*1.0d0), (r2*0.0d0), kind=kind(0.0d0) ) do i = 1, len call random_number( r1 ) diff --git a/lib/node_modules/@stdlib/blas/base/zscal/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/zscal/docs/repl.txt index 4360f9a6542b..e142823b857a 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/zscal/docs/repl.txt @@ -36,7 +36,7 @@ -------- // Standard usage: > var zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var za = new {{alias:@stdlib/complex/float64}}( 1.0, 2.0 ); + > var za = new {{alias:@stdlib/complex/float64/ctor}}( 1.0, 2.0 ); > {{alias}}( 2, za, zx, 1 ); > var z = zx.get( 0 ); > var re = {{alias:@stdlib/complex/real}}( z ) @@ -46,7 +46,7 @@ // Advanced indexing: > zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > za = new {{alias:@stdlib/complex/float64}}( 1.0, 1.0 ); + > za = new {{alias:@stdlib/complex/float64/ctor}}( 1.0, 1.0 ); > {{alias}}( 2, za, zx, 2 ); > z = zx.get( 0 ); > re = {{alias:@stdlib/complex/real}}( z ) @@ -57,7 +57,7 @@ // Using typed array views: > var zx0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var zx1 = new {{alias:@stdlib/array/complex128}}( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); - > var za = new {{alias:@stdlib/complex/float64}}( 2.0, 2.0 ); + > var za = new {{alias:@stdlib/complex/float64/ctor}}( 2.0, 2.0 ); > {{alias}}( 2, za, zx1, 1 ); > z = zx0.get( 1 ); > re = {{alias:@stdlib/complex/real}}( z ) @@ -101,7 +101,7 @@ -------- // Standard usage: > var zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var za = new {{alias:@stdlib/complex/float64}}( 2.0, 2.0 ); + > var za = new {{alias:@stdlib/complex/float64/ctor}}( 2.0, 2.0 ); > {{alias}}.ndarray( 2, za, zx, 1, 0 ); > var z = zx.get( 0 ); > var re = {{alias:@stdlib/complex/real}}( z ) @@ -111,7 +111,7 @@ // Advanced indexing: > zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - > za = new {{alias:@stdlib/complex/float64}}( 1.0, 2.0 ); + > za = new {{alias:@stdlib/complex/float64/ctor}}( 1.0, 2.0 ); > {{alias}}.ndarray( 2, za, zx, 1, 2 ); > z = zx.get( 2 ); > re = {{alias:@stdlib/complex/real}}( z ) diff --git a/lib/node_modules/@stdlib/blas/base/zscal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/zscal/docs/types/index.d.ts index 77d7f7e9310e..31280d0f711e 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/zscal/docs/types/index.d.ts @@ -38,7 +38,7 @@ interface Routine { * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); - * var Complex128 = require( '@stdlib/complex/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/real' ); * var imag = require( '@stdlib/complex/imag' ); * @@ -56,7 +56,7 @@ interface Routine { * var im = imag( z ); * // returns 6.0 */ - ( N: number, ca: Complex128, cx: Complex128Array, strideX: number ): Complex128Array; + ( N: number, za: Complex128, zx: Complex128Array, strideX: number ): Complex128Array; /** * Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. @@ -70,7 +70,7 @@ interface Routine { * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); - * var Complex128 = require( '@stdlib/complex/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/real' ); * var imag = require( '@stdlib/complex/imag' ); * @@ -79,7 +79,7 @@ interface Routine { * * zscal.ndarray( 3, za, zx, 1, 0 ); * - * var z = cx.get( 0 ); + * var z = zx.get( 0 ); * // returns * * var re = real( z ); @@ -88,7 +88,7 @@ interface Routine { * var im = imag( z ); * // returns 6.0 */ - ndarray( N: number, ca: Complex128, cx: Complex128Array, strideX: number, offsetX: number ): Complex128Array; + ndarray( N: number, za: Complex128, zx: Complex128Array, strideX: number, offsetX: number ): Complex128Array; } /** @@ -102,7 +102,7 @@ interface Routine { * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/real' ); * var imag = require( '@stdlib/complex/imag' ); * @@ -122,7 +122,7 @@ interface Routine { * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/real' ); * var imag = require( '@stdlib/complex/imag' ); * diff --git a/lib/node_modules/@stdlib/blas/base/zscal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/zscal/docs/types/test.ts index 501c3d9e0945..3a8aced11a20 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/zscal/docs/types/test.ts @@ -17,7 +17,7 @@ */ import Complex128Array = require( '@stdlib/array/complex128' ); -import Complex128 = require( '@stdlib/complex/float64' ); +import Complex128 = require( '@stdlib/complex/float64/ctor' ); import zscal = require( './index' ); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/zscal/examples/c/example.c index ebe815ce7642..3ff3c69a730c 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/zscal/examples/c/example.c @@ -17,11 +17,11 @@ */ #include "stdlib/blas/base/zscal.h" -#include "stdlib/complex/float64.h" +#include "stdlib/complex/float64/ctor.h" #include int main( void ) { - // Create strided array: + // Create a strided array of interleaved real and imaginary components: double zx[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; // Create a complex scalar: diff --git a/lib/node_modules/@stdlib/blas/base/zscal/examples/index.js b/lib/node_modules/@stdlib/blas/base/zscal/examples/index.js index ddd388916335..b84e75d78eac 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/examples/index.js @@ -20,7 +20,7 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var zscal = require( '@stdlib/blas/base/zscal' ); function rand() { diff --git a/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal.h b/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal.h index e2a14b02aaa0..98bc1f5a1dce 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal.h +++ b/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal.h @@ -22,7 +22,8 @@ #ifndef ZSCAL_H #define ZSCAL_H -#include "stdlib/complex/float64.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. @@ -34,7 +35,7 @@ extern "C" { /** * Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. */ -void c_zscal( const int N, const stdlib_complex128_t ZA, const void *ZX, const int strideX ); +void API_SUFFIX(c_zscal)( const CBLAS_INT N, const stdlib_complex128_t za, void *ZX, const CBLAS_INT strideX ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_cblas.h b/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_cblas.h index 53c44e5275d3..c80d88d58980 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_cblas.h @@ -22,7 +22,8 @@ #ifndef ZSCAL_CBLAS_H #define ZSCAL_CBLAS_H -#include "stdlib/complex/float64.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. @@ -34,7 +35,7 @@ extern "C" { /** * Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. */ -void cblas_zscal( const int N, const stdlib_complex128_t ZA, const void *ZX, const int strideX ); +void API_SUFFIX(cblas_zscal)( const CBLAS_INT N, const stdlib_complex128_t za, void *ZX, const CBLAS_INT strideX ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_fortran.h b/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_fortran.h index 7eef9facdec9..a8205aae7770 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_fortran.h +++ b/lib/node_modules/@stdlib/blas/base/zscal/include/stdlib/blas/base/zscal_fortran.h @@ -22,7 +22,7 @@ #ifndef ZSCAL_FORTRAN_H #define ZSCAL_FORTRAN_H -#include "stdlib/complex/float64.h" +#include "stdlib/complex/float64/ctor.h" /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C/Fortran compiler (a Fortran compiler must be configured to not attach underscores). @@ -34,7 +34,7 @@ extern "C" { /** * Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. */ -void zscal( const int *, const stdlib_complex128_t *, const void *, const int * ); +void zscal( const int *, const stdlib_complex128_t *, void *, const int * ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/zscal/lib/index.js b/lib/node_modules/@stdlib/blas/base/zscal/lib/index.js index a42652fb29a1..3823b60ea9d4 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/lib/index.js @@ -25,7 +25,7 @@ * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/real' ); * var imag = require( '@stdlib/complex/imag' ); * var zscal = require( '@stdlib/blas/base/zscal' ); @@ -46,7 +46,7 @@ * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/real' ); * var imag = require( '@stdlib/complex/imag' ); * var zscal = require( '@stdlib/blas/base/zscal' ); @@ -56,7 +56,7 @@ * * zscal.ndarray( 3, za zx, 1, 0 ); * -* var z = y.get( 0 ); +* var z = zx.get( 0 ); * // returns * * var re = real( z ); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.js index 0e6c61bedd7c..a1d87385f027 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.js @@ -37,7 +37,7 @@ var cmul = require( '@stdlib/math/base/ops/cmul' ); * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/real' ); * var imag = require( '@stdlib/complex/imag' ); * diff --git a/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.native.js index 637d6281b795..7ca9e6514dfc 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/lib/ndarray.native.js @@ -28,7 +28,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Scales a single-precision complex floating-point vector by a single-precision complex floating-point constant. +* Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. * * @param {PositiveInteger} N - number of indexed elements * @param {Complex128} za - scalar constant @@ -39,7 +39,7 @@ var addon = require( './../src/addon.node' ); * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/real' ); * var imag = require( '@stdlib/complex/imag' ); * @@ -59,7 +59,6 @@ var addon = require( './../src/addon.node' ); */ function zscal( N, za, zx, strideX, offsetX ) { var viewZX; - offsetX = minViewBufferIndex( N, strideX, offsetX ); viewZX = reinterpret( zx, offsetX ); addon( N, za, viewZX, strideX ); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.js b/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.js index ddb40188e8ef..fc064cb599fd 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.js @@ -31,12 +31,12 @@ var cmul = require( '@stdlib/math/base/ops/cmul' ); * @param {PositiveInteger} N - number of indexed elements * @param {Complex128} za - constant * @param {Complex128Array} zx - input array -* @param {integer} strideX - `cx` stride length +* @param {integer} strideX - `zx` stride length * @returns {Complex128Array} input array * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/real' ); * var imag = require( '@stdlib/complex/imag' ); * diff --git a/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.native.js b/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.native.js index 5bb1559c2808..2e587b941f78 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.native.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/lib/zscal.native.js @@ -32,12 +32,12 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} N - number of indexed elements * @param {Complex128} za - scalar constant * @param {Complex128Array} zx - input array -* @param {integer} strideX - `x` stride length +* @param {integer} strideX - `zx` stride length * @returns {Complex128Array} input array * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/real' ); * var imag = require( '@stdlib/complex/imag' ); * diff --git a/lib/node_modules/@stdlib/blas/base/zscal/manifest.json b/lib/node_modules/@stdlib/blas/base/zscal/manifest.json index df484c6c6a56..e2ec18a53fff 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/zscal/manifest.json @@ -43,12 +43,13 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64", + "@stdlib/complex/float64/ctor", "@stdlib/math/base/ops/cmul" ] }, @@ -66,8 +67,9 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/math/base/ops/cmul", - "@stdlib/complex/float64" + "@stdlib/complex/float64/ctor" ] }, { @@ -84,8 +86,9 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/math/base/ops/cmul", - "@stdlib/complex/float64" + "@stdlib/complex/float64/ctor" ] }, @@ -106,13 +109,13 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64", - "@stdlib/math/base/ops/cmul" + "@stdlib/complex/float64/ctor" ] }, { @@ -131,7 +134,10 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float32/ctor" + ] }, { "task": "examples", @@ -149,7 +155,10 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float32/ctor" + ] }, { @@ -167,13 +176,13 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64", - "@stdlib/math/base/ops/cmul" + "@stdlib/complex/float64/ctor" ] }, { @@ -190,7 +199,9 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/ops/cmul" + "@stdlib/blas/base/shared", + "@stdlib/math/base/ops/cmul", + "@stdlib/complex/float64/ctor" ] }, { @@ -207,7 +218,9 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/ops/cmul" + "@stdlib/blas/base/shared", + "@stdlib/math/base/ops/cmul", + "@stdlib/complex/float64/ctor" ] }, @@ -227,13 +240,13 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64", - "@stdlib/math/base/ops/cmul" + "@stdlib/complex/float64/ctor" ] }, { @@ -251,7 +264,10 @@ "-lblas" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor" + ] }, { "task": "examples", @@ -268,7 +284,10 @@ "-lblas" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor" + ] }, { @@ -288,13 +307,13 @@ ], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64", - "@stdlib/math/base/ops/cmul" + "@stdlib/complex/float64/ctor" ] }, { @@ -313,7 +332,10 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor" + ] }, { "task": "examples", @@ -331,7 +353,10 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor" + ] }, { @@ -348,12 +373,13 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64", + "@stdlib/complex/float64/ctor", "@stdlib/math/base/ops/cmul" ] }, @@ -371,8 +397,9 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/math/base/ops/cmul", - "@stdlib/complex/float64" + "@stdlib/complex/float64/ctor" ] }, { @@ -389,8 +416,9 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/math/base/ops/cmul", - "@stdlib/complex/float64" + "@stdlib/complex/float64/ctor" ] }, @@ -408,8 +436,9 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", "@stdlib/math/base/ops/cmul", - "@stdlib/complex/float64" + "@stdlib/complex/float64/ctor" ] } ] diff --git a/lib/node_modules/@stdlib/blas/base/zscal/package.json b/lib/node_modules/@stdlib/blas/base/zscal/package.json index 1bd946050155..c7f829097ff5 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/package.json +++ b/lib/node_modules/@stdlib/blas/base/zscal/package.json @@ -64,14 +64,13 @@ "subroutines", "zscal", "scale", - "cp", "vector", "typed", "array", "ndarray", "complex", "complex128", - "float", + "double", "float64", "float64array" ], diff --git a/lib/node_modules/@stdlib/blas/base/zscal/src/addon.c b/lib/node_modules/@stdlib/blas/base/zscal/src/addon.c index 6f4979fd6fd4..684dc692db65 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/zscal/src/addon.c @@ -36,9 +36,9 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 4 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); - STDLIB_NAPI_ARGV_COMPLEX128( env, ZA, argv, 1 ); + STDLIB_NAPI_ARGV_COMPLEX128( env, za, argv, 1 ); STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, ZX, N, strideX, argv, 2 ); - c_zscal( N, ZA, (void *)ZX, strideX ); + c_zscal( N, za, (void *)ZX, strideX ); return NULL; } diff --git a/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.c b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.c index 4d2939ef0b35..cdc4144778d8 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.c +++ b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.c @@ -17,21 +17,22 @@ */ #include "stdlib/blas/base/zscal.h" -#include "stdlib/complex/float64.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" #include "stdlib/math/base/ops/cmul.h" +#include /** * Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. * * @param N number of indexed elements -* @param ZA scalar constant +* @param za scalar constant * @param ZX input array * @param strideX ZX stride length */ -void c_zscal( const int N, const stdlib_complex128_t ZA, const void *ZX, const int strideX ) { - stdlib_complex128_t za = ZA; +void API_SUFFIX(c_zscal)( const CBLAS_INT N, const stdlib_complex128_t za, void *ZX, const CBLAS_INT strideX ) { stdlib_complex128_t z; - int i; + CBLAS_INT i; uint8_t *ip1 = (uint8_t *)ZX; int64_t is1 = 16 * strideX; @@ -39,15 +40,6 @@ void c_zscal( const int N, const stdlib_complex128_t ZA, const void *ZX, const i if ( N <= 0 || strideX <= 0 ) { return; } - if ( strideX == 1 ) { - // Code for stride equal to `1`... - for ( i = 0; i < N; i++, ip1 += is1 ) { - z = *( (stdlib_complex128_t *)ip1 ); - *( (stdlib_complex128_t *)ip1 ) = stdlib_base_cmul( za, z ); - } - return; - } - // Code for stride not equal to `1`... for ( i = 0; i < N; i++, ip1 += is1 ) { z = *( (stdlib_complex128_t *)ip1 ); *( (stdlib_complex128_t *)ip1 ) = stdlib_base_cmul( za, z ); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.f b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.f index 78bf05b78f76..13a35c91b3ff 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.f +++ b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal.f @@ -33,6 +33,7 @@ ! ! * Jack Dongarra, linpack, 3/11/78. ! +! - modified 3/93 to return if incx .le. 0. ! - modified 12/3/93, array(1) declarations changed to array(*) ! ! ## License diff --git a/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_cblas.c b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_cblas.c index bafa0e0430dd..69d78adaa641 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_cblas.c @@ -18,16 +18,17 @@ #include "stdlib/blas/base/zscal.h" #include "stdlib/blas/base/zscal_cblas.h" -#include "stdlib/complex/float64.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" /** * Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. * * @param N number of indexed elements -* @param ZA scalar constant +* @param za scalar constant * @param ZX input array * @param strideX ZX stride length */ -void c_zscal( const int N, const stdlib_complex128_t ZA, const void *ZX, const int strideX ) { - cblas_zscal( N, ZA, ZX, strideX ); +void API_SUFFIX(c_zscal)( const CBLAS_INT N, const stdlib_complex128_t za, void *ZX, const CBLAS_INT strideX ) { + cblas_zscal( N, za, ZX, strideX ); } diff --git a/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_f.c b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_f.c index 91bfd017648f..03ce288927b9 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_f.c +++ b/lib/node_modules/@stdlib/blas/base/zscal/src/zscal_f.c @@ -18,16 +18,17 @@ #include "stdlib/blas/base/zscal.h" #include "stdlib/blas/base/zscal_fortran.h" -#include "stdlib/complex/float64.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" /** * Scales a double-precision complex floating-point vector by a double-precision complex floating-point constant. * * @param N number of indexed elements -* @param ZA scalar constant +* @param za scalar constant * @param ZX input array * @param strideX ZX stride length */ -void c_zscal( const int N, const stdlib_complex128_t ZA, const void *ZX, const int strideX ) { - zscal( &N, &ZA, ZX, &strideX ); +void API_SUFFIX(c_zscal)( const CBLAS_INT N, const stdlib_complex128_t za, void *ZX, const CBLAS_INT strideX ) { + zscal( &N, &za, ZX, &strideX ); } diff --git a/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.js index fd47c12b3566..d720fee4c305 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.js @@ -22,7 +22,7 @@ var tape = require( 'tape' ); var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var EPS = require( '@stdlib/constants/float64/eps' ); var abs = require( '@stdlib/math/base/special/abs' ); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.native.js index 141c4b030a19..7a59816804f0 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/test/test.ndarray.native.js @@ -23,7 +23,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var EPS = require( '@stdlib/constants/float64/eps' ); var abs = require( '@stdlib/math/base/special/abs' ); diff --git a/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.js b/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.js index dc9ca289fd5f..c1a906faea08 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.js @@ -22,7 +22,7 @@ var tape = require( 'tape' ); var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var EPS = require( '@stdlib/constants/float64/eps' ); var abs = require( '@stdlib/math/base/special/abs' ); @@ -198,56 +198,6 @@ tape( 'if provided an `strideX` parameter less than or equal to `0`, the functio t.end(); }); -tape( 'the function supports complex access patterns', function test( t ) { - var expected; - var delta; - var viewX; - var tol; - var za; - var zx; - var k; - - zx = new Complex128Array( [ - 0.1, // 1 - -0.3, // 1 - 8.0, - 9.0, - 0.5, // 2 - -0.1, // 2 - 2.0, - 5.0, - 2.0, - 3.0 - ] ); - za = new Complex128( 0.4, -0.7 ); - - zscal( 2, za, zx, 2 ); - - viewX = new Float64Array( zx.buffer ); - expected = new Float64Array( [ - -0.17, // 1 - -0.19, // 1 - 8.0, - 9.0, - 0.13, // 2 - -0.39, // 2 - 2.0, - 5.0, - 2.0, - 3.0 - ] ); - for ( k = 0; k < expected.length; k++ ) { - if ( viewX[ k ] === expected[ k ] ) { - t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); - } else { - delta = abs( viewX[ k ] - expected[ k ] ); - tol = 1.0 * EPS * abs( expected[ k ] ); - t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - } - t.end(); -}); - tape( 'the function supports view offsets', function test( t ) { var expected; var delta; diff --git a/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.native.js b/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.native.js index 4a0031324106..0dc596643604 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.native.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/test/test.zscal.native.js @@ -23,7 +23,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); var EPS = require( '@stdlib/constants/float64/eps' ); var abs = require( '@stdlib/math/base/special/abs' ); @@ -207,56 +207,6 @@ tape( 'if provided an `strideX` parameter less than or equal to `0`, the functio t.end(); }); -tape( 'the function supports complex access patterns', opts, function test( t ) { - var expected; - var delta; - var viewX; - var tol; - var za; - var zx; - var k; - - zx = new Complex128Array( [ - 0.1, // 1 - -0.3, // 1 - 8.0, - 9.0, - 0.5, // 2 - -0.1, // 2 - 2.0, - 5.0, - 2.0, - 3.0 - ] ); - za = new Complex128( 0.4, -0.7 ); - - zscal( 2, za, zx, 2 ); - - viewX = new Float64Array( zx.buffer ); - expected = new Float64Array( [ - -0.17, // 1 - -0.19, // 1 - 8.0, - 9.0, - 0.13, // 2 - -0.39, // 2 - 2.0, - 5.0, - 2.0, - 3.0 - ] ); - for ( k = 0; k < expected.length; k++ ) { - if ( viewX[ k ] === expected[ k ] ) { - t.strictEqual( viewX[ k ], expected[ k ], 'returns expected value' ); - } else { - delta = abs( viewX[ k ] - expected[ k ] ); - tol = 1.0 * EPS * abs( expected[ k ] ); - t.ok( delta <= tol, 'within tolerance. x: '+viewX[ k ]+'. expected: '+expected[ k ]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - } - t.end(); -}); - tape( 'the function supports view offsets', opts, function test( t ) { var expected; var delta; From ee6f7e18e8856a22cd81b155415da6b015ae27f6 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 10 Jun 2024 16:10:38 +0530 Subject: [PATCH 5/7] docs: update comment --- lib/node_modules/@stdlib/blas/base/zscal/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/zscal/examples/index.js b/lib/node_modules/@stdlib/blas/base/zscal/examples/index.js index b84e75d78eac..9c138caf4327 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/zscal/examples/index.js @@ -33,6 +33,6 @@ console.log( zx.toString() ); var za = new Complex128( 2.0, 2.0 ); console.log( za.toString() ); -// Scales elements from `zx` by `za`: +// Scale elements from `zx` by `za`: zscal( zx.length, za, zx, 1 ); console.log( zx.get( zx.length-1 ).toString() ); From d75fe46c91937568c568ea441b81c49252824adc Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 10 Jun 2024 12:15:25 -0700 Subject: [PATCH 6/7] docs: fix text wrapping --- lib/node_modules/@stdlib/blas/base/zscal/docs/repl.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zscal/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/zscal/docs/repl.txt index e142823b857a..a128f74da9fe 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/zscal/docs/repl.txt @@ -72,8 +72,8 @@ semantics. While typed array views mandate a view offset based on the underlying - buffer, the offset parameter supports indexing semantics based on a - starting index. + buffer, the offset parameter supports indexing semantics based on a starting + index. Parameters ---------- From 7c33fe688ab94e781ad628d6129c7a69626dbe38 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 10 Jun 2024 12:21:48 -0700 Subject: [PATCH 7/7] build: remove unused dependency --- lib/node_modules/@stdlib/blas/base/zscal/manifest.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zscal/manifest.json b/lib/node_modules/@stdlib/blas/base/zscal/manifest.json index e2ec18a53fff..763eb581d9b4 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/zscal/manifest.json @@ -49,8 +49,7 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex128array", "@stdlib/napi/argv-complex128", - "@stdlib/complex/float64/ctor", - "@stdlib/math/base/ops/cmul" + "@stdlib/complex/float64/ctor" ] }, {