From cbead2a2512f02ba68118b9aed97ab024e84f33a Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 11 Jan 2025 12:38:17 +0000 Subject: [PATCH 01/14] feat: add blas/base/dzasum --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dzasum/README.md | 205 ++++++++++++++++++ .../blas/base/dzasum/benchmark/benchmark.js | 105 +++++++++ .../dzasum/benchmark/benchmark.ndarray.js | 105 +++++++++ .../blas/base/dzasum/docs/types/index.d.ts | 96 ++++++++ .../blas/base/dzasum/docs/types/test.ts | 158 ++++++++++++++ .../blas/base/dzasum/examples/index.js | 35 +++ .../@stdlib/blas/base/dzasum/lib/dzasum.js | 53 +++++ .../@stdlib/blas/base/dzasum/lib/index.js | 68 ++++++ .../@stdlib/blas/base/dzasum/lib/main.js | 35 +++ .../@stdlib/blas/base/dzasum/lib/ndarray.js | 65 ++++++ .../@stdlib/blas/base/dzasum/package.json | 83 +++++++ .../blas/base/dzasum/test/test.dzasum.js | 129 +++++++++++ .../@stdlib/blas/base/dzasum/test/test.js | 82 +++++++ .../blas/base/dzasum/test/test.ndarray.js | 128 +++++++++++ 14 files changed, 1347 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/README.md b/lib/node_modules/@stdlib/blas/base/dzasum/README.md new file mode 100644 index 000000000000..135590fee4f0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/README.md @@ -0,0 +1,205 @@ + + +# dzasum + +> Compute the sum of the [absolute values][@stdlib/blas/base/dcab1] of each element in a double-precision [complex][@stdlib/complex/float64/ctor] floating-point vector. + +
+ +dzasum is defined as + + + +```math +\|\mathbf{x}\|_1 = \sum_{i=0}^{n-1} \left( |a_i| + |b_i| \right) +``` + + + + + +
+ + + +
+ +## Usage + +```javascript +var dzasum = require( '@stdlib/blas/base/dzasum' ); +``` + +#### dzasum( N, x, stride ) + +Compute the sum of the [absolute values][@stdlib/blas/base/dcab1] of each element in a double-precision [complex][@stdlib/complex/float64/ctor] floating-point vector. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + +var sum = dzasum( x.length, x, 1 ); +// returns 19.0 +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **x**: input [`Complex128Array`][complex128array]. +- **stride**: index increment. + +The `N` and `stride` parameters determine which elements in `x` are used to compute the sum. For example, to sum every other value, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + +var sum = dzasum( 2, x, 2 ); +// returns 7.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' ); + +// Initial array... +var x0 = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); + +// Create an offset view... +var x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +// Sum every other value... +var sum = dzasum( 2, x1, 2 ); +// returns 22.0 +``` + +If `N` is less than or equal to `0`, the function returns `0`. + +#### dzasum.ndarray( N, x, stride, offset ) + +Compute the sum of the [absolute values][@stdlib/blas/base/dcab1] of each element in a double-precision [complex][@stdlib/complex/float64/ctor] floating-point vector using alternative indexing semantics. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + +var sum = dzasum.ndarray( x.length, x, 1, 0 ); +// returns 19.0 +``` + +The function has the following additional parameters: + +- **offset**: starting index. + +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 sum the last three elements, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); + +var sum = dzasum.ndarray( 3, x, 1, x.length-3 ); +// returns 33.0 + +// Using a negative stride to sum from the last element: +sum = dzasum.ndarray( 3, x, -1, x.length-1 ); +// returns 33.0 +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, the sum is `0`. +- `dzasum()` corresponds to the [BLAS][blas] level 1 function dzasum. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var dzasum = require( '@stdlib/blas/base/dzasum' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +// Generate random input arrays: +var x = filledarrayBy( 10, 'complex128', rand ); +console.log( x.toString() ); + +var out = dzasum( x.length, x, 1 ); +console.log( out ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js new file mode 100644 index 000000000000..8cee6bfd8a5c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 pkg = require( './../package.json' ).name; +var dzasum = require( './../lib/dzasum.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 x; + + x = new Complex128Array( uniform( len*2, -100.0, 100.0, options ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = dzasum( x.length, x, 1 ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + 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/dzasum/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..5fd95fe79ec7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 pkg = require( './../package.json' ).name; +var dzasum = 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 x; + + x = new Complex128Array( uniform( len*2, -100.0, 100.0, options ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = dzasum( x.length, x, 1, 0 ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + 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/dzasum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts new file mode 100644 index 000000000000..af30dd68a8ca --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts @@ -0,0 +1,96 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Complex128Array } from '@stdlib/types/array'; + +/** +* Interface describing `dzasum`. +*/ +interface Routine { + /** + * Compute the sum of the absolute values of each element in a double-precision complex floating-point vector. + * + * @param N - number of indexed elements + * @param x - input array + * @param stride - stride length + * @returns sum of absolute values + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * + * var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + * + * var sum = dzasum( x.length, x, 1 ); + * // returns 19.0 + */ + ( N: number, x: Complex128Array, stride: number ): number; + + /** + * Computes the sum of the absolute values using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param x - input array + * @param stride - stride length + * @param offset - starting index + * @returns sum of absolute values + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * + * var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + * + * var z = dzasum.ndarray( x.length, x, 1, 0 ); + * // returns 19.0 + */ + ndarray( N: number, x: Complex128Array, stride: number, offset: number ): number; +} + +/** +* Compute the sum of the absolute values of each element in a double-precision complex floating-point vector. +* +* @param N - number of indexed elements +* @param x - input array +* @param stride - stride length +* @returns sum of absolute values +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var sum = dzasum( x.length, x, 1 ); +* // returns 19.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var z = dzasum.ndarray( x.length, x, 1, 0 ); +* // returns 19.0 +*/ +declare var dzasum: Routine; + + +// EXPORTS // + +export = dzasum; diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts new file mode 100644 index 000000000000..98c9680adc1d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts @@ -0,0 +1,158 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Complex128Array = require( '@stdlib/array/complex128' ); +import dzasum = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const x = new Complex128Array( 10 ); + + dzasum( x.length, x, 1 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Complex128Array( 10 ); + + dzasum( '10', x, 1 ); // $ExpectError + dzasum( true, x, 1 ); // $ExpectError + dzasum( false, x, 1 ); // $ExpectError + dzasum( null, x, 1 ); // $ExpectError + dzasum( undefined, x, 1 ); // $ExpectError + dzasum( [], x, 1 ); // $ExpectError + dzasum( {}, x, 1 ); // $ExpectError + dzasum( ( x: number ): number => x, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Complex128Array... +{ + const x = new Complex128Array( 10 ); + + dzasum( x.length, 10, 1 ); // $ExpectError + dzasum( x.length, '10', 1 ); // $ExpectError + dzasum( x.length, true, 1 ); // $ExpectError + dzasum( x.length, false, 1 ); // $ExpectError + dzasum( x.length, null, 1 ); // $ExpectError + dzasum( x.length, undefined, 1 ); // $ExpectError + dzasum( x.length, [], 1 ); // $ExpectError + dzasum( x.length, {}, 1 ); // $ExpectError + dzasum( x.length, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Complex128Array( 10 ); + + dzasum( x.length, x, '10' ); // $ExpectError + dzasum( x.length, x, true ); // $ExpectError + dzasum( x.length, x, false ); // $ExpectError + dzasum( x.length, x, null ); // $ExpectError + dzasum( x.length, x, undefined ); // $ExpectError + dzasum( x.length, x, [] ); // $ExpectError + dzasum( x.length, x, {} ); // $ExpectError + dzasum( x.length, x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Complex128Array( 10 ); + + dzasum(); // $ExpectError + dzasum( x.length ); // $ExpectError + dzasum( x.length, x ); // $ExpectError + dzasum( x.length, x, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const x = new Complex128Array( 10 ); + + dzasum.ndarray( x.length, x, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Complex128Array( 10 ); + + dzasum.ndarray( '10', x, 1, 0 ); // $ExpectError + dzasum.ndarray( true, x, 1, 0 ); // $ExpectError + dzasum.ndarray( false, x, 1, 0 ); // $ExpectError + dzasum.ndarray( null, x, 1, 0 ); // $ExpectError + dzasum.ndarray( undefined, x, 1, 0 ); // $ExpectError + dzasum.ndarray( [], x, 1, 0 ); // $ExpectError + dzasum.ndarray( {}, x, 1, 0 ); // $ExpectError + dzasum.ndarray( ( x: number ): number => x, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex128Array... +{ + const x = new Complex128Array( 10 ); + + dzasum.ndarray( x.length, 10, 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, '10', 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, true, 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, false, 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, null, 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, undefined, 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, [], 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, {}, 1, 0 ); // $ExpectError + dzasum.ndarray( x.length, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const x = new Complex128Array( 10 ); + + dzasum.ndarray( x.length, x, '10', 0 ); // $ExpectError + dzasum.ndarray( x.length, x, true, 0 ); // $ExpectError + dzasum.ndarray( x.length, x, false, 0 ); // $ExpectError + dzasum.ndarray( x.length, x, null, 0 ); // $ExpectError + dzasum.ndarray( x.length, x, undefined, 0 ); // $ExpectError + dzasum.ndarray( x.length, x, [], 0 ); // $ExpectError + dzasum.ndarray( x.length, x, {}, 0 ); // $ExpectError + dzasum.ndarray( x.length, x, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Complex128Array( 10 ); + + dzasum.ndarray( x.length, x, 1, '10' ); // $ExpectError + dzasum.ndarray( x.length, x, 1, true ); // $ExpectError + dzasum.ndarray( x.length, x, 1, false ); // $ExpectError + dzasum.ndarray( x.length, x, 1, null ); // $ExpectError + dzasum.ndarray( x.length, x, 1, undefined ); // $ExpectError + dzasum.ndarray( x.length, x, 1, [] ); // $ExpectError + dzasum.ndarray( x.length, x, 1, {} ); // $ExpectError + dzasum.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Complex128Array( 10 ); + + dzasum.ndarray(); // $ExpectError + dzasum.ndarray( x.length ); // $ExpectError + dzasum.ndarray( x.length, x ); // $ExpectError + dzasum.ndarray( x.length, x, 1 ); // $ExpectError + dzasum.ndarray( x.length, x, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js b/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js new file mode 100644 index 000000000000..55e808dac0f2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Complex128 = require( '@stdlib/complex/float64/ctor' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var dzasum = require( '@stdlib/blas/base/dzasum' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +// Generate random input arrays: +var x = filledarrayBy( 10, 'complex128', rand ); +console.log( x.toString() ); + +var out = dzasum( x.length, x, 1 ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.js b/lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.js new file mode 100644 index 000000000000..f7be49fde4ce --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Computes the sum of the absolute values of each element in a double-precision complex floating-point vector. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex64Array} x - input array +* @param {integer} stride - `x` stride length +* @returns {number} sum +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var sum = dzasum( x.length, x, 1 ); +* // returns 19.0 +*/ +function dzasum( N, x, stride ) { + var ox = stride2offset( N, stride ); + return ndarray( N, x, stride, ox ); +} + + +// EXPORTS // + +module.exports = dzasum; diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/lib/index.js b/lib/node_modules/@stdlib/blas/base/dzasum/lib/index.js new file mode 100644 index 000000000000..44a78a24abea --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/lib/index.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* BLAS level 1 routine to compute the sum of absolute values of each element in a double-precision complex floating-point vector. +* +* @module @stdlib/blas/base/dzasum +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var dzasum = require( '@stdlib/blas/base/dzasum' ); +* +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var sum = dzasum( x.length, x, 1 ); +* // returns 19.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var dzasum = require( '@stdlib/blas/base/dzasum' ); +* +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var sum = dzasum.ndarray( x.length, x, 1, 0 ); +* // returns 19.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 dzasum; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dzasum = main; +} else { + dzasum = tmp; +} + + +// EXPORTS // + +module.exports = dzasum; + +// exports: { "ndarray": "dzasum.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/lib/main.js b/lib/node_modules/@stdlib/blas/base/dzasum/lib/main.js new file mode 100644 index 000000000000..02691681c914 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 dzasum = require( './dzasum.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dzasum, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dzasum; diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/lib/ndarray.js new file mode 100644 index 000000000000..e59053675ede --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/lib/ndarray.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 dcabs1 = require( '@stdlib/blas/base/dcabs1' ); + + +// MAIN // + +/** +* Computes the sum of the absolute values of each element in a double-precision complex floating-point vector. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex64Array} x - input array +* @param {integer} stride - `x` stride length +* @param {NonNegativeInteger} offset - starting index for `x` +* @returns {number} sum +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var sum = dzasum( x.length, x, 1, 0 ); +* // returns 19.0 +*/ +function dzasum( N, x, stride, offset ) { + var sum; + var ix; + var i; + + sum = 0.0; + if ( N <= 0 ) { + return sum; + } + ix = offset; + for ( i = 0; i < N; i++ ) { + sum += dcabs1( x.get( ix ) ); + ix += stride; + } + return sum; +} + + +// EXPORTS // + +module.exports = dzasum; diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/package.json b/lib/node_modules/@stdlib/blas/base/dzasum/package.json new file mode 100644 index 000000000000..693df0d5e522 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/package.json @@ -0,0 +1,83 @@ +{ + "name": "@stdlib/blas/base/dzasum", + "version": "0.0.0", + "description": "Compute the sum of the absolute values of each element in a double-precision complex floating-point vector.", + "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", + "dcabs1", + "absolute", + "value", + "sum", + "l1norm", + "norm", + "taxicab", + "manhattan", + "vector", + "array", + "ndarray", + "double", + "complex128", + "complex128array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js new file mode 100644 index 000000000000..181c7a728d82 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js @@ -0,0 +1,129 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 dzasum = require( './../lib/dzasum.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dzasum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 3', function test( t ) { + t.strictEqual( dzasum.length, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the sum of absolute values', function test( t ) { + var x; + var y; + + x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + y = dzasum( x.length, x, 1 ); + + t.strictEqual( y, 21.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + -4.0, + 5.0, // 2 + -6.0 // 2 + ]); + N = 2; + + y = dzasum( N, x, 2 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', function test( t ) { + var x; + var y; + + x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + y = dzasum( 0, x, 1 ); + + t.strictEqual( y, 0.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride', function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 2 + -2.0, // 2 + 3.0, + -4.0, + 5.0, // 1 + -6.0 // 1 + ]); + N = 2; + + y = dzasum( N, x, -2 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var x0; + var x1; + var y; + var N; + + // Initial array... + x0 = new Complex128Array([ + 1.0, + -2.0, + 3.0, // 1 + -4.0, // 1 + 5.0, // 2 + -6.0 // 2 + ]); + + // Create an offset view... + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + + N = 2; + y = dzasum( N, x1, 1 ); + + t.strictEqual( y, 18.0, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.js new file mode 100644 index 000000000000..c7c4ac04005a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dzasum = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dzasum, '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 dzasum.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 dzasum = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dzasum, mock, 'returns expected value' ); + 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 dzasum; + var main; + + main = require( './../lib/dzasum.js' ); + + dzasum = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dzasum, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js new file mode 100644 index 000000000000..e94b718f7c75 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js @@ -0,0 +1,128 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 dzasum = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dzasum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( dzasum.length, 4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the sum of absolute values', function test( t ) { + var x; + var y; + + x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + y = dzasum( x.length, x, 1, 0 ); + + t.strictEqual( y, 21.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + -4.0, + 5.0, // 2 + -6.0 // 2 + ]); + N = 2; + + y = dzasum( N, x, 2, 0 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, + -2.0, + 3.0, // 1 + -4.0, // 1 + 5.0, // 2 + -6.0 // 2 + ]); + N = 2; + + y = dzasum( N, x, 1, 1 ); + + t.strictEqual( y, 18.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', function test( t ) { + var x; + var y; + + x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + + y = dzasum( -1, x, 1, 0 ); + t.strictEqual( y, 0.0, 'returns expected value' ); + + y = dzasum( 0, x, 1, 0 ); + t.strictEqual( y, 0.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride', function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 2 + -2.0, // 2 + 3.0, + -4.0, + 5.0, // 1 + -6.0 // 1 + ]); + N = 2; + + y = dzasum( N, x, -2, x.length-1 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); From 9ef0e0ed5c5192719643710584ccb9e9346fcc8e Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 11 Jan 2025 12:45:54 +0000 Subject: [PATCH 02/14] add repl.txt --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/blas/base/dzasum/docs/repl.txt | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt new file mode 100644 index 000000000000..d7a062f681a6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt @@ -0,0 +1,90 @@ + +{{alias}}( N, x, stride ) + Compute the sum of the absolute values of each element in a + double-precision complex floating-point vector + + The `N` and `stride` parameters determine which elements in `x` are used + to compute the sum. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N` is less than or equal to `0`, the function returns `0`. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Complex128Array + Input array. + + stride: integer + Index increment. + + Returns + ------- + sum: number + Sum of absolute values. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); + > var s = {{alias}}( x.length, x, 1 ) + 15.0 + + // Sum every other value: + > s = {{alias}}( 2, x, 2 ) + 7.0 + + // Use view offset; e.g., starting at 2nd element: + > var x0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex128}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > s = {{alias}}( 2, x1, 2 ) + 22.0 + + +{{alias}}.ndarray( N, x, stride, offset ) + Compute the sum of the absolute values of each element in a + double-precision complex floating-point vector 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. + + x: Complex128Array + Input array. + + stride: integer + Index increment. + + offset: integer + Starting index. + + Returns + ------- + sum: number + Sum of absolute values. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + > var s = {{alias}}.ndarray( x.length, x, 1, 0 ) + 19.0 + + // Sum the last three elements: + > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); + > s = {{alias}}.ndarray( 3, x, -1, x.length-1 ) + 33.0 + + See Also + -------- + From cb2094fdfd56f44d88cd91125e4f87a57ec64c70 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 11 Jan 2025 12:56:41 +0000 Subject: [PATCH 03/14] fix: copyright years --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts | 2 +- lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts index 98c9680adc1d..16f905048756 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js index e94b718f7c75..ac1ca0fa4b91 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 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. From 114b390533cd208b1da508bf571461c2e62ff958 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 7 Jul 2025 13:30:36 +0530 Subject: [PATCH 04/14] bench: update variable naming --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/base/dzasum/benchmark/benchmark.js | 14 +++++++------- .../base/dzasum/benchmark/benchmark.ndarray.js | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js index 8cee6bfd8a5c..14a79ecdb1d7 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js @@ -42,13 +42,13 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} len - array length +* @param {PositiveInteger} N - array length * @returns {Function} benchmark function */ -function createBenchmark( len ) { +function createBenchmark( N ) { var x; - x = new Complex128Array( uniform( len*2, -100.0, 100.0, options ) ); + x = new Complex128Array( uniform( N*2, -100.0, 100.0, options ) ); return benchmark; /** @@ -86,9 +86,9 @@ function createBenchmark( len ) { * @private */ function main() { - var len; var min; var max; + var N; var f; var i; @@ -96,9 +96,9 @@ function main() { max = 6; // 10^max for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); + N = pow( 10, i ); + f = createBenchmark( N ); + bench( pkg+':size='+N, f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js index 5fd95fe79ec7..ad9098469294 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js @@ -42,13 +42,13 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} len - array length +* @param {PositiveInteger} N - array length * @returns {Function} benchmark function */ -function createBenchmark( len ) { +function createBenchmark( N ) { var x; - x = new Complex128Array( uniform( len*2, -100.0, 100.0, options ) ); + x = new Complex128Array( uniform( N*2, -100.0, 100.0, options ) ); return benchmark; /** @@ -86,9 +86,9 @@ function createBenchmark( len ) { * @private */ function main() { - var len; var min; var max; + var N; var f; var i; @@ -96,9 +96,9 @@ function main() { max = 6; // 10^max for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':ndarray:len='+len, f ); + N = pow( 10, i ); + f = createBenchmark( N ); + bench( pkg+':ndarray:size='+N, f ); } } From 9860165c3da0399af4bc2c54d939892f0df3f2fe Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 7 Jul 2025 13:45:06 +0530 Subject: [PATCH 05/14] docs: update variable naming and jsdoc --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dzasum/docs/repl.txt | 41 ++++++++++--------- .../blas/base/dzasum/docs/types/index.d.ts | 10 ++--- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt index d7a062f681a6..1f38f8eba558 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt @@ -1,9 +1,9 @@ -{{alias}}( N, x, stride ) - Compute the sum of the absolute values of each element in a - double-precision complex floating-point vector +{{alias}}( N, x, strideX ) + Computes the sum of the absolute values of each element in a + double-precision complex floating-point vector. - The `N` and `stride` parameters determine which elements in `x` are used + The `N` and `strideX` parameters determine which elements in `x` are used to compute the sum. Indexing is relative to the first index. To introduce an offset, use typed @@ -19,7 +19,7 @@ x: Complex128Array Input array. - stride: integer + strideX: integer Index increment. Returns @@ -30,28 +30,29 @@ Examples -------- // Standard usage: - > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); + > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0 ]); > var s = {{alias}}( x.length, x, 1 ) - 15.0 + 11.0 - // Sum every other value: + // Advanced indexing: + > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); > s = {{alias}}( 2, x, 2 ) 7.0 - // Use view offset; e.g., starting at 2nd element: - > var x0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); + // Using typed array views: + > var x0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); > var x1 = new {{alias:@stdlib/array/complex128}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > s = {{alias}}( 2, x1, 2 ) - 22.0 + > s = {{alias}}( 2, x1, 1 ) + 18.0 -{{alias}}.ndarray( N, x, stride, offset ) - Compute the sum of the absolute values of each element in a +{{alias}}.ndarray( N, x, strideX, offsetX ) + Computes the sum of the absolute values of each element in a double-precision complex floating-point vector 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 + buffer, the `offsetX` parameter supports indexing semantics based on a starting index. Parameters @@ -62,10 +63,10 @@ x: Complex128Array Input array. - stride: integer + strideX: integer Index increment. - offset: integer + offsetX: integer Starting index. Returns @@ -76,11 +77,11 @@ Examples -------- // Standard usage: - > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0 ] ); > var s = {{alias}}.ndarray( x.length, x, 1, 0 ) - 19.0 + 11.0 - // Sum the last three elements: + // Advanced indexing: > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); > s = {{alias}}.ndarray( 3, x, -1, x.length-1 ) 33.0 diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts index af30dd68a8ca..f5679e6c8f85 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts @@ -27,7 +27,7 @@ import { Complex128Array } from '@stdlib/types/array'; */ interface Routine { /** - * Compute the sum of the absolute values of each element in a double-precision complex floating-point vector. + * Computes the sum of the absolute values of each element in a double-precision complex floating-point vector. * * @param N - number of indexed elements * @param x - input array @@ -45,12 +45,12 @@ interface Routine { ( N: number, x: Complex128Array, stride: number ): number; /** - * Computes the sum of the absolute values using alternative indexing semantics. + * Computes the sum of the absolute values of each element in a double-precision complex floating-point vector using alternative indexing semantics. * * @param N - number of indexed elements * @param x - input array * @param stride - stride length - * @param offset - starting index + * @param offsetX - starting index * @returns sum of absolute values * * @example @@ -61,11 +61,11 @@ interface Routine { * var z = dzasum.ndarray( x.length, x, 1, 0 ); * // returns 19.0 */ - ndarray( N: number, x: Complex128Array, stride: number, offset: number ): number; + ndarray( N: number, x: Complex128Array, stride: number, offsetX: number ): number; } /** -* Compute the sum of the absolute values of each element in a double-precision complex floating-point vector. +* Computes the sum of the absolute values of each element in a double-precision complex floating-point vector. * * @param N - number of indexed elements * @param x - input array From 10ba7b3e895e9b6a4f1f715675e3c467d8a4f048 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 7 Jul 2025 13:49:50 +0530 Subject: [PATCH 06/14] chore: add ndarray example --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dzasum/examples/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js b/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js index 55e808dac0f2..2f0a93e5c503 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js @@ -21,7 +21,7 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); -var dzasum = require( '@stdlib/blas/base/dzasum' ); +var dzasum = require( './../lib' ); function rand() { return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); @@ -31,5 +31,10 @@ function rand() { var x = filledarrayBy( 10, 'complex128', rand ); console.log( x.toString() ); +// Compute the sum of the absolute values of each element: var out = dzasum( x.length, x, 1 ); console.log( out ); + +// Compute the sum of the absolute values of each element using alternative indexing semantics: +out = dzasum.ndarray( x.length, x, 1, 0 ); +console.log( out ); From 2a604f9fc2a8dee4721a8481a6109a978f260f51 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 7 Jul 2025 13:51:30 +0530 Subject: [PATCH 07/14] docs: update jsdoc and variable naming --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dzasum/lib/dzasum.js | 8 ++++---- .../@stdlib/blas/base/dzasum/lib/ndarray.js | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.js b/lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.js index f7be49fde4ce..bcfea6022966 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} x - input array -* @param {integer} stride - `x` stride length +* @param {integer} strideX - `x` stride length * @returns {number} sum * * @example @@ -42,9 +42,9 @@ var ndarray = require( './ndarray.js' ); * var sum = dzasum( x.length, x, 1 ); * // returns 19.0 */ -function dzasum( N, x, stride ) { - var ox = stride2offset( N, stride ); - return ndarray( N, x, stride, ox ); +function dzasum( N, x, strideX ) { + var ox = stride2offset( N, strideX ); + return ndarray( N, x, strideX, ox ); } diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/lib/ndarray.js index e59053675ede..864d39527722 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/lib/ndarray.js @@ -30,8 +30,8 @@ var dcabs1 = require( '@stdlib/blas/base/dcabs1' ); * * @param {PositiveInteger} N - number of indexed elements * @param {Complex64Array} x - input array -* @param {integer} stride - `x` stride length -* @param {NonNegativeInteger} offset - starting index for `x` +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` * @returns {number} sum * * @example @@ -42,7 +42,7 @@ var dcabs1 = require( '@stdlib/blas/base/dcabs1' ); * var sum = dzasum( x.length, x, 1, 0 ); * // returns 19.0 */ -function dzasum( N, x, stride, offset ) { +function dzasum( N, x, strideX, offsetX ) { var sum; var ix; var i; @@ -51,10 +51,10 @@ function dzasum( N, x, stride, offset ) { if ( N <= 0 ) { return sum; } - ix = offset; + ix = offsetX; for ( i = 0; i < N; i++ ) { sum += dcabs1( x.get( ix ) ); - ix += stride; + ix += strideX; } return sum; } From 5a3cb83683f43a897482ab0c17a54d08cc6dafe6 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 7 Jul 2025 13:56:16 +0530 Subject: [PATCH 08/14] chore: update markdown --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dzasum/README.md | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/README.md b/lib/node_modules/@stdlib/blas/base/dzasum/README.md index 135590fee4f0..4f8d84cda15c 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/README.md +++ b/lib/node_modules/@stdlib/blas/base/dzasum/README.md @@ -20,7 +20,7 @@ limitations under the License. # dzasum -> Compute the sum of the [absolute values][@stdlib/blas/base/dcab1] of each element in a double-precision [complex][@stdlib/complex/float64/ctor] floating-point vector. +> Computes the sum of the [absolute values][@stdlib/blas/base/dcabs1] of each element.
@@ -51,9 +51,9 @@ dzasum is defined as var dzasum = require( '@stdlib/blas/base/dzasum' ); ``` -#### dzasum( N, x, stride ) +#### dzasum( N, x, strideX ) -Compute the sum of the [absolute values][@stdlib/blas/base/dcab1] of each element in a double-precision [complex][@stdlib/complex/float64/ctor] floating-point vector. +Compute the sum of the [absolute values][@stdlib/blas/base/dcabs1] of each element in a double-precision [complex][@stdlib/complex/float64/ctor] floating-point vector. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); @@ -68,9 +68,9 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input [`Complex128Array`][complex128array]. -- **stride**: index increment. +- **strideX**: stride length for `x`. -The `N` and `stride` parameters determine which elements in `x` are used to compute the sum. For example, to sum every other value, +The `N` and `strideX` parameters determine which elements in `x` are used to compute the sum. For example, to sum every other value, ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); @@ -97,11 +97,9 @@ var sum = dzasum( 2, x1, 2 ); // returns 22.0 ``` -If `N` is less than or equal to `0`, the function returns `0`. +#### dzasum.ndarray( N, x, strideX, offsetX ) -#### dzasum.ndarray( N, x, stride, offset ) - -Compute the sum of the [absolute values][@stdlib/blas/base/dcab1] of each element in a double-precision [complex][@stdlib/complex/float64/ctor] floating-point vector using alternative indexing semantics. +Compute the sum of the [absolute values][@stdlib/blas/base/dcabs1] of each element in a double-precision [complex][@stdlib/complex/float64/ctor] floating-point vector using alternative indexing semantics. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); @@ -114,9 +112,9 @@ var sum = dzasum.ndarray( x.length, x, 1, 0 ); The function has the following additional parameters: -- **offset**: starting index. +- **offsetX**: starting index. -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 sum the last three elements, +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the `offsetX` parameter supports indexing semantics based on a starting index. For example, to sum the last three elements, ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); @@ -140,7 +138,7 @@ sum = dzasum.ndarray( 3, x, -1, x.length-1 ); ## Notes - If `N <= 0`, the sum is `0`. -- `dzasum()` corresponds to the [BLAS][blas] level 1 function dzasum. +- `dzasum()` corresponds to the [BLAS][blas] level 1 function [`dzasum`][blas-dzasum].
@@ -190,7 +188,9 @@ console.log( out ); [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray -[@stdlib/blas/base/dcab1]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/base/dcab1 +[blas-dzasum]: https://www.netlib.org/lapack/explore-html-3.6.1/de/da4/group__double__blas__level1_ga60d5c8001b317c929778670a15013eb4.html + +[@stdlib/blas/base/dcabs1]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/base/dcabs1 [complex128array]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex128 From 88559fbdb434613492ce0a804846f68c89fecc07 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 7 Jul 2025 14:02:46 +0530 Subject: [PATCH 09/14] fix: linting in package.json --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/dzasum/package.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/package.json b/lib/node_modules/@stdlib/blas/base/dzasum/package.json index 693df0d5e522..3294b7b49a19 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/package.json +++ b/lib/node_modules/@stdlib/blas/base/dzasum/package.json @@ -14,15 +14,11 @@ } ], "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", From 1a3dc71856620b75646ab84fff88f2a073e3de9a Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 7 Jul 2025 17:59:31 +0530 Subject: [PATCH 10/14] chore: update markdown example Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dzasum/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/README.md b/lib/node_modules/@stdlib/blas/base/dzasum/README.md index 4f8d84cda15c..cab604cc7933 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/README.md +++ b/lib/node_modules/@stdlib/blas/base/dzasum/README.md @@ -157,15 +157,20 @@ var filledarrayBy = require( '@stdlib/array/filled-by' ); var dzasum = require( '@stdlib/blas/base/dzasum' ); function rand() { - return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); } // Generate random input arrays: var x = filledarrayBy( 10, 'complex128', rand ); console.log( x.toString() ); +// Compute the sum of the absolute values of each element: var out = dzasum( x.length, x, 1 ); console.log( out ); + +// Compute the sum of the absolute values of each element using alternative indexing semantics: +out = dzasum.ndarray( x.length, x, 1, 0 ); +console.log( out ); ``` From f4c25fecb4a36a7e35ce6da94590e44b41e1219a Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Tue, 8 Jul 2025 21:46:05 +0530 Subject: [PATCH 11/14] chore: convert tabs to spaces --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/dzasum/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/README.md b/lib/node_modules/@stdlib/blas/base/dzasum/README.md index cab604cc7933..8665ab73f8f8 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/README.md +++ b/lib/node_modules/@stdlib/blas/base/dzasum/README.md @@ -157,7 +157,7 @@ var filledarrayBy = require( '@stdlib/array/filled-by' ); var dzasum = require( '@stdlib/blas/base/dzasum' ); function rand() { - return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); } // Generate random input arrays: From 4e94c5ce2da03e2e9a674d87113f0c274fa4640c Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Fri, 13 Mar 2026 18:42:47 +0530 Subject: [PATCH 12/14] feat: added fortran and c implementation --- .../@stdlib/blas/base/dzasum/README.md | 223 ++++++--- .../blas/base/dzasum/benchmark/benchmark.js | 2 +- .../base/dzasum/benchmark/benchmark.native.js | 111 +++++ .../dzasum/benchmark/benchmark.ndarray.js | 2 +- .../benchmark/benchmark.ndarray.native.js | 110 +++++ .../@stdlib/blas/base/dzasum/binding.gyp | 265 ++++++++++ .../@stdlib/blas/base/dzasum/docs/repl.txt | 18 +- .../blas/base/dzasum/docs/types/index.d.ts | 2 +- .../blas/base/dzasum/docs/types/test.ts | 2 +- .../blas/base/dzasum/examples/c/Makefile | 146 ++++++ .../blas/base/dzasum/examples/c/example.c | 43 ++ .../blas/base/dzasum/examples/index.js | 2 +- .../@stdlib/blas/base/dzasum/include.gypi | 70 +++ .../dzasum/include/stdlib/blas/base/dzasum.h | 48 ++ .../include/stdlib/blas/base/dzasum_cblas.h | 43 ++ .../include/stdlib/blas/base/dzasum_fortran.h | 41 ++ .../@stdlib/blas/base/dzasum/lib/dzasum.js | 8 +- .../blas/base/dzasum/lib/dzasum.native.js | 53 ++ .../@stdlib/blas/base/dzasum/lib/index.js | 2 +- .../@stdlib/blas/base/dzasum/lib/main.js | 4 +- .../@stdlib/blas/base/dzasum/lib/native.js | 35 ++ .../@stdlib/blas/base/dzasum/lib/ndarray.js | 8 +- .../blas/base/dzasum/lib/ndarray.native.js | 54 ++ .../@stdlib/blas/base/dzasum/manifest.json | 463 ++++++++++++++++++ .../@stdlib/blas/base/dzasum/package.json | 7 +- .../@stdlib/blas/base/dzasum/src/Makefile | 70 +++ .../@stdlib/blas/base/dzasum/src/addon.c | 61 +++ .../@stdlib/blas/base/dzasum/src/dzasum.c | 33 ++ .../@stdlib/blas/base/dzasum/src/dzasum.f | 83 ++++ .../blas/base/dzasum/src/dzasum_cblas.c | 57 +++ .../@stdlib/blas/base/dzasum/src/dzasum_f.c | 65 +++ .../blas/base/dzasum/src/dzasum_ndarray.c | 49 ++ .../@stdlib/blas/base/dzasum/src/dzasumsub.f | 46 ++ .../@stdlib/blas/base/dzasum/test.f | 12 + .../blas/base/dzasum/test/test.dzasum.js | 20 +- .../base/dzasum/test/test.dzasum.native.js | 152 ++++++ .../@stdlib/blas/base/dzasum/test/test.js | 6 +- .../blas/base/dzasum/test/test.ndarray.js | 49 +- .../base/dzasum/test/test.ndarray.native.js | 182 +++++++ 39 files changed, 2541 insertions(+), 106 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/include/stdlib/blas/base/dzasum.h create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/include/stdlib/blas/base/dzasum_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/include/stdlib/blas/base/dzasum_fortran.h create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.c create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.f create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_f.c create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_ndarray.c create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/src/dzasumsub.f create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/test.f create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/README.md b/lib/node_modules/@stdlib/blas/base/dzasum/README.md index 8665ab73f8f8..cdbc13ef385e 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/README.md +++ b/lib/node_modules/@stdlib/blas/base/dzasum/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2025 The Stdlib Authors. +Copyright (c) 2026 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. @@ -20,28 +20,7 @@ limitations under the License. # dzasum -> Computes the sum of the [absolute values][@stdlib/blas/base/dcabs1] of each element. - -
- -dzasum is defined as - - - -```math -\|\mathbf{x}\|_1 = \sum_{i=0}^{n-1} \left( |a_i| + |b_i| \right) -``` - - - - - -
- - +> Compute the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector.
@@ -53,31 +32,31 @@ var dzasum = require( '@stdlib/blas/base/dzasum' ); #### dzasum( N, x, strideX ) -Compute the sum of the [absolute values][@stdlib/blas/base/dcabs1] of each element in a double-precision [complex][@stdlib/complex/float64/ctor] floating-point vector. +Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +var x = new Complex128Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 ] ); -var sum = dzasum( x.length, x, 1 ); -// returns 19.0 +var out = dzasum( 4, x, 1 ); +// returns ~1.6 ``` The function has the following parameters: - **N**: number of indexed elements. -- **x**: input [`Complex128Array`][complex128array]. -- **strideX**: stride length for `x`. +- **x**: input [`Complex128Array`][@stdlib/array/complex128]. +- **strideX**: index increment for `x`. -The `N` and `strideX` parameters determine which elements in `x` are used to compute the sum. For example, to sum every other value, +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to traverse every other value, ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); -var sum = dzasum( 2, x, 2 ); +var out = dzasum( 2, x, 2 ); // returns 7.0 ``` @@ -86,47 +65,43 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -// Initial array... -var x0 = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); +// Initial array: +var x0 = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); -// Create an offset view... +// Create an offset view: var x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -// Sum every other value... -var sum = dzasum( 2, x1, 2 ); -// returns 22.0 +// Compute the sum of absolute values: +var out = dzasum( 2, x1, 1 ); +// returns 18.0 ``` -#### dzasum.ndarray( N, x, strideX, offsetX ) +#### dzasum.ndarray( N, x, strideX, offset ) -Compute the sum of the [absolute values][@stdlib/blas/base/dcabs1] of each element in a double-precision [complex][@stdlib/complex/float64/ctor] floating-point vector using alternative indexing semantics. +Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector using alternative indexing semantics. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +var x = new Complex128Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 ] ); -var sum = dzasum.ndarray( x.length, x, 1, 0 ); -// returns 19.0 +var out = dzasum.ndarray( 4, x, 1, 0 ); +// returns ~1.6 ``` The function has the following additional parameters: - **offsetX**: starting index. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the `offsetX` parameter supports indexing semantics based on a starting index. For example, to sum the last three elements, +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 start from the second index, ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); - -var sum = dzasum.ndarray( 3, x, 1, x.length-3 ); -// returns 33.0 +var x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); -// Using a negative stride to sum from the last element: -sum = dzasum.ndarray( 3, x, -1, x.length-1 ); -// returns 33.0 +var out = dzasum.ndarray( 2, x, 1, 1 ); +// returns 18.0 ```
@@ -137,8 +112,8 @@ sum = dzasum.ndarray( 3, x, -1, x.length-1 ); ## Notes -- If `N <= 0`, the sum is `0`. -- `dzasum()` corresponds to the [BLAS][blas] level 1 function [`dzasum`][blas-dzasum]. +- If `N <= 0`, both functions return `0.0`. +- `dzasum()` corresponds to the [BLAS][blas] level 1 function [`dzasum`][dzasum]. @@ -152,31 +127,149 @@ sum = dzasum.ndarray( 3, x, -1, x.length-1 ); ```javascript var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); var dzasum = require( '@stdlib/blas/base/dzasum' ); function rand() { return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); } -// Generate random input arrays: var x = filledarrayBy( 10, 'complex128', rand ); console.log( x.toString() ); -// Compute the sum of the absolute values of each element: +// Compute the sum of the absolute values of real and imaginary components: var out = dzasum( x.length, x, 1 ); console.log( out ); +``` -// Compute the sum of the absolute values of each element using alternative indexing semantics: -out = dzasum.ndarray( x.length, x, 1, 0 ); -console.log( out ); + + + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/dzasum.h" +``` + +#### c_dzasum( N, \*X, strideX ) + +Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. + +```c +const double X[] = { 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 }; + +double out = c_dzasum( 4, (void *)X, 1 ); +// returns 1.6 +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **X**: `[in] void*` input array. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. + +```c +double c_dzasum( const CBLAS_INT N, const void *X, const CBLAS_INT strideX ); +``` + +#### c_dzasum_ndarray( N, \*X, strideX, offsetX ) + +Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector using alternative indexing semantics. + +```c +const double X[] = { 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 }; + +double out = c_dzasum_ndarray( 4, (void *)X, 1, 0 ); +// returns 1.6 +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **X**: `[in] void*` input array. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. + +```c +double c_dzasum_ndarray( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/dzasum.h" +#include + +int main( void ) { + // Create a strided array of interleaved real and imaginary components: + const double X[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + + // Specify the number of elements: + const int N = 4; + + // Specify stride length: + const int strideX = 1; + + // Compute the sum of the absolute values of real and imaginary components: + double out = c_dzasum( N, (void *)X, strideX ); + + // Print the result: + printf( "out: %f\n", out ); + + // Compute the sum of the absolute values of real and imaginary components using alternative indexing semantics: + out = c_dzasum_ndarray( N, (void *)X, -strideX, N-1 ); + + // Print the result: + printf( "out: %f\n", out ); +} ```
+
+ + + diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js index 14a79ecdb1d7..0685dbdd0324 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.native.js new file mode 100644 index 000000000000..2f260030168a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.native.js @@ -0,0 +1,111 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var dzasum = tryRequire( resolve( __dirname, './../lib/dzasum.native.js' ) ); +var opts = { + 'skip': ( dzasum instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x; + + x = new Complex128Array( uniform( N*2, -100.0, 100.0, options ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = dzasum( x.length, x, 1 ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = pow( 10, i ); + f = createBenchmark( N ); + bench( pkg+'::native:size='+N, opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js index ad9098469294..c30bf8754231 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..653e27aa8f31 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,110 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var dzasum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dzasum instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x; + + x = new Complex128Array( uniform( N*2, -100.0, 100.0, options ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = dzasum( x.length, x, 1, 0 ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = pow( 10, i ); + f = createBenchmark( N ); + bench( pkg+':ndarray:native:size='+N, opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/binding.gyp b/lib/node_modules/@stdlib/blas/base/dzasum/binding.gyp new file mode 100644 index 000000000000..60dce9d0b31a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/binding.gyp @@ -0,0 +1,265 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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/dzasum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt index 1f38f8eba558..53a6f5a1324b 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dzasum/docs/repl.txt @@ -24,25 +24,25 @@ Returns ------- - sum: number - Sum of absolute values. + out: number + Result. Examples -------- // Standard usage: > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0 ]); - > var s = {{alias}}( x.length, x, 1 ) + > var out = {{alias}}( x.length, x, 1 ) 11.0 // Advanced indexing: > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); - > s = {{alias}}( 2, x, 2 ) + > out = {{alias}}( 2, x, 2 ) 7.0 // Using typed array views: > var x0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); > var x1 = new {{alias:@stdlib/array/complex128}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > s = {{alias}}( 2, x1, 1 ) + > out = {{alias}}( 2, x1, 1 ) 18.0 @@ -71,19 +71,19 @@ Returns ------- - sum: number - Sum of absolute values. + out: number + Result. Examples -------- // Standard usage: > var x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0 ] ); - > var s = {{alias}}.ndarray( x.length, x, 1, 0 ) + > var out = {{alias}}.ndarray( x.length, x, 1, 0 ) 11.0 // Advanced indexing: > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); - > s = {{alias}}.ndarray( 3, x, -1, x.length-1 ) + > out = {{alias}}.ndarray( 3, x, -1, x.length-1 ) 33.0 See Also diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts index f5679e6c8f85..f4337831da6a 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts index 16f905048756..7d25b9f4dfd7 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/dzasum/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/dzasum/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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/dzasum/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dzasum/examples/c/example.c new file mode 100644 index 000000000000..7e03d10fb8bc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/examples/c/example.c @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/dzasum.h" +#include + +int main( void ) { + // Create a strided array of interleaved real and imaginary components: + const double X[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + + // Specify the number of elements: + const int N = 4; + + // Specify stride length: + const int strideX = 1; + + // Compute the sum of the absolute values of real and imaginary components: + double out = c_dzasum( N, (void *)X, strideX ); + + // Print the result: + printf( "out: %lf\n", out ); + + // Compute the sum of the absolute values of real and imaginary components using alternative indexing semantics: + out = c_dzasum_ndarray( N, (void *)X, -strideX, N-1 ); + + // Print the result: + printf( "out: %lf\n", out ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js b/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js index 2f0a93e5c503..2fa386811dc4 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/include.gypi b/lib/node_modules/@stdlib/blas/base/dzasum/include.gypi new file mode 100644 index 000000000000..dcb556d250e8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/include.gypi @@ -0,0 +1,70 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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)', + ' + +/** +* Receives JavaScript callback invocation data. +* +* @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, 3 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(c_dzasum)( N, (void *)X, strideX ), out ); + return out; +} + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( 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, 2 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(c_dzasum_ndarray)( N, (void *)X, strideX, offsetX ), out ); + return out; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.c b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.c new file mode 100644 index 000000000000..3aa53265e4fe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.c @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/dzasum.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" + +/** +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +*/ +double API_SUFFIX(c_dzasum)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX ) { + CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + return API_SUFFIX(c_dzasum_ndarray)( N, X, strideX, ox ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.f b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.f new file mode 100644 index 000000000000..1d9d9f55d211 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum.f @@ -0,0 +1,83 @@ +!> +! @license Apache-2.0 +! +! Copyright (c) 2026 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. +!< + +!> Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. +! +! ## Notes +! +! * Modified version of reference BLAS level1 routine (version 3.8.0). Updated to "free form" Fortran 95. +! +! ## Authors +! +! * Edward Anderson, Lockheed Martin +! * Weslley Pereira, University of Colorado Denver, USA +! +! ## History +! +! * Original version written on August 2016. +! +! ## License +! +! From : +! +! > The reference BLAS is a freely-available software package. It is available from netlib via anonymous ftp and the World Wide Web. Thus, it can be included in commercial software packages (and has been). We only ask that proper credit be given to the authors. +! > +! > Like all software, it is copyrighted. It is not trademarked, but we do ask the following: +! > +! > * If you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original. +! > +! > * We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support. +! +! @param {integer} N - number of indexed elements +! @param {Array} x - array +! @param {integer} strideX - `x` stride length +! @returns {double precision} result +!< +double precision function dzasum( N, x, strideX ) + implicit none + ! .. + ! Scalar arguments: + integer :: N, strideX + ! .. + ! Array arguments: + complex(kind=kind(0.0d0)) :: x( * ) + ! .. + ! Local scalars: + integer :: i, nix + double precision :: stemp + ! .. + ! Intrinsic functions: + intrinsic abs, aimag, dble + ! .. + dzasum = 0.0d0 + stemp = 0.0d0 + ! .. + if ( N <= 0 .or. strideX <= 0 ) return + if( strideX == 1 ) then + do i = 1, N + stemp = stemp + ( abs( dble( x( i ) ) ) + abs( aimag( x( i ) ) ) ) + end do + else + nix = N*strideX + do i = 1, nix, strideX + stemp = stemp + ( abs( dble( x( i ) ) ) + abs( aimag( x( i ) ) ) ) + end do + end if + dzasum = stemp + return +end function dzasum diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_cblas.c b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_cblas.c new file mode 100644 index 000000000000..1724aab524c9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_cblas.c @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/dzasum.h" +#include "stdlib/blas/base/dzasum_cblas.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/strided/base/min_view_buffer_index.h" + +/** +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +*/ +double API_SUFFIX(c_dzasum)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX ) { + CBLAS_INT sx = strideX; + if( sx < 0 ) { + X = (const void *)( (const double *)X + ( (N-1) * (-sx) * 2 ) ); + sx = -sx; + } + return API_SUFFIX(cblas_dzasum)( N, X, sx ); +} + +/** +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +*/ +double API_SUFFIX(c_dzasum_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + const stdlib_complex128_t *x = (const stdlib_complex128_t *)X; + CBLAS_INT sx = strideX; + if( sx < 0 ) { + sx = -sx; + } + x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); + return API_SUFFIX(cblas_dzasum)( N, (void *)x, sx ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_f.c b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_f.c new file mode 100644 index 000000000000..669d8dc870d4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_f.c @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/dzasum.h" +#include "stdlib/blas/base/dzasum_fortran.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/strided/base/min_view_buffer_index.h" + +/** +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @return result +*/ +double API_SUFFIX(c_dzasum)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX ) { + CBLAS_INT sx; + double out; + + sx = strideX; + if ( sx < 0 ) { + sx = -sx; + } + dzasumsub( &N, X, &sx, &out ); + return out; +} + +/** +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +* @return result +*/ +double API_SUFFIX(c_dzasum_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + const stdlib_complex128_t *x = (const stdlib_complex128_t *)X; + CBLAS_INT sx = strideX; + double out; + + x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); + if ( sx < 0 ) { + sx = -sx; + } + dzasumsub( &N, (void *)x, &sx, &out ); + return out; +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_ndarray.c b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_ndarray.c new file mode 100644 index 000000000000..9166e3521a80 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasum_ndarray.c @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/dzasum.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/math/base/special/abs.h" + +/** +* Computes the sum of the absolute values of the real and imaginary components of a double-precision complex floating-point vector using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +*/ +double API_SUFFIX(c_dzasum_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + const double *x = (const double *)X; + double stemp; + CBLAS_INT sx; + CBLAS_INT ix; + CBLAS_INT i; + + if ( N <= 0 ) { + return 0.0; + } + stemp = 0.0; + sx = strideX * 2; + ix = offsetX * 2; + for( i = 0; i < N; i++ ) { + stemp += stdlib_base_abs( x[ix] ) + stdlib_base_abs( x[ix+1] ); + ix += sx; + } + return stemp; +} diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasumsub.f b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasumsub.f new file mode 100644 index 000000000000..9a129ba549dc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/src/dzasumsub.f @@ -0,0 +1,46 @@ +!> +! @license Apache-2.0 +! +! Copyright (c) 2026 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. +!< + +!> Wraps `dzasum` as a subroutine. +! +! @param {integer} N - number of indexed elements +! @param {Array} x - input array +! @param {integer} strideX - `x` stride length +! @param {double precision} out - output variable reference +!< +subroutine dzasumsub( N, x, strideX, out ) + implicit none + ! .. + ! External functions: + interface + double precision function dzasum( N, x, strideX ) + complex(kind=kind(0.0d0)) :: x(*) + integer :: strideX, N + end function dzasum + end interface + ! .. + ! Scalar arguments: + integer :: strideX, N + double precision :: out + ! .. + ! Array arguments: + complex(kind=kind(0.0d0)) :: x(*) + ! .. + out = dzasum( N, x, strideX ) + return +end subroutine dzasumsub diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test.f b/lib/node_modules/@stdlib/blas/base/dzasum/test.f new file mode 100644 index 000000000000..e2dd83c8c215 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test.f @@ -0,0 +1,12 @@ + double precision function dzasum( N, x, strideX ) + implicit none + integer :: N, strideX + complex(kind=kind(0.0d0)) :: x( * ) + integer :: i + double precision :: stemp + intrinsic abs, dble, aimag + stemp = 0.0d0 + stemp = stemp + abs( dble( x( 1 ) ) ) + abs( aimag( x( 1 ) ) ) + dzasum = stemp + return + end function dzasum diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js index 181c7a728d82..7b63340f54a5 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 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. @@ -42,7 +42,14 @@ tape( 'the function computes the sum of absolute values', function test( t ) { var x; var y; - x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + x = new Complex128Array( [ + 1.0, + -2.0, + 3.0, + -4.0, + 5.0, + -6.0 + ] ); y = dzasum( x.length, x, 1 ); t.strictEqual( y, 21.0, 'returns expected value' ); @@ -74,7 +81,14 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu var x; var y; - x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + x = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + -4.0, + 5.0, // 2 + -6.0 // 2 + ]); y = dzasum( 0, x, 1 ); t.strictEqual( y, 0.0, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.native.js new file mode 100644 index 000000000000..da3c9f239cf5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.native.js @@ -0,0 +1,152 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var dzasum = tryRequire( resolve( __dirname, './../lib/dzasum.native.js' ) ); +var opts = { + 'skip': ( dzasum instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dzasum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 3', opts, function test( t ) { + t.strictEqual( dzasum.length, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the sum of absolute values', opts, function test( t ) { + var x; + var y; + + x = new Complex128Array( [ + 1.0, + -2.0, + 3.0, + -4.0, + 5.0, + -6.0 + ] ); + y = dzasum( x.length, x, 1 ); + + t.strictEqual( y, 21.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + -4.0, + 5.0, // 2 + -6.0 // 2 + ]); + N = 2; + + y = dzasum( N, x, 2 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', opts, function test( t ) { + var x; + var y; + + x = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + -4.0, + 5.0, // 2 + -6.0 // 2 + ]); + y = dzasum( 0, x, 1 ); + + t.strictEqual( y, 0.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride', opts, function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 2 + -2.0, // 2 + 3.0, + -4.0, + 5.0, // 1 + -6.0 // 1 + ]); + N = 2; + + y = dzasum( N, x, -2 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var x0; + var x1; + var y; + var N; + + // Initial array... + x0 = new Complex128Array([ + 1.0, + -2.0, + 3.0, // 1 + -4.0, // 1 + 5.0, // 2 + -6.0 // 2 + ]); + + // Create an offset view... + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + + N = 2; + y = dzasum( N, x1, 1 ); + + t.strictEqual( y, 18.0, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.js index c7c4ac04005a..85e3d70d6dc5 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 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. @@ -22,14 +22,14 @@ var tape = require( 'tape' ); var proxyquire = require( 'proxyquire' ); -var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var isBrowser = require( '@stdlib/assert/is-browser' ); var dzasum = require( './../lib' ); // VARIABLES // var opts = { - 'skip': IS_BROWSER + 'skip': isBrowser }; diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js index ac1ca0fa4b91..4c7e1d30cbd9 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js @@ -42,7 +42,14 @@ tape( 'the function computes the sum of absolute values', function test( t ) { var x; var y; - x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + x = new Complex128Array( [ + 1.0, + -2.0, + 3.0, + -4.0, + 5.0, + -6.0 + ] ); y = dzasum( x.length, x, 1, 0 ); t.strictEqual( y, 21.0, 'returns expected value' ); @@ -95,7 +102,14 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu var x; var y; - x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + x = new Complex128Array( [ + 1.0, + -2.0, + 3.0, + -4.0, + 5.0, + -6.0 + ] ); y = dzasum( -1, x, 1, 0 ); t.strictEqual( y, 0.0, 'returns expected value' ); @@ -126,3 +140,34 @@ tape( 'the function supports specifying a negative stride', function test( t ) { t.strictEqual( y, 14.0, 'returns expected value' ); t.end(); }); + +tape( 'the function supports specifying complex access patterns', function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 0.3, // 4 + 0.1, // 4 + 5.0, + 8.0, + 0.5, // 3 + 0.0, // 3 + 6.0, + 9.0, + 0.0, // 2 + 0.5, // 2 + 8.0, + 3.0, + 0.0, // 1 + 0.2, // 1 + 9.0, + 4.0 + ]); + N = 4; + + y = dzasum( N, x, -2, 6 ); + + t.strictEqual( y, 1.6, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js new file mode 100644 index 000000000000..8d201d8198a7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js @@ -0,0 +1,182 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var dzasum = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dzasum instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dzasum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', opts, function test( t ) { + t.strictEqual( dzasum.length, 4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the sum of absolute values', opts, function test( t ) { + var x; + var y; + + x = new Complex128Array( [ + 1.0, + -2.0, + 3.0, + -4.0, + 5.0, + -6.0 + ] ); + y = dzasum( x.length, x, 1, 0 ); + + t.strictEqual( y, 21.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + -4.0, + 5.0, // 2 + -6.0 // 2 + ]); + N = 2; + + y = dzasum( N, x, 2, 0 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, + -2.0, + 3.0, // 1 + -4.0, // 1 + 5.0, // 2 + -6.0 // 2 + ]); + N = 2; + + y = dzasum( N, x, 1, 1 ); + + t.strictEqual( y, 18.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', opts, function test( t ) { + var x; + var y; + + x = new Complex128Array( [ + 1.0, + -2.0, + 3.0, + -4.0, + 5.0, + -6.0 + ] ); + + y = dzasum( -1, x, 1, 0 ); + t.strictEqual( y, 0.0, 'returns expected value' ); + + y = dzasum( 0, x, 1, 0 ); + t.strictEqual( y, 0.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride', opts, function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 1.0, // 2 + -2.0, // 2 + 3.0, + -4.0, + 5.0, // 1 + -6.0 // 1 + ]); + N = 2; + + y = dzasum( N, x, -2, x.length-1 ); + + t.strictEqual( y, 14.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying complex access patterns', opts, function test( t ) { + var x; + var y; + var N; + + x = new Complex128Array([ + 0.3, // 4 + 0.1, // 4 + 5.0, + 8.0, + 0.5, // 3 + 0.0, // 3 + 6.0, + 9.0, + 0.0, // 2 + 0.5, // 2 + 8.0, + 3.0, + 0.0, // 1 + 0.2, // 1 + 9.0, + 4.0 + ]); + N = 4; + + y = dzasum( N, x, -2, 6 ); + + t.strictEqual( y, 1.5999999999999999, 'returns expected value' ); + t.end(); +}); From 40e4f9033af0f4112a8520f8eb41b2ce9b7565e3 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Fri, 13 Mar 2026 19:05:46 +0530 Subject: [PATCH 13/14] fix: linting errors --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dzasum/benchmark/benchmark.js | 3 ++- .../blas/base/dzasum/benchmark/benchmark.native.js | 4 ++-- .../blas/base/dzasum/benchmark/benchmark.ndarray.js | 3 ++- .../base/dzasum/benchmark/benchmark.ndarray.native.js | 3 ++- lib/node_modules/@stdlib/blas/base/dzasum/lib/main.js | 2 +- .../@stdlib/blas/base/dzasum/test/test.dzasum.js | 4 ++-- .../@stdlib/blas/base/dzasum/test/test.dzasum.native.js | 4 ++-- .../@stdlib/blas/base/dzasum/test/test.ndarray.js | 8 ++++---- .../@stdlib/blas/base/dzasum/test/test.ndarray.native.js | 8 ++++---- 9 files changed, 21 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js index 0685dbdd0324..322fb242f34e 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.js @@ -25,6 +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 format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var dzasum = require( './../lib/dzasum.js' ); @@ -98,7 +99,7 @@ function main() { for ( i = min; i <= max; i++ ) { N = pow( 10, i ); f = createBenchmark( N ); - bench( pkg+':size='+N, f ); + bench( format( '%s:size=%u', pkg, N ), f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.native.js index 2f260030168a..07ea33e4139e 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.native.js @@ -27,6 +27,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Complex128Array = require( '@stdlib/array/complex128' ); var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -41,7 +42,6 @@ var options = { }; - // FUNCTIONS // /** @@ -104,7 +104,7 @@ function main() { for ( i = min; i <= max; i++ ) { N = pow( 10, i ); f = createBenchmark( N ); - bench( pkg+'::native:size='+N, opts, f ); + bench( format( '%s::native:size=%u', pkg, N ), opts, f); } } diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js index c30bf8754231..07eecc11a3a7 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.js @@ -25,6 +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 format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var dzasum = require( './../lib/ndarray.js' ); @@ -98,7 +99,7 @@ function main() { for ( i = min; i <= max; i++ ) { N = pow( 10, i ); f = createBenchmark( N ); - bench( pkg+':ndarray:size='+N, f ); + bench( format( '%s:ndarray:size=%u', pkg, N ), f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.native.js index 653e27aa8f31..5a3d4e279d27 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/benchmark/benchmark.ndarray.native.js @@ -27,6 +27,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var Complex128Array = require( '@stdlib/array/complex128' ); var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -103,7 +104,7 @@ function main() { for ( i = min; i <= max; i++ ) { N = pow( 10, i ); f = createBenchmark( N ); - bench( pkg+':ndarray:native:size='+N, opts, f ); + bench( format( '%s:ndarray:native:size=%u', pkg, N ), opts, f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/lib/main.js b/lib/node_modules/@stdlib/blas/base/dzasum/lib/main.js index 9f1fb017d3c2..1dfa09e73ab1 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/lib/main.js @@ -3,7 +3,7 @@ * * Copyright (c) 2026 The Stdlib Authors. * -* Licensed under the Apache Lice nse, Version 2.0 (the "License"); +* 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 * diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js index 7b63340f54a5..e487766c861c 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.js @@ -42,14 +42,14 @@ tape( 'the function computes the sum of absolute values', function test( t ) { var x; var y; - x = new Complex128Array( [ + x = new Complex128Array([ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 - ] ); + ]); y = dzasum( x.length, x, 1 ); t.strictEqual( y, 21.0, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.native.js index da3c9f239cf5..de47e07ab989 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.native.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.dzasum.native.js @@ -51,14 +51,14 @@ tape( 'the function computes the sum of absolute values', opts, function test( t var x; var y; - x = new Complex128Array( [ + x = new Complex128Array([ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 - ] ); + ]); y = dzasum( x.length, x, 1 ); t.strictEqual( y, 21.0, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js index 4c7e1d30cbd9..7b3eb02dd41b 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js @@ -42,14 +42,14 @@ tape( 'the function computes the sum of absolute values', function test( t ) { var x; var y; - x = new Complex128Array( [ + x = new Complex128Array([ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 - ] ); + ]); y = dzasum( x.length, x, 1, 0 ); t.strictEqual( y, 21.0, 'returns expected value' ); @@ -102,14 +102,14 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu var x; var y; - x = new Complex128Array( [ + x = new Complex128Array([ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 - ] ); + ]); y = dzasum( -1, x, 1, 0 ); t.strictEqual( y, 0.0, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js index 8d201d8198a7..fea132e4bf4c 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js @@ -51,14 +51,14 @@ tape( 'the function computes the sum of absolute values', opts, function test( t var x; var y; - x = new Complex128Array( [ + x = new Complex128Array([ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 - ] ); + ]); y = dzasum( x.length, x, 1, 0 ); t.strictEqual( y, 21.0, 'returns expected value' ); @@ -111,14 +111,14 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu var x; var y; - x = new Complex128Array( [ + x = new Complex128Array([ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 - ] ); + ]); y = dzasum( -1, x, 1, 0 ); t.strictEqual( y, 0.0, 'returns expected value' ); From cba5d266888d5911c82f9d8da13fc895149795bc Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Fri, 13 Mar 2026 19:28:33 +0530 Subject: [PATCH 14/14] fix: upgraded copyright years --- lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.native.js | 2 +- lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js | 2 +- .../@stdlib/blas/base/dzasum/test/test.ndarray.native.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.native.js index cb9b39a85d1b..9988bcbfc0ec 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.native.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/lib/dzasum.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js index 7b3eb02dd41b..11976d4c4fca 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js index fea132e4bf4c..cef1cd30f78f 100644 --- a/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dzasum/test/test.ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 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.