From 27e666241209ba8d850b5acd70803bba6617f2ca Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 1 Jul 2026 02:40:12 +0500 Subject: [PATCH 1/2] feat: add blas/ext/base/gindex-of-truthy-row --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../ext/base/gindex-of-truthy-row/README.md | 198 +++++++++ .../benchmark/benchmark.js | 111 +++++ .../benchmark/benchmark.ndarray.js | 122 ++++++ .../base/gindex-of-truthy-row/docs/repl.txt | 87 ++++ .../docs/types/index.d.ts | 112 +++++ .../gindex-of-truthy-row/docs/types/test.ts | 211 +++++++++ .../gindex-of-truthy-row/examples/index.js | 33 ++ .../base/gindex-of-truthy-row/lib/index.js | 57 +++ .../ext/base/gindex-of-truthy-row/lib/main.js | 95 ++++ .../base/gindex-of-truthy-row/lib/ndarray.js | 82 ++++ .../base/gindex-of-truthy-row/package.json | 65 +++ .../test/fixtures/column_major.json | 17 + .../test/fixtures/column_major_no_match.json | 16 + .../fixtures/large-strides/column_major.json | 29 ++ .../large-strides/column_major_no_match.json | 29 ++ .../fixtures/large-strides/row_major.json | 29 ++ .../large-strides/row_major_no_match.json | 29 ++ .../fixtures/mixed-strides/column_major.json | 23 + .../mixed-strides/column_major_no_match.json | 23 + .../fixtures/mixed-strides/row_major.json | 23 + .../mixed-strides/row_major_no_match.json | 23 + .../negative-strides/column_major.json | 23 + .../column_major_no_match.json | 23 + .../fixtures/negative-strides/row_major.json | 23 + .../negative-strides/row_major_no_match.json | 23 + .../test/fixtures/offsets/column_major.json | 24 ++ .../offsets/column_major_no_match.json | 24 ++ .../test/fixtures/offsets/row_major.json | 24 ++ .../fixtures/offsets/row_major_no_match.json | 24 ++ .../test/fixtures/row_major.json | 17 + .../test/fixtures/row_major_no_match.json | 16 + .../base/gindex-of-truthy-row/test/test.js | 38 ++ .../gindex-of-truthy-row/test/test.main.js | 264 ++++++++++++ .../gindex-of-truthy-row/test/test.ndarray.js | 407 ++++++++++++++++++ 34 files changed, 2344 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/column_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/column_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/column_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/column_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/row_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/row_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/column_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/column_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/row_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/row_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/column_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/column_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/row_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/row_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/column_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/column_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/row_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/row_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/row_major.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/row_major_no_match.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/README.md new file mode 100644 index 000000000000..496ce025091d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/README.md @@ -0,0 +1,198 @@ + + +# gindexOfTruthyRow + +> Return the index of the first row in an input matrix which contains all truthy elements. + +
+ +## Usage + +```javascript +var gindexOfTruthyRow = require( '@stdlib/blas/ext/base/gindex-of-truthy-row' ); +``` + +#### gindexOfTruthyRow( order, M, N, A, LDA ) + +Returns the index of the first row in an input matrix which contains all truthy elements. + + + +```javascript +/* + A = [ + [ 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, 1.0, 1.0, 1.0 ], + [ 1.0, 1.0, 1.0, 1.0 ], + [ 0.0, 0.0, 0.0, 0.0 ] + ] +*/ +var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; + +var out = gindexOfTruthyRow( 'row-major', 4, 4, A, 4 ); +// returns 1 +``` + +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`). + +If the function is unable to find a row with all truthy elements, the function returns `-1`. + +```javascript +var A = [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]; + +var out = gindexOfTruthyRow( 'row-major', 4, 2, A, 2 ); +// returns -1 +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial array: +var A0 = new Float64Array( [ 9999.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Create offset view: +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out = gindexOfTruthyRow( 'row-major', 4, 4, A1, 4 ); +// returns 1 +``` + +#### gindexOfTruthyRow.ndarray( M, N, A, strideA1, strideA2, offsetA ) + +Returns the index of the first row in an input matrix which contains all truthy elements using alternative indexing semantics. + + + +```javascript +/* + A = [ + [ 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, 1.0, 1.0, 1.0 ], + [ 1.0, 1.0, 1.0, 1.0 ], + [ 0.0, 0.0, 0.0, 0.0 ] + ] +*/ +var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; + +var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 0 ); +// returns 1 +``` + +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 length for the first dimension of `A`. +- **strideA2**: stride length for the second dimension of `A`. +- **offsetA**: starting index for `A`. + +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. + + + +```javascript +/* + A = [ + [ 0.0, 0.0, 0.0, 0.0 ], + [ 1.0, 1.0, 1.0, 1.0 ], + [ 1.0, 1.0, 1.0, 1.0 ], + [ 0.0, 0.0, 0.0, 0.0 ] + ] +*/ +var A = [ 9999.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; + +var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 1 ); +// returns 1 +``` + +
+ + + +
+ +## Notes + +- A row is considered to contain all truthy elements when all elements in the row are not equal to `0.0` and are not `NaN`. +- 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 gindexOfTruthyRow = require( '@stdlib/blas/ext/base/gindex-of-truthy-row' ); + +var shape = [ 3, 3 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var A = [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var out = gindexOfTruthyRow( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ] ); +console.log( out ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/benchmark/benchmark.js new file mode 100644 index 000000000000..71774454b19f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/benchmark/benchmark.js @@ -0,0 +1,111 @@ +/** +* @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 gindexOfTruthyRow = 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' ); + 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++ ) { + z = gindexOfTruthyRow( order, N, N, A, N ); + 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/gindex-of-truthy-row/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..0be39974a0cf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/benchmark/benchmark.ndarray.js @@ -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. +*/ + +'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 gindexOfTruthyRow = 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' ); + 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++ ) { + z = gindexOfTruthyRow( N, N, A, sa1, sa2, 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/gindex-of-truthy-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/repl.txt new file mode 100644 index 000000000000..49991ee4e22e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/repl.txt @@ -0,0 +1,87 @@ + +{{alias}}( order, M, N, A, LDA ) + Returns the index of the first row in an input matrix which contains all + truthy elements. + + 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 row with all truthy elements, the function returns `-1` (i.e., an + invalid index). + + Parameters + ---------- + order: string + Storage layout. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + A: Array|TypedArray + Input matrix. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + Returns + ------- + out: integer + Row index. + + Examples + -------- + > var A = [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ]; + > {{alias}}( 'row-major', 4, 2, A, 2 ) + 1 + + +{{alias}}.ndarray( M, N, A, strideA1, strideA2, offsetA ) + Returns the index of the first row in an input matrix which contains all + truthy elements 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 row with all truthy elements, 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. + + strideA1: integer + Stride length for the first dimension of `A`. + + strideA2: integer + Stride length for the second dimension of `A`. + + offsetA: integer + Starting index for `A`. + + Returns + ------- + out: integer + Row index. + + Examples + -------- + > var A = [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ]; + > {{alias}}.ndarray( 4, 2, A, 2, 1, 0 ) + 1 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/index.d.ts new file mode 100644 index 000000000000..079254a215aa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/index.d.ts @@ -0,0 +1,112 @@ +/* +* @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 `gindexOfTruthyRow`. +*/ +interface Routine { + /** + * Returns the index of the first row in an input matrix which contains all truthy elements. + * + * ## Notes + * + * - If the function is provided an empty matrix or if the function is unable to find a row with all truthy elements, 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`) + * @returns row index + * + * @example + * var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * var out = gindexOfTruthyRow( 'row-major', 4, 4, A, 4 ); + * // returns 1 + */ + ( order: Layout, M: number, N: number, A: InputArray, LDA: number ): number; + + /** + * Returns the index of the first row in an input matrix which contains all truthy elements using alternative indexing semantics. + * + * ## Notes + * + * - If the function is provided an empty matrix or if the function is unable to find a row with all truthy elements, 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 length for the first dimension of `A` + * @param strideA2 - stride length for the second dimension of `A` + * @param offsetA - starting index for `A` + * @returns row index + * + * @example + * var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 0 ); + * // returns 1 + */ + ndarray( M: number, N: number, A: InputArray, strideA1: number, strideA2: number, offsetA: number ): number; +} + +/** +* Returns the index of the first row in an input matrix which contains all truthy elements. +* +* ## Notes +* +* - If the function is provided an empty matrix or if the function is unable to find a row with all truthy elements, 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`) +* @returns row index +* +* @example +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* var out = gindexOfTruthyRow( 'row-major', 4, 4, A, 4 ); +* // returns 1 +* +* @example +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 0 ); +* // returns 1 +*/ +declare var gindexOfTruthyRow: Routine; + + +// EXPORTS // + +export = gindexOfTruthyRow; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/test.ts new file mode 100644 index 000000000000..7c2a6792b67a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/test.ts @@ -0,0 +1,211 @@ +/* +* @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 space-in-parens */ + +import gindexOfTruthyRow = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + + gindexOfTruthyRow( 'row-major', 2, 2, A, 2 ); // $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 ]; + + gindexOfTruthyRow( 5, 2, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( true, 2, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( false, 2, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( null, 2, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( void 0, 2, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( [], 2, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( {}, 2, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( ( x: number ): number => x, 2, 2, A, 2 ); // $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 ]; + + gindexOfTruthyRow( 'row-major', '5', 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', true, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', false, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', null, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', void 0, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', [], 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', {}, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', ( x: number ): number => x, 2, A, 2 ); // $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 ]; + + gindexOfTruthyRow( 'row-major', 2, '5', A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, true, A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, false, A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, null, A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, void 0, A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, [], A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, {}, A, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, ( x: number ): number => x, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a collection... +{ + gindexOfTruthyRow( 'row-major', 2, 2, 5, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, true, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, false, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, null, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, void 0, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, {}, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, ( x: number ): number => x, 2 ); // $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 ]; + + gindexOfTruthyRow( 'row-major', 2, 2, A, '5' ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, A, true ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, A, false ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, A, null ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, A, void 0 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, A, [] ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, A, {} ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, A, ( 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 ]; + + gindexOfTruthyRow(); // $ExpectError + gindexOfTruthyRow( 'row-major' ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2 ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, A ); // $ExpectError + gindexOfTruthyRow( 'row-major', 2, 2, A, 2, 0 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const A = [ 1.0, 2.0, 3.0, 4.0 ]; + + gindexOfTruthyRow.ndarray( 2, 2, A, 2, 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 ]; + + gindexOfTruthyRow.ndarray( '5', 2, A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( true, 2, A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( false, 2, A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( null, 2, A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( void 0, 2, A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( [], 2, A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( {}, 2, A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( ( x: number ): number => x, 2, A, 2, 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 ]; + + gindexOfTruthyRow.ndarray( 2, '5', A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, true, A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, false, A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, null, A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, void 0, A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, [], A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, {}, A, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, ( x: number ): number => x, A, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a collection... +{ + gindexOfTruthyRow.ndarray( 2, 2, 5, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, true, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, false, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, null, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, void 0, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, {}, 2, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, ( x: number ): number => x, 2, 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 ]; + + gindexOfTruthyRow.ndarray( 2, 2, A, '5', 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, true, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, false, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, null, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, void 0, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, [], 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, {}, 1, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, ( x: number ): number => 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 ]; + + gindexOfTruthyRow.ndarray( 2, 2, A, 2, '5', 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, true, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, false, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, null, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, void 0, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, [], 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, {}, 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, ( x: number ): number => x, 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 ]; + + gindexOfTruthyRow.ndarray( 2, 2, A, 2, 1, '5' ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, 1, true ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, 1, false ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, 1, null ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, 1, void 0 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, 1, [] ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, 1, {} ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, 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 ]; + + gindexOfTruthyRow.ndarray(); // $ExpectError + gindexOfTruthyRow.ndarray( 2 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, 1 ); // $ExpectError + gindexOfTruthyRow.ndarray( 2, 2, A, 2, 1, 0, 0 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/examples/index.js new file mode 100644 index 000000000000..dab5173d81c9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/examples/index.js @@ -0,0 +1,33 @@ +/** +* @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 gindexOfTruthyRow = require( './../lib' ); + +var shape = [ 3, 3 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var A = [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var out = gindexOfTruthyRow( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ] ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/index.js new file mode 100644 index 000000000000..5280f0ce8a40 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/index.js @@ -0,0 +1,57 @@ +/** +* @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 first row in an input matrix which contains all truthy elements. +* +* @module @stdlib/blas/ext/base/gindex-of-truthy-row +* +* @example +* var gindexOfTruthyRow = require( '@stdlib/blas/ext/base/gindex-of-truthy-row' ); +* +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] +* +* var out = gindexOfTruthyRow( 'row-major', 4, 4, A, 4 ); +* // returns 1 +* +* @example +* var gindexOfTruthyRow = require( '@stdlib/blas/ext/base/gindex-of-truthy-row' ); +* +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 0 ); +* // returns 1 +*/ + +// 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/gindex-of-truthy-row/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/main.js new file mode 100644 index 000000000000..3999368c323f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/main.js @@ -0,0 +1,95 @@ +/** +* @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 max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Returns the index of the first row in an input matrix which contains all truthy elements. +* +* ## Notes +* +* - If the function is provided an empty matrix or if the function is unable to find a row with all truthy elements, 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`) +* @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 = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] +* +* var out = gindexOfTruthyRow( 'row-major', 4, 4, A, 4 ); +* // returns 1 +* +* @example +* var A = [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]; // => [ [ 0.0, 1.0 ], [ 0.0, 1.0 ], [ 0.0, 1.0 ], [ 0.0, 1.0 ] ] +* +* var out = gindexOfTruthyRow( 'row-major', 4, 2, A, 2 ); +* // returns -1 +* +* @example +* var A = [ 0.0, 1.0, 1.0, 0.0, 1.0, 1.0 ]; // => [ [ 0.0, 1.0 ], [ 1.0, 0.0 ], [ 1.0, 1.0 ] ] +* +* var out = gindexOfTruthyRow( 'row-major', 3, 2, A, 2 ); +* // returns 2 +*/ +function gindexOfTruthyRow( order, M, N, A, LDA ) { + 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 ndarray( M, N, A, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = gindexOfTruthyRow; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/ndarray.js new file mode 100644 index 000000000000..e109d2cf0c17 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/ndarray.js @@ -0,0 +1,82 @@ +/** +* @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 gevery = require( '@stdlib/blas/ext/base/gevery' ).ndarray; + + +// MAIN // + +/** +* Returns the index of the first row in an input matrix which contains all truthy elements. +* +* ## Notes +* +* - If the function is provided an empty matrix or if the function is unable to find a row with all truthy elements, 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 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` +* @returns {integer} row index +* +* @example +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] +* +* var out = gindexOfTruthyRow( 4, 4, A, 4, 1, 0 ); +* // returns 1 +* +* @example +* var A = [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]; // => [ [ 0.0, 1.0 ], [ 0.0, 1.0 ], [ 0.0, 1.0 ], [ 0.0, 1.0 ] ] +* +* var out = gindexOfTruthyRow( 4, 2, A, 2, 1, 0 ); +* // returns -1 +* +* @example +* var A = [ 0.0, 1.0, 1.0, 0.0, 1.0, 1.0 ]; // => [ [ 0.0, 1.0 ], [ 1.0, 0.0 ], [ 1.0, 1.0 ] ] +* +* var out = gindexOfTruthyRow( 3, 2, A, 2, 1, 0 ); +* // returns 2 +*/ +function gindexOfTruthyRow( M, N, A, strideA1, strideA2, offsetA ) { + var ia; + var i; + + // Check whether the matrix is an empty matrix... + if ( M <= 0 || N <= 0 ) { + return -1; + } + // Search for the first row with all truthy elements... + for ( i = 0; i < M; i++ ) { + ia = offsetA + ( i*strideA1 ); + if ( gevery( N, A, strideA2, ia ) ) { + return i; + } + } + return -1; +} + + +// EXPORTS // + +module.exports = gindexOfTruthyRow; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/package.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/package.json new file mode 100644 index 000000000000..088d88d95c5d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/blas/ext/base/gindex-of-truthy-row", + "version": "0.0.0", + "description": "Return the index of the first row in an input matrix which contains all truthy elements.", + "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", + "row", + "index", + "truthy", + "find", + "index-of", + "indexof" + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/column_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/column_major.json new file mode 100644 index 000000000000..c79faeedd91a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/column_major.json @@ -0,0 +1,17 @@ +{ + "order": "column-major", + "A": [ 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0 ], + "M": 4, + "N": 2, + "strideA1": 1, + "strideA2": 4, + "offsetA": 0, + "LDA": 4, + "A_mat": [ + [ 0.0, 0.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 0.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/column_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/column_major_no_match.json new file mode 100644 index 000000000000..73ca6f93970e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/column_major_no_match.json @@ -0,0 +1,16 @@ +{ + "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 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/column_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/column_major.json new file mode 100644 index 000000000000..408be76924b7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/column_major.json @@ -0,0 +1,29 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 9999.0, + 1.0, + 9999.0, + 1.0, + 9999.0, + 0.0, + 9999.0, + 1.0, + 9999.0, + 1.0, + 9999.0 + ], + "M": 3, + "N": 2, + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/column_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/column_major_no_match.json new file mode 100644 index 000000000000..1881676dae6e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/column_major_no_match.json @@ -0,0 +1,29 @@ +{ + "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 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/row_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/row_major.json new file mode 100644 index 000000000000..f620aeac9dcb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/row_major.json @@ -0,0 +1,29 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 1.0, + 9999.0, + 1.0, + 9999.0, + 1.0, + 9999.0, + 1.0, + 9999.0 + ], + "M": 3, + "N": 2, + "strideA1": 4, + "strideA2": 2, + "offsetA": 0, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/row_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/row_major_no_match.json new file mode 100644 index 000000000000..50416c75b12b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/large-strides/row_major_no_match.json @@ -0,0 +1,29 @@ +{ + "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 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/column_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/column_major.json new file mode 100644 index 000000000000..6bd3a104ff06 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/column_major.json @@ -0,0 +1,23 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 1.0, + 1.0, + 0.0, + 1.0, + 1.0 + ], + "M": 3, + "N": 2, + "strideA1": 1, + "strideA2": -3, + "offsetA": 3, + "LDA": 3, + "A_mat": [ + [ 1.0, 0.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/column_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/column_major_no_match.json new file mode 100644 index 000000000000..d8af7823044b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/column_major_no_match.json @@ -0,0 +1,23 @@ +{ + "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 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/row_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/row_major.json new file mode 100644 index 000000000000..28f692fa2f82 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/row_major.json @@ -0,0 +1,23 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 0.0, + 1.0, + 1.0, + 1.0, + 1.0 + ], + "M": 3, + "N": 2, + "strideA1": -2, + "strideA2": 1, + "offsetA": 4, + "LDA": 2, + "A_mat": [ + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 0.0, 0.0 ] + ], + "expected": 0 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/row_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/row_major_no_match.json new file mode 100644 index 000000000000..cf2d9d05f366 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/row_major_no_match.json @@ -0,0 +1,23 @@ +{ + "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 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/column_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/column_major.json new file mode 100644 index 000000000000..e9047171fcf9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/column_major.json @@ -0,0 +1,23 @@ +{ + "order": "column-major", + "A": [ + 1.0, + 1.0, + 0.0, + 1.0, + 1.0, + 0.0 + ], + "M": 3, + "N": 2, + "strideA1": -1, + "strideA2": -3, + "offsetA": 5, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/column_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/column_major_no_match.json new file mode 100644 index 000000000000..66c579cd6072 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/column_major_no_match.json @@ -0,0 +1,23 @@ +{ + "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 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/row_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/row_major.json new file mode 100644 index 000000000000..62a5bb6eb5c1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/row_major.json @@ -0,0 +1,23 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 0.0, + 1.0, + 1.0, + 1.0, + 1.0 + ], + "M": 3, + "N": 2, + "strideA1": -2, + "strideA2": -1, + "offsetA": 5, + "LDA": 2, + "A_mat": [ + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 0.0, 0.0 ] + ], + "expected": 0 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/row_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/row_major_no_match.json new file mode 100644 index 000000000000..54f0db891e33 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/negative-strides/row_major_no_match.json @@ -0,0 +1,23 @@ +{ + "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 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/column_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/column_major.json new file mode 100644 index 000000000000..e2539485aa36 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/column_major.json @@ -0,0 +1,24 @@ +{ + "order": "column-major", + "A": [ + 9999.0, + 0.0, + 1.0, + 1.0, + 0.0, + 1.0, + 1.0 + ], + "M": 3, + "N": 2, + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/column_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/column_major_no_match.json new file mode 100644 index 000000000000..59b9a8f46fc3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/column_major_no_match.json @@ -0,0 +1,24 @@ +{ + "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 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/row_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/row_major.json new file mode 100644 index 000000000000..1d721429118e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/row_major.json @@ -0,0 +1,24 @@ +{ + "order": "row-major", + "A": [ + 9999.0, + 0.0, + 0.0, + 1.0, + 1.0, + 1.0, + 1.0 + ], + "M": 3, + "N": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 1, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/row_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/row_major_no_match.json new file mode 100644 index 000000000000..fb91d1f7908b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/offsets/row_major_no_match.json @@ -0,0 +1,24 @@ +{ + "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 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/row_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/row_major.json new file mode 100644 index 000000000000..a9555777bf4f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/row_major.json @@ -0,0 +1,17 @@ +{ + "order": "row-major", + "A": [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ], + "M": 4, + "N": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 1.0, 1.0 ], + [ 1.0, 1.0 ], + [ 0.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/row_major_no_match.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/row_major_no_match.json new file mode 100644 index 000000000000..20eceeaad571 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/row_major_no_match.json @@ -0,0 +1,16 @@ +{ + "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 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.js new file mode 100644 index 000000000000..1c374fc288a9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-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 gindexOfTruthyRow = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gindexOfTruthyRow, '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 gindexOfTruthyRow.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.main.js new file mode 100644 index 000000000000..c096e6593aa5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.main.js @@ -0,0 +1,264 @@ +/** +* @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 toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var gindexOfTruthyRow = 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 gindexOfTruthyRow, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( gindexOfTruthyRow.length, 5, '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() { + gindexOfTruthyRow( value, data.M, data.N, data.A, data.LDA ); + }; + } +}); + +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() { + gindexOfTruthyRow( data.order, data.M, data.N, data.A, value ); + }; + } +}); + +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() { + gindexOfTruthyRow( data.order, data.M, data.N, data.A, value ); + }; + } +}); + +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 = gindexOfTruthyRow( data.order, 0, data.N, data.A, data.LDA ); + + 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 = gindexOfTruthyRow( data.order, data.M, 0, data.A, data.LDA ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (row-major)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_DATA; + out = gindexOfTruthyRow( data.order, data.M, data.N, data.A, data.LDA ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (column-major)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_DATA; + out = gindexOfTruthyRow( data.order, data.M, data.N, data.A, data.LDA ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_NO_MATCH; + out = gindexOfTruthyRow( data.order, data.M, data.N, data.A, data.LDA ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_NO_MATCH; + out = gindexOfTruthyRow( data.order, data.M, data.N, data.A, data.LDA ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (row-major, accessors)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_DATA; + out = gindexOfTruthyRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (column-major, accessors)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_DATA; + out = gindexOfTruthyRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA ); + + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major, accessors)', function test( t ) { + var data; + var out; + + data = ROW_MAJOR_NO_MATCH; + out = gindexOfTruthyRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major, accessors)', function test( t ) { + var data; + var out; + + data = COLUMN_MAJOR_NO_MATCH; + out = gindexOfTruthyRow( data.order, data.M, data.N, toAccessorArray( data.A ), data.LDA ); + + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function treats NaN as falsy', function test( t ) { + var out; + var A; + + A = [ NaN, 1.0, 1.0, 1.0 ]; + out = gindexOfTruthyRow( 'row-major', 2, 2, A, 2 ); + t.strictEqual( out, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function treats NaN as falsy (accessors)', function test( t ) { + var out; + var A; + + A = toAccessorArray( [ NaN, 1.0, 1.0, 1.0 ] ); + out = gindexOfTruthyRow( 'row-major', 2, 2, A, 2 ); + t.strictEqual( out, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.ndarray.js new file mode 100644 index 000000000000..9181ed48e52d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.ndarray.js @@ -0,0 +1,407 @@ +/** +* @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 toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var gindexOfTruthyRow = 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 gindexOfTruthyRow, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( gindexOfTruthyRow.length, 6, '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 = ROW_MAJOR_DATA; + var out = gindexOfTruthyRow( 0, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + 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 = ROW_MAJOR_DATA; + var out = gindexOfTruthyRow( data.M, 0, data.A, data.strideA1, data.strideA2, data.offsetA ); + 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 = COLUMN_MAJOR_DATA; + var out = gindexOfTruthyRow( 0, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + 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 = COLUMN_MAJOR_DATA; + var out = gindexOfTruthyRow( data.M, 0, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (row-major)', function test( t ) { + var data = ROW_MAJOR_DATA; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (column-major)', function test( t ) { + var data = COLUMN_MAJOR_DATA; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major)', function test( t ) { + var data = ROW_MAJOR_NO_MATCH; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major)', function test( t ) { + var data = COLUMN_MAJOR_NO_MATCH; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (row-major, offsets)', function test( t ) { + var data = OFFSET_ROW_MAJOR_DATA; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (column-major, offsets)', function test( t ) { + var data = OFFSET_COLUMN_MAJOR_DATA; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major, offsets)', function test( t ) { + var data = OFFSET_ROW_MAJOR_NO_MATCH; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major, offsets)', function test( t ) { + var data = OFFSET_COLUMN_MAJOR_NO_MATCH; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (row-major, mixed strides)', function test( t ) { + var data = MIXED_STRIDES_ROW_MAJOR_DATA; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (column-major, mixed strides)', function test( t ) { + var data = MIXED_STRIDES_COLUMN_MAJOR_DATA; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major, mixed strides)', function test( t ) { + var data = MIXED_STRIDES_ROW_MAJOR_NO_MATCH; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major, mixed strides)', function test( t ) { + var data = MIXED_STRIDES_COLUMN_MAJOR_NO_MATCH; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (row-major, negative strides)', function test( t ) { + var data = NEGATIVE_STRIDES_ROW_MAJOR_DATA; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (column-major, negative strides)', function test( t ) { + var data = NEGATIVE_STRIDES_COLUMN_MAJOR_DATA; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major, negative strides)', function test( t ) { + var data = NEGATIVE_STRIDES_ROW_MAJOR_NO_MATCH; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major, negative strides)', function test( t ) { + var data = NEGATIVE_STRIDES_COLUMN_MAJOR_NO_MATCH; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (row-major, large strides)', function test( t ) { + var data = LARGE_STRIDES_ROW_MAJOR_DATA; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (column-major, large strides)', function test( t ) { + var data = LARGE_STRIDES_COLUMN_MAJOR_DATA; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major, large strides)', function test( t ) { + var data = LARGE_STRIDES_ROW_MAJOR_NO_MATCH; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major, large strides)', function test( t ) { + var data = LARGE_STRIDES_COLUMN_MAJOR_NO_MATCH; + var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (row-major, accessors)', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_DATA; + A = toAccessorArray( data.A ); + out = gindexOfTruthyRow( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (column-major, accessors)', function test( t ) { + var data; + var out; + var A; + + data = COLUMN_MAJOR_DATA; + A = toAccessorArray( data.A ); + out = gindexOfTruthyRow( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major, accessors)', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_NO_MATCH; + A = toAccessorArray( data.A ); + out = gindexOfTruthyRow( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major, accessors)', function test( t ) { + var data; + var out; + var A; + + data = COLUMN_MAJOR_NO_MATCH; + A = toAccessorArray( data.A ); + out = gindexOfTruthyRow( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (row-major, offsets, accessors)', function test( t ) { + var data; + var out; + var A; + + data = OFFSET_ROW_MAJOR_DATA; + A = toAccessorArray( data.A ); + out = gindexOfTruthyRow( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (column-major, offsets, accessors)', function test( t ) { + var data; + var out; + var A; + + data = OFFSET_COLUMN_MAJOR_DATA; + A = toAccessorArray( data.A ); + out = gindexOfTruthyRow( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (row-major, negative strides, accessors)', function test( t ) { + var data; + var out; + var A; + + data = NEGATIVE_STRIDES_ROW_MAJOR_DATA; + A = toAccessorArray( data.A ); + out = gindexOfTruthyRow( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (column-major, negative strides, accessors)', function test( t ) { + var data; + var out; + var A; + + data = NEGATIVE_STRIDES_COLUMN_MAJOR_DATA; + A = toAccessorArray( data.A ); + out = gindexOfTruthyRow( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (row-major, mixed strides, accessors)', function test( t ) { + var data; + var out; + var A; + + data = MIXED_STRIDES_ROW_MAJOR_DATA; + A = toAccessorArray( data.A ); + out = gindexOfTruthyRow( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (column-major, mixed strides, accessors)', function test( t ) { + var data; + var out; + var A; + + data = MIXED_STRIDES_COLUMN_MAJOR_DATA; + A = toAccessorArray( data.A ); + out = gindexOfTruthyRow( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (row-major, large strides, accessors)', function test( t ) { + var data; + var out; + var A; + + data = LARGE_STRIDES_ROW_MAJOR_DATA; + A = toAccessorArray( data.A ); + out = gindexOfTruthyRow( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the index of the first row with all truthy elements (column-major, large strides, accessors)', function test( t ) { + var data; + var out; + var A; + + data = LARGE_STRIDES_COLUMN_MAJOR_DATA; + A = toAccessorArray( data.A ); + out = gindexOfTruthyRow( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function treats NaN as falsy (row-major)', function test( t ) { + var data; + var out; + + data = [ NaN, 1.0, 1.0, 1.0 ]; + out = gindexOfTruthyRow( 2, 2, data, 2, 1, 0 ); + t.strictEqual( out, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function treats NaN as falsy (column-major)', function test( t ) { + var data; + var out; + + data = [ 1.0, 1.0, 1.0, NaN ]; + out = gindexOfTruthyRow( 2, 2, data, 1, 2, 0 ); + t.strictEqual( out, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function treats NaN as falsy (accessors)', function test( t ) { + var data; + var out; + + data = toAccessorArray( [ NaN, 1.0, 1.0, 1.0 ] ); + out = gindexOfTruthyRow( 2, 2, data, 2, 1, 0 ); + t.strictEqual( out, 1, 'returns expected value' ); + t.end(); +}); From 4dc19501acd4cc7912c516c40b4616735d53c129 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 17 Jul 2026 22:48:08 +0500 Subject: [PATCH 2/2] fix: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../ext/base/gindex-of-truthy-row/README.md | 24 +++---- .../base/gindex-of-truthy-row/docs/repl.txt | 20 +++--- .../docs/types/index.d.ts | 20 +++--- .../gindex-of-truthy-row/examples/index.js | 4 +- .../base/gindex-of-truthy-row/lib/index.js | 6 +- .../ext/base/gindex-of-truthy-row/lib/main.js | 14 ++-- .../base/gindex-of-truthy-row/lib/ndarray.js | 20 +++--- .../base/gindex-of-truthy-row/package.json | 2 +- .../test/fixtures/column_major.json | 4 +- .../fixtures/mixed-strides/column_major.json | 2 +- .../test/fixtures/row_major.json | 4 +- .../gindex-of-truthy-row/test/test.main.js | 20 +++--- .../gindex-of-truthy-row/test/test.ndarray.js | 72 +++++++++---------- 13 files changed, 106 insertions(+), 106 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/README.md b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/README.md index 496ce025091d..bd72f43afcef 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/README.md @@ -20,7 +20,7 @@ limitations under the License. # gindexOfTruthyRow -> Return the index of the first row in an input matrix which contains all truthy elements. +> Return the index of the first row in an input matrix which contains at least one truthy element.
@@ -32,7 +32,7 @@ var gindexOfTruthyRow = require( '@stdlib/blas/ext/base/gindex-of-truthy-row' ); #### gindexOfTruthyRow( order, M, N, A, LDA ) -Returns the index of the first row in an input matrix which contains all truthy elements. +Returns the index of the first row in an input matrix which contains at least one truthy element. @@ -40,12 +40,12 @@ Returns the index of the first row in an input matrix which contains all truthy /* A = [ [ 0.0, 0.0, 0.0, 0.0 ], - [ 1.0, 1.0, 1.0, 1.0 ], + [ 1.0, 0.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] */ -var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; +var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; var out = gindexOfTruthyRow( 'row-major', 4, 4, A, 4 ); // returns 1 @@ -59,10 +59,10 @@ The function has the following parameters: - **A**: input matrix as a linear array. - **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). -If the function is unable to find a row with all truthy elements, the function returns `-1`. +If the function is unable to find a row with at least one truthy element, the function returns `-1`. ```javascript -var A = [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]; +var A = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; var out = gindexOfTruthyRow( 'row-major', 4, 2, A, 2 ); // returns -1 @@ -87,7 +87,7 @@ var out = gindexOfTruthyRow( 'row-major', 4, 4, A1, 4 ); #### gindexOfTruthyRow.ndarray( M, N, A, strideA1, strideA2, offsetA ) -Returns the index of the first row in an input matrix which contains all truthy elements using alternative indexing semantics. +Returns the index of the first row in an input matrix which contains at least one truthy element using alternative indexing semantics. @@ -95,12 +95,12 @@ Returns the index of the first row in an input matrix which contains all truthy /* A = [ [ 0.0, 0.0, 0.0, 0.0 ], - [ 1.0, 1.0, 1.0, 1.0 ], + [ 1.0, 0.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] */ -var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; +var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 0 ); // returns 1 @@ -142,7 +142,7 @@ var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 1 ); ## Notes -- A row is considered to contain all truthy elements when all elements in the row are not equal to `0.0` and are not `NaN`. +- A row is considered to contain at least one truthy element when at least one element in the row is not equal to `0.0` and is not `NaN`. - 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]).
@@ -162,11 +162,11 @@ var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); var gindexOfTruthyRow = require( '@stdlib/blas/ext/base/gindex-of-truthy-row' ); -var shape = [ 3, 3 ]; +var shape = [ 4, 2 ]; var order = 'row-major'; var strides = shape2strides( shape, order ); -var A = [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; +var A = [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0 ]; console.log( ndarray2array( A, shape, strides, 0, order ) ); var out = gindexOfTruthyRow( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/repl.txt index 49991ee4e22e..207f71a746a7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/repl.txt @@ -1,14 +1,14 @@ {{alias}}( order, M, N, A, LDA ) - Returns the index of the first row in an input matrix which contains all - truthy elements. + Returns the index of the first row in an input matrix which contains at + least one truthy element. 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 row with all truthy elements, the function returns `-1` (i.e., an - invalid index). + find a row with at least one truthy element, the function returns `-1` + (i.e., an invalid index). Parameters ---------- @@ -35,22 +35,22 @@ Examples -------- - > var A = [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ]; + > var A = [ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0 ]; > {{alias}}( 'row-major', 4, 2, A, 2 ) 1 {{alias}}.ndarray( M, N, A, strideA1, strideA2, offsetA ) - Returns the index of the first row in an input matrix which contains all - truthy elements using alternative indexing semantics. + Returns the index of the first row in an input matrix which contains at + least one truthy element 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 row with all truthy elements, the method returns `-1` (i.e., an invalid - index). + a row with at least one truthy element, the method returns `-1` (i.e., an + invalid index). Parameters ---------- @@ -79,7 +79,7 @@ Examples -------- - > var A = [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ]; + > var A = [ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0 ]; > {{alias}}.ndarray( 4, 2, A, 2, 1, 0 ) 1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/index.d.ts index 079254a215aa..ef733c8ef99c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/docs/types/index.d.ts @@ -33,11 +33,11 @@ type InputArray = Collection | AccessorArrayLike; */ interface Routine { /** - * Returns the index of the first row in an input matrix which contains all truthy elements. + * Returns the index of the first row in an input matrix which contains at least one truthy element. * * ## Notes * - * - If the function is provided an empty matrix or if the function is unable to find a row with all truthy elements, the function returns `-1` (i.e., an invalid index). + * - If the function is provided an empty matrix or if the function is unable to find a row with at least one truthy element, the function returns `-1` (i.e., an invalid index). * * @param order - storage layout * @param M - number of rows in `A` @@ -47,7 +47,7 @@ interface Routine { * @returns row index * * @example - * var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; + * var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; * * var out = gindexOfTruthyRow( 'row-major', 4, 4, A, 4 ); * // returns 1 @@ -55,11 +55,11 @@ interface Routine { ( order: Layout, M: number, N: number, A: InputArray, LDA: number ): number; /** - * Returns the index of the first row in an input matrix which contains all truthy elements using alternative indexing semantics. + * Returns the index of the first row in an input matrix which contains at least one truthy element using alternative indexing semantics. * * ## Notes * - * - If the function is provided an empty matrix or if the function is unable to find a row with all truthy elements, the function returns `-1` (i.e., an invalid index). + * - If the function is provided an empty matrix or if the function is unable to find a row with at least one truthy element, the function returns `-1` (i.e., an invalid index). * * @param M - number of rows in `A` * @param N - number of columns in `A` @@ -70,7 +70,7 @@ interface Routine { * @returns row index * * @example - * var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; + * var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; * * var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 0 ); * // returns 1 @@ -79,11 +79,11 @@ interface Routine { } /** -* Returns the index of the first row in an input matrix which contains all truthy elements. +* Returns the index of the first row in an input matrix which contains at least one truthy element. * * ## Notes * -* - If the function is provided an empty matrix or if the function is unable to find a row with all truthy elements, the function returns `-1` (i.e., an invalid index). +* - If the function is provided an empty matrix or if the function is unable to find a row with at least one truthy element, the function returns `-1` (i.e., an invalid index). * * @param order - storage layout * @param M - number of rows in `A` @@ -93,13 +93,13 @@ interface Routine { * @returns row index * * @example -* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; * * var out = gindexOfTruthyRow( 'row-major', 4, 4, A, 4 ); * // returns 1 * * @example -* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; * * var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 0 ); * // returns 1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/examples/index.js index dab5173d81c9..c723fbe785ac 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/examples/index.js @@ -22,11 +22,11 @@ var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); var gindexOfTruthyRow = require( './../lib' ); -var shape = [ 3, 3 ]; +var shape = [ 4, 2 ]; var order = 'row-major'; var strides = shape2strides( shape, order ); -var A = [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; +var A = [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0 ]; console.log( ndarray2array( A, shape, strides, 0, order ) ); var out = gindexOfTruthyRow( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/index.js index 5280f0ce8a40..ef6d96b84479 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/index.js @@ -19,14 +19,14 @@ 'use strict'; /** -* Return the index of the first row in an input matrix which contains all truthy elements. +* Return the index of the first row in an input matrix which contains at least one truthy element. * * @module @stdlib/blas/ext/base/gindex-of-truthy-row * * @example * var gindexOfTruthyRow = require( '@stdlib/blas/ext/base/gindex-of-truthy-row' ); * -* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 0.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] * * var out = gindexOfTruthyRow( 'row-major', 4, 4, A, 4 ); * // returns 1 @@ -34,7 +34,7 @@ * @example * var gindexOfTruthyRow = require( '@stdlib/blas/ext/base/gindex-of-truthy-row' ); * -* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; * * var out = gindexOfTruthyRow.ndarray( 4, 4, A, 4, 1, 0 ); * // returns 1 diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/main.js index 3999368c323f..3cc588e1744f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/main.js @@ -31,11 +31,11 @@ var ndarray = require( './ndarray.js' ); // MAIN // /** -* Returns the index of the first row in an input matrix which contains all truthy elements. +* Returns the index of the first row in an input matrix which contains at least one truthy element. * * ## Notes * -* - If the function is provided an empty matrix or if the function is unable to find a row with all truthy elements, the function returns `-1` (i.e., an invalid index). +* - If the function is provided an empty matrix or if the function is unable to find a row with at least one truthy element, the function returns `-1` (i.e., an invalid index). * * @param {string} order - storage layout * @param {PositiveInteger} M - number of rows in `A` @@ -47,22 +47,22 @@ var ndarray = require( './ndarray.js' ); * @returns {integer} row index * * @example -* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 0.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] * * var out = gindexOfTruthyRow( 'row-major', 4, 4, A, 4 ); * // returns 1 * * @example -* var A = [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]; // => [ [ 0.0, 1.0 ], [ 0.0, 1.0 ], [ 0.0, 1.0 ], [ 0.0, 1.0 ] ] +* var A = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0 ], [ 0.0, 0.0 ], [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] * * var out = gindexOfTruthyRow( 'row-major', 4, 2, A, 2 ); * // returns -1 * * @example -* var A = [ 0.0, 1.0, 1.0, 0.0, 1.0, 1.0 ]; // => [ [ 0.0, 1.0 ], [ 1.0, 0.0 ], [ 1.0, 1.0 ] ] +* var A = [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0 ], [ 0.0, 1.0 ], [ 1.0, 1.0 ], [ 0.0, 0.0 ] ] * -* var out = gindexOfTruthyRow( 'row-major', 3, 2, A, 2 ); -* // returns 2 +* var out = gindexOfTruthyRow( 'row-major', 4, 2, A, 2 ); +* // returns 1 */ function gindexOfTruthyRow( order, M, N, A, LDA ) { var sa1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/ndarray.js index e109d2cf0c17..1e42d9b2c42e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/lib/ndarray.js @@ -20,17 +20,17 @@ // MODULES // -var gevery = require( '@stdlib/blas/ext/base/gevery' ).ndarray; +var gany = require( '@stdlib/blas/ext/base/gany' ).ndarray; // MAIN // /** -* Returns the index of the first row in an input matrix which contains all truthy elements. +* Returns the index of the first row in an input matrix which contains at least one truthy element. * * ## Notes * -* - If the function is provided an empty matrix or if the function is unable to find a row with all truthy elements, the function returns `-1` (i.e., an invalid index). +* - If the function is provided an empty matrix or if the function is unable to find a row with at least one truthy element, 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` @@ -41,22 +41,22 @@ var gevery = require( '@stdlib/blas/ext/base/gevery' ).ndarray; * @returns {integer} row index * * @example -* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] +* var A = [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0, 0.0, 0.0 ], [ 1.0, 0.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0, 1.0 ], [ 0.0, 0.0, 0.0, 0.0 ] ] * * var out = gindexOfTruthyRow( 4, 4, A, 4, 1, 0 ); * // returns 1 * * @example -* var A = [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]; // => [ [ 0.0, 1.0 ], [ 0.0, 1.0 ], [ 0.0, 1.0 ], [ 0.0, 1.0 ] ] +* var A = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0 ], [ 0.0, 0.0 ], [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] * * var out = gindexOfTruthyRow( 4, 2, A, 2, 1, 0 ); * // returns -1 * * @example -* var A = [ 0.0, 1.0, 1.0, 0.0, 1.0, 1.0 ]; // => [ [ 0.0, 1.0 ], [ 1.0, 0.0 ], [ 1.0, 1.0 ] ] +* var A = [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0 ]; // => [ [ 0.0, 0.0 ], [ 0.0, 1.0 ], [ 1.0, 1.0 ], [ 0.0, 0.0 ] ] * -* var out = gindexOfTruthyRow( 3, 2, A, 2, 1, 0 ); -* // returns 2 +* var out = gindexOfTruthyRow( 4, 2, A, 2, 1, 0 ); +* // returns 1 */ function gindexOfTruthyRow( M, N, A, strideA1, strideA2, offsetA ) { var ia; @@ -66,10 +66,10 @@ function gindexOfTruthyRow( M, N, A, strideA1, strideA2, offsetA ) { if ( M <= 0 || N <= 0 ) { return -1; } - // Search for the first row with all truthy elements... + // Search for the first row with at least one truthy element... for ( i = 0; i < M; i++ ) { ia = offsetA + ( i*strideA1 ); - if ( gevery( N, A, strideA2, ia ) ) { + if ( gany( N, A, strideA2, ia ) ) { return i; } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/package.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/package.json index 088d88d95c5d..f8747466118a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/ext/base/gindex-of-truthy-row", "version": "0.0.0", - "description": "Return the index of the first row in an input matrix which contains all truthy elements.", + "description": "Return the index of the first row in an input matrix which contains at least one truthy element.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/column_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/column_major.json index c79faeedd91a..4a2337b28627 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/column_major.json +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/column_major.json @@ -1,6 +1,6 @@ { "order": "column-major", - "A": [ 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0 ], + "A": [ 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ], "M": 4, "N": 2, "strideA1": 1, @@ -9,7 +9,7 @@ "LDA": 4, "A_mat": [ [ 0.0, 0.0 ], - [ 1.0, 1.0 ], + [ 1.0, 0.0 ], [ 1.0, 1.0 ], [ 0.0, 0.0 ] ], diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/column_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/column_major.json index 6bd3a104ff06..befe6eb74659 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/column_major.json +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/mixed-strides/column_major.json @@ -15,7 +15,7 @@ "offsetA": 3, "LDA": 3, "A_mat": [ - [ 1.0, 0.0 ], + [ 0.0, 0.0 ], [ 1.0, 1.0 ], [ 1.0, 1.0 ] ], diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/row_major.json b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/row_major.json index a9555777bf4f..63c8449c3135 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/row_major.json +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/fixtures/row_major.json @@ -1,6 +1,6 @@ { "order": "row-major", - "A": [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ], + "A": [ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0 ], "M": 4, "N": 2, "strideA1": 2, @@ -9,7 +9,7 @@ "LDA": 2, "A_mat": [ [ 0.0, 0.0 ], - [ 1.0, 1.0 ], + [ 1.0, 0.0 ], [ 1.0, 1.0 ], [ 0.0, 0.0 ] ], diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.main.js index c096e6593aa5..e8de070030d4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.main.js @@ -153,7 +153,7 @@ tape( 'the function returns an invalid index when N is less than or equal to zer t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (row-major)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (row-major)', function test( t ) { var data; var out; @@ -164,7 +164,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (column-major)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (column-major)', function test( t ) { var data; var out; @@ -175,7 +175,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (row-major)', function test( t ) { var data; var out; @@ -186,7 +186,7 @@ tape( 'the function returns an invalid index if unable to find a row with all tr t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (column-major)', function test( t ) { var data; var out; @@ -197,7 +197,7 @@ tape( 'the function returns an invalid index if unable to find a row with all tr t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (row-major, accessors)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (row-major, accessors)', function test( t ) { var data; var out; @@ -208,7 +208,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (column-major, accessors)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (column-major, accessors)', function test( t ) { var data; var out; @@ -219,7 +219,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major, accessors)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (row-major, accessors)', function test( t ) { var data; var out; @@ -230,7 +230,7 @@ tape( 'the function returns an invalid index if unable to find a row with all tr t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major, accessors)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (column-major, accessors)', function test( t ) { var data; var out; @@ -245,7 +245,7 @@ tape( 'the function treats NaN as falsy', function test( t ) { var out; var A; - A = [ NaN, 1.0, 1.0, 1.0 ]; + A = [ NaN, 0.0, 1.0, 1.0 ]; out = gindexOfTruthyRow( 'row-major', 2, 2, A, 2 ); t.strictEqual( out, 1, 'returns expected value' ); @@ -256,7 +256,7 @@ tape( 'the function treats NaN as falsy (accessors)', function test( t ) { var out; var A; - A = toAccessorArray( [ NaN, 1.0, 1.0, 1.0 ] ); + A = toAccessorArray( [ NaN, 0.0, 1.0, 1.0 ] ); out = gindexOfTruthyRow( 'row-major', 2, 2, A, 2 ); t.strictEqual( out, 1, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.ndarray.js index 9181ed48e52d..5a6de0205123 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gindex-of-truthy-row/test/test.ndarray.js @@ -92,147 +92,147 @@ tape( 'the function returns an invalid index when N is less than or equal to zer t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (row-major)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (row-major)', function test( t ) { var data = ROW_MAJOR_DATA; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (column-major)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (column-major)', function test( t ) { var data = COLUMN_MAJOR_DATA; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (row-major)', function test( t ) { var data = ROW_MAJOR_NO_MATCH; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (column-major)', function test( t ) { var data = COLUMN_MAJOR_NO_MATCH; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (row-major, offsets)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (row-major, offsets)', function test( t ) { var data = OFFSET_ROW_MAJOR_DATA; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (column-major, offsets)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (column-major, offsets)', function test( t ) { var data = OFFSET_COLUMN_MAJOR_DATA; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major, offsets)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (row-major, offsets)', function test( t ) { var data = OFFSET_ROW_MAJOR_NO_MATCH; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major, offsets)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (column-major, offsets)', function test( t ) { var data = OFFSET_COLUMN_MAJOR_NO_MATCH; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (row-major, mixed strides)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (row-major, mixed strides)', function test( t ) { var data = MIXED_STRIDES_ROW_MAJOR_DATA; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (column-major, mixed strides)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (column-major, mixed strides)', function test( t ) { var data = MIXED_STRIDES_COLUMN_MAJOR_DATA; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major, mixed strides)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (row-major, mixed strides)', function test( t ) { var data = MIXED_STRIDES_ROW_MAJOR_NO_MATCH; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major, mixed strides)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (column-major, mixed strides)', function test( t ) { var data = MIXED_STRIDES_COLUMN_MAJOR_NO_MATCH; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (row-major, negative strides)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (row-major, negative strides)', function test( t ) { var data = NEGATIVE_STRIDES_ROW_MAJOR_DATA; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (column-major, negative strides)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (column-major, negative strides)', function test( t ) { var data = NEGATIVE_STRIDES_COLUMN_MAJOR_DATA; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major, negative strides)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (row-major, negative strides)', function test( t ) { var data = NEGATIVE_STRIDES_ROW_MAJOR_NO_MATCH; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major, negative strides)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (column-major, negative strides)', function test( t ) { var data = NEGATIVE_STRIDES_COLUMN_MAJOR_NO_MATCH; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (row-major, large strides)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (row-major, large strides)', function test( t ) { var data = LARGE_STRIDES_ROW_MAJOR_DATA; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (column-major, large strides)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (column-major, large strides)', function test( t ) { var data = LARGE_STRIDES_COLUMN_MAJOR_DATA; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major, large strides)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (row-major, large strides)', function test( t ) { var data = LARGE_STRIDES_ROW_MAJOR_NO_MATCH; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major, large strides)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (column-major, large strides)', function test( t ) { var data = LARGE_STRIDES_COLUMN_MAJOR_NO_MATCH; var out = gindexOfTruthyRow( data.M, data.N, data.A, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, -1, 'returns expected value' ); t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (row-major, accessors)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (row-major, accessors)', function test( t ) { var data; var out; var A; @@ -244,7 +244,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (column-major, accessors)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (column-major, accessors)', function test( t ) { var data; var out; var A; @@ -256,7 +256,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (row-major, accessors)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (row-major, accessors)', function test( t ) { var data; var out; var A; @@ -268,7 +268,7 @@ tape( 'the function returns an invalid index if unable to find a row with all tr t.end(); }); -tape( 'the function returns an invalid index if unable to find a row with all truthy elements (column-major, accessors)', function test( t ) { +tape( 'the function returns an invalid index if unable to find a row with at least one truthy element (column-major, accessors)', function test( t ) { var data; var out; var A; @@ -280,7 +280,7 @@ tape( 'the function returns an invalid index if unable to find a row with all tr t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (row-major, offsets, accessors)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (row-major, offsets, accessors)', function test( t ) { var data; var out; var A; @@ -292,7 +292,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (column-major, offsets, accessors)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (column-major, offsets, accessors)', function test( t ) { var data; var out; var A; @@ -304,7 +304,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (row-major, negative strides, accessors)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (row-major, negative strides, accessors)', function test( t ) { var data; var out; var A; @@ -316,7 +316,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (column-major, negative strides, accessors)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (column-major, negative strides, accessors)', function test( t ) { var data; var out; var A; @@ -328,7 +328,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (row-major, mixed strides, accessors)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (row-major, mixed strides, accessors)', function test( t ) { var data; var out; var A; @@ -340,7 +340,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (column-major, mixed strides, accessors)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (column-major, mixed strides, accessors)', function test( t ) { var data; var out; var A; @@ -352,7 +352,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (row-major, large strides, accessors)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (row-major, large strides, accessors)', function test( t ) { var data; var out; var A; @@ -364,7 +364,7 @@ tape( 'the function returns the index of the first row with all truthy elements t.end(); }); -tape( 'the function returns the index of the first row with all truthy elements (column-major, large strides, accessors)', function test( t ) { +tape( 'the function returns the index of the first row with at least one truthy element (column-major, large strides, accessors)', function test( t ) { var data; var out; var A; @@ -380,7 +380,7 @@ tape( 'the function treats NaN as falsy (row-major)', function test( t ) { var data; var out; - data = [ NaN, 1.0, 1.0, 1.0 ]; + data = [ NaN, 0.0, 1.0, 1.0 ]; out = gindexOfTruthyRow( 2, 2, data, 2, 1, 0 ); t.strictEqual( out, 1, 'returns expected value' ); t.end(); @@ -390,9 +390,9 @@ tape( 'the function treats NaN as falsy (column-major)', function test( t ) { var data; var out; - data = [ 1.0, 1.0, 1.0, NaN ]; + data = [ NaN, 0.0, 0.0, 1.0 ]; out = gindexOfTruthyRow( 2, 2, data, 1, 2, 0 ); - t.strictEqual( out, 0, 'returns expected value' ); + t.strictEqual( out, 1, 'returns expected value' ); t.end(); }); @@ -400,7 +400,7 @@ tape( 'the function treats NaN as falsy (accessors)', function test( t ) { var data; var out; - data = toAccessorArray( [ NaN, 1.0, 1.0, 1.0 ] ); + data = toAccessorArray( [ NaN, 0.0, 1.0, 1.0 ] ); out = gindexOfTruthyRow( 2, 2, data, 2, 1, 0 ); t.strictEqual( out, 1, 'returns expected value' ); t.end();