From dd8fbbcf2c6ceb8fc23dab17371dbed708849adb Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 4 May 2026 20:31:39 +0500 Subject: [PATCH 1/6] feat: add blas/ext/base/glast-index-of-row --- .../ext/base/glast-index-of-row/README.md | 210 +++++++++++ .../glast-index-of-row/benchmark/benchmark.js | 113 ++++++ .../benchmark/benchmark.ndarray.js | 124 +++++++ .../ext/base/glast-index-of-row/docs/repl.txt | 103 ++++++ .../glast-index-of-row/docs/types/index.d.ts | 122 +++++++ .../glast-index-of-row/docs/types/test.ts | 302 ++++++++++++++++ .../base/glast-index-of-row/examples/index.js | 36 ++ .../base/glast-index-of-row/lib/accessors.js | 188 ++++++++++ .../ext/base/glast-index-of-row/lib/base.js | 170 +++++++++ .../ext/base/glast-index-of-row/lib/index.js | 59 ++++ .../ext/base/glast-index-of-row/lib/main.js | 87 +++++ .../base/glast-index-of-row/lib/ndarray.js | 60 ++++ .../ext/base/glast-index-of-row/package.json | 66 ++++ .../test/fixtures/column_major.json | 20 ++ .../test/fixtures/column_major_no_match.json | 19 + .../fixtures/large-strides/column_major.json | 37 ++ .../large-strides/column_major_no_match.json | 32 ++ .../fixtures/large-strides/row_major.json | 37 ++ .../large-strides/row_major_no_match.json | 32 ++ .../fixtures/mixed-strides/column_major.json | 29 ++ .../mixed-strides/column_major_no_match.json | 26 ++ .../fixtures/mixed-strides/row_major.json | 29 ++ .../mixed-strides/row_major_no_match.json | 26 ++ .../negative-strides/column_major.json | 29 ++ .../column_major_no_match.json | 26 ++ .../fixtures/negative-strides/row_major.json | 29 ++ .../negative-strides/row_major_no_match.json | 26 ++ .../test/fixtures/offsets/column_major.json | 30 ++ .../offsets/column_major_no_match.json | 27 ++ .../test/fixtures/offsets/row_major.json | 30 ++ .../fixtures/offsets/row_major_no_match.json | 27 ++ .../test/fixtures/row_major.json | 20 ++ .../test/fixtures/row_major_no_match.json | 19 + .../ext/base/glast-index-of-row/test/test.js | 38 ++ .../base/glast-index-of-row/test/test.main.js | 197 +++++++++++ .../glast-index-of-row/test/test.ndarray.js | 328 ++++++++++++++++++ 36 files changed, 2753 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/accessors.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/base.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/column_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/column_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/column_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/column_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/row_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/row_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/column_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/column_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/row_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/row_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/column_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/column_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/row_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/row_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/column_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/column_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/row_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/row_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/row_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/row_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md new file mode 100644 index 000000000000..7b1edc6078f7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md @@ -0,0 +1,210 @@ + + +# glastIndexOfRow + +> Return the index of the last row in an input matrix which has the same elements as a provided search vector. + +
+ +
+ + + +
+ +## Usage + +```javascript +var glastIndexOfRow = require( '@stdlib/blas/ext/base/glast-index-of-row' ); +``` + +#### glastIndexOfRow( order, M, N, A, LDA, x, strideX ) + +Returns the index of the last row in an input matrix which has the same elements as a provided search vector. + +```javascript +/* + A = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 3.0, 4.0 ] + ] +*/ +var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; + +var x = [ 3.0, 4.0 ]; +var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1 ); +// returns 2 +``` + +The function has the following parameters: + +- **order**: storage layout. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **A**: input matrix as a linear array. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **x**: search vector. +- **strideX**: stride length of `x`. + +If the function is unable to find a matching row, the function returns `-1`. + +```javascript +var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; + +var x = [ -3.0, -4.0 ]; +var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1 ); +// returns -1 +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays: +var A0 = new Float64Array( [ 9999.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); +var x0 = new Float64Array( [ 9999.0, 3.0, 4.0 ] ); + +// Create offset views: +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out = glastIndexOfRow( 'row-major', 3, 2, A1, 2, x1, 1 ); +// returns 1 +``` + +#### glastIndexOfRow.ndarray( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) + +Returns the index of the last row in an input matrix which has the same elements as a provided search vector using alternative indexing semantics. + +```javascript +/* + A = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 3.0, 4.0 ] + ] +*/ +var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; + +var x = [ 3.0, 4.0 ]; +var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0 ); +// returns 2 +``` + +The function has the following parameters: + +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **A**: input matrix as a linear array. +- **strideA1**: stride of the first dimension of `A`. +- **strideA2**: stride of the second dimension of `A`. +- **offsetA**: starting index for `A`. +- **x**: search vector. +- **strideX**: stride length of `x`. +- **offsetX**: starting index for `x`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, + +```javascript +/* + A = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ] +*/ +var A = [ 9999.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ]; + +var x = [ 9999.0, 3.0, 4.0 ]; +var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 1, x, 1, 1 ); +// returns 1 +``` + +
+ + + +
+ +## Notes + +- If `M <= 0` or `N <= 0`, both functions return `-1`. +- When searching for a matching row, 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. +- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). + +
+ + + +
+ +## Examples + + + + + +```javascript +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var glastIndexOfRow = require( '@stdlib/blas/ext/base/glast-index-of-row' ); + +var shape = [ 3, 3 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var A = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 4.0, 5.0, 6.0 ]; +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var x = [ 4.0, 5.0, 6.0 ]; +console.log( x ); + +var out = glastIndexOfRow( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ], x, 1 ); +console.log( out ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.js new file mode 100644 index 000000000000..abe3fc6e58c8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.js @@ -0,0 +1,113 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var zeros = require( '@stdlib/array/zeros' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var glastIndexOfRow = require( './../lib' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var A = zeros( N*N, 'generic' ); + var x = zeros( N, 'generic' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x[ N-1 ] += 1; + z = glastIndexOfRow( order, N, N, A, N, x, 1 ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::square_matrix:order=%s,size=%d', pkg, ord, N*N ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..1d72d569a54e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.ndarray.js @@ -0,0 +1,124 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var zeros = require( '@stdlib/array/zeros' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var glastIndexOfRow = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var A = zeros( N*N, 'generic' ); + var x = zeros( N, 'generic' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var sa1; + var sa2; + var z; + var i; + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { // order === 'row-major' + sa1 = N; + sa2 = 1; + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x[ N-1 ] += 1; + z = glastIndexOfRow( N, N, A, sa1, sa2, 0, x, 1, 0 ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::square_matrix:ndarray:order=%s,size=%d', pkg, ord, N*N ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/repl.txt new file mode 100644 index 000000000000..84c19d431927 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/repl.txt @@ -0,0 +1,103 @@ + +{{alias}}( order, M, N, A, LDA, x, strideX ) + Returns the index of the last row in an input matrix which has the same + elements as a provided search vector. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If the function is provided an empty matrix or if the function is unable to + find a matching row, the function returns `-1` (i.e., an invalid index). + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + A: Array|TypedArray + Input matrix `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + x: Array|TypedArray + Search vector. + + strideX: integer + Stride length for `x`. + + Returns + ------- + out: integer + Row index. + + Examples + -------- + > var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; + > var x = [ 3.0, 4.0 ]; + > {{alias}}( 'row-major', 3, 2, A, 2, x, 1 ) + 2 + + +{{alias}}.ndarray( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) + Returns the index of the last row in an input matrix which has the same + elements as a provided search vector using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, offset parameters support indexing semantics based on starting + indices. + + If the method is provided an empty matrix or if the method is unable to find + a matching row, the method returns `-1` (i.e., an invalid index). + + Parameters + ---------- + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + A: Array|TypedArray + Input matrix `A`. + + strideA1: integer + Stride of the first dimension of `A`. + + strideA2: integer + Stride of the second dimension of `A`. + + offsetA: integer + Starting index for `A`. + + x: Array|TypedArray + Search vector. + + strideX: integer + Stride length for `x`. + + offsetX: integer + Starting index for `x`. + + Returns + ------- + out: integer + Row index. + + Examples + -------- + > var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; + > var x = [ 3.0, 4.0 ]; + > {{alias}}.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0 ) + 2 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/index.d.ts new file mode 100644 index 000000000000..fba3ce25de24 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/index.d.ts @@ -0,0 +1,122 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; +import { Layout } from '@stdlib/types/blas'; + +/** +* Input array. +*/ +type InputArray = Collection | AccessorArrayLike; + +/** +* Interface describing `glastIndexOfRow`. +*/ +interface Routine { + /** + * Returns the index of the last row in an input matrix which has the same elements as a provided search vector. + * + * ## Notes + * + * - If the function is provided an empty matrix or if the function is unable to find a search vector, the function returns `-1` (i.e., an invalid 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 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` + * @returns row index + * + * @example + * var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] + * var x = [ 3.0, 4.0 ]; + * + * var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1 ); + * // returns 2 + */ + ( order: Layout, M: number, N: number, A: InputArray, LDA: number, x: InputArray, strideX: number ): number; + + /** + * Returns the index of the last row in an input matrix which has the same elements as a provided search vector using alternative indexing semantics. + * + * ## Notes + * + * - If the function is provided an empty matrix or if the function is unable to find a search vector, the function returns `-1` (i.e., an invalid index). + * + * @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 x - search vector + * @param strideX - stride length for `x` + * @param offsetX - starting index for `x` + * @returns row index + * + * @example + * var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] + * var x = [ 3.0, 4.0 ]; + * + * var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0 ); + * // returns 2 + */ + ndarray( M: number, N: number, A: InputArray, strideA1: number, strideA2: number, offsetA: number, x: InputArray, strideX: number, offsetX: number ): number; +} + +/** +* Returns the index of the last row in an input matrix which has the same elements as a provided search vector. +* +* ## Notes +* +* - If the function is provided an empty matrix or if the function is unable to find a search vector, the function returns `-1` (i.e., an invalid 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 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` +* @returns row index +* +* @example +* var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] +* var x = [ 3.0, 4.0 ]; +* +* var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1 ); +* // returns 2 +* +* @example +* var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] +* var x = [ 3.0, 4.0 ]; +* +* var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0 ); +* // returns 2 +*/ +declare var glastIndexOfRow: Routine; + + +// EXPORTS // + +export = glastIndexOfRow; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/test.ts new file mode 100644 index 000000000000..dfa95f307e73 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/test.ts @@ -0,0 +1,302 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import glastIndexOfRow = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow( 5, 2, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( true, 2, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( false, 2, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( null, 2, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( void 0, 2, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( [], 2, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( {}, 2, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( ( x: number ): number => x, 2, 2, A, 2, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow( 'row-major', '5', 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', true, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', false, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', null, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', void 0, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', [], 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', {}, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', ( x: number ): number => x, 2, A, 2, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow( 'row-major', 2, '5', A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, true, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, false, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, null, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, void 0, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, [], A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, {}, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, ( x: number ): number => x, A, 2, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a collection... +{ + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow( 'row-major', 2, 2, 5, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, true, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, false, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, null, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, void 0, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, {}, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, ( x: number ): number => x, 2, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow( 'row-major', 2, 2, A, '5', x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, true, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, false, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, null, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, void 0, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, [], x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, {}, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, ( x: number ): number => x, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a collection... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + + glastIndexOfRow( 'row-major', 2, 2, A, 2, 5, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, true, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, false, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, null, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, void 0, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, {}, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, '5' ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, true ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, false ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, null ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, void 0 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, [] ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, {} ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow(); // $ExpectError + glastIndexOfRow( 'row-major' ); // $ExpectError + glastIndexOfRow( 'row-major', 2 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, 0 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow.ndarray( '5', 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( true, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( false, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( null, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( void 0, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( [], 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( {}, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( ( x: number ): number => x, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow.ndarray( 2, '5', A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, true, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, false, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, null, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, void 0, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, [], A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, {}, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, ( x: number ): number => x, A, 2, 1, 0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a collection... +{ + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow.ndarray( 2, 2, 5, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, true, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, false, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, null, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, void 0, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, {}, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, ( x: number ): number => x, 2, 1, 0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, '5', 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, true, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, false, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, null, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, void 0, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, [], 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, {}, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, ( x: number ): number => x, 1, 0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, '5', 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, true, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, false, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, null, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, void 0, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, [], 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, {}, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, ( x: number ): number => x, 0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, '5', x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, true, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, false, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, null, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, void 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, [], x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, {}, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, ( x: number ): number => x, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a collection... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, 5, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, true, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, false, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, null, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, void 0, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, {}, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, '5', 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, true, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, false, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, null, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, void 0, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, [], 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, {}, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, '5' ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, true ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, false ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, null ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, void 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, [] ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, {} ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow.ndarray(); // $ExpectError + glastIndexOfRow.ndarray( 2 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, 0 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/examples/index.js new file mode 100644 index 000000000000..5f613e0b741f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/examples/index.js @@ -0,0 +1,36 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var glastIndexOfRow = require( './../lib' ); + +var shape = [ 3, 3 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var A = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 4.0, 5.0, 6.0 ]; +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var x = [ 4.0, 5.0, 6.0 ]; +console.log( x ); + +var out = glastIndexOfRow( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ], x, 1 ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/accessors.js new file mode 100644 index 000000000000..9a4264714bf1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/accessors.js @@ -0,0 +1,188 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var ones = require( '@stdlib/array/base/ones' ); + + +// MAIN // + +/** +* Returns the index of the last row in an input matrix which has the same elements as a provided search vector. +* +* ## Notes +* +* - If the function is unable to find a search vector, the function returns `-1` (i.e., an invalid index). +* +* @private +* @param {PositiveInteger} M - number of rows in `A` +* @param {PositiveInteger} N - number of columns in `A` +* @param {Object} A - input matrix object +* @param {Collection} A.data - input matrix data +* @param {Array} A.accessors - matrix element accessors +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Object} x - search vector object +* @param {Collection} x.data - search vector data +* @param {Array} x.accessors - search vector element accessors +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @returns {integer} row index +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] +* var x = [ 3.0, 4.0 ]; +* +* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 2, 1, 0, arraylike2object( toAccessorArray( x ) ), 1, 0 ); +* // returns 2 +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var A = [ 1.0, 3.0, 3.0, 2.0, 4.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] +* var x = [ 3.0, 4.0 ]; +* +* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 1, 3, 0, arraylike2object( toAccessorArray( x ) ), 1, 0 ); +* // returns 2 +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* var x = [ 1.0, 2.0 ]; +* +* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 1, 3, 0, arraylike2object( toAccessorArray( x ) ), 1, 0 ); +* // returns 0 +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* var x = [ 0.0, 0.0 ]; +* +* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 1, 3, 0, arraylike2object( toAccessorArray( x ) ), 1, 0 ); +* // returns 2 +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* var x = [ -3.0, -4.0 ]; +* +* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 1, 3, 0, arraylike2object( toAccessorArray( x ) ), 1, 0 ); +* // returns -1 +*/ +function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-len + var matches; + var abuf; + var xbuf; + var aget; + var xget; + var da0; + var da1; + var S0; + var S1; + var ia; + var ix; + var i0; + var i1; + + // Cache references to array data: + abuf = A.data; + xbuf = x.data; + + // Cache references to the element accessors: + aget = A.accessors[ 0 ]; + xget = x.accessors[ 0 ]; + + // Search for the last row matching the search vector... + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + S0 = N; + S1 = M; + + // Scan a row-major linear buffer from the last indexed element to the first indexed element, always moving in the same direction when both strides are the same sign, thus ensuring cache optimal traversal... + for ( i1 = S1-1; i1 >= 0; i1-- ) { + ia = offsetA + ( i1*strideA1 ) + ( (S0-1)*strideA2 ); + ix = offsetX + ( (S0-1)*strideX ); + for ( i0 = S0-1; i0 >= 0; i0-- ) { + if ( aget( abuf, ia ) !== xget( xbuf, ix ) ) { + // We found an element which is not in the search vector... + break; + } + ia -= strideA2; + ix -= strideX; + } + // If we successfully iterated over all columns, then that means we've found a match... + if ( i0 === -1 ) { + return i1; + } + } + // If we've made it here, then no rows match the search vector: + return -1; + } + // Column-major... + S0 = M; + S1 = N; + + // Resolve loop offset (pointer) increments: + da0 = -strideA1; + da1 = ( S0*strideA1 ) - strideA2; + + // Create an array for tracking which rows contain matching elements: + matches = ones( M ); + + // Finding the last matching row when a matrix is stored in column-major order requires effectively performing a full linear scan. In order to ensure cache-efficient traversal, scan up each column (otherwise, if we went row-by-row, we'd hop around linear memory, resulting in poor cache behavior)... + ia = offsetA + ( (S0-1)*strideA1 ) + ( (S1-1)*strideA2 ); + ix = offsetX + ( (S1-1)*strideX ); + for ( i1 = S1-1; i1 >= 0; i1-- ) { + // Scan up the rows in a column looking for a matching element... + for ( i0 = S0-1; i0 >= 0; i0-- ) { + if ( aget( abuf, ia ) !== xget( xbuf, ix ) ) { + // We found a non-matching element, which means we can exclude this row from the list of row candidates... + matches[ i0 ] = 0; + } + ia += da0; + } + ia += da1; + ix -= strideX; + } + // Search for the last matching row... + for ( i0 = S0-1; i0 >= 0; i0-- ) { + if ( matches[ i0 ] === 1 ) { + break; + } + } + return i0; +} + + +// EXPORTS // + +module.exports = glastIndexOfRow; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/base.js new file mode 100644 index 000000000000..177f927d9c49 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/base.js @@ -0,0 +1,170 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var ones = require( '@stdlib/array/base/ones' ); +var accessors = require( './accessors.js' ); + + +// MAIN // + +/** +* Returns the index of the last row in an input matrix which has the same elements as a provided search vector. +* +* ## Notes +* +* - If the function is provided an empty matrix or if the function is unable to find a search vector, the function returns `-1` (i.e., an invalid index). +* +* @private +* @param {PositiveInteger} M - number of rows in `A` +* @param {PositiveInteger} N - number of columns in `A` +* @param {Collection} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Collection} x - search vector +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @returns {integer} row index +* +* @example +* var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] +* var x = [ 3.0, 4.0 ]; +* +* var out = glastIndexOfRow( 3, 2, A, 2, 1, 0, x, 1, 0 ); +* // returns 2 +* +* @example +* var A = [ 1.0, 3.0, 3.0, 2.0, 4.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] +* var x = [ 3.0, 4.0 ]; +* +* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); +* // returns 2 +* +* @example +* var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* var x = [ 1.0, 2.0 ]; +* +* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); +* // returns 0 +* +* @example +* var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* var x = [ 0.0, 0.0 ]; +* +* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); +* // returns 2 +* +* @example +* var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* var x = [ -3.0, -4.0 ]; +* +* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); +* // returns -1 +*/ +function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-len + var matches; + var da0; + var da1; + var S0; + var S1; + var ia; + var ix; + var i0; + var i1; + var oa; + var ox; + + // Check whether the matrix is an empty matrix... + if ( M <= 0 || N <= 0 ) { + return -1; + } + oa = arraylike2object( A ); + ox = arraylike2object( x ); + if ( oa.accessorProtocol || ox.accessorProtocol ) { + return accessors( M, N, oa, strideA1, strideA2, offsetA, ox, strideX, offsetX ); // eslint-disable-line max-len + } + // Search for the last row matching the search vector... + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + S0 = N; + S1 = M; + + // Scan a row-major linear buffer from the last indexed element to the first indexed element, always moving in the same direction when both strides are the same sign, thus ensuring cache optimal traversal... + for ( i1 = S1-1; i1 >= 0; i1-- ) { + ia = offsetA + ( i1*strideA1 ) + ( (S0-1)*strideA2 ); + ix = offsetX + ( (S0-1)*strideX ); + for ( i0 = S0-1; i0 >= 0; i0-- ) { + if ( A[ ia ] !== x[ ix ] ) { + // We found an element which is not in the search vector... + break; + } + ia -= strideA2; + ix -= strideX; + } + // If we successfully iterated over all columns, then that means we've found a match... + if ( i0 === -1 ) { + return i1; + } + } + // If we've made it here, then no rows match the search vector: + return -1; + } + // Column-major... + S0 = M; + S1 = N; + + // Resolve loop offset (pointer) increments: + da0 = -strideA1; + da1 = ( S0*strideA1 ) - strideA2; + + // Create an array for tracking which rows contain matching elements: + matches = ones( M ); + + // Finding the last matching row when a matrix is stored in column-major order requires effectively performing a full linear scan. In order to ensure cache-efficient traversal, scan up each column (otherwise, if we went row-by-row, we'd hop around linear memory, resulting in poor cache behavior)... + ia = offsetA + ( (S0-1)*strideA1 ) + ( (S1-1)*strideA2 ); + ix = offsetX + ( (S1-1)*strideX ); + for ( i1 = S1-1; i1 >= 0; i1-- ) { + // Scan up the rows in a column looking for a matching element... + for ( i0 = S0-1; i0 >= 0; i0-- ) { + if ( A[ ia ] !== x[ ix ] ) { + // We found a non-matching element, which means we can exclude this row from the list of row candidates... + matches[ i0 ] = 0; + } + ia += da0; + } + ia += da1; + ix -= strideX; + } + // Search for the last matching row... + for ( i0 = S0-1; i0 >= 0; i0-- ) { + if ( matches[ i0 ] === 1 ) { + break; + } + } + return i0; +} + + +// EXPORTS // + +module.exports = glastIndexOfRow; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/index.js new file mode 100644 index 000000000000..41ddb26eb93a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/index.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Return the index of the last row in an input matrix which has the same elements as a provided search vector. +* +* @module @stdlib/blas/ext/base/glast-index-of-row +* +* @example +* var glastIndexOfRow = require( '@stdlib/blas/ext/base/glast-index-of-row' ); +* +* var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] +* var x = [ 3.0, 4.0 ]; +* +* var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1 ); +* // returns 2 +* +* @example +* var glastIndexOfRow = require( '@stdlib/blas/ext/base/glast-index-of-row' ); +* +* var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] +* var x = [ 3.0, 4.0 ]; +* +* var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0 ); +* // returns 2 +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js new file mode 100644 index 000000000000..951a9423711f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js @@ -0,0 +1,87 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Returns the index of the last row in an input matrix which has the same elements as a provided search vector. +* +* ## Notes +* +* - If the function is provided an empty matrix or if the function is unable to find a search vector, the function returns `-1` (i.e., an invalid index). +* +* @param {string} order - storage layout +* @param {PositiveInteger} M - number of rows in `A` +* @param {PositiveInteger} N - number of columns in `A` +* @param {Collection} A - input matrix +* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Collection} x - search vector +* @param {integer} strideX - stride length for `x` +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} fifth argument must be greater than or equal to max(1,N) +* @returns {integer} row index +* +* @example +* var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] +* var x = [ 3.0, 4.0 ]; +* +* var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1 ); +* // returns 2 +*/ +function glastIndexOfRow( order, M, N, A, LDA, x, strideX ) { + var sa1; + var sa2; + var s; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( isRowMajor( order ) ) { + s = N; + } else { + 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`.', s, LDA ) ); + } + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( M, N, A, sa1, sa2, 0, x, strideX, stride2offset( N, strideX ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = glastIndexOfRow; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js new file mode 100644 index 000000000000..0e09984b9360 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Returns the index of the last row in an input matrix which has the same elements as a provided search vector using alternative indexing semantics. +* +* ## Notes +* +* - If the function is provided an empty matrix or if the function is unable to find a search vector, the function returns `-1` (i.e., an invalid index). +* +* @param {PositiveInteger} M - number of rows in `A` +* @param {PositiveInteger} N - number of columns in `A` +* @param {Collection} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Collection} x - search vector +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @returns {integer} row index +* +* @example +* var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] +* var x = [ 3.0, 4.0 ]; +* +* var out = glastIndexOfRow( 3, 2, A, 2, 1, 0, x, 1, 0 ); +* // returns 2 +*/ +function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-len + return base( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ); +} + + +// EXPORTS // + +module.exports = glastIndexOfRow; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/package.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/package.json new file mode 100644 index 000000000000..690aa485b6d7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/blas/ext/base/glast-index-of-row", + "version": "0.0.0", + "description": "Return the index of the last row in an input matrix which has the same elements as a provided search vector.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "blas", + "matrix", + "strided", + "array", + "ndarray", + "vector", + "row", + "index", + "search", + "find", + "last-index-of", + "lastindexof" + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/column_major.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/column_major.json new file mode 100644 index 000000000000..1b3f885bb1bd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/column_major.json @@ -0,0 +1,20 @@ +{ + "order": "column-major", + "A": [ 1.0, 2.0, 2.0, 0.0, 3.0, 4.0, 4.0, 0.0 ], + "M": 4, + "N": 2, + "strideA1": 1, + "strideA2": 4, + "offsetA": 0, + "LDA": 4, + "A_mat": [ + [ 1.0, 3.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 2.0, 4.0 ], + "strideX": 1, + "offsetX": 0, + "expected": 2 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/column_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/column_major_no_match.json new file mode 100644 index 000000000000..8c3262a27da1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/column_major_no_match.json @@ -0,0 +1,19 @@ +{ + "order": "column-major", + "A": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "M": 3, + "N": 2, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 2.0, 4.0 ], + "strideX": 1, + "offsetX": 0, + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/column_major.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/column_major.json new file mode 100644 index 000000000000..d5c9f674b041 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/column_major.json @@ -0,0 +1,37 @@ +{ + "order": "column-major", + "A": [ + 1.0, + 9999.0, + 2.0, + 9999.0, + 2.0, + 9999.0, + 0.0, + 9999.0, + 3.0, + 9999.0, + 4.0, + 9999.0, + 4.0, + 9999.0, + 0.0, + 9999.0 + ], + "M": 4, + "N": 2, + "strideA1": 2, + "strideA2": 8, + "offsetA": 0, + "LDA": 4, + "A_mat": [ + [ 1.0, 3.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 2.0, 9999.0, 4.0, 9999.0 ], + "strideX": 2, + "offsetX": 0, + "expected": 2 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/column_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/column_major_no_match.json new file mode 100644 index 000000000000..29de47f49af6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/column_major_no_match.json @@ -0,0 +1,32 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "M": 3, + "N": 2, + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 3.0, 9999.0, 4.0, 9999.0 ], + "strideX": 2, + "offsetX": 0, + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/row_major.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/row_major.json new file mode 100644 index 000000000000..334a2220a3a5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/row_major.json @@ -0,0 +1,37 @@ +{ + "order": "row-major", + "A": [ + 1.0, + 9999.0, + 2.0, + 9999.0, + 3.0, + 9999.0, + 4.0, + 9999.0, + 3.0, + 9999.0, + 4.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "M": 4, + "N": 2, + "strideA1": 4, + "strideA2": 2, + "offsetA": 0, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 3.0, 9999.0, 4.0, 9999.0 ], + "strideX": 2, + "offsetX": 0, + "expected": 2 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/row_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/row_major_no_match.json new file mode 100644 index 000000000000..5337eee8283c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/large-strides/row_major_no_match.json @@ -0,0 +1,32 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "M": 3, + "N": 2, + "strideA1": 4, + "strideA2": 2, + "offsetA": 0, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 3.0, 9999.0, 4.0, 9999.0 ], + "strideX": 2, + "offsetX": 0, + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/column_major.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/column_major.json new file mode 100644 index 000000000000..c61c4091d06f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/column_major.json @@ -0,0 +1,29 @@ +{ + "order": "column-major", + "A": [ + 3.0, + 4.0, + 4.0, + 0.0, + 1.0, + 2.0, + 2.0, + 0.0 + ], + "M": 4, + "N": 2, + "strideA1": 1, + "strideA2": -4, + "offsetA": 4, + "LDA": 4, + "A_mat": [ + [ 1.0, 3.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 4.0, 9999.0, 2.0, 9999.0 ], + "strideX": -2, + "offsetX": 2, + "expected": 2 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/column_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/column_major_no_match.json new file mode 100644 index 000000000000..efd5cb66e8c3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/column_major_no_match.json @@ -0,0 +1,26 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 3, + "N": 2, + "strideA1": 1, + "strideA2": -3, + "offsetA": 3, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 4.0, 9999.0, 3.0, 9999.0 ], + "strideX": -2, + "offsetX": 2, + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/row_major.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/row_major.json new file mode 100644 index 000000000000..a82acc546e47 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/row_major.json @@ -0,0 +1,29 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 0.0, + 3.0, + 4.0, + 3.0, + 4.0, + 1.0, + 2.0 + ], + "M": 4, + "N": 2, + "strideA1": -2, + "strideA2": 1, + "offsetA": 6, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 9999.0, 4.0, 9999.0, 3.0, 9999.0 ], + "strideX": -2, + "offsetX": 3, + "expected": 2 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/row_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/row_major_no_match.json new file mode 100644 index 000000000000..0270879b82ad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/mixed-strides/row_major_no_match.json @@ -0,0 +1,26 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 3, + "N": 2, + "strideA1": -2, + "strideA2": 1, + "offsetA": 4, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 9999.0, 4.0, 9999.0, 3.0, 9999.0 ], + "strideX": -2, + "offsetX": 3, + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/column_major.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/column_major.json new file mode 100644 index 000000000000..5bb82a1c0e1c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/column_major.json @@ -0,0 +1,29 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 4.0, + 4.0, + 3.0, + 0.0, + 2.0, + 2.0, + 1.0 + ], + "M": 4, + "N": 2, + "strideA1": -1, + "strideA2": -4, + "offsetA": 7, + "LDA": 4, + "A_mat": [ + [ 1.0, 3.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 2.0, 9999.0, 4.0, 9999.0 ], + "strideX": 2, + "offsetX": 0, + "expected": 2 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/column_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/column_major_no_match.json new file mode 100644 index 000000000000..5fc0e96d96a2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/column_major_no_match.json @@ -0,0 +1,26 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 3, + "N": 2, + "strideA1": -1, + "strideA2": -3, + "offsetA": 5, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 2.0, 9999.0, 4.0, 9999.0 ], + "strideX": 2, + "offsetX": 0, + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/row_major.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/row_major.json new file mode 100644 index 000000000000..287989ddcaa5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/row_major.json @@ -0,0 +1,29 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 0.0, + 4.0, + 3.0, + 4.0, + 3.0, + 2.0, + 1.0 + ], + "M": 4, + "N": 2, + "strideA1": -2, + "strideA2": -1, + "offsetA": 7, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 3.0, 9999.0, 4.0, 9999.0 ], + "strideX": 2, + "offsetX": 0, + "expected": 2 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/row_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/row_major_no_match.json new file mode 100644 index 000000000000..4e430bab2070 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/negative-strides/row_major_no_match.json @@ -0,0 +1,26 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 3, + "N": 2, + "strideA1": -2, + "strideA2": -1, + "offsetA": 5, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 3.0, 9999.0, 4.0, 9999.0 ], + "strideX": 2, + "offsetX": 0, + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/column_major.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/column_major.json new file mode 100644 index 000000000000..284d9786905b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/column_major.json @@ -0,0 +1,30 @@ +{ + "order": "column-major", + "A": [ + 9999.0, + 1.0, + 2.0, + 2.0, + 0.0, + 3.0, + 4.0, + 4.0, + 0.0 + ], + "M": 4, + "N": 2, + "strideA1": 1, + "strideA2": 4, + "offsetA": 1, + "LDA": 4, + "A_mat": [ + [ 1.0, 3.0 ], + [ 2.0, 4.0 ], + [ 2.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 9999.0, 2.0, 4.0 ], + "strideX": 1, + "offsetX": 1, + "expected": 2 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/column_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/column_major_no_match.json new file mode 100644 index 000000000000..391801cfb10e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/column_major_no_match.json @@ -0,0 +1,27 @@ +{ + "order": "column-major", + "A": [ + 9999.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 3, + "N": 2, + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 9999.0, 3.0, 4.0 ], + "strideX": 1, + "offsetX": 1, + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/row_major.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/row_major.json new file mode 100644 index 000000000000..d81fab2629f9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/row_major.json @@ -0,0 +1,30 @@ +{ + "order": "row-major", + "A": [ + 9999.0, + 1.0, + 2.0, + 3.0, + 4.0, + 3.0, + 4.0, + 0.0, + 0.0 + ], + "M": 4, + "N": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 1, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 9999.0, 3.0, 4.0 ], + "strideX": 1, + "offsetX": 1, + "expected": 2 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/row_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/row_major_no_match.json new file mode 100644 index 000000000000..c7ef9df5d92a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/offsets/row_major_no_match.json @@ -0,0 +1,27 @@ +{ + "order": "row-major", + "A": [ + 9999.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 3, + "N": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 1, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 9999.0, 3.0, 4.0 ], + "strideX": 1, + "offsetX": 1, + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/row_major.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/row_major.json new file mode 100644 index 000000000000..077da11e148d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/row_major.json @@ -0,0 +1,20 @@ +{ + "order": "row-major", + "A": [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 0.0, 0.0 ], + "M": 4, + "N": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 3.0, 4.0 ], + "strideX": 1, + "offsetX": 0, + "expected": 2 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/row_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/row_major_no_match.json new file mode 100644 index 000000000000..d556a7f35cd4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/fixtures/row_major_no_match.json @@ -0,0 +1,19 @@ +{ + "order": "row-major", + "A": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "M": 3, + "N": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "x": [ 3.0, 4.0 ], + "strideX": 1, + "offsetX": 0, + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.js new file mode 100644 index 000000000000..13620484d023 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var glastIndexOfRow = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof glastIndexOfRow, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof glastIndexOfRow.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.main.js new file mode 100644 index 000000000000..944b6618632b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.main.js @@ -0,0 +1,197 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var glastIndexOfRow = require( './../lib' ); + + +// FIXTURES // + +var ROW_MAJOR_DATA = require( './fixtures/row_major.json' ); +var ROW_MAJOR_NO_MATCH = require( './fixtures/row_major_no_match.json' ); +var COLUMN_MAJOR_DATA = require( './fixtures/column_major.json' ); +var COLUMN_MAJOR_NO_MATCH = require( './fixtures/column_major_no_match.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof glastIndexOfRow, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( glastIndexOfRow.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { + var values; + var data; + var i; + + data = ROW_MAJOR_DATA; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + glastIndexOfRow( value, data.M, data.N, data.A, data.LDA, data.x, data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided a fifth argument which is not a valid `LDA` value (row-major)', function test( t ) { + var values; + var data; + var i; + + data = ROW_MAJOR_DATA; + + values = [ + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + glastIndexOfRow( data.order, data.M, data.N, data.A, value, data.x, data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided a fifth argument which is not a valid `LDA` value (column-major)', function test( t ) { + var values; + var data; + var i; + + data = COLUMN_MAJOR_DATA; + + values = [ + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + glastIndexOfRow( data.order, data.M, data.N, data.A, value, data.x, data.strideX ); + }; + } +}); + +tape( 'the function returns an invalid index when M is less than or equal to zero', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_DATA; + out = glastIndexOfRow( data.order, 0, data.N, data.A, data.LDA, data.x, data.strideX ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index when N is less than or equal to zero', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_DATA; + out = glastIndexOfRow( data.order, data.M, 0, data.A, data.LDA, data.x, data.strideX ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (row-major)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_DATA; + out = glastIndexOfRow( data.order, data.M, data.N, data.A, data.LDA, data.x, data.strideX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (column-major)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.order, data.M, data.N, data.A, data.LDA, data.x, data.strideX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (row-major)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.order, data.M, data.N, data.A, data.LDA, data.x, data.strideX ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (column-major)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.order, data.M, data.N, data.A, data.LDA, data.x, data.strideX ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.ndarray.js new file mode 100644 index 000000000000..4b0bc3bc359d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.ndarray.js @@ -0,0 +1,328 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, id-length */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var glastIndexOfRow = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var ROW_MAJOR_DATA = require( './fixtures/row_major.json' ); +var ROW_MAJOR_NO_MATCH = require( './fixtures/row_major_no_match.json' ); +var COLUMN_MAJOR_DATA = require( './fixtures/column_major.json' ); +var COLUMN_MAJOR_NO_MATCH = require( './fixtures/column_major_no_match.json' ); +var OFFSET_ROW_MAJOR_DATA = require( './fixtures/offsets/row_major.json' ); +var OFFSET_ROW_MAJOR_NO_MATCH = require( './fixtures/offsets/row_major_no_match.json' ); +var OFFSET_COLUMN_MAJOR_DATA = require( './fixtures/offsets/column_major.json' ); +var OFFSET_COLUMN_MAJOR_NO_MATCH = require( './fixtures/offsets/column_major_no_match.json' ); +var NEGATIVE_STRIDES_ROW_MAJOR_DATA = require( './fixtures/negative-strides/row_major.json' ); +var NEGATIVE_STRIDES_ROW_MAJOR_NO_MATCH = require( './fixtures/negative-strides/row_major_no_match.json' ); +var NEGATIVE_STRIDES_COLUMN_MAJOR_DATA = require( './fixtures/negative-strides/column_major.json' ); +var NEGATIVE_STRIDES_COLUMN_MAJOR_NO_MATCH = require( './fixtures/negative-strides/column_major_no_match.json' ); +var MIXED_STRIDES_ROW_MAJOR_DATA = require( './fixtures/mixed-strides/row_major.json' ); +var MIXED_STRIDES_ROW_MAJOR_NO_MATCH = require( './fixtures/mixed-strides/row_major_no_match.json' ); +var MIXED_STRIDES_COLUMN_MAJOR_DATA = require( './fixtures/mixed-strides/column_major.json' ); +var MIXED_STRIDES_COLUMN_MAJOR_NO_MATCH = require( './fixtures/mixed-strides/column_major_no_match.json' ); +var LARGE_STRIDES_ROW_MAJOR_DATA = require( './fixtures/large-strides/row_major.json' ); +var LARGE_STRIDES_ROW_MAJOR_NO_MATCH = require( './fixtures/large-strides/row_major_no_match.json' ); +var LARGE_STRIDES_COLUMN_MAJOR_DATA = require( './fixtures/large-strides/column_major.json' ); +var LARGE_STRIDES_COLUMN_MAJOR_NO_MATCH = require( './fixtures/large-strides/column_major_no_match.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof glastIndexOfRow, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( glastIndexOfRow.length, 9, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index when M is less than or equal to zero (row-major)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_DATA; + out = glastIndexOfRow( 0, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index when N is less than or equal to zero (row-major)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_DATA; + out = glastIndexOfRow( data.M, 0, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index when M is less than or equal to zero (column-major)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_DATA; + out = glastIndexOfRow( 0, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index when N is less than or equal to zero (column-major)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.M, 0, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (row-major)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (column-major)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (row-major)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (column-major)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (row-major, offsets)', function test( t ) { + var data; + var out; + + data = OFFSET_ROW_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (column-major, offsets)', function test( t ) { + var data; + var out; + + data = OFFSET_COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (row-major, offsets)', function test( t ) { + var data; + var out; + + data = OFFSET_ROW_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (column-major, offsets)', function test( t ) { + var data; + var out; + + data = OFFSET_COLUMN_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (row-major, mixed strides)', function test( t ) { + var data; + var out; + + data = MIXED_STRIDES_ROW_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (column-major, mixed strides)', function test( t ) { + var data; + var out; + + data = MIXED_STRIDES_COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (row-major, mixed strides)', function test( t ) { + var data; + var out; + + data = MIXED_STRIDES_ROW_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (column-major, mixed strides)', function test( t ) { + var data; + var out; + + data = MIXED_STRIDES_COLUMN_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (row-major, negative strides)', function test( t ) { + var data; + var out; + + data = NEGATIVE_STRIDES_ROW_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (column-major, negative strides)', function test( t ) { + var data; + var out; + + data = NEGATIVE_STRIDES_COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (row-major, negative strides)', function test( t ) { + var data; + var out; + + data = NEGATIVE_STRIDES_ROW_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (column-major, negative strides)', function test( t ) { + var data; + var out; + + data = NEGATIVE_STRIDES_COLUMN_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (row-major, large strides)', function test( t ) { + var data; + var out; + + data = LARGE_STRIDES_ROW_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (column-major, large strides)', function test( t ) { + var data; + var out; + + data = LARGE_STRIDES_COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (row-major, large strides)', function test( t ) { + var data; + var out; + + data = LARGE_STRIDES_ROW_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (column-major, large strides)', function test( t ) { + var data; + var out; + + data = LARGE_STRIDES_COLUMN_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); From 6ee13f97ebcd85f80befeb2a1e12eda388d10c80 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 4 May 2026 20:34:33 +0500 Subject: [PATCH 2/6] fix: lint error --- .../@stdlib/blas/ext/base/glast-index-of-row/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md index 7b1edc6078f7..7af7d7724663 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md @@ -94,8 +94,12 @@ var out = glastIndexOfRow( 'row-major', 3, 2, A1, 2, x1, 1 ); // returns 1 ``` + + #### glastIndexOfRow.ndarray( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) + + Returns the index of the last row in an input matrix which has the same elements as a provided search vector using alternative indexing semantics. ```javascript From a8d29139e0bb3b3f23747bdba412cd9fd02b0274 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Tue, 5 May 2026 00:30:54 +0500 Subject: [PATCH 3/6] fix: remove base --- .../ext/base/glast-index-of-row/lib/base.js | 170 ------------------ .../ext/base/glast-index-of-row/lib/main.js | 4 +- .../base/glast-index-of-row/lib/ndarray.js | 85 ++++++++- 3 files changed, 85 insertions(+), 174 deletions(-) delete mode 100644 lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/base.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/base.js deleted file mode 100644 index 177f927d9c49..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/base.js +++ /dev/null @@ -1,170 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); -var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -var ones = require( '@stdlib/array/base/ones' ); -var accessors = require( './accessors.js' ); - - -// MAIN // - -/** -* Returns the index of the last row in an input matrix which has the same elements as a provided search vector. -* -* ## Notes -* -* - If the function is provided an empty matrix or if the function is unable to find a search vector, the function returns `-1` (i.e., an invalid index). -* -* @private -* @param {PositiveInteger} M - number of rows in `A` -* @param {PositiveInteger} N - number of columns in `A` -* @param {Collection} A - input matrix -* @param {integer} strideA1 - stride of the first dimension of `A` -* @param {integer} strideA2 - stride of the second dimension of `A` -* @param {NonNegativeInteger} offsetA - starting index for `A` -* @param {Collection} x - search vector -* @param {integer} strideX - stride length for `x` -* @param {NonNegativeInteger} offsetX - starting index for `x` -* @returns {integer} row index -* -* @example -* var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] -* var x = [ 3.0, 4.0 ]; -* -* var out = glastIndexOfRow( 3, 2, A, 2, 1, 0, x, 1, 0 ); -* // returns 2 -* -* @example -* var A = [ 1.0, 3.0, 3.0, 2.0, 4.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] -* var x = [ 3.0, 4.0 ]; -* -* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); -* // returns 2 -* -* @example -* var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] -* var x = [ 1.0, 2.0 ]; -* -* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); -* // returns 0 -* -* @example -* var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] -* var x = [ 0.0, 0.0 ]; -* -* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); -* // returns 2 -* -* @example -* var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] -* var x = [ -3.0, -4.0 ]; -* -* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); -* // returns -1 -*/ -function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-len - var matches; - var da0; - var da1; - var S0; - var S1; - var ia; - var ix; - var i0; - var i1; - var oa; - var ox; - - // Check whether the matrix is an empty matrix... - if ( M <= 0 || N <= 0 ) { - return -1; - } - oa = arraylike2object( A ); - ox = arraylike2object( x ); - if ( oa.accessorProtocol || ox.accessorProtocol ) { - return accessors( M, N, oa, strideA1, strideA2, offsetA, ox, strideX, offsetX ); // eslint-disable-line max-len - } - // Search for the last row matching the search vector... - if ( isRowMajor( [ strideA1, strideA2 ] ) ) { - S0 = N; - S1 = M; - - // Scan a row-major linear buffer from the last indexed element to the first indexed element, always moving in the same direction when both strides are the same sign, thus ensuring cache optimal traversal... - for ( i1 = S1-1; i1 >= 0; i1-- ) { - ia = offsetA + ( i1*strideA1 ) + ( (S0-1)*strideA2 ); - ix = offsetX + ( (S0-1)*strideX ); - for ( i0 = S0-1; i0 >= 0; i0-- ) { - if ( A[ ia ] !== x[ ix ] ) { - // We found an element which is not in the search vector... - break; - } - ia -= strideA2; - ix -= strideX; - } - // If we successfully iterated over all columns, then that means we've found a match... - if ( i0 === -1 ) { - return i1; - } - } - // If we've made it here, then no rows match the search vector: - return -1; - } - // Column-major... - S0 = M; - S1 = N; - - // Resolve loop offset (pointer) increments: - da0 = -strideA1; - da1 = ( S0*strideA1 ) - strideA2; - - // Create an array for tracking which rows contain matching elements: - matches = ones( M ); - - // Finding the last matching row when a matrix is stored in column-major order requires effectively performing a full linear scan. In order to ensure cache-efficient traversal, scan up each column (otherwise, if we went row-by-row, we'd hop around linear memory, resulting in poor cache behavior)... - ia = offsetA + ( (S0-1)*strideA1 ) + ( (S1-1)*strideA2 ); - ix = offsetX + ( (S1-1)*strideX ); - for ( i1 = S1-1; i1 >= 0; i1-- ) { - // Scan up the rows in a column looking for a matching element... - for ( i0 = S0-1; i0 >= 0; i0-- ) { - if ( A[ ia ] !== x[ ix ] ) { - // We found a non-matching element, which means we can exclude this row from the list of row candidates... - matches[ i0 ] = 0; - } - ia += da0; - } - ia += da1; - ix -= strideX; - } - // Search for the last matching row... - for ( i0 = S0-1; i0 >= 0; i0-- ) { - if ( matches[ i0 ] === 1 ) { - break; - } - } - return i0; -} - - -// EXPORTS // - -module.exports = glastIndexOfRow; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js index 951a9423711f..672dab3ae109 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js @@ -26,7 +26,7 @@ var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string var stride2offset = require( '@stdlib/strided/base/stride2offset' ); var max = require( '@stdlib/math/base/special/fast/max' ); var format = require( '@stdlib/string/format' ); -var base = require( './base.js' ); +var ndarray = require( './ndarray.js' ); // MAIN // @@ -78,7 +78,7 @@ function glastIndexOfRow( order, M, N, A, LDA, x, strideX ) { sa1 = LDA; sa2 = 1; } - return base( M, N, A, sa1, sa2, 0, x, strideX, stride2offset( N, strideX ) ); // eslint-disable-line max-len + return ndarray( M, N, A, sa1, sa2, 0, x, strideX, stride2offset( N, strideX ) ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js index 0e09984b9360..3227ac4601d6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js @@ -20,7 +20,10 @@ // MODULES // -var base = require( './base.js' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var ones = require( '@stdlib/array/base/ones' ); +var accessors = require( './accessors.js' ); // MAIN // @@ -51,7 +54,85 @@ var base = require( './base.js' ); * // returns 2 */ function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-len - return base( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ); + var matches; + var da0; + var da1; + var S0; + var S1; + var ia; + var ix; + var i0; + var i1; + var oa; + var ox; + + // Check whether the matrix is an empty matrix... + if ( M <= 0 || N <= 0 ) { + return -1; + } + oa = arraylike2object( A ); + ox = arraylike2object( x ); + if ( oa.accessorProtocol || ox.accessorProtocol ) { + return accessors( M, N, oa, strideA1, strideA2, offsetA, ox, strideX, offsetX ); // eslint-disable-line max-len + } + // Search for the last row matching the search vector... + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + S0 = N; + S1 = M; + + // Scan a row-major linear buffer from the last indexed element to the first indexed element, always moving in the same direction when both strides are the same sign, thus ensuring cache optimal traversal... + for ( i1 = S1-1; i1 >= 0; i1-- ) { + ia = offsetA + ( i1*strideA1 ) + ( (S0-1)*strideA2 ); + ix = offsetX + ( (S0-1)*strideX ); + for ( i0 = S0-1; i0 >= 0; i0-- ) { + if ( A[ ia ] !== x[ ix ] ) { + // We found an element which is not in the search vector... + break; + } + ia -= strideA2; + ix -= strideX; + } + // If we successfully iterated over all columns, then that means we've found a match... + if ( i0 === -1 ) { + return i1; + } + } + // If we've made it here, then no rows match the search vector: + return -1; + } + // Column-major... + S0 = M; + S1 = N; + + // Resolve loop offset (pointer) increments: + da0 = -strideA1; + da1 = ( S0*strideA1 ) - strideA2; + + // Create an array for tracking which rows contain matching elements: + matches = ones( M ); + + // Finding the last matching row when a matrix is stored in column-major order requires effectively performing a full linear scan. In order to ensure cache-efficient traversal, scan up each column (otherwise, if we went row-by-row, we'd hop around linear memory, resulting in poor cache behavior)... + ia = offsetA + ( (S0-1)*strideA1 ) + ( (S1-1)*strideA2 ); + ix = offsetX + ( (S1-1)*strideX ); + for ( i1 = S1-1; i1 >= 0; i1-- ) { + // Scan up the rows in a column looking for a matching element... + for ( i0 = S0-1; i0 >= 0; i0-- ) { + if ( A[ ia ] !== x[ ix ] ) { + // We found a non-matching element, which means we can exclude this row from the list of row candidates... + matches[ i0 ] = 0; + } + ia += da0; + } + ia += da1; + ix -= strideX; + } + // Search for the last matching row... + for ( i0 = S0-1; i0 >= 0; i0-- ) { + if ( matches[ i0 ] === 1 ) { + break; + } + } + return i0; } From bf0b99b0f9d3ec8b7e01f298b623adce567a85e6 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 4 May 2026 20:38:04 -0700 Subject: [PATCH 4/6] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/glast-index-of-row/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js index 672dab3ae109..a74ccdca3290 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js @@ -46,7 +46,7 @@ var ndarray = require( './ndarray.js' ); * @param {Collection} x - search vector * @param {integer} strideX - stride length for `x` * @throws {TypeError} first argument must be a valid order -* @throws {RangeError} fifth argument must be greater than or equal to max(1,N) +* @throws {RangeError} fifth argument must be a valid stride * @returns {integer} row index * * @example From 75c42444d7d80542057d94addfd0454fc5a6e13d Mon Sep 17 00:00:00 2001 From: headlessNode Date: Tue, 5 May 2026 17:19:47 +0500 Subject: [PATCH 5/6] fix: apply suggestions from code review --- .../ext/base/glast-index-of-row/README.md | 10 +- .../ext/base/glast-index-of-row/docs/repl.txt | 8 +- .../glast-index-of-row/docs/types/index.d.ts | 9 +- .../base/glast-index-of-row/lib/accessors.js | 4 +- .../ext/base/glast-index-of-row/lib/main.js | 4 +- .../base/glast-index-of-row/lib/ndarray.js | 32 ++- .../base/glast-index-of-row/test/test.main.js | 45 ++++ .../glast-index-of-row/test/test.ndarray.js | 221 ++++++++++++++++++ 8 files changed, 314 insertions(+), 19 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md index 7af7d7724663..72954b81d530 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md @@ -61,9 +61,9 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix as a linear array. -- **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. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. If the function is unable to find a matching row, the function returns `-1`. @@ -122,11 +122,11 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input matrix as a linear array. -- **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. -- **strideX**: stride length of `x`. +- **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/repl.txt index 84c19d431927..6a73a1ecebdf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-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: Array|TypedArray Search vector. @@ -70,10 +70,10 @@ Input matrix `A`. strideA1: integer - Stride of the first dimension of `A`. + Stride length for the first dimension of `A`. strideA2: integer - Stride of the second dimension of `A`. + Stride length for the second dimension of `A`. offsetA: integer Starting index for `A`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/index.d.ts index fba3ce25de24..4478d70ff0da 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/index.d.ts @@ -43,7 +43,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` * @returns row index @@ -67,8 +67,9 @@ 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` * @param offsetX - starting index for `x` @@ -95,7 +96,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` * @returns row index diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/accessors.js index 9a4264714bf1..6de912787b47 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/accessors.js @@ -39,8 +39,8 @@ var ones = require( '@stdlib/array/base/ones' ); * @param {Object} A - input matrix object * @param {Collection} A.data - input matrix data * @param {Array} A.accessors - matrix element accessors -* @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 {Object} x - search vector object * @param {Collection} x.data - search vector data diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js index a74ccdca3290..b833de211e18 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js @@ -42,7 +42,7 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Collection} 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 {Collection} x - search vector * @param {integer} strideX - stride length for `x` * @throws {TypeError} first argument must be a valid order @@ -69,7 +69,7 @@ function glastIndexOfRow( order, M, N, A, LDA, x, strideX ) { 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`.', s, LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be a valid stride. Value: `%d`.', LDA ) ); } if ( isColumnMajor( order ) ) { sa1 = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js index 3227ac4601d6..7ebf12af1ea6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js @@ -38,8 +38,8 @@ var accessors = require( './accessors.js' ); * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` * @param {Collection} 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 {Collection} x - search vector * @param {integer} strideX - stride length for `x` @@ -52,6 +52,34 @@ var accessors = require( './accessors.js' ); * * var out = glastIndexOfRow( 3, 2, A, 2, 1, 0, x, 1, 0 ); * // returns 2 +* +* @example +* var A = [ 1.0, 3.0, 3.0, 2.0, 4.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] +* var x = [ 3.0, 4.0 ]; +* +* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); +* // returns 2 +* +* @example +* var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* var x = [ 1.0, 2.0 ]; +* +* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); +* // returns 0 +* +* @example +* var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* var x = [ 0.0, 0.0 ]; +* +* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); +* // returns 2 +* +* @example +* var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* var x = [ -3.0, -4.0 ]; +* +* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); +* // returns -1 */ function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-len var matches; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.main.js index 944b6618632b..1c3d7f54ee20 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.main.js @@ -23,6 +23,7 @@ // MODULES // var tape = require( 'tape' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var glastIndexOfRow = require( './../lib' ); @@ -195,3 +196,47 @@ tape( 'the function returns an invalid index if unable to find a search vector ( t.strictEqual( out, -1, 'returns expected value' ); t.end(); }); + +tape( 'the function returns the index of the last row matching a search vector (row-major, accessors)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_DATA; + out = glastIndexOfRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA, toAccessorArray( data.x ), data.strideX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (column-major, accessors)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA, toAccessorArray( data.x ), data.strideX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (row-major, accessors)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA, toAccessorArray( data.x ), data.strideX ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (column-major, accessors)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA, toAccessorArray( data.x ), data.strideX ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.ndarray.js index 4b0bc3bc359d..6143c7af6e2d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.ndarray.js @@ -23,6 +23,7 @@ // MODULES // var tape = require( 'tape' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var glastIndexOfRow = require( './../lib/ndarray.js' ); @@ -326,3 +327,223 @@ tape( 'the function returns an invalid index if unable to find a search vector ( t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); }); + +tape( 'the function returns the index of the last row matching a search vector (row-major, accessors)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (column-major, accessors)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (row-major, accessors)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (column-major, accessors)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (row-major, offsets, accessors)', function test( t ) { + var data; + var out; + + data = OFFSET_ROW_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (column-major, offsets, accessors)', function test( t ) { + var data; + var out; + + data = OFFSET_COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (row-major, offsets, accessors)', function test( t ) { + var data; + var out; + + data = OFFSET_ROW_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (column-major, offsets, accessors)', function test( t ) { + var data; + var out; + + data = OFFSET_COLUMN_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (row-major, mixed strides, accessors)', function test( t ) { + var data; + var out; + + data = MIXED_STRIDES_ROW_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (column-major, mixed strides, accessors)', function test( t ) { + var data; + var out; + + data = MIXED_STRIDES_COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (row-major, mixed strides, accessors)', function test( t ) { + var data; + var out; + + data = MIXED_STRIDES_ROW_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (column-major, mixed strides, accessors)', function test( t ) { + var data; + var out; + + data = MIXED_STRIDES_COLUMN_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (row-major, negative strides, accessors)', function test( t ) { + var data; + var out; + + data = NEGATIVE_STRIDES_ROW_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (column-major, negative strides, accessors)', function test( t ) { + var data; + var out; + + data = NEGATIVE_STRIDES_COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (row-major, negative strides, accessors)', function test( t ) { + var data; + var out; + + data = NEGATIVE_STRIDES_ROW_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (column-major, negative strides, accessors)', function test( t ) { + var data; + var out; + + data = NEGATIVE_STRIDES_COLUMN_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (row-major, large strides, accessors)', function test( t ) { + var data; + var out; + + data = LARGE_STRIDES_ROW_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the last row matching a search vector (column-major, large strides, accessors)', function test( t ) { + var data; + var out; + + data = LARGE_STRIDES_COLUMN_MAJOR_DATA; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (row-major, large strides, accessors)', function test( t ) { + var data; + var out; + + data = LARGE_STRIDES_ROW_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a search vector (column-major, large strides, accessors)', function test( t ) { + var data; + var out; + + data = LARGE_STRIDES_COLUMN_MAJOR_NO_MATCH; + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); From 5933ce5044c6a00374a621d3c5212c546b42b409 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 7 May 2026 00:58:50 +0500 Subject: [PATCH 6/6] refactor: add workspace --- .../ext/base/glast-index-of-row/README.md | 64 ++- .../glast-index-of-row/benchmark/benchmark.js | 3 +- .../benchmark/benchmark.ndarray.js | 3 +- .../ext/base/glast-index-of-row/docs/repl.txt | 37 +- .../glast-index-of-row/docs/types/index.d.ts | 31 +- .../glast-index-of-row/docs/types/test.ts | 385 +++++++++++------- .../base/glast-index-of-row/examples/index.js | 4 +- .../base/glast-index-of-row/lib/accessors.js | 42 +- .../ext/base/glast-index-of-row/lib/index.js | 6 +- .../ext/base/glast-index-of-row/lib/main.js | 10 +- .../base/glast-index-of-row/lib/ndarray.js | 44 +- .../base/glast-index-of-row/test/test.main.js | 31 +- .../glast-index-of-row/test/test.ndarray.js | 93 ++--- 13 files changed, 494 insertions(+), 259 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md index 72954b81d530..14809e953f54 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/README.md @@ -36,7 +36,7 @@ limitations under the License. var glastIndexOfRow = require( '@stdlib/blas/ext/base/glast-index-of-row' ); ``` -#### glastIndexOfRow( order, M, N, A, LDA, x, strideX ) +#### glastIndexOfRow( order, M, N, A, LDA, x, strideX, workspace, strideW ) Returns the index of the last row in an input matrix which has the same elements as a provided search vector. @@ -51,7 +51,8 @@ Returns the index of the last row in an input matrix which has the same elements var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; var x = [ 3.0, 4.0 ]; -var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1 ); +var workspace = [ 0, 0, 0 ]; +var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1, workspace, 1 ); // returns 2 ``` @@ -64,6 +65,26 @@ The function has the following parameters: - **LDA**: stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: search vector. - **strideX**: stride length for `x`. +- **workspace**: workspace array for tracking row match candidates. This parameter is ignored if the input matrix is stored in row-major order. +- **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. + +```javascript +/* + A = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 3.0, 4.0 ] + ] +*/ +var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; + +var x = [ 3.0, 4.0 ]; +var workspace = []; +var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1, workspace, 1 ); +// returns 2 +``` If the function is unable to find a matching row, the function returns `-1`. @@ -71,7 +92,8 @@ If the function is unable to find a matching row, the function returns `-1`. var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; var x = [ -3.0, -4.0 ]; -var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1 ); +var workspace = [ 0, 0, 0 ]; +var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1, workspace, 1 ); // returns -1 ``` @@ -90,13 +112,14 @@ var x0 = new Float64Array( [ 9999.0, 3.0, 4.0 ] ); var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var out = glastIndexOfRow( 'row-major', 3, 2, A1, 2, x1, 1 ); +var workspace = [ 0, 0, 0 ]; +var out = glastIndexOfRow( 'row-major', 3, 2, A1, 2, x1, 1, workspace, 1 ); // returns 1 ``` -#### glastIndexOfRow.ndarray( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) +#### glastIndexOfRow.ndarray( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX, workspace, strideW, offsetW ) @@ -113,7 +136,8 @@ Returns the index of the last row in an input matrix which has the same elements var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; var x = [ 3.0, 4.0 ]; -var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0 ); +var workspace = [ 0, 0, 0 ]; +var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0, workspace, 1, 0 ); // returns 2 ``` @@ -128,6 +152,27 @@ The function has the following parameters: - **x**: search vector. - **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. +- **workspace**: workspace array for tracking row match candidates. This parameter is ignored if the input matrix is stored in row-major order. +- **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. + +```javascript +/* + A = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 3.0, 4.0 ] + ] +*/ +var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; + +var x = [ 3.0, 4.0 ]; +var workspace = []; +var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0, workspace, 1, 0 ); +// returns 2 +``` While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, @@ -142,7 +187,8 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the var A = [ 9999.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ]; var x = [ 9999.0, 3.0, 4.0 ]; -var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 1, x, 1, 1 ); +var workspace = [ 0, 0, 0 ]; +var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 1, x, 1, 1, workspace, 1, 0 ); // returns 1 ``` @@ -185,7 +231,9 @@ console.log( ndarray2array( A, shape, strides, 0, order ) ); var x = [ 4.0, 5.0, 6.0 ]; console.log( x ); -var out = glastIndexOfRow( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ], x, 1 ); +var workspace = [ 0, 0, 0 ]; + +var out = glastIndexOfRow( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ], x, 1, workspace, 1 ); console.log( out ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.js index abe3fc6e58c8..ae7b269dc76f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.js @@ -49,6 +49,7 @@ var LAYOUTS = [ * @returns {Function} benchmark function */ function createBenchmark( order, N ) { + var workspace = zeros( N, 'generic' ); var A = zeros( N*N, 'generic' ); var x = zeros( N, 'generic' ); return benchmark; @@ -66,7 +67,7 @@ function createBenchmark( order, N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { x[ N-1 ] += 1; - z = glastIndexOfRow( order, N, N, A, N, x, 1 ); + z = glastIndexOfRow( order, N, N, A, N, x, 1, workspace, 1 ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.ndarray.js index 1d72d569a54e..d6c02dcdcb73 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/benchmark/benchmark.ndarray.js @@ -50,6 +50,7 @@ var LAYOUTS = [ * @returns {Function} benchmark function */ function createBenchmark( order, N ) { + var workspace = zeros( N, 'generic' ); var A = zeros( N*N, 'generic' ); var x = zeros( N, 'generic' ); return benchmark; @@ -77,7 +78,7 @@ function createBenchmark( order, N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { x[ N-1 ] += 1; - z = glastIndexOfRow( N, N, A, sa1, sa2, 0, x, 1, 0 ); + z = glastIndexOfRow( N, N, A, sa1, sa2, 0, x, 1, 0, workspace, 1, 0 ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/repl.txt index 6a73a1ecebdf..9768fd6259da 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( order, M, N, A, LDA, x, strideX ) +{{alias}}( order, M, N, A, LDA, x, strideX, workspace, strideW ) Returns the index of the last row in an input matrix which has the same elements as a provided search vector. @@ -34,6 +34,13 @@ strideX: integer Stride length for `x`. + workspace: Array|TypedArray + Workspace array for tracking row match candidates. This parameter is + ignored if the input matrix is stored in row-major order. + + strideW: integer + Stride length for `workspace`. + Returns ------- out: integer @@ -43,11 +50,12 @@ -------- > var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; > var x = [ 3.0, 4.0 ]; - > {{alias}}( 'row-major', 3, 2, A, 2, x, 1 ) + > var w = [ 0, 0, 0 ]; + > {{alias}}( 'row-major', 3, 2, A, 2, x, 1, w, 1 ) 2 -{{alias}}.ndarray( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) +{{alias}}.ndarray( M, N, A, sa1, sa2, oa, x, sx, ox, w, sw, ow ) Returns the index of the last row in an input matrix which has the same elements as a provided search vector using alternative indexing semantics. @@ -69,24 +77,34 @@ A: Array|TypedArray Input matrix `A`. - strideA1: integer + sa1: integer Stride length for the first dimension of `A`. - strideA2: integer + sa2: integer Stride length for the second dimension of `A`. - offsetA: integer + oa: integer Starting index for `A`. x: Array|TypedArray Search vector. - strideX: integer + sx: integer Stride length for `x`. - offsetX: integer + ox: integer Starting index for `x`. + w: Array|TypedArray + Workspace array for tracking row match candidates. This parameter is + ignored if the input matrix is stored in row-major order. + + sw: integer + Stride length for `w`. + + ow: integer + Starting index for `w`. + Returns ------- out: integer @@ -96,7 +114,8 @@ -------- > var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; > var x = [ 3.0, 4.0 ]; - > {{alias}}.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0 ) + > var w = [ 0, 0, 0 ]; + > {{alias}}.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0 ) 2 See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/index.d.ts index 4478d70ff0da..0eabf23cdd33 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/index.d.ts @@ -28,6 +28,11 @@ import { Layout } from '@stdlib/types/blas'; */ type InputArray = Collection | AccessorArrayLike; +/** +* Workspace array. +*/ +type WorkspaceArray = Collection | AccessorArrayLike; + /** * Interface describing `glastIndexOfRow`. */ @@ -38,6 +43,7 @@ interface Routine { * ## Notes * * - If the function is provided an empty matrix or if the function is unable to find a search vector, the function returns `-1` (i.e., an invalid index). + * - The `workspace` array is only applicable when an input matrix is stored in column-major order. When the matrix is stored in row-major order, the workspace array is ignored. * * @param order - storage layout * @param M - number of rows in `A` @@ -46,16 +52,19 @@ interface Routine { * @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` * @returns row index * * @example * var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] * var x = [ 3.0, 4.0 ]; + * var workspace = [ 0, 0, 0 ]; * - * var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1 ); + * var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1, workspace, 1 ); * // returns 2 */ - ( order: Layout, M: number, N: number, A: InputArray, LDA: number, x: InputArray, strideX: number ): number; + ( order: Layout, M: number, N: number, A: InputArray, LDA: number, x: InputArray, strideX: number, workspace: WorkspaceArray, strideW: number ): number; /** * Returns the index of the last row in an input matrix which has the same elements as a provided search vector using alternative indexing semantics. @@ -63,6 +72,7 @@ interface Routine { * ## Notes * * - If the function is provided an empty matrix or if the function is unable to find a search vector, the function returns `-1` (i.e., an invalid index). + * - The `workspace` array is only applicable when an input matrix is stored in column-major order. When the matrix is stored in row-major order, the workspace array is ignored. * * @param M - number of rows in `A` * @param N - number of columns in `A` @@ -73,16 +83,20 @@ interface Routine { * @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` * @returns row index * * @example * var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] * var x = [ 3.0, 4.0 ]; + * var workspace = [ 0, 0, 0 ]; * - * var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0 ); + * var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0, workspace, 1, 0 ); * // returns 2 */ - ndarray( M: number, N: number, A: InputArray, strideA1: number, strideA2: number, offsetA: number, x: InputArray, strideX: number, offsetX: number ): number; + ndarray( M: number, N: number, A: InputArray, strideA1: number, strideA2: number, offsetA: number, x: InputArray, strideX: number, offsetX: number, workspace: WorkspaceArray, strideW: number, offsetW: number ): number; } /** @@ -91,6 +105,7 @@ interface Routine { * ## Notes * * - If the function is provided an empty matrix or if the function is unable to find a search vector, the function returns `-1` (i.e., an invalid index). +* - The `workspace` array is only applicable when an input matrix is stored in column-major order. When the matrix is stored in row-major order, the workspace array is ignored. * * @param order - storage layout * @param M - number of rows in `A` @@ -99,20 +114,24 @@ interface Routine { * @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` * @returns row index * * @example * var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] * var x = [ 3.0, 4.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1 ); +* var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1, workspace, 1 ); * // returns 2 * * @example * var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] * var x = [ 3.0, 4.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0 ); +* var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0, workspace, 1, 0 ); * // returns 2 */ declare var glastIndexOfRow: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/test.ts index dfa95f307e73..5c64af356d73 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/docs/types/test.ts @@ -25,115 +25,154 @@ import glastIndexOfRow = require( './index' ); { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; + const w = [ 0, 0 ]; - glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1 ); // $ExpectType number + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, 1 ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a string... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; - - glastIndexOfRow( 5, 2, 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( true, 2, 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( false, 2, 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( null, 2, 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( void 0, 2, 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( [], 2, 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( {}, 2, 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( ( x: number ): number => x, 2, 2, A, 2, x, 1 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow( 5, 2, 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( true, 2, 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( false, 2, 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( null, 2, 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( void 0, 2, 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( [], 2, 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( {}, 2, 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( ( x: number ): number => x, 2, 2, A, 2, x, 1, w, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; - - glastIndexOfRow( 'row-major', '5', 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', true, 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', false, 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', null, 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', void 0, 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', [], 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', {}, 2, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', ( x: number ): number => x, 2, A, 2, x, 1 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow( 'row-major', '5', 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', true, 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', false, 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', null, 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', void 0, 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', [], 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', {}, 2, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', ( x: number ): number => x, 2, A, 2, x, 1, w, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; - - glastIndexOfRow( 'row-major', 2, '5', A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, true, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, false, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, null, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, void 0, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, [], A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, {}, A, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, ( x: number ): number => x, A, 2, x, 1 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow( 'row-major', 2, '5', A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, true, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, false, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, null, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, void 0, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, [], A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, {}, A, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, ( x: number ): number => x, A, 2, x, 1, w, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a collection... { const x = [ 3.0, 4.0 ]; - - glastIndexOfRow( 'row-major', 2, 2, 5, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, true, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, false, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, null, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, void 0, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, {}, 2, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, ( x: number ): number => x, 2, x, 1 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow( 'row-major', 2, 2, 5, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, true, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, false, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, null, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, void 0, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, {}, 2, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, ( x: number ): number => x, 2, x, 1, w, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; - - glastIndexOfRow( 'row-major', 2, 2, A, '5', x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, true, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, false, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, null, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, void 0, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, [], x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, {}, x, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, ( x: number ): number => x, x, 1 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow( 'row-major', 2, 2, A, '5', x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, true, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, false, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, null, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, void 0, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, [], x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, {}, x, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, ( x: number ): number => x, x, 1, w, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a sixth argument which is not a collection... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; - - glastIndexOfRow( 'row-major', 2, 2, A, 2, 5, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, true, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, false, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, null, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, void 0, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, {}, 1 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, ( x: number ): number => x, 1 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow( 'row-major', 2, 2, A, 2, 5, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, true, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, false, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, null, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, void 0, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, {}, 1, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, ( x: number ): number => x, 1, w, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a seventh argument which is not a number... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; + const w = [ 0, 0 ]; + + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, '5', w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, true, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, false, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, null, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, void 0, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, [], w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, {}, w, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, ( x: number ): number => x, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a collection... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, 5, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, true, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, false, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, null, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, void 0, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, {}, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, ( x: number ): number => x, 1 ); // $ExpectError +} - glastIndexOfRow( 'row-major', 2, 2, A, 2, x, '5' ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, x, true ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, x, false ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, x, null ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, x, void 0 ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, x, [] ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, x, {} ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, x, ( x: number ): number => x ); // $ExpectError +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + const w = [ 0, 0 ]; + + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, '5' ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, true ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, false ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, null ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, void 0 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, [] ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, {} ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; + const w = [ 0, 0 ]; glastIndexOfRow(); // $ExpectError glastIndexOfRow( 'row-major' ); // $ExpectError @@ -142,152 +181,211 @@ import glastIndexOfRow = require( './index' ); glastIndexOfRow( 'row-major', 2, 2, A ); // $ExpectError glastIndexOfRow( 'row-major', 2, 2, A, 2 ); // $ExpectError glastIndexOfRow( 'row-major', 2, 2, A, 2, x ); // $ExpectError - glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, 0 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1 ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w ); // $ExpectError + glastIndexOfRow( 'row-major', 2, 2, A, 2, x, 1, w, 1, 0 ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; + const w = [ 0, 0 ]; - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectType number + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; - - glastIndexOfRow.ndarray( '5', 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( true, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( false, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( null, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( void 0, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( [], 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( {}, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( ( x: number ): number => x, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow.ndarray( '5', 2, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( true, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( false, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( null, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( void 0, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( [], 2, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( {}, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( ( x: number ): number => x, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; - - glastIndexOfRow.ndarray( 2, '5', A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, true, A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, false, A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, null, A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, void 0, A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, [], A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, {}, A, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, ( x: number ): number => x, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow.ndarray( 2, '5', A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, true, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, false, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, null, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, void 0, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, [], A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, {}, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, ( x: number ): number => x, A, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a collection... { const x = [ 3.0, 4.0 ]; - - glastIndexOfRow.ndarray( 2, 2, 5, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, true, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, false, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, null, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, void 0, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, {}, 2, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, ( x: number ): number => x, 2, 1, 0, x, 1, 0 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow.ndarray( 2, 2, 5, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, true, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, false, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, null, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, void 0, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, {}, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, ( x: number ): number => x, 2, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; - - glastIndexOfRow.ndarray( 2, 2, A, '5', 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, true, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, false, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, null, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, void 0, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, [], 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, {}, 1, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, ( x: number ): number => x, 1, 0, x, 1, 0 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, '5', 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, true, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, false, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, null, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, void 0, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, [], 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, {}, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, ( x: number ): number => x, 1, 0, x, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; - - glastIndexOfRow.ndarray( 2, 2, A, 2, '5', 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, true, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, false, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, null, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, void 0, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, [], 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, {}, 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, ( x: number ): number => x, 0, x, 1, 0 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, '5', 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, true, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, false, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, null, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, void 0, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, [], 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, {}, 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, ( x: number ): number => x, 0, x, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a sixth argument which is not a number... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; - - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, '5', x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, true, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, false, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, null, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, void 0, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, [], x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, {}, x, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, ( x: number ): number => x, x, 1, 0 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, '5', x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, true, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, false, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, null, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, void 0, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, [], x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, {}, x, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, ( x: number ): number => x, x, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a seventh argument which is not a collection... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; - - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, 5, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, true, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, false, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, null, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, void 0, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, {}, 1, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, 5, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, true, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, false, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, null, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, void 0, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, {}, 1, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, ( x: number ): number => x, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided an eighth argument which is not a number... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; - - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, '5', 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, true, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, false, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, null, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, void 0, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, [], 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, {}, 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, ( x: number ): number => x, 0 ); // $ExpectError + const w = [ 0, 0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, '5', 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, true, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, false, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, null, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, void 0, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, [], 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, {}, 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, ( x: number ): number => x, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + const w = [ 0, 0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, '5', w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, true, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, false, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, null, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, void 0, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, [], w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, {}, w, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, ( x: number ): number => x, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a collection... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, '5' ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, true ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, false ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, null ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, void 0 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, [] ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, {} ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, ( x: number ): number => x ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, 5, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, true, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, false, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, null, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, void 0, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, {}, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + const w = [ 0, 0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, '5', 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, true, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, false, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, null, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, void 0, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, [], 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, {}, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + const x = [ 3.0, 4.0 ]; + const w = [ 0, 0 ]; + + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, '5' ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, true ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, false ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, null ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, void 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, [] ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, {} ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... { const A = [ 1.0, 2.0, 3.0, 4.0 ]; const x = [ 3.0, 4.0 ]; + const w = [ 0, 0 ]; glastIndexOfRow.ndarray(); // $ExpectError glastIndexOfRow.ndarray( 2 ); // $ExpectError @@ -298,5 +396,8 @@ import glastIndexOfRow = require( './index' ); glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0 ); // $ExpectError glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x ); // $ExpectError glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1 ); // $ExpectError - glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1 ); // $ExpectError + glastIndexOfRow.ndarray( 2, 2, A, 2, 1, 0, x, 1, 0, w, 1, 0, 0 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/examples/index.js index 5f613e0b741f..9ee1cae0bf93 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/examples/index.js @@ -32,5 +32,7 @@ console.log( ndarray2array( A, shape, strides, 0, order ) ); var x = [ 4.0, 5.0, 6.0 ]; console.log( x ); -var out = glastIndexOfRow( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ], x, 1 ); +var workspace = [ 0, 0, 0 ]; + +var out = glastIndexOfRow( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ], x, 1, workspace, 1 ); // eslint-disable-line max-len console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/accessors.js index 6de912787b47..97ec82640503 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/accessors.js @@ -16,12 +16,13 @@ * limitations under the License. */ +/* eslint-disable max-params */ + 'use strict'; // MODULES // var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); -var ones = require( '@stdlib/array/base/ones' ); // MAIN // @@ -32,6 +33,7 @@ var ones = require( '@stdlib/array/base/ones' ); * ## Notes * * - If the function is unable to find a search vector, the function returns `-1` (i.e., an invalid index). +* - The `workspace` array is only applicable when an input matrix is stored in column-major order. When the matrix is stored in row-major order, the workspace array is ignored. * * @private * @param {PositiveInteger} M - number of rows in `A` @@ -47,6 +49,9 @@ var ones = require( '@stdlib/array/base/ones' ); * @param {Array} x.accessors - search vector element accessors * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Collection} workspace - workspace array for tracking row match candidates +* @param {integer} strideW - stride length for `workspace` +* @param {NonNegativeInteger} offsetW - starting index for `workspace` * @returns {integer} row index * * @example @@ -55,8 +60,9 @@ var ones = require( '@stdlib/array/base/ones' ); * * var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] * var x = [ 3.0, 4.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 2, 1, 0, arraylike2object( toAccessorArray( x ) ), 1, 0 ); +* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 2, 1, 0, arraylike2object( toAccessorArray( x ) ), 1, 0, workspace, 1, 0 ); * // returns 2 * * @example @@ -65,8 +71,9 @@ var ones = require( '@stdlib/array/base/ones' ); * * var A = [ 1.0, 3.0, 3.0, 2.0, 4.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] * var x = [ 3.0, 4.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 1, 3, 0, arraylike2object( toAccessorArray( x ) ), 1, 0 ); +* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 1, 3, 0, arraylike2object( toAccessorArray( x ) ), 1, 0, workspace, 1, 0 ); * // returns 2 * * @example @@ -75,8 +82,9 @@ var ones = require( '@stdlib/array/base/ones' ); * * var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = [ 1.0, 2.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 1, 3, 0, arraylike2object( toAccessorArray( x ) ), 1, 0 ); +* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 1, 3, 0, arraylike2object( toAccessorArray( x ) ), 1, 0, workspace, 1, 0 ); * // returns 0 * * @example @@ -85,8 +93,9 @@ var ones = require( '@stdlib/array/base/ones' ); * * var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = [ 0.0, 0.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 1, 3, 0, arraylike2object( toAccessorArray( x ) ), 1, 0 ); +* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 1, 3, 0, arraylike2object( toAccessorArray( x ) ), 1, 0, workspace, 1, 0 ); * // returns 2 * * @example @@ -95,12 +104,12 @@ var ones = require( '@stdlib/array/base/ones' ); * * var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = [ -3.0, -4.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 1, 3, 0, arraylike2object( toAccessorArray( x ) ), 1, 0 ); +* var out = glastIndexOfRow( 3, 2, arraylike2object( toAccessorArray( A ) ), 1, 3, 0, arraylike2object( toAccessorArray( x ) ), 1, 0, workspace, 1, 0 ); * // returns -1 */ -function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-len - var matches; +function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX, workspace, strideW, offsetW ) { // eslint-disable-line max-len var abuf; var xbuf; var aget; @@ -110,6 +119,7 @@ function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offs var S0; var S1; var ia; + var iw; var ix; var i0; var i1; @@ -155,29 +165,37 @@ function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offs da0 = -strideA1; da1 = ( S0*strideA1 ) - strideA2; - // Create an array for tracking which rows contain matching elements: - matches = ones( M ); + // Initialize the workspace array for tracking which rows contain matching elements: + iw = offsetW; + for ( i0 = 0; i0 < S0; i0++ ) { + workspace[ iw ] = 1; + iw += strideW; + } // Finding the last matching row when a matrix is stored in column-major order requires effectively performing a full linear scan. In order to ensure cache-efficient traversal, scan up each column (otherwise, if we went row-by-row, we'd hop around linear memory, resulting in poor cache behavior)... ia = offsetA + ( (S0-1)*strideA1 ) + ( (S1-1)*strideA2 ); ix = offsetX + ( (S1-1)*strideX ); for ( i1 = S1-1; i1 >= 0; i1-- ) { // Scan up the rows in a column looking for a matching element... + iw = offsetW + ( (S0-1)*strideW ); for ( i0 = S0-1; i0 >= 0; i0-- ) { if ( aget( abuf, ia ) !== xget( xbuf, ix ) ) { // We found a non-matching element, which means we can exclude this row from the list of row candidates... - matches[ i0 ] = 0; + workspace[ iw ] = 0; } ia += da0; + iw -= strideW; } ia += da1; ix -= strideX; } // Search for the last matching row... + iw = offsetW + ( (S0-1)*strideW ); for ( i0 = S0-1; i0 >= 0; i0-- ) { - if ( matches[ i0 ] === 1 ) { + if ( workspace[ iw ] === 1 ) { break; } + iw -= strideW; } return i0; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/index.js index 41ddb26eb93a..028ec05b3e35 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/index.js @@ -28,8 +28,9 @@ * * var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] * var x = [ 3.0, 4.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1 ); +* var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1, workspace, 1 ); * // returns 2 * * @example @@ -37,8 +38,9 @@ * * var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] * var x = [ 3.0, 4.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0 ); +* var out = glastIndexOfRow.ndarray( 3, 2, A, 2, 1, 0, x, 1, 0, workspace, 1, 0 ); * // returns 2 */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js index b833de211e18..c01570bba41a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/main.js @@ -37,6 +37,7 @@ var ndarray = require( './ndarray.js' ); * ## Notes * * - If the function is provided an empty matrix or if the function is unable to find a search vector, the function returns `-1` (i.e., an invalid index). +* - The `workspace` array is only applicable when an input matrix is stored in column-major order. When the matrix is stored in row-major order, the workspace array is ignored. * * @param {string} order - storage layout * @param {PositiveInteger} M - number of rows in `A` @@ -45,6 +46,8 @@ var ndarray = require( './ndarray.js' ); * @param {integer} LDA - stride length for the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Collection} x - search vector * @param {integer} strideX - stride length for `x` +* @param {Collection} workspace - workspace array for tracking row match candidates +* @param {integer} strideW - stride length for `workspace` * @throws {TypeError} first argument must be a valid order * @throws {RangeError} fifth argument must be a valid stride * @returns {integer} row index @@ -52,11 +55,12 @@ var ndarray = require( './ndarray.js' ); * @example * var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] * var x = [ 3.0, 4.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1 ); +* var out = glastIndexOfRow( 'row-major', 3, 2, A, 2, x, 1, workspace, 1 ); * // returns 2 */ -function glastIndexOfRow( order, M, N, A, LDA, x, strideX ) { +function glastIndexOfRow( order, M, N, A, LDA, x, strideX, workspace, strideW ) { // eslint-disable-line max-len var sa1; var sa2; var s; @@ -78,7 +82,7 @@ function glastIndexOfRow( order, M, N, A, LDA, x, strideX ) { sa1 = LDA; sa2 = 1; } - return ndarray( M, N, A, sa1, sa2, 0, x, strideX, stride2offset( N, strideX ) ); // eslint-disable-line max-len + return ndarray( M, N, A, sa1, sa2, 0, x, strideX, stride2offset( N, strideX ), workspace, strideW, stride2offset( M, strideW ) ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js index 7ebf12af1ea6..ebe639e4e390 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/lib/ndarray.js @@ -16,13 +16,14 @@ * limitations under the License. */ +/* eslint-disable max-params, max-len */ + 'use strict'; // MODULES // var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -var ones = require( '@stdlib/array/base/ones' ); var accessors = require( './accessors.js' ); @@ -34,6 +35,7 @@ var accessors = require( './accessors.js' ); * ## Notes * * - If the function is provided an empty matrix or if the function is unable to find a search vector, the function returns `-1` (i.e., an invalid index). +* - The `workspace` array is only applicable when an input matrix is stored in column-major order. When the matrix is stored in row-major order, the workspace array is ignored. * * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` @@ -44,50 +46,58 @@ var accessors = require( './accessors.js' ); * @param {Collection} x - search vector * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Collection} workspace - workspace array for tracking row match candidates +* @param {integer} strideW - stride length for `workspace` +* @param {NonNegativeInteger} offsetW - starting index for `workspace` * @returns {integer} row index * * @example * var A = [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] * var x = [ 3.0, 4.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 3, 2, A, 2, 1, 0, x, 1, 0 ); +* var out = glastIndexOfRow( 3, 2, A, 2, 1, 0, x, 1, 0, workspace, 1, 0 ); * // returns 2 * * @example * var A = [ 1.0, 3.0, 3.0, 2.0, 4.0, 4.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 3.0, 4.0 ] ] * var x = [ 3.0, 4.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); +* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0, workspace, 1, 0 ); * // returns 2 * * @example * var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = [ 1.0, 2.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); +* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0, workspace, 1, 0 ); * // returns 0 * * @example * var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = [ 0.0, 0.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); +* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0, workspace, 1, 0 ); * // returns 2 * * @example * var A = [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ]; // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * var x = [ -3.0, -4.0 ]; +* var workspace = [ 0, 0, 0 ]; * -* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0 ); +* var out = glastIndexOfRow( 3, 2, A, 1, 3, 0, x, 1, 0, workspace, 1, 0 ); * // returns -1 */ -function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-len - var matches; +function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX, workspace, strideW, offsetW ) { var da0; var da1; var S0; var S1; var ia; + var iw; var ix; var i0; var i1; @@ -101,7 +111,7 @@ function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offs oa = arraylike2object( A ); ox = arraylike2object( x ); if ( oa.accessorProtocol || ox.accessorProtocol ) { - return accessors( M, N, oa, strideA1, strideA2, offsetA, ox, strideX, offsetX ); // eslint-disable-line max-len + return accessors( M, N, oa, strideA1, strideA2, offsetA, ox, strideX, offsetX, workspace, strideW, offsetW ); } // Search for the last row matching the search vector... if ( isRowMajor( [ strideA1, strideA2 ] ) ) { @@ -136,29 +146,37 @@ function glastIndexOfRow( M, N, A, strideA1, strideA2, offsetA, x, strideX, offs da0 = -strideA1; da1 = ( S0*strideA1 ) - strideA2; - // Create an array for tracking which rows contain matching elements: - matches = ones( M ); + // Initialize the workspace array for tracking which rows contain matching elements: + iw = offsetW; + for ( i0 = 0; i0 < S0; i0++ ) { + workspace[ iw ] = 1; + iw += strideW; + } // Finding the last matching row when a matrix is stored in column-major order requires effectively performing a full linear scan. In order to ensure cache-efficient traversal, scan up each column (otherwise, if we went row-by-row, we'd hop around linear memory, resulting in poor cache behavior)... ia = offsetA + ( (S0-1)*strideA1 ) + ( (S1-1)*strideA2 ); ix = offsetX + ( (S1-1)*strideX ); for ( i1 = S1-1; i1 >= 0; i1-- ) { // Scan up the rows in a column looking for a matching element... + iw = offsetW + ( (S0-1)*strideW ); for ( i0 = S0-1; i0 >= 0; i0-- ) { if ( A[ ia ] !== x[ ix ] ) { // We found a non-matching element, which means we can exclude this row from the list of row candidates... - matches[ i0 ] = 0; + workspace[ iw ] = 0; } ia += da0; + iw -= strideW; } ia += da1; ix -= strideX; } // Search for the last matching row... + iw = offsetW + ( (S0-1)*strideW ); for ( i0 = S0-1; i0 >= 0; i0-- ) { - if ( matches[ i0 ] === 1 ) { + if ( workspace[ iw ] === 1 ) { break; } + iw -= strideW; } return i0; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.main.js index 1c3d7f54ee20..aa639036a612 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.main.js @@ -24,6 +24,7 @@ var tape = require( 'tape' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var zeros = require( '@stdlib/array/base/zeros' ); var glastIndexOfRow = require( './../lib' ); @@ -43,8 +44,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 7', function test( t ) { - t.strictEqual( glastIndexOfRow.length, 7, 'returns expected value' ); +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( glastIndexOfRow.length, 9, 'returns expected value' ); t.end(); }); @@ -78,7 +79,7 @@ tape( 'the function throws an error if provided a first argument which is not a function badValue( value ) { return function badValue() { - glastIndexOfRow( value, data.M, data.N, data.A, data.LDA, data.x, data.strideX ); + glastIndexOfRow( value, data.M, data.N, data.A, data.LDA, data.x, data.strideX, zeros( data.M ), 1 ); }; } }); @@ -102,7 +103,7 @@ tape( 'the function throws an error if provided a fifth argument which is not a function badValue( value ) { return function badValue() { - glastIndexOfRow( data.order, data.M, data.N, data.A, value, data.x, data.strideX ); + glastIndexOfRow( data.order, data.M, data.N, data.A, value, data.x, data.strideX, zeros( data.M ), 1 ); }; } }); @@ -126,7 +127,7 @@ tape( 'the function throws an error if provided a fifth argument which is not a function badValue( value ) { return function badValue() { - glastIndexOfRow( data.order, data.M, data.N, data.A, value, data.x, data.strideX ); + glastIndexOfRow( data.order, data.M, data.N, data.A, value, data.x, data.strideX, zeros( data.M ), 1 ); }; } }); @@ -136,7 +137,7 @@ tape( 'the function returns an invalid index when M is less than or equal to zer var out; data = ROW_MAJOR_DATA; - out = glastIndexOfRow( data.order, 0, data.N, data.A, data.LDA, data.x, data.strideX ); + out = glastIndexOfRow( data.order, 0, data.N, data.A, data.LDA, data.x, data.strideX, zeros( data.M ), 1 ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); @@ -147,7 +148,7 @@ tape( 'the function returns an invalid index when N is less than or equal to zer var out; data = ROW_MAJOR_DATA; - out = glastIndexOfRow( data.order, data.M, 0, data.A, data.LDA, data.x, data.strideX ); + out = glastIndexOfRow( data.order, data.M, 0, data.A, data.LDA, data.x, data.strideX, zeros( data.M ), 1 ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); @@ -158,7 +159,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = ROW_MAJOR_DATA; - out = glastIndexOfRow( data.order, data.M, data.N, data.A, data.LDA, data.x, data.strideX ); + out = glastIndexOfRow( data.order, data.M, data.N, data.A, data.LDA, data.x, data.strideX, zeros( data.M ), 1 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -169,7 +170,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.order, data.M, data.N, data.A, data.LDA, data.x, data.strideX ); + out = glastIndexOfRow( data.order, data.M, data.N, data.A, data.LDA, data.x, data.strideX, zeros( data.M ), 1 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -180,7 +181,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = ROW_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.order, data.M, data.N, data.A, data.LDA, data.x, data.strideX ); + out = glastIndexOfRow( data.order, data.M, data.N, data.A, data.LDA, data.x, data.strideX, zeros( data.M ), 1 ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); @@ -191,7 +192,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = COLUMN_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.order, data.M, data.N, data.A, data.LDA, data.x, data.strideX ); + out = glastIndexOfRow( data.order, data.M, data.N, data.A, data.LDA, data.x, data.strideX, zeros( data.M ), 1 ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); @@ -202,7 +203,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = ROW_MAJOR_DATA; - out = glastIndexOfRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA, toAccessorArray( data.x ), data.strideX ); + out = glastIndexOfRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA, toAccessorArray( data.x ), data.strideX, zeros( data.M ), 1 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -213,7 +214,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA, toAccessorArray( data.x ), data.strideX ); + out = glastIndexOfRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA, toAccessorArray( data.x ), data.strideX, zeros( data.M ), 1 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -224,7 +225,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = ROW_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA, toAccessorArray( data.x ), data.strideX ); + out = glastIndexOfRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA, toAccessorArray( data.x ), data.strideX, zeros( data.M ), 1 ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); @@ -235,7 +236,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = COLUMN_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA, toAccessorArray( data.x ), data.strideX ); + out = glastIndexOfRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA, toAccessorArray( data.x ), data.strideX, zeros( data.M ), 1 ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.ndarray.js index 6143c7af6e2d..374a5fc1c67b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/glast-index-of-row/test/test.ndarray.js @@ -24,6 +24,7 @@ var tape = require( 'tape' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var zeros = require( '@stdlib/array/base/zeros' ); var glastIndexOfRow = require( './../lib/ndarray.js' ); @@ -59,8 +60,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 9', function test( t ) { - t.strictEqual( glastIndexOfRow.length, 9, 'returns expected value' ); +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( glastIndexOfRow.length, 12, 'returns expected value' ); t.end(); }); @@ -69,7 +70,7 @@ tape( 'the function returns an invalid index when M is less than or equal to zer var out; data = ROW_MAJOR_DATA; - out = glastIndexOfRow( 0, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( 0, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); @@ -80,7 +81,7 @@ tape( 'the function returns an invalid index when N is less than or equal to zer var out; data = ROW_MAJOR_DATA; - out = glastIndexOfRow( data.M, 0, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, 0, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); @@ -91,7 +92,7 @@ tape( 'the function returns an invalid index when M is less than or equal to zer var out; data = COLUMN_MAJOR_DATA; - out = glastIndexOfRow( 0, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( 0, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); @@ -102,7 +103,7 @@ tape( 'the function returns an invalid index when N is less than or equal to zer var out; data = COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.M, 0, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, 0, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); @@ -113,7 +114,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = ROW_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -124,7 +125,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -135,7 +136,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = ROW_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -146,7 +147,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = COLUMN_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -157,7 +158,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = OFFSET_ROW_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -168,7 +169,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = OFFSET_COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -179,7 +180,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = OFFSET_ROW_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -190,7 +191,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = OFFSET_COLUMN_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -201,7 +202,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = MIXED_STRIDES_ROW_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -212,7 +213,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = MIXED_STRIDES_COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -223,7 +224,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = MIXED_STRIDES_ROW_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -234,7 +235,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = MIXED_STRIDES_COLUMN_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -245,7 +246,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = NEGATIVE_STRIDES_ROW_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -256,7 +257,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = NEGATIVE_STRIDES_COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -267,7 +268,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = NEGATIVE_STRIDES_ROW_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -278,7 +279,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = NEGATIVE_STRIDES_COLUMN_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -289,7 +290,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = LARGE_STRIDES_ROW_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -300,7 +301,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = LARGE_STRIDES_COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -311,7 +312,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = LARGE_STRIDES_ROW_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -322,7 +323,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = LARGE_STRIDES_COLUMN_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA, data.x, data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -333,7 +334,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = ROW_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -344,7 +345,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -355,7 +356,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = ROW_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -366,7 +367,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = COLUMN_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -377,7 +378,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = OFFSET_ROW_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -388,7 +389,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = OFFSET_COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -399,7 +400,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = OFFSET_ROW_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -410,7 +411,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = OFFSET_COLUMN_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -421,7 +422,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = MIXED_STRIDES_ROW_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -432,7 +433,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = MIXED_STRIDES_COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -443,7 +444,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = MIXED_STRIDES_ROW_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -454,7 +455,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = MIXED_STRIDES_COLUMN_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -465,7 +466,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = NEGATIVE_STRIDES_ROW_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -476,7 +477,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = NEGATIVE_STRIDES_COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -487,7 +488,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = NEGATIVE_STRIDES_ROW_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -498,7 +499,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = NEGATIVE_STRIDES_COLUMN_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -509,7 +510,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = LARGE_STRIDES_ROW_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -520,7 +521,7 @@ tape( 'the function returns the index of the last row matching a search vector ( var out; data = LARGE_STRIDES_COLUMN_MAJOR_DATA; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -531,7 +532,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = LARGE_STRIDES_ROW_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); @@ -542,7 +543,7 @@ tape( 'the function returns an invalid index if unable to find a search vector ( var out; data = LARGE_STRIDES_COLUMN_MAJOR_NO_MATCH; - out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX ); + out = glastIndexOfRow( data.M, data.N, toAccessorArray( data.A ), data.strideA1, data.strideA2, data.offsetA, toAccessorArray( data.x ), data.strideX, data.offsetX, zeros( data.M ), 1, 0 ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end();