diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/README.md b/lib/node_modules/@stdlib/lapack/base/dlauu2/README.md new file mode 100644 index 000000000000..19905be8a529 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/README.md @@ -0,0 +1,234 @@ + + +# dlauu2 + +> Compute the product `U*U^T` or `L^T*L`, where the triangular factor `U` or `L` is stored in the upper or lower triangular part of array `A`. + +
+ +## Usage + +```javascript +var dlauu2 = require( '@stdlib/lapack/base/dlauu2' ); +``` + +#### dlauu2( order, uplo, N, A, LDA ) + +Computes the product `U*U^T` or `L^T*L`, where the triangular factor `U` or `L` is stored in the upper or lower triangular part of array `A`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var out = dlauu2( 'row-major', 'upper', 2, A, 2 ); +// returns 0 +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A`. +- **N**: order of triangular factor `U` or `L`. +- **A**: input `Float64Array` containing the triangular factor `U` or `L`. +- **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 arrays... +var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); + +// Create offset views... +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dlauu2( 'row-major', 'upper', 2, A1, 2 ); +// A0 => [ 0.0, 5.0, 8.0, 3.0, 16.0 ] +``` + +#### dlauu2.ndarray( uplo, N, A, strideA1, strideA2, offsetA ) + +Computes the product `U*U^T` or `L^T*L`, where the triangular factor `U` or `L` is stored in the upper or lower triangular part of array `A` using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var out = dlauu2.ndarray( 'upper', 2, A, 2, 1, 0 ); +// returns 0 +``` + +The function has the following additional parameters: + +- **order**: storage layout. +- **uplo**: specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A`. +- **N**: order of triangular factor `U` or `L`. +- **A**: input `Float64Array` containing the triangular factor `U` or `L`. +- **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 parameters support indexing semantics based on starting indices. For example, + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +var out = dlauu2.ndarray( 'upper', 2, A, 2, 1, 1 ); +// returns 0 +``` + +
+ + + +
+ +## Notes + +- Both functions mutate the input array `A`. + +- Both functions return a status code indicating success or failure. A status code indicates the following conditions: + + - `0`: successful exit. + - `<0`: the k-th argument had an illegal value, where `-k` equals the status code value. + +- `dlauu2()` corresponds to the [LAPACK][LAPACK] routine [`dlauu2`][lapack-dlauu2]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dlauu2 = require( '@stdlib/lapack/base/dlauu2' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +dlauu2( 'row-major', 'upper', 2, A, 2 ); +console.log( 'A: ', A ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlauu2/benchmark/benchmark.js new file mode 100644 index 000000000000..3a5330dc9a83 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/benchmark/benchmark.js @@ -0,0 +1,99 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 floor = require( '@stdlib/math/base/special/floor' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dlauu2 = require( './../lib/dlauu2.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var N = floor( pow( len, 0.5 ) ); + var M = floor( N / 2 ); + var A = uniform( M * N, 0.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dlauu2( 'row-major', 'upper', M, A, N ); + if ( isnan( d ) || isnan( A[i%A.length] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d ) || isnan( A[i%A.length] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':order=row-major,len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlauu2/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..f902bcfd4937 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/benchmark/benchmark.ndarray.js @@ -0,0 +1,99 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 floor = require( '@stdlib/math/base/special/floor' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dlauu2 = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var N = floor( pow( len, 0.5 ) ); + var M = floor( N / 2 ); + var A = uniform( M * N, 0.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dlauu2( 'upper', M, A, N, 1, 0 ); + if ( isnan( d ) || isnan( A[i%A.length] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d ) || isnan( A[i%A.length] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':ndarray:order=row-major,len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlauu2/docs/repl.txt new file mode 100644 index 000000000000..b570f29fade5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/docs/repl.txt @@ -0,0 +1,98 @@ + +{{alias}}( order, uplo, N, A, LDA ) + Computes the product `U*U^T` or `L^T*L`, where the triangular factor `U` or + `L` is stored in the upper or lower triangular part of array `A`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + The function mutates `A`. + + Parameters + ---------- + order: string + Storage layout. + + uplo: string + Specifies whether to copy the upper or lower triangular/trapezoidal + part of matrix `A`. + + N: integer + Order of triangular factor `U` or `L`. + + A: Float64Array + Input array. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + Returns + ------- + info: integer + Status code. The status code indicates the following conditions: + + - if equal to zero, then the operation was successful. + - if less than zero, then the k-th argument had an illegal value, where + `k = -info`. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 'row-major', 'upper', 2, A, 2 ) + 0 + > A + [ 5.0, 8.0, 3.0, 16.0 ] + + +{{alias}}.ndarray( uplo, N, A, strideA1, strideA2, offsetA ) + Computes the product `U*U^T` or `L^T*L`, where the triangular factor `U` + or `L` is stored in the upper or lower triangular part of array `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. + + The function mutates both `D` and `E`. + + Parameters + ---------- + uplo: string + Specifies whether to copy the upper or lower triangular/trapezoidal + part of matrix `A`. + + N: integer + Order of triangular factor `U` or `L`. + + A: Float64Array + Input array. + + 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 + ------- + info: integer + Status code. The status code indicates the following conditions: + + - if equal to zero, then the operation was successful. + - if less than zero, then the k-th argument had an illegal value, where + `k = -info`. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}.ndarray( 'upper', 2, A, 2, 1, 1 ) + 0 + > A + [ 0.0, 5.0, 8.0, 3.0, 16.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlauu2/docs/types/index.d.ts new file mode 100644 index 000000000000..1323f563144e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/docs/types/index.d.ts @@ -0,0 +1,98 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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, MatrixTriangle } from '@stdlib/types/blas'; + +/** +* Interface describing `dlauu2`. +*/ +interface Routine { + /** + * Computes the product `U*U^T` or `L^T*L`, where the triangular factor `U` or `L` is stored in the upper or lower triangular part of array `A`. + * + * @param order - storage layout + * @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` + * @param N - order of triangular factor `U` or `L`. + * @param A - input array + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var out = dlauu2( 'row-major', 'upper', 2, A, 2 ); + * // returns 0 + */ + ( order: Layout, uplo: MatrixTriangle, N: number, A: Float64Array, LDA: number ): number; + + /** + * Computes the product `U*U^T` or `L^T*L`, where the triangular factor `U` or `L` is stored in the upper or lower triangular part of array `A` using alternative indexing semantics. + * + * @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` + * @param N - order of triangular factor `U` or `L`. + * @param A - input array + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index for `A` + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var out = dlauu2.ndarray( 'upper', 2, A, 2, 1, 0 ); + * // returns 0 + */ + ndarray( uplo: MatrixTriangle, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): number; +} + +/** +* Computes the product `U*U^T` or `L^T*L`, where the triangular factor `U` or `L` is stored in the upper or lower triangular part of array `A`. +* +* @param order - storage layout +* @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param N - order of triangular factor `U` or `L`. +* @param A - input array +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @returns status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var out = dlauu2( 'row-major', 'upper', 2, A, 2 ); +* // returns 0 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var out = dlauu2.ndarray( 'upper', 2, A, 2, 1, 0 ); +* // returns 0 +*/ +declare var dlauu2: Routine; + + +// EXPORTS // + +export = dlauu2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlauu2/docs/types/test.ts new file mode 100644 index 000000000000..39174f7dcc43 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/docs/types/test.ts @@ -0,0 +1,215 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dlauu2 = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2( 'row-major', 'upper', 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2( 5, 'upper', 2, A, 2 ); // $ExpectError + dlauu2( true, 'upper', 2, A, 2 ); // $ExpectError + dlauu2( false, 'upper', 2, A, 2 ); // $ExpectError + dlauu2( null, 'upper', 2, A, 2 ); // $ExpectError + dlauu2( void 0, 'upper', 2, A, 2 ); // $ExpectError + dlauu2( [], 'upper', 2, A, 2 ); // $ExpectError + dlauu2( {}, 'upper', 2, A, 2 ); // $ExpectError + dlauu2( ( x: number ): number => x, 'upper', 2, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2( 'row-major', 5, 2, A, 2 ); // $ExpectError + dlauu2( 'row-major', true, 2, A, 2 ); // $ExpectError + dlauu2( 'row-major', false, 2, A, 2 ); // $ExpectError + dlauu2( 'row-major', null, 2, A, 2 ); // $ExpectError + dlauu2( 'row-major', void 0, 2, A, 2 ); // $ExpectError + dlauu2( 'row-major', [], 2, A, 2 ); // $ExpectError + dlauu2( 'row-major', {}, 2, A, 2 ); // $ExpectError + dlauu2( '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( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2( 'row-major', 'upper', '5', A, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', true, A, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', false, A, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', null, A, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', void 0, A, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', [], A, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', {}, A, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', ( 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... +{ + + dlauu2( 'row-major', 'upper', 2, '5', 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, 5, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, true, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, false, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, null, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, void 0, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, [], 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, {}, 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2( 'row-major', 'upper', 2, A, '5' ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, A, true ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, A, false ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, A, null ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, A, void 0 ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, A, [] ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, A, {} ); // $ExpectError + dlauu2( 'row-major', 'upper', 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2(); // $ExpectError + dlauu2( 'row-major' ); // $ExpectError + dlauu2( 'row-major', 'upper' ); // $ExpectError + dlauu2( 'row-major', 'upper', 2 ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, A ); // $ExpectError + dlauu2( 'row-major', 'upper', 2, A, 2, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2.ndarray( 'upper', 2, A, 2, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2.ndarray( 5, 2, A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( true, 2, A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( false, 2, A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( null, 2, A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( void 0, 2, A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( [], 2, A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( {}, 2, A, 2, 1, 0 ); // $ExpectError + dlauu2.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( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2.ndarray( 'upper', '5', A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', true, A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', false, A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', null, A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', void 0, A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', [], A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', {}, A, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', ( 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... +{ + + dlauu2.ndarray( 'upper', 2, '5', 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, 5, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, true, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, false, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, null, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, void 0, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, [], 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, {}, 2, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2.ndarray( 'upper', 2, A, '5', 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, true, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, false, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, null, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, void 0, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, [], 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, {}, 1, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2.ndarray( 'upper', 2, A, 2, '5', 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, true, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, false, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, null, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, void 0, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, [], 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, {}, 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2.ndarray( 'upper', 2, A, 2, 1, '5' ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, 1, true ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, 1, false ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, 1, null ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, 1, void 0 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, 1, [] ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, 1, {} ); // $ExpectError + dlauu2.ndarray( 'upper', 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlauu2.ndarray(); // $ExpectError + dlauu2.ndarray( 'upper' ); // $ExpectError + dlauu2.ndarray( 'upper', 2 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, 1 ); // $ExpectError + dlauu2.ndarray( 'upper', 2, A, 2, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlauu2/examples/index.js new file mode 100644 index 000000000000..79cccfbe5a4e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/examples/index.js @@ -0,0 +1,26 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 Float64Array = require( '@stdlib/array/float64' ); +var dlauu2 = require( './../lib' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +dlauu2( 'row-major', 'upper', 2, A, 2 ); +console.log( 'A: ', A ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/base.js new file mode 100644 index 000000000000..c44381df5460 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/base.js @@ -0,0 +1,114 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var dgemv = require( '@stdlib/blas/base/dgemv' ).ndarray; +var dscal = require( '@stdlib/blas/base/dscal' ).ndarray; +var ddot = require( '@stdlib/blas/base/ddot' ).ndarray; + + +// MAIN // + +/** +* Computes the product `U*U^T` or `L^T*L`, where the triangular factor `U` or `L` is stored in the upper or lower triangular part of array `A`. +* +* @private +* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {NonNegativeInteger} N - order of triangular factor `U` or `L`. +* @param {Float64Array} A - input array +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var out = dlauu2( 'upper', 2, A, 2, 1, 0 ); +* // returns 0 +*/ +function dlauu2( uplo, N, A, strideA1, strideA2, offsetA ) { + var aii; + var i; + + // Quick return if possible + if ( N === 0 ) { + return 0; + } + if ( uplo === 'upper' ) { + // Compute the product U*U^T. + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i = 0; i < N; i++ ) { + aii = A[ offsetA + ( i * strideA1 ) + ( i * strideA2 ) ]; + if ( i < N - 1 ) { + A[ offsetA + ( i * strideA1 ) + ( i * strideA2 ) ] = ddot( N - i, A, strideA2, offsetA + ( i * strideA1 ) + ( i * strideA2 ), A, strideA2, offsetA + ( i * strideA1 ) + ( i * strideA2 ) ); + dgemv( 'no-transpose', i, N - i - 1, 1.0, A, strideA1, strideA2, offsetA + ( ( i + 1 ) * strideA2 ), A, strideA2, offsetA + ( ( i + 1 ) * strideA2 ) + ( i * strideA1 ), aii, A, strideA1, offsetA + ( i * strideA2 ) ); + } else { + dscal( i + 1, aii, A, strideA1, offsetA + ( i * strideA2 ) ); + } + } + return 0; + } + // column-major + for ( i = 0; i < N; i++ ) { + aii = A[ offsetA + ( i * strideA1 ) + ( i * strideA2 ) ]; + if ( i < N - 1 ) { + A[ offsetA + ( i * strideA1 ) + ( i * strideA2 ) ] = ddot( N - i, A, strideA2, offsetA + ( i * strideA1 ) + ( i * strideA2 ), A, strideA2, offsetA + ( i * strideA1 ) + ( i * strideA2 ) ); + dgemv( 'no-transpose', i, N - i - 1, 1.0, A, strideA1, strideA2, offsetA + ( ( i + 1 ) * strideA1 ), A, strideA1, offsetA + ( ( i + 1 ) * strideA1 ) + ( i * strideA2 ), aii, A, strideA2, offsetA + ( i * strideA1 ) ); + } else { + dscal( i + 1, aii, A, strideA1, offsetA + ( i * strideA2 ) ); + } + } + return 0; + } + // Lower + // Compute the product L^T*L. + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for (i = 0; i < N; i++ ) { + aii = A[ offsetA + ( i * strideA1 ) + ( i * strideA2 ) ]; + if ( i < N - 1 ) { + A[ offsetA + ( i * strideA1 ) + ( i * strideA2 ) ] = ddot( N - i, A, strideA1, offsetA + ( i * strideA1 ) + ( i * strideA2 ), A, strideA1, offsetA + ( i * strideA1 ) + ( i * strideA2 ) ); + dgemv( 'transpose', N - i - 1, i, 1.0, A, strideA1, strideA2, offsetA + ( ( i + 1 ) * strideA1 ), A, strideA1, offsetA + ( i * strideA2 ) + ( ( i + 1 ) * strideA1 ), aii, A, strideA2, offsetA + ( i * strideA1 ) ); + } else { + dscal( i + 1, aii, A, strideA2, offsetA + ( i * strideA1 ) ); + } + } + return 0; + } + // column-major + for (i = 0; i < N; i++ ) { + aii = A[ offsetA + ( i * strideA2 ) + ( i * strideA1 ) ]; + if ( i < N - 1 ) { + A[ offsetA + ( i * strideA2 ) + ( i * strideA1 ) ] = ddot( N - i, A, strideA1, offsetA + ( i * strideA2 ) + ( i * strideA1 ), A, strideA1, offsetA + ( i * strideA2 ) + ( i * strideA1 ) ); + dgemv( 'transpose', N - i - 1, i, 1.0, A, strideA1, strideA2, offsetA + ( ( i + 1 ) * strideA1 ), A, strideA1, offsetA + ( i * strideA2 ) + ( ( i + 1 ) * strideA1 ), aii, A, strideA2, offsetA + ( i * strideA1 ) ); + } else { + dscal( i + 1, aii, A, strideA2, offsetA + ( i * strideA1 ) ); + } + } + return 0; +} + + +// EXPORTS // + +module.exports = dlauu2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/dlauu2.js b/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/dlauu2.js new file mode 100644 index 000000000000..84b336a6668f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/dlauu2.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the product `U*U^T` or `L^T*L`, where the triangular factor `U` or `L` is stored in the upper or lower triangular part of array `A`. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {NonNegativeInteger} N - order of triangular factor `U` or `L`. +* @param {Float64Array} A - input array +* @param {NonNegativeInteger} 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 {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var out = dlauu2( 'row-major', 'upper', 2, A, 2 ); +* // returns 0 +*/ +function dlauu2( order, uplo, N, A, LDA ) { + var sa1; + var sa2; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( uplo, N, A, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = dlauu2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/index.js new file mode 100644 index 000000000000..943d5afb9208 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/index.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 compute the product `U*U^T` or `L^T*L`, where the triangular factor `U` or `L` is stored in the upper or lower triangular part of array `A`. +* +* @module @stdlib/lapack/base/dlauu2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlauu2 = require( '@stdlib/lapack/base/dlauu2' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var out = dlauu2( 'row-major', 'upper', 2, A, 2 ); +* // returns 0 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlauu2 = require( '@stdlib/lapack/base/dlauu2' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var out = dlauu2.ndarray( 'upper', 2, A, 2, 1, 0 ); +* // returns 0 +*/ + +// 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 dlauu2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlauu2 = main; +} else { + dlauu2 = tmp; +} + + +// EXPORTS // + +module.exports = dlauu2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/main.js new file mode 100644 index 000000000000..e393f0251095 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dlauu2 = require( './dlauu2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlauu2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlauu2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/ndarray.js new file mode 100644 index 000000000000..43e22b4d9656 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/lib/ndarray.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the product `U*U^T` or `L^T*L`, where the triangular factor `U` or `L` is stored in the upper or lower triangular part of array `A` using alternative indexing semantics. +* +* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {NonNegativeInteger} N - order of triangular factor `U` or `L`. +* @param {Float64Array} A - input array +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @throws {TypeError} first argument must specify whether the lower or upper triangular matrix is supplied +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var out = dlauu2( 'upper', 2, A, 2, 1, 0 ); +* // returns 0 +*/ +function dlauu2( uplo, N, A, strideA1, strideA2, offsetA ) { + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. first argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + return base( uplo, N, A, strideA1, strideA2, offsetA ); +} + + +// EXPORTS // + +module.exports = dlauu2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/package.json b/lib/node_modules/@stdlib/lapack/base/dlauu2/package.json new file mode 100644 index 000000000000..73379903ded8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dlauu2", + "version": "0.0.0", + "description": "Compute the product `U*U^T` or `L^T*L`, where the triangular factor `U` or `L` is stored in the upper or lower triangular part of array.", + "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", + "triangular", + "multiply", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/test/test.dlauu2.js b/lib/node_modules/@stdlib/lapack/base/dlauu2/test/test.dlauu2.js new file mode 100644 index 000000000000..4f220b8258b1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/test/test.dlauu2.js @@ -0,0 +1,216 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlauu2 = require( './../lib/dlauu2.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlauu2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( dlauu2.length, 5, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + 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() { + dlauu2( value, 'upper', 2, A, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + 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() { + dlauu2( 'row-major', value, 2, A, 2 ); + }; + } +}); + +tape( 'the function correctly sets upper triangular part of matrix with `U*U^T` ( row-major )', function test( t ) { + var expected; + var out; + var A; + + expected = new Float64Array( [ 5.0, 8.0, 3.0, 16.0 ] ); + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + out = dlauu2( 'row-major', 'upper', 2, A, 2 ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, A, expected, 1.0 ); + + expected = new Float64Array( [ 17.0, 20.0, 2.0, 25.0, 3.0, 6.0 ] ); + A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + out = dlauu2( 'row-major', 'upper', 2, A, 2 ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, A, expected, 1.0 ); + t.end(); +}); + +tape( 'the function correctly sets upper triangular part of matrix with `U*U^T` ( column-major )', function test( t ) { + var expected; + var out; + var A; + + expected = new Float64Array( [ 5.0, 3.0, 8.0, 16.0 ] ); + A = new Float64Array( [ 1.0, 3.0, 2.0, 4.0 ] ); + out = dlauu2( 'column-major', 'upper', 2, A, 2 ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, A, expected, 1.0 ); + + expected = new Float64Array( [ 10.0, 2.0, 12.0, 16.0, 5.0, 6.0 ] ); + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + out = dlauu2( 'column-major', 'upper', 2, A, 2 ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, A, expected, 1.0 ); + t.end(); +}); + +tape( 'the function correctly sets lower triangular part of matrix with `L^T*L` ( row-major )', function test( t ) { + var expected; + var out; + var A; + + expected = new Float64Array( [ 66.0, 2.0, 3.0, 76.0, 89.0, 6.0, 63.0, 72.0, 81.0 ] ); + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); + out = dlauu2( 'row-major', 'lower', 3, A, 3 ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, A, expected, 1.0 ); + + expected = new Float64Array( [ 66.0, 2.0, 3.0, 76.0, 89.0, 6.0, 63.0, 72.0, 81.0, 10.0, 11.0, 12.0 ] ); + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); + out = dlauu2( 'row-major', 'lower', 3, A, 3 ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, A, expected, 1.0 ); + t.end(); +}); + +tape( 'the function correctly sets lower triangular part of matrix with `L^T*L` ( column-major )', function test( t ) { + var expected; + var out; + var A; + + expected = new Float64Array( [ 66.0, 76.0, 63.0, 2.0, 89.0, 72.0, 3.0, 6.0, 81.0 ] ); + A = new Float64Array( [ 1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0 ] ); + out = dlauu2( 'column-major', 'lower', 3, A, 3 ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, A, expected, 1.0 ); + + expected = new Float64Array( [ 66.0, 76.0, 63.0, 2.0, 89.0, 72.0, 3.0, 6.0, 81.0, 10.0, 11.0, 12.0 ] ); + A = new Float64Array( [ 1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0, 10.0, 11.0, 12.0 ] ); + out = dlauu2( 'column-major', 'lower', 3, A, 3 ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, A, expected, 1.0 ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlauu2/test/test.js new file mode 100644 index 000000000000..bd0f13128cdb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dlauu2 = 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 dlauu2, '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 dlauu2.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 dlauu2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlauu2, 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 dlauu2; + var main; + + main = require( './../lib/dlauu2.js' ); + + dlauu2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlauu2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlauu2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlauu2/test/test.ndarray.js new file mode 100644 index 000000000000..e3ffb0afeb5d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlauu2/test/test.ndarray.js @@ -0,0 +1,198 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlauu2 = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlauu2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( dlauu2.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + 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() { + dlauu2( value, 2, A, 2, 1, 0 ); + }; + } +}); + +tape( 'the function supports accessing elements from non-contiguous arrangement of row and column', function test( t ) { + var expected; + var out; + var A; + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 2, 999, 3, + 999, 999, 999, 999, 999, 999, + 999, 4, 999, 5, 999, 6, + 999, 999, 999, 999, 999, 999, + 999, 7, 999, 8, 999, 9, + 999, 999, 999, 999, 999, 999 + ]); + expected = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 66, 999, 2, 999, 3, + 999, 999, 999, 999, 999, 999, + 999, 76, 999, 89, 999, 6, + 999, 999, 999, 999, 999, 999, + 999, 63, 999, 72, 999, 81, + 999, 999, 999, 999, 999, 999 + ]); + + /* eslint-enable array-element-newline, no-multi-spaces */ + out = dlauu2( 'lower', 3, A, 12, 2, 7 ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, A, expected, EPS ); + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 2, 999, 3, + 999, 999, 999, 999, 999, 999, + 999, 4, 999, 5, 999, 6, + 999, 999, 999, 999, 999, 999, + 999, 7, 999, 8, 999, 9, + 999, 999, 999, 999, 999, 999 + ]); + expected = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 14, 999, 28, 999, 27, + 999, 999, 999, 999, 999, 999, + 999, 4, 999, 61, 999, 54, + 999, 999, 999, 999, 999, 999, + 999, 7, 999, 8, 999, 81, + 999, 999, 999, 999, 999, 999 + ]); + + /* eslint-enable array-element-newline, no-multi-spaces */ + out = dlauu2( 'upper', 3, A, 12, 2, 7 ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, A, expected, EPS ); + t.end(); +}); + +tape( 'the function supports accessing elements from non-contiguous arrangement of row and column and in different orders', function test( t ) { + var expected; + var out; + var A; + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 2, 999, 3, + 999, 999, 999, 999, 999, 999, + 999, 4, 999, 5, 999, 6, + 999, 999, 999, 999, 999, 999, + 999, 7, 999, 8, 999, 9, + 999, 999, 999, 999, 999, 999 + ]); + expected = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 2, 999, 3, + 999, 999, 999, 999, 999, 999, + 999, 4, 999, 29, 999, 36, + 999, 999, 999, 999, 999, 999, + 999, 7, 999, 8, 999, 126, + 999, 999, 999, 999, 999, 999 + ]); + + /* eslint-enable array-element-newline, no-multi-spaces */ + out = dlauu2( 'lower', 3, A, -12, -2, 35 ); + t.strictEqual( out, 0, 'returns expected value' ); + console.log( A ); + isApprox( t, A, expected, EPS ); + t.end(); +});