From 10285d405f011c35305358e28e07dd32fbe0d7cf Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Fri, 17 Jan 2025 17:25:40 +0000 Subject: [PATCH 1/6] feat: add blas/base/izamax --- 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: 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 --- --- 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 --- --- 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/izamax/README.md | 172 +++++++++++++++ .../blas/base/izamax/benchmark/benchmark.js | 105 +++++++++ .../izamax/benchmark/benchmark.ndarray.js | 105 +++++++++ .../@stdlib/blas/base/izamax/docs/repl.txt | 91 ++++++++ .../blas/base/izamax/docs/types/index.d.ts | 96 +++++++++ .../blas/base/izamax/docs/types/test.ts | 158 ++++++++++++++ .../blas/base/izamax/examples/index.js | 35 +++ .../@stdlib/blas/base/izamax/lib/index.js | 68 ++++++ .../@stdlib/blas/base/izamax/lib/izamax.js | 53 +++++ .../@stdlib/blas/base/izamax/lib/main.js | 35 +++ .../@stdlib/blas/base/izamax/lib/ndarray.js | 75 +++++++ .../@stdlib/blas/base/izamax/package.json | 74 +++++++ .../blas/base/izamax/test/test.izamax.js | 182 ++++++++++++++++ .../@stdlib/blas/base/izamax/test/test.js | 82 +++++++ .../blas/base/izamax/test/test.ndarray.js | 202 ++++++++++++++++++ 15 files changed, 1533 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/lib/izamax.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/base/izamax/README.md b/lib/node_modules/@stdlib/blas/base/izamax/README.md new file mode 100644 index 000000000000..da361efaf11f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/README.md @@ -0,0 +1,172 @@ + + +# izamax + +> Find the index of the first element having the maximum absolute value. + +
+ +## Usage + +```javascript +var izamax = require( '@stdlib/blas/base/izamax' ); +``` + +#### izamax( N, zx, strideX ) + +Finds the index of the first element having the maximum absolute value. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + +var idx = izamax( zx.length, zx, 1 ); +// returns 1 +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **zx**: input [`Complex128Array`][@stdlib/array/complex128]. +- **strideX**: index increment for `zx`. + +The `N` and `strideX` parameters determine which elements in `zx` are accessed at runtime. For example, to traverse every other value, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + +var idx = izamax( 2, zx, 2 ); +// returns 1 +``` + +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 zx0 = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + +// Create an offset view: +var zx1 = new Complex128Array( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +// Find index of element having the maximum absolute value: +var idx = izamax( 2, zx1, 1 ); +// returns 1 +``` + +#### izamax.ndarray( N, zx, strideX, offset ) + +Finds the index of the first element having the maximum absolute value using alternative indexing semantics. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + +var idx = izamax.ndarray( zx.length, zx, 1, 0 ); +// returns 1 +``` + +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 `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 zx = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); + +var idx = izamax.ndarray( 3, zx, 1, 1 ); +// returns 2 +``` + +
+ + + +
+ +## Notes + +- If `N < 1`, both functions return `-1`. +- `izamax()` corresponds to the [BLAS][blas] level 1 function [`izamax`][izamax]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var izamax = require( '@stdlib/blas/base/izamax' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +// Generate random input arrays: +var zx = filledarrayBy( 10, 'complex128', rand ); +console.log( zx.toString() ); + +var idx = izamax( zx.length, zx, 1 ); +console.log( idx ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.js new file mode 100644 index 000000000000..e35072b9fbcf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/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 izamax = require( './../lib/izamax.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Create a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var zx; + + zx = new Complex128Array( uniform( len*2, -100.0, 100.0, options ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = izamax( zx.length, zx, 1 ); + if ( isnan( idx ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( idx ) ) { + 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/izamax/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..42d38a98b6b1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/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 izamax = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Create a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var zx; + + zx = new Complex128Array( uniform( len*2, -100.0, 100.0, options ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = izamax( zx.length, zx, 1, 0 ); + if ( isnan( idx ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( idx ) ) { + 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/izamax/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/izamax/docs/repl.txt new file mode 100644 index 000000000000..f2313a739e5f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/docs/repl.txt @@ -0,0 +1,91 @@ + +{{alias}}( N, zx, strideX ) + Finds the index of the first element having the maximum absolute value. + + The `N` and `strideX` parameters determine which elements in `zx` are + accessed at runtime. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N < 1`, the function returns `-1`. + + Parameters + ---------- + N: integer + Number of indexed elements. + + zx: Complex128Array + Input array. + + strideX: integer + Index increment for `zx`. + + Returns + ------- + idx: integer + Index value. + + Examples + -------- + // Standard Usage: + > var zx; + > zx = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); + > var idx = {{alias}}( zx.length, zx, 1 ) + 1 + + // Using `N` and `strideX` parameters: + > zx = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); + > idx = {{alias}}( 2, zx, 2 ) + 1 + + // Using view offsets: + > var zx0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + > var zx1 = new {{alias:@stdlib/array/complex128}}( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); + > idx = {{alias}}( 2, zx1, 1 ) + 1 + + +{{alias}}.ndarray( N, zx, strideX, offsetX ) + Finds the index of the first element having the maximum absolute value using + alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the `offsetX` parameter supports indexing semantics based on a + starting index. + + Parameters + ---------- + N: integer + Number of indexed elements. + + zx: Complex128Array + Input array. + + strideX: integer + Index increment for `zx`. + + offsetX: integer + Starting index of `zx`. + + Returns + ------- + idx: integer + Index value. + + Examples + -------- + // Standard Usage: + > var zx; + > zx = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); + > var idx = {{alias}}.ndarray( zx.length, zx, 1, 0 ) + 1 + + // Using an index offset: + > zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + > idx = {{alias}}.ndarray( 2, zx, 1, 1 ) + 1 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/izamax/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/izamax/docs/types/index.d.ts new file mode 100644 index 000000000000..88f27a0114e6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/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 `izamax`. +*/ +interface Routine { + /** + * Finds the index of the first element having the maximum absolute value. + * + * @param N - number of indexed elements + * @param zx - input array + * @param strideX - stride length for `zx` + * @returns index value + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * + * var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + * + * var idx = izamax( zx.length, zx, 1 ); + * // returns 1 + */ + ( N: number, zx: Complex128Array, strideX: number ): number; + + /** + * Finds the index of the first element having the maximum absolute value using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param zx - input array + * @param strideX - stride length for `zx` + * @param offsetX - starting index for `zx` + * @returns index value + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * + * var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + * + * var idx = izamax.ndarray( zx.length, zx, 1, 0 ); + * // returns 1 + */ + ndarray( N: number, zx: Complex128Array, strideX: number, offsetX: number ): number; +} + +/** +* Finds the index of the first element having the maximum absolute value. +* +* @param N - number of indexed elements +* @param zx - input array +* @param strideX - stride length for `zx` +* @returns index value +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var idx = izamax( zx.length, zx, 1 ); +* // returns 1 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var idx = izamax.ndarray( zx.length, zx, 1, 0 ); +* // returns 1 +*/ +declare var izamax: Routine; + + +// EXPORTS // + +export = izamax; diff --git a/lib/node_modules/@stdlib/blas/base/izamax/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/izamax/docs/types/test.ts new file mode 100644 index 000000000000..21eef7e322e3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/docs/types/test.ts @@ -0,0 +1,158 @@ +/* +* @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. +*/ + +import Complex128Array = require( '@stdlib/array/complex128' ); +import izamax = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const zx = new Complex128Array( 10 ); + + izamax( zx.length, zx, 1 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + izamax( '10', zx, 1 ); // $ExpectError + izamax( true, zx, 1 ); // $ExpectError + izamax( false, zx, 1 ); // $ExpectError + izamax( null, zx, 1 ); // $ExpectError + izamax( undefined, zx, 1 ); // $ExpectError + izamax( [], zx, 1 ); // $ExpectError + izamax( {}, zx, 1 ); // $ExpectError + izamax( ( x: number ): number => x, zx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + + izamax( zx.length, 10, 1 ); // $ExpectError + izamax( zx.length, '10', 1 ); // $ExpectError + izamax( zx.length, true, 1 ); // $ExpectError + izamax( zx.length, false, 1 ); // $ExpectError + izamax( zx.length, null, 1 ); // $ExpectError + izamax( zx.length, undefined, 1 ); // $ExpectError + izamax( zx.length, [], 1 ); // $ExpectError + izamax( zx.length, {}, 1 ); // $ExpectError + izamax( zx.length, ( zx: number ): number => zx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + izamax( zx.length, zx, '10' ); // $ExpectError + izamax( zx.length, zx, true ); // $ExpectError + izamax( zx.length, zx, false ); // $ExpectError + izamax( zx.length, zx, null ); // $ExpectError + izamax( zx.length, zx, undefined ); // $ExpectError + izamax( zx.length, zx, [] ); // $ExpectError + izamax( zx.length, zx, {} ); // $ExpectError + izamax( zx.length, zx, ( zx: number ): number => zx ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const zx = new Complex128Array( 10 ); + + izamax(); // $ExpectError + izamax( zx.length ); // $ExpectError + izamax( zx.length, zx ); // $ExpectError + izamax( zx.length, zx, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const zx = new Complex128Array( 10 ); + + izamax.ndarray( zx.length, zx, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + izamax.ndarray( '10', zx, 1, 0 ); // $ExpectError + izamax.ndarray( true, zx, 1, 0 ); // $ExpectError + izamax.ndarray( false, zx, 1, 0 ); // $ExpectError + izamax.ndarray( null, zx, 1, 0 ); // $ExpectError + izamax.ndarray( undefined, zx, 1, 0 ); // $ExpectError + izamax.ndarray( [], zx, 1, 0 ); // $ExpectError + izamax.ndarray( {}, zx, 1, 0 ); // $ExpectError + izamax.ndarray( ( zx: number ): number => zx, zx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + + izamax.ndarray( zx.length, 10, 1, 0 ); // $ExpectError + izamax.ndarray( zx.length, '10', 1, 0 ); // $ExpectError + izamax.ndarray( zx.length, true, 1, 0 ); // $ExpectError + izamax.ndarray( zx.length, false, 1, 0 ); // $ExpectError + izamax.ndarray( zx.length, null, 1, 0 ); // $ExpectError + izamax.ndarray( zx.length, undefined, 1, 0 ); // $ExpectError + izamax.ndarray( zx.length, [], 1, 0 ); // $ExpectError + izamax.ndarray( zx.length, {}, 1, 0 ); // $ExpectError + izamax.ndarray( zx.length, ( zx: number ): number => zx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + izamax.ndarray( zx.length, zx, '10', 0 ); // $ExpectError + izamax.ndarray( zx.length, zx, true, 0 ); // $ExpectError + izamax.ndarray( zx.length, zx, false, 0 ); // $ExpectError + izamax.ndarray( zx.length, zx, null, 0 ); // $ExpectError + izamax.ndarray( zx.length, zx, undefined, 0 ); // $ExpectError + izamax.ndarray( zx.length, zx, [], 0 ); // $ExpectError + izamax.ndarray( zx.length, zx, {}, 0 ); // $ExpectError + izamax.ndarray( zx.length, zx, ( zx: number ): number => zx, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + izamax.ndarray( zx.length, zx, 1, '10' ); // $ExpectError + izamax.ndarray( zx.length, zx, 1, true ); // $ExpectError + izamax.ndarray( zx.length, zx, 1, false ); // $ExpectError + izamax.ndarray( zx.length, zx, 1, null ); // $ExpectError + izamax.ndarray( zx.length, zx, 1, undefined ); // $ExpectError + izamax.ndarray( zx.length, zx, 1, [] ); // $ExpectError + izamax.ndarray( zx.length, zx, 1, {} ); // $ExpectError + izamax.ndarray( zx.length, zx, 1, ( zx: number ): number => zx ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const zx = new Complex128Array( 10 ); + + izamax.ndarray(); // $ExpectError + izamax.ndarray( zx.length ); // $ExpectError + izamax.ndarray( zx.length, zx ); // $ExpectError + izamax.ndarray( zx.length, zx, 1 ); // $ExpectError + izamax.ndarray( zx.length, zx, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/izamax/examples/index.js b/lib/node_modules/@stdlib/blas/base/izamax/examples/index.js new file mode 100644 index 000000000000..fd5ac991af33 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/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 filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var izamax = require( '@stdlib/blas/base/izamax' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +// Generate random input arrays: +var zx = filledarrayBy( 10, 'complex128', rand ); +console.log( zx.toString() ); + +var idx = izamax( zx.length, zx, 1 ); +console.log( idx ); diff --git a/lib/node_modules/@stdlib/blas/base/izamax/lib/index.js b/lib/node_modules/@stdlib/blas/base/izamax/lib/index.js new file mode 100644 index 000000000000..6d8255423cd7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/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 find the index of the first element having the maximum absolute value. +* +* @module @stdlib/blas/base/izamax +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var izamax = require( '@stdlib/blas/base/izamax' ); +* +* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var idx = izamax( zx.length, zx, 1 ); +* // returns 1 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var izamax = require( '@stdlib/blas/base/izamax' ); +* +* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var idx = izamax.ndarray( zx.length, zx, 1, 0 ); +* // returns 1 +*/ + +// 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 izamax; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + izamax = main; +} else { + izamax = tmp; +} + + +// EXPORTS // + +module.exports = izamax; + +// exports: { "ndarray": "izamax.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/izamax/lib/izamax.js b/lib/node_modules/@stdlib/blas/base/izamax/lib/izamax.js new file mode 100644 index 000000000000..f03ffe6cbd65 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/lib/izamax.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 // + +/** +* Finds the index of the first element having the maximum absolute value. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128Array} zx - input array +* @param {integer} strideX - `zx` stride length +* @returns {integer} index value +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var idx = izamax( zx.length, zx, 1 ); +* // returns 1 +*/ +function izamax( N, zx, strideX ) { + var ox = stride2offset( N, strideX ); + return ndarray( N, zx, strideX, ox ); +} + + +// EXPORTS // + +module.exports = izamax; diff --git a/lib/node_modules/@stdlib/blas/base/izamax/lib/main.js b/lib/node_modules/@stdlib/blas/base/izamax/lib/main.js new file mode 100644 index 000000000000..4e6037fb5a26 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/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 izamax = require( './izamax.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( izamax, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = izamax; diff --git a/lib/node_modules/@stdlib/blas/base/izamax/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/izamax/lib/ndarray.js new file mode 100644 index 000000000000..38b9cb09050a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/lib/ndarray.js @@ -0,0 +1,75 @@ +/** +* @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 // + +/** +* Finds the index of the first element having the maximum absolute value. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128Array} zx - input array +* @param {integer} strideX - `zx` stride length +* @param {NonNegativeInteger} offsetX - starting index for `zx` +* @returns {integer} index value +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var idx = izamax( zx.length, zx, 1, 0 ); +* // returns 1 +*/ +function izamax( N, zx, strideX, offsetX ) { + var zmax; + var idx; + var ix; + var v; + var i; + + if ( N < 1 ) { + return -1; + } + idx = 0; + if ( N === 1 ) { + return idx; + } + zmax = dcabs1( zx.get( offsetX ) ); + ix = offsetX + strideX; + for ( i = 1; i < N; i++ ) { + v = dcabs1( zx.get( ix ) ); + if ( v > zmax ) { + idx = i; + zmax = v; + } + ix += strideX; + } + return idx; +} + + +// EXPORTS // + +module.exports = izamax; diff --git a/lib/node_modules/@stdlib/blas/base/izamax/package.json b/lib/node_modules/@stdlib/blas/base/izamax/package.json new file mode 100644 index 000000000000..03b09daef463 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/blas/base/izamax", + "version": "0.0.0", + "description": "Find the index of the first element having the maximum absolute value.", + "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", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "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", + "izamax", + "maximum", + "dcabs1", + "absolute", + "find", + "index", + "linear", + "algebra", + "subroutines", + "vector", + "array", + "ndarray", + "complex128", + "complex", + "complex128array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.js b/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.js new file mode 100644 index 000000000000..3213d525a57f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.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 tape = require( 'tape' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var izamax = require( './../lib/izamax.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof izamax, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 3', function test( t ) { + t.strictEqual( izamax.length, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the function finds the index of the element with the maximum absolute value', function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 0.1, // 1 + -0.3, // 1 + 0.5, // 2 + -0.1, // 2 + -0.2, // 3 + 0.6, // 3 + -0.4, // 4 + 0.9 // 4 + ]); + expected = 3; + + idx = izamax( 4, x, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + x = new Complex128Array([ + 0.2, // 1 + -0.6, // 1 + 0.3, // 2 + 0.6, // 2 + 5.0, + 5.0 + ]); + expected = 1; + + idx = izamax( 2, x, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than `1`, the function returns `-1`', function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, + 4.0 + ]); + expected = -1; + + idx = izamax( 0, x, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, + 4.0 + ]); + expected = 0; + + idx = izamax( 1, x, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride', function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 0.1, // 1 + 4.0, // 1 + -0.3, + 6.0, + -0.5, // 2 + 7.0, // 2 + -0.1, + 3.0 + ]); + expected = 1; + + idx = izamax( 2, x, 2 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride', function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] ); + expected = 1; + + idx = izamax( x.length, x, -1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + // eslint-disable-next-line max-len + x = new Complex128Array( [ 0.1, 4.0, 999.0, 999.0, -0.3, 6.0, 999.0, 999.0, -0.5, 7.0, 999.0, 999.0, -0.1, 3.0 ] ); + expected = 1; + + idx = izamax( 4, x, -2 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var expected; + var idx; + var x0; + var x1; + + x0 = new Complex128Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, // 1 + 6.0, // 1 + 7.0, // 2 + 8.0 // 2 + ]); + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + expected = 2; + + idx = izamax( 3, x1, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/izamax/test/test.js b/lib/node_modules/@stdlib/blas/base/izamax/test/test.js new file mode 100644 index 000000000000..c1ac86a56ee4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/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 izamax = 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 izamax, '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 izamax.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 izamax = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( izamax, 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 izamax; + var main; + + main = require( './../lib/izamax.js' ); + + izamax = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( izamax, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.js new file mode 100644 index 000000000000..c424362c59d7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.js @@ -0,0 +1,202 @@ +/** +* @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 izamax = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof izamax, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( izamax.length, 4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function finds the index of the element with the maximum absolute value', function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 0.1, // 1 + -0.3, // 1 + 0.5, // 2 + -0.1, // 2 + -0.2, // 3 + 0.6, // 3 + -0.4, // 4 + 0.9 // 4 + ]); + expected = 3; + + idx = izamax( 4, x, 1, 0 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + x = new Complex128Array([ + 0.2, // 1 + -0.6, // 1 + 0.3, // 2 + 0.6, // 2 + 5.0, + 5.0 + ]); + expected = 1; + + idx = izamax( 2, x, 1, 0 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than `1`, the function returns `-1`', function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, + 4.0 + ]); + expected = -1; + + idx = izamax( 0, x, 1, 0 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, + 4.0 + ]); + expected = 0; + + idx = izamax( 1, x, 1, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports accessing elements in reverse order', function test( t ) { + var idx; + var x; + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] ); + + idx = izamax( x.length, x, -1, x.length-1 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = izamax( 2, x, -1, x.length-2 ); + t.strictEqual( idx, 0, 'returns expected value' ); + + // eslint-disable-next-line max-len + x = new Complex128Array( [ 0.1, 4.0, 999.0, 999.0, -0.3, 6.0, 999.0, 999.0, -0.5, 7.0, 999.0, 999.0, -0.1, 3.0 ] ); + idx = izamax( 4, x, -2, x.length-1 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride', function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 0.1, // 1 + 4.0, // 1 + -0.3, + 6.0, + -0.5, // 2 + 7.0, // 2 + -0.1, + 3.0 + ]); + expected = 1; + + idx = izamax( 2, x, 2, 0 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` offset', function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, // 1 + 6.0, // 1 + 7.0, // 2 + 8.0 // 2 + ]); + expected = 2; + + idx = izamax( 3, x, 1, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + expected = 1; + + idx = izamax( 2, x, 2, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); From 83893424eb9e94e5c3b13bfa09f5977fa380954d Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Fri, 17 Jan 2025 17:59:24 +0000 Subject: [PATCH 2/6] fix: readme example error --- 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 --- --- 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: passed - 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 --- --- lib/node_modules/@stdlib/blas/base/izamax/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/izamax/README.md b/lib/node_modules/@stdlib/blas/base/izamax/README.md index da361efaf11f..2ff0db6ba686 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/README.md +++ b/lib/node_modules/@stdlib/blas/base/izamax/README.md @@ -126,7 +126,7 @@ var idx = izamax.ndarray( 3, zx, 1, 1 ); ```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var izamax = require( '@stdlib/blas/base/izamax' ); From 550e42854d567b8a4ec8b2f47131119274a0a150 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 13 Jun 2025 17:09:03 +0530 Subject: [PATCH 3/6] chore: update implementation --- 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: passed - 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/izamax/README.md | 38 ++-- .../blas/base/izamax/benchmark/benchmark.js | 6 +- .../izamax/benchmark/benchmark.ndarray.js | 6 +- .../@stdlib/blas/base/izamax/docs/repl.txt | 48 ++--- .../blas/base/izamax/docs/types/index.d.ts | 34 ++-- .../blas/base/izamax/docs/types/test.ts | 170 +++++++++--------- .../blas/base/izamax/examples/index.js | 11 +- .../@stdlib/blas/base/izamax/lib/index.js | 10 +- .../@stdlib/blas/base/izamax/lib/izamax.js | 12 +- .../@stdlib/blas/base/izamax/lib/ndarray.js | 22 +-- .../@stdlib/blas/base/izamax/package.json | 2 +- .../blas/base/izamax/test/test.izamax.js | 32 ++-- .../blas/base/izamax/test/test.ndarray.js | 32 ++-- 13 files changed, 213 insertions(+), 210 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/izamax/README.md b/lib/node_modules/@stdlib/blas/base/izamax/README.md index 2ff0db6ba686..dac84f4d1f4e 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/README.md +++ b/lib/node_modules/@stdlib/blas/base/izamax/README.md @@ -30,33 +30,33 @@ limitations under the License. var izamax = require( '@stdlib/blas/base/izamax' ); ``` -#### izamax( N, zx, strideX ) +#### izamax( N, x, strideX ) Finds the index of the first element having the maximum absolute value. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); -var idx = izamax( zx.length, zx, 1 ); +var idx = izamax( x.length, x, 1 ); // returns 1 ``` The function has the following parameters: - **N**: number of indexed elements. -- **zx**: input [`Complex128Array`][@stdlib/array/complex128]. -- **strideX**: index increment for `zx`. +- **x**: input [`Complex128Array`][@stdlib/array/complex128]. +- **strideX**: index increment for `x`. -The `N` and `strideX` parameters determine which elements in `zx` are accessed at runtime. For example, to traverse every other value, +The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. For example, to traverse every other value, ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); -var idx = izamax( 2, zx, 2 ); +var idx = izamax( 2, x, 2 ); // returns 1 ``` @@ -66,26 +66,26 @@ Note that indexing is relative to the first index. To introduce an offset, use [ var Complex128Array = require( '@stdlib/array/complex128' ); // Initial array: -var zx0 = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); +var x0 = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); // Create an offset view: -var zx1 = new Complex128Array( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element // Find index of element having the maximum absolute value: -var idx = izamax( 2, zx1, 1 ); +var idx = izamax( 2, x1, 1 ); // returns 1 ``` -#### izamax.ndarray( N, zx, strideX, offset ) +#### izamax.ndarray( N, x, strideX, offset ) Finds the index of the first element having the maximum absolute value using alternative indexing semantics. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); -var idx = izamax.ndarray( zx.length, zx, 1, 0 ); +var idx = izamax.ndarray( x.length, x, 1, 0 ); // returns 1 ``` @@ -98,9 +98,9 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var zx = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); +var x = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 ] ); -var idx = izamax.ndarray( 3, zx, 1, 1 ); +var idx = izamax.ndarray( 3, x, 1, 1 ); // returns 2 ``` @@ -136,10 +136,10 @@ function rand() { } // Generate random input arrays: -var zx = filledarrayBy( 10, 'complex128', rand ); -console.log( zx.toString() ); +var x = filledarrayBy( 10, 'complex128', rand ); +console.log( x.toString() ); -var idx = izamax( zx.length, zx, 1 ); +var idx = izamax( x.length, x, 1 ); console.log( idx ); ``` diff --git a/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.js index e35072b9fbcf..8ef43e210efd 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.js @@ -46,9 +46,9 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var zx; + var x; - zx = new Complex128Array( uniform( len*2, -100.0, 100.0, options ) ); + x = new Complex128Array( uniform( len*2, -100.0, 100.0, options ) ); return benchmark; /** @@ -63,7 +63,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - idx = izamax( zx.length, zx, 1 ); + idx = izamax( x.length, x, 1 ); if ( isnan( idx ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.ndarray.js index 42d38a98b6b1..42ed0a56fc30 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.ndarray.js @@ -46,9 +46,9 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var zx; + var x; - zx = new Complex128Array( uniform( len*2, -100.0, 100.0, options ) ); + x = new Complex128Array( uniform( len*2, -100.0, 100.0, options ) ); return benchmark; /** @@ -63,7 +63,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - idx = izamax( zx.length, zx, 1, 0 ); + idx = izamax( x.length, x, 1, 0 ); if ( isnan( idx ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/base/izamax/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/izamax/docs/repl.txt index f2313a739e5f..d225d760548b 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/izamax/docs/repl.txt @@ -1,8 +1,8 @@ -{{alias}}( N, zx, strideX ) - Finds the index of the first element having the maximum absolute value. +{{alias}}( N, x, strideX ) + Finds the index of the first element having maximum |Re(.)| + |Im(.)|. - The `N` and `strideX` parameters determine which elements in `zx` are + The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use typed @@ -15,11 +15,11 @@ N: integer Number of indexed elements. - zx: Complex128Array + x: Complex128Array Input array. strideX: integer - Index increment for `zx`. + Index increment for `x`. Returns ------- @@ -29,26 +29,26 @@ Examples -------- // Standard Usage: - > var zx; - > zx = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); - > var idx = {{alias}}( zx.length, zx, 1 ) + > var x; + > x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); + > var idx = {{alias}}( x.length, x, 1 ) 1 // Using `N` and `strideX` parameters: - > zx = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); - > idx = {{alias}}( 2, zx, 2 ) + > x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); + > idx = {{alias}}( 2, x, 2 ) 1 // Using view offsets: - > var zx0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); - > var zx1 = new {{alias:@stdlib/array/complex128}}( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); - > idx = {{alias}}( 2, zx1, 1 ) + > 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 ); + > idx = {{alias}}( 2, x1, 1 ) 1 -{{alias}}.ndarray( N, zx, strideX, offsetX ) - Finds the index of the first element having the maximum absolute value using - alternative indexing semantics. +{{alias}}.ndarray( N, x, strideX, offsetX ) + Finds the index of the first element having maximum |Re(.)| + |Im(.)| value + using alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the `offsetX` parameter supports indexing semantics based on a @@ -59,14 +59,14 @@ N: integer Number of indexed elements. - zx: Complex128Array + x: Complex128Array Input array. strideX: integer - Index increment for `zx`. + Index increment for `x`. offsetX: integer - Starting index of `zx`. + Starting index of `x`. Returns ------- @@ -76,14 +76,14 @@ Examples -------- // Standard Usage: - > var zx; - > zx = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); - > var idx = {{alias}}.ndarray( zx.length, zx, 1, 0 ) + > var x; + > x = new {{alias:@stdlib/array/complex128}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0 ] ); + > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 1 // Using an index offset: - > zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); - > idx = {{alias}}.ndarray( 2, zx, 1, 1 ) + > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + > idx = {{alias}}.ndarray( 2, x, 1, 1 ) 1 See Also diff --git a/lib/node_modules/@stdlib/blas/base/izamax/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/izamax/docs/types/index.d.ts index 88f27a0114e6..56f84a6239c2 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/izamax/docs/types/index.d.ts @@ -30,62 +30,62 @@ interface Routine { * Finds the index of the first element having the maximum absolute value. * * @param N - number of indexed elements - * @param zx - input array - * @param strideX - stride length for `zx` + * @param x - input array + * @param strideX - stride length for `x` * @returns index value * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * - * var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + * var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); * - * var idx = izamax( zx.length, zx, 1 ); + * var idx = izamax( x.length, x, 1 ); * // returns 1 */ - ( N: number, zx: Complex128Array, strideX: number ): number; + ( N: number, x: Complex128Array, strideX: number ): number; /** * Finds the index of the first element having the maximum absolute value using alternative indexing semantics. * * @param N - number of indexed elements - * @param zx - input array - * @param strideX - stride length for `zx` - * @param offsetX - starting index for `zx` + * @param x - input array + * @param strideX - stride length for `x` + * @param offsetX - starting index for `x` * @returns index value * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * - * var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + * var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); * - * var idx = izamax.ndarray( zx.length, zx, 1, 0 ); + * var idx = izamax.ndarray( x.length, x, 1, 0 ); * // returns 1 */ - ndarray( N: number, zx: Complex128Array, strideX: number, offsetX: number ): number; + ndarray( N: number, x: Complex128Array, strideX: number, offsetX: number ): number; } /** * Finds the index of the first element having the maximum absolute value. * * @param N - number of indexed elements -* @param zx - input array -* @param strideX - stride length for `zx` +* @param x - input array +* @param strideX - stride length for `x` * @returns index value * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); * -* var idx = izamax( zx.length, zx, 1 ); +* var idx = izamax( x.length, x, 1 ); * // returns 1 * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); * -* var idx = izamax.ndarray( zx.length, zx, 1, 0 ); +* var idx = izamax.ndarray( x.length, x, 1, 0 ); * // returns 1 */ declare var izamax: Routine; diff --git a/lib/node_modules/@stdlib/blas/base/izamax/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/izamax/docs/types/test.ts index 21eef7e322e3..76d4f66f7a41 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/izamax/docs/types/test.ts @@ -24,135 +24,135 @@ import izamax = require( './index' ); // The function returns a number... { - const zx = new Complex128Array( 10 ); + const x = new Complex128Array( 10 ); - izamax( zx.length, zx, 1 ); // $ExpectType number + izamax( 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 zx = new Complex128Array( 10 ); - - izamax( '10', zx, 1 ); // $ExpectError - izamax( true, zx, 1 ); // $ExpectError - izamax( false, zx, 1 ); // $ExpectError - izamax( null, zx, 1 ); // $ExpectError - izamax( undefined, zx, 1 ); // $ExpectError - izamax( [], zx, 1 ); // $ExpectError - izamax( {}, zx, 1 ); // $ExpectError - izamax( ( x: number ): number => x, zx, 1 ); // $ExpectError + const x = new Complex128Array( 10 ); + + izamax( '10', x, 1 ); // $ExpectError + izamax( true, x, 1 ); // $ExpectError + izamax( false, x, 1 ); // $ExpectError + izamax( null, x, 1 ); // $ExpectError + izamax( undefined, x, 1 ); // $ExpectError + izamax( [], x, 1 ); // $ExpectError + izamax( {}, x, 1 ); // $ExpectError + izamax( ( 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 zx = new Complex128Array( 10 ); - - izamax( zx.length, 10, 1 ); // $ExpectError - izamax( zx.length, '10', 1 ); // $ExpectError - izamax( zx.length, true, 1 ); // $ExpectError - izamax( zx.length, false, 1 ); // $ExpectError - izamax( zx.length, null, 1 ); // $ExpectError - izamax( zx.length, undefined, 1 ); // $ExpectError - izamax( zx.length, [], 1 ); // $ExpectError - izamax( zx.length, {}, 1 ); // $ExpectError - izamax( zx.length, ( zx: number ): number => zx, 1 ); // $ExpectError + const x = new Complex128Array( 10 ); + + izamax( x.length, 10, 1 ); // $ExpectError + izamax( x.length, '10', 1 ); // $ExpectError + izamax( x.length, true, 1 ); // $ExpectError + izamax( x.length, false, 1 ); // $ExpectError + izamax( x.length, null, 1 ); // $ExpectError + izamax( x.length, undefined, 1 ); // $ExpectError + izamax( x.length, [], 1 ); // $ExpectError + izamax( x.length, {}, 1 ); // $ExpectError + izamax( 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 zx = new Complex128Array( 10 ); - - izamax( zx.length, zx, '10' ); // $ExpectError - izamax( zx.length, zx, true ); // $ExpectError - izamax( zx.length, zx, false ); // $ExpectError - izamax( zx.length, zx, null ); // $ExpectError - izamax( zx.length, zx, undefined ); // $ExpectError - izamax( zx.length, zx, [] ); // $ExpectError - izamax( zx.length, zx, {} ); // $ExpectError - izamax( zx.length, zx, ( zx: number ): number => zx ); // $ExpectError + const x = new Complex128Array( 10 ); + + izamax( x.length, x, '10' ); // $ExpectError + izamax( x.length, x, true ); // $ExpectError + izamax( x.length, x, false ); // $ExpectError + izamax( x.length, x, null ); // $ExpectError + izamax( x.length, x, undefined ); // $ExpectError + izamax( x.length, x, [] ); // $ExpectError + izamax( x.length, x, {} ); // $ExpectError + izamax( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { - const zx = new Complex128Array( 10 ); + const x = new Complex128Array( 10 ); izamax(); // $ExpectError - izamax( zx.length ); // $ExpectError - izamax( zx.length, zx ); // $ExpectError - izamax( zx.length, zx, 1, 10 ); // $ExpectError + izamax( x.length ); // $ExpectError + izamax( x.length, x ); // $ExpectError + izamax( x.length, x, 1, 10 ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... { - const zx = new Complex128Array( 10 ); + const x = new Complex128Array( 10 ); - izamax.ndarray( zx.length, zx, 1, 0 ); // $ExpectType number + izamax.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 zx = new Complex128Array( 10 ); - - izamax.ndarray( '10', zx, 1, 0 ); // $ExpectError - izamax.ndarray( true, zx, 1, 0 ); // $ExpectError - izamax.ndarray( false, zx, 1, 0 ); // $ExpectError - izamax.ndarray( null, zx, 1, 0 ); // $ExpectError - izamax.ndarray( undefined, zx, 1, 0 ); // $ExpectError - izamax.ndarray( [], zx, 1, 0 ); // $ExpectError - izamax.ndarray( {}, zx, 1, 0 ); // $ExpectError - izamax.ndarray( ( zx: number ): number => zx, zx, 1, 0 ); // $ExpectError + const x = new Complex128Array( 10 ); + + izamax.ndarray( '10', x, 1, 0 ); // $ExpectError + izamax.ndarray( true, x, 1, 0 ); // $ExpectError + izamax.ndarray( false, x, 1, 0 ); // $ExpectError + izamax.ndarray( null, x, 1, 0 ); // $ExpectError + izamax.ndarray( undefined, x, 1, 0 ); // $ExpectError + izamax.ndarray( [], x, 1, 0 ); // $ExpectError + izamax.ndarray( {}, x, 1, 0 ); // $ExpectError + izamax.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 zx = new Complex128Array( 10 ); - - izamax.ndarray( zx.length, 10, 1, 0 ); // $ExpectError - izamax.ndarray( zx.length, '10', 1, 0 ); // $ExpectError - izamax.ndarray( zx.length, true, 1, 0 ); // $ExpectError - izamax.ndarray( zx.length, false, 1, 0 ); // $ExpectError - izamax.ndarray( zx.length, null, 1, 0 ); // $ExpectError - izamax.ndarray( zx.length, undefined, 1, 0 ); // $ExpectError - izamax.ndarray( zx.length, [], 1, 0 ); // $ExpectError - izamax.ndarray( zx.length, {}, 1, 0 ); // $ExpectError - izamax.ndarray( zx.length, ( zx: number ): number => zx, 1, 0 ); // $ExpectError + const x = new Complex128Array( 10 ); + + izamax.ndarray( x.length, 10, 1, 0 ); // $ExpectError + izamax.ndarray( x.length, '10', 1, 0 ); // $ExpectError + izamax.ndarray( x.length, true, 1, 0 ); // $ExpectError + izamax.ndarray( x.length, false, 1, 0 ); // $ExpectError + izamax.ndarray( x.length, null, 1, 0 ); // $ExpectError + izamax.ndarray( x.length, undefined, 1, 0 ); // $ExpectError + izamax.ndarray( x.length, [], 1, 0 ); // $ExpectError + izamax.ndarray( x.length, {}, 1, 0 ); // $ExpectError + izamax.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 zx = new Complex128Array( 10 ); - - izamax.ndarray( zx.length, zx, '10', 0 ); // $ExpectError - izamax.ndarray( zx.length, zx, true, 0 ); // $ExpectError - izamax.ndarray( zx.length, zx, false, 0 ); // $ExpectError - izamax.ndarray( zx.length, zx, null, 0 ); // $ExpectError - izamax.ndarray( zx.length, zx, undefined, 0 ); // $ExpectError - izamax.ndarray( zx.length, zx, [], 0 ); // $ExpectError - izamax.ndarray( zx.length, zx, {}, 0 ); // $ExpectError - izamax.ndarray( zx.length, zx, ( zx: number ): number => zx, 0 ); // $ExpectError + const x = new Complex128Array( 10 ); + + izamax.ndarray( x.length, x, '10', 0 ); // $ExpectError + izamax.ndarray( x.length, x, true, 0 ); // $ExpectError + izamax.ndarray( x.length, x, false, 0 ); // $ExpectError + izamax.ndarray( x.length, x, null, 0 ); // $ExpectError + izamax.ndarray( x.length, x, undefined, 0 ); // $ExpectError + izamax.ndarray( x.length, x, [], 0 ); // $ExpectError + izamax.ndarray( x.length, x, {}, 0 ); // $ExpectError + izamax.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 zx = new Complex128Array( 10 ); - - izamax.ndarray( zx.length, zx, 1, '10' ); // $ExpectError - izamax.ndarray( zx.length, zx, 1, true ); // $ExpectError - izamax.ndarray( zx.length, zx, 1, false ); // $ExpectError - izamax.ndarray( zx.length, zx, 1, null ); // $ExpectError - izamax.ndarray( zx.length, zx, 1, undefined ); // $ExpectError - izamax.ndarray( zx.length, zx, 1, [] ); // $ExpectError - izamax.ndarray( zx.length, zx, 1, {} ); // $ExpectError - izamax.ndarray( zx.length, zx, 1, ( zx: number ): number => zx ); // $ExpectError + const x = new Complex128Array( 10 ); + + izamax.ndarray( x.length, x, 1, '10' ); // $ExpectError + izamax.ndarray( x.length, x, 1, true ); // $ExpectError + izamax.ndarray( x.length, x, 1, false ); // $ExpectError + izamax.ndarray( x.length, x, 1, null ); // $ExpectError + izamax.ndarray( x.length, x, 1, undefined ); // $ExpectError + izamax.ndarray( x.length, x, 1, [] ); // $ExpectError + izamax.ndarray( x.length, x, 1, {} ); // $ExpectError + izamax.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 zx = new Complex128Array( 10 ); + const x = new Complex128Array( 10 ); izamax.ndarray(); // $ExpectError - izamax.ndarray( zx.length ); // $ExpectError - izamax.ndarray( zx.length, zx ); // $ExpectError - izamax.ndarray( zx.length, zx, 1 ); // $ExpectError - izamax.ndarray( zx.length, zx, 1, 0, 10 ); // $ExpectError + izamax.ndarray( x.length ); // $ExpectError + izamax.ndarray( x.length, x ); // $ExpectError + izamax.ndarray( x.length, x, 1 ); // $ExpectError + izamax.ndarray( x.length, x, 1, 0, 10 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/base/izamax/examples/index.js b/lib/node_modules/@stdlib/blas/base/izamax/examples/index.js index fd5ac991af33..df409cc6226f 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/examples/index.js @@ -21,15 +21,18 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var izamax = require( '@stdlib/blas/base/izamax' ); +var izamax = require( './../lib' ); function rand() { return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); } // Generate random input arrays: -var zx = filledarrayBy( 10, 'complex128', rand ); -console.log( zx.toString() ); +var x = filledarrayBy( 10, 'complex128', rand ); +console.log( x.toString() ); -var idx = izamax( zx.length, zx, 1 ); +var idx = izamax( x.length, x, 1 ); +console.log( idx ); + +idx = izamax.ndarray( x.length, x, 1, 0 ); console.log( idx ); diff --git a/lib/node_modules/@stdlib/blas/base/izamax/lib/index.js b/lib/node_modules/@stdlib/blas/base/izamax/lib/index.js index 6d8255423cd7..1b60757e5c4e 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 1 routine to find the index of the first element having the maximum absolute value. +* BLAS level 1 routine to find the index of the first element having maximum |Re(.)| + |Im(.)|. * * @module @stdlib/blas/base/izamax * @@ -27,18 +27,18 @@ * var Complex128Array = require( '@stdlib/array/complex128' ); * var izamax = require( '@stdlib/blas/base/izamax' ); * -* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); * -* var idx = izamax( zx.length, zx, 1 ); +* var idx = izamax( x.length, x, 1 ); * // returns 1 * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * var izamax = require( '@stdlib/blas/base/izamax' ); * -* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); * -* var idx = izamax.ndarray( zx.length, zx, 1, 0 ); +* var idx = izamax.ndarray( x.length, x, 1, 0 ); * // returns 1 */ diff --git a/lib/node_modules/@stdlib/blas/base/izamax/lib/izamax.js b/lib/node_modules/@stdlib/blas/base/izamax/lib/izamax.js index f03ffe6cbd65..536bdf898877 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/lib/izamax.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/lib/izamax.js @@ -30,21 +30,21 @@ var ndarray = require( './ndarray.js' ); * Finds the index of the first element having the maximum absolute value. * * @param {PositiveInteger} N - number of indexed elements -* @param {Complex128Array} zx - input array -* @param {integer} strideX - `zx` stride length +* @param {Complex128Array} x - input array +* @param {integer} strideX - `x` stride length * @returns {integer} index value * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); * -* var idx = izamax( zx.length, zx, 1 ); +* var idx = izamax( x.length, x, 1 ); * // returns 1 */ -function izamax( N, zx, strideX ) { +function izamax( N, x, strideX ) { var ox = stride2offset( N, strideX ); - return ndarray( N, zx, strideX, ox ); + return ndarray( N, x, strideX, ox ); } diff --git a/lib/node_modules/@stdlib/blas/base/izamax/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/izamax/lib/ndarray.js index 38b9cb09050a..2d1980012bd5 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/lib/ndarray.js @@ -29,21 +29,21 @@ var dcabs1 = require( '@stdlib/blas/base/dcabs1' ); * Finds the index of the first element having the maximum absolute value. * * @param {PositiveInteger} N - number of indexed elements -* @param {Complex128Array} zx - input array -* @param {integer} strideX - `zx` stride length -* @param {NonNegativeInteger} offsetX - starting index for `zx` +* @param {Complex128Array} x - input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` * @returns {integer} index value * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var zx = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* var x = new Complex128Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); * -* var idx = izamax( zx.length, zx, 1, 0 ); +* var idx = izamax( x.length, x, 1, 0 ); * // returns 1 */ -function izamax( N, zx, strideX, offsetX ) { - var zmax; +function izamax( N, x, strideX, offsetX ) { + var max; var idx; var ix; var v; @@ -56,13 +56,13 @@ function izamax( N, zx, strideX, offsetX ) { if ( N === 1 ) { return idx; } - zmax = dcabs1( zx.get( offsetX ) ); + max = dcabs1( x.get( offsetX ) ); ix = offsetX + strideX; for ( i = 1; i < N; i++ ) { - v = dcabs1( zx.get( ix ) ); - if ( v > zmax ) { + v = dcabs1( x.get( ix ) ); + if ( v > max ) { idx = i; - zmax = v; + max = v; } ix += strideX; } diff --git a/lib/node_modules/@stdlib/blas/base/izamax/package.json b/lib/node_modules/@stdlib/blas/base/izamax/package.json index 03b09daef463..f0a5e24abbd6 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/package.json +++ b/lib/node_modules/@stdlib/blas/base/izamax/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/izamax", "version": "0.0.0", - "description": "Find the index of the first element having the maximum absolute value.", + "description": "Find the index of the first element having maximum |Re(.)| + |Im(.)|", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.js b/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.js index 3213d525a57f..ac7f9e6b7dd0 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.js @@ -44,14 +44,14 @@ tape( 'the function finds the index of the element with the maximum absolute val var x; x = new Complex128Array([ - 0.1, // 1 - -0.3, // 1 - 0.5, // 2 - -0.1, // 2 - -0.2, // 3 - 0.6, // 3 - -0.4, // 4 - 0.9 // 4 + 0.1, // 0 + -0.3, // 0 + 0.5, // 1 + -0.1, // 1 + -0.2, // 2 + 0.6, // 2 + -0.4, // 3 + 0.9 // 3 ]); expected = 3; @@ -59,10 +59,10 @@ tape( 'the function finds the index of the element with the maximum absolute val t.strictEqual( idx, expected, 'returns expected value' ); x = new Complex128Array([ - 0.2, // 1 - -0.6, // 1 - 0.3, // 2 - 0.6, // 2 + 0.2, // 0 + -0.6, // 0 + 0.3, // 1 + 0.6, // 1 5.0, 5.0 ]); @@ -118,12 +118,12 @@ tape( 'the function supports specifying a stride', function test( t ) { var x; x = new Complex128Array([ - 0.1, // 1 - 4.0, // 1 + 0.1, // 0 + 4.0, // 0 -0.3, 6.0, - -0.5, // 2 - 7.0, // 2 + -0.5, // 1 + 7.0, // 1 -0.1, 3.0 ]); diff --git a/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.js index c424362c59d7..0d41fdecfb97 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.js @@ -44,14 +44,14 @@ tape( 'the function finds the index of the element with the maximum absolute val var x; x = new Complex128Array([ - 0.1, // 1 - -0.3, // 1 - 0.5, // 2 - -0.1, // 2 - -0.2, // 3 - 0.6, // 3 - -0.4, // 4 - 0.9 // 4 + 0.1, // 0 + -0.3, // 0 + 0.5, // 1 + -0.1, // 1 + -0.2, // 2 + 0.6, // 2 + -0.4, // 3 + 0.9 // 3 ]); expected = 3; @@ -59,10 +59,10 @@ tape( 'the function finds the index of the element with the maximum absolute val t.strictEqual( idx, expected, 'returns expected value' ); x = new Complex128Array([ - 0.2, // 1 - -0.6, // 1 - 0.3, // 2 - 0.6, // 2 + 0.2, // 0 + -0.6, // 0 + 0.3, // 1 + 0.6, // 1 5.0, 5.0 ]); @@ -138,12 +138,12 @@ tape( 'the function supports specifying a stride', function test( t ) { var x; x = new Complex128Array([ - 0.1, // 1 - 4.0, // 1 + 0.1, // 0 + 4.0, // 0 -0.3, 6.0, - -0.5, // 2 - 7.0, // 2 + -0.5, // 1 + 7.0, // 1 -0.1, 3.0 ]); From 291c158bc09f4132dafac84520469df42fe53418 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Mon, 16 Mar 2026 00:17:32 +0530 Subject: [PATCH 4/6] feat: add c and fortran implementation --- 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: missing_dependencies - task: lint_c_examples status: missing_dependencies - 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/izamax/README.md | 2 +- .../blas/base/izamax/benchmark/benchmark.js | 5 +- .../base/izamax/benchmark/benchmark.native.js | 110 ++++ .../izamax/benchmark/benchmark.ndarray.js | 5 +- .../benchmark/benchmark.ndarray.native.js | 110 ++++ .../@stdlib/blas/base/izamax/binding.gyp | 265 ++++++++++ .../blas/base/izamax/docs/types/index.d.ts | 2 +- .../blas/base/izamax/docs/types/test.ts | 2 +- .../blas/base/izamax/examples/c/Makefile | 146 ++++++ .../blas/base/izamax/examples/c/example.c | 43 ++ .../blas/base/izamax/examples/index.js | 2 +- .../@stdlib/blas/base/izamax/include.gypi | 70 +++ .../izamax/include/stdlib/blas/base/izamax.h | 48 ++ .../include/stdlib/blas/base/izamax_cblas.h | 43 ++ .../include/stdlib/blas/base/izamax_fortran.h | 41 ++ .../@stdlib/blas/base/izamax/lib/index.js | 2 +- .../@stdlib/blas/base/izamax/lib/izamax.js | 4 +- .../blas/base/izamax/lib/izamax.native.js | 53 ++ .../@stdlib/blas/base/izamax/lib/main.js | 2 +- .../@stdlib/blas/base/izamax/lib/native.js | 35 ++ .../@stdlib/blas/base/izamax/lib/ndarray.js | 4 +- .../blas/base/izamax/lib/ndarray.native.js | 54 ++ .../@stdlib/blas/base/izamax/manifest.json | 476 ++++++++++++++++++ .../@stdlib/blas/base/izamax/package.json | 5 +- .../@stdlib/blas/base/izamax/src/Makefile | 70 +++ .../@stdlib/blas/base/izamax/src/addon.c | 67 +++ .../@stdlib/blas/base/izamax/src/izamax.c | 34 ++ .../@stdlib/blas/base/izamax/src/izamax.f | 108 ++++ .../blas/base/izamax/src/izamax_cblas.c | 91 ++++ .../@stdlib/blas/base/izamax/src/izamax_f.c | 97 ++++ .../blas/base/izamax/src/izamax_ndarray.c | 61 +++ .../@stdlib/blas/base/izamax/src/izamaxsub.f | 46 ++ .../blas/base/izamax/test/test.izamax.js | 2 +- .../base/izamax/test/test.izamax.native.js | 191 +++++++ .../blas/base/izamax/test/test.ndarray.js | 42 +- .../base/izamax/test/test.ndarray.native.js | 212 ++++++++ 36 files changed, 2513 insertions(+), 37 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/include/stdlib/blas/base/izamax.h create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/include/stdlib/blas/base/izamax_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/include/stdlib/blas/base/izamax_fortran.h create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/lib/izamax.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/src/izamax.c create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/src/izamax.f create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/src/izamax_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/src/izamax_f.c create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/src/izamax_ndarray.c create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/src/izamaxsub.f create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.native.js diff --git a/lib/node_modules/@stdlib/blas/base/izamax/README.md b/lib/node_modules/@stdlib/blas/base/izamax/README.md index dac84f4d1f4e..dffa3d5b1b38 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/README.md +++ b/lib/node_modules/@stdlib/blas/base/izamax/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. diff --git a/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.js index 8ef43e210efd..20bc44441823 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/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. @@ -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 izamax = require( './../lib/izamax.js' ); @@ -98,7 +99,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':len='+len, f ); + bench( format( '%s:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.native.js new file mode 100644 index 000000000000..e9f471fd131c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var format = require( '@stdlib/string/format' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var izamax = tryRequire( resolve( __dirname, './../lib/izamax.native.js' ) ); +var opts = { + 'skip': ( izamax instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Create a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var 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 idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = izamax( x.length, x, 1 ); + if ( isnanf( idx ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( idx ) ) { + 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( format( '%s::native:len=%d', pkg, len ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.ndarray.js index 42ed0a56fc30..7f240d236021 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/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. @@ -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 izamax = require( './../lib/ndarray.js' ); @@ -98,7 +99,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':ndarray:len='+len, f ); + bench( format( '%s:ndarray:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/izamax/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..566ec2555e11 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +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; + + +// VARIABLES // + +var izamax = tryRequire( resolve( __dirname, './../lib/izamax.native.js' ) ); +var opts = { + 'skip': ( izamax instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Create a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var 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 idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = izamax( x.length, x, 1, 0 ); + if ( isnanf( idx ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( idx ) ) { + 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( format( '%s::native:ndarray:len=%d', pkg, len ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/izamax/binding.gyp b/lib/node_modules/@stdlib/blas/base/izamax/binding.gyp new file mode 100644 index 000000000000..60dce9d0b31a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/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/izamax/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/izamax/docs/types/index.d.ts index 56f84a6239c2..67c74068b030 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/izamax/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/izamax/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/izamax/docs/types/test.ts index 76d4f66f7a41..8dd23880556a 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/izamax/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/izamax/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/izamax/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/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/izamax/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/izamax/examples/c/example.c new file mode 100644 index 000000000000..398d954206b9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/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/izamax.h" +#include + +int main( void ) { + // Create strided array: + 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 = 8; + + // Specify stride: + const int strideX = 1; + + // Compute the index of the maximum absolute value: + int idx = c_izamax( N, (void *)x, strideX ); + + // Print the result: + printf( "index value: %d\n", idx ); + + // Compute the index of the maximum absolute value: + idx = c_izamax_ndarray( N, (void *)x, -strideX, N-1 ); + + // Print the result: + printf( "index value: %d\n", idx ); +} diff --git a/lib/node_modules/@stdlib/blas/base/izamax/examples/index.js b/lib/node_modules/@stdlib/blas/base/izamax/examples/index.js index df409cc6226f..faf457cc79e7 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/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/izamax/include.gypi b/lib/node_modules/@stdlib/blas/base/izamax/include.gypi new file mode 100644 index 000000000000..dcb556d250e8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/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 ); + + // TODO: revisit once we support 64-bit integers as return values and 64 integers more generally in JavaScript + STDLIB_NAPI_CREATE_INT32( env, API_SUFFIX(c_izamax)( N, X, strideX ), idx ); + + return idx; +} + +/** +* 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 ); + + // TODO: revisit once we support 64-bit integers as return values and 64 integers more generally in JavaScript + STDLIB_NAPI_CREATE_INT32( env, API_SUFFIX(c_izamax_ndarray)( N, X, strideX, offsetX ), idx ); + + return idx; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/base/izamax/src/izamax.c b/lib/node_modules/@stdlib/blas/base/izamax/src/izamax.c new file mode 100644 index 000000000000..8ac07205c530 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/src/izamax.c @@ -0,0 +1,34 @@ +/** +* @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/izamax.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" + +/** +* Finds the index of the first element having maximum |Re(.)| + |Im(.)|. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @return index value +*/ +CBLAS_INT API_SUFFIX(c_izamax)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX ) { + CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + return API_SUFFIX(c_izamax_ndarray)( N, X, strideX, ox ); +} diff --git a/lib/node_modules/@stdlib/blas/base/izamax/src/izamax.f b/lib/node_modules/@stdlib/blas/base/izamax/src/izamax.f new file mode 100644 index 000000000000..453a6db8962f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/src/izamax.f @@ -0,0 +1,108 @@ +!> +! @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. +!< + +!> Finds the index of the first element having maximum |Re(.)| + |Im(.)|. +! +! ## Notes +! +! * Modified version of reference BLAS level1 routine (version 3.7.0). Updated to "free form" Fortran 95. +! +! ## Authors +! +! * Univ. of Tennessee +! * Univ. of California Berkeley +! * Univ. of Colorado Denver +! * NAG Ltd. +! +! ## History +! +! * Jack Dongarra, linpack, 3/11/78. +! +! - modified 3/93 to return if incx .le. 0. +! - modified 12/3/93, array(1) declarations changed to array(*) +! +! ## License +! +! From : +! +! > The reference BLAS is a freely-available software package. It is available from netlib via anonymous ftp and the World Wide Web. Thus, it can be included in commercial software packages (and has been). We only ask that proper credit be given to the authors. +! > +! > Like all software, it is copyrighted. It is not trademarked, but we do ask the following: +! > +! > * If you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original. +! > +! > * We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support. +! +! @param {integer} N - number of indexed elements +! @param {Array} cx - input array +! @param {integer} strideX - `cx` stride length +! @returns {integer} index value +!< +integer function izamax( N, cx, strideX ) + implicit none + ! .. + ! Scalar arguments: + integer :: strideX, N + ! .. + ! Array arguments: + complex(kind=kind(0.0d0)) :: cx(*) + ! .. + ! Local scalars: + double precision :: smax + integer :: i, ix + ! .. + ! Intrinsic functions: + intrinsic abs, real, aimag + ! .. + izamax = 0 + if ( N < 1 .OR. strideX <= 0 ) then + return + end if + izamax = 1 + ! .. + if ( N == 1 ) then + return + end if + ! .. + if ( strideX == 1 ) then + ! .. + ! Code for increment equal to `1`... + smax = abs( real( cx( 1 ) ) ) + abs( aimag( cx( 1 ) ) ) + do i = 2, N + if ( ( abs( real( cx( i ) ) ) + abs( aimag( cx( i ) ) ) ) > smax ) then + izamax = i + smax = abs( real( cx( i ) ) ) + abs( aimag( cx( i ) ) ) + end if + end do + return + else + ! .. + ! Code for increment not equal to `1`... + ix = 1 + smax = abs( real( cx( 1 ) ) ) + abs( aimag( cx( 1 ) ) ) + do i = 2, N + ix = ix + strideX + if ( ( abs( real( cx( ix ) ) ) + abs( aimag( cx( ix ) ) ) ) > smax ) then + izamax = i + smax = abs( real( cx( ix ) ) ) + abs( aimag( cx( ix ) ) ) + end if + end do + return + end if + return +end function izamax \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/izamax/src/izamax_cblas.c b/lib/node_modules/@stdlib/blas/base/izamax/src/izamax_cblas.c new file mode 100644 index 000000000000..407a861bb8e1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/src/izamax_cblas.c @@ -0,0 +1,91 @@ +/** +* @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/izamax.h" +#include "stdlib/blas/base/izamax_cblas.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/zcopy.h" +#include "stdlib/blas/base/xerbla.h" +#include "stdlib/strided/base/min_view_buffer_index.h" +#include + +/** +* Finds the index of the first element having maximum |Re(.)| + |Im(.)|. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @return index value +*/ +CBLAS_INT API_SUFFIX(c_izamax)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX ) { + CBLAS_INT idx; + double *copyX; + + if ( strideX < 0 ) { + // Allocate memory for a temporary workspace: + copyX = (double *)malloc( N * 2 * sizeof(double) ); + if ( copyX == NULL ) { + API_SUFFIX(c_xerbla)( 1, "izamax", "Memory allocation failed when copying the input array to a temporary workspace.\n" ); + } + // Copy the input array to a temporary workspace: + API_SUFFIX(c_zcopy)( N, X, strideX, copyX, 1 ); + + // Perform operation: + idx = API_SUFFIX(cblas_izamax)( N, copyX, 1 ); + + // Free allocated memory: + free( copyX ); + + return idx; + } + return API_SUFFIX(cblas_izamax)( N, X, strideX ); +} + +/** +* Finds the index of the first element having maximum |Re(.)| + |Im(.)| 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 index value +*/ +CBLAS_INT API_SUFFIX(c_izamax_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + CBLAS_INT idx; + double *copyX; + + if ( strideX < 0 ) { + // Allocate memory for a temporary workspace: + copyX = (double *)malloc( N * 2 * sizeof(double) ); + if ( copyX == NULL ) { + API_SUFFIX(c_xerbla)( 1, "izamax", "Memory allocation failed when copying the input array to a temporary workspace.\n" ); + } + // Copy values to a temporary workspace: + API_SUFFIX(c_zcopy_ndarray)( N, X, strideX, offsetX, copyX, 1, 0 ); + + // Perform operation: + idx = API_SUFFIX(cblas_izamax)( N, copyX, 1 ); + + // Free allocated memory: + free( copyX ); + + return idx; + } + X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer + return API_SUFFIX(cblas_izamax)( N, X, strideX ); +} diff --git a/lib/node_modules/@stdlib/blas/base/izamax/src/izamax_f.c b/lib/node_modules/@stdlib/blas/base/izamax/src/izamax_f.c new file mode 100644 index 000000000000..288bd5550b6e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/src/izamax_f.c @@ -0,0 +1,97 @@ +/** +* @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/izamax.h" +#include "stdlib/blas/base/izamax_fortran.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/xerbla.h" +#include "stdlib/blas/base/zcopy.h" +#include "stdlib/strided/base/min_view_buffer_index.h" +#include + +/** +* Finds the index of the first element having maximum |Re(.)| + |Im(.)|. +* +* @param N number of indexed elements +* @param X input array +* @param strideX X stride length +* @return index value +*/ +CBLAS_INT API_SUFFIX(c_izamax)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX ) { + CBLAS_INT idx; + CBLAS_INT sx; + double *copyX; + + if ( strideX < 0 ) { + // Allocate memory for a temporary workspace: + copyX = (double *)malloc( N * 2 * sizeof(double) ); + if ( copyX == NULL ) { + API_SUFFIX(c_xerbla)( 1, "izamax", "Memory allocation failed when copying the input array to a temporary workspace.\n" ); + } + // Copy the input array to a temporary workspace: + API_SUFFIX(c_zcopy)( N, X, strideX, copyX, 1 ); + + // Perform operation: + sx = 1; + izamaxsub( &N, copyX, &sx, &idx ); + + // Free allocated memory: + free( copyX ); + + return idx - 1; + } + izamaxsub( &N, X, &strideX, &idx ); + return idx - 1; +} + +/** +* Finds the index of the first element having maximum |Re(.)| + |Im(.)| 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 index value +*/ +CBLAS_INT API_SUFFIX(c_izamax_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + CBLAS_INT idx; + CBLAS_INT sx; + double *copyX; + + if ( strideX < 0 ) { + // Allocate memory for a temporary workspace: + copyX = (double *)malloc( N * 2 * sizeof(double) ); + if ( copyX == NULL ) { + API_SUFFIX(c_xerbla)( 1, "izamax", "Memory allocation failed when copying the input array to a temporary workspace.\n" ); + } + // Copy the input array to a temporary workspace: + API_SUFFIX(c_zcopy_ndarray)( N, X, strideX, offsetX, copyX, 1, 0 ); + + // Perform operation: + sx = 1; + izamaxsub( &N, copyX, &sx, &idx ); + + // Free allocated memory: + free( copyX ); + + return idx - 1; + } + X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer + izamaxsub( &N, X, &strideX, &idx ); + return idx - 1; +} diff --git a/lib/node_modules/@stdlib/blas/base/izamax/src/izamax_ndarray.c b/lib/node_modules/@stdlib/blas/base/izamax/src/izamax_ndarray.c new file mode 100644 index 000000000000..7420d45cfa13 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/src/izamax_ndarray.c @@ -0,0 +1,61 @@ +/** +* @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/izamax.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/math/base/special/abs.h" + +/** +* Finds the index of the first element having maximum |Re(.)| + |Im(.)| 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 index value +*/ +CBLAS_INT API_SUFFIX(c_izamax_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + const double *x = (const double *)X; + CBLAS_INT idx; + CBLAS_INT sx; + CBLAS_INT ix; + CBLAS_INT i; + double smax; + double v; + + if ( N < 1 ) { + return -1; + } + idx = 0; + if ( N == 1 ) { + return idx; + } + sx = strideX * 2; + ix = offsetX * 2; + smax = stdlib_base_abs( x[ ix ] ) + stdlib_base_abs( x[ ix+1 ] ); + ix += sx; + for ( i = 1; i < N; i++ ) { + v = stdlib_base_abs( x[ ix ] ) + stdlib_base_abs( x[ ix+1 ] ); + if ( v > smax ) { + idx = i; + smax = v; + } + ix += sx; + } + return idx; +} diff --git a/lib/node_modules/@stdlib/blas/base/izamax/src/izamaxsub.f b/lib/node_modules/@stdlib/blas/base/izamax/src/izamaxsub.f new file mode 100644 index 000000000000..7874c26ccc28 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/src/izamaxsub.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 `izamax` as a subroutine. +! +! @param {integer} N - number of indexed elements +! @param {Array} cx - input array +! @param {integer} strideX - stride length +! @param {integer} idx - output variable reference +!< +subroutine izamaxsub( N, cx, strideX, idx ) + implicit none + ! .. + ! External functions: + interface + integer function izamax( N, cx, strideX ) + complex(kind=kind(0.0d0)) :: cx(*) + integer :: strideX, N + end function izamax + end interface + ! .. + ! Scalar arguments: + integer :: strideX, N, idx + ! .. + ! Array arguments: + complex(kind=kind(0.0d0)) :: cx(*) + ! .. + ! Find the maximum absolute value: + idx = izamax( N, cx, strideX ) + return +end subroutine izamaxsub \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.js b/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.js index ac7f9e6b7dd0..5bc4d930bf5e 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.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/izamax/test/test.izamax.native.js b/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.native.js new file mode 100644 index 000000000000..f526b63e4aa5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/test/test.izamax.native.js @@ -0,0 +1,191 @@ +/** +* @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 izamax = tryRequire( resolve( __dirname, './../lib/izamax.native.js' ) ); +var opts = { + 'skip': ( izamax instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof izamax, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 3', opts, function test( t ) { + t.strictEqual( izamax.length, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the function finds the index of the element with the maximum |Re(.)| + |Im(.)|', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 0.1, // 0 + -0.3, // 0 + 0.5, // 1 + -0.1, // 1 + -0.2, // 2 + 0.6, // 2 + -0.4, // 3 + 0.9 // 3 + ]); + expected = 3; + + idx = izamax( 4, x, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + x = new Complex128Array([ + 0.2, // 0 + -0.6, // 0 + 0.3, // 1 + 0.6, // 1 + 5.0, + 5.0 + ]); + expected = 1; + + idx = izamax( 2, x, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than `1`, the function returns `-1`', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, + 4.0 + ]); + expected = -1; + + idx = izamax( 0, x, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, + 4.0 + ]); + expected = 0; + + idx = izamax( 1, x, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 0.1, // 0 + 4.0, // 0 + -0.3, + 6.0, + -0.5, // 1 + 7.0, // 1 + -0.1, + 3.0 + ]); + expected = 1; + + idx = izamax( 2, x, 2 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] ); + expected = 1; + + idx = izamax( 3, x, -1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + // eslint-disable-next-line max-len + x = new Complex128Array( [ 0.1, 4.0, 999.0, 999.0, -0.3, 6.0, 999.0, 999.0, -0.5, 7.0, 999.0, 999.0, -0.1, 3.0 ] ); + expected = 1; + + idx = izamax( 4, x, -2 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var expected; + var idx; + var x0; + var x1; + + x0 = new Complex128Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, // 1 + 6.0, // 1 + 7.0, // 2 + 8.0 // 2 + ]); + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + expected = 2; + + idx = izamax( 3, x1, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.js index 0d41fdecfb97..91f0f636ac45 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/izamax/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. @@ -112,26 +112,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun t.end(); }); -tape( 'the function supports accessing elements in reverse order', function test( t ) { - var idx; - var x; - - x = new Complex128Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] ); - - idx = izamax( x.length, x, -1, x.length-1 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = izamax( 2, x, -1, x.length-2 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - // eslint-disable-next-line max-len - x = new Complex128Array( [ 0.1, 4.0, 999.0, 999.0, -0.3, 6.0, 999.0, 999.0, -0.5, 7.0, 999.0, 999.0, -0.1, 3.0 ] ); - idx = izamax( 4, x, -2, x.length-1 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports specifying a stride', function test( t ) { var expected; var idx; @@ -155,6 +135,26 @@ tape( 'the function supports specifying a stride', function test( t ) { t.end(); }); +tape( 'the function supports specifying a negative stride', function test( t ) { + var idx; + var x; + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] ); + + idx = izamax( x.length, x, -1, x.length-1 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = izamax( 2, x, -1, x.length-2 ); + t.strictEqual( idx, 0, 'returns expected value' ); + + // eslint-disable-next-line max-len + x = new Complex128Array( [ 0.1, 4.0, 999.0, 999.0, -0.3, 6.0, 999.0, 999.0, -0.5, 7.0, 999.0, 999.0, -0.1, 3.0 ] ); + idx = izamax( 4, x, -2, x.length-1 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports specifying an `x` offset', function test( t ) { var expected; var idx; diff --git a/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.native.js new file mode 100644 index 000000000000..a46a5726abcb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/izamax/test/test.ndarray.native.js @@ -0,0 +1,212 @@ +/** +* @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 izamax = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( izamax instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof izamax, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', opts, function test( t ) { + t.strictEqual( izamax.length, 4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function finds the index of the element with the maximum |Re(.)| + |Im(.)|', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 0.1, // 0 + -0.3, // 0 + 0.5, // 1 + -0.1, // 1 + -0.2, // 2 + 0.6, // 2 + -0.4, // 3 + 0.9 // 3 + ]); + expected = 3; + + idx = izamax( 4, x, 1, 0 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + x = new Complex128Array([ + 0.2, // 0 + -0.6, // 0 + 0.3, // 1 + 0.6, // 1 + 5.0, + 5.0 + ]); + expected = 1; + + idx = izamax( 2, x, 1, 0 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than `1`, the function returns `-1`', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, + 4.0 + ]); + expected = -1; + + idx = izamax( 0, x, 1, 0 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, + 4.0 + ]); + expected = 0; + + idx = izamax( 1, x, 1, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 0.1, // 0 + 4.0, // 0 + -0.3, + 6.0, + -0.5, // 1 + 7.0, // 1 + -0.1, + 3.0 + ]); + expected = 1; + + idx = izamax( 2, x, 2, 0 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] ); + expected = 1; + + idx = izamax( 3, x, -1, 2 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + // eslint-disable-next-line max-len + x = new Complex128Array( [ 0.1, 4.0, 999.0, 999.0, -0.3, 6.0, 999.0, 999.0, -0.5, 7.0, 999.0, 999.0, -0.1, 3.0 ] ); + expected = 1; + + idx = izamax( 4, x, -2, 6 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` offset', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, // 1 + 6.0, // 1 + 7.0, // 2 + 8.0 // 2 + ]); + expected = 2; + + idx = izamax( 3, x, 1, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Complex128Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + expected = 1; + + idx = izamax( 2, x, 2, 1 ); + t.strictEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); From 7fe24d2a2c2d4f13833533cf57cbcf2c78ffc585 Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Mon, 16 Mar 2026 00:47:33 +0530 Subject: [PATCH 5/6] fix: update copyright years --- .../@stdlib/blas/base/izamax/README.md | 135 +++++++++++++++++- .../@stdlib/blas/base/izamax/test/test.js | 2 +- 2 files changed, 130 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/izamax/README.md b/lib/node_modules/@stdlib/blas/base/izamax/README.md index dffa3d5b1b38..f6b58901218f 100644 --- a/lib/node_modules/@stdlib/blas/base/izamax/README.md +++ b/lib/node_modules/@stdlib/blas/base/izamax/README.md @@ -20,7 +20,7 @@ limitations under the License. # izamax -> Find the index of the first element having the maximum absolute value. +> Find the index of the first element having maximum |Re(.)| + |Im(.)|.
@@ -32,7 +32,7 @@ var izamax = require( '@stdlib/blas/base/izamax' ); #### izamax( N, x, strideX ) -Finds the index of the first element having the maximum absolute value. +Finds the index of the first element having maximum |Re(.)| + |Im(.)|. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); @@ -71,14 +71,14 @@ var x0 = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); // Create an offset view: var x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -// Find index of element having the maximum absolute value: +// Find index of element having maximum |Re(.)| + |Im(.)|: var idx = izamax( 2, x1, 1 ); // returns 1 ``` -#### izamax.ndarray( N, x, strideX, offset ) +#### izamax.ndarray( N, x, strideX, offsetX ) -Finds the index of the first element having the maximum absolute value using alternative indexing semantics. +Finds the index of the first element having maximum |Re(.)| + |Im(.)| using alternative indexing semantics. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); @@ -93,7 +93,7 @@ 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 `offset` parameter supports indexing semantics based on a starting index. For example, to start from the second 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 start from the second index, ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); @@ -147,6 +147,129 @@ console.log( idx ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/izamax.h" +``` + +#### c_izamax( N, \*X, strideX ) + +Finds the index of the first element having maximum |Re(.)| + |Im(.)|. + +```c +const double x[] = { 4.0, 2.0, -3.0, 5.0, -1.0, 2.0 }; + +CBLAS_INT idx = c_izamax( 3, (void *)x, 1 ); +// returns 1 +``` + +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 +CBLAS_INT c_izamax( const CBLAS_INT N, const void *X, const CBLAS_INT strideX ); +``` + +#### c_izamax_ndarray( N, \*X, strideX, offsetX ) + +Finds the index of the first element having maximum |Re(.)| + |Im(.)| using alternative indexing semantics. + +```c +const double x[] = { 4.0, 2.0, -3.0, 5.0, -1.0, 2.0 }; + +CBLAS_INT idx = c_izamax_ndarray( 3, (void *)x, 1, 0 ); +// returns 1 +``` + +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 +CBLAS_INT c_izamax_ndarray( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/izamax.h" +#include + +int main( void ) { + // Create a strided array: + 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: + const int strideX = 1; + + // Compute the index of the maximum value: + CBLAS_INT idx = c_izamax( N, (void *)x, strideX ); + + // Print the result: + printf( "index value: %d\n", idx ); + + // Compute the index of the maximum value: + idx = c_izamax_ndarray( N, (void *)x, -strideX, N-1 ); + + // Print the result: + printf( "index value: %d\n", idx ); +} +``` + +
+ + + +
+ + +