diff --git a/lib/node_modules/@stdlib/blas/base/idamax/README.md b/lib/node_modules/@stdlib/blas/base/idamax/README.md index 1b541821d9d..56cf4f873cc 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/README.md +++ b/lib/node_modules/@stdlib/blas/base/idamax/README.md @@ -112,7 +112,7 @@ var idx = idamax.ndarray( 5, x, 1, 1 ); ## Notes -- If `N < 1` or `strideX <= 0`, both functions return `-1`. +- If `N < 1`, both functions return `-1`. - `idamax()` corresponds to the [BLAS][blas] level 1 function [`idamax`][idamax]. @@ -157,7 +157,7 @@ console.log( idx ); [blas]: http://www.netlib.org/blas -[idamax]: http://www.netlib.org/lapack/explore-html/de/da4/group__double__blas__level1.html +[idamax]: https://netlib.org/lapack/explore-html/dd/de0/idamax_8f_source.html [@stdlib/array/float64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float64 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 97f31b38472..5b82171255c 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/idamax/docs/repl.txt @@ -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 `-1`. + If `N < 1`, both functions return `-1`. Parameters ---------- 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 8b9fd18fc99..48543ebcf34 100644 --- a/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/idamax/lib/ndarray.js @@ -49,7 +49,7 @@ function idamax( N, x, strideX, offsetX ) { var v; var i; - if ( N < 1 || strideX <= 0 ) { + if ( N < 1 ) { return -1; } idx = 0; 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 e7333942ccc..f4123a9e92b 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 @@ -48,6 +48,9 @@ function idamax( N, x, strideX, offsetX ) { var viewX; offsetX = minViewBufferIndex( N, strideX, offsetX ); viewX = offsetView( x, offsetX ); + if ( strideX < 0 ) { + return N - 1 - addon( N, viewX, -strideX ); + } return addon( N, viewX, strideX ); } 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 6a53cb7a07c..86f5977c4bd 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 @@ -108,19 +108,21 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun t.end(); }); -tape( 'if provided a `strideX` parameter less than or equal to `0`, the function returns `-1`', function test( t ) { - var expected; +tape( 'the function supports accessing elements in reverse order', function test( t ) { 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.strictEqual( idx, expected, 'returns expected value' ); + idx = idamax( x.length, x, -1, x.length-1 ); + t.strictEqual( idx, 2, 'returns expected value' ); - idx = idamax( x.length, x, -1, 0 ); - t.strictEqual( idx, expected, 'returns expected value' ); + idx = idamax( 3, x, -1, x.length-4 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + x = new Float64Array( [ 3.0, 999.9, 999.9, -4.0, 999.9, 999.9, 1.0, 999.9, 999.9, 15.0, 999.9, 999.9, 4.0, 999.9, 999.9, 3.0 ] ); + idx = idamax( 6, x, -3, x.length-1 ); + t.strictEqual( idx, 2, '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 320ed6b0e09..92e9cf0c059 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 @@ -117,19 +117,21 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', opt t.end(); }); -tape( 'if provided a `strideX` parameter less than or equal to `0`, the function returns `-1`', opts, function test( t ) { - var expected; +tape( 'the function supports accessing elements in reverse order', function test( t ) { 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.strictEqual( idx, expected, 'returns expected value' ); + idx = idamax( x.length, x, -1, x.length-1 ); + t.strictEqual( idx, 2, 'returns expected value' ); - idx = idamax( x.length, x, -1, 5 ); - t.strictEqual( idx, expected, 'returns expected value' ); + idx = idamax( 3, x, -1, x.length-4 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + x = new Float64Array( [ 3.0, 999.9, 999.9, -4.0, 999.9, 999.9, 1.0, 999.9, 999.9, 15.0, 999.9, 999.9, 4.0, 999.9, 999.9, 3.0 ] ); + idx = idamax( 6, x, -3, x.length-1 ); + t.strictEqual( idx, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/isamax/README.md b/lib/node_modules/@stdlib/blas/base/isamax/README.md index 77fe942d764..7fce18ad218 100644 --- a/lib/node_modules/@stdlib/blas/base/isamax/README.md +++ b/lib/node_modules/@stdlib/blas/base/isamax/README.md @@ -112,7 +112,7 @@ var idx = isamax.ndarray( 5, x, 1, 1 ); ## Notes -- If `N < 1` or `strideX <= 0`, both functions return `-1`. +- If `N < 1`, both functions return `-1`. - `isamax()` corresponds to the [BLAS][blas] level 1 function [`isamax`][isamax]. diff --git a/lib/node_modules/@stdlib/blas/base/isamax/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/isamax/docs/repl.txt index 747106f0cbe..2b19fedb391 100644 --- a/lib/node_modules/@stdlib/blas/base/isamax/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/isamax/docs/repl.txt @@ -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 `-1`. + If `N < 1`, both functions return `-1`. Parameters ---------- diff --git a/lib/node_modules/@stdlib/blas/base/isamax/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/isamax/lib/ndarray.js index 2237b76c769..5258ebd00af 100644 --- a/lib/node_modules/@stdlib/blas/base/isamax/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/isamax/lib/ndarray.js @@ -49,7 +49,7 @@ function isamax( N, x, strideX, offsetX ) { var v; var i; - if ( N < 1 || strideX <= 0 ) { + if ( N < 1 ) { return -1; } idx = 0; diff --git a/lib/node_modules/@stdlib/blas/base/isamax/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/isamax/lib/ndarray.native.js index 942c8a9f883..a9284dcbd7b 100644 --- a/lib/node_modules/@stdlib/blas/base/isamax/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/isamax/lib/ndarray.native.js @@ -48,6 +48,9 @@ function isamax( N, x, strideX, offsetX ) { var viewX; offsetX = minViewBufferIndex( N, strideX, offsetX ); viewX = offsetView( x, offsetX ); + if ( strideX < 0 ) { + return N - 1 - addon( N, viewX, -strideX ); + } return addon( N, viewX, strideX ); } diff --git a/lib/node_modules/@stdlib/blas/base/isamax/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/isamax/test/test.ndarray.js index 9f80610832b..8431cfac569 100644 --- a/lib/node_modules/@stdlib/blas/base/isamax/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/isamax/test/test.ndarray.js @@ -108,19 +108,21 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', fun t.end(); }); -tape( 'if provided a `strideX` parameter less than or equal to `0`, the function returns `-1`', function test( t ) { - var expected; +tape( 'the function supports accessing elements in reverse order', function test( t ) { var idx; var x; x = new Float32Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] ); - expected = -1; - idx = isamax( x.length, x, 0, 0 ); - t.strictEqual( idx, expected, 'returns expected value' ); + idx = isamax( x.length, x, -1, x.length-1 ); + t.strictEqual( idx, 2, 'returns expected value' ); - idx = isamax( x.length, x, -1, 0 ); - t.strictEqual( idx, expected, 'returns expected value' ); + idx = isamax( 3, x, -1, x.length-4 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + x = new Float32Array( [ 3.0, 999.9, 999.9, -4.0, 999.9, 999.9, 1.0, 999.9, 999.9, 15.0, 999.9, 999.9, 4.0, 999.9, 999.9, 3.0 ] ); + idx = isamax( 6, x, -3, x.length-1 ); + t.strictEqual( idx, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/isamax/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/isamax/test/test.ndarray.native.js index f3e580cf10a..3debe7824ab 100644 --- a/lib/node_modules/@stdlib/blas/base/isamax/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/isamax/test/test.ndarray.native.js @@ -117,19 +117,21 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns `0`', opt t.end(); }); -tape( 'if provided a `strideX` parameter less than or equal to `0`, the function returns `-1`', opts, function test( t ) { - var expected; +tape( 'the function supports accessing elements in reverse order', function test( t ) { var idx; var x; x = new Float32Array( [ 3.0, -4.0, 1.0, 15.0, 4.0, 3.0 ] ); - expected = -1; - idx = isamax( x.length, x, 0, 0 ); - t.strictEqual( idx, expected, 'returns expected value' ); + idx = isamax( x.length, x, -1, x.length-1 ); + t.strictEqual( idx, 2, 'returns expected value' ); - idx = isamax( x.length, x, -1, 5 ); - t.strictEqual( idx, expected, 'returns expected value' ); + idx = isamax( 3, x, -1, x.length-4 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + x = new Float32Array( [ 3.0, 999.9, 999.9, -4.0, 999.9, 999.9, 1.0, 999.9, 999.9, 15.0, 999.9, 999.9, 4.0, 999.9, 999.9, 3.0 ] ); + idx = isamax( 6, x, -3, x.length-1 ); + t.strictEqual( idx, 2, 'returns expected value' ); t.end(); });