diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/README.md b/lib/node_modules/@stdlib/lapack/base/iladlc/README.md new file mode 100644 index 000000000000..e0715351a0b5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/README.md @@ -0,0 +1,259 @@ + + +# iladlc + +> Find the index of the last non-zero column in a matrix `A`. + +
+ +## Usage + +```javascript +var iladlc = require( '@stdlib/lapack/base/iladlc' ); +``` + +#### iladlc( order, M, N, A, LDA ) + +Returns the index of the last non-zero column in a matrix `A`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); + +/* + A = [ + [ 1.0, 2.0, 0.0 ], + [ 3.0, 4.0, 0.0 ] + ] +*/ + +var out = iladlc( 'row-major', 2, 3, A, 3 ); +// 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 [`Float64Array`][mdn-float64array]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). + +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, 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); + +// Create an offset view: +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out = iladlc( 'row-major', 2, 3, A1, 3 ); +// returns 1 +``` + +#### iladlc.ndarray( M, N, A, strideA1, strideA2, offsetA ) + +Returns the index of the last non-zero column in a matrix `A` using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); + +/* + A = [ + [ 1.0, 2.0, 0.0 ], + [ 3.0, 4.0, 0.0 ] + ] +*/ + +var out = iladlc.ndarray( 2, 3, A, 3, 1, 0 ); +// returns 1 +``` + +The function has the following parameters: + +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **A**: input [`Float64Array`][mdn-float64array]. +- **strideA1**: stride of the first dimension of `A`. +- **strideA2**: stride of 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, the offset parameter supports indexing semantics based on a starting index. For example, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 9999.0, 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); + +/* + A = [ + [ 1.0, 2.0, 0.0 ], + [ 3.0, 4.0, 0.0 ] + ] +*/ + +var out = iladlc.ndarray( 2, 3, A, 3, 1, 1 ); +// returns 1 +``` + +
+ + + +
+ +## Notes + +- This routine is commonly used throughout LAPACK to shrink work domains (e.g., before bulge-chasing, deflation, or when trimming Householder panels), thus ensuring that higher-level routines operate only on numerically relevant sub-matrices. +- `iladlc()` corresponds to the [LAPACK][lapack] routine [`iladlc`][lapack-iladlc]. + +
+ + + +
+ +## Examples + + + +```javascript +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var iladlc = require( '@stdlib/lapack/base/iladlc' ); + +var shape = [ 3, 3 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0, 5.0, 6.0, 0.0 ] ); +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var out = iladlc( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ] ); +console.log( out ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/iladlc/benchmark/benchmark.js new file mode 100644 index 000000000000..1d123579f1e9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/benchmark/benchmark.js @@ -0,0 +1,111 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 pkg = require( './../package.json' ).name; +var iladlc = require( './../lib/iladlc.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, 'float64' ); + 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++ ) { + A[ 0 ] = i; + z = iladlc( 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( pkg+'::square_matrix:order='+ord+',size='+(N*N), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlc/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..584f12bd7e37 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/benchmark/benchmark.ndarray.js @@ -0,0 +1,122 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 pkg = require( './../package.json' ).name; +var iladlc = 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, 'float64' ); + 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++ ) { + A[ 0 ] = i; + z = iladlc( 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( pkg+'::square_matrix:order='+ord+',size='+(N*N), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/iladlc/docs/repl.txt new file mode 100644 index 000000000000..6945e7c29f86 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/docs/repl.txt @@ -0,0 +1,81 @@ + +{{alias}}( order, M, N, A, LDA ) + Returns the index of the last non-zero column in a matrix `A`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If provided an empty matrix or a matrix containing only zeros, the function + returns `-1` (i.e., an invalid index). + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + A: Float64Array + Input matrix `A`. + + Returns + ------- + out: integer + Zero-based index of the last non-zero column. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 'row-major', 2, 2, A, 2 ) + 1 + + +{{alias}}.ndarray( M, N, A, strideA1, strideA2, offsetA ) + Returns the index of the last non-zero column in a matrix `A` using + alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + If provided an empty matrix or a matrix containing only zeros, the function + returns `-1` (i.e., an invalid index). + + Parameters + ---------- + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + A: Float64Array + Input matrix `A`. + + strideA1: integer + Stride of the first dimension of `A`. + + strideA2: integer + Stride of the second dimension of `A`. + + offsetA: integer + Starting index for `A`. + + Returns + ------- + out: integer + Zero-based index of the last non-zero column. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}.ndarray( 2, 2, A, 2, 1, 0 ) + 1 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/iladlc/docs/types/index.d.ts new file mode 100644 index 000000000000..b74c6859dc3d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/docs/types/index.d.ts @@ -0,0 +1,113 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 { Layout } from '@stdlib/types/blas'; + +/** +* Interface describing `iladlc`. +*/ +interface Routine { + /** + * Returns the index of the last non-zero column in a matrix `A`. + * + * ## Notes + * + * - If provided an empty matrix or a matrix containing only zeros, 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 index of the last non-zero column + * + * @example + * var Float64array = require( '@stdlib/array/float64' ); + * + * var A = new Float64array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 2.0, 0,0 ], [ 3.0, 4.0, 0.0 ] ] + * + * var out = iladlc( 'row-major', 2, 3, A, 3 ); + * // returns 1 + */ + ( order: Layout, M: number, N: number, A: Float64Array, LDA: number ): number; + + /** + * Returns the index of the last non-zero column in a matrix `A` using alternative indexing semantics. + * + * ## Notes + * + * - If provided an empty matrix or a matrix containing only zeros, the function returns `-1` (i.e., an invalid index). + * + * @param M - number of rows in `A` + * @param N - number of columns in `A` + * @param A - input matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @returns index of the last non-zero column + * + * @example + * var Float64array = require( '@stdlib/array/float64' ); + * + * var A = new Float64array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 2.0, 0,0 ], [ 3.0, 4.0, 0.0 ] ] + * + * var out = iladlc.ndarray( 2, 3, A, 3, 1, 0 ); + * // returns 1 + */ + ndarray( M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): number; +} + +/** +* Returns the index of the last non-zero column in a matrix `A`. +* +* ## Notes +* +* - If provided an empty matrix or a matrix containing only zeros, 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 index of the last non-zero column +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* +* var A = new Float64array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 2.0, 0,0 ], [ 3.0, 4.0, 0.0 ] ] +* +* var out = iladlc( 'row-major', 2, 3, A, 3 ); +* // returns 1 +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* +* var A = new Float64array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 2.0, 0,0 ], [ 3.0, 4.0, 0.0 ] ] +* +* var out = iladlc.ndarray( 2, 3, A, 3, 1, 0 ); +* // returns 1 +*/ +declare var iladlc: Routine; + + +// EXPORTS // + +export = iladlc; diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/iladlc/docs/types/test.ts new file mode 100644 index 000000000000..d75a38de80ea --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/docs/types/test.ts @@ -0,0 +1,213 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import iladlc = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const A = new Float64Array( 4 ); + + iladlc( '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 = new Float64Array( 4 ); + + iladlc( 5, 2, 2, A, 2 ); // $ExpectError + iladlc( true, 2, 2, A, 2 ); // $ExpectError + iladlc( false, 2, 2, A, 2 ); // $ExpectError + iladlc( null, 2, 2, A, 2 ); // $ExpectError + iladlc( void 0, 2, 2, A, 2 ); // $ExpectError + iladlc( [], 2, 2, A, 2 ); // $ExpectError + iladlc( {}, 2, 2, A, 2 ); // $ExpectError + iladlc( ( 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 = new Float64Array( 4 ); + + iladlc( 'row-major', '5', 2, A, 2 ); // $ExpectError + iladlc( 'row-major', true, 2, A, 2 ); // $ExpectError + iladlc( 'row-major', false, 2, A, 2 ); // $ExpectError + iladlc( 'row-major', null, 2, A, 2 ); // $ExpectError + iladlc( 'row-major', void 0, 2, A, 2 ); // $ExpectError + iladlc( 'row-major', [], 2, A, 2 ); // $ExpectError + iladlc( 'row-major', {}, 2, A, 2 ); // $ExpectError + iladlc( '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 = new Float64Array( 4 ); + + iladlc( 'row-major', 2, '5', A, 2 ); // $ExpectError + iladlc( 'row-major', 2, true, A, 2 ); // $ExpectError + iladlc( 'row-major', 2, false, A, 2 ); // $ExpectError + iladlc( 'row-major', 2, null, A, 2 ); // $ExpectError + iladlc( 'row-major', 2, void 0, A, 2 ); // $ExpectError + iladlc( 'row-major', 2, [], A, 2 ); // $ExpectError + iladlc( 'row-major', 2, {}, A, 2 ); // $ExpectError + iladlc( '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 Float64Array... +{ + iladlc( 'row-major', 2, 2, '5', 2 ); // $ExpectError + iladlc( 'row-major', 2, 2, 5, 2 ); // $ExpectError + iladlc( 'row-major', 2, 2, true, 2 ); // $ExpectError + iladlc( 'row-major', 2, 2, false, 2 ); // $ExpectError + iladlc( 'row-major', 2, 2, null, 2 ); // $ExpectError + iladlc( 'row-major', 2, 2, void 0, 2 ); // $ExpectError + iladlc( 'row-major', 2, 2, [], 2 ); // $ExpectError + iladlc( 'row-major', 2, 2, {}, 2 ); // $ExpectError + iladlc( '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 = new Float64Array( 4 ); + + iladlc( 'row-major', 2, 2, A, '5' ); // $ExpectError + iladlc( 'row-major', 2, 2, A, true ); // $ExpectError + iladlc( 'row-major', 2, 2, A, false ); // $ExpectError + iladlc( 'row-major', 2, 2, A, null ); // $ExpectError + iladlc( 'row-major', 2, 2, A, void 0 ); // $ExpectError + iladlc( 'row-major', 2, 2, A, [] ); // $ExpectError + iladlc( 'row-major', 2, 2, A, {} ); // $ExpectError + iladlc( '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 = new Float64Array( 4 ); + + iladlc(); // $ExpectError + iladlc( 'row-major' ); // $ExpectError + iladlc( 'row-major', 2 ); // $ExpectError + iladlc( 'row-major', 2, 2 ); // $ExpectError + iladlc( 'row-major', 2, 2, A ); // $ExpectError + iladlc( 'row-major', 2, 2, A, 2, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const A = new Float64Array( 4 ); + + iladlc.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 = new Float64Array( 4 ); + + iladlc.ndarray( '5', 2, A, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( true, 2, A, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( false, 2, A, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( null, 2, A, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( void 0, 2, A, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( [], 2, A, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( {}, 2, A, 2, 1, 0 ); // $ExpectError + iladlc.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 = new Float64Array( 4 ); + + iladlc.ndarray( 2, '5', A, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, true, A, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, false, A, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, null, A, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, void 0, A, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, [], A, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, {}, A, 2, 1, 0 ); // $ExpectError + iladlc.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 Float64Array... +{ + iladlc.ndarray( 2, 2, '5', 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, 5, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, true, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, false, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, null, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, void 0, 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, [], 2, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, {}, 2, 1, 0 ); // $ExpectError + iladlc.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 = new Float64Array( 4 ); + + iladlc.ndarray( 2, 2, A, '5', 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, true, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, false, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, null, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, void 0, 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, [], 1, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, {}, 1, 0 ); // $ExpectError + iladlc.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 = new Float64Array( 4 ); + + iladlc.ndarray( 2, 2, A, 2, '5', 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, true, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, false, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, null, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, void 0, 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, [], 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, {}, 0 ); // $ExpectError + iladlc.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 = new Float64Array( 4 ); + + iladlc.ndarray( 2, 2, A, 2, 1, '5' ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, 1, true ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, 1, false ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, 1, null ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, 1, void 0 ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, 1, [] ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, 1, {} ); // $ExpectError + iladlc.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 = new Float64Array( 4 ); + + iladlc.ndarray(); // $ExpectError + iladlc.ndarray( 2 ); // $ExpectError + iladlc.ndarray( 2, 2 ); // $ExpectError + iladlc.ndarray( 2, 2, A ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2 ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, 1 ); // $ExpectError + iladlc.ndarray( 2, 2, A, 2, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/examples/index.js b/lib/node_modules/@stdlib/lapack/base/iladlc/examples/index.js new file mode 100644 index 000000000000..38ed4505cdf5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/examples/index.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Float64Array = require( '@stdlib/array/float64' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var iladlc = require( './../lib' ); + +var shape = [ 3, 3 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var A = new Float64Array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0, 5.0, 6.0, 0.0 ] ); +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var out = iladlc( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ] ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/lib/base.js b/lib/node_modules/@stdlib/lapack/base/iladlc/lib/base.js new file mode 100644 index 000000000000..9971bd25d8ba --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/lib/base.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 iladlr = require( '@stdlib/lapack/base/iladlr' ).ndarray; + + +// MAIN // + +/** +* Returns the index of the last non-zero column in a matrix `A`. +* +* ## Notes +* +* - If provided an empty matrix or a matrix containing only zeros, the function returns `-1` (i.e., an invalid index). +* +* @private +* @param {PositiveInteger} M - number of rows in `A` +* @param {PositiveInteger} N - number of columns in `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - index offset for `A` +* @returns {integer} index of the last non-zero column +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* +* var A = new Float64array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 2.0, 0.0 ], [ 3.0, 4.0, 0.0 ] ] +* +* var out = iladlc( 2, 3, A, 3, 1, 0 ); +* // returns 1 +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* +* var A = new Float64array( [ 1.0, 3.0, 2.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0, 0.0 ], [ 3.0, 4.0, 0.0 ] ] +* +* var out = iladlc( 2, 3, A, 1, 2, 0 ); +* // returns 1 +*/ +function iladlc( M, N, A, strideA1, strideA2, offsetA ) { + return iladlr( N, M, A, strideA2, strideA1, offsetA ); +} + + +// EXPORTS // + +module.exports = iladlc; diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/lib/iladlc.js b/lib/node_modules/@stdlib/lapack/base/iladlc/lib/iladlc.js new file mode 100644 index 000000000000..3231fe0d57a9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/lib/iladlc.js @@ -0,0 +1,85 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 base = require( './base.js' ); + + +// MAIN // + +/** +* Returns the index of the last non-zero column in a matrix `A`. +* +* ## Notes +* +* - If provided an empty matrix or a matrix containing only zeros, 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 {Float64Array} 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} index of the last non-zero column +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* +* var A = new Float64array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 2.0, 0.0 ], [ 3.0, 4.0, 0.0 ] ] +* +* var out = iladlc( 'row-major', 2, 3, A, 3 ); +* // returns 1 +*/ +function iladlc( 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 base( M, N, A, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = iladlc; diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/lib/index.js b/lib/node_modules/@stdlib/lapack/base/iladlc/lib/index.js new file mode 100644 index 000000000000..b5618f0794e2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/lib/index.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* LAPACK routine to find the index of the last non-zero column in a input matrix. +* +* @module @stdlib/lapack/base/iladlc +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* var iladlc = require( '@stdlib/lapack/base/iladlc' ); +* +* var A = new Float64array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 2.0, 0.0 ], [ 3.0, 4.0, 0.0 ] ] +* +* var out = iladlc( 'row-major', 2, 3, A, 3 ); +* // returns 1 +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var iladlc; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + iladlc = main; +} else { + iladlc = tmp; +} + + +// EXPORTS // + +module.exports = iladlc; diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/lib/main.js b/lib/node_modules/@stdlib/lapack/base/iladlc/lib/main.js new file mode 100644 index 000000000000..f97d6f686359 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var iladlc = require( './iladlc.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( iladlc, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = iladlc; diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlc/lib/ndarray.js new file mode 100644 index 000000000000..06351fbd120c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/lib/ndarray.js @@ -0,0 +1,58 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Finds the index of the last non-zero column in a matrix `A` using alternative indexing semantics. +* +* ## Notes +* +* - If provided an empty matrix or a matrix containing only zeros, 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 {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - index offset for `A` +* @returns {integer} index of the last non-zero column +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* +* var A = new Float64array( [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ] ); // => [ [ 1.0, 2.0, 0.0 ], [ 3.0, 4.0, 0.0 ] ] +* +* var out = iladlc( 2, 3, A, 3, 1, 0 ); +* // returns 1 +*/ +function iladlc( M, N, A, strideA1, strideA2, offsetA ) { + return base( M, N, A, strideA1, strideA2, offsetA ); +} + + +// EXPORTS // + +module.exports = iladlc; diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/package.json b/lib/node_modules/@stdlib/lapack/base/iladlc/package.json new file mode 100644 index 000000000000..31ae84a7411f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/lapack/base/iladlc", + "version": "0.0.0", + "description": "LAPACK routine to find the index of the last non-zero column in a input matrix.", + "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", + "stdmath", + "mathematics", + "math", + "lapack", + "iladlc", + "last", + "column", + "index", + "matrix", + "auxilary", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/column_major.json new file mode 100644 index 000000000000..75b1e74f3f39 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/column_major.json @@ -0,0 +1,15 @@ +{ + "order": "column-major", + "A": [ 1.0, 4.0, 2.0, 1.0, 0.0, 0.0 ], + "M": 2, + "N": 3, + "strideA1": 1, + "strideA2": 2, + "offsetA": 0, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0, 0.0 ], + [ 4.0, 1.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/column_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/column_major_zeros.json new file mode 100644 index 000000000000..f480814443be --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/column_major_zeros.json @@ -0,0 +1,15 @@ +{ + "order": "column-major", + "A": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "M": 2, + "N": 3, + "strideA1": 1, + "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/lapack/base/iladlc/test/fixtures/large_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/large_strides/column_major.json new file mode 100644 index 000000000000..f75917461c24 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/large_strides/column_major.json @@ -0,0 +1,28 @@ +{ + "order": "column-major", + "A": [ + 1.0, + 9999.0, + 4.0, + 9999.0, + 2.0, + 9999.0, + 1.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "M": 2, + "N": 3, + "strideA1": 2, + "strideA2": 4, + "offsetA": 0, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0, 0.0 ], + [ 4.0, 1.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/large_strides/column_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/large_strides/column_major_zeros.json new file mode 100644 index 000000000000..a5832e296c80 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/large_strides/column_major_zeros.json @@ -0,0 +1,28 @@ +{ + "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": 2, + "N": 3, + "strideA1": 2, + "strideA2": 4, + "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/lapack/base/iladlc/test/fixtures/large_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/large_strides/row_major.json new file mode 100644 index 000000000000..9f679c20e503 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/large_strides/row_major.json @@ -0,0 +1,28 @@ +{ + "order": "row-major", + "A": [ + 1.0, + 9999.0, + 2.0, + 9999.0, + 0.0, + 9999.0, + 4.0, + 9999.0, + 1.0, + 9999.0, + 0.0, + 9999.0 + ], + "M": 2, + "N": 3, + "strideA1": 6, + "strideA2": 2, + "offsetA": 0, + "LDA": 3, + "A_mat": [ + [ 1.0, 2.0, 0.0 ], + [ 4.0, 1.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/large_strides/row_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/large_strides/row_major_zeros.json new file mode 100644 index 000000000000..a4600f4cc890 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/large_strides/row_major_zeros.json @@ -0,0 +1,28 @@ +{ + "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": 2, + "N": 3, + "strideA1": 6, + "strideA2": 2, + "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/lapack/base/iladlc/test/fixtures/mixed_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/mixed_strides/column_major.json new file mode 100644 index 000000000000..6255823ae44a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/mixed_strides/column_major.json @@ -0,0 +1,22 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 0.0, + 2.0, + 1.0, + 1.0, + 4.0 + ], + "M": 2, + "N": 3, + "strideA1": 1, + "strideA2": -2, + "offsetA": 4, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0, 0.0 ], + [ 4.0, 1.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/mixed_strides/column_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/mixed_strides/column_major_zeros.json new file mode 100644 index 000000000000..8d10b99a7f59 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/mixed_strides/column_major_zeros.json @@ -0,0 +1,22 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 2, + "N": 3, + "strideA1": 1, + "strideA2": -2, + "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/lapack/base/iladlc/test/fixtures/mixed_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/mixed_strides/row_major.json new file mode 100644 index 000000000000..2a5419a31eb2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/mixed_strides/row_major.json @@ -0,0 +1,22 @@ +{ + "order": "row-major", + "A": [ + 4.0, + 1.0, + 0.0, + 1.0, + 2.0, + 0.0 + ], + "M": 2, + "N": 3, + "strideA1": -3, + "strideA2": 1, + "offsetA": 3, + "LDA": 3, + "A_mat": [ + [ 1.0, 2.0, 0.0 ], + [ 4.0, 1.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/mixed_strides/row_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/mixed_strides/row_major_zeros.json new file mode 100644 index 000000000000..99450022d8cc --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/mixed_strides/row_major_zeros.json @@ -0,0 +1,22 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 2, + "N": 3, + "strideA1": -3, + "strideA2": 1, + "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/lapack/base/iladlc/test/fixtures/negative_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/negative_strides/column_major.json new file mode 100644 index 000000000000..62e842441497 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/negative_strides/column_major.json @@ -0,0 +1,22 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 0.0, + 1.0, + 2.0, + 4.0, + 1.0 + ], + "M": 2, + "N": 3, + "strideA1": -1, + "strideA2": -2, + "offsetA": 5, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0, 0.0 ], + [ 4.0, 1.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/negative_strides/column_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/negative_strides/column_major_zeros.json new file mode 100644 index 000000000000..1123e8d1b252 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/negative_strides/column_major_zeros.json @@ -0,0 +1,22 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 2, + "N": 3, + "strideA1": -1, + "strideA2": -2, + "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/lapack/base/iladlc/test/fixtures/negative_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/negative_strides/row_major.json new file mode 100644 index 000000000000..50dec8496a73 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/negative_strides/row_major.json @@ -0,0 +1,22 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 1.0, + 4.0, + 0.0, + 2.0, + 1.0 + ], + "M": 2, + "N": 3, + "strideA1": -3, + "strideA2": -1, + "offsetA": 5, + "LDA": 3, + "A_mat": [ + [ 1.0, 2.0, 0.0 ], + [ 4.0, 1.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/negative_strides/row_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/negative_strides/row_major_zeros.json new file mode 100644 index 000000000000..8525dd854700 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/negative_strides/row_major_zeros.json @@ -0,0 +1,22 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 2, + "N": 3, + "strideA1": -3, + "strideA2": -1, + "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/lapack/base/iladlc/test/fixtures/offsets/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/offsets/column_major.json new file mode 100644 index 000000000000..eff5c767d2c7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/offsets/column_major.json @@ -0,0 +1,23 @@ +{ + "order": "column-major", + "A": [ + 9999.0, + 1.0, + 4.0, + 2.0, + 1.0, + 0.0, + 0.0 + ], + "M": 2, + "N": 3, + "strideA1": 1, + "strideA2": 2, + "offsetA": 1, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0, 0.0 ], + [ 4.0, 1.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/offsets/column_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/offsets/column_major_zeros.json new file mode 100644 index 000000000000..b544ba368326 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/offsets/column_major_zeros.json @@ -0,0 +1,23 @@ +{ + "order": "column-major", + "A": [ + 9999.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 2, + "N": 3, + "strideA1": 1, + "strideA2": 2, + "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/lapack/base/iladlc/test/fixtures/offsets/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/offsets/row_major.json new file mode 100644 index 000000000000..a711dc2ce270 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/offsets/row_major.json @@ -0,0 +1,23 @@ +{ + "order": "row-major", + "A": [ + 9999.0, + 1.0, + 2.0, + 0.0, + 4.0, + 1.0, + 0.0 + ], + "M": 2, + "N": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 1, + "LDA": 3, + "A_mat": [ + [ 1.0, 2.0, 0.0 ], + [ 4.0, 1.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/offsets/row_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/offsets/row_major_zeros.json new file mode 100644 index 000000000000..0beb43f62a9f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/offsets/row_major_zeros.json @@ -0,0 +1,23 @@ +{ + "order": "row-major", + "A": [ + 9999.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 2, + "N": 3, + "strideA1": 3, + "strideA2": 1, + "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/lapack/base/iladlc/test/fixtures/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/row_major.json new file mode 100644 index 000000000000..820ab2f8010c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/row_major.json @@ -0,0 +1,15 @@ +{ + "order": "row-major", + "A": [ 1.0, 2.0, 0.0, 4.0, 1.0, 0.0 ], + "M": 2, + "N": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "LDA": 3, + "A_mat": [ + [ 1.0, 2.0, 0.0 ], + [ 4.0, 1.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/row_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/row_major_zeros.json new file mode 100644 index 000000000000..aaafc221b206 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/fixtures/row_major_zeros.json @@ -0,0 +1,15 @@ +{ + "order": "row-major", + "A": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "M": 2, + "N": 3, + "strideA1": 3, + "strideA2": 1, + "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/lapack/base/iladlc/test/test.iladlc.js b/lib/node_modules/@stdlib/lapack/base/iladlc/test/test.iladlc.js new file mode 100644 index 000000000000..5abceac2236d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/test.iladlc.js @@ -0,0 +1,223 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var iladlc = require( './../lib/iladlc.js' ); + + +// FIXTURES // + +var ROW_MAJOR_DATA = require( './fixtures/row_major.json' ); +var ROW_MAJOR_ZEROS = require( './fixtures/row_major_zeros.json' ); +var COLUMN_MAJOR_DATA = require( './fixtures/column_major.json' ); +var COLUMN_MAJOR_ZEROS = require( './fixtures/column_major_zeros.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof iladlc, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( iladlc.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 A; + var i; + + data = ROW_MAJOR_DATA; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( data.A ); + + 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() { + iladlc( value, data.M, data.N, 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 A; + var i; + + data = ROW_MAJOR_DATA; + + values = [ + 0, + 1 + ]; + + A = new Float64Array( data.A ); + + 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() { + iladlc( data.order, data.M, data.N, 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 A; + var i; + + data = COLUMN_MAJOR_DATA; + + values = [ + 0, + 1 + ]; + + A = new Float64Array( data.A ); + + 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() { + iladlc( data.order, data.M, data.N, A, value ); + }; + } +}); + +tape( 'the function returns an invalid index (-1) when M is less than or equal to zero', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlc( data.order, 0, data.N, A, data.LDA ); + + t.deepEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when N is less than or equal to zero', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlc( data.order, data.M, 0, A, data.LDA ); + + t.deepEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero-based index of the last non-zero column of a matrix (row-major)', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlc( data.order, data.M, data.N, A, data.LDA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero-based index of the last non-zero column of a matrix (column-major)', function test( t ) { + var data; + var out; + var A; + + data = COLUMN_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlc( data.order, data.M, data.N, A, data.LDA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major)', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlc( data.order, data.M, data.N, A, data.LDA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major)', function test( t ) { + var data; + var out; + var A; + + data = COLUMN_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlc( data.order, data.M, data.N, A, data.LDA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/test.js b/lib/node_modules/@stdlib/lapack/base/iladlc/test/test.js new file mode 100644 index 000000000000..1d911d3b6b33 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var iladlc = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof iladlc, '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 iladlc.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var iladlc = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( iladlc, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var iladlc; + var main; + + main = require( './../lib/iladlc.js' ); + + iladlc = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( iladlc, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlc/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlc/test/test.ndarray.js new file mode 100644 index 000000000000..677173508ae2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlc/test/test.ndarray.js @@ -0,0 +1,349 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Float64Array = require( '@stdlib/array/float64' ); +var iladlr = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var ROW_MAJOR_DATA = require( './fixtures/row_major.json' ); +var ROW_MAJOR_ZEROS = require( './fixtures/row_major_zeros.json' ); +var COLUMN_MAJOR_DATA = require( './fixtures/column_major.json' ); +var COLUMN_MAJOR_ZEROS = require( './fixtures/column_major_zeros.json' ); + +var OFFSET_ROW_MAJOR_DATA = require( './fixtures/offsets/row_major.json' ); +var OFFSET_ROW_MAJOR_ZEROS = require( './fixtures/offsets/row_major_zeros.json' ); +var OFFSET_COLUMN_MAJOR_DATA = require( './fixtures/offsets/column_major.json' ); +var OFFSET_COLUMN_MAJOR_ZEROS = require( './fixtures/offsets/column_major_zeros.json' ); + +var NEGATIVE_STRIDES_ROW_MAJOR_DATA = require( './fixtures/negative_strides/row_major.json' ); +var NEGATIVE_STRIDES_ROW_MAJOR_ZEROS = require( './fixtures/negative_strides/row_major_zeros.json' ); +var NEGATIVE_STRIDES_COLUMN_MAJOR_DATA = require( './fixtures/negative_strides/column_major.json' ); +var NEGATIVE_STRIDES_COLUMN_MAJOR_ZEROS = require( './fixtures/negative_strides/column_major_zeros.json' ); + +var MIXED_STRIDES_ROW_MAJOR_DATA = require( './fixtures/mixed_strides/row_major.json' ); +var MIXED_STRIDES_ROW_MAJOR_ZEROS = require( './fixtures/mixed_strides/row_major_zeros.json' ); +var MIXED_STRIDES_COLUMN_MAJOR_DATA = require( './fixtures/mixed_strides/column_major.json' ); +var MIXED_STRIDES_COLUMN_MAJOR_ZEROS = require( './fixtures/mixed_strides/column_major_zeros.json' ); + +var LARGE_STRIDES_ROW_MAJOR_DATA = require( './fixtures/large_strides/row_major.json' ); +var LARGE_STRIDES_ROW_MAJOR_ZEROS = require( './fixtures/large_strides/row_major_zeros.json' ); +var LARGE_STRIDES_COLUMN_MAJOR_DATA = require( './fixtures/large_strides/column_major.json' ); +var LARGE_STRIDES_COLUMN_MAJOR_ZEROS = require( './fixtures/large_strides/column_major_zeros.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof iladlr, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( iladlr.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero-based index of the last non-zero column of a matrix (row-major)', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero-based index of the last non-zero column of a matrix (column-major)', function test( t ) { + var data; + var out; + var A; + + data = COLUMN_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major)', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major)', function test( t ) { + var data; + var out; + var A; + + data = COLUMN_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero-based index of the last non-zero column of a matrix (row-major) (offsets)', function test( t ) { + var data; + var out; + var A; + + data = OFFSET_ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero-based index of the last non-zero column of a matrix (column-major) (offsets)', function test( t ) { + var data; + var out; + var A; + + data = OFFSET_COLUMN_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major) (offsets)', function test( t ) { + var data; + var out; + var A; + + data = OFFSET_ROW_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major) (offsets)', function test( t ) { + var data; + var out; + var A; + + data = OFFSET_COLUMN_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero-based index of the last non-zero column of a matrix (row-major) (mixed strides)', function test( t ) { + var data; + var out; + var A; + + data = MIXED_STRIDES_ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero-based index of the last non-zero column of a matrix (column-major) (mixed strides)', function test( t ) { + var data; + var out; + var A; + + data = MIXED_STRIDES_COLUMN_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major) (mixed strides)', function test( t ) { + var data; + var out; + var A; + + data = MIXED_STRIDES_ROW_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major) (mixed strides)', function test( t ) { + var data; + var out; + var A; + + data = MIXED_STRIDES_COLUMN_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero-based index of the last non-zero column of a matrix (row-major) (negative strides)', function test( t ) { + var data; + var out; + var A; + + data = NEGATIVE_STRIDES_ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero-based index of the last non-zero column of a matrix (column-major) (negative strides)', function test( t ) { + var data; + var out; + var A; + + data = NEGATIVE_STRIDES_COLUMN_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major) (negative strides)', function test( t ) { + var data; + var out; + var A; + + data = NEGATIVE_STRIDES_ROW_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major) (negative strides)', function test( t ) { + var data; + var out; + var A; + + data = NEGATIVE_STRIDES_COLUMN_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero-based index of the last non-zero column of a matrix (row-major) (large strides)', function test( t ) { + var data; + var out; + var A; + + data = LARGE_STRIDES_ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero-based index of the last non-zero column of a matrix (column-major) (large strides)', function test( t ) { + var data; + var out; + var A; + + data = LARGE_STRIDES_COLUMN_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major) (large strides)', function test( t ) { + var data; + var out; + var A; + + data = LARGE_STRIDES_ROW_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major) (large strides)', function test( t ) { + var data; + var out; + var A; + + data = LARGE_STRIDES_COLUMN_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +});