diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/README.md b/lib/node_modules/@stdlib/lapack/base/dorg2r/README.md new file mode 100644 index 000000000000..bd2c916d7fcb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/README.md @@ -0,0 +1,254 @@ + + +# dorg2r + +> LAPACK routine to generate an M-by-N real matrix Q with orthonormal columns. + +
+ +## Usage + +```javascript +var dorg2r = require( '@stdlib/lapack/base/dorg2r' ); +``` + +#### dorg2r( order, M, N, K, A, LDA, tau, work ) + +Generates an M-by-N real matrix Q with orthonormal columns. The matrix Q is defined as the first N columns of a product of K elementary reflectors of order M. `Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var tau = new Float64Array( [ 0.0, 0.0 ] ); +var work = new Float64Array( 10 ); + +dorg2r( 'column-major', 3, 2, 2, A, 3, tau, work ); +// A => [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **M**: number of rows in matrix `A`. +- **N**: number of columns in matrix `A`. +- **K**: number of elementary reflectors whose product defines the matrix Q. +- **A**: input matrix (overwritten by Householder vectors from `dgeqrf`) stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **tau**: vector of K scalar factors of the elementary reflectors as a [`Float64Array`][mdn-float64array]. +- **work**: workspace array as a [`Float64Array`][mdn-float64array]. + +The function returns the input matrix `A` overwritten with the orthogonal matrix Q. + +#### dorg2r.ndarray( M, N, K, A, sa1, sa2, oa, tau, st, ot, work, sw, ow ) + +Generates an M-by-N real matrix Q with orthonormal columns using alternative indexing semantics. The matrix Q is defined as the first N columns of a product of K elementary reflectors of order M. `Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var tau = new Float64Array( [ 0.0, 0.0 ] ); +var work = new Float64Array( 10 ); + +dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); +// A => [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] +``` + +The function has the following additional parameters: + +- **M**: number of rows in matrix `A`. +- **N**: number of columns in matrix `A`. +- **K**: number of elementary reflectors whose product defines the matrix Q. +- **A**: input matrix (overwritten by Householder vectors from `dgeqrf`) stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: index offset for `A`. +- **tau**: vector of K scalar factors of the elementary reflectors as a [`Float64Array`][mdn-float64array]. +- **st**: stride length for `tau`. +- **ot**: index offset for `tau`. +- **work**: workspace array as a [`Float64Array`][mdn-float64array]. +- **sw**: stride length for `work`. +- **ow**: index offset for `work`. + +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, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var tau = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); +var work = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +dorg2r.ndarray( 3, 2, 2, A, 1, 3, 3, tau, 1, 2, work, 1, 0 ); +// A => [ 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] +``` + +
+ + + +
+ +## Notess + +- The function overwrites the input matrix `A` with the orthogonal matrix `Q`. +- The matrix Q is generated from the Householder vectors and scalar factors returned by `dgeqrf`. +- `dorg2r()` corresponds to the [LAPACK][LAPACK] function [`dorg2r`][lapack-dorg2r]. + +
+ + + +
+ +## Examples + + + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dorg2r = require( '@stdlib/lapack/base/dorg2r' ); + +// Specify matrix meta data: +var M = 4; +var N = 3; +var K = 2; + +// Create a matrix stored in linear memory: +var 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 ] ); +console.log( 'Original matrix A containing Householder vectors:' ); +console.log( ndarray2array( A, [ M, N ], [ 1, M ], 0, 'column-major' ) ); + +// Define scalar factors of the elementary reflectors: +var tau = new Float64Array( [ 1.2, 0.8 ] ); + +// Create workspace array: +var work = new Float64Array( N ); + +// Generate the orthogonal matrix Q: +dorg2r( 'column-major', M, N, K, A, M, tau, work ); +console.log( 'Resulting orthogonal matrix Q:' ); +console.log( ndarray2array( A, [ M, N ], [ 1, M ], 0, 'column-major' ) ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dorg2r/benchmark/benchmark.js new file mode 100644 index 000000000000..cf9c02afb597 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/benchmark/benchmark.js @@ -0,0 +1,123 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +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 pkg = require( './../package.json' ).name; +var dorg2r = require( './../lib/dorg2r.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - matrix order (N-by-N) +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var work; + var opts; + var tau; + var A; + + opts = { + 'dtype': 'float64' + }; + + // Random input matrix and auxiliary arrays: + A = uniform( N*N, -1.0, 1.0, opts ); + tau = uniform( N, 0.1, 1.0, opts ); + work = uniform( N, 0.0, 0.0, opts ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dorg2r( order, N, N, 0, A, N, tau, work ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + 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+':order='+ord+',size='+(N*N), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dorg2r/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..1f236757de6e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/benchmark/benchmark.ndarray.js @@ -0,0 +1,134 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +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 pkg = require( './../package.json' ).name; +var dorg2r = 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 - matrix order (N-by-N) +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var work; + var sa1; + var sa2; + var tau; + var A; + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { + sa1 = N; + sa2 = 1; + } + + A = uniform( N*N, -1.0, 1.0, { + 'dtype': 'float64' + }); + tau = uniform( N, 0.1, 1.0, { + 'dtype': 'float64' + }); + work = uniform( N, 0.0, 0.0, { + 'dtype': '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++ ) { + z = dorg2r( N, N, 0, A, sa1, sa2, 0, tau, 1, 0, work, 1, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + 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+':ndarray:order='+ord+',size='+(N*N), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dorg2r/docs/repl.txt new file mode 100644 index 000000000000..45624c4156f7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/docs/repl.txt @@ -0,0 +1,115 @@ +{{alias}}( order, M, N, K, A, LDA, tau, work ) + Generates an M-by-N real matrix Q with orthonormal columns. The matrix Q + is defined as the first N columns of a product of K elementary reflectors + of order M. Q = H(1) H(2) . . . H(K) as returned by dgeqrf. + + The function overwrites the input matrix A with the orthogonal matrix Q. + + 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 matrix A. + + N: integer + Number of columns in matrix A. + + K: integer + Number of elementary reflectors whose product defines the matrix Q. + + A: Float64Array + Input matrix (overwritten by Householder vectors from dgeqrf). + + LDA: integer + Stride of the first dimension of A (a.k.a., leading dimension of the + matrix A). + + tau: Float64Array + Vector of K scalar factors of the elementary reflectors. + + work: Float64Array + Workspace array. + + Returns + ------- + A: Float64Array + Mutated input matrix overwritten with the orthogonal matrix Q. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}([ 1.0,2.0,3.0,4.0,5.0,6.0 ]); + > var tau = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0 ] ); + > var work = new {{alias:@stdlib/array/float64}}( 10 ); + > {{alias}}( 'column-major', 3, 2, 2, A, 3, tau, work ) + [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] + + +{{alias}}.ndarray( M, N, K, A, sa1, sa2, oa, tau, st, ot, work, sw, ow ) + Generates an M-by-N real matrix Q with orthonormal columns using + alternative indexing semantics. The matrix Q is defined as the first N + columns of a product of K elementary reflectors of order M. + `Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + M: integer + Number of rows in matrix A. + + N: integer + Number of columns in matrix A. + + K: integer + Number of elementary reflectors whose product defines the matrix Q. + + A: Float64Array + Input matrix. + + sa1: integer + Stride of the first dimension of A. + + sa2: integer + Stride of the second dimension of A. + + oa: integer + Index offset for A. + + tau: Float64Array + Vector of K scalar factors of the elementary reflectors. + + st: integer + Stride length for tau. + + ot: integer + Index offset for tau. + + work: Float64Array + Workspace array. + + sw: integer + Stride length for work. + + ow: integer + Index offset for work. + + Returns + ------- + A: Float64Array + Mutated input matrix overwritten with the orthogonal matrix Q. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}([ 1.0,2.0,3.0,4.0,5.0,6.0 ]); + > var tau = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0 ] ); + > var work = new {{alias:@stdlib/array/float64}}( 10 ); + > {{alias}}.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ) + [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dorg2r/docs/types/index.d.ts new file mode 100644 index 000000000000..d0be77106bf7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/docs/types/index.d.ts @@ -0,0 +1,128 @@ +/* +* @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 `dorg2r`. +*/ +interface Routine { + /** + * Generates an `M`-by-`N` real matrix `Q` with orthonormal columns. The matrix `Q` is defined as the first `N` columns of a product of `K` elementary reflectors of order `M`. `Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`. + * + * + * @param order - storage layout + * @param M - number of rows in `A` + * @param N - number of columns in `A` + * @param K - number of elementary reflectors whose product defines the matrix `Q` + * @param A - input matrix (overwritten with `Q` on output) + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param tau - vector of `K` scalar factors of the elementary reflectors + * @param work - workspace array + * @returns matrix `A` overwritten with the orthogonal matrix `Q` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var dorg2r = require( '@stdlib/lapack/base/dorg2r' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var tau = new Float64Array( [ 0.0, 0.0 ] ); + * var work = new Float64Array( 10 ); + * + * dorg2r( 'column-major', 3, 2, 2, A, 3, tau, work ); + * // A => [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] + */ + ( order: Layout, M: number, N: number, K: number, A: Float64Array, LDA: number, tau: Float64Array, work: Float64Array ): Float64Array; + + /** + * Generates an `M`-by-`N` real matrix `Q` with orthonormal columns using alternative indexing semantics. The matrix `Q` is defined as the first `N` columns of a product of `K` elementary reflectors of order `M`. `Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`. + * + * @param M - number of rows in `A` + * @param N - number of columns in `A` + * @param K - number of elementary reflectors + * @param A - input matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - index offset for `A` + * @param tau - vector of scalar factors of the elementary reflectors + * @param strideTau - stride length for `tau` + * @param offsetTau - index offset for `tau` + * @param work - workspace array + * @param strideWork - stride length for `work` + * @param offsetWork - index offset for `work` + * @returns matrix `A` overwritten with the orthogonal matrix `Q` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var dorg2r = require( '@stdlib/lapack/base/dorg2r' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var tau = new Float64Array( [ 0.0, 0.0 ] ); + * var work = new Float64Array( 10 ); + * + * dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); + * // A => [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] + */ + ndarray( M: number, N: number, K: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, tau: Float64Array, strideTau: number, offsetTau: number, work: Float64Array, strideWork: number, offsetWork: number ): Float64Array; // eslint-disable-line max-len +} + +/** +* Generates an `M`-by-`N` real matrix `Q` with orthonormal columns. The matrix `Q` is defined as the first `N` columns of a product of `K` elementary reflectors of order `M`. `Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`. +* +* @param order - storage layout +* @param M - number of rows in `A` +* @param N - number of columns in `A` +* @param K - number of elementary reflectors whose product defines the matrix `Q` +* @param A - input matrix (overwritten with `Q` on output) +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param tau - vector of `K` scalar factors of the elementary reflectors +* @param work - workspace array +* @returns matrix `A` overwritten with the orthogonal matrix `Q` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dorg2r = require( '@stdlib/lapack/base/dorg2r' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var tau = new Float64Array( [ 0.0, 0.0 ] ); +* var work = new Float64Array( 10 ); +* +* dorg2r( 'column-major', 3, 2, 2, A, 3, tau, work ); +* // A => [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dorg2r = require( '@stdlib/lapack/base/dorg2r' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var tau = new Float64Array( [ 0.0, 0.0 ] ); +* var work = new Float64Array( 10 ); +* +* dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); +* // A => [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] +*/ +declare var dorg2r: Routine; + + +// EXPORTS // + +export = dorg2r; diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dorg2r/docs/types/test.ts new file mode 100644 index 000000000000..60e928164f32 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/docs/types/test.ts @@ -0,0 +1,415 @@ +/* +* @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 dorg2r = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r( 'column-major', 3, 2, 2, A, 3, tau, work ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r( 5, 3, 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( true, 3, 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( false, 3, 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( null, 3, 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( void 0, 3, 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( [], 3, 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( {}, 3, 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( ( x: number ): number => x, 3, 2, 2, A, 3, tau, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r( 'column-major', '3', 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', true, 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', false, 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', null, 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', void 0, 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', [], 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', {}, 2, 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', ( x: number ): number => x, 2, 2, A, 3, tau, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r( 'column-major', 3, '2', 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, true, 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, false, 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, null, 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, void 0, 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, [], 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, {}, 2, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, ( x: number ): number => x, 2, A, 3, tau, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r( 'column-major', 3, 2, '2', A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, true, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, false, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, null, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, void 0, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, [], A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, {}, A, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, ( x: number ): number => x, A, 3, tau, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r( 'column-major', 3, 2, 2, '5', 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, 5, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, true, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, false, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, null, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, void 0, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, [], 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, {}, 3, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, ( x: number ): number => x, 3, tau, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r( 'column-major', 3, 2, 2, A, '3', tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, true, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, false, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, null, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, void 0, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, [], tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, {}, tau, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, ( x: number ): number => x, tau, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + const A = new Float64Array( 6 ); + const work = new Float64Array( 10 ); + + dorg2r( 'column-major', 3, 2, 2, A, 3, '5', work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, 5, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, true, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, false, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, null, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, void 0, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, [], work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, {}, work ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, ( x: number ): number => x, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a Float64Array... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + + dorg2r( 'column-major', 3, 2, 2, A, 3, tau, '5' ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, tau, 5 ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, tau, true ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, tau, false ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, tau, null ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, tau, void 0 ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, tau, [] ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, tau, {} ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, tau, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r(); // $ExpectError + dorg2r( 'column-major' ); // $ExpectError + dorg2r( 'column-major', 3 ); // $ExpectError + dorg2r( 'column-major', 3, 2 ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2 ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3 ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, tau ); // $ExpectError + dorg2r( 'column-major', 3, 2, 2, A, 3, tau, work, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( '3', 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( true, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( false, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( null, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( void 0, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( [], 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( {}, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( ( x: number ): number => x, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 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( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( 3, '2', 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, true, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, false, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, null, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, void 0, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, [], 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, {}, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, ( x: number ): number => x, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( 3, 2, '2', A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, true, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, false, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, null, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, void 0, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, [], A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, {}, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, ( x: number ): number => x, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( 3, 2, 2, '5', 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, 5, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, true, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, false, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, null, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, void 0, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, [], 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, {}, 1, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, ( x: number ): number => x, 1, 3, 0, tau, 1, 0, work, 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( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( 3, 2, 2, A, '1', 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, true, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, false, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, null, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, void 0, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, [], 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, {}, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, ( x: number ): number => x, 3, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( 3, 2, 2, A, 1, '3', 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, true, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, false, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, null, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, void 0, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, [], 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, {}, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, ( x: number ): number => x, 0, tau, 1, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( 3, 2, 2, A, 1, 3, '0', tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, true, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, false, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, null, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, void 0, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, [], tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, {}, tau, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, ( x: number ): number => x, tau, 1, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a Float64Array... +{ + const A = new Float64Array( 6 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, '5', 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, 5, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, true, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, false, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, null, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, void 0, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, [], 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, {}, 1, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, ( x: number ): number => x, 1, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, '1', 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, true, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, false, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, null, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, void 0, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, [], 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, {}, 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, ( x: number ): number => x, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, '0', work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, true, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, false, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, null, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, void 0, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, [], work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, {}, work, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, ( x: number ): number => x, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a Float64Array... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, '5', 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, 5, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, true, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, false, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, null, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, void 0, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, [], 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, {}, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, '1', 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, true, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, false, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, null, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, void 0, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, [], 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, {}, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not a number... +{ + const A = new Float64Array( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, '0' ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, true ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, false ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, null ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, void 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, [] ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, {} ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 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( 6 ); + const tau = new Float64Array( 2 ); + const work = new Float64Array( 10 ); + + dorg2r.ndarray(); // $ExpectError + dorg2r.ndarray( 3 ); // $ExpectError + dorg2r.ndarray( 3, 2 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1 ); // $ExpectError + dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dorg2r/examples/index.js new file mode 100644 index 000000000000..13dd9280dc90 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/examples/index.js @@ -0,0 +1,41 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dorg2r = require( './../lib' ); + +var M = 4; +var N = 3; +var K = 2; + +var 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 ] ); // eslint-disable-line max-len + +console.log( 'Original matrix A containing Householder vectors:' ); +console.log( ndarray2array( A, [ M, N ], [ 1, M ], 0, 'column-major' ) ); + +var tau = new Float64Array( [ 1.2, 0.8 ] ); + +var work = new Float64Array( N ); + +dorg2r( 'column-major', M, N, K, A, M, tau, work ); + +console.log( 'Resulting orthogonal matrix Q:' ); +console.log( ndarray2array( A, [ M, N ], [ 1, M ], 0, 'column-major' ) ); diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/base.js new file mode 100644 index 000000000000..6f7cc8a52ae2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/base.js @@ -0,0 +1,124 @@ +/** +* @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 dscal = require( '@stdlib/blas/base/dscal' ).ndarray; +var dlarf1f = require( './dlarf1f.js' ); + + +// MAIN // + +/** +* Generates an M-by-N real matrix Q with orthonormal columns. The matrix Q is defined as the first N columns of a product of K elementary reflectors of order M. `Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`. +* +* @private +* @param {PositiveInteger} M - number of rows in matrix `A` +* @param {PositiveInteger} N - number of columns in matrix `A` +* @param {NonNegativeInteger} K - number of elementary reflectors whose product defines the matrix Q +* @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` +* @param {Float64Array} tau - vector of K scalar factors of the elementary reflectors +* @param {integer} strideTau - stride length for `tau` +* @param {NonNegativeInteger} offsetTau - index offset for `tau` +* @param {Float64Array} work - workspace array +* @param {integer} strideWork - stride length for `work` +* @param {NonNegativeInteger} offsetWork - index offset for `work` +* @returns {Float64Array} matrix `A` overwritten with the orthogonal matrix Q +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var tau = new Float64Array( [ 0.0, 0.0 ] ); +* var work = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dorg2r( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); +* // A => [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] +*/ +function dorg2r( M, N, K, A, strideA1, strideA2, offsetA, tau, strideTau, offsetTau, work, strideWork, offsetWork ) { // eslint-disable-line max-len, max-params + var ia1; + var ia3; + var del; + var ia2; + var it; + var i; + var j; + var l; + + if ( N <= 0 ) { + return A; + } + + // Initialize columns k+1:n to columns of the unit matrix + ia1 = offsetA + (K*strideA1) + (K*strideA2); + ia2 = offsetA + (K*strideA2); + del = strideA1 + strideA2; + + for ( j = K; j < N; j++ ) { + for ( l = 0; l < M; l++ ) { + A[ ia2 ] = 0.0; + ia2 += strideA1; + } + A[ ia1 ] = 1.0; + ia1 += del; + ia2 += strideA2; + } + + it = offsetTau + ((K-1)*strideTau); + ia1 = offsetA + ((K-1)*(strideA1+strideA2)); + ia2 = offsetA + ((K-1)*strideA2); + + // Apply H(i) to A(i:m,i:n) from the left + for ( i = K-1; i >= 0; i-- ) { + if ( i < N ) { + // Apply H(i) to A(i:m,i+1:n) from the left + dlarf1f( 'left', M-i, N-i-1, A, strideA1, ia1, tau[ it ], A, strideA1, strideA2, ia1 + strideA2, work, strideWork, offsetWork ); + } + if ( i < M ) { + // Scale A(i+1:m,i) by -tau(i) + dscal( M-i-1, -tau[ it ], A, strideA1, ia1 + strideA1 ); + } + + // Set A(i,i) = 1 - tau(i) + A[ ia1 ] = 1.0 - tau[ it ]; + + ia3 = 0; + + // Set A(0:i-1,i) to zero + for ( l = 0; l < i; l++ ) { + A[ ia2 + ia3 ] = 0.0; + ia3 += strideA1; + } + it -= strideTau; + + ia1 -= del; + ia2 -= strideA2; + } + + return A; +} + + +// EXPORTS // + +module.exports = dorg2r; diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/dlarf1f.js b/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/dlarf1f.js new file mode 100644 index 000000000000..1da894fe3c3c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/dlarf1f.js @@ -0,0 +1,128 @@ +/** +* @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'; + +/* eslint-disable max-len */ + +// MODULES // + +var iladlc = require( '@stdlib/lapack/base/iladlc' ).ndarray; +var iladlr = require( '@stdlib/lapack/base/iladlr' ).ndarray; +var dgemv = require( '@stdlib/blas/base/dgemv' ).ndarray; +var dger = require( '@stdlib/blas/base/dger' ).ndarray; +var daxpy = require( '@stdlib/blas/base/daxpy' ).ndarray; +var dscal = require( '@stdlib/blas/base/dscal' ).ndarray; + + +// MAIN // + +/** +* Applies a real elementary reflector `H = I - tau * v * v ^ T` to a real M by N matrix `C`. +* +* ## Notes +* +* - `work` should have `N` indexed elements if side = `left` and `M` indexed elements if side = `right`. +* - `V` should have `1 + (M-1) * abs(strideV)` indexed elements if side = `left` and `1 + (N-1) * abs(strideV)` indexed elements if side = `right`. +* - `C` is overwritten by `H * C` if side = `left` and `C * H` if side = `right`. +* +* @private +* @param {string} side - specifies the side of multiplication with `C`. Use `left` to form `H * C` and `right` to from `C * H`. +* @param {NonNegativeInteger} M - number of rows in `C` +* @param {NonNegativeInteger} N - number of columns in `C` +* @param {Float64Array} V - the vector `v` in the representation of `H` +* @param {integer} strideV - stride length for `V` +* @param {NonNegativeInteger} offsetV - starting index for `V` +* @param {number} tau - the value of `tau` in representation of `H` +* @param {Float64Array} C - input matrix +* @param {integer} strideC1 - stride of the first dimension of `C` +* @param {integer} strideC2 - stride of the second dimension of `C` +* @param {NonNegativeInteger} offsetC - starting index for `C` +* @param {Float64Array} work - workspace array +* @param {integer} strideWork - stride length for `work` +* @param {NonNegativeInteger} offsetWork - starting index for `work` +* @returns {Float64Array} `C * H` or `H * C` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var C = new Float64Array( [ 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] ); +* var V = new Float64Array( [ 0.5, 0.5, 0.5, 0.5 ] ); +* var work = new Float64Array( 3 ); +* +* var out = dlarf1f( 'left', 4, 3, V, 1, 0, 1.0, C, 3, 1, 0, work, 1, 0 ); +* // returns [ -4.5, -10.5, -16.5, -0.75, -1.75, -2.75, 0.25, -0.75, -1.75, 1.25, 0.25, -0.75 ] +*/ +function dlarf1f( side, M, N, V, strideV, offsetV, tau, C, strideC1, strideC2, offsetC, work, strideWork, offsetWork ) { // eslint-disable-line max-params + var lastv; + var lastc; + var i; + + lastv = 1; + lastc = 0; + if ( tau !== 0.0 ) { + if ( side === 'left' ) { + lastv = M; + } else { + lastv = N; + } + + // i points to the last element in V + i = offsetV + ( ( lastv - 1 ) * strideV ); + + // Move i to the last non-zero element in V + while ( lastv > 0 && V[ i ] === 0.0 ) { + lastv -= 1; + i -= strideV; + } + if ( side === 'left' ) { + lastc = iladlc( lastv + 1, N, C, strideC1, strideC2, offsetC ) + 1; // to account for the difference between zero-based and one-based indexing + } else { + lastc = iladlr( M, lastv + 1, C, strideC1, strideC2, offsetC ) + 1; // to account for the difference between zero-based and one-based indexing + } + // lastc is zero if a matrix is filled with zeros + } + if ( lastc === 0 ) { + // Returns C unchanged if tau is zero or all elements in C are zero + return C; + } + if ( side === 'left' ) { + if ( lastv === 0 ) { + dscal( lastc, 1.0 - tau, C, strideC2, offsetC ); // scale the first row + } else { + dgemv( 'transpose', lastv-1, lastc, 1.0, C, strideC1, strideC2, offsetC + strideC1, V, strideV, offsetV + strideV, 0.0, work, strideWork, offsetWork ); // C( 1, 0 ) is accessed here + daxpy( lastc, 1.0, C, strideC2, offsetC, work, strideWork, offsetWork ); // operates on the first row of C + daxpy( lastc, -tau, work, strideWork, offsetWork, C, strideC2, offsetC ); // operates on the first row of C + dger( lastv-1, lastc, -tau, V, strideV, offsetV + strideV, work, strideWork, offsetWork, C, strideC1, strideC2, offsetC + strideC1 ); // C( 1, 0 ) is accessed here + } + } else if ( lastv === 0 ) { + dscal( lastc, 1.0 - tau, C, strideC1, offsetC ); // scale the first column + } else { + dgemv( 'no-transpose', lastc, lastv-1, 1.0, C, strideC1, strideC2, offsetC + strideC2, V, strideV, offsetV + strideV, 0.0, work, strideWork, offsetWork ); // C( 0, 1 ) is accessed here + daxpy( lastc, 1.0, C, strideC1, offsetC, work, strideWork, offsetWork ); // operates on the first column of C + daxpy( lastc, -tau, work, strideWork, offsetWork, C, strideC1, offsetC ); // operates on the first column of C + dger( lastc, lastv-1, -tau, work, strideWork, offsetWork, V, strideV, offsetV + strideV, C, strideC1, strideC2, offsetC + strideC2 ); // C( 0, 1 ) is accessed here + } + + return C; +} + + +// EXPORTS // + +module.exports = dlarf1f; diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/dorg2r.js b/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/dorg2r.js new file mode 100644 index 000000000000..a4f97d88a27a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/dorg2r.js @@ -0,0 +1,80 @@ +/** +* @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/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Generates an M-by-N real matrix Q with orthonormal columns. The matrix Q is defined as the first N columns of a product of K elementary reflectors of order M. `Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`. +* +* @param {string} order - storage layout +* @param {PositiveInteger} M - number of rows in matrix `A` +* @param {PositiveInteger} N - number of columns in matrix `A` +* @param {NonNegativeInteger} K - number of elementary reflectors whose product defines the matrix Q +* @param {Float64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float64Array} tau - vector of K scalar factors of the elementary reflectors +* @param {Float64Array} work - workspace array +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} sixth argument must be greater than or equal to max(1,M) +* @returns {Float64Array} matrix `A` overwritten with the orthogonal matrix Q +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var tau = new Float64Array( [ 0.0, 0.0 ] ); +* var work = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dorg2r( 'column-major', 3, 2, 2, A, 3, tau, work ); +* // A => [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] +*/ +function dorg2r( order, M, N, K, A, LDA, tau, work ) { + var sa1; + var sa2; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( isRowMajor( order ) && LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDA ) ); + } + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( M, N, K, A, sa1, sa2, 0, tau, 1, 0, work, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dorg2r; diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/index.js new file mode 100644 index 000000000000..a60c5cb7dc27 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/index.js @@ -0,0 +1,70 @@ +/** +* @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 generate an M-by-N real matrix Q with orthonormal columns. The matrix Q is defined as the first N columns of a product of K elementary reflectors of order M. `Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`. +* +* @module @stdlib/lapack/base/dorg2r +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dorg2r = require( '@stdlib/lapack/base/dorg2r' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var tau = new Float64Array( [ 0.0, 0.0 ] ); +* var work = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dorg2r( 'column-major', 3, 2, 2, A, 3, tau, work ); +* // A => [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dorg2r = require( '@stdlib/lapack/base/dorg2r' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var tau = new Float64Array( [ 0.0, 0.0 ] ); +* var work = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); +* // A => [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.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 dorg2r; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dorg2r = main; +} else { + dorg2r = tmp; +} + + +// EXPORTS // + +module.exports = dorg2r; diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/main.js new file mode 100644 index 000000000000..fb5fc0f2cc24 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/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 dorg2r = require( './dorg2r.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dorg2r, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dorg2r; diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/ndarray.js new file mode 100644 index 000000000000..dfa82bfbb3d8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/lib/ndarray.js @@ -0,0 +1,63 @@ +/** +* @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 // + +/** +* Generates an M-by-N real matrix Q with orthonormal columns. The matrix Q is defined as the first N columns of a product of K elementary reflectors of order M. `Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`. +* +* @param {PositiveInteger} M - number of rows in matrix `A` +* @param {PositiveInteger} N - number of columns in matrix `A` +* @param {NonNegativeInteger} K - number of elementary reflectors whose product defines the matrix Q +* @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` +* @param {Float64Array} tau - vector of K scalar factors of the elementary reflectors +* @param {integer} strideTau - stride length for `tau` +* @param {NonNegativeInteger} offsetTau - index offset for `tau` +* @param {Float64Array} work - workspace array +* @param {integer} strideWork - stride length for `work` +* @param {NonNegativeInteger} offsetWork - index offset for `work` +* @returns {Float64Array} matrix `A` overwritten with the orthogonal matrix Q +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var tau = new Float64Array( [ 0.0, 0.0 ] ); +* var work = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dorg2r( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); +* // A => [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] +*/ +function dorg2r( M, N, K, A, strideA1, strideA2, offsetA, tau, strideTau, offsetTau, work, strideWork, offsetWork ) { // eslint-disable-line max-len, max-params + return base( M, N, K, A, strideA1, strideA2, offsetA, tau, strideTau, offsetTau, work, strideWork, offsetWork ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dorg2r; diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/package.json b/lib/node_modules/@stdlib/lapack/base/dorg2r/package.json new file mode 100644 index 000000000000..ea0006080b68 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/package.json @@ -0,0 +1,73 @@ +{ + "name": "@stdlib/lapack/base/dorg2r", + "version": "0.0.0", + "description": "LAPACK routine to generate an M-by-N real matrix Q with orthonormal columns.", + "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", + "dorg2r", + "orthogonal", + "qr", + "decomposition", + "householder", + "reflectors", + "matrix", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/test/fixtures/column_major.json b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/fixtures/column_major.json new file mode 100644 index 000000000000..7d37c2912dd5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/fixtures/column_major.json @@ -0,0 +1,27 @@ +{ + "M": 3, + "N": 2, + "K": 2, + "LDA": 3, + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "tau": [ 0.0, 0.0 ], + "strideTau": 1, + "offsetTau": 0, + "work": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "strideWork": 1, + "offsetWork": 0, + "A_out_mat": [ + [ 1.0, 0.0 ], + [ 0.0, 1.0 ], + [ 0.0, 0.0 ] + ], + "A_out": [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/test/fixtures/column_major_k_lt_n.json b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/fixtures/column_major_k_lt_n.json new file mode 100644 index 000000000000..d146be42f228 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/fixtures/column_major_k_lt_n.json @@ -0,0 +1,35 @@ +{ + "M": 7, + "N": 7, + "K": 3, + "LDA": 7, + "A_mat": [ + [ 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + [ 0.2100000000000000199840144, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + [ 0.3100000000000000532907052, 0.3200000000000000621724894, 2.0, 0.0, 0.0, 0.0, 0.0 ], + [ 0.4100000000000000310862447, 0.4200000000000000399680289, 0.4300000000000000488498131, 0.0, 0.0, 0.0, 0.0 ], + [ 0.5100000000000000088817842, 0.5200000000000000177635684, 0.5300000000000000266453526, 0.0, 0.0, 0.0, 0.0 ], + [ 0.6100000000000000976996262, 0.6200000000000001065814104, 0.6300000000000001154631946, 0.0, 0.0, 0.0, 0.0 ], + [ 0.7100000000000000754951657, 0.7200000000000000843769499, 0.7300000000000000932587341, 0.0, 0.0, 0.0, 0.0 ] + ], + "A": [ 2.0, 0.2100000000000000199840144, 0.3100000000000000532907052, 0.4100000000000000310862447, 0.5100000000000000088817842, 0.6100000000000000976996262, 0.7100000000000000754951657, 0.0, 2.0, 0.3200000000000000621724894, 0.4200000000000000399680289, 0.5200000000000000177635684, 0.6200000000000001065814104, 0.7200000000000000843769499, 0.0, 0.0, 2.0, 0.4300000000000000488498131, 0.5300000000000000266453526, 0.6300000000000001154631946, 0.7300000000000000932587341, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "strideA1": 1, + "strideA2": 7, + "offsetA": 0, + "tau": [ 1.0, 1.0, 1.0 ], + "strideTau": 1, + "offsetTau": 0, + "work": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "strideWork": 1, + "offsetWork": 0, + "A_out_mat": [ + [ 0.0, 1.4260000000000003783640068, -0.8960464000000005757584631, -0.1999935520000002964202679, -0.2473501920000003018174084, -0.2947068320000004737480026, -0.3420634720000004236339919 ], + [ -0.2100000000000000199840144, 0.2994600000000001149835782, 1.1842302560000002031870281, 0.2657333540800001503434657, 0.3250284596800001590821694, 0.3843235652800002788431755, 0.4436186708800002875818791 ], + [ -0.3100000000000000532907052, 0.1220600000000001128519500, 0.1613936159999999619962807, -0.3935237611200000373834484, -0.4860475195200000264605933, -0.5785712779200001820711918, -0.6710950363200000046148830 ], + [ -0.4100000000000000310862447, 0.1646600000000001395861204, -0.2209710240000001824078879, 0.8623500836799998792159272, -0.1709853387200000462975424, -0.2043207611200000828333145, -0.2376561835200000638579354 ], + [ -0.5100000000000000088817842, 0.2072600000000002218314421, -0.2733356640000001447354805, -0.1698760715200000603886110, 0.7889768420799998516201867, -0.2521702443200001253487130, -0.2933173307200001023176128 ], + [ -0.6100000000000000976996262, 0.2498600000000003040767638, -0.3257003040000002735965268, -0.2021022267200001110154517, -0.2510609771200000839286304, 0.6999802724799998321358885, -0.3489784779200001407772902 ], + [ -0.7100000000000000754951657, 0.2924600000000002752997830, -0.3780649440000002359241194, -0.2343283819200001061311411, -0.2910987963200001304997500, -0.3478692107200002103795100, 0.5953603748799998207630324 ] + ], + "A_out": [ 0.0, -0.2100000000000000199840144, -0.3100000000000000532907052, -0.4100000000000000310862447, -0.5100000000000000088817842, -0.6100000000000000976996262, -0.7100000000000000754951657, 1.4260000000000003783640068, 0.2994600000000001149835782, 0.1220600000000001128519500, 0.1646600000000001395861204, 0.2072600000000002218314421, 0.2498600000000003040767638, 0.2924600000000002752997830, -0.8960464000000005757584631, 1.1842302560000002031870281, 0.1613936159999999619962807, -0.2209710240000001824078879, -0.2733356640000001447354805, -0.3257003040000002735965268, -0.3780649440000002359241194, -0.1999935520000002964202679, 0.2657333540800001503434657, -0.3935237611200000373834484, 0.8623500836799998792159272, -0.1698760715200000603886110, -0.2021022267200001110154517, -0.2343283819200001061311411, -0.2473501920000003018174084, 0.3250284596800001590821694, -0.4860475195200000264605933, -0.1709853387200000462975424, 0.7889768420799998516201867, -0.2510609771200000839286304, -0.2910987963200001304997500, -0.2947068320000004737480026, 0.3843235652800002788431755, -0.5785712779200001820711918, -0.2043207611200000828333145, -0.2521702443200001253487130, 0.6999802724799998321358885, -0.3478692107200002103795100, -0.3420634720000004236339919, 0.4436186708800002875818791, -0.6710950363200000046148830, -0.2376561835200000638579354, -0.2933173307200001023176128, -0.3489784779200001407772902, 0.5953603748799998207630324 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/test/fixtures/row_major.json b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/fixtures/row_major.json new file mode 100644 index 000000000000..09344ac9ff65 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/fixtures/row_major.json @@ -0,0 +1,27 @@ +{ + "M": 3, + "N": 2, + "K": 2, + "LDA": 2, + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "tau": [ 0.0, 0.0 ], + "strideTau": 1, + "offsetTau": 0, + "work": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "strideWork": 1, + "offsetWork": 0, + "A_out_mat": [ + [ 1.0, 0.0 ], + [ 0.0, 1.0 ], + [ 0.0, 0.0 ] + ], + "A_out": [ 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/test/fixtures/row_major_k_lt_n.json b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/fixtures/row_major_k_lt_n.json new file mode 100644 index 000000000000..6c6e744b35dc --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/fixtures/row_major_k_lt_n.json @@ -0,0 +1,35 @@ +{ + "M": 7, + "N": 7, + "K": 3, + "LDA": 7, + "A_mat": [ + [ 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + [ 0.2100000000000000199840144, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + [ 0.3100000000000000532907052, 0.3200000000000000621724894, 2.0, 0.0, 0.0, 0.0, 0.0 ], + [ 0.4100000000000000310862447, 0.4200000000000000399680289, 0.4300000000000000488498131, 0.0, 0.0, 0.0, 0.0 ], + [ 0.5100000000000000088817842, 0.5200000000000000177635684, 0.5300000000000000266453526, 0.0, 0.0, 0.0, 0.0 ], + [ 0.6100000000000000976996262, 0.6200000000000001065814104, 0.6300000000000001154631946, 0.0, 0.0, 0.0, 0.0 ], + [ 0.7100000000000000754951657, 0.7200000000000000843769499, 0.7300000000000000932587341, 0.0, 0.0, 0.0, 0.0 ] + ], + "A": [ 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.2100000000000000199840144, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3100000000000000532907052, 0.3200000000000000621724894, 2.0, 0.0, 0.0, 0.0, 0.0, 0.4100000000000000310862447, 0.4200000000000000399680289, 0.4300000000000000488498131, 0.0, 0.0, 0.0, 0.0, 0.5100000000000000088817842, 0.5200000000000000177635684, 0.5300000000000000266453526, 0.0, 0.0, 0.0, 0.0, 0.6100000000000000976996262, 0.6200000000000001065814104, 0.6300000000000001154631946, 0.0, 0.0, 0.0, 0.0, 0.7100000000000000754951657, 0.7200000000000000843769499, 0.7300000000000000932587341, 0.0, 0.0, 0.0, 0.0 ], + "strideA1": 7, + "strideA2": 1, + "offsetA": 0, + "tau": [ 1.0, 1.0, 1.0 ], + "strideTau": 1, + "offsetTau": 0, + "work": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "strideWork": 1, + "offsetWork": 0, + "A_out_mat": [ + [ 0.0, 1.4260000000000003783640068, -0.8960464000000005757584631, -0.1999935520000002964202679, -0.2473501920000003018174084, -0.2947068320000004737480026, -0.3420634720000004236339919 ], + [ -0.2100000000000000199840144, 0.2994600000000001149835782, 1.1842302560000002031870281, 0.2657333540800001503434657, 0.3250284596800001590821694, 0.3843235652800002788431755, 0.4436186708800002875818791 ], + [ -0.3100000000000000532907052, 0.1220600000000001128519500, 0.1613936159999999619962807, -0.3935237611200000373834484, -0.4860475195200000264605933, -0.5785712779200001820711918, -0.6710950363200000046148830 ], + [ -0.4100000000000000310862447, 0.1646600000000001395861204, -0.2209710240000001824078879, 0.8623500836799998792159272, -0.1709853387200000462975424, -0.2043207611200000828333145, -0.2376561835200000638579354 ], + [ -0.5100000000000000088817842, 0.2072600000000002218314421, -0.2733356640000001447354805, -0.1698760715200000603886110, 0.7889768420799998516201867, -0.2521702443200001253487130, -0.2933173307200001023176128 ], + [ -0.6100000000000000976996262, 0.2498600000000003040767638, -0.3257003040000002735965268, -0.2021022267200001110154517, -0.2510609771200000839286304, 0.6999802724799998321358885, -0.3489784779200001407772902 ], + [ -0.7100000000000000754951657, 0.2924600000000002752997830, -0.3780649440000002359241194, -0.2343283819200001061311411, -0.2910987963200001304997500, -0.3478692107200002103795100, 0.5953603748799998207630324 ] + ], + "A_out": [ 0.0, 1.4260000000000003783640068, -0.8960464000000005757584631, -0.1999935520000002964202679, -0.2473501920000003018174084, -0.2947068320000004737480026, -0.3420634720000004236339919, -0.2100000000000000199840144, 0.2994600000000001149835782, 1.1842302560000002031870281, 0.2657333540800001503434657, 0.3250284596800001590821694, 0.3843235652800002788431755, 0.4436186708800002875818791, -0.3100000000000000532907052, 0.1220600000000001128519500, 0.1613936159999999619962807, -0.3935237611200000373834484, -0.4860475195200000264605933, -0.5785712779200001820711918, -0.6710950363200000046148830, -0.4100000000000000310862447, 0.1646600000000001395861204, -0.2209710240000001824078879, 0.8623500836799998792159272, -0.1709853387200000462975424, -0.2043207611200000828333145, -0.2376561835200000638579354, -0.5100000000000000088817842, 0.2072600000000002218314421, -0.2733356640000001447354805, -0.1698760715200000603886110, 0.7889768420799998516201867, -0.2521702443200001253487130, -0.2933173307200001023176128, -0.6100000000000000976996262, 0.2498600000000003040767638, -0.3257003040000002735965268, -0.2021022267200001110154517, -0.2510609771200000839286304, 0.6999802724799998321358885, -0.3489784779200001407772902, -0.7100000000000000754951657, 0.2924600000000002752997830, -0.3780649440000002359241194, -0.2343283819200001061311411, -0.2910987963200001304997500, -0.3478692107200002103795100, 0.5953603748799998207630324 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/test/test.dorg2r.js b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/test.dorg2r.js new file mode 100644 index 000000000000..c3a93c099dda --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/test.dorg2r.js @@ -0,0 +1,208 @@ +/** +* @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 dorg2r = require( './../lib/dorg2r.js' ); + + +// FIXTURES // + +// Note: the outputs are tested against the outputs of the Fortran implementation. + +var COL_MAJOR = require( './fixtures/column_major.json' ); +var ROW_MAJOR = require( './fixtures/row_major.json' ); +var COL_MAJOR_K_LT_N = require( './fixtures/column_major_k_lt_n.json' ); +var ROW_MAJOR_K_LT_N = require( './fixtures/row_major_k_lt_n.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dorg2r, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( dorg2r.length, 8, '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 work; + var tau; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + work = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len + tau = new Float64Array( [ 0.0, 0.0 ] ); + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.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() { + dorg2r( value, 3, 2, 2, A, 3, tau, work ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is not a valid `LDA` value (row-major)', function test( t ) { + var values; + var work; + var tau; + var A; + var i; + + values = [ + 0, + 1 + ]; + + work = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len + tau = new Float64Array( [ 0.0, 0.0 ] ); + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + 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() { + dorg2r( 'row-major', 3, 2, 2, A, value, tau, work ); + }; + } +}); + +tape( 'the function generates an orthonormal matrix Q (column-major)', function test( t ) { + var expected; + var data; + var work; + var out; + var tau; + var A; + + data = COL_MAJOR; + + A = new Float64Array( data.A ); + tau = new Float64Array( data.tau ); + work = new Float64Array( data.work ); + + expected = new Float64Array( data.A_out ); + + out = dorg2r( 'column-major', data.M, data.N, data.K, A, data.LDA, tau, work ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function generates an orthonormal matrix Q (row-major)', function test( t ) { + var expected; + var data; + var work; + var out; + var tau; + var A; + + data = ROW_MAJOR; + + A = new Float64Array( data.A ); + tau = new Float64Array( data.tau ); + work = new Float64Array( data.work ); + + expected = new Float64Array( data.A_out ); + + out = dorg2r( 'row-major', data.M, data.N, data.K, A, data.LDA, tau, work ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function generates an orthonormal matrix Q (column-major, K < N)', function test( t ) { + var expected; + var data; + var work; + var out; + var tau; + var A; + + data = COL_MAJOR_K_LT_N; + + A = new Float64Array( data.A ); + tau = new Float64Array( data.tau ); + work = new Float64Array( data.work ); + + expected = new Float64Array( data.A_out ); + + out = dorg2r( 'column-major', data.M, data.N, data.K, A, data.LDA, tau, work ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function generates an orthonormal matrix Q (row-major, K < N)', function test( t ) { + var expected; + var data; + var work; + var out; + var tau; + var A; + + data = ROW_MAJOR_K_LT_N; + + A = new Float64Array( data.A ); + tau = new Float64Array( data.tau ); + work = new Float64Array( data.work ); + + expected = new Float64Array( data.A_out ); + + out = dorg2r( 'row-major', data.M, data.N, data.K, A, data.LDA, tau, work ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/test/test.js b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/test.js new file mode 100644 index 000000000000..ca636d9b312a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/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 dorg2r = 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 dorg2r, '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 dorg2r.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 dorg2r = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dorg2r, 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 dorg2r; + var main; + + main = require( './../lib/dorg2r.js' ); + + dorg2r = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dorg2r, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dorg2r/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/test.ndarray.js new file mode 100644 index 000000000000..9df678c11f67 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dorg2r/test/test.ndarray.js @@ -0,0 +1,163 @@ +/** +* @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 */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dorg2r = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +// Note: the outputs are tested against the outputs of the Fortran implementation. + +var COL_MAJOR = require( './fixtures/column_major.json' ); +var ROW_MAJOR = require( './fixtures/row_major.json' ); +var COL_MAJOR_K_LT_N = require( './fixtures/column_major_k_lt_n.json' ); +var ROW_MAJOR_K_LT_N = require( './fixtures/row_major_k_lt_n.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dorg2r, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 13', function test( t ) { + t.strictEqual( dorg2r.length, 13, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates an orthogonal matrix Q (column-major)', function test( t ) { + var expected; + var work; + var data; + var out; + var tau; + var A; + + data = COL_MAJOR; + + A = new Float64Array( data.A ); + tau = new Float64Array( data.tau ); + work = new Float64Array( data.work ); + + expected = new Float64Array( data.A_out ); + + out = dorg2r( data.M, data.N, data.K, A, data.strideA1, data.strideA2, data.offsetA, tau, data.strideTau, data.offsetTau, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function generates an orthogonal matrix Q (row-major)', function test( t ) { + var expected; + var work; + var data; + var out; + var tau; + var A; + + data = ROW_MAJOR; + + A = new Float64Array( data.A ); + tau = new Float64Array( data.tau ); + work = new Float64Array( data.work ); + + expected = new Float64Array( data.A_out ); + + out = dorg2r( data.M, data.N, data.K, A, data.strideA1, data.strideA2, data.offsetA, tau, data.strideTau, data.offsetTau, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function generates an orthogonal matrix Q (column-major, K < N)', function test( t ) { + var expected; + var work; + var data; + var out; + var tau; + var A; + + data = COL_MAJOR_K_LT_N; + + A = new Float64Array( data.A ); + tau = new Float64Array( data.tau ); + work = new Float64Array( data.work ); + + expected = new Float64Array( data.A_out ); + + out = dorg2r( data.M, data.N, data.K, A, data.strideA1, data.strideA2, data.offsetA, tau, data.strideTau, data.offsetTau, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function generates an orthogonal matrix Q (row-major, K < N)', function test( t ) { + var expected; + var work; + var data; + var out; + var tau; + var A; + + data = ROW_MAJOR_K_LT_N; + + A = new Float64Array( data.A ); + tau = new Float64Array( data.tau ); + work = new Float64Array( data.work ); + + expected = new Float64Array( data.A_out ); + + out = dorg2r( data.M, data.N, data.K, A, data.strideA1, data.strideA2, data.offsetA, tau, data.strideTau, data.offsetTau, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the input matrix unchanged if `N` <= 0', function test( t ) { + var expected; + var work; + var out; + var tau; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + tau = new Float64Array( [ 0.0, 0.0 ] ); + work = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + out = dorg2r( 3, 0, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +});