From 10983390572c4581e5fc519b8248896c8278d581 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 11 Apr 2024 22:35:11 +0530 Subject: [PATCH 1/7] feat: add BLAS Level 1 idamax routine --- .../@stdlib/blas/base/idamax/README.md | 170 +++++++++++ .../blas/base/idamax/benchmark/benchmark.js | 91 ++++++ .../base/idamax/benchmark/benchmark.native.js | 96 +++++++ .../idamax/benchmark/benchmark.ndarray.js | 91 ++++++ .../benchmark/benchmark.ndarray.native.js | 96 +++++++ .../blas/base/idamax/benchmark/c/Makefile | 129 +++++++++ .../idamax/benchmark/c/benchmark.length.c | 154 ++++++++++ .../base/idamax/benchmark/fortran/Makefile | 141 ++++++++++ .../benchmark/fortran/benchmark.kength.f | 217 ++++++++++++++ .../@stdlib/blas/base/idamax/binding.gyp | 265 ++++++++++++++++++ .../@stdlib/blas/base/idamax/docs/repl.txt | 89 ++++++ .../blas/base/idamax/docs/types/index.d.ts | 92 ++++++ .../blas/base/idamax/docs/types/test.ts | 157 +++++++++++ .../blas/base/idamax/examples/c/Makefile | 129 +++++++++ .../blas/base/idamax/examples/c/example.c | 37 +++ .../blas/base/idamax/examples/index.js | 31 ++ .../@stdlib/blas/base/idamax/include.gypi | 70 +++++ .../idamax/include/stdlib/blas/base/idamax.h | 42 +++ .../include/stdlib/blas/base/idamax_cblas.h | 41 +++ .../include/stdlib/blas/base/idamax_fortran.h | 41 +++ .../@stdlib/blas/base/idamax/lib/idamax.js | 85 ++++++ .../blas/base/idamax/lib/idamax.native.js | 51 ++++ .../@stdlib/blas/base/idamax/lib/index.js | 68 +++++ .../@stdlib/blas/base/idamax/lib/main.js | 35 +++ .../@stdlib/blas/base/idamax/lib/native.js | 35 +++ .../@stdlib/blas/base/idamax/lib/ndarray.js | 74 +++++ .../blas/base/idamax/lib/ndarray.native.js | 60 ++++ .../@stdlib/blas/base/idamax/manifest.json | 171 +++++++++++ .../@stdlib/blas/base/idamax/package.json | 74 +++++ .../@stdlib/blas/base/idamax/src/Makefile | 70 +++++ .../@stdlib/blas/base/idamax/src/addon.c | 47 ++++ .../@stdlib/blas/base/idamax/src/idamax.c | 65 +++++ .../@stdlib/blas/base/idamax/src/idamax.f | 109 +++++++ .../blas/base/idamax/src/idamax_cblas.c | 34 +++ .../@stdlib/blas/base/idamax/src/idamax_f.c | 39 +++ .../@stdlib/blas/base/idamax/src/idamaxsub.f | 46 +++ .../blas/base/idamax/test/test.idamax.js | 153 ++++++++++ .../base/idamax/test/test.idamax.native.js | 162 +++++++++++ .../@stdlib/blas/base/idamax/test/test.js | 82 ++++++ .../blas/base/idamax/test/test.ndarray.js | 170 +++++++++++ .../base/idamax/test/test.ndarray.native.js | 179 ++++++++++++ 41 files changed, 3988 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.kength.f create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax.h create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_fortran.h create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/src/idamax.c create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/src/idamax_f.c create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/src/idamaxsub.f create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.native.js diff --git a/lib/node_modules/@stdlib/blas/base/idamax/README.md b/lib/node_modules/@stdlib/blas/base/idamax/README.md new file mode 100644 index 000000000000..5f70d6eb21e0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/README.md @@ -0,0 +1,170 @@ + + +# idamax + +> Find the index of the first element having maximum absolute value. + +
+ +## Usage + +```javascript +var idamax = require( '@stdlib/blas/base/idamax' ); +``` + +#### idamax( N, x, strideX ) + +Finds the index of the first element having maximum absolute value. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + +var idx = idamax( x.length, x, 1 ); +// returns 3 +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **x**: input [`Float64Array`][@stdlib/array/float64]. +- **strideX**: index increment for `x`. + +The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. For example, to find index of element having maximum absolute value traversing every other value, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + +var idx = idamax( 4, x, 2 ); +// returns 2 +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial array: +var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + +// Create an offset view: +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +// Find index of element having maximum absolute value for every other element... +var idx = idamax( 3, x1, 2 ); +// returns 2 +``` + +If either `N` is less than `1` or `strideX` is less than or equal to `0`, the function returns `0`. + +#### idamax.ndarray( N, x, strideX, offset ) + +Finds the index of the first element having maximum absolute value using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + +var idx = idamax.ndarray( x.length, x, 1, 0 ); +// returns 3 +``` + +The function has the following additional parameters: + +- **offset**: starting index. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the `offset` parameter supports indexing semantics based on a starting index. For example, to find the index of the element having the maximum absolute value starting from second index, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + +var idx = idamax.ndarray( 5, x, 1, 1 ); +// returns 4 +``` + +
+ + + +
+ +## Notes + +- If `N < 1` or `strideX <= 0`, both functions return `0`. +- `idamax()` corresponds to the [BLAS][blas] level 1 function [`idamax`][idamax]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var idamax = require( '@stdlib/blas/base/idamax' ); + +var opts = { + 'dtype': 'float64' +}; +var x = discreteUniform( 10, -100, 100, opts ); +console.log( x ); + +var idx = idamax( x.length, x, 1 ); +console.log( idx ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.js new file mode 100644 index 000000000000..1e308c2035d3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.js @@ -0,0 +1,91 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var idamax = require( './../lib/idamax.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 x = uniform( len, -100.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = idamax( x.length, x, 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 // + +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/idamax/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.native.js new file mode 100644 index 000000000000..01ba41d5cdb6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.native.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var idamax = tryRequire( resolve( __dirname, './../lib/idamax.native.js' ) ); +var opts = { + 'skip': ( idamax 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 = uniform( len, -100.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = idamax( x.length, x, 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 // + +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+'::native:len='+len, opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..baced47637f2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.ndarray.js @@ -0,0 +1,91 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var idamax = 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 x = uniform( len, -100.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = idamax( x.length, x, 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 // + +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/idamax/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..c2f1a2384379 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var idamax = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( idamax 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 = uniform( len, -100.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = idamax( x.length, x, 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 // + +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+'::native:ndarray:len='+len, opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/Makefile new file mode 100644 index 000000000000..2234f32350a9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/Makefile @@ -0,0 +1,129 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2019 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 source files: +c_src := ../../src/idamax.c + +# List of C targets: +c_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles C source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler +# @param {string} CFLAGS - C compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) -I ../../include -o $@ $(c_src) $< -lm + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..9a23444cf58b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/benchmark.length.c @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/** +* Benchmark `idamax`. +*/ +#include "stdlib/blas/base/idamax.h" +#include +#include +#include +#include +#include + +#define NAME "idamax" +#define ITERATIONS 10000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +void print_results( int iterations, double elapsed ) { + double rate = (double)iterations / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", iterations ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1]. +* +* @return random number +*/ +double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +double benchmark( int iterations, int len ) { + double elapsed; + double x[ len ]; + double idx; + double t; + int i; + + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_double()*20000.0 ) - 10000.0; + } + idx = -1; + t = tic(); + for ( i = 0; i < iterations; i++ ) { + idx = c_idamax( len, x, 1 ); + if ( idx != idx ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( idx != idx ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int len; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:len=%d\n", NAME, len ); + elapsed = benchmark( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/Makefile new file mode 100644 index 000000000000..a029be690fbf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/Makefile @@ -0,0 +1,141 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2019 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling Fortran source files: +ifdef FORTRAN_COMPILER + FC := $(FORTRAN_COMPILER) +else + FC := gfortran +endif + +# Define the command-line options when compiling Fortran files: +FFLAGS ?= \ + -std=f95 \ + -ffree-form \ + -O3 \ + -Wall \ + -Wextra \ + -Wno-compare-reals \ + -Wimplicit-interface \ + -fno-underscoring \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop`): +INCLUDE ?= + +# List of Fortran source files: +SOURCE_FILES ?= ../../src/idamax.f + +# List of Fortran targets: +f_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles Fortran source files. +# +# @param {string} SOURCE_FILES - list of Fortran source files +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} [FORTRAN_COMPILER] - Fortran compiler +# @param {string} [FFLAGS] - Fortran compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @example +# make +# +# @example +# make all +#/ +all: $(f_targets) + +.PHONY: all + +#/ +# Compiles Fortran source files. +# +# @private +# @param {string} SOURCE_FILES - list of Fortran source files +# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} FC - Fortran compiler +# @param {string} FFLAGS - Fortran compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(f_targets): %.out: %.f + $(QUIET) $(FC) $(FFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(f_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.kength.f b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.kength.f new file mode 100644 index 000000000000..d7df44bd60a5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.kength.f @@ -0,0 +1,217 @@ +!> +! @license Apache-2.0 +! +! Copyright (c) 2024 The Stdlib Authors. +! +! Licensed under the Apache License, Version 2.0 (the "License"); +! you may not use this file except in compliance with the License. +! You may obtain a copy of the License at +! +! http://www.apache.org/licenses/LICENSE-2.0 +! +! Unless required by applicable law or agreed to in writing, software +! distributed under the License is distributed on an "AS IS" BASIS, +! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +! See the License for the specific language governing permissions and +! limitations under the License. +!< + +!> Benchmark `idamax`. +! +! ## Notes +! +! - Written in "free form" Fortran 95. +! +!< +program bench + implicit none + ! .. + ! Local constants: + character(4), parameter :: name = 'idamax' ! if changed, be sure to adjust length + integer, parameter :: iterations = 1000000 + integer, parameter :: repeats = 3 + integer, parameter :: min = 1 + integer, parameter :: max = 6 + ! .. + ! Run the benchmarks: + call main() + ! .. + ! Functions: +contains + ! .. + ! Prints the TAP version. + ! .. + subroutine print_version() + print '(A)', 'TAP version 13' + end subroutine print_version + ! .. + ! Prints the TAP summary. + ! + ! @param {integer} total - total number of tests + ! @param {integer} passing - total number of passing tests + ! .. + subroutine print_summary( total, passing ) + ! .. + ! Scalar arguments: + integer, intent(in) :: total, passing + ! .. + ! Local variables: + character(len=999) :: str, tmp + ! .. + ! Intrinsic functions: + intrinsic adjustl, trim + ! .. + print '(A)', '#' + ! .. + write (str, '(I15)') total ! TAP plan + tmp = adjustl( str ) + print '(A,A)', '1..', trim( tmp ) + ! .. + print '(A,A)', '# total ', trim( tmp ) + ! .. + write (str, '(I15)') passing + tmp = adjustl( str ) + print '(A,A)', '# pass ', trim( tmp ) + ! .. + print '(A)', '#' + print '(A)', '# ok' + end subroutine print_summary + ! .. + ! Prints benchmarks results. + ! + ! @param {integer} iterations - number of iterations + ! @param {double} elapsed - elapsed time in seconds + ! .. + subroutine print_results( iterations, elapsed ) + ! .. + ! Scalar arguments: + double precision, intent(in) :: elapsed + integer, intent(in) :: iterations + ! .. + ! Local variables: + double precision :: rate + character(len=999) :: str, tmp + ! .. + ! Intrinsic functions: + intrinsic dble, adjustl, trim + ! .. + rate = dble( iterations ) / elapsed + ! .. + print '(A)', ' ---' + ! .. + write (str, '(I15)') iterations + tmp = adjustl( str ) + print '(A,A)', ' iterations: ', trim( tmp ) + ! .. + write (str, '(f0.9)') elapsed + tmp = adjustl( str ) + print '(A,A)', ' elapsed: ', trim( tmp ) + ! .. + write( str, '(f0.9)') rate + tmp = adjustl( str ) + print '(A,A)', ' rate: ', trim( tmp ) + ! .. + print '(A)', ' ...' + end subroutine print_results + ! .. + ! Runs a benchmark. + ! + ! @param {integer} iterations - number of iterations + ! @param {integer} len - array length + ! @return {double} elapsed time in seconds + ! .. + double precision function benchmark( iterations, len ) + ! .. + ! External functions: + interface + integer function idamax( N, dx, strideX ) + integer :: strideX, N + double precision :: dx(*) + end function idamax + end interface + ! .. + ! Scalar arguments: + integer, intent(in) :: iterations, len + ! .. + ! Local scalars: + integer :: idx + double precision :: elapsed, r + double precision :: t1, t2 + integer :: i + ! .. + ! Local arrays: + double precision, allocatable :: x(:) + ! .. + ! Intrinsic functions: + intrinsic random_number, cpu_time + ! .. + ! Allocate arrays: + allocate( x(len) ) + ! .. + do i = 1, len + call random_number( r ) + x( i ) = ( r*2000.0 ) - 1000.0 + end do + ! .. + idx = -1 + call cpu_time( t1 ) + ! .. + do i = 1, iterations + idx = idamax( len, x, 1, y, 1 ) + if ( idx /= idx ) then + print '(A)', 'should not return NaN' + exit + end if + end do + ! .. + call cpu_time( t2 ) + ! .. + elapsed = t2 - t1 + ! .. + if ( idx /= idx ) then + print '(A)', 'should not return NaN' + end if + ! .. + ! Deallocate arrays: + deallocate( x ) + ! .. + benchmark = elapsed + return + end function benchmark + ! .. + ! Main execution sequence. + ! .. + subroutine main() + ! .. + ! Local variables: + character(len=999) :: str, tmp + double precision :: elapsed + integer :: i, j, len, count, iter + ! .. + ! Intrinsic functions: + intrinsic adjustl, trim + ! .. + call print_version() + count = 0 + do i = min, max + len = 10**i + iter = iterations / 10**(i-1) + do j = 1, repeats + count = count + 1 + ! .. + write (str, '(I15)') len + tmp = adjustl( str ) + print '(A,A,A,A)', '# fortran::', name, ':len=', trim(tmp) + ! .. + elapsed = benchmark( iter, len ) + ! .. + call print_results( iter, elapsed ) + ! .. + write (str, '(I15)') count + tmp = adjustl( str ) + print '(A,A,A)', 'ok ', trim( tmp ), ' benchmark finished' + end do + end do + call print_summary( count, count ) + end subroutine main +end program bench \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/idamax/binding.gyp b/lib/node_modules/@stdlib/blas/base/idamax/binding.gyp new file mode 100644 index 000000000000..02a2799da097 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/binding.gyp @@ -0,0 +1,265 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Fortran compiler (to override -Dfortran_compiler=): + 'fortran_compiler%': 'gfortran', + + # Fortran compiler flags: + 'fflags': [ + # Specify the Fortran standard to which a program is expected to conform: + '-std=f95', + + # Indicate that the layout is free-form source code: + '-ffree-form', + + # Aggressive optimization: + '-O3', + + # Enable commonly used warning options: + '-Wall', + + # Warn if source code contains problematic language features: + '-Wextra', + + # Warn if a procedure is called without an explicit interface: + '-Wimplicit-interface', + + # Do not transform names of entities specified in Fortran source files by appending underscores (i.e., don't mangle names, thus allowing easier usage in C wrappers): + '-fno-underscoring', + + # Warn if source code contains Fortran 95 extensions and C-language constructs: + '-pedantic', + + # Compile but do not link (output is an object file): + '-c', + ], + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + + # Define custom build actions for particular inputs: + 'rules': [ + { + # Define a rule for processing Fortran files: + 'extension': 'f', + + # Define the pathnames to be used as inputs when performing processing: + 'inputs': [ + # Full path of the current input: + '<(RULE_INPUT_PATH)' + ], + + # Define the outputs produced during processing: + 'outputs': [ + # Store an output object file in a directory for placing intermediate results (only accessible within a single target): + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)' + ], + + # Define the rule for compiling Fortran based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + + # Rule to compile Fortran on Windows: + { + 'rule_name': 'compile_fortran_windows', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Windows...', + + 'process_outputs_as_sources': 0, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + }, + + # Rule to compile Fortran on non-Windows: + { + 'rule_name': 'compile_fortran_linux', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Linux...', + + 'process_outputs_as_sources': 1, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '-fPIC', # generate platform-independent code + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + } + ], # end condition (OS=="win") + ], # end conditions + }, # end rule (extension=="f") + ], # end rules + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/blas/base/idamax/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/idamax/docs/repl.txt new file mode 100644 index 000000000000..95ac97c54f75 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/docs/repl.txt @@ -0,0 +1,89 @@ + +{{alias}}( N, x, strideX ) + Finds the index of the first element having maximum absolute value. + + 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 + array views. + + If `N < 1` or `strideX <= 0`, the function returns `0`. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Float64Array + Input array. + + strideX: integer + Index increment for `x`. + + Returns + ------- + idx: integer + Index value. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0 ] ); + > var idx = {{alias}}( x.length, x, 1 ) + 3 + + // Using `N` and `strideX` parameters: + > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0 ] ); + > var idx = {{alias}}( 2, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 1 ) + 2 + + +{{alias}}.ndarray( N, x, strideX, offsetX ) + Finds the index of the first element having 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. + + x: Float64Array + Input array. + + strideX: integer + Index increment for `x`. + + offsetX: integer + Starting index of `x`. + + Returns + ------- + idx: integer + Index value. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); + > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) + 3 + + // Using an index offset: + > x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 2 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/idamax/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/idamax/docs/types/index.d.ts new file mode 100644 index 000000000000..28bded096af4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/docs/types/index.d.ts @@ -0,0 +1,92 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Interface describing `idamax`. +*/ +interface Routine { + /** + * Finds the index of the first element having maximum absolute value. + * + * @param N - number of indexed elements + * @param x - input array + * @param strideX - stride length for `x` + * @returns index value + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + * + * var idx = idamax( x.length, x, 1 ); + * // returns 3 + */ + ( N: number, x: Float64Array, strideX: number ): number; + + /** + * Finds the index of the first element having maximum absolute value using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param x - input array + * @param strideX - stride length for `x` + * @param offsetX - starting index for `x` + * @returns index value + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); + * + * var idx = idamax.ndarray( x.length, x, 1, 0 ); + * // returns 3 + */ + ndarray( N: number, x: Float64Array, strideX: number, offsetX: number ): number; +} + +/** +* Finds the index of the first element having maximum absolute value. +* +* @param N - number of indexed elements +* @param x - input array +* @param strideX - stride length for `x` +* @returns index value +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var idx = idamax( 4, x, 2 ); +* // returns 2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var idx = idamax.ndarray( x.length, x, 1, 1 ); +* // returns 2 +*/ +declare var idamax: Routine; + + +// EXPORTS // + +export = idamax; diff --git a/lib/node_modules/@stdlib/blas/base/idamax/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/idamax/docs/types/test.ts new file mode 100644 index 000000000000..708e2f375915 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/docs/types/test.ts @@ -0,0 +1,157 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import idamax = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const x = new Float64Array( 10 ); + + idamax( x.length, x, 1 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + + idamax( '10', x, 1 ); // $ExpectError + idamax( true, x, 1 ); // $ExpectError + idamax( false, x, 1 ); // $ExpectError + idamax( null, x, 1 ); // $ExpectError + idamax( undefined, x, 1 ); // $ExpectError + idamax( [], x, 1 ); // $ExpectError + idamax( {}, x, 1 ); // $ExpectError + idamax( ( x: number ): number => x, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + + idamax( x.length, 10, 1 ); // $ExpectError + idamax( x.length, '10', 1 ); // $ExpectError + idamax( x.length, true, 1 ); // $ExpectError + idamax( x.length, false, 1 ); // $ExpectError + idamax( x.length, null, 1 ); // $ExpectError + idamax( x.length, undefined, 1 ); // $ExpectError + idamax( x.length, [], 1 ); // $ExpectError + idamax( x.length, {}, 1 ); // $ExpectError + idamax( x.length, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float64Array( 10 ); + + idamax( x.length, x, '10' ); // $ExpectError + idamax( x.length, x, true ); // $ExpectError + idamax( x.length, x, false ); // $ExpectError + idamax( x.length, x, null ); // $ExpectError + idamax( x.length, x, undefined ); // $ExpectError + idamax( x.length, x, [] ); // $ExpectError + idamax( x.length, x, {} ); // $ExpectError + idamax( x.length, x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + + idamax(); // $ExpectError + idamax( x.length ); // $ExpectError + idamax( x.length, x ); // $ExpectError + idamax( x.length, x, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const x = new Float64Array( 10 ); + + idamax.ndarray( x.length, x, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + + idamax.ndarray( '10', x, 1, 0 ); // $ExpectError + idamax.ndarray( true, x, 1, 0 ); // $ExpectError + idamax.ndarray( false, x, 1, 0 ); // $ExpectError + idamax.ndarray( null, x, 1, 0 ); // $ExpectError + idamax.ndarray( undefined, x, 1, 0 ); // $ExpectError + idamax.ndarray( [], x, 1, 0 ); // $ExpectError + idamax.ndarray( {}, x, 1, 0 ); // $ExpectError + idamax.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 Float64Array... +{ + const x = new Float64Array( 10 ); + + idamax.ndarray( x.length, 10, 1, 0 ); // $ExpectError + idamax.ndarray( x.length, '10', 1, 0 ); // $ExpectError + idamax.ndarray( x.length, true, 1, 0 ); // $ExpectError + idamax.ndarray( x.length, false, 1, 0 ); // $ExpectError + idamax.ndarray( x.length, null, 1, 0 ); // $ExpectError + idamax.ndarray( x.length, undefined, 1, 0 ); // $ExpectError + idamax.ndarray( x.length, [], 1, 0 ); // $ExpectError + idamax.ndarray( x.length, {}, 1, 0 ); // $ExpectError + idamax.ndarray( x.length, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const x = new Float64Array( 10 ); + + idamax.ndarray( x.length, x, '10', 0 ); // $ExpectError + idamax.ndarray( x.length, x, true, 0 ); // $ExpectError + idamax.ndarray( x.length, x, false, 0 ); // $ExpectError + idamax.ndarray( x.length, x, null, 0 ); // $ExpectError + idamax.ndarray( x.length, x, undefined, 0 ); // $ExpectError + idamax.ndarray( x.length, x, [], 0 ); // $ExpectError + idamax.ndarray( x.length, x, {}, 0 ); // $ExpectError + idamax.ndarray( x.length, x, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + + idamax.ndarray( x.length, x, 1, '10' ); // $ExpectError + idamax.ndarray( x.length, x, 1, true ); // $ExpectError + idamax.ndarray( x.length, x, 1, false ); // $ExpectError + idamax.ndarray( x.length, x, 1, null ); // $ExpectError + idamax.ndarray( x.length, x, 1, undefined ); // $ExpectError + idamax.ndarray( x.length, x, 1, [] ); // $ExpectError + idamax.ndarray( x.length, x, 1, {} ); // $ExpectError + idamax.ndarray( x.length, x, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + + idamax.ndarray(); // $ExpectError + idamax.ndarray( x.length ); // $ExpectError + idamax.ndarray( x.length, x ); // $ExpectError + idamax.ndarray( x.length, x, 1 ); // $ExpectError + idamax.ndarray( x.length, x, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/idamax/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/idamax/examples/c/Makefile new file mode 100644 index 000000000000..0b17b69f43de --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/examples/c/Makefile @@ -0,0 +1,129 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2020 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# 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 source files: +c_src := ../../src/idamax.c + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles C source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler +# @param {string} CFLAGS - C compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) -I ../../include -o $@ $(c_src) $< -lm + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/idamax/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/idamax/examples/c/example.c new file mode 100644 index 000000000000..9656cf8d3a8c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/examples/c/example.c @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/idamax.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 element: + const int N = 8; + + // Specify stride: + const int strideX = 1; + + // Compute the index of the maximum absolute value: + int idx = c_idamax( N, x, strideX ); + + // Print the result: + printf( "index value: %d\n", idx ); +} diff --git a/lib/node_modules/@stdlib/blas/base/idamax/examples/index.js b/lib/node_modules/@stdlib/blas/base/idamax/examples/index.js new file mode 100644 index 000000000000..d67032d76761 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/examples/index.js @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var idamax = require( './../lib' ); + +var opts = { + 'dtype': 'float64' +}; +var x = discreteUniform( 10, 0, 100, opts ); +console.log( x ); + +var idx = idamax.ndarray( x.length, x, 1, 0 ); +console.log( idx ); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/include.gypi b/lib/node_modules/@stdlib/blas/base/idamax/include.gypi new file mode 100644 index 000000000000..497aeca15320 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/include.gypi @@ -0,0 +1,70 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Note that nesting variables is required due to how GYP processes a configuration. Any variables defined within a nested 'variables' section is defined in the outer scope. Thus, conditions in the outer variable scope are free to use these variables without running into "variable undefined" errors. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +# +# Variable nesting hacks: +# +# [3]: https://chromium.googlesource.com/external/skia/gyp/+/master/common_variables.gypi +# [4]: https://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + 'variables': { + # Host BLAS library (to override -Dblas=): + 'blas%': '', + + # Path to BLAS library (to override -Dblas_dir=): + 'blas_dir%': '', + }, # end variables + + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<@(blas_dir)', + ' dmax ) { + idx = i; + dmax = abs( x[ i ] ); + } + } + return idx; + } + // Code for stride not equal to `1`... + ix = 0; + dmax = abs( x[ 0 ] ); + ix += strideX; + for ( i = 1; i < N; i++ ) { + if ( abs( x[ ix ] ) > dmax ) { + idx = i; + dmax = abs( x[ ix ] ); + } + ix += strideX; + } + return idx; +} + + +// EXPORTS // + +module.exports = idamax; diff --git a/lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.native.js b/lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.native.js new file mode 100644 index 000000000000..eb1823e19216 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.native.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Finds the index of the first element having maximum absolute value. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Float64Array} x - first input array +* @param {integer} strideX - `x` stride length +* @returns {integer} index value +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ); +* +* var idx = idamax( x.length, x, 1 ); +* // returns 3 +*/ +function idamax( N, x, strideX ) { + return addon( N, x, strideX ); +} + + +// EXPORTS // + +module.exports = idamax; diff --git a/lib/node_modules/@stdlib/blas/base/idamax/lib/index.js b/lib/node_modules/@stdlib/blas/base/idamax/lib/index.js new file mode 100644 index 000000000000..1e19f57085a3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/lib/index.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* BLAS level 1 routine to find the index of the first element having maximum absolute value. +* +* @module @stdlib/blas/base/idamax +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var idamax = require( '@stdlib/blas/base/idamax' ); +* +* var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var idx = idamax( x.length, x, 1 ); +* // returns 3 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var idamax = require( '@stdlib/blas/base/idamax' ); +* +* var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); +* +* var idx = idamax.ndarray( x.length, x, 1, 0 ); +* // returns 3 +*/ + +// 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 idamax; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + idamax = main; +} else { + idamax = tmp; +} + + +// EXPORTS // + +module.exports = idamax; + +// exports: { "ndarray": "idamax.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/idamax/lib/main.js b/lib/node_modules/@stdlib/blas/base/idamax/lib/main.js new file mode 100644 index 000000000000..a9fbdc7ad963 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var idamax = require( './idamax.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( idamax, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = idamax; diff --git a/lib/node_modules/@stdlib/blas/base/idamax/lib/native.js b/lib/node_modules/@stdlib/blas/base/idamax/lib/native.js new file mode 100644 index 000000000000..7fefa5418b25 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/lib/native.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var idamax = require( './idamax.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( idamax, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = idamax; diff --git a/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.js new file mode 100644 index 000000000000..ca05bdc5da0c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.js @@ -0,0 +1,74 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var abs = require( '@stdlib/math/base/special/abs' ); + + +// MAIN // + +/** +* Finds the index of the first element having maximum absolute value. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Float64Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @returns {integer} index of the first element having maximum absolute value +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* +* var idx = idamax( x.length, x, 1, 0 ); +* // returns 4 +*/ +function idamax( N, x, strideX, offsetX ) { + var dmax; + var idx; + var ix; + var i; + + idx = 0; + if ( N < 1 || strideX <= 0 ) { + return -1; + } + if ( N === 1 ) { + return idx; + } + ix = offsetX; + dmax = abs( x[ 0 ] ); + ix += strideX; + for ( i = 1; i < N; i++ ) { + if ( abs( x[ ix ] ) > dmax ) { + idx = i; + dmax = abs( x[ ix ] ); + } + ix += strideX; + } + return idx; +} + + +// EXPORTS // + +module.exports = idamax; diff --git a/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.native.js new file mode 100644 index 000000000000..98a995228738 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.native.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); +var offsetView = require( '@stdlib/strided/base/offset-view' ); +var addon = require( './idamax.native.js' ); + + +// MAIN // + +/** +* Finds the index of the first element having maximum absolute value. +* +* @param {integer} N - number of indexed elements +* @param {Float64Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @returns {integer} index value +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ); +* +* var idx = idamax( x.length, x, 1, 0 ); +* // returns 3 +*/ +function idamax( N, x, strideX, offsetX ) { + var viewX; + + offsetX = minViewBufferIndex( N, strideX, offsetX ); + + viewX = offsetView( x, offsetX ); + + return addon( N, viewX, strideX ); +} + + +// EXPORTS // + +module.exports = idamax; diff --git a/lib/node_modules/@stdlib/blas/base/idamax/manifest.json b/lib/node_modules/@stdlib/blas/base/idamax/manifest.json new file mode 100644 index 000000000000..603c7bff78d8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/manifest.json @@ -0,0 +1,171 @@ +{ + "options": { + "os": "linux", + "blas": "", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/idamax.f", + "./src/idamaxsub.f", + "./src/idamax_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/idamax_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/idamax.f", + "./src/idamaxsub.f", + "./src/idamax_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/idamax_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/idamax_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/idamax.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/idamax.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/idamax/package.json b/lib/node_modules/@stdlib/blas/base/idamax/package.json new file mode 100644 index 000000000000..2823ada33719 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/blas/base/idamax", + "version": "0.0.0", + "description": "Find the index of the first element having 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", + "browser": "./lib/main.js", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "level 1", + "idamax", + "maximum", + "linear", + "algebra", + "subroutines", + "vector", + "array", + "ndarray", + "float64", + "integer", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/Makefile b/lib/node_modules/@stdlib/blas/base/idamax/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/addon.c b/lib/node_modules/@stdlib/blas/base/idamax/src/addon.c new file mode 100644 index 000000000000..d76418ba34d7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/addon.c @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/idamax.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float64array.h" +#include +#include + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 3 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); + + napi_value idx; + napi_status status = napi_create_int64( env, c_idamax( N, X, strideX ), &idx ); + assert( status == napi_ok ); + return idx; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.c b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.c new file mode 100644 index 000000000000..829d6a4c5be6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.c @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/idamax.h" +#include + +/** +* Finds the index of the first element having maximum fabsolute value. +* +* @param N number of indexed elements +* @param X input array +* @param strideX index increment for `x` +*/ +int c_idamax( const int N, const double *X, const int strideX ) { + double dmax; + int idx; + int ix; + int i; + + idx = 0; + if ( N < 1 || strideX <= 0 ) { + return -1; + } + if ( N == 1 ) { + return idx; + } + if (strideX == 1 ) { + // Code for stride equal to `1`... + dmax = fabs( X[ 0 ] ); + for ( i = 1; i < N; i++ ) { + if ( fabs( X[ i ] ) > dmax ) { + idx = i; + dmax = fabs( X[ i ] ); + } + } + return idx; + } + // Code for stride not equal to `1`... + ix = 0; + dmax = fabs( X[ 0 ] ); + ix += strideX; + for ( i = 1; i < N; i++ ) { + if ( fabs( X[ ix ] ) > dmax ) { + idx = i; + dmax = fabs( X[ ix ] ); + } + ix += strideX; + } + return idx; +} diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f new file mode 100644 index 000000000000..e510d697220b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f @@ -0,0 +1,109 @@ +!> +! @license Apache-2.0 +! +! Copyright (c) 2024 The Stdlib Authors. +! +! Licensed under the Apache License, Version 2.0 (the "License"); +! you may not use this file except in compliance with the License. +! You may obtain a copy of the License at +! +! http://www.apache.org/licenses/LICENSE-2.0 +! +! Unless required by applicable law or agreed to in writing, software +! distributed under the License is distributed on an "AS IS" BASIS, +! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +! See the License for the specific language governing permissions and +! limitations under the License. +!< + +!> Find the index of the first element having maximum absolute value. +! +! ## 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} dx - input array +! @param {integer} stride - `dx` stride length +!< +integer function idamax( N, dx, stride ) + implicit none + ! .. + ! Scalar arguments: + integer :: stride, N + ! .. + ! Array arguments: + double precision :: dx(*) + ! .. + ! Local scalars: + double precision :: dmax + integer :: i, ix + ! .. + ! Intrinsic functions: + intrinsic DABS + ! .. + IDAMAX = 0 + if ( N < 1 .OR. stride <= 0 ) then + return + end if + IDAMAX = 1 + ! .. + ! If N is equal to `1`, return early... + if ( N == 1 ) then + return + end if + ! .. + ! If stride is equal to `1`, use unrolled loops... + if ( stride == 1 ) then + ! .. + ! Code for increment equal to `1`... + dmax = DABS( dx( 1 ) ) + do i = 2, N + if ( DABS( dx( i ) ) > dmax ) then + IDAMAX = i + dmax = DABS( dx( i ) ) + end if + end do + return + else + ! .. + ! Code for increment not equal to `1`... + ix = 1 + dmax = DABS( dx( 1 ) ) + do i = 2, N + ix = ix + stride + if ( DABS( dx( ix ) ) > dmax ) then + IDAMAX = i + dmax = DABS( dx( ix ) ) + end if + end do + return + end if + return +end function idamax \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c new file mode 100644 index 000000000000..4be162dd1403 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/idamax.h" +#include "stdlib/blas/base/idamax_cblas.h" + +/** +* Finds the index of the first element having maximum absolute value. +* +* @param N number of indexed elements +* @param X input array +* @param strideX index increment for `x` +*/ +int c_idamax( const int N, const double *X, const int strideX ) { + int idx; + + idx = cblas_idamax( N, X, strideX ); + return idx; +} diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_f.c b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_f.c new file mode 100644 index 000000000000..47232703f222 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_f.c @@ -0,0 +1,39 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/** + * Find the index of the first element having maximum absolute value. + * + * @see idamax + */ +#include "stdlib/blas/base/idamax.h" +#include "stdlib/blas/base/idamax_fortran.h" + +/** +* Finds the index of the first element having maximum absolute value. +* +* @param N number of indexed elements +* @param X first array +* @param strideX X stride length +* @return index value +*/ +int c_idamax( const int N, const double *X, const int strideX ) { + int idx; + idamaxsub( &N, X, &strideX, &idx ); + return idx - 1; +} diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/idamaxsub.f b/lib/node_modules/@stdlib/blas/base/idamax/src/idamaxsub.f new file mode 100644 index 000000000000..8ce187798f8c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/idamaxsub.f @@ -0,0 +1,46 @@ +!> +! @license Apache-2.0 +! +! Copyright (c) 2024 The Stdlib Authors. +! +! Licensed under the Apache License, Version 2.0 (the "License"); +! you may not use this file except in compliance with the License. +! You may obtain a copy of the License at +! +! http://www.apache.org/licenses/LICENSE-2.0 +! +! Unless required by applicable law or agreed to in writing, software +! distributed under the License is distributed on an "AS IS" BASIS, +! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +! See the License for the specific language governing permissions and +! limitations under the License. +!< + +!> Wraps `idamax` as a subroutine. +! +! @param {integer} N - number of indexed elements +! @param {Array} dx - first array +! @param {integer} strideX - `dx` stride length +! @param {integer} index - output variable reference +!< +subroutine idamaxsub( N, dx, strideX, idx ) + implicit none + ! .. + ! External functions: + interface + integer function idamax( N, dx, strideX ) + double precision :: dx(*) + integer :: strideX, N + end function idamax + end interface + ! .. + ! Scalar arguments: + integer :: strideX, N, idx + ! .. + ! Array arguments: + double precision :: dx(*) + ! .. + ! Compute the dot product: + idx = idamax( N, dx, strideX ) + return +end subroutine idamaxsub \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.js b/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.js new file mode 100644 index 000000000000..25c196ad0111 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.js @@ -0,0 +1,153 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var idamax = require( './../lib/idamax.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof idamax, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 3', function test( t ) { + t.strictEqual( idamax.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 Float64Array([ + 0.1, // 1 + -0.3, // 2 + 0.5, // 3 + -0.1, // 4 + 6.0, + 6.0, + 6.0 + ]); + expected = 2; + + idx = idamax( 4, x, 1 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + x = new Float64Array( [ + 0.2, // 1 + -0.6, // 2 + 0.3, // 3 + 5.0, + 5.0 + ] ); + expected = 1; + + idx = idamax( 3, x, 1 ); + t.deepEqual( 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 Float64Array( [ + 1.0, + 2.0, + 3.0 + ] ); + expected = -1; + + idx = idamax( 0, x, 1 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `strideX` parameter less than or equal to `0`, the function returns `-1`', function test( t ) { + var expected; + var idx; + var x; + + x = new Float64Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] ); + expected = -1; + + idx = idamax( x.length, x, 0 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + idx = idamax( x.length, x, -1 ); + t.deepEqual( 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 Float64Array([ + 0.1, // 1 + 4.0, + -0.3, // 2 + 6.0, + -0.5, // 3 + 7.0, + -0.1, // 4 + 3.0 + ]); + expected = 2; + + idx = idamax( 4, x, 2 ); + t.deepEqual( 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 Float64Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + expected = 2; + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + idx = idamax( 3, x1, 2 ); + t.deepEqual( idx, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.native.js b/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.native.js new file mode 100644 index 000000000000..245515e191da --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.native.js @@ -0,0 +1,162 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var idamax = tryRequire( resolve( __dirname, './../lib/idamax.native.js' ) ); +var opts = { + 'skip': ( idamax instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof idamax, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 3', opts, function test( t ) { + t.strictEqual( idamax.length, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the function finds the index of the element with the maximum absolute value', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Float64Array([ + 0.1, // 1 + -0.3, // 2 + 0.5, // 3 + -0.1, // 4 + 6.0, + 6.0, + 6.0 + ]); + expected = 2; + + idx = idamax( 4, x, 1 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + x = new Float64Array( [ + 0.2, // 1 + -0.6, // 2 + 0.3, // 3 + 5.0, + 5.0 + ] ); + expected = 1; + + idx = idamax( 3, x, 1 ); + t.deepEqual( 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 Float64Array( [ + 1.0, + 2.0, + 3.0 + ] ); + expected = -1; + + idx = idamax( 0, x, 1 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `strideX` parameter less than or equal to `0`, the function returns `-1`', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Float64Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] ); + expected = -1; + + idx = idamax( x.length, x, 0 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + idx = idamax( x.length, x, -1 ); + t.deepEqual( 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 Float64Array([ + 0.1, // 1 + 4.0, + -0.3, // 2 + 6.0, + -0.5, // 3 + 7.0, + -0.1, // 4 + 3.0 + ]); + expected = 2; + + idx = idamax( 4, x, 2 ); + t.deepEqual( 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 Float64Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + expected = 2; + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + idx = idamax( 3, x1, 2 ); + t.deepEqual( idx, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/test/test.js b/lib/node_modules/@stdlib/blas/base/idamax/test/test.js new file mode 100644 index 000000000000..f59c4efacf64 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var idamax = 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 idamax, '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 idamax.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 idamax = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( idamax, 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 idamax; + var main; + + main = require( './../lib/idamax.js' ); + + idamax = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( idamax, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.js new file mode 100644 index 000000000000..d5ad8f3bf2ee --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.js @@ -0,0 +1,170 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var idamax = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof idamax, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( idamax.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 Float64Array([ + 0.1, // 1 + -0.3, // 2 + 0.5, // 3 + -0.1, // 4 + 6.0, + 6.0, + 6.0 + ]); + expected = 2; + + idx = idamax( 4, x, 1, 0 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + x = new Float64Array( [ + 0.2, // 1 + -0.6, // 2 + 0.3, // 3 + 5.0, + 5.0 + ] ); + expected = 1; + + idx = idamax( 3, x, 1, 0 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than `1`, the function returns `0`', function test( t ) { + var expected; + var idx; + var x; + + x = new Float64Array( [ + 1.0, + 2.0, + 3.0 + ] ); + expected = -1; + + idx = idamax( 0, x, 1, 0 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `strideX` parameter less than or equal to `0`, the function returns `0`', function test( t ) { + var expected; + var idx; + var x; + + x = new Float64Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] ); + expected = -1; + + idx = idamax( x.length, x, 0, 0 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + idx = idamax( x.length, x, -1, 0 ); + t.deepEqual( 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 Float64Array([ + 0.1, // 1 + 4.0, + -0.3, // 2 + 6.0, + -0.5, // 3 + 7.0, + -0.1, // 4 + 3.0 + ]); + expected = 2; + + idx = idamax( 4, x, 2, 0 ); + t.deepEqual( 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 Float64Array([ + 1.0, + 2.0, // 0 + 3.0, // 1 + 4.0, // 2 + 5.0, // 3 + 6.0 // 4 + ]); + expected = 4; + + idx = idamax( 5, x, 1, 1 ); + t.deepEqual( 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 Float64Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + expected = 2; + + idx = idamax( 3, x, 2, 1 ); + t.deepEqual( idx, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.native.js new file mode 100644 index 000000000000..f84818e730ad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.native.js @@ -0,0 +1,179 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var idamax = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( idamax instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof idamax, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', opts, function test( t ) { + t.strictEqual( idamax.length, 4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function finds the index of the element with the maximum absolute value', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Float64Array([ + 0.1, // 1 + -0.3, // 2 + 0.5, // 3 + -0.1, // 4 + 6.0, + 6.0, + 6.0 + ]); + expected = 2; + + idx = idamax( 4, x, 1, 0 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + x = new Float64Array( [ + 0.2, // 1 + -0.6, // 2 + 0.3, // 3 + 5.0, + 5.0 + ] ); + expected = 1; + + idx = idamax( 3, x, 1, 0 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than `1`, the function returns `0`', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Float64Array( [ + 1.0, + 2.0, + 3.0 + ] ); + expected = -1; + + idx = idamax( 0, x, 1, 0 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `strideX` parameter less than or equal to `0`, the function returns `0`', opts, function test( t ) { + var expected; + var idx; + var x; + + x = new Float64Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] ); + expected = -1; + + idx = idamax( x.length, x, 0, 0 ); + t.deepEqual( idx, expected, 'returns expected value' ); + + idx = idamax( x.length, x, -1, 5 ); + t.deepEqual( 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 Float64Array([ + 0.1, // 1 + 4.0, + -0.3, // 2 + 6.0, + -0.5, // 3 + 7.0, + -0.1, // 4 + 3.0 + ]); + expected = 2; + + idx = idamax( 4, x, 2, 0 ); + t.deepEqual( 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 Float64Array([ + 1.0, + 2.0, // 1 + 3.0, // 2 + 4.0, // 3 + 5.0, // 4 + 6.0 // 5 + ]); + expected = 4; + + idx = idamax( 5, x, 1, 1 ); + t.deepEqual( 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 Float64Array([ + 1.0, + 2.0, // 1 + 3.0, + 4.0, // 2 + 5.0, + 6.0 // 3 + ]); + expected = 2; + + idx = idamax( 3, x, 2, 1 ); + t.deepEqual( idx, expected, 'returns expected value' ); + t.end(); +}); From 9ff762b5f8a47bed57dc26263221eb8f3c0f1c98 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 11 Apr 2024 23:57:30 +0530 Subject: [PATCH 2/7] chore: apply review changes --- .../blas/base/idamax/benchmark/fortran/benchmark.kength.f | 2 +- .../blas/base/idamax/include/stdlib/blas/base/idamax_cblas.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.kength.f b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.kength.f index d7df44bd60a5..056d1c9d5a63 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.kength.f +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.kength.f @@ -157,7 +157,7 @@ end function idamax call cpu_time( t1 ) ! .. do i = 1, iterations - idx = idamax( len, x, 1, y, 1 ) + idx = idamax( len, x, 1 ) if ( idx /= idx ) then print '(A)', 'should not return NaN' exit diff --git a/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_cblas.h b/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_cblas.h index 3635d8037a1b..ee7aa1b679b6 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_cblas.h @@ -32,7 +32,7 @@ extern "C" { /** * Finds the index of the first element having maximum absolute value. */ -int cblas_idamax( const int N, double *X, const int strideX ); +int cblas_idamax( const int N, const double *X, const int strideX ); #ifdef __cplusplus } From b69917cfc8ce6eafa98ffc06c7ce1f63faad519a Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 11 Apr 2024 23:59:39 +0530 Subject: [PATCH 3/7] feat: add review changes --- .../benchmark/fortran/{benchmark.kength.f => benchmark.length.f} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/{benchmark.kength.f => benchmark.length.f} (100%) diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.kength.f b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.length.f similarity index 100% rename from lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.kength.f rename to lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.length.f From a0017e7b8887ea79994777667366f9dc6e07d1da Mon Sep 17 00:00:00 2001 From: aman-095 Date: Fri, 12 Apr 2024 00:01:13 +0530 Subject: [PATCH 4/7] feat: add review changes --- .../blas/base/idamax/benchmark/fortran/benchmark.length.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.length.f index 056d1c9d5a63..9c2409b4f69b 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.length.f +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.length.f @@ -27,7 +27,7 @@ program bench implicit none ! .. ! Local constants: - character(4), parameter :: name = 'idamax' ! if changed, be sure to adjust length + character(6), parameter :: name = 'idamax' ! if changed, be sure to adjust length integer, parameter :: iterations = 1000000 integer, parameter :: repeats = 3 integer, parameter :: min = 1 From e29f733aa1f256e03bcb027efc731f46725ee4af Mon Sep 17 00:00:00 2001 From: aman-095 Date: Fri, 12 Apr 2024 23:48:17 +0530 Subject: [PATCH 5/7] chore: apply review changes --- lib/node_modules/@stdlib/blas/base/idamax/README.md | 2 +- .../@stdlib/blas/base/idamax/benchmark/c/Makefile | 2 +- .../@stdlib/blas/base/idamax/benchmark/fortran/Makefile | 2 +- .../@stdlib/blas/base/idamax/examples/c/Makefile | 2 +- lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c | 5 +---- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/idamax/README.md b/lib/node_modules/@stdlib/blas/base/idamax/README.md index 5f70d6eb21e0..95cf6d993b61 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/README.md +++ b/lib/node_modules/@stdlib/blas/base/idamax/README.md @@ -93,7 +93,7 @@ var idx = idamax.ndarray( x.length, x, 1, 0 ); The function has the following additional parameters: -- **offset**: starting index. +- **offsetX**: starting index. While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the `offset` parameter supports indexing semantics based on a starting index. For example, to find the index of the element having the maximum absolute value starting from second index, diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/Makefile index 2234f32350a9..8ef44769c199 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2019 The Stdlib Authors. +# Copyright (c) 2024 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/Makefile index a029be690fbf..f0e61d434240 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/Makefile +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2019 The Stdlib Authors. +# Copyright (c) 2024 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/idamax/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/idamax/examples/c/Makefile index 0b17b69f43de..c34b13fb446d 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/examples/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/idamax/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2020 The Stdlib Authors. +# Copyright (c) 2024 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c index 4be162dd1403..859067708868 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c @@ -27,8 +27,5 @@ * @param strideX index increment for `x` */ int c_idamax( const int N, const double *X, const int strideX ) { - int idx; - - idx = cblas_idamax( N, X, strideX ); - return idx; + return cblas_idamax( N, X, strideX ); } From 16c849a5472a820d1efa7f0708c832e6445aa717 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Tue, 16 Apr 2024 03:48:50 -0700 Subject: [PATCH 6/7] refactor: update descriptions, tests, and implementations --- .../@stdlib/blas/base/idamax/README.md | 14 +- .../blas/base/idamax/benchmark/c/Makefile | 31 ++- .../idamax/benchmark/c/benchmark.length.c | 10 +- .../benchmark/fortran/benchmark.length.f | 14 +- .../@stdlib/blas/base/idamax/docs/repl.txt | 12 +- .../blas/base/idamax/docs/types/index.d.ts | 10 +- .../blas/base/idamax/examples/c/Makefile | 33 ++- .../idamax/include/stdlib/blas/base/idamax.h | 2 +- .../include/stdlib/blas/base/idamax_cblas.h | 2 +- .../include/stdlib/blas/base/idamax_fortran.h | 2 +- .../@stdlib/blas/base/idamax/lib/idamax.js | 22 +- .../blas/base/idamax/lib/idamax.native.js | 4 +- .../@stdlib/blas/base/idamax/lib/index.js | 2 +- .../@stdlib/blas/base/idamax/lib/ndarray.js | 19 +- .../blas/base/idamax/lib/ndarray.native.js | 7 +- .../@stdlib/blas/base/idamax/manifest.json | 235 +++++++++++++++++- .../@stdlib/blas/base/idamax/package.json | 6 +- .../@stdlib/blas/base/idamax/src/addon.c | 2 +- .../@stdlib/blas/base/idamax/src/idamax.c | 33 +-- .../@stdlib/blas/base/idamax/src/idamax.f | 13 +- .../blas/base/idamax/src/idamax_cblas.c | 9 +- .../@stdlib/blas/base/idamax/src/idamax_f.c | 11 +- .../@stdlib/blas/base/idamax/src/idamaxsub.f | 8 +- .../blas/base/idamax/test/test.idamax.js | 14 +- .../base/idamax/test/test.idamax.native.js | 14 +- .../blas/base/idamax/test/test.ndarray.js | 16 +- .../base/idamax/test/test.ndarray.native.js | 16 +- 27 files changed, 411 insertions(+), 150 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/idamax/README.md b/lib/node_modules/@stdlib/blas/base/idamax/README.md index 95cf6d993b61..c8f7673baf97 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/README.md +++ b/lib/node_modules/@stdlib/blas/base/idamax/README.md @@ -20,7 +20,7 @@ limitations under the License. # idamax -> Find the index of the first element having maximum absolute value. +> Find the index of the first element having the maximum absolute value.
@@ -32,7 +32,7 @@ var idamax = require( '@stdlib/blas/base/idamax' ); #### idamax( N, x, strideX ) -Finds the index of the first element having maximum absolute value. +Finds the index of the first element having the maximum absolute value. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -49,7 +49,7 @@ The function has the following parameters: - **x**: input [`Float64Array`][@stdlib/array/float64]. - **strideX**: index increment for `x`. -The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. For example, to find index of element having maximum absolute value traversing 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 Float64Array = require( '@stdlib/array/float64' ); @@ -71,16 +71,14 @@ var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); // Create an offset view: var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -// Find index of element having maximum absolute value for every other element... +// Find index of element having the maximum absolute value: var idx = idamax( 3, x1, 2 ); // returns 2 ``` -If either `N` is less than `1` or `strideX` is less than or equal to `0`, the function returns `0`. - #### idamax.ndarray( N, x, strideX, offset ) -Finds the index of the first element having maximum absolute value using alternative indexing semantics. +Finds the index of the first element having the maximum absolute value using alternative indexing semantics. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -95,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 find the index of the element having the maximum absolute value starting from second 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 Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/Makefile index 8ef44769c199..9f97140e7cb0 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/Makefile @@ -69,8 +69,17 @@ else fPIC ?= -fPIC endif +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + # List of source files: -c_src := ../../src/idamax.c +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= # List of C targets: c_targets := benchmark.length.out @@ -79,11 +88,15 @@ c_targets := benchmark.length.out # RULES # #/ -# Compiles C source files. +# Compiles source files. # # @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) # @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`) +# @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 @@ -99,12 +112,16 @@ all: $(c_targets) # Compiles C source files. # # @private -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +# @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) -I ../../include -o $@ $(c_src) $< -lm + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) #/ # Runs compiled benchmarks. diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/benchmark.length.c index 9a23444cf58b..0232f06156b7 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/c/benchmark.length.c @@ -100,8 +100,8 @@ double rand_double( void ) { double benchmark( int iterations, int len ) { double elapsed; double x[ len ]; - double idx; double t; + int idx; int i; for ( i = 0; i < len; i++ ) { @@ -111,14 +111,14 @@ double benchmark( int iterations, int len ) { t = tic(); for ( i = 0; i < iterations; i++ ) { idx = c_idamax( len, x, 1 ); - if ( idx != idx ) { - printf( "should not return NaN\n" ); + if ( idx < -2 ) { + printf( "unexpected result\n" ); break; } } elapsed = tic() - t; - if ( idx != idx ) { - printf( "should not return NaN\n" ); + if ( idx < -2 ) { + printf( "unexpected result\n" ); } return elapsed; } diff --git a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.length.f index 9c2409b4f69b..f1630549c8fd 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.length.f +++ b/lib/node_modules/@stdlib/blas/base/idamax/benchmark/fortran/benchmark.length.f @@ -134,9 +134,9 @@ end function idamax integer, intent(in) :: iterations, len ! .. ! Local scalars: - integer :: idx double precision :: elapsed, r double precision :: t1, t2 + integer :: idx integer :: i ! .. ! Local arrays: @@ -150,16 +150,16 @@ end function idamax ! .. do i = 1, len call random_number( r ) - x( i ) = ( r*2000.0 ) - 1000.0 + x( i ) = ( r*2000.0d0 ) - 1000.0d0 end do ! .. - idx = -1 call cpu_time( t1 ) ! .. + idx = 0 do i = 1, iterations idx = idamax( len, x, 1 ) - if ( idx /= idx ) then - print '(A)', 'should not return NaN' + if ( idx < 0 .OR. idx > len ) then + print '(A)', 'unexpected result' exit end if end do @@ -168,8 +168,8 @@ end function idamax ! .. elapsed = t2 - t1 ! .. - if ( idx /= idx ) then - print '(A)', 'should not return NaN' + if ( idx < 0 .OR. idx > len ) then + print '(A)', 'unexpected result' end if ! .. ! Deallocate arrays: diff --git a/lib/node_modules/@stdlib/blas/base/idamax/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/idamax/docs/repl.txt index 95ac97c54f75..97f31b384727 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/idamax/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( N, x, strideX ) - Finds the index of the first element having maximum absolute value. + Finds the index of the first element having the maximum absolute value. The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. @@ -8,7 +8,7 @@ Indexing is relative to the first index. To introduce an offset, use typed array views. - If `N < 1` or `strideX <= 0`, the function returns `0`. + If `N < 1` or `strideX <= 0`, the function returns `-1`. Parameters ---------- @@ -35,18 +35,18 @@ // Using `N` and `strideX` parameters: > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0 ] ); - > var idx = {{alias}}( 2, x, 2 ) + > idx = {{alias}}( 2, x, 2 ) 1 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > var idx = {{alias}}( 3, x1, 1 ) + > idx = {{alias}}( 3, x1, 1 ) 2 {{alias}}.ndarray( N, x, strideX, offsetX ) - Finds the index of the first element having maximum absolute value using + 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 @@ -81,7 +81,7 @@ // Using an index offset: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); - > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + > idx = {{alias}}.ndarray( 3, x, 2, 1 ) 2 See Also diff --git a/lib/node_modules/@stdlib/blas/base/idamax/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/idamax/docs/types/index.d.ts index 28bded096af4..4cc63d8c76b2 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/idamax/docs/types/index.d.ts @@ -23,7 +23,7 @@ */ interface Routine { /** - * Finds the index of the first element having maximum absolute value. + * Finds the index of the first element having the maximum absolute value. * * @param N - number of indexed elements * @param x - input array @@ -41,7 +41,7 @@ interface Routine { ( N: number, x: Float64Array, strideX: number ): number; /** - * Finds the index of the first element having maximum absolute value using alternative indexing semantics. + * Finds the index of the first element having the maximum absolute value using alternative indexing semantics. * * @param N - number of indexed elements * @param x - input array @@ -61,7 +61,7 @@ interface Routine { } /** -* Finds the index of the first element having maximum absolute value. +* Finds the index of the first element having the maximum absolute value. * * @param N - number of indexed elements * @param x - input array @@ -81,8 +81,8 @@ interface Routine { * * var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); * -* var idx = idamax.ndarray( x.length, x, 1, 1 ); -* // returns 2 +* var idx = idamax.ndarray( x.length, x, 1, 0 ); +* // returns 3 */ declare var idamax: Routine; diff --git a/lib/node_modules/@stdlib/blas/base/idamax/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/idamax/examples/c/Makefile index c34b13fb446d..6aed70daf167 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/examples/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/idamax/examples/c/Makefile @@ -69,8 +69,17 @@ else fPIC ?= -fPIC endif +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + # List of source files: -c_src := ../../src/idamax.c +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 @@ -79,11 +88,15 @@ c_targets := example.out # RULES # #/ -# Compiles C source files. +# Compiles source files. # # @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) # @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`) +# @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 @@ -99,15 +112,19 @@ all: $(c_targets) # Compiles C source files. # # @private -# @param {string} CC - C compiler -# @param {string} CFLAGS - C compiler flags -# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +# @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) -I ../../include -o $@ $(c_src) $< -lm + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) #/ -# Runs compiled benchmarks. +# Runs compiled examples. # # @example # make run diff --git a/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax.h b/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax.h index c1a0db04cf85..2288ac6057f6 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax.h +++ b/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax.h @@ -30,7 +30,7 @@ extern "C" { #endif /** -* Finds the index of the first element having maximum absolute value. +* Finds the index of the first element having the maximum absolute value. */ int c_idamax( const int N, const double *X, const int strideX ); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_cblas.h b/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_cblas.h index ee7aa1b679b6..e44daf4ab014 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_cblas.h @@ -30,7 +30,7 @@ extern "C" { #endif /** -* Finds the index of the first element having maximum absolute value. +* Finds the index of the first element having the maximum absolute value. */ int cblas_idamax( const int N, const double *X, const int strideX ); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_fortran.h b/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_fortran.h index f82050368e9a..fe340f72181b 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_fortran.h +++ b/lib/node_modules/@stdlib/blas/base/idamax/include/stdlib/blas/base/idamax_fortran.h @@ -30,7 +30,7 @@ extern "C" { #endif /** -* Finds the index of the first element having maximum absolute value. +* Finds the index of the first element having the maximum absolute value. */ void idamaxsub( const int *, const double *, const int *, int * ); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.js b/lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.js index fc8b4f8b02f6..524eba592ecf 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.js +++ b/lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.js @@ -26,12 +26,12 @@ var abs = require( '@stdlib/math/base/special/abs' ); // MAIN // /** -* Finds the index of the first element having maximum absolute value. +* Finds the index of the first element having the maximum absolute value. * * @param {PositiveInteger} N - number of indexed elements -* @param {Float64Array} x - first input array +* @param {Float64Array} x - input array * @param {integer} strideX - `x` stride length -* @returns {integer} index of the first element having maximum absolute value +* @returns {integer} index value * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -45,12 +45,13 @@ function idamax( N, x, strideX ) { var dmax; var idx; var ix; + var v; var i; - idx = 0; if ( N < 1 || strideX <= 0 ) { return -1; } + idx = 0; if ( N === 1 ) { return idx; } @@ -58,21 +59,22 @@ function idamax( N, x, strideX ) { // Code for stride equal to `1`... dmax = abs( x[ 0 ] ); for ( i = 1; i < N; i++ ) { - if ( abs( x[ i ] ) > dmax ) { + v = abs( x[ i ] ); + if ( v > dmax ) { idx = i; - dmax = abs( x[ i ] ); + dmax = v; } } return idx; } // Code for stride not equal to `1`... - ix = 0; dmax = abs( x[ 0 ] ); - ix += strideX; + ix = strideX; for ( i = 1; i < N; i++ ) { - if ( abs( x[ ix ] ) > dmax ) { + v = abs( x[ ix ] ); + if ( v > dmax ) { idx = i; - dmax = abs( x[ ix ] ); + dmax = v; } ix += strideX; } diff --git a/lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.native.js b/lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.native.js index eb1823e19216..4b4a5bea34b6 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.native.js +++ b/lib/node_modules/@stdlib/blas/base/idamax/lib/idamax.native.js @@ -26,10 +26,10 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Finds the index of the first element having maximum absolute value. +* Finds the index of the first element having the maximum absolute value. * * @param {PositiveInteger} N - number of indexed elements -* @param {Float64Array} x - first input array +* @param {Float64Array} x - input array * @param {integer} strideX - `x` stride length * @returns {integer} index value * diff --git a/lib/node_modules/@stdlib/blas/base/idamax/lib/index.js b/lib/node_modules/@stdlib/blas/base/idamax/lib/index.js index 1e19f57085a3..67386b986619 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/idamax/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 1 routine to find the index of the first element having maximum absolute value. +* BLAS level 1 routine to find the index of the first element having the maximum absolute value. * * @module @stdlib/blas/base/idamax * diff --git a/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.js index ca05bdc5da0c..8b9fd18fc99b 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.js @@ -26,13 +26,13 @@ var abs = require( '@stdlib/math/base/special/abs' ); // MAIN // /** -* Finds the index of the first element having maximum absolute value. +* Finds the index of the first element having the maximum absolute value. * * @param {PositiveInteger} N - number of indexed elements -* @param {Float64Array} x - first input array +* @param {Float64Array} x - input array * @param {integer} strideX - `x` stride length * @param {NonNegativeInteger} offsetX - starting index for `x` -* @returns {integer} index of the first element having maximum absolute value +* @returns {integer} index value * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -46,22 +46,23 @@ function idamax( N, x, strideX, offsetX ) { var dmax; var idx; var ix; + var v; var i; - idx = 0; if ( N < 1 || strideX <= 0 ) { return -1; } + idx = 0; if ( N === 1 ) { return idx; } - ix = offsetX; - dmax = abs( x[ 0 ] ); - ix += strideX; + dmax = abs( x[ offsetX ] ); + ix = offsetX + strideX; for ( i = 1; i < N; i++ ) { - if ( abs( x[ ix ] ) > dmax ) { + v = abs( x[ ix ] ); + if ( v > dmax ) { idx = i; - dmax = abs( x[ ix ] ); + dmax = v; } ix += strideX; } diff --git a/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.native.js index 98a995228738..e7333942ccc7 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.native.js @@ -28,10 +28,10 @@ var addon = require( './idamax.native.js' ); // MAIN // /** -* Finds the index of the first element having maximum absolute value. +* Finds the index of the first element having the maximum absolute value. * * @param {integer} N - number of indexed elements -* @param {Float64Array} x - first input array +* @param {Float64Array} x - input array * @param {integer} strideX - `x` stride length * @param {NonNegativeInteger} offsetX - starting index for `x` * @returns {integer} index value @@ -46,11 +46,8 @@ var addon = require( './idamax.native.js' ); */ function idamax( N, x, strideX, offsetX ) { var viewX; - offsetX = minViewBufferIndex( N, strideX, offsetX ); - viewX = offsetView( x, offsetX ); - return addon( N, viewX, strideX ); } diff --git a/lib/node_modules/@stdlib/blas/base/idamax/manifest.json b/lib/node_modules/@stdlib/blas/base/idamax/manifest.json index 603c7bff78d8..f1049aaf9fbe 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/idamax/manifest.json @@ -1,5 +1,6 @@ { "options": { + "task": "build", "os": "linux", "blas": "", "wasm": false @@ -28,6 +29,7 @@ ], "confs": [ { + "task": "build", "os": "linux", "blas": "", "wasm": false, @@ -45,10 +47,47 @@ "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float64array" + "@stdlib/napi/argv-strided-float64array", + "@stdlib/math/base/special/abs" ] }, { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/idamax.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/abs" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/idamax.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/abs" + ] + }, + + { + "task": "build", "os": "linux", "blas": "openblas", "wasm": false, @@ -71,6 +110,44 @@ ] }, { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/idamax_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/idamax_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [] + }, + + { + "task": "build", "os": "mac", "blas": "", "wasm": false, @@ -88,10 +165,47 @@ "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float64array" + "@stdlib/napi/argv-strided-float64array", + "@stdlib/math/base/special/abs" ] }, { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/idamax.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/abs" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/idamax.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/abs" + ] + }, + + { + "task": "build", "os": "mac", "blas": "apple_accelerate_framework", "wasm": false, @@ -113,6 +227,42 @@ ] }, { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/idamax_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/idamax_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [] + }, + + { + "task": "build", "os": "mac", "blas": "openblas", "wasm": false, @@ -135,6 +285,44 @@ ] }, { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/idamax_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/idamax_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [] + }, + + { + "task": "build", "os": "win", "blas": "", "wasm": false, @@ -150,10 +338,47 @@ "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float64array" + "@stdlib/napi/argv-strided-float64array", + "@stdlib/math/base/special/abs" ] }, { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/idamax.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/abs" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/idamax.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/abs" + ] + }, + + { + "task": "build", "os": "", "blas": "", "wasm": true, @@ -165,7 +390,9 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/math/base/special/abs" + ] } ] } diff --git a/lib/node_modules/@stdlib/blas/base/idamax/package.json b/lib/node_modules/@stdlib/blas/base/idamax/package.json index 2823ada33719..0fb84ee480e9 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/package.json +++ b/lib/node_modules/@stdlib/blas/base/idamax/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/idamax", "version": "0.0.0", - "description": "Find the index of the first element having maximum absolute value.", + "description": "Find the index of the first element having the maximum absolute value.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -61,6 +61,10 @@ "level 1", "idamax", "maximum", + "abs", + "absolute", + "find", + "index", "linear", "algebra", "subroutines", diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/addon.c b/lib/node_modules/@stdlib/blas/base/idamax/src/addon.c index d76418ba34d7..63776a7e6144 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/addon.c @@ -39,7 +39,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); napi_value idx; - napi_status status = napi_create_int64( env, c_idamax( N, X, strideX ), &idx ); + napi_status status = napi_create_int32( env, c_idamax( N, X, strideX ), &idx ); // TODO: revisit once we support 64-bit integers as return values and 64 integers more generally in JavaScript assert( status == napi_ok ); return idx; } diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.c b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.c index 829d6a4c5be6..f63236119ad5 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.c +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.c @@ -17,47 +17,50 @@ */ #include "stdlib/blas/base/idamax.h" -#include +#include "stdlib/math/base/special/abs.h" /** -* Finds the index of the first element having maximum fabsolute value. +* Finds the index of the first element having the maximum absolute value. * -* @param N number of indexed elements -* @param X input array -* @param strideX index increment for `x` +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @return index value */ int c_idamax( const int N, const double *X, const int strideX ) { double dmax; + double v; int idx; int ix; int i; - idx = 0; if ( N < 1 || strideX <= 0 ) { return -1; } + idx = 0; if ( N == 1 ) { return idx; } - if (strideX == 1 ) { + if ( strideX == 1 ) { // Code for stride equal to `1`... - dmax = fabs( X[ 0 ] ); + dmax = stdlib_base_abs( X[ 0 ] ); for ( i = 1; i < N; i++ ) { - if ( fabs( X[ i ] ) > dmax ) { + v = stdlib_base_abs( X[ i ] ); + if ( v > dmax ) { idx = i; - dmax = fabs( X[ i ] ); + dmax = v; } } return idx; } // Code for stride not equal to `1`... - ix = 0; - dmax = fabs( X[ 0 ] ); - ix += strideX; + dmax = stdlib_base_abs( X[ 0 ] ); + ix = strideX; for ( i = 1; i < N; i++ ) { - if ( fabs( X[ ix ] ) > dmax ) { + v = stdlib_base_abs( X[ ix ] ); + if ( v > dmax ) { idx = i; - dmax = fabs( X[ ix ] ); + dmax = v; } ix += strideX; } diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f index e510d697220b..4361fb2557dc 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f @@ -16,7 +16,7 @@ ! limitations under the License. !< -!> Find the index of the first element having maximum absolute value. +!> Find the index of the first element having the maximum absolute value. ! ! ## Notes ! @@ -51,6 +51,7 @@ ! @param {integer} N - number of indexed elements ! @param {Array} dx - input array ! @param {integer} stride - `dx` stride length +! @returns {integer} index value !< integer function idamax( N, dx, stride ) implicit none @@ -68,25 +69,23 @@ integer function idamax( N, dx, stride ) ! Intrinsic functions: intrinsic DABS ! .. - IDAMAX = 0 + idamax = 0 if ( N < 1 .OR. stride <= 0 ) then return end if - IDAMAX = 1 + idamax = 1 ! .. - ! If N is equal to `1`, return early... if ( N == 1 ) then return end if ! .. - ! If stride is equal to `1`, use unrolled loops... if ( stride == 1 ) then ! .. ! Code for increment equal to `1`... dmax = DABS( dx( 1 ) ) do i = 2, N if ( DABS( dx( i ) ) > dmax ) then - IDAMAX = i + idamax = i dmax = DABS( dx( i ) ) end if end do @@ -99,7 +98,7 @@ integer function idamax( N, dx, stride ) do i = 2, N ix = ix + stride if ( DABS( dx( ix ) ) > dmax ) then - IDAMAX = i + idamax = i dmax = DABS( dx( ix ) ) end if end do diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c index 859067708868..6c7fd60c7d34 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_cblas.c @@ -20,11 +20,12 @@ #include "stdlib/blas/base/idamax_cblas.h" /** -* Finds the index of the first element having maximum absolute value. +* Finds the index of the first element having the maximum absolute value. * -* @param N number of indexed elements -* @param X input array -* @param strideX index increment for `x` +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @returns index value */ int c_idamax( const int N, const double *X, const int strideX ) { return cblas_idamax( N, X, strideX ); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_f.c b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_f.c index 47232703f222..e86dc0cb504c 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_f.c +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax_f.c @@ -16,20 +16,15 @@ * limitations under the License. */ -/** - * Find the index of the first element having maximum absolute value. - * - * @see idamax - */ #include "stdlib/blas/base/idamax.h" #include "stdlib/blas/base/idamax_fortran.h" /** -* Finds the index of the first element having maximum absolute value. +* Finds the index of the first element having the maximum absolute value. * * @param N number of indexed elements -* @param X first array -* @param strideX X stride length +* @param X input array +* @param strideX stride length * @return index value */ int c_idamax( const int N, const double *X, const int strideX ) { diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/idamaxsub.f b/lib/node_modules/@stdlib/blas/base/idamax/src/idamaxsub.f index 8ce187798f8c..bf8ef3defab3 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/src/idamaxsub.f +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/idamaxsub.f @@ -19,9 +19,9 @@ !> Wraps `idamax` as a subroutine. ! ! @param {integer} N - number of indexed elements -! @param {Array} dx - first array -! @param {integer} strideX - `dx` stride length -! @param {integer} index - output variable reference +! @param {Array} dx - input array +! @param {integer} strideX - stride length +! @param {integer} idx - output variable reference !< subroutine idamaxsub( N, dx, strideX, idx ) implicit none @@ -40,7 +40,7 @@ end function idamax ! Array arguments: double precision :: dx(*) ! .. - ! Compute the dot product: + ! Find the maximum absolute value: idx = idamax( N, dx, strideX ) return end subroutine idamaxsub \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.js b/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.js index 25c196ad0111..0de758449243 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.js +++ b/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.js @@ -55,7 +55,7 @@ tape( 'the function finds the index of the element with the maximum absolute val expected = 2; idx = idamax( 4, x, 1 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); x = new Float64Array( [ 0.2, // 1 @@ -67,7 +67,7 @@ tape( 'the function finds the index of the element with the maximum absolute val expected = 1; idx = idamax( 3, x, 1 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -85,7 +85,7 @@ tape( 'if provided an `N` parameter less than `1`, the function returns `-1`', f expected = -1; idx = idamax( 0, x, 1 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -99,10 +99,10 @@ tape( 'if provided a `strideX` parameter less than or equal to `0`, the function expected = -1; idx = idamax( x.length, x, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); idx = idamax( x.length, x, -1 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -125,7 +125,7 @@ tape( 'the function supports specifying a stride', function test( t ) { expected = 2; idx = idamax( 4, x, 2 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -148,6 +148,6 @@ tape( 'the function supports view offsets', function test( t ) { x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); idx = idamax( 3, x1, 2 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.native.js b/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.native.js index 245515e191da..b1aeead33bab 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.native.js +++ b/lib/node_modules/@stdlib/blas/base/idamax/test/test.idamax.native.js @@ -64,7 +64,7 @@ tape( 'the function finds the index of the element with the maximum absolute val expected = 2; idx = idamax( 4, x, 1 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); x = new Float64Array( [ 0.2, // 1 @@ -76,7 +76,7 @@ tape( 'the function finds the index of the element with the maximum absolute val expected = 1; idx = idamax( 3, x, 1 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -94,7 +94,7 @@ tape( 'if provided an `N` parameter less than `1`, the function returns `-1`', o expected = -1; idx = idamax( 0, x, 1 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -108,10 +108,10 @@ tape( 'if provided a `strideX` parameter less than or equal to `0`, the function expected = -1; idx = idamax( x.length, x, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); idx = idamax( x.length, x, -1 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -134,7 +134,7 @@ tape( 'the function supports specifying a stride', opts, function test( t ) { expected = 2; idx = idamax( 4, x, 2 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -157,6 +157,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); idx = idamax( 3, x1, 2 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.js index d5ad8f3bf2ee..09e33858adf9 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.js @@ -55,7 +55,7 @@ tape( 'the function finds the index of the element with the maximum absolute val expected = 2; idx = idamax( 4, x, 1, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); x = new Float64Array( [ 0.2, // 1 @@ -67,7 +67,7 @@ tape( 'the function finds the index of the element with the maximum absolute val expected = 1; idx = idamax( 3, x, 1, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -85,7 +85,7 @@ tape( 'if provided an `N` parameter less than `1`, the function returns `0`', fu expected = -1; idx = idamax( 0, x, 1, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -99,10 +99,10 @@ tape( 'if provided a `strideX` parameter less than or equal to `0`, the function expected = -1; idx = idamax( x.length, x, 0, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); idx = idamax( x.length, x, -1, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -125,7 +125,7 @@ tape( 'the function supports specifying a stride', function test( t ) { expected = 2; idx = idamax( 4, x, 2, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -145,7 +145,7 @@ tape( 'the function supports specifying an `x` offset', function test( t ) { expected = 4; idx = idamax( 5, x, 1, 1 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -165,6 +165,6 @@ tape( 'the function supports complex access patterns', function test( t ) { expected = 2; idx = idamax( 3, x, 2, 1 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.native.js index f84818e730ad..3f081a3a5f53 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/idamax/test/test.ndarray.native.js @@ -64,7 +64,7 @@ tape( 'the function finds the index of the element with the maximum absolute val expected = 2; idx = idamax( 4, x, 1, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); x = new Float64Array( [ 0.2, // 1 @@ -76,7 +76,7 @@ tape( 'the function finds the index of the element with the maximum absolute val expected = 1; idx = idamax( 3, x, 1, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -94,7 +94,7 @@ tape( 'if provided an `N` parameter less than `1`, the function returns `0`', op expected = -1; idx = idamax( 0, x, 1, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -108,10 +108,10 @@ tape( 'if provided a `strideX` parameter less than or equal to `0`, the function expected = -1; idx = idamax( x.length, x, 0, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); idx = idamax( x.length, x, -1, 5 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -134,7 +134,7 @@ tape( 'the function supports specifying a stride', opts, function test( t ) { expected = 2; idx = idamax( 4, x, 2, 0 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -154,7 +154,7 @@ tape( 'the function supports specifying an `x` offset', opts, function test( t ) expected = 4; idx = idamax( 5, x, 1, 1 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); @@ -174,6 +174,6 @@ tape( 'the function supports complex access patterns', opts, function test( t ) expected = 2; idx = idamax( 3, x, 2, 1 ); - t.deepEqual( idx, expected, 'returns expected value' ); + t.strictEqual( idx, expected, 'returns expected value' ); t.end(); }); From 18b8dd64c13553446fc4127039a2179a990635b5 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Tue, 16 Apr 2024 03:57:13 -0700 Subject: [PATCH 7/7] docs: update description --- lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f index 4361fb2557dc..e3e68d92a76f 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f +++ b/lib/node_modules/@stdlib/blas/base/idamax/src/idamax.f @@ -16,7 +16,7 @@ ! limitations under the License. !< -!> Find the index of the first element having the maximum absolute value. +!> Finds the index of the first element having the maximum absolute value. ! ! ## Notes !