From 10285d405f011c35305358e28e07dd32fbe0d7cf Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Fri, 17 Jan 2025 17:25:40 +0000 Subject: [PATCH 1/3] 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/3] 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/3] 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 ]);