diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/README.md b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/README.md index d8452e9cd87b..ca41f95d08a8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/README.md @@ -28,6 +28,8 @@ limitations under the License. + +
## Usage @@ -196,17 +198,20 @@ var out = cindexOfColumn.ndarray( 2, 2, A, 1, 2, 0, x, 1, 0, workspace, 1, 0 ); + +
## Notes -- If `M <= 0` or `N <= 0`, both functions return `-1`. - When searching for a matching column, the function checks for equality using the strict equality operator `===`. As a consequence, `NaN` values are considered distinct, and `-0` and `+0` are considered the same.
+ +
## Examples @@ -220,6 +225,7 @@ var Complex64Array = require( '@stdlib/array/complex64' ); var Uint8Array = require( '@stdlib/array/uint8' ); var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var logEach = require( '@stdlib/console/log-each' ); var cindexOfColumn = require( '@stdlib/blas/ext/base/cindex-of-column' ); var shape = [ 2, 2 ]; @@ -230,7 +236,7 @@ var A = new Complex64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); console.log( ndarray2array( A, shape, strides, 0, order ) ); var x = new Complex64Array( [ 2.0, 0.0, 4.0, 0.0 ] ); -console.log( x ); +logEach( '%s', x ); var workspace = new Uint8Array( shape[ 1 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/docs/types/test.ts index 93ecff0894be..297d76397793 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import Complex64Array = require( '@stdlib/array/complex64' ); import cindexOfColumn = require( './index' ); @@ -183,7 +184,7 @@ import cindexOfColumn = require( './index' ); cindexOfColumn( 'row-major', 2, 2, A, 2, x ); // $ExpectError cindexOfColumn( 'row-major', 2, 2, A, 2, x, 1 ); // $ExpectError cindexOfColumn( 'row-major', 2, 2, A, 2, x, 1, w ); // $ExpectError - cindexOfColumn( 'row-major', 2, 2, A, 2, x, 1, w, 1, 0 ); // $ExpectError + cindexOfColumn( 'row-major', 2, 2, A, 2, x, 1, w, 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -399,5 +400,5 @@ import cindexOfColumn = require( './index' ); cindexOfColumn.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError cindexOfColumn.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w ); // $ExpectError cindexOfColumn.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1 ); // $ExpectError - cindexOfColumn.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0, 0 ); // $ExpectError + cindexOfColumn.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/examples/index.js index c66011254800..553ccb3ef90b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/examples/index.js @@ -22,6 +22,7 @@ var Complex64Array = require( '@stdlib/array/complex64' ); var Uint8Array = require( '@stdlib/array/uint8' ); var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var logEach = require( '@stdlib/console/log-each' ); var cindexOfColumn = require( './../lib' ); var shape = [ 2, 2 ]; @@ -32,7 +33,7 @@ var A = new Complex64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); console.log( ndarray2array( A, shape, strides, 0, order ) ); var x = new Complex64Array( [ 2.0, 0.0, 4.0, 0.0 ] ); -console.log( x ); +logEach( '%s', x ); var workspace = new Uint8Array( shape[ 1 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.js index 1dcdba459234..77089ece1368 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.js @@ -76,7 +76,7 @@ function cindexOfColumn( order, M, N, A, LDA, x, strideX, workspace, strideW ) { s = M; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', max( 1, s ), LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } if ( isColumnMajor( order ) ) { sa1 = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.native.js index 9e3681d579b8..69daa5e28f89 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/lib/cindex_of_column.native.js @@ -74,7 +74,7 @@ function cindexOfColumn( order, M, N, A, LDA, x, strideX, workspace, strideW ) { s = M; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', max( 1, s ), LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } return addon( resolveOrder( order ), M, N, reinterpret( A, 0 ), LDA, reinterpret( x, 0 ), strideX, workspace, strideW ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/src/main.c index 265515be157b..265d4fc1336a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-column/src/main.c @@ -27,16 +27,16 @@ /** * Returns the index of the first column in a single-precision complex floating-point input matrix which has the same elements as a provided search vector. * -* @param order storage layout -* @param M number of rows in `A` -* @param N number of columns in `A` -* @param A input matrix -* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param X search vector -* @param strideX stride length for `X` -* @param workspace workspace array for tracking column match candidates -* @param strideW stride length for `workspace` -* @return column index +* @param order storage layout +* @param M number of rows in `A` +* @param N number of columns in `A` +* @param A input matrix +* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param X search vector +* @param strideX stride length for `X` +* @param workspace workspace array for tracking column match candidates +* @param strideW stride length for `workspace` +* @return column index */ CBLAS_INT API_SUFFIX(stdlib_strided_cindex_of_column)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex64_t *A, const CBLAS_INT LDA, const stdlib_complex64_t *X, const CBLAS_INT strideX, uint8_t *workspace, const CBLAS_INT strideW ) { CBLAS_INT sa1; @@ -59,19 +59,19 @@ CBLAS_INT API_SUFFIX(stdlib_strided_cindex_of_column)( const CBLAS_LAYOUT order, /** * Returns the index of the first column in a single-precision complex floating-point input matrix which has the same elements as a provided search vector using alternative indexing semantics. * -* @param M number of rows in `A` -* @param N number of columns in `A` -* @param A input matrix -* @param strideA1 stride length for the first dimension of `A` -* @param strideA2 stride length for the second dimension of `A` -* @param offsetA starting index for `A` -* @param X search vector -* @param strideX stride length for `X` -* @param offsetX starting index for `X` -* @param workspace workspace array for tracking column match candidates -* @param strideW stride length for `workspace` -* @param offsetW starting index for `workspace` -* @return column index +* @param M number of rows in `A` +* @param N number of columns in `A` +* @param A input matrix +* @param strideA1 stride length for the first dimension of `A` +* @param strideA2 stride length for the second dimension of `A` +* @param offsetA starting index for `A` +* @param X search vector +* @param strideX stride length for `X` +* @param offsetX starting index for `X` +* @param workspace workspace array for tracking column match candidates +* @param strideW stride length for `workspace` +* @param offsetW starting index for `workspace` +* @return column index */ CBLAS_INT API_SUFFIX(stdlib_strided_cindex_of_column_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex64_t *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const stdlib_complex64_t *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, uint8_t *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { stdlib_complex64_t va; diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/README.md b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/README.md index 98edfd16b85c..2f32b99e305b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/README.md @@ -138,7 +138,6 @@ var idx = cindexOfFalsy.ndarray( 3, x, 1, x.length-3 ); ## Notes - A complex number is falsy when both its real and imaginary components are falsy. -- If unable to find a falsy element, both functions return `-1`. - Both functions explicitly treat `NaN` values as falsy.
@@ -257,7 +256,6 @@ CBLAS_INT stdlib_strided_cindex_of_falsy_ndarray( const CBLAS_INT N, const stdli ### Notes - A complex number is falsy when both its real and imaginary components are falsy. -- If unable to find a falsy element, both functions return `-1`. - Both functions explicitly treat `NaN` values as falsy.
diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/repl.txt index 4c66051f1b68..42a09ee118f0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/repl.txt @@ -14,7 +14,7 @@ A complex number is falsy when both its real and imaginary components are falsy. - The function treats `NaN` values as falsy. + The function explicitly treats `NaN` values as falsy. Parameters ---------- @@ -34,10 +34,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 0.0, 0.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 5.0, 6.0 ] ); + > var idx = {{alias}}( 2, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0, 0.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 2, x1, 2 ) + 1 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first falsy element in a single-precision complex @@ -47,6 +59,11 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + A complex number is falsy when both its real and imaginary components are + falsy. + + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -68,10 +85,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 0.0, 0.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 1 + // Using an index offset: + > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0, 0.0 ] ); + > var idx = {{alias}}.ndarray( 2, x, 2, 1 ) + 1 + See Also -------- - diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/index.d.ts index e53d8b626d5f..b015ab203076 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/index.d.ts @@ -30,7 +30,7 @@ interface Routine { * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -54,7 +54,7 @@ interface Routine { * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -80,7 +80,7 @@ interface Routine { * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/test.ts index 990c56b2cbb9..5fe719cc4e7f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/docs/types/test.ts @@ -40,6 +40,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy( false, x, 1 ); // $ExpectError cindexOfFalsy( null, x, 1 ); // $ExpectError cindexOfFalsy( {}, x, 1 ); // $ExpectError + cindexOfFalsy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Complex64Array... @@ -51,6 +52,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy( x.length, false, 1 ); // $ExpectError cindexOfFalsy( x.length, null, 1 ); // $ExpectError cindexOfFalsy( x.length, {}, 1 ); // $ExpectError + cindexOfFalsy( 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... @@ -62,6 +64,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy( x.length, x, false ); // $ExpectError cindexOfFalsy( x.length, x, null ); // $ExpectError cindexOfFalsy( x.length, x, {} ); // $ExpectError + cindexOfFalsy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -88,6 +91,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy.ndarray( false, x, 1, 1 ); // $ExpectError cindexOfFalsy.ndarray( null, x, 1, 1 ); // $ExpectError cindexOfFalsy.ndarray( {}, x, 1, 1 ); // $ExpectError + cindexOfFalsy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex64Array... @@ -99,6 +103,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy.ndarray( x.length, false, 1, 1 ); // $ExpectError cindexOfFalsy.ndarray( x.length, null, 1, 1 ); // $ExpectError cindexOfFalsy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + cindexOfFalsy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -110,6 +115,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy.ndarray( x.length, x, false, 1 ); // $ExpectError cindexOfFalsy.ndarray( x.length, x, null, 1 ); // $ExpectError cindexOfFalsy.ndarray( x.length, x, {}, 1 ); // $ExpectError + cindexOfFalsy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -121,6 +127,7 @@ import cindexOfFalsy = require( './index' ); cindexOfFalsy.ndarray( x.length, x, 1, false ); // $ExpectError cindexOfFalsy.ndarray( x.length, x, 1, null ); // $ExpectError cindexOfFalsy.ndarray( x.length, x, 1, {} ); // $ExpectError + cindexOfFalsy.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... diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.js index b6d9f55b5230..7437829b76a5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.js @@ -32,7 +32,7 @@ var ndarray = require( './ndarray.js' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.native.js index 750b70173344..d6351b6185f6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/cindex_of_falsy.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.js index c6db468e304f..9adbf01841fd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.js @@ -31,7 +31,7 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.native.js index 853da1c5f83a..a19e8696c167 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/lib/ndarray.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is falsy when both its real and imaginary components are falsy. -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/src/main.c index b2ccbdd0cba4..5120e8290d3e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/src/main.c @@ -27,10 +27,10 @@ /** * Returns the index of the first falsy element in a single-precision complex floating-point strided array. * -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @return index +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_cindex_of_falsy)( const CBLAS_INT N, const stdlib_complex64_t *X, const CBLAS_INT strideX ) { CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); @@ -40,11 +40,11 @@ CBLAS_INT API_SUFFIX(stdlib_strided_cindex_of_falsy)( const CBLAS_INT N, const s /** * Returns the index of the first falsy element in a single-precision complex floating-point strided array using alternative indexing semantics. * -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @param offsetX starting index -* @return index +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @param offsetX starting index +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_cindex_of_falsy_ndarray)( const CBLAS_INT N, const stdlib_complex64_t *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { stdlib_complex64_t v; diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.js index 553d9b3b0ca7..72ad1cdf8d74 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.js @@ -52,20 +52,9 @@ tape( 'the function returns the index of the first falsy element', function test 1.0 ]); - // Nonnegative stride... actual = cindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = cindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -90,6 +79,28 @@ tape( 'the function ignores truthy elements (e.g., `1+1i`, `0+1i`, `1+0i`)', fun t.end(); }); +tape( 'the function explicitly treats `NaN` values as falsy', function test( t ) { + var actual; + var x; + + x = new Complex64Array( [ 1.0, 2.0, NaN, NaN, 2.0, 3.0 ] ); + + actual = cindexOfFalsy( 3, x, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + x = new Complex64Array( [ 1.0, 2.0, NaN, 0.0, 2.0, 3.0 ] ); + + actual = cindexOfFalsy( 3, x, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + x = new Complex64Array( [ 1.0, 2.0, 0.0, NaN, 2.0, 3.0 ] ); + + actual = cindexOfFalsy( 3, x, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns `-1` if unable to find a falsy element', function test( t ) { var actual; var x; @@ -111,7 +122,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -132,3 +143,77 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = cindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 2 + 0.0, // 2 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 0 + 8.0 // 0 + ]); + + actual = cindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex64Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = cindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.native.js index 5584f74f1a2e..1bfb6de68828 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.cindex_of_falsy.native.js @@ -61,20 +61,9 @@ tape( 'the function returns the index of the first falsy element', opts, functio 1.0 ]); - // Nonnegative stride... actual = cindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = cindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -99,6 +88,28 @@ tape( 'the function ignores truthy elements (e.g., `1+1i`, `0+1i`, `1+0i`)', opt t.end(); }); +tape( 'the function explicitly treats `NaN` values as falsy', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array( [ 1.0, 2.0, NaN, NaN, 2.0, 3.0 ] ); + + actual = cindexOfFalsy( 3, x, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + x = new Complex64Array( [ 1.0, 2.0, NaN, 0.0, 2.0, 3.0 ] ); + + actual = cindexOfFalsy( 3, x, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + x = new Complex64Array( [ 1.0, 2.0, 0.0, NaN, 2.0, 3.0 ] ); + + actual = cindexOfFalsy( 3, x, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns `-1` if unable to find a falsy element', opts, function test( t ) { var actual; var x; @@ -120,7 +131,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -141,3 +152,77 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = cindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 2 + 0.0, // 2 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 0 + 8.0 // 0 + ]); + + actual = cindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex64Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = cindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.js index 61f52260c6d9..79813faa119e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.js @@ -52,29 +52,9 @@ tape( 'the function returns the index of the first falsy element', function test 1.0 ]); - // Nonnegative stride... actual = cindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = cindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -99,6 +79,28 @@ tape( 'the function ignores truthy elements (e.g., `1+1i`, `0+1i`, `1+0i`)', fun t.end(); }); +tape( 'the function explicitly treats `NaN` values as falsy', function test( t ) { + var actual; + var x; + + x = new Complex64Array( [ 1.0, 2.0, NaN, NaN, 2.0, 3.0 ] ); + + actual = cindexOfFalsy( 3, x, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + x = new Complex64Array( [ 1.0, 2.0, NaN, 0.0, 2.0, 3.0 ] ); + + actual = cindexOfFalsy( 3, x, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + x = new Complex64Array( [ 1.0, 2.0, 0.0, NaN, 2.0, 3.0 ] ); + + actual = cindexOfFalsy( 3, x, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns `-1` if unable to find a falsy element', function test( t ) { var actual; var x; @@ -120,7 +122,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -141,3 +143,74 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = cindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 2 + 0.0, // 2 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 0 + 8.0 // 0 + ]); + + actual = cindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = cindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.native.js index 5bb7efb71820..f64ecdc2a759 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-falsy/test/test.ndarray.native.js @@ -61,29 +61,9 @@ tape( 'the function returns the index of the first falsy element', opts, functio 1.0 ]); - // Nonnegative stride... actual = cindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = cindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -108,6 +88,28 @@ tape( 'the function ignores truthy elements (e.g., `1+1i`, `0+1i`, `1+0i`)', opt t.end(); }); +tape( 'the function explicitly treats `NaN` values as falsy', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array( [ 1.0, 2.0, NaN, NaN, 2.0, 3.0 ] ); + + actual = cindexOfFalsy( 3, x, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + x = new Complex64Array( [ 1.0, 2.0, NaN, 0.0, 2.0, 3.0 ] ); + + actual = cindexOfFalsy( 3, x, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + x = new Complex64Array( [ 1.0, 2.0, 0.0, NaN, 2.0, 3.0 ] ); + + actual = cindexOfFalsy( 3, x, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns `-1` if unable to find a falsy element', opts, function test( t ) { var actual; var x; @@ -129,7 +131,7 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -150,3 +152,74 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = cindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 2 + 0.0, // 2 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 0 + 8.0 // 0 + ]); + + actual = cindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 0.0, // 1 + 0.0, // 1 + 5.0, + 6.0, + 7.0, // 2 + 8.0 // 2 + ]); + + actual = cindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/README.md index 459e19506a2d..6cf351248053 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-row/README.md @@ -68,11 +68,11 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Complex64Array`][@stdlib/array/complex64]. -- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: search vector stored as a [`Complex64Array`][@stdlib/array/complex64]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. When an input matrix is stored in row-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -166,14 +166,14 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Complex64Array`][@stdlib/array/complex64]. -- **strideA1**: stride of the first dimension of `A`. -- **strideA2**: stride of the second dimension of `A`. +- **strideA1**: stride length for the first dimension of `A`. +- **strideA2**: stride length for the second dimension of `A`. - **offsetA**: starting index for `A`. - **x**: search vector stored as a [`Complex64Array`][@stdlib/array/complex64]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. - **offsetW**: starting index for `workspace`. When an input matrix is stored in row-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -227,6 +227,7 @@ var Complex64Array = require( '@stdlib/array/complex64' ); var Uint8Array = require( '@stdlib/array/uint8' ); var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var logEach = require( '@stdlib/console/log-each' ); var cindexOfRow = require( '@stdlib/blas/ext/base/cindex-of-row' ); var shape = [ 2, 2 ]; @@ -237,7 +238,7 @@ var A = new Complex64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); console.log( ndarray2array( A, shape, strides, 0, order ) ); var x = new Complex64Array( [ 3.0, 0.0, 4.0, 0.0 ] ); -console.log( x ); +logEach( '%s', x ); var workspace = new Uint8Array( shape[ 0 ] ); @@ -302,7 +303,7 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] stdlib_complex64_t*` input matrix. -- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: `[in] CBLAS_INT` stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **X**: `[in] stdlib_complex64_t*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **workspace**: `[inout] uint8_t*` workspace array for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. @@ -350,8 +351,8 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] stdlib_complex64_t*` input matrix. -- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. -- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **strideA1**: `[in] CBLAS_INT` stride length for the first dimension of `A`. +- **strideA2**: `[in] CBLAS_INT` stride length for the second dimension of `A`. - **offsetA**: `[in] CBLAS_INT` index offset for `A`. - **X**: `[in] stdlib_complex64_t*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. @@ -427,6 +428,14 @@ int main( void ) { + + +
+ +
+ + + @@ -265,7 +264,6 @@ CBLAS_INT stdlib_strided_cindex_of_truthy_ndarray( const CBLAS_INT N, const stdl ### Notes - A complex number is truthy when at least one of its real or imaginary components is truthy. -- If unable to find a truthy element, both functions return `-1`. - Both functions explicitly treat `NaN` values as falsy. diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/repl.txt index b8a402731735..e51726f293a5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/repl.txt @@ -14,8 +14,6 @@ A complex number is truthy when at least one of its real or imaginary components is truthy. - If unable to find a truthy element, the function returns `-1`. - The function explicitly treats `NaN` values as falsy. Parameters @@ -36,10 +34,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); + > var idx = {{alias}}( 2, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 2, x1, 2 ) + 1 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first truthy element in a single-precision complex @@ -52,8 +62,6 @@ A complex number is truthy when at least one of its real or imaginary components is truthy. - If unable to find a truthy element, the function returns `-1`. - The function explicitly treats `NaN` values as falsy. Parameters @@ -77,9 +85,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 1 + // Using an index offset: + > var x = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + > var idx = {{alias}}.ndarray( 2, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/index.d.ts index ca7db764632a..666e0c13ac32 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/index.d.ts @@ -32,7 +32,7 @@ interface Routine { * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -56,7 +56,7 @@ interface Routine { * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -82,7 +82,7 @@ interface Routine { * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/test.ts index 55e406a8c193..3acbbc5bda74 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/docs/types/test.ts @@ -40,6 +40,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy( false, x, 1 ); // $ExpectError cindexOfTruthy( null, x, 1 ); // $ExpectError cindexOfTruthy( {}, x, 1 ); // $ExpectError + cindexOfTruthy( ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Complex64Array... @@ -51,6 +52,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy( x.length, false, 1 ); // $ExpectError cindexOfTruthy( x.length, null, 1 ); // $ExpectError cindexOfTruthy( x.length, {}, 1 ); // $ExpectError + cindexOfTruthy( 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... @@ -62,6 +64,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy( x.length, x, false ); // $ExpectError cindexOfTruthy( x.length, x, null ); // $ExpectError cindexOfTruthy( x.length, x, {} ); // $ExpectError + cindexOfTruthy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -88,6 +91,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy.ndarray( false, x, 1, 1 ); // $ExpectError cindexOfTruthy.ndarray( null, x, 1, 1 ); // $ExpectError cindexOfTruthy.ndarray( {}, x, 1, 1 ); // $ExpectError + cindexOfTruthy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex64Array... @@ -99,6 +103,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy.ndarray( x.length, false, 1, 1 ); // $ExpectError cindexOfTruthy.ndarray( x.length, null, 1, 1 ); // $ExpectError cindexOfTruthy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + cindexOfTruthy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -110,6 +115,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy.ndarray( x.length, x, false, 1 ); // $ExpectError cindexOfTruthy.ndarray( x.length, x, null, 1 ); // $ExpectError cindexOfTruthy.ndarray( x.length, x, {}, 1 ); // $ExpectError + cindexOfTruthy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -121,6 +127,7 @@ import cindexOfTruthy = require( './index' ); cindexOfTruthy.ndarray( x.length, x, 1, false ); // $ExpectError cindexOfTruthy.ndarray( x.length, x, 1, null ); // $ExpectError cindexOfTruthy.ndarray( x.length, x, 1, {} ); // $ExpectError + cindexOfTruthy.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... diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.js index c63b23e30dda..254cb854ed96 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.js @@ -32,7 +32,7 @@ var ndarray = require( './ndarray.js' ); * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.native.js index 736d971ecdea..994fccf218fd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/cindex_of_truthy.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.js index f053e051e135..39e23490563d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.js @@ -31,7 +31,7 @@ var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.native.js index 6307d0153dea..c7d405b78100 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/lib/ndarray.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * ## Notes * * - A complex number is truthy when at least one of its real or imaginary components is truthy. -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/src/main.c index 810c2ef7874c..36d926d5df63 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/src/main.c @@ -17,6 +17,7 @@ */ #include "stdlib/blas/ext/base/cindex_of_truthy.h" +#include "stdlib/complex/float32/ctor.h" #include "stdlib/complex/float32/real.h" #include "stdlib/complex/float32/imag.h" #include "stdlib/math/base/assert/is_nanf.h" @@ -26,10 +27,10 @@ /** * Returns the index of the first truthy element in a single-precision complex floating-point strided array. * -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @return index +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_cindex_of_truthy)( const CBLAS_INT N, const stdlib_complex64_t *X, const CBLAS_INT strideX ) { CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); @@ -39,11 +40,11 @@ CBLAS_INT API_SUFFIX(stdlib_strided_cindex_of_truthy)( const CBLAS_INT N, const /** * Returns the index of the first truthy element in a single-precision complex floating-point strided array using alternative indexing semantics. * -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @param offsetX starting index -* @return index +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @param offsetX starting index +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_cindex_of_truthy_ndarray)( const CBLAS_INT N, const stdlib_complex64_t *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { stdlib_complex64_t v; diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.js index 03c50cd474c4..aadbd6d1a2ac 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.js @@ -52,20 +52,9 @@ tape( 'the function returns the index of the first truthy element', function tes 0.0 ]); - // Nonnegative stride... actual = cindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = cindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -111,7 +100,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = cindexOfTruthy( 0, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 1 ); // eslint-disable-line max-len @@ -122,3 +111,77 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 0 + 0.0, // 0 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 3.0, + 3.0, + 4.0, // 2 + 4.0 // 2 + ]); + + actual = cindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 3.0, // 2 + 3.0, // 2 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 4.0, + 4.0, + 0.0, // 0 + 0.0 // 0 + ]); + + actual = cindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex64Array([ + 1.0, + 1.0, + 0.0, // 0 + 0.0, // 0 + 2.0, + 2.0, + 3.0, // 1 + 3.0, // 1 + 4.0, + 4.0, + 5.0, // 2 + 5.0 // 2 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = cindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.native.js index 29d1e1c5f1c2..6c160bec4d7a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.cindex_of_truthy.native.js @@ -61,20 +61,9 @@ tape( 'the function returns the index of the first truthy element', opts, functi 0.0 ]); - // Nonnegative stride... actual = cindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = cindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -120,7 +109,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = cindexOfTruthy( 0, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 1 ); // eslint-disable-line max-len @@ -131,3 +120,77 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 0 + 0.0, // 0 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 3.0, + 3.0, + 4.0, // 2 + 4.0 // 2 + ]); + + actual = cindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 3.0, // 2 + 3.0, // 2 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 4.0, + 4.0, + 0.0, // 0 + 0.0 // 0 + ]); + + actual = cindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex64Array([ + 1.0, + 1.0, + 0.0, // 0 + 0.0, // 0 + 2.0, + 2.0, + 3.0, // 1 + 3.0, // 1 + 4.0, + 4.0, + 5.0, // 2 + 5.0 // 2 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = cindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.js index e82ef408c579..d746120132db 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.js @@ -52,29 +52,9 @@ tape( 'the function returns the index of the first truthy element', function tes 0.0 ]); - // Nonnegative stride... actual = cindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = cindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -120,7 +100,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -143,3 +123,74 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 0 + 0.0, // 0 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 3.0, + 3.0, + 4.0, // 2 + 4.0 // 2 + ]); + + actual = cindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 3.0, // 2 + 3.0, // 2 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 4.0, + 4.0, + 0.0, // 0 + 0.0 // 0 + ]); + + actual = cindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, + 1.0, + 0.0, // 0 + 0.0, // 0 + 2.0, + 2.0, + 3.0, // 1 + 3.0, // 1 + 4.0, + 4.0, + 5.0, // 2 + 5.0 // 2 + ]); + + actual = cindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.native.js index a29352157c2c..850727c3a4d8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of-truthy/test/test.ndarray.native.js @@ -61,29 +61,9 @@ tape( 'the function returns the index of the first truthy element', opts, functi 0.0 ]); - // Nonnegative stride... actual = cindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = cindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = cindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -129,7 +109,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -152,3 +132,74 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 0.0, // 0 + 0.0, // 0 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 3.0, + 3.0, + 4.0, // 2 + 4.0 // 2 + ]); + + actual = cindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 3.0, // 2 + 3.0, // 2 + 1.0, + 1.0, + 2.0, // 1 + 2.0, // 1 + 4.0, + 4.0, + 0.0, // 0 + 0.0 // 0 + ]); + + actual = cindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, + 1.0, + 0.0, // 0 + 0.0, // 0 + 2.0, + 2.0, + 3.0, // 1 + 3.0, // 1 + 4.0, + 4.0, + 5.0, // 2 + 5.0 // 2 + ]); + + actual = cindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/README.md b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/README.md index 15baf72d8337..d05ee16f209d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/README.md @@ -160,13 +160,14 @@ var idx = cindexOf.ndarray( 3, new Complex64( 5.0, 6.0 ), x, 1, x.length-3 ); var uniform = require( '@stdlib/random/array/uniform' ); var Complex64Array = require( '@stdlib/array/complex64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var logEach = require( '@stdlib/console/log-each' ); var cindexOf = require( '@stdlib/blas/ext/base/cindex-of' ); var buf = uniform( 10*2, -10, 10, { 'dtype': 'float32' }); var x = new Complex64Array( buf.buffer ); -console.log( x ); +logEach( '%s', x ); var idx = cindexOf( x.length, new Complex64( 5.0, 5.0 ), x, 1 ); console.log( idx ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/docs/repl.txt index 0833aee84650..e462a3dfe693 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/docs/repl.txt @@ -32,11 +32,25 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var s = new {{alias:@stdlib/complex/float32/ctor}}( 3.0, 4.0 ); > var idx = {{alias}}( x.length, s, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var s = new {{alias:@stdlib/complex/float32/ctor}}( 5.0, 6.0 ); + > var idx = {{alias}}( 2, s, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var s = new {{alias:@stdlib/complex/float32/ctor}}( 7.0, 8.0 ); + > var idx = {{alias}}( 2, s, x1, 2 ) + 1 + {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) Returns the first index of a specified search element in a single-precision @@ -70,10 +84,17 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var s = new {{alias:@stdlib/complex/float32/ctor}}( 3.0, 4.0 ); > var idx = {{alias}}.ndarray( x.length, s, x, 1, 0 ) 1 + // Using an index offset: + > var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var s = new {{alias:@stdlib/complex/float32/ctor}}( 7.0, 8.0 ); + > var idx = {{alias}}.ndarray( 2, s, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/docs/types/test.ts index 5fe0fcb36840..b7d965e5bdd7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/docs/types/test.ts @@ -99,7 +99,7 @@ import cindexOf = require( './index' ); cindexOf( x.length ); // $ExpectError cindexOf( x.length, s ); // $ExpectError cindexOf( x.length, s, x ); // $ExpectError - cindexOf( x.length, s, x, 1, 0 ); // $ExpectError + cindexOf( x.length, s, x, 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -192,5 +192,5 @@ import cindexOf = require( './index' ); cindexOf.ndarray( x.length, s ); // $ExpectError cindexOf.ndarray( x.length, s, x ); // $ExpectError cindexOf.ndarray( x.length, s, x, 1 ); // $ExpectError - cindexOf.ndarray( x.length, s, x, 1, 0, 0 ); // $ExpectError + cindexOf.ndarray( x.length, s, x, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/examples/index.js index c97f396ae3f4..bc2c6dcaea93 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/examples/index.js @@ -21,13 +21,14 @@ var uniform = require( '@stdlib/random/array/uniform' ); var Complex64Array = require( '@stdlib/array/complex64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var logEach = require( '@stdlib/console/log-each' ); var cindexOf = require( './../lib' ); var buf = uniform( 10*2, -10, 10, { 'dtype': 'float32' }); var x = new Complex64Array( buf.buffer ); -console.log( x ); +logEach( '%s', x ); var idx = cindexOf( x.length, new Complex64( 5.0, 5.0 ), x, 1 ); console.log( idx ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.js index 436862ac4fe5..8e9250fa7e20 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the first index of a specified search element in a single-precision complex floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Complex64} searchElement - search element * @param {Complex64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.native.js index 5af67f0bc8a6..40dd62a43965 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/cindex_of.native.js @@ -29,6 +29,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the first index of a specified search element in a single-precision complex floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Complex64} searchElement - search element * @param {Complex64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.js index 0e306a326f64..d8bd609bd0d8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.js @@ -30,6 +30,10 @@ var imagf = require( '@stdlib/complex/float32/imag' ); /** * Returns the first index of a specified search element in a single-precision complex floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Complex64} searchElement - search element * @param {Complex64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.native.js index 719a3c289295..d9c371d7c0d5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/lib/ndarray.native.js @@ -29,6 +29,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the first index of a specified search element in a single-precision complex floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Complex64} searchElement - search element * @param {Complex64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.js index 4eaa52ffbdff..d252e76eadda 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.js @@ -53,32 +53,9 @@ tape( 'the function returns the first index of an element which equals a provide 6.0 ]); - // Nonnegative stride... actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = cindexOf( x.length, new Complex64( 3.0, 4.0 ), x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 5.0, 6.0 ), x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 7.0, 8.0 ), x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 3.0, 4.0 ), x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 5.0, 6.0 ), x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 7.0, 8.0 ), x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -143,3 +120,73 @@ tape( 'the function returns `-1` if provided a search element having a `NaN` com t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 2 + 10.0 // 2 + ]); + + actual = cindexOf( 3, new Complex64( 5.0, 6.0 ), x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 2 + 2.0, // 2 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 0 + 10.0 // 0 + ]); + + actual = cindexOf( 3, new Complex64( 9.0, 10.0 ), x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex64Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = cindexOf( 2, new Complex64( 7.0, 8.0 ), x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.native.js index 9dce9436b253..1a2684f20b64 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.cindex_of.native.js @@ -62,32 +62,9 @@ tape( 'the function returns the first index of an element which equals a provide 6.0 ]); - // Nonnegative stride... actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = cindexOf( x.length, new Complex64( 3.0, 4.0 ), x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 5.0, 6.0 ), x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 7.0, 8.0 ), x, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 3.0, 4.0 ), x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 5.0, 6.0 ), x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 7.0, 8.0 ), x, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -152,3 +129,73 @@ tape( 'the function returns `-1` if provided a search element having a `NaN` com t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 2 + 10.0 // 2 + ]); + + actual = cindexOf( 3, new Complex64( 5.0, 6.0 ), x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 2 + 2.0, // 2 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 0 + 10.0 // 0 + ]); + + actual = cindexOf( 3, new Complex64( 9.0, 10.0 ), x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Complex64Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = cindexOf( 2, new Complex64( 7.0, 8.0 ), x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.js index 8ee27573db63..a3530800b752 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.js @@ -53,36 +53,13 @@ tape( 'the function returns the first index of an element which equals a provide 6.0 ]); - // Nonnegative stride... actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = cindexOf( x.length-1, new Complex64( 3.0, 4.0 ), x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOf( x.length-2, new Complex64( 5.0, 6.0 ), x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length-2, new Complex64( 7.0, 8.0 ), x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = cindexOf( 3, new Complex64( 3.0, 4.0 ), x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOf( 3, new Complex64( 1.0, 2.0 ), x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 7.0, 8.0 ), x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; var x; @@ -104,30 +81,6 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function supports an `x` offset', function test( t ) { - var actual; - var x; - - x = new Complex64Array([ - 1.0, - 2.0, - 3.0, - 4.0, - 5.0, - 6.0, - 7.0, - 8.0 - ]); - - actual = cindexOf( 3, new Complex64( 5.0, 6.0 ), x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOf( 3, new Complex64( 1.0, 2.0 ), x, 1, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports a stride length equal to zero', function test( t ) { var actual; var x; @@ -170,3 +123,70 @@ tape( 'the function returns `-1` if provided a search element having a `NaN` com t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 2 + 10.0 // 2 + ]); + + actual = cindexOf( 3, new Complex64( 5.0, 6.0 ), x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 2 + 2.0, // 2 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 0 + 10.0 // 0 + ]); + + actual = cindexOf( 3, new Complex64( 9.0, 10.0 ), x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + + actual = cindexOf( 2, new Complex64( 7.0, 8.0 ), x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.native.js index 341e3cd9da8f..adc305612d84 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/cindex-of/test/test.ndarray.native.js @@ -62,36 +62,13 @@ tape( 'the function returns the first index of an element which equals a provide 6.0 ]); - // Nonnegative stride... actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = cindexOf( x.length-1, new Complex64( 3.0, 4.0 ), x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOf( x.length-2, new Complex64( 5.0, 6.0 ), x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length-2, new Complex64( 7.0, 8.0 ), x, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = cindexOf( x.length, new Complex64( 1.0, 2.0 ), x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = cindexOf( 3, new Complex64( 3.0, 4.0 ), x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOf( 3, new Complex64( 1.0, 2.0 ), x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = cindexOf( x.length, new Complex64( 7.0, 8.0 ), x, -1, x.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; var x; @@ -113,30 +90,6 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); -tape( 'the function supports an `x` offset', opts, function test( t ) { - var actual; - var x; - - x = new Complex64Array([ - 1.0, - 2.0, - 3.0, - 4.0, - 5.0, - 6.0, - 7.0, - 8.0 - ]); - - actual = cindexOf( 3, new Complex64( 5.0, 6.0 ), x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = cindexOf( 3, new Complex64( 1.0, 2.0 ), x, 1, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - tape( 'the function supports a stride length equal to zero', opts, function test( t ) { var actual; var x; @@ -179,3 +132,70 @@ tape( 'the function returns `-1` if provided a search element having a `NaN` com t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 2 + 10.0 // 2 + ]); + + actual = cindexOf( 3, new Complex64( 5.0, 6.0 ), x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, // 2 + 2.0, // 2 + 3.0, + 4.0, + 5.0, // 1 + 6.0, // 1 + 7.0, + 8.0, + 9.0, // 0 + 10.0 // 0 + ]); + + actual = cindexOf( 3, new Complex64( 9.0, 10.0 ), x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Complex64Array([ + 1.0, + 2.0, + 3.0, // 0 + 4.0, // 0 + 5.0, + 6.0, + 7.0, // 1 + 8.0 // 1 + ]); + + actual = cindexOf( 2, new Complex64( 7.0, 8.0 ), x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/README.md index f06a954e08af..194f4391ebce 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/README.md @@ -28,6 +28,8 @@ limitations under the License. + +
## Usage @@ -234,6 +236,8 @@ var out = clastIndexOfRow.ndarray( 3, 2, A, 2, 1, 1, x, 1, 1, workspace, 1, 0 ); + +
## Notes @@ -245,6 +249,8 @@ var out = clastIndexOfRow.ndarray( 3, 2, A, 2, 1, 1, x, 1, 1, workspace, 1, 0 ); + +
## Examples @@ -258,6 +264,7 @@ var Complex64Array = require( '@stdlib/array/complex64' ); var Uint8Array = require( '@stdlib/array/uint8' ); var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var logEach = require( '@stdlib/console/log-each' ); var clastIndexOfRow = require( '@stdlib/blas/ext/base/clast-index-of-row' ); var shape = [ 3, 3 ]; @@ -268,7 +275,7 @@ var A = new Complex64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0, console.log( ndarray2array( A, shape, strides, 0, order ) ); var x = new Complex64Array( [ 4.0, 0.0, 5.0, 0.0, 6.0, 0.0 ] ); -console.log( x ); +logEach( '%s', x ); var workspace = new Uint8Array( shape[ 0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/docs/types/test.ts index 68c4b4d8c060..004a63c86398 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import Complex64Array = require( '@stdlib/array/complex64' ); import clastIndexOfRow = require( './index' ); @@ -183,7 +184,7 @@ import clastIndexOfRow = require( './index' ); clastIndexOfRow( 'row-major', 2, 2, A, 2, x ); // $ExpectError clastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1 ); // $ExpectError clastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w ); // $ExpectError - clastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, 1, 0 ); // $ExpectError + clastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -399,5 +400,5 @@ import clastIndexOfRow = require( './index' ); clastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError clastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w ); // $ExpectError clastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1 ); // $ExpectError - clastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0, 0 ); // $ExpectError + clastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/examples/index.js index bd1ac96c4d57..ea69b11e7d58 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/examples/index.js @@ -22,6 +22,7 @@ var Complex64Array = require( '@stdlib/array/complex64' ); var Uint8Array = require( '@stdlib/array/uint8' ); var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var logEach = require( '@stdlib/console/log-each' ); var clastIndexOfRow = require( './../lib' ); var shape = [ 3, 3 ]; @@ -32,7 +33,7 @@ var A = new Complex64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0, console.log( ndarray2array( A, shape, strides, 0, order ) ); var x = new Complex64Array( [ 4.0, 0.0, 5.0, 0.0, 6.0, 0.0 ] ); -console.log( x ); +logEach( '%s', x ); var workspace = new Uint8Array( shape[ 0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/src/main.c index e2ea5655a389..6a1c5bcf9fbf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/clast-index-of-row/src/main.c @@ -27,16 +27,16 @@ /** * Returns the index of the last row in a single-precision complex floating-point input matrix which has the same elements as a provided search vector. * -* @param order storage layout -* @param M number of rows in `A` -* @param N number of columns in `A` -* @param A input matrix -* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param X search vector -* @param strideX stride length for `X` -* @param workspace workspace array for tracking row match candidates -* @param strideW stride length for `workspace` -* @return row index +* @param order storage layout +* @param M number of rows in `A` +* @param N number of columns in `A` +* @param A input matrix +* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param X search vector +* @param strideX stride length for `X` +* @param workspace workspace array for tracking row match candidates +* @param strideW stride length for `workspace` +* @return row index */ CBLAS_INT API_SUFFIX(stdlib_strided_clast_index_of_row)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex64_t *A, const CBLAS_INT LDA, const stdlib_complex64_t *X, const CBLAS_INT strideX, uint8_t *workspace, const CBLAS_INT strideW ) { CBLAS_INT sa1; @@ -59,19 +59,19 @@ CBLAS_INT API_SUFFIX(stdlib_strided_clast_index_of_row)( const CBLAS_LAYOUT orde /** * Returns the index of the last row in a single-precision complex floating-point input matrix which has the same elements as a provided search vector using alternative indexing semantics. * -* @param M number of rows in `A` -* @param N number of columns in `A` -* @param A input matrix -* @param strideA1 stride length for the first dimension of `A` -* @param strideA2 stride length for the second dimension of `A` -* @param offsetA starting index for `A` -* @param X search vector -* @param strideX stride length for `X` -* @param offsetX starting index for `X` -* @param workspace workspace array for tracking row match candidates -* @param strideW stride length for `workspace` -* @param offsetW starting index for `workspace` -* @return row index +* @param M number of rows in `A` +* @param N number of columns in `A` +* @param A input matrix +* @param strideA1 stride length for the first dimension of `A` +* @param strideA2 stride length for the second dimension of `A` +* @param offsetA starting index for `A` +* @param X search vector +* @param strideX stride length for `X` +* @param offsetX starting index for `X` +* @param workspace workspace array for tracking row match candidates +* @param strideW stride length for `workspace` +* @param offsetW starting index for `workspace` +* @return row index */ CBLAS_INT API_SUFFIX(stdlib_strided_clast_index_of_row_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex64_t *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const stdlib_complex64_t *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, uint8_t *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { stdlib_complex64_t va; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/README.md index b2d20792db3f..977b450afdd5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/README.md @@ -50,7 +50,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); -var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); +var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); // returns 2 ``` @@ -62,7 +62,7 @@ The function has the following parameters: - **y**: second input [`Float64Array`][@stdlib/array/float64]. - **strideY**: stride length for `y`. -If the function is unable to find a match, the function returns `-1`. +If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -70,20 +70,20 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var y = new Float64Array( [ 5.0, 6.0, 7.0, 8.0 ] ); -var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); +var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); // returns -1 ``` -The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to search every other element: +The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compare every other element: ```javascript var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -var y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 5.0, 0.0 ] ); +var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); var idx = dfirstIndexEqual( 3, x, 2, y, 2 ); -// returns 2 +// returns 1 ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -114,7 +114,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); -var idx = dfirstIndexEqual.ndarray( 4, x, 1, 0, y, 1, 0 ); +var idx = dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, 0 ); // returns 2 ``` @@ -123,16 +123,16 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetY**: starting index for `y`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on a starting index. For example, to access only the last three elements of the strided arrays: +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to access only the last three elements of each strided array: ```javascript var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 6.0 ] ); +var y = new Float64Array( [ 0.0, 0.0, 0.0, 4.0, 5.0, 6.0 ] ); var idx = dfirstIndexEqual.ndarray( 3, x, 1, x.length-3, y, 1, y.length-3 ); -// returns 2 +// returns 0 ```
@@ -212,8 +212,8 @@ console.log( idx ); Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. ```c -double x[] = { 1.0, 2.0, 3.0, 4.0 }; -double y[] = { 0.0, 0.0, 3.0, 0.0 }; +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; +const double y[] = { 0.0, 0.0, 3.0, 0.0 }; int idx = stdlib_strided_dfirst_index_equal( 4, x, 1, y, 1 ); // returns 2 @@ -240,8 +240,8 @@ CBLAS_INT stdlib_strided_dfirst_index_equal( const CBLAS_INT N, const double *X, Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. ```c -double x[] = { 1.0, 2.0, 3.0, 4.0 }; -double y[] = { 0.0, 0.0, 3.0, 0.0 }; +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; +const double y[] = { 0.0, 0.0, 3.0, 0.0 }; int idx = stdlib_strided_dfirst_index_equal_ndarray( 4, x, 1, 0, y, 1, 0 ); // returns 2 @@ -285,8 +285,8 @@ CBLAS_INT stdlib_strided_dfirst_index_equal_ndarray( const CBLAS_INT N, const do int main( void ) { // Create strided arrays: - double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; - double y[] = { 0.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0 }; + const double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; + const double y[] = { 0.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0 }; // Specify the number of indexed elements: const int N = 8; @@ -295,11 +295,11 @@ int main( void ) { const int strideX = 1; const int strideY = 1; - // Find the first index of a match: + // Perform a search: int idx = stdlib_strided_dfirst_index_equal( N, x, strideX, y, strideY ); // Print the result: - printf( "first index: %d\n", idx ); + printf( "index value: %d\n", idx ); } ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/benchmark/benchmark.js index 924080c11b54..c8339d43ec6e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/benchmark/benchmark.js @@ -27,7 +27,7 @@ var oneTo = require( '@stdlib/array/one-to' ); var zeros = require( '@stdlib/array/zeros' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; -var dfirstIndexEqual = require( './../lib' ); +var dfirstIndexEqual = require( './../lib/dfirst_index_equal.js' ); // FUNCTIONS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/repl.txt index 649441ce9b41..7d203ea2c1ea 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/repl.txt @@ -44,16 +44,16 @@ // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0, 5.0, 0.0 ] ); + > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); > idx = {{alias}}( 3, x, 2, y, 2 ) - 2 + 1 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 3.0, 0.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 3.0, 0.0 ] ); > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); - > idx = {{alias}}( 2, x1, 1, y1, 1 ) + > var idx = {{alias}}( 2, x1, 1, y1, 1 ) 1 @@ -102,7 +102,7 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using offsets: + // Using index offsets: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0 ] ); > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/index.d.ts index 834ebef251fa..0989affb6435 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find a match, the function returns `-1`. + * - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -42,7 +42,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * - * var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); + * var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); * // returns 2 */ ( N: number, x: Float64Array, strideX: number, y: Float64Array, strideY: number ): number; @@ -52,7 +52,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find a match, the function returns `-1`. + * - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -69,7 +69,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * - * var idx = dfirstIndexEqual.ndarray( 4, x, 1, 0, y, 1, 0 ); + * var idx = dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ ndarray( N: number, x: Float64Array, strideX: number, offsetX: number, y: Float64Array, strideY: number, offsetY: number ): number; @@ -78,6 +78,10 @@ interface Routine { /** * Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. +* * @param N - number of indexed elements * @param x - first input array * @param strideX - stride length for `x` @@ -91,7 +95,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); +* var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); * // returns 2 * * @example @@ -100,7 +104,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual.ndarray( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ declare var dfirstIndexEqual: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/test.ts index b16ef3584fa3..455c3a3f6a56 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/docs/types/test.ts @@ -39,6 +39,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual( false, x, 1, y, 1 ); // $ExpectError dfirstIndexEqual( null, x, 1, y, 1 ); // $ExpectError dfirstIndexEqual( {}, x, 1, y, 1 ); // $ExpectError + dfirstIndexEqual( ( x: number ): number => x, x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... @@ -50,6 +51,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual( 3, false, 1, y, 1 ); // $ExpectError dfirstIndexEqual( 3, null, 1, y, 1 ); // $ExpectError dfirstIndexEqual( 3, {}, 1, y, 1 ); // $ExpectError + dfirstIndexEqual( 3, ( x: number ): number => x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -62,6 +64,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual( x.length, x, false, y, 1 ); // $ExpectError dfirstIndexEqual( x.length, x, null, y, 1 ); // $ExpectError dfirstIndexEqual( x.length, x, {}, y, 1 ); // $ExpectError + dfirstIndexEqual( x.length, x, ( x: number ): number => x, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... @@ -73,6 +76,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual( x.length, x, 1, false, 1 ); // $ExpectError dfirstIndexEqual( x.length, x, 1, null, 1 ); // $ExpectError dfirstIndexEqual( x.length, x, 1, {}, 1 ); // $ExpectError + dfirstIndexEqual( x.length, x, 1, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... @@ -85,6 +89,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual( x.length, x, 1, y, false ); // $ExpectError dfirstIndexEqual( x.length, x, 1, y, null ); // $ExpectError dfirstIndexEqual( x.length, x, 1, y, {} ); // $ExpectError + dfirstIndexEqual( x.length, x, 1, y, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -118,6 +123,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( false, x, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( null, x, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( {}, x, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexEqual.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... @@ -129,6 +135,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( 3, false, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( 3, null, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( 3, {}, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexEqual.ndarray( 3, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -141,6 +148,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( x.length, x, false, 0, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, null, 0, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, {}, 0, y, 1, 0 ); // $ExpectError + dfirstIndexEqual.ndarray( x.length, x, ( x: number ): number => x, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -153,6 +161,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( x.length, x, 1, false, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, null, y, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, {}, y, 1, 0 ); // $ExpectError + dfirstIndexEqual.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Float64Array... @@ -164,6 +173,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( x.length, x, 1, 0, false, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, 0, null, 1, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, 0, {}, 1, 0 ); // $ExpectError + dfirstIndexEqual.ndarray( x.length, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... @@ -176,6 +186,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, false, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, null, 0 ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, {}, 0 ); // $ExpectError + dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... @@ -188,6 +199,7 @@ import dfirstIndexEqual = require( './index' ); dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, false ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, null ); // $ExpectError dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, {} ); // $ExpectError + dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/examples/c/example.c index ddc5695e011f..20d6e7074521 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/examples/c/example.c @@ -31,9 +31,9 @@ int main( void ) { const int strideX = 1; const int strideY = 1; - // Find the first index of a match: + // Perform a search: int idx = stdlib_strided_dfirst_index_equal( N, x, strideX, y, strideY ); // Print the result: - printf( "first index: %d\n", idx ); + printf( "index value: %d\n", idx ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.js index 6578f671efc0..26f470e0491f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` @@ -42,7 +46,7 @@ var ndarray = require( './ndarray.js' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); +* var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); * // returns 2 */ function dfirstIndexEqual( N, x, strideX, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.native.js index 25cfab141d32..19d2f0ae280e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/dfirst_index_equal.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` @@ -41,7 +45,7 @@ var addon = require( './../src/addon.node' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); +* var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); * // returns 2 */ function dfirstIndexEqual( N, x, strideX, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/index.js index 95105b27e37c..56095cf3a877 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/index.js @@ -30,7 +30,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual( 4, x, 1, y, 1 ); +* var idx = dfirstIndexEqual( x.length, x, 1, y, 1 ); * // returns 2 * * @example @@ -40,7 +40,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual.ndarray( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexEqual.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.js index 3078c67046b8..48cdfb8c5507 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.js @@ -23,6 +23,10 @@ /** * Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` @@ -38,7 +42,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexEqual( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ function dfirstIndexEqual( N, x, strideX, offsetX, y, strideY, offsetY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.native.js index 881ede8dd73c..644c2bd7da1b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` @@ -43,7 +47,7 @@ var addon = require( './../src/addon.node' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dfirstIndexEqual( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexEqual( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ function dfirstIndexEqual( N, x, strideX, offsetX, y, strideY, offsetY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.js index 2c0353416ab5..924d0d348fd7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.js @@ -46,59 +46,9 @@ tape( 'the function returns the first index of an element which equals a corresp x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, 2, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 3.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -114,7 +64,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ NaN ] ), 1, new Float64Array( [ NaN ] ), 1 ); @@ -123,7 +73,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, new Float64Array( [ 0.0 ] ), 1 ); @@ -153,8 +103,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -179,12 +129,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -197,16 +147,42 @@ tape( 'the function supports negative strides', function test( t ) { 5.0 // 0 ]); y = new Float64Array([ - 0.0, // 2 - 3.0, // 1 0.0, // 0 + 3.0, // 1 + 0.0, // 2 0.0, 0.0 ]); - actual = dfirstIndexEqual( 3, x, -2, y, -1 ); + actual = dfirstIndexEqual( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 0.0, // 2 + 2.0, // 1 + 0.0, // 0 + 0.0, + 0.0 + ]); + + actual = dfirstIndexEqual( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -233,7 +209,42 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var y0; + var x1; + var y1; + + // Initial arrays... + x0 = new Float64Array([ + 1.0, + 2.0, // 2 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 0 + ]); + y0 = new Float64Array([ + 0.0, + 0.0, + 0.0, + 0.0, // 0 + 4.0, // 1 + 0.0 // 2 + ]); + + // Create offset views... + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at 4th element + + actual = dfirstIndexEqual( 3, x1, -2, y1, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.native.js index 6b1e78b9a70e..9c5729b92f07 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.dfirst_index_equal.native.js @@ -55,59 +55,9 @@ tape( 'the function returns the first index of an element which equals a corresp x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, 2, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 3.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -123,7 +73,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ NaN ] ), 1, new Float64Array( [ NaN ] ), 1 ); @@ -132,7 +82,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, new Float64Array( [ 0.0 ] ), 1 ); @@ -162,8 +112,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -188,12 +138,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -206,16 +156,42 @@ tape( 'the function supports negative strides', opts, function test( t ) { 5.0 // 0 ]); y = new Float64Array([ - 0.0, // 2 - 3.0, // 1 0.0, // 0 + 3.0, // 1 + 0.0, // 2 0.0, 0.0 ]); - actual = dfirstIndexEqual( 3, x, -2, y, -1 ); + actual = dfirstIndexEqual( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 0.0, // 2 + 2.0, // 1 + 0.0, // 0 + 0.0, + 0.0 + ]); + + actual = dfirstIndexEqual( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -242,7 +218,42 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dfirstIndexEqual( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var y0; + var x1; + var y1; + + // Initial arrays... + x0 = new Float64Array([ + 1.0, + 2.0, // 2 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 0 + ]); + y0 = new Float64Array([ + 0.0, + 0.0, + 0.0, + 0.0, // 0 + 4.0, // 1 + 0.0 // 2 + ]); + + // Create offset views... + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at 4th element + + actual = dfirstIndexEqual( 3, x1, -2, y1, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.js index f236de9a4f42..7e79c7c0bbe0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.js @@ -46,59 +46,9 @@ tape( 'the function returns the first index of an element which equals a corresp x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dfirstIndexEqual( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length-1, x, 1, 1, y, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, -2, x.length-1, y, -2, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, -2, x.length-2, y, -2, y.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -114,7 +64,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ NaN ] ), 1, 0, new Float64Array( [ NaN ] ), 1, 0 ); @@ -123,7 +73,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, 0, new Float64Array( [ 0.0 ] ), 1, 0 ); @@ -153,8 +103,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -179,12 +129,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -197,16 +147,90 @@ tape( 'the function supports negative strides', function test( t ) { 5.0 // 0 ]); y = new Float64Array([ - 0.0, // 2 + 0.0, // 0 3.0, // 1 + 0.0, // 2 + 0.0, + 0.0 + ]); + + actual = dfirstIndexEqual( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 0.0, // 2 + 2.0, // 1 0.0, // 0 0.0, 0.0 ]); - actual = dfirstIndexEqual( 3, x, -2, 4, y, -1, 2 ); + actual = dfirstIndexEqual( 3, x, 1, 0, y, -1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + var y; + x = new Float64Array([ + 5.0, + 5.0, + 5.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float64Array([ + 9.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = dfirstIndexEqual( 3, x, 1, 2, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a `y` offset', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float64Array([ + 0.0, + 0.0, + 9.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = dfirstIndexEqual( 3, x, 1, 0, y, 1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -233,7 +257,7 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.native.js index 3d08120524fb..3110b1284286 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-equal/test/test.ndarray.native.js @@ -55,59 +55,9 @@ tape( 'the function returns the first index of an element which equals a corresp x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dfirstIndexEqual( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length-1, x, 1, 1, y, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, -2, x.length-1, y, -2, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( 3, x, -2, x.length-2, y, -2, y.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dfirstIndexEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -123,7 +73,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ NaN ] ), 1, 0, new Float64Array( [ NaN ] ), 1, 0 ); @@ -132,7 +82,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = dfirstIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, 0, new Float64Array( [ 0.0 ] ), 1, 0 ); @@ -162,8 +112,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -188,12 +138,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dfirstIndexEqual( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -206,16 +156,90 @@ tape( 'the function supports negative strides', opts, function test( t ) { 5.0 // 0 ]); y = new Float64Array([ - 0.0, // 2 + 0.0, // 0 3.0, // 1 + 0.0, // 2 + 0.0, + 0.0 + ]); + + actual = dfirstIndexEqual( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 0.0, // 2 + 2.0, // 1 0.0, // 0 0.0, 0.0 ]); - actual = dfirstIndexEqual( 3, x, -2, 4, y, -1, 2 ); + actual = dfirstIndexEqual( 3, x, 1, 0, y, -1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + var y; + x = new Float64Array([ + 5.0, + 5.0, + 5.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float64Array([ + 9.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = dfirstIndexEqual( 3, x, 1, 2, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a `y` offset', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float64Array([ + 0.0, + 0.0, + 9.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + + actual = dfirstIndexEqual( 3, x, 1, 0, y, 1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -242,7 +266,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dfirstIndexEqual( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/README.md b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/README.md index c6a52a3dafe1..6dc81fdcb10d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/README.md @@ -50,7 +50,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); -var idx = dfirstIndexGreaterThan( 4, x, 1, y, 1 ); +var idx = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); // returns 2 ``` @@ -70,7 +70,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var y = new Float64Array( [ 5.0, 6.0, 7.0, 8.0 ] ); -var idx = dfirstIndexGreaterThan( 4, x, 1, y, 1 ); +var idx = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); // returns -1 ``` @@ -118,7 +118,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); -var idx = dfirstIndexGreaterThan.ndarray( 4, x, 1, 0, y, 1, 0 ); +var idx = dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, 0 ); // returns 2 ``` @@ -151,7 +151,7 @@ var idx = dfirstIndexGreaterThan.ndarray( 3, x, 1, x.length-3, y, 1, y.length-3 ## Notes -- When comparing elements, the function checks whether an element in `x` is greater than a corresponding element in `y` using the greater-than operator `>`. As a consequence, comparisons involving `NaN` always evaluate to `false`. +- When comparing elements, the function checks whether an element in `x` is greater than a corresponding element in `y` using the greater-than operator `>`. As a consequence, comparisons involving `NaN` always evaluate to `false`, and `-0` and `+0` are considered the same.
@@ -222,8 +222,8 @@ console.log( idx ); Returns the index of the first element in a double-precision floating-point strided array which is greater than a corresponding element in another double-precision floating-point strided array. ```c -double x[] = { 1.0, 2.0, 3.0, 4.0 }; -double y[] = { 2.0, 2.0, 2.0, 2.0 }; +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; +const double y[] = { 2.0, 2.0, 2.0, 2.0 }; int idx = stdlib_strided_dfirst_index_greater_than( 4, x, 1, y, 1 ); // returns 2 @@ -250,8 +250,8 @@ CBLAS_INT stdlib_strided_dfirst_index_greater_than( const CBLAS_INT N, const dou Returns the index of the first element in a double-precision floating-point strided array which is greater than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. ```c -double x[] = { 1.0, 2.0, 3.0, 4.0 }; -double y[] = { 2.0, 2.0, 2.0, 2.0 }; +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; +const double y[] = { 2.0, 2.0, 2.0, 2.0 }; int idx = stdlib_strided_dfirst_index_greater_than_ndarray( 4, x, 1, 0, y, 1, 0 ); // returns 2 @@ -295,8 +295,8 @@ CBLAS_INT stdlib_strided_dfirst_index_greater_than_ndarray( const CBLAS_INT N, c int main( void ) { // Create strided arrays: - double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; - double y[] = { 9.0, 9.0, 9.0, 9.0, 4.0, 9.0, 9.0, 9.0 }; + const double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; + const double y[] = { 9.0, 9.0, 9.0, 9.0, 4.0, 9.0, 9.0, 9.0 }; // Specify the number of indexed elements: const int N = 8; @@ -305,11 +305,11 @@ int main( void ) { const int strideX = 1; const int strideY = 1; - // Find the first index of an element which is greater than a corresponding element: + // Perform a search: int idx = stdlib_strided_dfirst_index_greater_than( N, x, strideX, y, strideY ); // Print the result: - printf( "first index: %d\n", idx ); + printf( "index value: %d\n", idx ); } ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/benchmark/benchmark.js index 1c9a52ad8e0f..92a99e78c165 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/benchmark/benchmark.js @@ -26,7 +26,7 @@ var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; var ones = require( '@stdlib/array/ones' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; -var dfirstIndexGreaterThan = require( './../lib' ); +var dfirstIndexGreaterThan = require( './../lib/dfirst_index_greater_than.js' ); // FUNCTIONS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/repl.txt index 6ffe98636d3d..3497e779e624 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/repl.txt @@ -49,12 +49,12 @@ 1 // Using view offsets: - > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0 ] ); - > var y0 = new {{alias:@stdlib/array/float64}}( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); + > 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 y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*2 ); - > idx = {{alias}}( 3, x1, 2, y1, 2 ) - -1 + > var y0 = new {{alias:@stdlib/array/float64}}( [ 9.0, 9.0, 0.0, 9.0 ] ); + > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 2, x1, 1, y1, 1 ) + 1 {{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) @@ -64,8 +64,8 @@ semantics. While typed array views mandate a view offset based on the underlying - buffer, the offset parameters support indexing semantics based on - starting indices. + buffer, the offset parameters support indexing semantics based on starting + indices. Parameters ---------- @@ -103,7 +103,7 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using offsets: + // Using index offsets: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0 ] ); > y = new {{alias:@stdlib/array/float64}}( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0, 0.0 ] ); > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/index.d.ts index 8c35974f4b62..52fbe2c9f28d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/index.d.ts @@ -42,7 +42,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * - * var idx = dfirstIndexGreaterThan( 4, x, 1, y, 1 ); + * var idx = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); * // returns 2 */ ( N: number, x: Float64Array, strideX: number, y: Float64Array, strideY: number ): number; @@ -69,7 +69,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * - * var idx = dfirstIndexGreaterThan.ndarray( 4, x, 1, 0, y, 1, 0 ); + * var idx = dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ ndarray( N: number, x: Float64Array, strideX: number, offsetX: number, y: Float64Array, strideY: number, offsetY: number ): number; @@ -95,7 +95,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan( 4, x, 1, y, 1 ); +* var idx = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); * // returns 2 * * @example @@ -104,7 +104,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan.ndarray( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ declare const dfirstIndexGreaterThan: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/test.ts index 84d545dbf597..ba55d0b5cb61 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/docs/types/test.ts @@ -39,6 +39,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan( false, x, 1, y, 1 ); // $ExpectError dfirstIndexGreaterThan( null, x, 1, y, 1 ); // $ExpectError dfirstIndexGreaterThan( {}, x, 1, y, 1 ); // $ExpectError + dfirstIndexGreaterThan( ( x: number ): number => x, x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... @@ -50,6 +51,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan( 3, false, 1, y, 1 ); // $ExpectError dfirstIndexGreaterThan( 3, null, 1, y, 1 ); // $ExpectError dfirstIndexGreaterThan( 3, {}, 1, y, 1 ); // $ExpectError + dfirstIndexGreaterThan( 3, ( x: number ): number => x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -62,6 +64,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan( x.length, x, false, y, 1 ); // $ExpectError dfirstIndexGreaterThan( x.length, x, null, y, 1 ); // $ExpectError dfirstIndexGreaterThan( x.length, x, {}, y, 1 ); // $ExpectError + dfirstIndexGreaterThan( x.length, x, ( x: number ): number => x, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... @@ -73,6 +76,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan( x.length, x, 1, false, 1 ); // $ExpectError dfirstIndexGreaterThan( x.length, x, 1, null, 1 ); // $ExpectError dfirstIndexGreaterThan( x.length, x, 1, {}, 1 ); // $ExpectError + dfirstIndexGreaterThan( x.length, x, 1, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... @@ -85,6 +89,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan( x.length, x, 1, y, false ); // $ExpectError dfirstIndexGreaterThan( x.length, x, 1, y, null ); // $ExpectError dfirstIndexGreaterThan( x.length, x, 1, y, {} ); // $ExpectError + dfirstIndexGreaterThan( x.length, x, 1, y, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -118,6 +123,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( false, x, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( null, x, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( {}, x, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexGreaterThan.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... @@ -129,6 +135,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( 3, false, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( 3, null, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( 3, {}, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexGreaterThan.ndarray( 3, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -141,6 +148,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( x.length, x, false, 0, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, null, 0, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, {}, 0, y, 1, 0 ); // $ExpectError + dfirstIndexGreaterThan.ndarray( x.length, x, ( x: number ): number => x, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -153,6 +161,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( x.length, x, 1, false, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, null, y, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, {}, y, 1, 0 ); // $ExpectError + dfirstIndexGreaterThan.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Float64Array... @@ -164,6 +173,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, false, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, null, 1, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, {}, 1, 0 ); // $ExpectError + dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... @@ -176,6 +186,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, false, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, null, 0 ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, {}, 0 ); // $ExpectError + dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... @@ -188,6 +199,7 @@ import dfirstIndexGreaterThan = require( './index' ); dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, false ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, null ); // $ExpectError dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, {} ); // $ExpectError + dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/examples/c/example.c index 81f9efc0bfcf..c993558c7799 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/examples/c/example.c @@ -31,9 +31,9 @@ int main( void ) { const int strideX = 1; const int strideY = 1; - // Find the first index of an element which is greater than a corresponding element: + // Perform a search: int idx = stdlib_strided_dfirst_index_greater_than( N, x, strideX, y, strideY ); // Print the result: - printf( "first index: %d\n", idx ); + printf( "index value: %d\n", idx ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.js index 99a28faef530..2a0c34d0e1eb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the first element in a double-precision floating-point strided array which is greater than a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is greater than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` @@ -42,7 +46,7 @@ var ndarray = require( './ndarray.js' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan( 4, x, 1, y, 1 ); +* var idx = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); * // returns 2 */ function dfirstIndexGreaterThan( N, x, strideX, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.native.js index a38ffae9acc1..a293c1de8068 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/dfirst_index_greater_than.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a double-precision floating-point strided array which is greater than a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is greater than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` @@ -41,7 +45,7 @@ var addon = require( './../src/addon.node' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan( 4, x, 1, y, 1 ); +* var idx = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); * // returns 2 */ function dfirstIndexGreaterThan( N, x, strideX, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/index.js index 6ac7f1babca2..c91443bf1b49 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/index.js @@ -30,7 +30,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan( 4, x, 1, y, 1 ); +* var idx = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); * // returns 2 * * @example @@ -40,7 +40,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan.ndarray( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexGreaterThan.ndarray( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.js index dba855c95fce..1d258ea60424 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.js @@ -23,6 +23,10 @@ /** * Returns the index of the first element in a double-precision floating-point strided array which is greater than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is greater than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` @@ -38,7 +42,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ function dfirstIndexGreaterThan( N, x, strideX, offsetX, y, strideY, offsetY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.native.js index b471ae7fee00..6afab6a0ef42 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a double-precision floating-point strided array which is greater than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is greater than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` @@ -43,7 +47,7 @@ var addon = require( './../src/addon.node' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); * -* var idx = dfirstIndexGreaterThan( 4, x, 1, 0, y, 1, 0 ); +* var idx = dfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); * // returns 2 */ function dfirstIndexGreaterThan( N, x, strideX, offsetX, y, strideY, offsetY ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.js index e127ed25195d..953e7e0a259b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.js @@ -46,59 +46,23 @@ tape( 'the function returns the first index of an element which is greater than x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - // Nonnegative stride... actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 0.0, 9.0 ] ); + t.end(); +}); - actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is greater than a corresponding element in another array', function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 2.0, 3.0, 4.0 ] ); actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( 3, x, 2, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 0.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 0.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -126,7 +90,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = dfirstIndexGreaterThan( 1, new Float64Array( [ 0.0 ] ), 1, new Float64Array( [ -0.0 ] ), 1 ); @@ -156,8 +120,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -182,12 +146,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -199,6 +163,32 @@ tape( 'the function supports negative strides', function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 9.0, // 0 + 0.0, // 1 + 9.0, // 2 + 9.0, + 9.0 + ]); + + actual = dfirstIndexGreaterThan( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 9.0, // 2 0.0, // 1 @@ -207,9 +197,9 @@ tape( 'the function supports negative strides', function test( t ) { 9.0 ]); - actual = dfirstIndexGreaterThan( 3, x, -2, y, -1 ); - + actual = dfirstIndexGreaterThan( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -236,8 +226,8 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -272,5 +262,6 @@ tape( 'the function supports view offsets', function test( t ) { actual = dfirstIndexGreaterThan( 3, x1, -2, y1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.native.js index 6ba30ee59430..0c434fe87435 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.dfirst_index_greater_than.native.js @@ -55,59 +55,23 @@ tape( 'the function returns the first index of an element which is greater than x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - // Nonnegative stride... actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 0.0, 9.0 ] ); + t.end(); +}); - actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is greater than a corresponding element in another array', opts, function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 2.0, 3.0, 4.0 ] ); actual = dfirstIndexGreaterThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( 3, x, 2, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 0.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 0.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -135,7 +99,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = dfirstIndexGreaterThan( 1, new Float64Array( [ 0.0 ] ), 1, new Float64Array( [ -0.0 ] ), 1 ); @@ -165,8 +129,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -191,12 +155,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -208,6 +172,32 @@ tape( 'the function supports negative strides', opts, function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 9.0, // 0 + 0.0, // 1 + 9.0, // 2 + 9.0, + 9.0 + ]); + + actual = dfirstIndexGreaterThan( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 9.0, // 2 0.0, // 1 @@ -216,9 +206,9 @@ tape( 'the function supports negative strides', opts, function test( t ) { 9.0 ]); - actual = dfirstIndexGreaterThan( 3, x, -2, y, -1 ); - + actual = dfirstIndexGreaterThan( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -245,8 +235,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dfirstIndexGreaterThan( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -281,5 +271,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { actual = dfirstIndexGreaterThan( 3, x1, -2, y1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.js index be1485b60734..c9ca07f3c275 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.js @@ -46,57 +46,21 @@ tape( 'the function returns the first index of an element which is greater than x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - // Nonnegative stride... actual = dfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length-1, x, 1, 1, y, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 0.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 0.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( 3, x, -2, x.length-1, y, -2, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + t.end(); +}); - actual = dfirstIndexGreaterThan( 3, x, -2, x.length-2, y, -2, y.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is greater than a corresponding element in another array', function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 2.0, 3.0, 4.0 ] ); - actual = dfirstIndexGreaterThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); + actual = dfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -126,7 +90,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = dfirstIndexGreaterThan( 1, new Float64Array( [ 0.0 ] ), 1, 0, new Float64Array( [ -0.0 ] ), 1, 0 ); @@ -156,8 +120,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -182,12 +146,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -199,6 +163,32 @@ tape( 'the function supports negative strides', function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 9.0, // 0 + 0.0, // 1 + 9.0, // 2 + 9.0, + 9.0 + ]); + + actual = dfirstIndexGreaterThan( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 9.0, // 2 0.0, // 1 @@ -207,9 +197,9 @@ tape( 'the function supports negative strides', function test( t ) { 9.0 ]); - actual = dfirstIndexGreaterThan( 3, x, -2, 4, y, -1, 2 ); - + actual = dfirstIndexGreaterThan( 3, x, 1, 0, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -240,8 +230,8 @@ tape( 'the function supports an `x` offset', function test( t ) { ]); actual = dfirstIndexGreaterThan( 4, x, 2, 1, y, 1, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -272,8 +262,8 @@ tape( 'the function supports a `y` offset', function test( t ) { ]); actual = dfirstIndexGreaterThan( 4, x, 1, 0, y, 2, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -300,7 +290,7 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.native.js index 6257fa8eb007..edcc4700711b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-greater-than/test/test.ndarray.native.js @@ -55,57 +55,21 @@ tape( 'the function returns the first index of an element which is greater than x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - // Nonnegative stride... actual = dfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length-1, x, 1, 1, y, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 0.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 0.0, 9.0, 9.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 0.0, 9.0, 9.0 ] ); - - actual = dfirstIndexGreaterThan( 3, x, -2, x.length-1, y, -2, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + t.end(); +}); - actual = dfirstIndexGreaterThan( 3, x, -2, x.length-2, y, -2, y.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is greater than a corresponding element in another array', opts, function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 2.0, 3.0, 4.0 ] ); - actual = dfirstIndexGreaterThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); + actual = dfirstIndexGreaterThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -135,7 +99,7 @@ tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = dfirstIndexGreaterThan( 1, new Float64Array( [ 0.0 ] ), 1, 0, new Float64Array( [ -0.0 ] ), 1, 0 ); @@ -165,8 +129,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -191,12 +155,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dfirstIndexGreaterThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -208,6 +172,32 @@ tape( 'the function supports negative strides', opts, function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 9.0, // 0 + 0.0, // 1 + 9.0, // 2 + 9.0, + 9.0 + ]); + + actual = dfirstIndexGreaterThan( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 9.0, // 2 0.0, // 1 @@ -216,9 +206,9 @@ tape( 'the function supports negative strides', opts, function test( t ) { 9.0 ]); - actual = dfirstIndexGreaterThan( 3, x, -2, 4, y, -1, 2 ); - + actual = dfirstIndexGreaterThan( 3, x, 1, 0, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -249,8 +239,8 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { ]); actual = dfirstIndexGreaterThan( 4, x, 2, 1, y, 1, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -281,8 +271,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { ]); actual = dfirstIndexGreaterThan( 4, x, 1, 0, y, 2, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -309,7 +299,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dfirstIndexGreaterThan( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/README.md b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/README.md index b1c10014545e..401157a9517a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/README.md @@ -149,7 +149,7 @@ var idx = dfirstIndexLessThan.ndarray( 3, x, 1, x.length-3, y, 1, y.length-3 ); ## Notes -- When comparing elements, the function checks whether an element in `x` is less than a corresponding element in `y` using the less-than operator `<`. As a consequence, comparisons involving `NaN` always evaluate to `false`. +- When comparing elements, the function checks whether an element in `x` is less than a corresponding element in `y` using the less-than operator `<`. As a consequence, comparisons involving `NaN` always evaluate to `false`, and `-0` and `+0` are considered the same.
@@ -215,8 +215,8 @@ console.log( idx ); Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array. ```c -double x[] = { 0.0, 0.0, 0.0, 0.0 }; -double y[] = { 0.0, 0.0, 1.0, 0.0 }; +const double x[] = { 0.0, 0.0, 0.0, 0.0 }; +const double y[] = { 0.0, 0.0, 1.0, 0.0 }; int idx = stdlib_strided_dfirst_index_less_than( 4, x, 1, y, 1 ); // returns 2 @@ -226,9 +226,9 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **X**: `[in] double*` first input array. -- **strideX**: `[in] CBLAS_INT` stride length. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. - **Y**: `[in] double*` second input array. -- **strideY**: `[in] CBLAS_INT` stride length. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. ```c CBLAS_INT stdlib_strided_dfirst_index_less_than( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY ); @@ -243,8 +243,8 @@ CBLAS_INT stdlib_strided_dfirst_index_less_than( const CBLAS_INT N, const double Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. ```c -double x[] = { 0.0, 0.0, 0.0, 0.0 }; -double y[] = { 0.0, 0.0, 1.0, 0.0 }; +const double x[] = { 0.0, 0.0, 0.0, 0.0 }; +const double y[] = { 0.0, 0.0, 1.0, 0.0 }; int idx = stdlib_strided_dfirst_index_less_than_ndarray( 4, x, 1, 0, y, 1, 0 ); // returns 2 @@ -254,11 +254,11 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **X**: `[in] double*` first input array. -- **strideX**: `[in] CBLAS_INT` stride length. -- **offsetX**: `[in] CBLAS_INT` starting index. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. - **Y**: `[in] double*` second input array. -- **strideY**: `[in] CBLAS_INT` stride length. -- **offsetY**: `[in] CBLAS_INT` starting index. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. +- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. ```c CBLAS_INT stdlib_strided_dfirst_index_less_than_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); @@ -294,7 +294,7 @@ int main( void ) { // Specify the number of indexed elements: const int N = 8; - // Specify stride lengths: + // Specify strides: const int strideX = 1; const int strideY = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/repl.txt index 4f8e1407a594..4ef77e96e6ce 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/repl.txt @@ -63,8 +63,8 @@ precision floating-point strided array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying - buffer, the offset parameters support indexing semantics based on - starting indices. + buffer, the offset parameters support indexing semantics based on starting + indices. Parameters ---------- @@ -102,13 +102,7 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using `N` and stride parameters: - > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 9.0, 0.0, 9.0, 9.0, 9.0 ] ); - > idx = {{alias}}.ndarray( 3, x, 2, 0, y, 2, 0 ) - 2 - - // Using an index offset: + // Using index offsets: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); > y = new {{alias:@stdlib/array/float64}}( [ 9.0, 2.0, 9.0, 9.0 ] ); > idx = {{alias}}.ndarray( 2, x, 1, 1, y, 1, 1 ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/types/test.ts index 2d3f8236839b..98cb0f141d51 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/docs/types/test.ts @@ -39,18 +39,19 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan( false, x, 1, y, 1 ); // $ExpectError dfirstIndexLessThan( null, x, 1, y, 1 ); // $ExpectError dfirstIndexLessThan( {}, x, 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( ( x: number ): number => x, x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... { - var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - dfirstIndexLessThan( x.length, '1', 1, y, 1 ); // $ExpectError - dfirstIndexLessThan( x.length, true, 1, y, 1 ); // $ExpectError - dfirstIndexLessThan( x.length, false, 1, y, 1 ); // $ExpectError - dfirstIndexLessThan( x.length, null, 1, y, 1 ); // $ExpectError - dfirstIndexLessThan( x.length, {}, 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( 3, '1', 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( 3, true, 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( 3, false, 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( 3, null, 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( 3, {}, 1, y, 1 ); // $ExpectError + dfirstIndexLessThan( 3, ( x: number ): number => x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -63,6 +64,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan( x.length, x, false, y, 1 ); // $ExpectError dfirstIndexLessThan( x.length, x, null, y, 1 ); // $ExpectError dfirstIndexLessThan( x.length, x, {}, y, 1 ); // $ExpectError + dfirstIndexLessThan( x.length, x, ( x: number ): number => x, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... @@ -74,6 +76,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan( x.length, x, 1, false, 1 ); // $ExpectError dfirstIndexLessThan( x.length, x, 1, null, 1 ); // $ExpectError dfirstIndexLessThan( x.length, x, 1, {}, 1 ); // $ExpectError + dfirstIndexLessThan( x.length, x, 1, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... @@ -86,6 +89,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan( x.length, x, 1, y, false ); // $ExpectError dfirstIndexLessThan( x.length, x, 1, y, null ); // $ExpectError dfirstIndexLessThan( x.length, x, 1, y, {} ); // $ExpectError + dfirstIndexLessThan( x.length, x, 1, y, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -94,6 +98,7 @@ import dfirstIndexLessThan = require( './index' ); var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); dfirstIndexLessThan(); // $ExpectError + dfirstIndexLessThan( 3 ); // $ExpectError dfirstIndexLessThan( 3, x ); // $ExpectError dfirstIndexLessThan( 3, x, 1 ); // $ExpectError dfirstIndexLessThan( 3, x, 1, y ); // $ExpectError @@ -118,18 +123,19 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan.ndarray( false, x, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( null, x, 1, 0, y, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( {}, x, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... { - var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - dfirstIndexLessThan.ndarray( x.length, '1', 1, 0, y, 1, 0 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, true, 1, 0, y, 1, 0 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, false, 1, 0, y, 1, 0 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, null, 1, 0, y, 1, 0 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, {}, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, '1', 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, true, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, false, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, null, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, {}, 1, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -142,6 +148,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan.ndarray( x.length, x, false, 0, y, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, null, 0, y, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, {}, 0, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( x.length, x, ( x: number ): number => x, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -154,6 +161,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan.ndarray( x.length, x, 1, false, y, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, null, y, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, {}, y, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Float64Array... @@ -165,6 +173,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan.ndarray( x.length, x, 1, 0, false, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, 0, null, 1, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, 0, {}, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( x.length, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... @@ -177,6 +186,7 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, false, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, null, 0 ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, {}, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... @@ -189,19 +199,20 @@ import dfirstIndexLessThan = require( './index' ); dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, false ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, null ); // $ExpectError dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, {} ); // $ExpectError + dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x ); // $ExpectError } - // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... { var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); dfirstIndexLessThan.ndarray(); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, x ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, x, 1 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, x, 1, 0 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1 ); // $ExpectError - dfirstIndexLessThan.ndarray( x.length, x, 1, 0, y, 1, 0, {} ); // $ExpectError + dfirstIndexLessThan.ndarray( 3 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, x ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, x, 1 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, x, 1, 0 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, x, 1, 0, y ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, x, 1, 0, y, 1 ); // $ExpectError + dfirstIndexLessThan.ndarray( 3, x, 1, 0, y, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/examples/c/example.c index 73c81b87173c..e510574d06c6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/examples/c/example.c @@ -27,7 +27,7 @@ int main( void ) { // Specify the number of indexed elements: const int N = 8; - // Specify stride lengths: + // Specify strides: const int strideX = 1; const int strideY = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.js index 55d7a1df75bd..72610cfe580f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.native.js index d80c07036777..bf2cf422e4ba 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/dfirst_index_less_than.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.js index 0962e0980740..718b16e8e900 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.js @@ -23,6 +23,10 @@ /** * Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.native.js index 8b7b73c97e5d..f3b93c8a83fe 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is less than a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/package.json b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/package.json index 2dad59ffe2dc..babda7c8b011 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/package.json @@ -59,6 +59,8 @@ "index", "search", "element", + "less", + "compare", "array", "ndarray", "strided", diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/addon.c index f36dbdb54446..a8eda9a52510 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/addon.c @@ -36,8 +36,8 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 5 ); 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 ); STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 4 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 3 ); STDLIB_NAPI_CREATE_INT32( env, API_SUFFIX(stdlib_strided_dfirst_index_less_than)( N, X, strideX, Y, strideY ), idx ); // TODO: Need to revisit in order to support int64_t for CBLAS_INT return idx; @@ -55,9 +55,9 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 4 ); STDLIB_NAPI_CREATE_INT32( env, API_SUFFIX(stdlib_strided_dfirst_index_less_than_ndarray)( N, X, strideX, offsetX, Y, strideY, offsetY ), idx ); // TODO: Need to revisit in order to support int64_t for CBLAS_INT return idx; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/main.c index a0232c3da79e..8d550d93c0ef 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/src/main.c @@ -23,12 +23,12 @@ /** * Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array. * -* @param N number of indexed elements -* @param X first input array -* @param strideX stride length for X -* @param Y second input array -* @param strideY stride length for Y -* @return index +* @param N number of indexed elements +* @param X first input array +* @param strideX stride length for X +* @param Y second input array +* @param strideY stride length for Y +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dfirst_index_less_than)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY ) { CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); @@ -39,14 +39,14 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dfirst_index_less_than)( const CBLAS_INT N, /** * Returns the index of the first element in a double-precision floating-point strided array which is less than a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * -* @param N number of indexed elements -* @param X first input array -* @param strideX stride length for X -* @param offsetX starting index for X -* @param Y second input array -* @param strideY stride length for Y -* @param offsetY starting index for Y -* @return index +* @param N number of indexed elements +* @param X first input array +* @param strideX stride length for X +* @param offsetX starting index for X +* @param Y second input array +* @param strideY stride length for Y +* @param offsetY starting index for Y +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dfirst_index_less_than_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { CBLAS_INT ix; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.js index 7c95a2a21eb7..b044b9615856 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.js @@ -33,6 +33,11 @@ tape( 'main export is a function', function test( t ) { t.end(); }); +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( dfirstIndexLessThan.length, 5, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the first index of an element which is less than a corresponding element in another array', function test( t ) { var actual; var x; @@ -41,68 +46,33 @@ tape( 'the function returns the first index of an element which is less than a c x = new Float64Array( [ 6.0, 1.0, 5.0, 5.0, 5.0, 5.0 ] ); y = new Float64Array( [ 5.0, 2.0, 4.0, 4.0, 4.0, 4.0 ] ); - // Nonnegative stride... actual = dfirstIndexLessThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - x = new Float64Array( [ 6.0, 5.0, 1.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 2.0, 4.0, 4.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, y, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); - y = new Float64Array( [ 2.0, 6.0, 5.0, 4.0, 3.0, 5.0 ] ); - - actual = dfirstIndexLessThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 3.0, 5.0, 4.0, 6.0, 2.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 6.0, 5.0, 5.0, 3.0, 6.0 ] ); - - actual = dfirstIndexLessThan( 3, x, -2, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 5.0, 5.0, 6.0, 3.0, 2.0, 4.0 ] ); - y = new Float64Array( [ 6.0, 6.0, 5.0, 4.0, 3.0, 4.0 ] ); + t.end(); +}); - actual = dfirstIndexLessThan( 3, x, -1, y, -2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is less than a corresponding element in another array', function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 0.0, 1.0, 2.0 ] ); - actual = dfirstIndexLessThan( 3, x, -2, y, -2 ); + actual = dfirstIndexLessThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = dfirstIndexLessThan( 0, x, 1, y, 1 ); + actual = dfirstIndexLessThan( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dfirstIndexLessThan( -1, x, 1, y, 1 ); + actual = dfirstIndexLessThan( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -150,8 +120,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -176,12 +146,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -193,6 +163,32 @@ tape( 'the function supports negative strides', function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 5.0, // 0 + 2.0, // 1 + 4.0, // 2 + 0.0, + 0.0 + ]); + + actual = dfirstIndexLessThan( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 3.0, // 2 2.0, // 1 @@ -201,9 +197,9 @@ tape( 'the function supports negative strides', function test( t ) { 0.0 ]); - actual = dfirstIndexLessThan( 3, x, -2, y, -1 ); - + actual = dfirstIndexLessThan( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -230,8 +226,8 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -266,5 +262,6 @@ tape( 'the function supports view offsets', function test( t ) { actual = dfirstIndexLessThan( 3, x1, -2, y1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.native.js index 01af96a0fc89..4a3accdd7ff7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.dfirst_index_less_than.native.js @@ -42,6 +42,11 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); +tape( 'the function has an arity of 5', opts, function test( t ) { + t.strictEqual( dfirstIndexLessThan.length, 5, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the first index of an element which is less than a corresponding element in another array', opts, function test( t ) { var actual; var x; @@ -50,68 +55,33 @@ tape( 'the function returns the first index of an element which is less than a c x = new Float64Array( [ 6.0, 1.0, 5.0, 5.0, 5.0, 5.0 ] ); y = new Float64Array( [ 5.0, 2.0, 4.0, 4.0, 4.0, 4.0 ] ); - // Nonnegative stride... actual = dfirstIndexLessThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - x = new Float64Array( [ 6.0, 5.0, 1.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 2.0, 4.0, 4.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, y, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); - y = new Float64Array( [ 2.0, 6.0, 5.0, 4.0, 3.0, 5.0 ] ); - - actual = dfirstIndexLessThan( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 3.0, 5.0, 4.0, 6.0, 2.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 6.0, 5.0, 5.0, 3.0, 6.0 ] ); - - actual = dfirstIndexLessThan( 3, x, -2, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 5.0, 5.0, 6.0, 3.0, 2.0, 4.0 ] ); - y = new Float64Array( [ 6.0, 6.0, 5.0, 4.0, 3.0, 4.0 ] ); + t.end(); +}); - actual = dfirstIndexLessThan( 3, x, -1, y, -2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is less than a corresponding element in another array', opts, function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 0.0, 1.0, 2.0 ] ); - actual = dfirstIndexLessThan( 3, x, -2, y, -2 ); + actual = dfirstIndexLessThan( x.length, x, 1, y, 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = dfirstIndexLessThan( 0, x, 1, y, 1 ); + actual = dfirstIndexLessThan( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dfirstIndexLessThan( -1, x, 1, y, 1 ); + actual = dfirstIndexLessThan( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -159,8 +129,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -185,12 +155,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -202,6 +172,32 @@ tape( 'the function supports negative strides', opts, function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 5.0, // 0 + 2.0, // 1 + 4.0, // 2 + 0.0, + 0.0 + ]); + + actual = dfirstIndexLessThan( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 3.0, // 2 2.0, // 1 @@ -210,9 +206,9 @@ tape( 'the function supports negative strides', opts, function test( t ) { 0.0 ]); - actual = dfirstIndexLessThan( 3, x, -2, y, -1 ); - + actual = dfirstIndexLessThan( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -239,8 +235,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dfirstIndexLessThan( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -275,5 +271,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { actual = dfirstIndexLessThan( 3, x1, -2, y1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.js index 11b1ebdf9046..4d86c846465d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.js @@ -33,6 +33,11 @@ tape( 'main export is a function', function test( t ) { t.end(); }); +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( dfirstIndexLessThan.length, 7, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the first index of an element which is less than a corresponding element in another array', function test( t ) { var actual; var x; @@ -41,68 +46,33 @@ tape( 'the function returns the first index of an element which is less than a c x = new Float64Array( [ 6.0, 1.0, 5.0, 5.0, 5.0, 5.0 ] ); y = new Float64Array( [ 5.0, 2.0, 4.0, 4.0, 4.0, 4.0 ] ); - // Nonnegative stride... actual = dfirstIndexLessThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - x = new Float64Array( [ 6.0, 5.0, 1.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 2.0, 4.0, 4.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); - y = new Float64Array( [ 2.0, 6.0, 5.0, 4.0, 3.0, 5.0 ] ); - - actual = dfirstIndexLessThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 3.0, 5.0, 4.0, 6.0, 2.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 6.0, 5.0, 5.0, 3.0, 6.0 ] ); - - actual = dfirstIndexLessThan( 3, x, -2, 4, y, -1, 2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 5.0, 5.0, 6.0, 3.0, 2.0, 4.0 ] ); - y = new Float64Array( [ 6.0, 6.0, 5.0, 4.0, 3.0, 4.0 ] ); + t.end(); +}); - actual = dfirstIndexLessThan( 3, x, -1, 2, y, -2, 4 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is less than a corresponding element in another array', function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 0.0, 1.0, 2.0 ] ); - actual = dfirstIndexLessThan( 3, x, -2, 4, y, -2, 4 ); + actual = dfirstIndexLessThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = dfirstIndexLessThan( 0, x, 1, 0, y, 1, 0 ); + actual = dfirstIndexLessThan( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dfirstIndexLessThan( -1, x, 1, 0, y, 1, 0 ); + actual = dfirstIndexLessThan( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -150,8 +120,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -176,12 +146,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -193,6 +163,32 @@ tape( 'the function supports negative strides', function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 5.0, // 0 + 2.0, // 1 + 4.0, // 2 + 0.0, + 0.0 + ]); + + actual = dfirstIndexLessThan( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 3.0, // 2 2.0, // 1 @@ -201,9 +197,9 @@ tape( 'the function supports negative strides', function test( t ) { 0.0 ]); - actual = dfirstIndexLessThan( 3, x, -2, 4, y, -1, 2 ); - + actual = dfirstIndexLessThan( 3, x, 1, 0, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -226,8 +222,8 @@ tape( 'the function supports an `x` offset', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, 2, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -250,8 +246,8 @@ tape( 'the function supports a `y` offset', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, 0, y, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -278,7 +274,7 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.native.js index 0aff544155b6..65e6f2e9b2b2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dfirst-index-less-than/test/test.ndarray.native.js @@ -42,6 +42,11 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); +tape( 'the function has an arity of 7', opts, function test( t ) { + t.strictEqual( dfirstIndexLessThan.length, 7, 'has expected arity' ); + t.end(); +}); + tape( 'the function returns the first index of an element which is less than a corresponding element in another array', opts, function test( t ) { var actual; var x; @@ -50,68 +55,33 @@ tape( 'the function returns the first index of an element which is less than a c x = new Float64Array( [ 6.0, 1.0, 5.0, 5.0, 5.0, 5.0 ] ); y = new Float64Array( [ 5.0, 2.0, 4.0, 4.0, 4.0, 4.0 ] ); - // Nonnegative stride... actual = dfirstIndexLessThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - x = new Float64Array( [ 6.0, 5.0, 1.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 2.0, 4.0, 4.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 6.0, 5.0, 5.0, 5.0, 1.0, 5.0 ] ); - y = new Float64Array( [ 5.0, 4.0, 4.0, 4.0, 2.0, 4.0 ] ); - - actual = dfirstIndexLessThan( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); - y = new Float64Array( [ 2.0, 6.0, 5.0, 4.0, 3.0, 5.0 ] ); - - actual = dfirstIndexLessThan( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 3.0, 5.0, 4.0, 6.0, 2.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 6.0, 5.0, 5.0, 3.0, 6.0 ] ); - - actual = dfirstIndexLessThan( 3, x, -2, 4, y, -1, 2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 5.0, 5.0, 6.0, 3.0, 2.0, 4.0 ] ); - y = new Float64Array( [ 6.0, 6.0, 5.0, 4.0, 3.0, 4.0 ] ); + t.end(); +}); - actual = dfirstIndexLessThan( 3, x, -1, 2, y, -2, 4 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find an element which is less than a corresponding element in another array', opts, function test( t ) { + var actual; + var x; + var y; - x = new Float64Array( [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ] ); - y = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + y = new Float64Array( [ 0.0, 1.0, 2.0 ] ); - actual = dfirstIndexLessThan( 3, x, -2, 4, y, -2, 4 ); + actual = dfirstIndexLessThan( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = dfirstIndexLessThan( 0, x, 1, 0, y, 1, 0 ); + actual = dfirstIndexLessThan( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dfirstIndexLessThan( -1, x, 1, 0, y, 1, 0 ); + actual = dfirstIndexLessThan( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); @@ -159,8 +129,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -185,12 +155,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -202,6 +172,32 @@ tape( 'the function supports negative strides', opts, function test( t ) { 4.0, 5.0 // 0 ]); + y = new Float64Array([ + 5.0, // 0 + 2.0, // 1 + 4.0, // 2 + 0.0, + 0.0 + ]); + + actual = dfirstIndexLessThan( 3, x, -2, 4, y, 1, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 4.0, + 5.0 + ]); y = new Float64Array([ 3.0, // 2 2.0, // 1 @@ -210,9 +206,9 @@ tape( 'the function supports negative strides', opts, function test( t ) { 0.0 ]); - actual = dfirstIndexLessThan( 3, x, -2, 4, y, -1, 2 ); - + actual = dfirstIndexLessThan( 3, x, 1, 0, y, -1, 2 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -235,8 +231,8 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, 2, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -259,8 +255,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { ]); actual = dfirstIndexLessThan( 3, x, 1, 0, y, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -287,7 +283,7 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dfirstIndexLessThan( 3, x, 2, 0, y, -1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/README.md b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/README.md index acc7b2d69a52..64a1b3e4eebd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/README.md @@ -69,11 +69,11 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Float64Array`][mdn-float64array]. -- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: search vector stored as a [`Float64Array`][mdn-float64array]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking column match candidates. This parameter is ignored if the function is provided an input matrix stored in column-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. When an input matrix is stored in column-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -170,14 +170,14 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Float64Array`][mdn-float64array]. -- **strideA1**: stride of the first dimension of `A`. -- **strideA2**: stride of the second dimension of `A`. +- **strideA1**: stride length for the first dimension of `A`. +- **strideA2**: stride length for the second dimension of `A`. - **offsetA**: starting index for `A`. - **x**: search vector stored as a [`Float64Array`][mdn-float64array]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking column match candidates. This parameter is ignored if the function is provided an input matrix stored in column-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. - **offsetW**: starting index for `workspace`. When an input matrix is stored in column-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -299,7 +299,7 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] double*` input matrix. -- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: `[in] CBLAS_INT` stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **X**: `[in] double*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **workspace**: `[inout] uint8_t*` workspace array for tracking column match candidates. This parameter is ignored if the function is provided an input matrix stored in column-major order. @@ -345,8 +345,8 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] double*` input matrix. -- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. -- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **strideA1**: `[in] CBLAS_INT` stride length for the first dimension of `A`. +- **strideA2**: `[in] CBLAS_INT` stride length for the second dimension of `A`. - **offsetA**: `[in] CBLAS_INT` starting index for `A`. - **X**: `[in] double*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/repl.txt index 25637fd1b4e3..94b3160dbb98 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/repl.txt @@ -25,8 +25,8 @@ Input matrix `A`. LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + Stride length for the first dimension of `A` (a.k.a., leading dimension + of the matrix `A`). x: Float64Array Search vector. @@ -79,10 +79,10 @@ Input matrix `A`. sa1: integer - Stride of the first dimension of `A`. + Stride length for the first dimension of `A`. sa2: integer - Stride of the second dimension of `A`. + Stride length for the second dimension of `A`. oa: integer Starting index for `A`. @@ -121,4 +121,3 @@ See Also -------- - diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/types/index.d.ts index ad877713f204..d857b8ac6942 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/types/index.d.ts @@ -38,7 +38,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @param workspace - workspace array for tracking column match candidates @@ -49,7 +49,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * - * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0, 0.0 ] ); * var workspace = new Uint8Array( 2 ); * @@ -69,8 +69,8 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param strideA1 - stride of the first dimension of `A` - * @param strideA2 - stride of the second dimension of `A` + * @param strideA1 - stride length for the first dimension of `A` + * @param strideA2 - stride length for the second dimension of `A` * @param offsetA - starting index for `A` * @param x - search vector * @param strideX - stride length for `x` @@ -84,7 +84,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * - * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0, 0.0 ] ); * var workspace = new Uint8Array( 2 ); * @@ -106,7 +106,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix -* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @param workspace - workspace array for tracking column match candidates @@ -117,7 +117,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0, 0.0 ] ); * var workspace = new Uint8Array( 2 ); * @@ -128,7 +128,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0, 0.0 ] ); * var workspace = new Uint8Array( 2 ); * diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/types/test.ts index 4317de820597..e9293ed613ef 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/docs/types/test.ts @@ -183,7 +183,7 @@ import dindexOfColumn = require( './index' ); dindexOfColumn( 'row-major', 2, 2, A, 2, x ); // $ExpectError dindexOfColumn( 'row-major', 2, 2, A, 2, x, 1 ); // $ExpectError dindexOfColumn( 'row-major', 2, 2, A, 2, x, 1, w ); // $ExpectError - dindexOfColumn( 'row-major', 2, 2, A, 2, x, 1, w, 1, 0 ); // $ExpectError + dindexOfColumn( 'row-major', 2, 2, A, 2, x, 1, w, 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -399,5 +399,5 @@ import dindexOfColumn = require( './index' ); dindexOfColumn.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError dindexOfColumn.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w ); // $ExpectError dindexOfColumn.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1 ); // $ExpectError - dindexOfColumn.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0, 0 ); // $ExpectError + dindexOfColumn.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.js index 6ff35470c6bf..11134bddb4d1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.js @@ -43,7 +43,7 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking column match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.native.js index 36ab6c8caa9f..bc873160ed52 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/dindex_of_column.native.js @@ -42,7 +42,7 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking column match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.js index 774fcedff3cf..5bfa373f63c9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.js @@ -38,8 +38,8 @@ var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.native.js index 5247becb2eca..28e2d81408aa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/lib/ndarray.native.js @@ -38,8 +38,8 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/src/main.c index b5426833962a..efd1da4877ab 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-column/src/main.c @@ -24,16 +24,16 @@ /** * Returns the index of the first column in a double-precision floating-point input matrix which has the same elements as a provided search vector. * -* @param order storage layout -* @param M number of rows in `A` -* @param N number of columns in `A` -* @param A input matrix -* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param X search vector -* @param strideX stride length for `X` -* @param workspace workspace array for tracking column match candidates -* @param strideW stride length for `workspace` -* @return column index +* @param order storage layout +* @param M number of rows in `A` +* @param N number of columns in `A` +* @param A input matrix +* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param X search vector +* @param strideX stride length for `X` +* @param workspace workspace array for tracking column match candidates +* @param strideW stride length for `workspace` +* @return column index */ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_column)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, const double *X, const CBLAS_INT strideX, uint8_t *workspace, const CBLAS_INT strideW ) { CBLAS_INT sa1; @@ -56,19 +56,19 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_column)( const CBLAS_LAYOUT order, /** * Returns the index of the first column in a double-precision floating-point input matrix which has the same elements as a provided search vector using alternative indexing semantics. * -* @param M number of rows in `A` -* @param N number of columns in `A` -* @param A input matrix -* @param strideA1 stride of the first dimension of `A` -* @param strideA2 stride of the second dimension of `A` -* @param offsetA starting index for `A` -* @param X search vector -* @param strideX stride length for `X` -* @param offsetX starting index for `X` -* @param workspace workspace array for tracking column match candidates -* @param strideW stride length for `workspace` -* @param offsetW starting index for `workspace` -* @return column index +* @param M number of rows in `A` +* @param N number of columns in `A` +* @param A input matrix +* @param strideA1 stride length for the first dimension of `A` +* @param strideA2 stride length for the second dimension of `A` +* @param offsetA starting index for `A` +* @param X search vector +* @param strideX stride length for `X` +* @param offsetX starting index for `X` +* @param workspace workspace array for tracking column match candidates +* @param strideW stride length for `workspace` +* @param offsetW starting index for `workspace` +* @return column index */ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_column_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, uint8_t *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { CBLAS_INT da0; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/README.md b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/README.md index bfa4b21dc416..115be12b3fa7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/README.md @@ -47,7 +47,7 @@ Returns the index of the first falsy element in a double-precision floating-poin ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); var idx = dindexOfFalsy( x.length, x, 1 ); // returns 2 @@ -75,7 +75,7 @@ The `N` and stride parameters determine which elements in the strided array are ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); var idx = dindexOfFalsy( 4, x, 2 ); // returns 1 @@ -87,7 +87,7 @@ Note that indexing is relative to the first index. To introduce an offset, use [ var Float64Array = require( '@stdlib/array/float64' ); // Initial array... -var x0 = new Float64Array( [ 3.0, 3.0, 3.0, 0.0, 5.0, 3.0 ] ); +var x0 = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); // Create an offset view... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element @@ -104,7 +104,7 @@ Returns the index of the first falsy element in a double-precision floating-poin ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); var idx = dindexOfFalsy.ndarray( x.length, x, 1, 0 ); // returns 2 @@ -119,7 +119,7 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, 3.0, 0.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 0.0 ] ); var idx = dindexOfFalsy.ndarray( 3, x, 1, x.length-3 ); // returns 2 @@ -135,7 +135,6 @@ var idx = dindexOfFalsy.ndarray( 3, x, 1, x.length-3 ); ## Notes -- If the function is unable to find a falsy element, the function returns `-1`. - Both functions explicitly treat `NaN` values as falsy. @@ -198,7 +197,7 @@ console.log( idx ); Returns the index of the first falsy element in a double-precision floating-point strided array. ```c -const double x[] = { 3.0, 3.0, 0.0, 4.0 }; +const double x[] = { 1.0, 2.0, 0.0, 3.0 }; int idx = stdlib_strided_dindex_of_falsy( 4, x, 1 ); // returns 2 @@ -219,7 +218,7 @@ CBLAS_INT stdlib_strided_dindex_of_falsy( const CBLAS_INT N, const double *X, co Returns the index of the first falsy element in a double-precision floating-point strided array using alternative indexing semantics. ```c -const double x[] = { 3.0, 3.0, 0.0, 4.0 }; +const double x[] = { 1.0, 2.0, 0.0, 3.0 }; int idx = stdlib_strided_dindex_of_falsy_ndarray( 4, x, 1, 0 ); // returns 2 @@ -264,7 +263,7 @@ CBLAS_INT stdlib_strided_dindex_of_falsy_ndarray( const CBLAS_INT N, const doubl int main( void ) { // Create a strided array: - const double x[] = { 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 }; + const double x[] = { 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; // Specify the number of indexed elements: const int N = 8; @@ -312,6 +311,10 @@ int main( void ) { [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/repl.txt index 0cd12038bebc..766be7b1ce62 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/repl.txt @@ -9,7 +9,7 @@ Indexing is relative to the first index. To introduce an offset, use a typed array view. - if `N <= 0`, the function returns `-1`. + If `N <= 0`, the function returns `-1`. The function explicitly treats `NaN` values as falsy. @@ -31,10 +31,22 @@ Examples -------- - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 3.0, 0.0, 2.0, 4.0, 1.0 ] ); + // Standard usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 2 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0 ] ); + > var idx = {{alias}}( 3, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 1 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first falsy element in a double-precision floating- @@ -44,6 +56,8 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -65,9 +79,15 @@ Examples -------- - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 3.0, 0.0, 2.0, 4.0, 1.0 ] ); + // Standard usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 2 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/index.d.ts index 3400f7cf146d..309ae6a54158 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -38,10 +38,10 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * - * var x = new Float64Array( [ 1.0, 0.0, 3.0, 2.0 ] ); + * var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1 ); - * // returns 1 + * // returns 2 */ ( N: number, x: Float64Array, strideX: number ): number; @@ -50,7 +50,7 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -62,10 +62,10 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * - * var x = new Float64Array( [ 1.0, 0.0, 3.0, 2.0 ] ); + * var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dindexOfFalsy.ndarray( x.length, x, 1, 0 ); - * // returns 1 + * // returns 2 */ ndarray( N: number, x: Float64Array, strideX: number, offsetX: number ): number; } @@ -75,7 +75,7 @@ interface Routine { * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -86,18 +86,18 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 0.0, 3.0, 2.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1 ); -* // returns 1 +* // returns 2 * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 0.0, 3.0, 2.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dindexOfFalsy.ndarray( x.length, x, 1, 0 ); -* // returns 1 +* // returns 2 */ declare var dindexOfFalsy: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/test.ts index ad30f74e15a7..8aabdc9e08cd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/docs/types/test.ts @@ -16,8 +16,6 @@ * limitations under the License. */ -/* eslint-disable space-in-parens */ - import dindexOfFalsy = require( './index' ); @@ -39,6 +37,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy( false, x, 1 ); // $ExpectError dindexOfFalsy( null, x, 1 ); // $ExpectError dindexOfFalsy( {}, x, 1 ); // $ExpectError + dindexOfFalsy( ( 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... @@ -48,6 +47,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy( x.length, false, 1 ); // $ExpectError dindexOfFalsy( x.length, null, 1 ); // $ExpectError dindexOfFalsy( x.length, {}, 1 ); // $ExpectError + dindexOfFalsy( 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... @@ -59,6 +59,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy( x.length, x, false ); // $ExpectError dindexOfFalsy( x.length, x, null ); // $ExpectError dindexOfFalsy( x.length, x, {} ); // $ExpectError + dindexOfFalsy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -66,7 +67,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy(); // $ExpectError dindexOfFalsy( 3 ); // $ExpectError dindexOfFalsy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError - dindexOfFalsy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // $ExpectError + dindexOfFalsy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -85,6 +86,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy.ndarray( false, x, 1, 1 ); // $ExpectError dindexOfFalsy.ndarray( null, x, 1, 1 ); // $ExpectError dindexOfFalsy.ndarray( {}, x, 1, 1 ); // $ExpectError + dindexOfFalsy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... @@ -94,6 +96,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy.ndarray( x.length, false, 1, 1 ); // $ExpectError dindexOfFalsy.ndarray( x.length, null, 1, 1 ); // $ExpectError dindexOfFalsy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + dindexOfFalsy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -105,6 +108,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy.ndarray( x.length, x, false, 1 ); // $ExpectError dindexOfFalsy.ndarray( x.length, x, null, 1 ); // $ExpectError dindexOfFalsy.ndarray( x.length, x, {}, 1 ); // $ExpectError + dindexOfFalsy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -116,6 +120,7 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy.ndarray( x.length, x, 1, false ); // $ExpectError dindexOfFalsy.ndarray( x.length, x, 1, null ); // $ExpectError dindexOfFalsy.ndarray( x.length, x, 1, {} ); // $ExpectError + dindexOfFalsy.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... @@ -124,5 +129,5 @@ import dindexOfFalsy = require( './index' ); dindexOfFalsy.ndarray( 3 ); // $ExpectError dindexOfFalsy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError dindexOfFalsy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); // $ExpectError - dindexOfFalsy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, 0 ); // $ExpectError + dindexOfFalsy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/examples/c/example.c index 66744f037476..be8f8b65fb43 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/examples/c/example.c @@ -21,7 +21,7 @@ int main( void ) { // Create a strided array: - const double x[] = { 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 }; + const double x[] = { 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; // Specify the number of indexed elements: const int N = 8; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.js index ce6232d3adf7..5aac21692d62 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -42,7 +42,7 @@ var ndarray = require( './ndarray.js' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1 ); * // returns 2 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.native.js index 1c43bb1f28df..145bdcd32d53 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/dindex_of_falsy.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -41,7 +41,7 @@ var addon = require( './../src/addon.node' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1 ); * // returns 2 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/index.js index 0e6aa8ee8568..1f05c71f4012 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/index.js @@ -27,7 +27,7 @@ * var Float64Array = require( '@stdlib/array/float64' ); * var dindexOfFalsy = require( '@stdlib/blas/ext/base/dindex-of-falsy' ); * -* var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1 ); * // returns 2 @@ -36,7 +36,7 @@ * var Float64Array = require( '@stdlib/array/float64' ); * var dindexOfFalsy = require( '@stdlib/blas/ext/base/dindex-of-falsy' ); * -* var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); * * var idx = dindexOfFalsy.ndarray( x.length, x, 1, 0 ); * // returns 2 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.js index 49660995cb4d..84344f8f1265 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.js @@ -25,7 +25,7 @@ * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -37,7 +37,7 @@ * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1, 0 ); * // returns 2 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.native.js index 307d81d8ce76..78fb3f62ccb9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -42,7 +42,7 @@ var addon = require( './../src/addon.node' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 3.0, 3.0, 0.0, 3.0, 4.0, 3.0, -1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 5.0, 6.0, 7.0 ] ); * * var idx = dindexOfFalsy( x.length, x, 1, 0 ); * // returns 2 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/src/main.c index 4e16af5a2cb9..e0fd2dc12ac1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/src/main.c @@ -24,10 +24,10 @@ /** * Returns the index of the first falsy element in a double-precision floating-point strided array. * -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @return index +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_falsy)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ) { CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); @@ -37,11 +37,11 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_falsy)( const CBLAS_INT N, const d /** * Returns the index of the first falsy element in a double-precision floating-point strided array using alternative indexing semantics. * -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @param offsetX starting index -* @return index +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @param offsetX starting index +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_falsy_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { CBLAS_INT ix; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.js index 89cd9d5a03d3..988b0c3e1495 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.js @@ -39,28 +39,29 @@ tape( 'the function returns the index of the first falsy element', function test x = new Float64Array( [ 1.0, 0.0, 1.0, 2.0, 0.0, 1.0 ] ); - // Nonnegative stride... actual = dindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - // Negative stride... - actual = dindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); +tape( 'the function ignores truthy elements (e.g., non-zero values)', function test( t ) { + var actual; + var x; - actual = dindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + x = new Float64Array( [ 3.0, 5.0, 0.0, 2.0 ] ); + + actual = dindexOfFalsy( x.length, x, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function treats `NaN` values as falsy (e.g., `NaN`, `0`)', function test( t ) { +tape( 'the function explicitly treats `NaN` values as falsy', function test( t ) { var actual; var x; - x = new Float64Array( [ 3.0, 5.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); actual = dindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); @@ -80,14 +81,72 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1 ); + actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1 ); + actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.native.js index f9795d29370d..bb890fd838dc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.dindex_of_falsy.native.js @@ -48,28 +48,29 @@ tape( 'the function returns the index of the first falsy element', opts, functio x = new Float64Array( [ 1.0, 0.0, 1.0, 2.0, 0.0, 1.0 ] ); - // Nonnegative stride... actual = dindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - // Negative stride... - actual = dindexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); +tape( 'the function ignores truthy elements (e.g., non-zero values)', opts, function test( t ) { + var actual; + var x; - actual = dindexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + x = new Float64Array( [ 3.0, 5.0, 0.0, 2.0 ] ); + + actual = dindexOfFalsy( x.length, x, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function treats `NaN` values as falsy (e.g., `NaN`, `0`)', opts, function test( t ) { +tape( 'the function explicitly treats `NaN` values as falsy', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 3.0, 5.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); actual = dindexOfFalsy( x.length, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); @@ -89,14 +90,72 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1 ); + actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1 ); + actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dindexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dindexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.js index 9a8cd31944f6..be8d025659ad 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.js @@ -39,37 +39,29 @@ tape( 'the function returns the index of the first falsy element', function test x = new Float64Array( [ 1.0, 0.0, 1.0, 2.0, 0.0, 1.0 ] ); - // Nonnegative stride... actual = dindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); +tape( 'the function ignores truthy elements (e.g., non-zero values)', function test( t ) { + var actual; + var x; - // Negative stride... - actual = dindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + x = new Float64Array( [ 3.0, 5.0, 0.0, 2.0 ] ); - actual = dindexOfFalsy( 3, x, -2, x.length-1 ); + actual = dindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); -tape( 'the function treats `NaN` values as falsy (e.g., `NaN`, `0`)', function test( t ) { +tape( 'the function explicitly treats `NaN` values as falsy', function test( t ) { var actual; var x; - x = new Float64Array( [ 3.0, 5.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); actual = dindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); @@ -89,14 +81,69 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1, 0 ); + actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1, 0 ); + actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = dindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.native.js index 39bee715d0c6..1ea06eee6e94 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-falsy/test/test.ndarray.native.js @@ -48,37 +48,29 @@ tape( 'the function returns the index of the first falsy element', opts, functio x = new Float64Array( [ 1.0, 0.0, 1.0, 2.0, 0.0, 1.0 ] ); - // Nonnegative stride... actual = dindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dindexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); +tape( 'the function ignores truthy elements (e.g., non-zero values)', opts, function test( t ) { + var actual; + var x; - // Negative stride... - actual = dindexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + x = new Float64Array( [ 3.0, 5.0, 0.0, 2.0 ] ); - actual = dindexOfFalsy( 3, x, -2, x.length-1 ); + actual = dindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dindexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); -tape( 'the function treats `NaN` values as falsy (e.g., `NaN`, `0`)', opts, function test( t ) { +tape( 'the function explicitly treats `NaN` values as falsy', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 3.0, 5.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); actual = dindexOfFalsy( x.length, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); @@ -98,14 +90,69 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1, 0 ); + actual = dindexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 0.0, 0.0 ] ), 1, 0 ); + actual = dindexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dindexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, + 1.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = dindexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/repl.txt index 25a5b034fb96..e65ec7ee4ec5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/repl.txt @@ -42,7 +42,7 @@ > var idx = {{alias}}( 3, 1.0, x, 2 ) 1 - // View offsets: + // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 1.0, 1.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var idx = {{alias}}( 2, 1.0, x1, 1 ) @@ -87,7 +87,7 @@ > var idx = {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) 2 - // Advanced indexing: + // Using an index offset: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 1.0, 3.0, 1.0, 4.0 ] ); > var idx = {{alias}}.ndarray( 3, 1.0, x, 2, 1 ) 0 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/types/test.ts index fff8d364263d..41f423e809b4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/docs/types/test.ts @@ -37,6 +37,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual( false, 2.0, x, 1 ); // $ExpectError dindexOfNotEqual( null, 2.0, x, 1 ); // $ExpectError dindexOfNotEqual( {}, 2.0, x, 1 ); // $ExpectError + dindexOfNotEqual( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -48,6 +49,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual( x.length, false, x, 1 ); // $ExpectError dindexOfNotEqual( x.length, null, x, 1 ); // $ExpectError dindexOfNotEqual( x.length, {}, x, 1 ); // $ExpectError + dindexOfNotEqual( x.length, ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float64Array... @@ -57,6 +59,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual( x.length, 1.0, false, 1 ); // $ExpectError dindexOfNotEqual( x.length, 1.0, null, 1 ); // $ExpectError dindexOfNotEqual( x.length, 1.0, {}, 1 ); // $ExpectError + dindexOfNotEqual( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -68,6 +71,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual( x.length, 2.0, x, false ); // $ExpectError dindexOfNotEqual( x.length, 2.0, x, null ); // $ExpectError dindexOfNotEqual( x.length, 2.0, x, {} ); // $ExpectError + dindexOfNotEqual( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -94,6 +98,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError dindexOfNotEqual.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError dindexOfNotEqual.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + dindexOfNotEqual.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... @@ -105,6 +110,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual.ndarray( x.length, false, x, 1, 1 ); // $ExpectError dindexOfNotEqual.ndarray( x.length, null, x, 1, 1 ); // $ExpectError dindexOfNotEqual.ndarray( x.length, {}, x, 1, 1 ); // $ExpectError + dindexOfNotEqual.ndarray( x.length, ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float64Array... @@ -114,6 +120,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError dindexOfNotEqual.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError dindexOfNotEqual.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + dindexOfNotEqual.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -125,6 +132,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError dindexOfNotEqual.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError dindexOfNotEqual.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + dindexOfNotEqual.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -136,6 +144,7 @@ import dindexOfNotEqual = require( './index' ); dindexOfNotEqual.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError dindexOfNotEqual.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError dindexOfNotEqual.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + dindexOfNotEqual.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.js index 031bcd089736..37541133d141 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.js @@ -44,33 +44,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOfNotEqual( x.length, 1.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dindexOfNotEqual( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = dindexOfNotEqual( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -131,13 +107,19 @@ tape( 'the function supports an `x` stride', function test( t ) { t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ] ); + x = new Float64Array([ + 1.0, // 2 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 0 + ]); - actual = dindexOfNotEqual( x.length, 1.0, x, -1 ); + actual = dindexOfNotEqual( 3, 1.0, x, -2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.native.js index 7b5ee6595253..bf6ccc93f735 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.dindex_of_not_equal.native.js @@ -53,33 +53,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOfNotEqual( x.length, 1.0, x, 1 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dindexOfNotEqual( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = dindexOfNotEqual( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -140,13 +116,19 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0 ] ); + x = new Float64Array([ + 1.0, // 2 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 0 + ]); - actual = dindexOfNotEqual( x.length, 1.0, x, -1 ); + actual = dindexOfNotEqual( 3, 1.0, x, -2 ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.js index ecd2cdab08aa..3a6b1646bd9d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.js @@ -44,33 +44,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOfNotEqual( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dindexOfNotEqual( x.length, 2.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = dindexOfNotEqual( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 2.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -131,33 +107,39 @@ tape( 'the function supports an `x` stride', function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; x = new Float64Array([ - 9.0, - 0.0, // 0 + 1.0, // 2 9.0, 0.0, // 1 9.0, - 1.0 // 2 + 1.0 // 0 ]); - actual = dindexOfNotEqual( 3, 0.0, x, 2, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = dindexOfNotEqual( 3, 1.0, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; var x; - x = new Float64Array( [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ] ); + x = new Float64Array([ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]); - actual = dindexOfNotEqual( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = dindexOfNotEqual( 3, 0.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.native.js index 2d2cfb19eaa6..bfb33c9f5809 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-not-equal/test/test.ndarray.native.js @@ -53,33 +53,9 @@ tape( 'the function returns the index of the first element in a strided array wh x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOfNotEqual( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dindexOfNotEqual( x.length, 2.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 2.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - actual = dindexOfNotEqual( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 2.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 3.0, x, -1, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dindexOfNotEqual( x.length, 4.0, x, -1, x.length-1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -140,33 +116,39 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { t.end(); }); -tape( 'the function supports an `x` offset', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; x = new Float64Array([ - 9.0, - 0.0, // 0 + 1.0, // 2 9.0, 0.0, // 1 9.0, - 1.0 // 2 + 1.0 // 0 ]); - actual = dindexOfNotEqual( 3, 0.0, x, 2, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = dindexOfNotEqual( 3, 1.0, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports an `x` offset', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ] ); + x = new Float64Array([ + 9.0, + 0.0, // 0 + 9.0, + 0.0, // 1 + 9.0, + 1.0 // 2 + ]); - actual = dindexOfNotEqual( x.length, 0.0, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + actual = dindexOfNotEqual( 3, 0.0, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/README.md index f9ea6756947e..e047b27285ed 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/README.md @@ -69,11 +69,11 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Float64Array`][mdn-float64array]. -- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: search vector stored as a [`Float64Array`][mdn-float64array]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. When an input matrix is stored in row-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -170,14 +170,14 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix stored as a [`Float64Array`][mdn-float64array]. -- **strideA1**: stride of the first dimension of `A`. -- **strideA2**: stride of the second dimension of `A`. +- **strideA1**: stride length for the first dimension of `A`. +- **strideA2**: stride length for the second dimension of `A`. - **offsetA**: starting index for `A`. - **x**: search vector stored as a [`Float64Array`][mdn-float64array]. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. - **workspace**: workspace array stored as a [`Uint8Array`][mdn-uint8array] for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. -- **strideW**: stride length of `workspace`. +- **strideW**: stride length for `workspace`. - **offsetW**: starting index for `workspace`. When an input matrix is stored in row-major order, the workspace parameter is ignored, and, thus, one may provide an empty workspace array. @@ -299,7 +299,7 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] double*` input matrix. -- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **LDA**: `[in] CBLAS_INT` stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **X**: `[in] double*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **workspace**: `[inout] uint8_t*` workspace array for tracking row match candidates. This parameter is ignored if the function is provided an input matrix stored in row-major order. @@ -345,8 +345,8 @@ The function accepts the following arguments: - **M**: `[in] CBLAS_INT` number of rows in `A`. - **N**: `[in] CBLAS_INT` number of columns in `A`. - **A**: `[in] double*` input matrix. -- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. -- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **strideA1**: `[in] CBLAS_INT` stride length for the first dimension of `A`. +- **strideA2**: `[in] CBLAS_INT` stride length for the second dimension of `A`. - **offsetA**: `[in] CBLAS_INT` index offset for `A`. - **X**: `[in] double*` search vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/repl.txt index 5afc1bfb78f2..42b92988550c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/repl.txt @@ -25,8 +25,8 @@ Input matrix `A`. LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + Stride length for the first dimension of `A` (a.k.a., leading dimension + of the matrix `A`). x: Float64Array Search vector. @@ -79,10 +79,10 @@ Input matrix `A`. sa1: integer - Stride of the first dimension of `A`. + Stride length for the first dimension of `A`. sa2: integer - Stride of the second dimension of `A`. + Stride length for the second dimension of `A`. oa: integer Starting index for `A`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/index.d.ts index 687ffad9cece..c72af4ab87a2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/index.d.ts @@ -38,7 +38,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @param workspace - workspace array for tracking row match candidates @@ -49,7 +49,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * - * var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); + * var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 3.0 ], [ 2.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0 ] ); * var workspace = new Uint8Array( 3 ); * @@ -69,8 +69,8 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix - * @param strideA1 - stride of the first dimension of `A` - * @param strideA2 - stride of the second dimension of `A` + * @param strideA1 - stride length for the first dimension of `A` + * @param strideA2 - stride length for the second dimension of `A` * @param offsetA - starting index for `A` * @param x - search vector * @param strideX - stride length for `x` @@ -84,7 +84,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * - * var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); + * var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 3.0 ], [ 2.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0 ] ); * var workspace = new Uint8Array( 3 ); * @@ -106,7 +106,7 @@ interface Routine { * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix -* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - search vector * @param strideX - stride length for `x` * @param workspace - workspace array for tracking row match candidates @@ -117,7 +117,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * -* var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 3.0 ], [ 2.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0 ] ); * var workspace = new Uint8Array( 3 ); * @@ -128,7 +128,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * var Uint8Array = require( '@stdlib/array/uint8' ); * -* var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 3.0 ], [ 2.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = new Float64Array( [ 2.0, 4.0 ] ); * var workspace = new Uint8Array( 3 ); * diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/test.ts index d72ea08bb95f..1540b796ad68 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/docs/types/test.ts @@ -183,7 +183,7 @@ import dindexOfRow = require( './index' ); dindexOfRow( 'row-major', 2, 2, A, 2, x ); // $ExpectError dindexOfRow( 'row-major', 2, 2, A, 2, x, 1 ); // $ExpectError dindexOfRow( 'row-major', 2, 2, A, 2, x, 1, w ); // $ExpectError - dindexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, 1, 0 ); // $ExpectError + dindexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -399,5 +399,5 @@ import dindexOfRow = require( './index' ); dindexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError dindexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w ); // $ExpectError dindexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1 ); // $ExpectError - dindexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0, 0 ); // $ExpectError + dindexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.js index 3046f4acce61..cc7d0bdd41b1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.js @@ -43,7 +43,7 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.native.js index 2903b2055bcd..b70acd228086 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/dindex_of_row.native.js @@ -42,7 +42,7 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` * @param {Uint8Array} workspace - workspace array for tracking row match candidates diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.js index 0f3c0d0c2ec3..d037419a8993 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.js @@ -38,8 +38,8 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.native.js index 7a11ef64c024..d1d3a8f80aa4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/lib/ndarray.native.js @@ -38,8 +38,8 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {Float64Array} x - search vector * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/src/main.c index 06b691d266bc..f01fe5fa2f5a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-row/src/main.c @@ -24,16 +24,16 @@ /** * Returns the index of the first row in a double-precision floating-point input matrix which has the same elements as a provided search vector. * -* @param order storage layout -* @param M number of rows in `A` -* @param N number of columns in `A` -* @param A input matrix -* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param X search vector -* @param strideX stride length for `X` -* @param workspace workspace array for tracking row match candidates -* @param strideW stride length for `workspace` -* @return row index +* @param order storage layout +* @param M number of rows in `A` +* @param N number of columns in `A` +* @param A input matrix +* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param X search vector +* @param strideX stride length for `X` +* @param workspace workspace array for tracking row match candidates +* @param strideW stride length for `workspace` +* @return row index */ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_row)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, const double *X, const CBLAS_INT strideX, uint8_t *workspace, const CBLAS_INT strideW ) { CBLAS_INT sa1; @@ -56,19 +56,19 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_row)( const CBLAS_LAYOUT order, co /** * Returns the index of the first row in a double-precision floating-point input matrix which has the same elements as a provided search vector using alternative indexing semantics. * -* @param M number of rows in `A` -* @param N number of columns in `A` -* @param A input matrix -* @param strideA1 stride of the first dimension of `A` -* @param strideA2 stride of the second dimension of `A` -* @param offsetA index offset for `A` -* @param X search vector -* @param strideX stride length for `X` -* @param offsetX starting index for `X` -* @param workspace workspace array for tracking row match candidates -* @param strideW stride length for `workspace` -* @param offsetW starting index for `workspace` -* @return row index +* @param M number of rows in `A` +* @param N number of columns in `A` +* @param A input matrix +* @param strideA1 stride length for the first dimension of `A` +* @param strideA2 stride length for the second dimension of `A` +* @param offsetA index offset for `A` +* @param X search vector +* @param strideX stride length for `X` +* @param offsetX starting index for `X` +* @param workspace workspace array for tracking row match candidates +* @param strideW stride length for `workspace` +* @param offsetW starting index for `workspace` +* @return row index */ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_row_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, uint8_t *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { CBLAS_INT da0; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/README.md b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/README.md index adc593c8c226..f3f1d5f356b4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/README.md @@ -135,7 +135,6 @@ var idx = dindexOfTruthy.ndarray( 3, x, 1, x.length-3 ); ## Notes -- If the function is unable to find a truthy element, the function returns `-1`. - Both functions explicitly treat `NaN` values as falsy. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/repl.txt index 63a2408cbbc4..affc77d7e14a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/repl.txt @@ -11,6 +11,8 @@ If `N <= 0`, the function returns `-1`. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -29,10 +31,22 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 2 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}( 3, x, 2 ) + 1 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 2 + {{alias}}.ndarray( N, x, strideX, offsetX ) Returns the index of the first truthy element in a double-precision @@ -42,6 +56,8 @@ buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -63,9 +79,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 2 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 2 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/index.d.ts index eb2e5785f4c9..d7751b4cff39 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -50,7 +50,7 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -75,7 +75,7 @@ interface Routine { * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/test.ts index 23817bcd581c..5f28c851d115 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/docs/types/test.ts @@ -37,6 +37,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy( false, x, 1 ); // $ExpectError dindexOfTruthy( null, x, 1 ); // $ExpectError dindexOfTruthy( {}, x, 1 ); // $ExpectError + dindexOfTruthy( ( 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... @@ -46,6 +47,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy( x.length, false, 1 ); // $ExpectError dindexOfTruthy( x.length, null, 1 ); // $ExpectError dindexOfTruthy( x.length, {}, 1 ); // $ExpectError + dindexOfTruthy( 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... @@ -57,6 +59,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy( x.length, x, false ); // $ExpectError dindexOfTruthy( x.length, x, null ); // $ExpectError dindexOfTruthy( x.length, x, {} ); // $ExpectError + dindexOfTruthy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -64,7 +67,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy(); // $ExpectError dindexOfTruthy( 3 ); // $ExpectError dindexOfTruthy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError - dindexOfTruthy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // $ExpectError + dindexOfTruthy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -83,6 +86,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy.ndarray( false, x, 1, 1 ); // $ExpectError dindexOfTruthy.ndarray( null, x, 1, 1 ); // $ExpectError dindexOfTruthy.ndarray( {}, x, 1, 1 ); // $ExpectError + dindexOfTruthy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... @@ -92,6 +96,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy.ndarray( x.length, false, 1, 1 ); // $ExpectError dindexOfTruthy.ndarray( x.length, null, 1, 1 ); // $ExpectError dindexOfTruthy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + dindexOfTruthy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -103,6 +108,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy.ndarray( x.length, x, false, 1 ); // $ExpectError dindexOfTruthy.ndarray( x.length, x, null, 1 ); // $ExpectError dindexOfTruthy.ndarray( x.length, x, {}, 1 ); // $ExpectError + dindexOfTruthy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -114,6 +120,7 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy.ndarray( x.length, x, 1, false ); // $ExpectError dindexOfTruthy.ndarray( x.length, x, 1, null ); // $ExpectError dindexOfTruthy.ndarray( x.length, x, 1, {} ); // $ExpectError + dindexOfTruthy.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... @@ -122,5 +129,5 @@ import dindexOfTruthy = require( './index' ); dindexOfTruthy.ndarray( 3 ); // $ExpectError dindexOfTruthy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError dindexOfTruthy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); // $ExpectError - dindexOfTruthy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, 0 ); // $ExpectError + dindexOfTruthy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.js index 99cec89e225a..8edd65631af1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.native.js index d6ca36b8c639..87ccc006c965 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/dindex_of_truthy.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.js index e2adce4317cd..83b2fb3679d0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.js @@ -25,7 +25,7 @@ * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.native.js index 73e672600755..c5fb9d5356ff 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/src/main.c index 251efaeb73cc..67ae02dc7fde 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/src/main.c @@ -24,10 +24,10 @@ /** * Returns the index of the first truthy element in a double-precision floating-point strided array. * -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @return index +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_truthy)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ) { CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); @@ -37,11 +37,11 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_truthy)( const CBLAS_INT N, const /** * Returns the index of the first truthy element in a double-precision floating-point strided array using alternative indexing semantics. * -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @param offsetX starting index -* @return index +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @param offsetX starting index +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dindex_of_truthy_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { CBLAS_INT ix; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.js index a7285940201a..86b1a11a5158 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.js @@ -39,20 +39,9 @@ tape( 'the function returns the index of the first truthy element', function tes x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = dindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -80,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = dindexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -91,3 +80,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = dindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.native.js index 64d830fd57d8..896aeea02931 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.dindex_of_truthy.native.js @@ -48,20 +48,9 @@ tape( 'the function returns the index of the first truthy element', opts, functi x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dindexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = dindexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -89,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = dindexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -100,3 +89,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = dindexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dindexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.js index 79e16ca17790..14f589bdb88e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.js @@ -39,29 +39,9 @@ tape( 'the function returns the index of the first truthy element', function tes x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = dindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -89,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = dindexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -100,3 +80,58 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = dindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = dindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.native.js index 849091639973..cac7c8bf1af3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of-truthy/test/test.ndarray.native.js @@ -48,29 +48,9 @@ tape( 'the function returns the index of the first truthy element', opts, functi x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dindexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dindexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = dindexOfTruthy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = dindexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = dindexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -98,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = dindexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); @@ -109,3 +89,58 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dindexOfTruthy( 3, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = dindexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = dindexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/README.md b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/README.md index 6538aced11c0..42fa4a73a71e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/README.md @@ -198,7 +198,7 @@ console.log( idx ); Returns the first index of a specified search element in a double-precision floating-point strided array. ```c -double x[] = { 1.0, 2.0, 3.0, 4.0 }; +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; int idx = stdlib_strided_dindex_of( 4, 3.0, x, 1 ); // returns 2 @@ -220,7 +220,7 @@ CBLAS_INT N stdlib_strided_dindex_of( const CBLAS_INT N, const double searchElem Returns the first index of a specified search element in a double-precision floating-point strided array using alternative indexing semantics. ```c -double x[] = { 1.0, 2.0, 3.0, 4.0 }; +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; int idx = stdlib_strided_dindex_of_ndarray( 4, 3.0, x, 1, 0 ); // returns 2 @@ -262,7 +262,7 @@ CBLAS_INT stdlib_strided_dindex_of_ndarray( const CBLAS_INT N, const double sear int main( void ) { // Create a strided array: - double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; + const double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; // Specify the number of indexed elements: const int N = 8; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/repl.txt index 524a31cce7dc..c9a6faddb974 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/repl.txt @@ -32,10 +32,22 @@ 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}}( x.length, 1.0, x, 1 ) 1 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ] ); + > var idx = {{alias}}( 4, 4.0, x, 2 ) + 2 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, -4.0, x1, 2 ) + 1 + {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) Returns the first index of a specified search element in a double-precision @@ -69,9 +81,15 @@ 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, 1.0, x, 1, 0 ) 1 + // Using an index offset: + > 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( 3, -5.0, x, 2, 1 ) + 1 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/types/test.ts index 8982d272dbca..40e3203eda13 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/docs/types/test.ts @@ -37,6 +37,7 @@ import dindexOf = require( './index' ); dindexOf( false, 2.0, x, 1 ); // $ExpectError dindexOf( null, 2.0, x, 1 ); // $ExpectError dindexOf( {}, 2.0, x, 1 ); // $ExpectError + dindexOf( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -48,6 +49,7 @@ import dindexOf = require( './index' ); dindexOf( x.length, false, x, 1 ); // $ExpectError dindexOf( x.length, null, x, 1 ); // $ExpectError dindexOf( x.length, {}, x, 1 ); // $ExpectError + dindexOf( x.length, ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float64Array... @@ -57,6 +59,7 @@ import dindexOf = require( './index' ); dindexOf( x.length, 1.0, false, 1 ); // $ExpectError dindexOf( x.length, 1.0, null, 1 ); // $ExpectError dindexOf( x.length, 1.0, {}, 1 ); // $ExpectError + dindexOf( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -68,6 +71,7 @@ import dindexOf = require( './index' ); dindexOf( x.length, 2.0, x, false ); // $ExpectError dindexOf( x.length, 2.0, x, null ); // $ExpectError dindexOf( x.length, 2.0, x, {} ); // $ExpectError + dindexOf( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -75,7 +79,7 @@ import dindexOf = require( './index' ); dindexOf(); // $ExpectError dindexOf( 3, 2.0 ); // $ExpectError dindexOf( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError - dindexOf( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // $ExpectError + dindexOf( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -94,6 +98,7 @@ import dindexOf = require( './index' ); dindexOf.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError dindexOf.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError dindexOf.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + dindexOf.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... @@ -105,6 +110,7 @@ import dindexOf = require( './index' ); dindexOf.ndarray( x.length, false, x, 1, 1 ); // $ExpectError dindexOf.ndarray( x.length, null, x, 1, 1 ); // $ExpectError dindexOf.ndarray( x.length, {}, x, 1, 1 ); // $ExpectError + dindexOf.ndarray( x.length, ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float64Array... @@ -114,6 +120,7 @@ import dindexOf = require( './index' ); dindexOf.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError dindexOf.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError dindexOf.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + dindexOf.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -125,6 +132,7 @@ import dindexOf = require( './index' ); dindexOf.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError dindexOf.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError dindexOf.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + dindexOf.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -136,6 +144,7 @@ import dindexOf = require( './index' ); dindexOf.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError dindexOf.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError dindexOf.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + dindexOf.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... @@ -144,5 +153,5 @@ import dindexOf = require( './index' ); dindexOf.ndarray( 3, 2.0 ); // $ExpectError dindexOf.ndarray( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError dindexOf.ndarray( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); // $ExpectError - dindexOf.ndarray( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, 0 ); // $ExpectError + dindexOf.ndarray( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.js index 8043aa83d4df..ff0c866c8c3d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the first index of a specified search element in a double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.native.js index 26801cf3fce6..eb14fa125b8b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/dindex_of.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the first index of a specified search element in a double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.js index 8b5c9983aadf..5cdabc9138a7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.js @@ -23,6 +23,10 @@ /** * Returns the first index of a specified search element in a double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.native.js index a919095e29df..75688be5a151 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the first index of a specified search element in a double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.js index 5d0238a31de1..2122aa43ea8e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.js @@ -39,52 +39,87 @@ tape( 'the function returns the first index of an element which equals a provide x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = dindexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; - actual = dindexOf( x.length, 4.0, x, 1 ); + actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dindexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { + var actual; - actual = dindexOf( x.length, 4.0, x, -1 ); + actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; + var x; - actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dindexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; + var x; - actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dindexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dindexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.native.js index 581e8806dc6c..2ef2d0405a20 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.dindex_of.native.js @@ -48,52 +48,87 @@ tape( 'the function returns the first index of an element which equals a provide x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = dindexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; - actual = dindexOf( x.length, 4.0, x, 1 ); + actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dindexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { + var actual; - actual = dindexOf( x.length, 4.0, x, -1 ); + actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; + var x; - actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dindexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; + var x; - actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dindexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dindexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.js index 839d9b94f244..6874132348fb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.js @@ -39,52 +39,84 @@ tape( 'the function returns the first index of an element which equals a provide x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = dindexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; - actual = dindexOf( x.length-2, 4.0, x, 1, 2 ); + actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dindexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { + var actual; - actual = dindexOf( x.length, 4.0, x, -1, x.length-1 ); + actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; + var x; - actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dindexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; + var x; - actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dindexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + actual = dindexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.native.js index fc8274101c79..cd6ce9ee63e8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dindex-of/test/test.ndarray.native.js @@ -48,52 +48,84 @@ tape( 'the function returns the first index of an element which equals a provide x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dindexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 0, 'returns expected value' ); - actual = dindexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; - actual = dindexOf( x.length-2, 4.0, x, 1, 2 ); + actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dindexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dindexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = dindexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { + var actual; - actual = dindexOf( x.length, 4.0, x, -1, x.length-1 ); + actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; + var x; - actual = dindexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dindexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dindexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; + var x; - actual = dindexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 2.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dindexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 2.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + actual = dindexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/README.md index 3f3fde33d301..cb8cd665b76d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/README.md @@ -62,7 +62,7 @@ The function has the following parameters: - **y**: second input [`Float64Array`][@stdlib/array/float64]. - **strideY**: stride length for `y`. -If the function is unable to find a match, the function returns `-1`. +If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -295,7 +295,7 @@ int main( void ) { const int strideX = 1; const int strideY = 1; - // Perform the search: + // Perform a search: int idx = stdlib_strided_dlast_index_equal( N, x, strideX, y, strideY ); // Print the result: diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/benchmark/benchmark.js index df942a4dfb2d..0b3a7a2440f8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/benchmark/benchmark.js @@ -27,7 +27,7 @@ var oneTo = require( '@stdlib/array/one-to' ); var zeros = require( '@stdlib/array/zeros' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; -var dlastIndexEqual = require( './../lib' ); +var dlastIndexEqual = require( './../lib/dlast_index_equal.js' ); // FUNCTIONS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/repl.txt index 2bc0e01c039d..14a8cec41037 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/repl.txt @@ -102,11 +102,11 @@ > var idx = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) 2 - // Using strides: + // Using index offsets: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > y = new {{alias:@stdlib/array/float64}}( [ 1.0, 0.0, 0.0, 0.0, 5.0, 0.0 ] ); - > idx = {{alias}}.ndarray( 3, x, 2, 0, y, 2, 0 ) - 2 + > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0 ] ); + > idx = {{alias}}.ndarray( 3, x, 2, 1, y, 2, 2 ) + -1 See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/types/index.d.ts index f45a739cd508..0cb043b285eb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find a match, the function returns `-1`. + * - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -52,7 +52,7 @@ interface Routine { * * ## Notes * - * - If the function is unable to find a match, the function returns `-1`. + * - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array @@ -80,7 +80,7 @@ interface Routine { * * ## Notes * -* - If the function is unable to find matching elements, the function returns `-1`. +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. * * @param N - number of indexed elements * @param x - first input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/examples/c/example.c index 8cb07c0a9e95..d038f87c33c1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/examples/c/example.c @@ -31,7 +31,7 @@ int main( void ) { const int strideX = 1; const int strideY = 1; - // Perform the search: + // Perform a search: int idx = stdlib_strided_dlast_index_equal( N, x, strideX, y, strideY ); // Print the result: diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.js index 585b9c5054eb..7aba6fb7d31f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the index of the last element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.native.js index e38fce2ae890..0fd0d986f41a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/dlast_index_equal.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the last element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.js index ac2e6451aa84..1283f2840cfe 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.js @@ -28,6 +28,10 @@ var dfirstIndexEqual = require( '@stdlib/blas/ext/base/dfirst-index-equal' ).nda /** * Returns the index of the last element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.native.js index 2fea6fda3ee4..72732c46cf38 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the index of the last element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find an element in `x` which is equal to a corresponding element in `y`, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - first input array * @param {integer} strideX - stride length for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/src/main.c index 2cc60d93547d..4f5068c88f65 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/src/main.c @@ -24,12 +24,12 @@ /** * Returns the index of the last element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array. * -* @param N number of indexed elements -* @param X first input array -* @param strideX stride length for X -* @param Y second input array -* @param strideY stride length for Y -* @return index +* @param N number of indexed elements +* @param X first input array +* @param strideX stride length for X +* @param Y second input array +* @param strideY stride length for Y +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_equal)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY ) { CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); @@ -40,14 +40,14 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_equal)( const CBLAS_INT N, const /** * Returns the index of the last element in a double-precision floating-point strided array equal to a corresponding element in another double-precision floating-point strided array using alternative indexing semantics. * -* @param N number of indexed elements -* @param X first input array -* @param strideX stride length for X -* @param offsetX starting index for X -* @param Y second input array -* @param strideY stride length for Y -* @param offsetY starting index for Y -* @return index +* @param N number of indexed elements +* @param X first input array +* @param strideX stride length for X +* @param offsetX starting index for X +* @param Y second input array +* @param strideY stride length for Y +* @param offsetY starting index for Y +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_equal_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { CBLAS_INT idx; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.js index 5904bec953b2..299a3ea5794b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.js @@ -46,59 +46,9 @@ tape( 'the function returns the last index of an element which equals a correspo x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexEqual( x.length, x, 1, y, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( 3, x, 2, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 3.0 ] ); - - actual = dlastIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -114,7 +64,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ NaN ] ), 1, new Float64Array( [ NaN ] ), 1 ); @@ -123,7 +73,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, new Float64Array( [ 0.0 ] ), 1 ); @@ -153,8 +103,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dlastIndexEqual( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -179,12 +129,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dlastIndexEqual( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -197,16 +147,42 @@ tape( 'the function supports negative strides', function test( t ) { 5.0 // 0 ]); y = new Float64Array([ - 0.0, // 2 - 3.0, // 1 0.0, // 0 + 3.0, // 1 + 0.0, // 2 0.0, 0.0 ]); - actual = dlastIndexEqual( 3, x, -2, y, -1 ); + actual = dlastIndexEqual( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 0.0, // 2 + 2.0, // 1 + 0.0, // 0 + 0.0, + 0.0 + ]); + actual = dlastIndexEqual( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -233,8 +209,8 @@ tape( 'the function supports complex access patterns', function test( t ) { ]); actual = dlastIndexEqual( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -269,5 +245,6 @@ tape( 'the function supports view offsets', function test( t ) { actual = dlastIndexEqual( 3, x1, -2, y1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.native.js index e3b612ce564f..acaac2285f09 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.dlast_index_equal.native.js @@ -55,59 +55,9 @@ tape( 'the function returns the last index of an element which equals a correspo x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexEqual( x.length, x, 1, y, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, 1, y, 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( 3, x, 2, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 3.0 ] ); - - actual = dlastIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, -1, y, -1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -123,7 +73,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ NaN ] ), 1, new Float64Array( [ NaN ] ), 1 ); @@ -132,7 +82,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, new Float64Array( [ 0.0 ] ), 1 ); @@ -162,8 +112,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dlastIndexEqual( 3, x, 2, y, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -188,12 +138,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dlastIndexEqual( 3, x, 1, y, 2 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -206,16 +156,42 @@ tape( 'the function supports negative strides', opts, function test( t ) { 5.0 // 0 ]); y = new Float64Array([ - 0.0, // 2 - 3.0, // 1 0.0, // 0 + 3.0, // 1 + 0.0, // 2 0.0, 0.0 ]); - actual = dlastIndexEqual( 3, x, -2, y, -1 ); + actual = dlastIndexEqual( 3, x, -2, y, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `y` stride', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 0.0, // 2 + 2.0, // 1 + 0.0, // 0 + 0.0, + 0.0 + ]); + actual = dlastIndexEqual( 3, x, 1, y, -1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -242,8 +218,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) ]); actual = dlastIndexEqual( 3, x, 2, y, -1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); @@ -278,5 +254,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { actual = dlastIndexEqual( 3, x1, -2, y1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.js index 2ce5c1a534a6..40a4149a8e54 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.js @@ -46,59 +46,9 @@ tape( 'the function returns the last index of an element which equals a correspo x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexEqual( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length-1, x, 1, 1, y, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( 3, x, -2, x.length-1, y, -2, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( 3, x, -2, x.length-2, y, -2, y.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -114,7 +64,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ NaN ] ), 1, 0, new Float64Array( [ NaN ] ), 1, 0 ); @@ -123,7 +73,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', function t.end(); }); -tape( 'the function treats -0 and +0 as equal', function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, 0, new Float64Array( [ 0.0 ] ), 1, 0 ); @@ -153,8 +103,8 @@ tape( 'the function supports an `x` stride', function test( t ) { ]); actual = dlastIndexEqual( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -179,12 +129,12 @@ tape( 'the function supports a `y` stride', function test( t ) { ]); actual = dlastIndexEqual( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; var y; @@ -197,44 +147,42 @@ tape( 'the function supports negative strides', function test( t ) { 5.0 // 0 ]); y = new Float64Array([ - 0.0, // 2 - 3.0, // 1 0.0, // 0 + 3.0, // 1 + 0.0, // 2 0.0, 0.0 ]); - actual = dlastIndexEqual( 3, x, -2, 4, y, -1, 2 ); - + actual = dlastIndexEqual( 3, x, -2, 4, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports complex access patterns', function test( t ) { +tape( 'the function supports a negative `y` stride', function test( t ) { var actual; var x; var y; x = new Float64Array([ 1.0, // 0 - 2.0, - 3.0, // 1 + 2.0, // 1 + 3.0, // 2 4.0, - 5.0, // 2 - 6.0 + 5.0 ]); y = new Float64Array([ - 5.0, // 2 - 0.0, // 1 - 0.0, // 0 - 0.0, + 0.0, // 2 + 2.0, // 1 + 0.0, // 0 0.0, 0.0 ]); - actual = dlastIndexEqual( 3, x, 2, 0, y, -1, 2 ); + actual = dlastIndexEqual( 3, x, 1, 0, y, -1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); @@ -243,12 +191,22 @@ tape( 'the function supports an `x` offset', function test( t ) { var x; var y; - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float64Array( [ 0.0, 3.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( 2, x, 1, 1, y, 1, 0 ); + x = new Float64Array([ + 5.0, + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 4.0, // 2 + 0.0 + ]); + actual = dlastIndexEqual( 3, x, 1, 1, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -257,11 +215,49 @@ tape( 'the function supports a `y` offset', function test( t ) { var x; var y; - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 3.0 ] ); - - actual = dlastIndexEqual( 2, x, 1, 1, y, 1, 2 ); + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 0.0 + ]); + y = new Float64Array([ + 0.0, + 6.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + actual = dlastIndexEqual( 3, x, 1, 0, y, 1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]); + y = new Float64Array([ + 5.0, // 2 + 0.0, // 1 + 0.0, // 0 + 0.0, + 0.0, + 0.0 + ]); + + actual = dlastIndexEqual( 3, x, 2, 0, y, -1, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.native.js index 84bd9056df0c..919d8dc1719e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-equal/test/test.ndarray.native.js @@ -55,59 +55,9 @@ tape( 'the function returns the last index of an element which equals a correspo x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); y = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexEqual( x.length, x, 1, 0, y, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length-1, x, 1, 1, y, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 3.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length-2, x, 1, 2, y, 1, 2 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 3.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( 3, x, 2, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - // Negative stride... - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( 3, x, -2, x.length-1, y, -2, y.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( 3, x, -2, x.length-2, y, -2, y.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( x.length, x, -1, x.length-1, y, -1, y.length-1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - t.end(); }); @@ -123,7 +73,7 @@ tape( 'the function returns `-1` if a provided `N` parameter is less than or equ t.end(); }); -tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, function test( t ) { +tape( 'the function returns `-1` if comparisons involve `NaN` values', opts, function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ NaN ] ), 1, 0, new Float64Array( [ NaN ] ), 1, 0 ); @@ -132,7 +82,7 @@ tape( 'the function returns `-1` if provided elements equal to `NaN`', opts, fun t.end(); }); -tape( 'the function treats -0 and +0 as equal', opts, function test( t ) { +tape( 'the function treats `-0` and `+0` as equal', opts, function test( t ) { var actual; actual = dlastIndexEqual( 1, new Float64Array( [ -0.0 ] ), 1, 0, new Float64Array( [ 0.0 ] ), 1, 0 ); @@ -162,8 +112,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { ]); actual = dlastIndexEqual( 3, x, 2, 0, y, 1, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -188,12 +138,12 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { ]); actual = dlastIndexEqual( 3, x, 1, 0, y, 2, 0 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports negative strides', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; var y; @@ -206,44 +156,42 @@ tape( 'the function supports negative strides', opts, function test( t ) { 5.0 // 0 ]); y = new Float64Array([ - 0.0, // 2 - 3.0, // 1 0.0, // 0 + 3.0, // 1 + 0.0, // 2 0.0, 0.0 ]); - actual = dlastIndexEqual( 3, x, -2, 4, y, -1, 2 ); - + actual = dlastIndexEqual( 3, x, -2, 4, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); -tape( 'the function supports complex access patterns', opts, function test( t ) { +tape( 'the function supports a negative `y` stride', opts, function test( t ) { var actual; var x; var y; x = new Float64Array([ 1.0, // 0 - 2.0, - 3.0, // 1 + 2.0, // 1 + 3.0, // 2 4.0, - 5.0, // 2 - 6.0 + 5.0 ]); y = new Float64Array([ - 5.0, // 2 - 0.0, // 1 - 0.0, // 0 - 0.0, + 0.0, // 2 + 2.0, // 1 + 0.0, // 0 0.0, 0.0 ]); - actual = dlastIndexEqual( 3, x, 2, 0, y, -1, 2 ); + actual = dlastIndexEqual( 3, x, 1, 0, y, -1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); - t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); @@ -252,12 +200,22 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { var x; var y; - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float64Array( [ 0.0, 3.0, 0.0, 0.0 ] ); - - actual = dlastIndexEqual( 2, x, 1, 1, y, 1, 0 ); + x = new Float64Array([ + 5.0, + 6.0, // 0 + 1.0, // 1 + 5.0 // 2 + ]); + y = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 4.0, // 2 + 0.0 + ]); + actual = dlastIndexEqual( 3, x, 1, 1, y, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); }); @@ -266,11 +224,49 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { var x; var y; - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 2.0, 3.0 ] ); - - actual = dlastIndexEqual( 2, x, 1, 1, y, 1, 2 ); + x = new Float64Array([ + 6.0, // 0 + 1.0, // 1 + 5.0, // 2 + 0.0 + ]); + y = new Float64Array([ + 0.0, + 6.0, // 0 + 1.0, // 1 + 4.0 // 2 + ]); + actual = dlastIndexEqual( 3, x, 1, 0, y, 1, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', opts, function test( t ) { + var actual; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0, // 2 + 6.0 + ]); + y = new Float64Array([ + 5.0, // 2 + 0.0, // 1 + 0.0, // 0 + 0.0, + 0.0, + 0.0 + ]); + + actual = dlastIndexEqual( 3, x, 2, 0, y, -1, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/README.md b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/README.md index ce53aae77b3b..c6840f8e5006 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/README.md @@ -47,10 +47,10 @@ Returns the index of the last falsy element in a double-precision floating-point ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); var idx = dlastIndexOfFalsy( x.length, x, 1 ); -// returns 4 +// returns 5 ``` The function has the following parameters: @@ -75,10 +75,10 @@ The `N` and stride parameters determine which elements in the strided array are ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 1.0, 3.0 ] ); -var idx = dlastIndexOfFalsy( 4, x, 2 ); -// returns 2 +var idx = dlastIndexOfFalsy( 3, x, 2 ); +// returns 1 ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -87,14 +87,14 @@ Note that indexing is relative to the first index. To introduce an offset, use [ var Float64Array = require( '@stdlib/array/float64' ); // Initial array... -var x0 = new Float64Array( [ 1.0, 3.0, 1.0, 0.0, 2.0, 1.0 ] ); +var x0 = new Float64Array( [ 1.0, 0.0, 1.0, 3.0, 5.0, 0.0 ] ); // Create an offset view... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element // Find index... var idx = dlastIndexOfFalsy( 3, x1, 2 ); -// returns 1 +// returns 2 ``` #### dlastIndexOfFalsy.ndarray( N, x, strideX, offsetX ) @@ -104,10 +104,10 @@ Returns the index of the last falsy element in a double-precision floating-point ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); var idx = dlastIndexOfFalsy.ndarray( x.length, x, 1, 0 ); -// returns 4 +// returns 5 ``` The function has the following additional parameters: @@ -119,7 +119,7 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0, 1.0, 4.0, 0.0, 0.0, 3.0 ] ); var idx = dlastIndexOfFalsy.ndarray( 3, x, 1, x.length-3 ); // returns 1 @@ -197,10 +197,10 @@ console.log( idx ); Returns the index of the last falsy element in a double-precision floating-point strided array. ```c -const double x[] = { 1.0, 3.0, 0.0, 4.0 }; +const double x[] = { 1.0, 2.0, 3.0, 0.0 }; int idx = stdlib_strided_dlast_index_of_falsy( 4, x, 1 ); -// returns 2 +// returns 3 ``` The function accepts the following arguments: @@ -218,10 +218,10 @@ CBLAS_INT stdlib_strided_dlast_index_of_falsy( const CBLAS_INT N, const double * Returns the index of the last falsy element in a double-precision floating-point strided array using alternative indexing semantics. ```c -const double x[] = { 1.0, 3.0, 0.0, 4.0 }; +const double x[] = { 1.0, 2.0, 3.0, 0.0 }; int idx = stdlib_strided_dlast_index_of_falsy_ndarray( 4, x, 1, 0 ); -// returns 2 +// returns 3 ``` The function accepts the following arguments: @@ -263,7 +263,7 @@ CBLAS_INT stdlib_strided_dlast_index_of_falsy_ndarray( const CBLAS_INT N, const int main( void ) { // Create a strided array: - const double x[] = { 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 }; + const double x[] = { 0.0, 0.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 }; // Specify the number of indexed elements: const int N = 8; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/repl.txt index 80ce4d30e844..d7da8aad6b9d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( N, x, strideX ) - Returns the index of the last falsy element in a double-precision - floating-point strided array. + Returns the index of the last falsy element in a double-precision floating- + point strided array. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. @@ -31,19 +31,33 @@ Examples -------- - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 3.0, 0.0, 4.0 ] ); + // Standard usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) - 4 + 5 + + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 3.0, 0.0, 4.0 ] ); + > var idx = {{alias}}( 3, x, 2 ) + 2 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 0.0, 2.0, 0.0, 4.0, 5.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 1 {{alias}}.ndarray( N, x, strideX, offsetX ) - Returns the index of the last falsy element in a double-precision - floating-point strided array using alternative indexing semantics. + Returns the index of the last falsy element in a double-precision floating- + point strided array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -65,9 +79,15 @@ Examples -------- - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 3.0, 0.0, 4.0 ] ); + // Standard usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) - 4 + 5 + + // Using an index offset: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 0.0, 2.0, 0.0, 4.0, 5.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 1 See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/index.d.ts index 4dc00ce8f414..26a7a6036f1b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -38,10 +38,10 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * - * var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + * var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1 ); - * // returns 3 + * // returns 2 */ ( N: number, x: Float64Array, strideX: number ): number; @@ -50,7 +50,7 @@ interface Routine { * * ## Notes * - * - If unable to find a falsy element, the function returns `-1`. + * - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -62,10 +62,10 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * - * var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + * var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy.ndarray( x.length, x, 1, 0 ); - * // returns 3 + * // returns 2 */ ndarray( N: number, x: Float64Array, strideX: number, offsetX: number ): number; } @@ -75,7 +75,7 @@ interface Routine { * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -86,18 +86,18 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1 ); -* // returns 3 +* // returns 2 * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 0.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy.ndarray( x.length, x, 1, 0 ); -* // returns 3 +* // returns 2 */ declare var dlastIndexOfFalsy: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/test.ts index 559b95ee8757..2792789883bc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/docs/types/test.ts @@ -16,8 +16,6 @@ * limitations under the License. */ -/* eslint-disable space-in-parens */ - import dlastIndexOfFalsy = require( './index' ); @@ -39,6 +37,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy( false, x, 1 ); // $ExpectError dlastIndexOfFalsy( null, x, 1 ); // $ExpectError dlastIndexOfFalsy( {}, x, 1 ); // $ExpectError + dlastIndexOfFalsy( ( 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... @@ -48,6 +47,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy( x.length, false, 1 ); // $ExpectError dlastIndexOfFalsy( x.length, null, 1 ); // $ExpectError dlastIndexOfFalsy( x.length, {}, 1 ); // $ExpectError + dlastIndexOfFalsy( 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... @@ -59,6 +59,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy( x.length, x, false ); // $ExpectError dlastIndexOfFalsy( x.length, x, null ); // $ExpectError dlastIndexOfFalsy( x.length, x, {} ); // $ExpectError + dlastIndexOfFalsy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -85,6 +86,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy.ndarray( false, x, 1, 1 ); // $ExpectError dlastIndexOfFalsy.ndarray( null, x, 1, 1 ); // $ExpectError dlastIndexOfFalsy.ndarray( {}, x, 1, 1 ); // $ExpectError + dlastIndexOfFalsy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... @@ -94,6 +96,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy.ndarray( x.length, false, 1, 1 ); // $ExpectError dlastIndexOfFalsy.ndarray( x.length, null, 1, 1 ); // $ExpectError dlastIndexOfFalsy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + dlastIndexOfFalsy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -105,6 +108,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy.ndarray( x.length, x, false, 1 ); // $ExpectError dlastIndexOfFalsy.ndarray( x.length, x, null, 1 ); // $ExpectError dlastIndexOfFalsy.ndarray( x.length, x, {}, 1 ); // $ExpectError + dlastIndexOfFalsy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -116,6 +120,7 @@ import dlastIndexOfFalsy = require( './index' ); dlastIndexOfFalsy.ndarray( x.length, x, 1, false ); // $ExpectError dlastIndexOfFalsy.ndarray( x.length, x, 1, null ); // $ExpectError dlastIndexOfFalsy.ndarray( x.length, x, 1, {} ); // $ExpectError + dlastIndexOfFalsy.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... diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/examples/c/example.c index 7f2569390118..d340814ec304 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/examples/c/example.c @@ -21,7 +21,7 @@ int main( void ) { // Create a strided array: - const double x[] = { 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 }; + const double x[] = { 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 }; // Specify the number of indexed elements: const int N = 8; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.js index e6d54fd6bb00..ac77952c1ab1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -42,10 +42,10 @@ var ndarray = require( './ndarray.js' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1 ); -* // returns 4 +* // returns 5 */ function dlastIndexOfFalsy( N, x, strideX ) { return ndarray( N, x, strideX, stride2offset( N, strideX ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.native.js index d11d515c8d2e..af2d19b29079 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/dlast_index_of_falsy.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -41,10 +41,10 @@ var addon = require( './../src/addon.node' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1 ); -* // returns 4 +* // returns 5 */ function dlastIndexOfFalsy( N, x, strideX ) { return addon( N, x, strideX ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/index.js index 5802ef0bbe71..90933dc3b2f2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/index.js @@ -27,19 +27,19 @@ * var Float64Array = require( '@stdlib/array/float64' ); * var dlastIndexOfFalsy = require( '@stdlib/blas/ext/base/dlast-index-of-falsy' ); * -* var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1 ); -* // returns 4 +* // returns 5 * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var dlastIndexOfFalsy = require( '@stdlib/blas/ext/base/dlast-index-of-falsy' ); * -* var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy.ndarray( x.length, x, 1, 0 ); -* // returns 4 +* // returns 5 */ // MODULES // diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.js index 18bfb964744d..f8fa2f168cef 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.js @@ -30,7 +30,7 @@ var dindexOfFalsy = require( '@stdlib/blas/ext/base/dindex-of-falsy' ).ndarray; * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -42,10 +42,10 @@ var dindexOfFalsy = require( '@stdlib/blas/ext/base/dindex-of-falsy' ).ndarray; * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1, 0 ); -* // returns 4 +* // returns 5 */ function dlastIndexOfFalsy( N, x, strideX, offsetX ) { var idx; @@ -54,7 +54,7 @@ function dlastIndexOfFalsy( N, x, strideX, offsetX ) { return -1; } // Reverse the iteration order by flipping the stride and adjusting the offset: - offsetX += ( N-1 ) * strideX; + offsetX += ( ( N - 1 ) * strideX ); strideX *= -1; // Find the index of the first falsy element in the reversed "view": diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.native.js index 3043efb6d9b2..bfa85edc2fba 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a falsy element, the function returns `-1`. +* - If the function is unable to find a falsy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements @@ -42,10 +42,10 @@ var addon = require( './../src/addon.node' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var x = new Float64Array( [ 1.0, 3.0, 0.0, 2.0, 0.0, 4.0, 1.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0, -1.0, 3.0 ] ); * * var idx = dlastIndexOfFalsy( x.length, x, 1, 0 ); -* // returns 4 +* // returns 5 */ function dlastIndexOfFalsy( N, x, strideX, offsetX ) { return addon.ndarray( N, x, strideX, offsetX ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/src/main.c index a98d52ce068a..f98ccfd07cd5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/src/main.c @@ -24,10 +24,10 @@ /** * Returns the index of the last falsy element in a double-precision floating-point strided array. * -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @return index +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_of_falsy)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ) { CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); @@ -37,26 +37,26 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_of_falsy)( const CBLAS_INT N, co /** * Returns the index of the last falsy element in a double-precision floating-point strided array using alternative indexing semantics. * -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @param offsetX starting index -* @return index +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @param offsetX starting index +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_of_falsy_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { CBLAS_INT idx; - CBLAS_INT ox; - CBLAS_INT sx; + CBLAS_INT sv; + CBLAS_INT ov; if ( N <= 0 ) { return -1; } // Reverse the iteration order by flipping the stride and adjusting the offset: - ox = offsetX + ( ( N - 1 ) * strideX ); - sx = -strideX; + ov = offsetX + ( ( N - 1 ) * strideX ); + sv = -strideX; // Find the index of the first falsy element in the reversed "view": - idx = API_SUFFIX(stdlib_strided_dindex_of_falsy_ndarray)( N, X, sx, ox ); + idx = API_SUFFIX(stdlib_strided_dindex_of_falsy_ndarray)( N, X, sv, ov ); if ( idx < 0 ) { return idx; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.js index f5966a577437..20ea3717537a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.js @@ -37,21 +37,22 @@ tape( 'the function returns the index of the last falsy element', function test( var actual; var x; - x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 0.0, 4.0 ] ); + x = new Float64Array( [ 0.0, -1.0, 0.0, -2.0, -3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexOfFalsy( x.length, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + t.strictEqual( actual, 5, 'returns expected value' ); - actual = dlastIndexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the function ignores truthy elements (e.g., non-zero values)', function test( t ) { + var actual; + var x; - // Negative stride... - actual = dlastIndexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + x = new Float64Array( [ 3.0, 0.0, 5.0, 0.0, 2.0 ] ); - actual = dlastIndexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = dlastIndexOfFalsy( x.length, x, 1 ); + t.strictEqual( actual, 3, 'returns expected value' ); t.end(); }); @@ -60,10 +61,10 @@ tape( 'the function explicitly treats `NaN` values as falsy', function test( t ) var actual; var x; - x = new Float64Array( [ 1.0, 2.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); actual = dlastIndexOfFalsy( x.length, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); @@ -80,14 +81,72 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - actual = dlastIndexOfFalsy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + actual = dlastIndexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOfFalsy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + actual = dlastIndexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]); + + actual = dlastIndexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dlastIndexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dlastIndexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.native.js index 6ebcd8a73e85..5be01fb12a70 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.dlast_index_of_falsy.native.js @@ -46,21 +46,22 @@ tape( 'the function returns the index of the last falsy element', opts, function var actual; var x; - x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 0.0, 4.0 ] ); + x = new Float64Array( [ 0.0, -1.0, 0.0, -2.0, -3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexOfFalsy( x.length, x, 1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + t.strictEqual( actual, 5, 'returns expected value' ); - actual = dlastIndexOfFalsy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the function ignores truthy elements (e.g., non-zero values)', opts, function test( t ) { + var actual; + var x; - // Negative stride... - actual = dlastIndexOfFalsy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); + x = new Float64Array( [ 3.0, 0.0, 5.0, 0.0, 2.0 ] ); - actual = dlastIndexOfFalsy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = dlastIndexOfFalsy( x.length, x, 1 ); + t.strictEqual( actual, 3, 'returns expected value' ); t.end(); }); @@ -69,10 +70,10 @@ tape( 'the function explicitly treats `NaN` values as falsy', opts, function tes var actual; var x; - x = new Float64Array( [ 1.0, 2.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); actual = dlastIndexOfFalsy( x.length, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); @@ -89,14 +90,72 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - actual = dlastIndexOfFalsy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + actual = dlastIndexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOfFalsy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + actual = dlastIndexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]); + + actual = dlastIndexOfFalsy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dlastIndexOfFalsy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dlastIndexOfFalsy( 3, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.js index aa10a54bf633..cf8f0fc4bc76 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.js @@ -37,41 +37,22 @@ tape( 'the function returns the index of the last falsy element', function test( var actual; var x; - x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 0.0, 4.0 ] ); + x = new Float64Array( [ 0.0, -1.0, 0.0, -2.0, -3.0, 0.0 ] ); - actual = dlastIndexOfFalsy( 6, x, 1, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = dlastIndexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = dlastIndexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dlastIndexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = dlastIndexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = dlastIndexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dlastIndexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); + t.strictEqual( actual, 5, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter', function test( t ) { +tape( 'the function ignores truthy elements (e.g., non-zero values)', function test( t ) { var actual; var x; - x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0 ] ); + x = new Float64Array( [ 3.0, 0.0, 5.0, 0.0, 2.0 ] ); - actual = dlastIndexOfFalsy( 3, x, 1, 3 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); + t.strictEqual( actual, 3, 'returns expected value' ); t.end(); }); @@ -80,10 +61,10 @@ tape( 'the function explicitly treats `NaN` values as falsy', function test( t ) var actual; var x; - x = new Float64Array( [ 1.0, 2.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); - actual = dlastIndexOfFalsy( 4, x, 1, 0 ); - t.strictEqual( actual, 3, 'returns expected value' ); + actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); @@ -100,14 +81,69 @@ tape( 'the function returns `-1` if unable to find a falsy element', function te t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - actual = dlastIndexOfFalsy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + actual = dlastIndexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOfFalsy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + actual = dlastIndexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]); + + actual = dlastIndexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dlastIndexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = dlastIndexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.native.js index cd8245449553..2198385412c0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-falsy/test/test.ndarray.native.js @@ -46,41 +46,22 @@ tape( 'the function returns the index of the last falsy element', opts, function var actual; var x; - x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 0.0, 4.0 ] ); + x = new Float64Array( [ 0.0, -1.0, 0.0, -2.0, -3.0, 0.0 ] ); - actual = dlastIndexOfFalsy( 6, x, 1, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = dlastIndexOfFalsy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = dlastIndexOfFalsy( x.length-2, x, 1, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dlastIndexOfFalsy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Negative stride... - actual = dlastIndexOfFalsy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = dlastIndexOfFalsy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = dlastIndexOfFalsy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); + t.strictEqual( actual, 5, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter', opts, function test( t ) { +tape( 'the function ignores truthy elements (e.g., non-zero values)', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 0.0 ] ); + x = new Float64Array( [ 3.0, 0.0, 5.0, 0.0, 2.0 ] ); - actual = dlastIndexOfFalsy( 3, x, 1, 3 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); + t.strictEqual( actual, 3, 'returns expected value' ); t.end(); }); @@ -89,10 +70,10 @@ tape( 'the function explicitly treats `NaN` values as falsy', opts, function tes var actual; var x; - x = new Float64Array( [ 1.0, 2.0, NaN, 0.0 ] ); + x = new Float64Array( [ 2.0, 3.0, NaN, 1.0 ] ); - actual = dlastIndexOfFalsy( 4, x, 1, 0 ); - t.strictEqual( actual, 3, 'returns expected value' ); + actual = dlastIndexOfFalsy( x.length, x, 1, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); @@ -109,14 +90,69 @@ tape( 'the function returns `-1` if unable to find a falsy element', opts, funct t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - actual = dlastIndexOfFalsy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + actual = dlastIndexOfFalsy( 0, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOfFalsy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + actual = dlastIndexOfFalsy( -1, new Float64Array( [ 0.0, 1.0, 2.0 ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 0.0, // 1 + 3.0, + 0.0 // 2 + ]); + + actual = dlastIndexOfFalsy( 3, x, 2, 0 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 2 + 1.0, + 0.0, // 1 + 4.0, + 3.0 // 0 + ]); + + actual = dlastIndexOfFalsy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 0.0, // 1 + 4.0, + 5.0 // 2 + ]); + + actual = dlastIndexOfFalsy( 3, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/README.md index 641323e9633e..c121fd89983a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/README.md @@ -28,6 +28,8 @@ limitations under the License. + +
## Usage @@ -222,6 +224,8 @@ var out = dlastIndexOfRow.ndarray( 3, 2, A, 2, 1, 1, x, 1, 1, workspace, 1, 0 ); + +
## Notes @@ -233,6 +237,8 @@ var out = dlastIndexOfRow.ndarray( 3, 2, A, 2, 1, 1, x, 1, 1, workspace, 1, 0 ); + +
## Examples diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/docs/types/test.ts index d1ccbeb1e8ba..53c169e1f71e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/docs/types/test.ts @@ -183,7 +183,7 @@ import dlastIndexOfRow = require( './index' ); dlastIndexOfRow( 'row-major', 2, 2, A, 2, x ); // $ExpectError dlastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1 ); // $ExpectError dlastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w ); // $ExpectError - dlastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, 1, 0 ); // $ExpectError + dlastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -399,5 +399,5 @@ import dlastIndexOfRow = require( './index' ); dlastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError dlastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w ); // $ExpectError dlastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1 ); // $ExpectError - dlastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0, 0 ); // $ExpectError + dlastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.js index a77bbde25303..83cb74e8f9f3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.js @@ -76,7 +76,7 @@ function dlastIndexOfRow( order, M, N, A, LDA, x, strideX, workspace, strideW ) s = M; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', max( 1, s ), LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } if ( isColumnMajor( order ) ) { sa1 = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.native.js index ed0de8cc5d5b..8bbd7edde978 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/lib/dlast_index_of_row.native.js @@ -73,7 +73,7 @@ function dlastIndexOfRow( order, M, N, A, LDA, x, strideX, workspace, strideW ) s = M; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', max( 1, s ), LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } return addon( resolveOrder( order ), M, N, A, LDA, x, strideX, workspace, strideW ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/src/main.c index 253a89e52096..e60e34fba209 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-row/src/main.c @@ -24,16 +24,16 @@ /** * Returns the index of the last row in a double-precision floating-point input matrix which has the same elements as a provided search vector. * -* @param order storage layout -* @param M number of rows in `A` -* @param N number of columns in `A` -* @param A input matrix -* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param X search vector -* @param strideX stride length for `X` -* @param workspace workspace array for tracking row match candidates -* @param strideW stride length for `workspace` -* @return row index +* @param order storage layout +* @param M number of rows in `A` +* @param N number of columns in `A` +* @param A input matrix +* @param LDA stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param X search vector +* @param strideX stride length for `X` +* @param workspace workspace array for tracking row match candidates +* @param strideW stride length for `workspace` +* @return row index */ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_of_row)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, const double *X, const CBLAS_INT strideX, uint8_t *workspace, const CBLAS_INT strideW ) { CBLAS_INT sa1; @@ -56,19 +56,19 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_of_row)( const CBLAS_LAYOUT orde /** * Returns the index of the last row in a double-precision floating-point input matrix which has the same elements as a provided search vector using alternative indexing semantics. * -* @param M number of rows in `A` -* @param N number of columns in `A` -* @param A input matrix -* @param strideA1 stride length for the first dimension of `A` -* @param strideA2 stride length for the second dimension of `A` -* @param offsetA starting index for `A` -* @param X search vector -* @param strideX stride length for `X` -* @param offsetX starting index for `X` -* @param workspace workspace array for tracking row match candidates -* @param strideW stride length for `workspace` -* @param offsetW starting index for `workspace` -* @return row index +* @param M number of rows in `A` +* @param N number of columns in `A` +* @param A input matrix +* @param strideA1 stride length for the first dimension of `A` +* @param strideA2 stride length for the second dimension of `A` +* @param offsetA starting index for `A` +* @param X search vector +* @param strideX stride length for `X` +* @param offsetX starting index for `X` +* @param workspace workspace array for tracking row match candidates +* @param strideW stride length for `workspace` +* @param offsetW starting index for `workspace` +* @return row index */ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_of_row_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, uint8_t *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { CBLAS_INT da0; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/repl.txt index aeff52b6dade..f3fe96e6ccda 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( N, x, strideX ) - Returns the index of the last truthy element in a double-precision - floating-point strided array. + Returns the index of the last truthy element in a double-precision floating- + point strided array. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. @@ -31,19 +31,33 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}( x.length, x, 1 ) 5 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}( 3, x, 2 ) + 2 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, x1, 2 ) + 2 + {{alias}}.ndarray( N, x, strideX, offsetX ) - Returns the index of the last truthy element in a double-precision - floating-point strided array using alternative indexing semantics. + Returns the index of the last truthy element in a double-precision floating- + point strided array using alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. + The function explicitly treats `NaN` values as falsy. + Parameters ---------- N: integer @@ -65,9 +79,15 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); > var idx = {{alias}}.ndarray( x.length, x, 1, 0 ) 5 + // Using an index offset: + > var x = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 1.0, 0.0, 2.0, 3.0 ] ); + > var idx = {{alias}}.ndarray( 3, x, 2, 1 ) + 2 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/index.d.ts index 759f65d5b820..42611a421991 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/index.d.ts @@ -27,7 +27,7 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -50,7 +50,7 @@ interface Routine { * * ## Notes * - * - If unable to find a truthy element, the function returns `-1`. + * - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements @@ -75,7 +75,7 @@ interface Routine { * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/test.ts index 5048cc9121fe..68cecb4d700d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/docs/types/test.ts @@ -37,6 +37,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy( false, x, 1 ); // $ExpectError dlastIndexOfTruthy( null, x, 1 ); // $ExpectError dlastIndexOfTruthy( {}, x, 1 ); // $ExpectError + dlastIndexOfTruthy( ( 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... @@ -46,6 +47,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy( x.length, false, 1 ); // $ExpectError dlastIndexOfTruthy( x.length, null, 1 ); // $ExpectError dlastIndexOfTruthy( x.length, {}, 1 ); // $ExpectError + dlastIndexOfTruthy( 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... @@ -57,6 +59,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy( x.length, x, false ); // $ExpectError dlastIndexOfTruthy( x.length, x, null ); // $ExpectError dlastIndexOfTruthy( x.length, x, {} ); // $ExpectError + dlastIndexOfTruthy( x.length, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -64,7 +67,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy(); // $ExpectError dlastIndexOfTruthy( 3 ); // $ExpectError dlastIndexOfTruthy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError - dlastIndexOfTruthy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // $ExpectError + dlastIndexOfTruthy( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -83,6 +86,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy.ndarray( false, x, 1, 1 ); // $ExpectError dlastIndexOfTruthy.ndarray( null, x, 1, 1 ); // $ExpectError dlastIndexOfTruthy.ndarray( {}, x, 1, 1 ); // $ExpectError + dlastIndexOfTruthy.ndarray( ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... @@ -92,6 +96,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy.ndarray( x.length, false, 1, 1 ); // $ExpectError dlastIndexOfTruthy.ndarray( x.length, null, 1, 1 ); // $ExpectError dlastIndexOfTruthy.ndarray( x.length, {}, 1, 1 ); // $ExpectError + dlastIndexOfTruthy.ndarray( x.length, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -103,6 +108,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy.ndarray( x.length, x, false, 1 ); // $ExpectError dlastIndexOfTruthy.ndarray( x.length, x, null, 1 ); // $ExpectError dlastIndexOfTruthy.ndarray( x.length, x, {}, 1 ); // $ExpectError + dlastIndexOfTruthy.ndarray( x.length, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -114,6 +120,7 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy.ndarray( x.length, x, 1, false ); // $ExpectError dlastIndexOfTruthy.ndarray( x.length, x, 1, null ); // $ExpectError dlastIndexOfTruthy.ndarray( x.length, x, 1, {} ); // $ExpectError + dlastIndexOfTruthy.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... @@ -122,5 +129,5 @@ import dlastIndexOfTruthy = require( './index' ); dlastIndexOfTruthy.ndarray( 3 ); // $ExpectError dlastIndexOfTruthy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError dlastIndexOfTruthy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); // $ExpectError - dlastIndexOfTruthy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, 0 ); // $ExpectError + dlastIndexOfTruthy.ndarray( 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.js index d7ba13dd164b..faf507689d09 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.native.js index 375140164f6c..e07efac67aca 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/dlast_index_of_truthy.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.js index 1f984417c90c..8d6e37941aba 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.js @@ -30,7 +30,7 @@ var dindexOfTruthy = require( '@stdlib/blas/ext/base/dindex-of-truthy' ).ndarray * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.native.js index 9111665a8075..23838706311a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/lib/ndarray.native.js @@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' ); * * ## Notes * -* - If unable to find a truthy element, the function returns `-1`. +* - If the function is unable to find a truthy element, the function returns `-1`. * - The function explicitly treats `NaN` values as falsy. * * @param {PositiveInteger} N - number of indexed elements diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/src/main.c index ebeaed052693..c3af4c718a8d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/src/main.c @@ -24,10 +24,10 @@ /** * Returns the index of the last truthy element in a double-precision floating-point strided array. * -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @return index +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_of_truthy)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ) { CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); @@ -37,11 +37,11 @@ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_of_truthy)( const CBLAS_INT N, c /** * Returns the index of the last truthy element in a double-precision floating-point strided array using alternative indexing semantics. * -* @param N number of indexed elements -* @param X input array -* @param strideX stride length -* @param offsetX starting index -* @return index +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @param offsetX starting index +* @return index */ CBLAS_INT API_SUFFIX(stdlib_strided_dlast_index_of_truthy_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { CBLAS_INT idx; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.js index 8b3219a69301..4a36c8abc95f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.js @@ -39,20 +39,9 @@ tape( 'the function returns the index of the last truthy element', function test x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = dlastIndexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = dlastIndexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = dlastIndexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -80,7 +69,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', function t t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; actual = dlastIndexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -91,3 +80,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dlastIndexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = dlastIndexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dlastIndexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.native.js index 1d8f9c1f41f6..dfcd7ec454e6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.dlast_index_of_truthy.native.js @@ -48,20 +48,9 @@ tape( 'the function returns the index of the last truthy element', opts, functio x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexOfTruthy( x.length, x, 1 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = dlastIndexOfTruthy( 3, x, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Negative stride... - actual = dlastIndexOfTruthy( x.length, x, -1 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = dlastIndexOfTruthy( 3, x, -2 ); - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); }); @@ -89,7 +78,7 @@ tape( 'the function returns `-1` if unable to find a truthy element', opts, func t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; actual = dlastIndexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); @@ -100,3 +89,61 @@ tape( 'the function returns `-1` if provided an `N` parameter which is less than t.end(); }); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); + + actual = dlastIndexOfTruthy( 3, x, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); + + actual = dlastIndexOfTruthy( 3, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dlastIndexOfTruthy( 3, x1, 2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.js index ffea1f49693f..01ba352fa417 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.js @@ -39,76 +39,99 @@ tape( 'the function returns the index of the last truthy element', function test x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = dlastIndexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the function ignores falsy elements (e.g., `0`, `NaN`)', function test( t ) { + var actual; + var x; + + x = new Float64Array( [ 0.0, -0.0, 5.0, NaN ] ); - actual = dlastIndexOfTruthy( x.length-2, x, 1, 2 ); + actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dlastIndexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + t.end(); +}); - // Negative stride... - actual = dlastIndexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find a truthy element', function test( t ) { + var actual; + var x; - actual = dlastIndexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = dlastIndexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter', function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { var actual; - var x; - x = new Float64Array( [ 0.0, 0.0, 0.0, 4.0, 0.0, 5.0 ] ); + actual = dlastIndexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOfTruthy( 3, x, 1, 3 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = dlastIndexOfTruthy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function ignores falsy elements (e.g., `0`, `NaN`)', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; var x; - x = new Float64Array( [ 0.0, -0.0, 5.0, NaN ] ); + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); - actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); + actual = dlastIndexOfTruthy( 3, x, 2, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if unable to find a truthy element', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; var x; - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); - actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` offset', function test( t ) { var actual; + var x; - actual = dlastIndexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); - actual = dlastIndexOfTruthy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.native.js index 8dd150bbf99f..acb5d89e803a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of-truthy/test/test.ndarray.native.js @@ -48,76 +48,99 @@ tape( 'the function returns the index of the last truthy element', opts, functio x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 3.0, 0.0 ] ); - // Nonnegative stride... actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 4, 'returns expected value' ); - actual = dlastIndexOfTruthy( x.length-1, x, 1, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the function ignores falsy elements (e.g., `0`, `NaN`)', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array( [ 0.0, -0.0, 5.0, NaN ] ); - actual = dlastIndexOfTruthy( x.length-2, x, 1, 2 ); + actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); - actual = dlastIndexOfTruthy( 1, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + t.end(); +}); - // Negative stride... - actual = dlastIndexOfTruthy( x.length, x, -1, x.length-1 ); - t.strictEqual( actual, 4, 'returns expected value' ); +tape( 'the function returns `-1` if unable to find a truthy element', opts, function test( t ) { + var actual; + var x; - actual = dlastIndexOfTruthy( 3, x, -2, x.length-1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = dlastIndexOfTruthy( 3, x, -2, x.length-2 ); - t.strictEqual( actual, 0, 'returns expected value' ); + actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function supports an offset parameter', opts, function test( t ) { +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { var actual; - var x; - x = new Float64Array( [ 0.0, 0.0, 0.0, 4.0, 0.0, 5.0 ] ); + actual = dlastIndexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOfTruthy( 3, x, 1, 3 ); - t.strictEqual( actual, 2, 'returns expected value' ); + actual = dlastIndexOfTruthy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); + t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function ignores falsy elements (e.g., `0`, `NaN`)', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 0.0, -0.0, 5.0, NaN ] ); + x = new Float64Array([ + 0.0, // 0 + 1.0, + 2.0, // 1 + 3.0, + 4.0 // 2 + ]); - actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); + actual = dlastIndexOfTruthy( 3, x, 2, 0 ); t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if unable to find a truthy element', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; var x; - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + x = new Float64Array([ + 3.0, // 2 + 1.0, + 2.0, // 1 + 4.0, + 0.0 // 0 + ]); - actual = dlastIndexOfTruthy( x.length, x, 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOfTruthy( 3, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` offset', opts, function test( t ) { var actual; + var x; - actual = dlastIndexOfTruthy( 0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 1.0, + 0.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); - actual = dlastIndexOfTruthy( -1, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOfTruthy( 3, x, 2, 1 ); + t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/README.md b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/README.md index ba8be65ee488..bab8cb6bf16d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/README.md @@ -87,13 +87,13 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -// Initial array: +// Initial array... var x0 = new Float64Array( [ -2.0, 3.0, -6.0, -4.0, 5.0, 3.0 ] ); -// Create an offset view: +// Create an offset view... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -// Find index: +// Find index... var idx = dlastIndexOf( 3, 3.0, x1, 2 ); // returns 2 ``` @@ -115,7 +115,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 access only the last three elements of the strided array +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 access only the last three elements of the strided array: ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -198,7 +198,7 @@ console.log( idx ); Returns the last index of a specified search element in a double-precision floating-point strided array. ```c -double x[] = { 1.0, 2.0, 3.0, 2.0 }; +const double x[] = { 1.0, 2.0, 3.0, 2.0 }; int idx = stdlib_strided_dlast_index_of( 4, 2.0, x, 1 ); // returns 3 @@ -220,7 +220,7 @@ CBLAS_INT stdlib_strided_dlast_index_of( const CBLAS_INT N, const double searchE Returns the last index of a specified search element in a double-precision floating-point strided array using alternative indexing semantics. ```c -double x[] = { 1.0, 2.0, 3.0, 2.0 }; +const double x[] = { 1.0, 2.0, 3.0, 2.0 }; int idx = stdlib_strided_dlast_index_of_ndarray( 4, 2.0, x, 1, 0 ); // returns 3 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/repl.txt index 53b639b7b4d3..8991cbfc304b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/repl.txt @@ -32,10 +32,22 @@ 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}}( x.length, 3.0, x, 1 ) 6 + // Using `N` and stride parameters: + > var x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, 3.0 ] ); + > var idx = {{alias}}( 4, 3.0, x, 2 ) + 3 + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -2.0, 5.0, -6.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var idx = {{alias}}( 3, -2.0, x1, 2 ) + 1 + {{alias}}.ndarray( N, searchElement, x, strideX, offsetX ) Returns the last index of a specified search element in a double-precision @@ -69,9 +81,15 @@ 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, 3.0, x, 1, 0 ) 6 + // Using an index offset: + > 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( 3, 3.0, x, 2, 2 ) + 2 + See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/types/test.ts index 731cd3b4adc7..6d7959159e8a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/docs/types/test.ts @@ -37,6 +37,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf( false, 2.0, x, 1 ); // $ExpectError dlastIndexOf( null, 2.0, x, 1 ); // $ExpectError dlastIndexOf( {}, 2.0, x, 1 ); // $ExpectError + dlastIndexOf( ( x: number ): number => x, 2.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -48,6 +49,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf( x.length, false, x, 1 ); // $ExpectError dlastIndexOf( x.length, null, x, 1 ); // $ExpectError dlastIndexOf( x.length, {}, x, 1 ); // $ExpectError + dlastIndexOf( x.length, ( x: number ): number => x, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float64Array... @@ -57,6 +59,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf( x.length, 1.0, false, 1 ); // $ExpectError dlastIndexOf( x.length, 1.0, null, 1 ); // $ExpectError dlastIndexOf( x.length, 1.0, {}, 1 ); // $ExpectError + dlastIndexOf( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -68,6 +71,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf( x.length, 2.0, x, false ); // $ExpectError dlastIndexOf( x.length, 2.0, x, null ); // $ExpectError dlastIndexOf( x.length, 2.0, x, {} ); // $ExpectError + dlastIndexOf( x.length, 2.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -75,7 +79,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf(); // $ExpectError dlastIndexOf( 3, 2.0 ); // $ExpectError dlastIndexOf( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError - dlastIndexOf( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // $ExpectError + dlastIndexOf( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... @@ -94,6 +98,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf.ndarray( false, 2.0, x, 1, 1 ); // $ExpectError dlastIndexOf.ndarray( null, 2.0, x, 1, 1 ); // $ExpectError dlastIndexOf.ndarray( {}, 2.0, x, 1, 1 ); // $ExpectError + dlastIndexOf.ndarray( ( x: number ): number => x, 2.0, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... @@ -105,6 +110,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf.ndarray( x.length, false, x, 1, 1 ); // $ExpectError dlastIndexOf.ndarray( x.length, null, x, 1, 1 ); // $ExpectError dlastIndexOf.ndarray( x.length, {}, x, 1, 1 ); // $ExpectError + dlastIndexOf.ndarray( x.length, ( x: number ): number => x, x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float64Array... @@ -114,6 +120,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf.ndarray( x.length, 1.0, false, 1, 1 ); // $ExpectError dlastIndexOf.ndarray( x.length, 1.0, null, 1, 1 ); // $ExpectError dlastIndexOf.ndarray( x.length, 1.0, {}, 1, 1 ); // $ExpectError + dlastIndexOf.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -125,6 +132,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf.ndarray( x.length, 2.0, x, false, 1 ); // $ExpectError dlastIndexOf.ndarray( x.length, 2.0, x, null, 1 ); // $ExpectError dlastIndexOf.ndarray( x.length, 2.0, x, {}, 1 ); // $ExpectError + dlastIndexOf.ndarray( x.length, 2.0, x, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -136,6 +144,7 @@ import dlastIndexOf = require( './index' ); dlastIndexOf.ndarray( x.length, 2.0, x, 1, false ); // $ExpectError dlastIndexOf.ndarray( x.length, 2.0, x, 1, null ); // $ExpectError dlastIndexOf.ndarray( x.length, 2.0, x, 1, {} ); // $ExpectError + dlastIndexOf.ndarray( x.length, 2.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... @@ -144,5 +153,5 @@ import dlastIndexOf = require( './index' ); dlastIndexOf.ndarray( 3, 2.0 ); // $ExpectError dlastIndexOf.ndarray( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ) ); // $ExpectError dlastIndexOf.ndarray( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); // $ExpectError - dlastIndexOf.ndarray( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, 0 ); // $ExpectError + dlastIndexOf.ndarray( 3, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.js index 243c760bc6aa..489c7f5af9f4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.js @@ -29,6 +29,10 @@ var ndarray = require( './ndarray.js' ); /** * Returns the last index of a specified search element in a double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.native.js index 90fc1f154dae..60e1b250a438 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/dlast_index_of.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the last index of a specified search element in a double-precision floating-point strided array. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.js index c56004585907..d286be5618f2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.js @@ -28,6 +28,10 @@ var dindexOf = require( '@stdlib/blas/ext/base/dindex-of' ).ndarray; /** * Returns the last index of a specified search element in a double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.native.js index 0556514af354..67c2c4d6cdea 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/lib/ndarray.native.js @@ -28,6 +28,10 @@ var addon = require( './../src/addon.node' ); /** * Returns the last index of a specified search element in a double-precision floating-point strided array using alternative indexing semantics. * +* ## Notes +* +* - If the function is unable to find a search element, the function returns `-1`. +* * @param {PositiveInteger} N - number of indexed elements * @param {number} searchElement - search element * @param {Float64Array} x - input array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.js index ab7675d06166..9b2b04671899 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.js @@ -39,52 +39,87 @@ tape( 'the function returns the last index of an element which equals a provided x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dlastIndexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dlastIndexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 5, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; - actual = dlastIndexOf( x.length, 4.0, x, 1 ); + actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dlastIndexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); + actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { + var actual; - actual = dlastIndexOf( x.length, 4.0, x, -1 ); + actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; + var x; - actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; + var x; - actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dlastIndexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dlastIndexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.native.js index 40294f80972c..32e81f7c0879 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.dlast_index_of.native.js @@ -48,52 +48,87 @@ tape( 'the function returns the last index of an element which equals a provided x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dlastIndexOf( x.length, 1.0, x, 1 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dlastIndexOf( x.length, 2.0, x, 1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( x.length, 3.0, x, 1 ); - t.strictEqual( actual, 5, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; - actual = dlastIndexOf( x.length, 4.0, x, 1 ); + actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dlastIndexOf( x.length, 1.0, x, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); + actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOf( x.length, 2.0, x, -1 ); - t.strictEqual( actual, 3, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( x.length, 3.0, x, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { + var actual; - actual = dlastIndexOf( x.length, 4.0, x, -1 ); + actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; + var x; - actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOf( 3, 5.0, x, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; + var x; - actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dlastIndexOf( 3, 5.0, x, -2 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var actual; + var x0; + var x1; + + x0 = new Float64Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + actual = dlastIndexOf( 3, 4.0, x1, 2 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.js index e057f6d6ddd1..82805f36b604 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.js @@ -39,52 +39,84 @@ tape( 'the function returns the last index of an element which equals a provided x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dlastIndexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dlastIndexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 3, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', function test( t ) { + var actual; - actual = dlastIndexOf( x.length-2, 4.0, x, 1, 2 ); + actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dlastIndexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 5, 'returns expected value' ); + actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { + var actual; - actual = dlastIndexOf( x.length, 4.0, x, -1, x.length-1 ); + actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided an `N` parameter which is less than or equal to zero', function test( t ) { +tape( 'the function supports an `x` stride', function test( t ) { var actual; + var x; - actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { +tape( 'the function supports a negative `x` stride', function test( t ) { var actual; + var x; - actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dlastIndexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + actual = dlastIndexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.native.js index 0113dae2e25e..a459dd751cb9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dlast-index-of/test/test.ndarray.native.js @@ -48,52 +48,84 @@ tape( 'the function returns the last index of an element which equals a provided x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - // Nonnegative stride... actual = dlastIndexOf( x.length, 1.0, x, 1, 0 ); t.strictEqual( actual, 1, 'returns expected value' ); - actual = dlastIndexOf( x.length-1, 2.0, x, 1, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( x.length-2, 3.0, x, 1, 2 ); - t.strictEqual( actual, 3, 'returns expected value' ); +tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { + var actual; - actual = dlastIndexOf( x.length-2, 4.0, x, 1, 2 ); + actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len t.strictEqual( actual, -1, 'returns expected value' ); - // Negative stride... - actual = dlastIndexOf( x.length, 1.0, x, -1, x.length-1 ); - t.strictEqual( actual, 5, 'returns expected value' ); + actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len + t.strictEqual( actual, -1, 'returns expected value' ); - actual = dlastIndexOf( 3, 2.0, x, -2, x.length-1 ); - t.strictEqual( actual, 1, 'returns expected value' ); + t.end(); +}); - actual = dlastIndexOf( 3, 1.0, x, -2, x.length-2 ); - t.strictEqual( actual, 2, 'returns expected value' ); +tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { + var actual; - actual = dlastIndexOf( x.length, 4.0, x, -1, x.length-1 ); + actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if a provided `N` parameter is less than or equal to zero', opts, function test( t ) { +tape( 'the function supports an `x` stride', opts, function test( t ) { var actual; + var x; - actual = dlastIndexOf( 0, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 0 + -3.0, + 5.0, // 1 + 7.0, + 6.0 // 2 + ]); - actual = dlastIndexOf( -1, 2.0, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); + actual = dlastIndexOf( 3, 5.0, x, 2, 0 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); -tape( 'the function returns `-1` if provided a search element equal to `NaN`', opts, function test( t ) { +tape( 'the function supports a negative `x` stride', opts, function test( t ) { var actual; + var x; - actual = dlastIndexOf( 1, NaN, new Float64Array( [ NaN ] ), 1, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); + x = new Float64Array([ + 5.0, // 2 + -3.0, + -6.0, // 1 + 7.0, + 5.0 // 0 + ]); + + actual = dlastIndexOf( 3, 5.0, x, -2, 4 ); + t.strictEqual( actual, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var actual; + var x; + + x = new Float64Array([ + 1.0, + 4.0, // 0 + 3.0, + 4.0, // 1 + 5.0, + 6.0 // 2 + ]); + + actual = dlastIndexOf( 3, 4.0, x, 2, 1 ); + t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/README.md b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/README.md index d19d7efb767c..f7bcf900db04 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfind-index/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gfind-index/README.md @@ -22,6 +22,16 @@ limitations under the License. > Return the index of the first element which passes a test implemented by a predicate function. + + +
+ +
+ + + + +
## Usage @@ -45,7 +55,7 @@ var idx = gfindIndex( x.length, x, 1, isEven ); // returns 3 ``` -If no element passes a test implemented by a predicate function, the function returns `-1`. +If the function is unable to find an element which passes a test implemented by a predicate function, the function returns `-1`. ```javascript function isEven( v ) { @@ -61,7 +71,7 @@ var idx = gfindIndex( x.length, x, 1, isEven ); The function has the following parameters: - **N**: number of indexed elements. -- **x**: input array. +- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. - **strideX**: stride length. - **clbk**: callback function. - **thisArg**: execution context (_optional_). @@ -145,7 +155,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 access only the last three elements: +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array: ```javascript function isEven( v ) { @@ -162,6 +172,8 @@ var idx = gfindIndex.ndarray( 3, x, 1, x.length-3, isEven ); + +
## Notes @@ -173,6 +185,8 @@ var idx = gfindIndex.ndarray( 3, x, 1, x.length-3, isEven ); + +
## Examples @@ -220,6 +234,8 @@ console.log( idx );