diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/README.md b/lib/node_modules/@stdlib/lapack/base/dormbr/README.md new file mode 100644 index 000000000000..089fd48ef2da --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/README.md @@ -0,0 +1,368 @@ + + +# dormbr + +> Multiply a general matrix by the orthogonal matrix from a bi-diagonal reduction determined by `DGEBRD`. + +
+ +`dormbr` overwrites the general real `M` by `N` matrix `C` by the orthogonal matrix `Q` or `P^T` determined by [`dgebrd`][@stdlib/lapack/base/dgebrd] when reducing a real matrix `A` to bi-diagonal form, `A = Q * B * P^T`. + +- If `VECT = 'Q'`, `dormbr` overwrites `C` with `Q * C`, `Q^T * C`, `C * Q`, or `C * Q^T`, depending on `SIDE` and `TRANS`. +- If `VECT = 'P'`, `dormbr` overwrites `C` with `P * C`, `P^T * C`, `C * P`, or `C * P^T`, depending on `SIDE` and `TRANS`. + +The matrices `Q` and `P^T` are represented as products of elementary reflectors + + + +```math +A = Q B P^T +``` + + + +
+ + + +
+ +## Usage + +```javascript +var dormbr = require( '@stdlib/lapack/base/dormbr' ); +``` + +#### dormbr( order, vect, side, trans, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK ) + +Multiplies a general matrix by the orthogonal matrix from a bi-diagonal reduction determined by `DGEBRD`. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1, 0, 0 ] ); +var TAU = new Float64Array( [ 2 ] ); +var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); +var WORK = new Float64Array( 3 ); + +var info = dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); +// returns 0 +// C => [ -1, -3, -5, 2, 4, 6 ] +// WORK[ 0 ] => 96 +``` + +The function has the following parameters: + +- **order**: storage layout. Must be either `'row-major'` or `'column-major'`. +- **vect**: specifies whether the matrix `Q` or the matrix `P` is applied. Must be either `'Q'` or `'P'`. +- **side**: specifies the side of multiplication with `C`. Use `'left'` to form `Q * C`, `Q^T * C`, `P * C`, or `P^T * C`, and `'right'` to form `C * Q`, `C * Q^T`, `C * P`, or `C * P^T`. +- **trans**: transpose operation. Use `'no-transpose'` for `Q` or `P` and `'transpose'` for `Q^T` or `P^T`. +- **M**: number of rows of `C`. +- **N**: number of columns of `C`. +- **K**: number of elementary reflectors whose product defines the matrix `Q` or `P`. +- **A**: reflector vectors from `DGEBRD` as a [`Float64Array`][@stdlib/array/float64]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **TAU**: scalar factors of elementary reflectors as a [`Float64Array`][@stdlib/array/float64]. +- **C**: input/output matrix stored in linear memory as a [`Float64Array`][@stdlib/array/float64]. +- **LDC**: stride of the first dimension of `C` (a.k.a., leading dimension of the matrix `C`). +- **WORK**: workspace array as a [`Float64Array`][@stdlib/array/float64]. +- **LWORK**: dimension of the array `WORK`. + +When `side` is `'left'`: + +- `WORK` must have length `LWORK >= max(1, N)`. +- `LDA` must be greater than or equal to `max(1, NQ)` for column-major layout and `max(1, K)` for row-major layout, where `NQ` is the order of `Q` or `P` (i.e., `NQ = M`). + +When `side` is `'right'`: + +- `WORK` must have length `LWORK >= max(1, M)`. +- `LDA` must be greater than or equal to `max(1, NQ)` for column-major layout and `max(1, K)` for row-major layout, where `NQ` is the order of `Q` or `P` (i.e., `NQ = N`). + +If `LWORK` is equal to `-1`, the function returns a workspace query and only the first element of `WORK` is modified with the optimal workspace size. + +The function overwrites `C` with: + +- `Q * C` if `VECT = 'Q'`, `SIDE = 'left'`, and `TRANS = 'no-transpose'` +- `Q^T * C` if `VECT = 'Q'`, `SIDE = 'left'`, and `TRANS = 'transpose'` +- `C * Q` if `VECT = 'Q'`, `SIDE = 'right'`, and `TRANS = 'no-transpose'` +- `C * Q^T` if `VECT = 'Q'`, `SIDE = 'right'`, and `TRANS = 'transpose'` +- `P * C` if `VECT = 'P'`, `SIDE = 'left'`, and `TRANS = 'no-transpose'` +- `P^T * C` if `VECT = 'P'`, `SIDE = 'left'`, and `TRANS = 'transpose'` +- `C * P` if `VECT = 'P'`, `SIDE = 'right'`, and `TRANS = 'no-transpose'` +- `C * P^T` if `VECT = 'P'`, `SIDE = 'right'`, and `TRANS = 'transpose'` + +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, 0 ] ); +var TAU0 = new Float64Array( [ 0.0, 2 ] ); +var C0 = new Float64Array( [ 0.0, 1, 3, 5, 2, 4, 6 ] ); +var WORK0 = new Float64Array( 4 ); + +// Create offset views... +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var TAU1 = new Float64Array( TAU0.buffer, TAU0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var C1 = new Float64Array( C0.buffer, C0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var WORK1 = new Float64Array( WORK0.buffer, WORK0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A1, 2, TAU1, C1, 3, WORK1, 3 ); +// C0 => [ 0.0, -1, -3, -5, 2, 4, 6 ] +``` + + + +#### dormbr.ndarray( vect, side, trans, M, N, K, A, sa1, sa2, oa, TAU, st, ot, C, sc1, sc2, oc, WORK, sw, ow, LWORK ) + +Multiplies a general matrix by the orthogonal matrix from a bi-diagonal reduction determined by `DGEBRD` using alternative indexing semantics. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1, 0, 0 ] ); +var TAU = new Float64Array( [ 2 ] ); +var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); +var WORK = new Float64Array( 3 ); + +var info = dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); +// returns 0 +// C => [ -1, -3, -5, 2, 4, 6 ] +// WORK[ 0 ] => 96 +``` + +The function has the following additional parameters: + +- **vect**: specifies whether the matrix `Q` or the matrix `P` is applied. +- **side**: specifies the side of multiplication with `C`. +- **trans**: transpose operation. +- **M**: number of rows of `C`. +- **N**: number of columns of `C`. +- **K**: number of elementary reflectors. +- **A**: reflector vectors from `DGEBRD` as a [`Float64Array`][@stdlib/array/float64]. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. +- **TAU**: scalar factors of elementary reflectors as a [`Float64Array`][@stdlib/array/float64]. +- **st**: stride length for `TAU`. +- **ot**: starting index for `TAU`. +- **C**: input/output matrix as a [`Float64Array`][@stdlib/array/float64]. +- **sc1**: stride of the first dimension of `C`. +- **sc2**: stride of the second dimension of `C`. +- **oc**: starting index for `C`. +- **WORK**: workspace array as a [`Float64Array`][@stdlib/array/float64]. +- **sw**: stride length for `WORK`. +- **ow**: starting index for `WORK`. +- **LWORK**: dimension of the array `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, 1, 0, 0 ] ); +var TAU = new Float64Array( [ 0.0, 2 ] ); +var C = new Float64Array( [ 0.0, 1, 3, 5, 2, 4, 6 ] ); +var WORK = new Float64Array( 4 ); + +var info = dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 1, TAU, 1, 1, C, 3, 1, 1, WORK, 1, 1, 3 ); +// C => [ 0.0, -1, -3, -5, 2, 4, 6 ] +``` + +
+ + + +
+ +## Notes + +- `dormbr()` corresponds to the [LAPACK][LAPACK] routine [`dormbr`][lapack-dormbr]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var dormbr = require( '@stdlib/lapack/base/dormbr' ); + +// Define a matrix C stored in column-major order: +var shape = [ 2, 3 ]; +var order = 'column-major'; +var strides = shape2strides( shape, order ); + +var C = new Float64Array( [ 1.0, 2.0, 4.0, 5.0, 3.0, 6.0 ] ); +console.log( ndarray2array( C, shape, strides, 0, order ) ); + +// Define the reflector vector A (stored in column-major order, LDA=2) and scalar factors: +var A = new Float64Array( [ 1.0, 0.0, 0.0 ] ); +var TAU = new Float64Array( [ 2.0 ] ); +var WORK = new Float64Array( 3 ); + +// Apply the orthogonal matrix Q from the left (no transpose): +var info = dormbr( order, 'Q', 'left', 'no-transpose', shape[ 0 ], shape[ 1 ], 1, A, 2, TAU, C, strides[ 1 ], WORK, WORK.length ); +console.log( ndarray2array( C, shape, strides, 0, order ) ); +console.log( info ); + +// Define a matrix C stored in column-major order: +shape = [ 4, 3 ]; +strides = shape2strides( shape, order ); + +C = new Float64Array( [ + 4.0, 5.0, 6.0, 7.0, + 7.0, 8.0, 9.0, 10.0, + 10.0, 11.0, 12.0, 13.0 +] ); +console.log( ndarray2array( C, shape, strides, 0, order ) ); + +// Define the reflector vectors A (stored in column-major order, LDA=4) and scalar factors: +A = new Float64Array( [ + 1.0, 0.0, 0.0, -0.125, + 0.5, 1.0, 0.0, 0.25, + 0.25, 0.5, 1.0, 0.5, + 0.0, 0.0, 0.0, 0.0 +] ); +TAU = new Float64Array( [ 1.5, 0.75, 0.0 ] ); +WORK = new Float64Array( 3 ); + +// Apply the orthogonal matrix P^T from the left (no transpose): +info = dormbr( order, 'P', 'left', 'no-transpose', shape[ 0 ], shape[ 1 ], 3, A, 4, TAU, C, strides[ 1 ], WORK, WORK.length ); +console.log( ndarray2array( C, shape, strides, 0, order ) ); +console.log( info ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dormbr/benchmark/benchmark.js new file mode 100644 index 000000000000..8bff3626c1b6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/benchmark/benchmark.js @@ -0,0 +1,149 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dormbr = require( './../lib/dormbr.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; +var VECTORS = [ + 'Q', + 'P' +]; +var SIDES = [ + 'left', + 'right' +]; +var TRANSPOSES = [ + 'no-transpose', + 'transpose' +]; +var opts = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {string} vect - specifies whether to apply `Q` or `P` +* @param {string} side - operation side +* @param {string} trans - transpose operation +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, vect, side, trans, N ) { + var LWORK = N * 32; + var WORK = new Float64Array( LWORK ); + var TAU = discreteUniform(N, 1.0, 2.0, opts); + var A = discreteUniform( N*N, 1.0, 10.0, opts ); + var C = discreteUniform( N*N, 1.0, 10.0, opts ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dormbr( order, vect, side, trans, N, N, N, A, N, TAU, C, N, WORK, LWORK ); + if ( d < 0 ) { + b.fail( 'should return a success status code' ); + } + } + b.toc(); + if ( d < 0 ) { + b.fail( 'should return a success status code' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var trans; + var vect; + var side; + var min; + var max; + var ord; + var N; + var f; + var i; + var j; + var k; + var l; + var m; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( m = 0; m < VECTORS.length; m++ ) { + vect = VECTORS[ m ]; + for ( l = 0; l < TRANSPOSES.length; l++ ) { + trans = TRANSPOSES[ l ]; + for ( j = 0; j < SIDES.length; j++ ) { + side = SIDES[ j ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); + f = createBenchmark( ord, vect, side, trans, N ); + bench( format( '%s::square_matrix:order=%s,vect=%s,side=%s,trans=%s,size=%d', pkg, ord, vect, side, trans, N*N ), f ); + } + } + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dormbr/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..097a56fe3fc5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/benchmark/benchmark.ndarray.js @@ -0,0 +1,166 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var Float64Array = require( '@stdlib/array/float64' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dormbr = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; +var VECTORS = [ + 'Q', + 'P' +]; +var SIDES = [ + 'left', + 'right' +]; +var TRANSPOSES = [ + 'no-transpose', + 'transpose' +]; +var opts = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {string} vect - specifies whether to apply `Q` or `P` +* @param {string} side - operation side +* @param {string} trans - transpose operation +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, vect, side, trans, N ) { + var LWORK = N * 32; + var WORK = new Float64Array( LWORK ); + var TAU = discreteUniform(N, 1.0, 2.0, opts); + var sa1; + var sa2; + var sc1; + var sc2; + var A = discreteUniform( N*N, 1.0, 10.0, opts ); + var C = discreteUniform( N*N, 1.0, 10.0, opts ); + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + sc1 = 1; + sc2 = N; + } else { // order === 'row-major' + sa1 = N; + sa2 = 1; + sc1 = N; + sc2 = 1; + } + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dormbr( vect, side, trans, N, N, N, A, sa1, sa2, 0, TAU, 1, 0, C, sc1, sc2, 0, WORK, 1, 0, LWORK ); + if ( d < 0 ) { + b.fail( 'should return a success status code' ); + } + } + b.toc(); + if ( d < 0 ) { + b.fail( 'should return a success status code' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var trans; + var vect; + var side; + var min; + var max; + var ord; + var N; + var f; + var i; + var j; + var k; + var l; + var m; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( m = 0; m < VECTORS.length; m++ ) { + vect = VECTORS[ m ]; + for ( l = 0; l < TRANSPOSES.length; l++ ) { + trans = TRANSPOSES[ l ]; + for ( j = 0; j < SIDES.length; j++ ) { + side = SIDES[ j ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); + f = createBenchmark( ord, vect, side, trans, N ); + bench( format( '%s::square_matrix:order=%s,vect=%s,side=%s,trans=%s,size=%d:ndarray', pkg, ord, vect, side, trans, N*N ), f ); + } + } + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dormbr/docs/repl.txt new file mode 100644 index 000000000000..612912cce158 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/docs/repl.txt @@ -0,0 +1,202 @@ + +{{alias}}( order, vect, side, trans, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK ) + Multiplies a general matrix by the orthogonal matrix from a bi-diagonal + reduction determined by `DGEBRD`. + + `Q` and `P^T` are the orthogonal matrices determined by `DGEBRD` when + reducing a real matrix `A` to bi-diagonal form, `A = Q * B * P^T`. + + If VECT = 'Q', the function overwrites the general real `M` by `N` matrix + `C` with `Q * C`, `Q^T * C`, `C * Q`, or `C * Q^T`, depending on SIDE and + TRANS. If VECT = 'P', the function overwrites `C` with `P * C`, `P^T * C`, + `C * P`, or `C * P^T`, depending on SIDE and TRANS. + + If SIDE = 'left', `LWORK >= max(1,N)`. If SIDE = 'right', + `LWORK >= max(1,M)`. + + For optimum performance, `LWORK >= N*NB` if SIDE = 'left', and + `LWORK >= M*NB` if SIDE = 'right', where `NB` is the optimal blocksize. + + If `LWORK` is equal to `-1`, the function returns a workspace query and + only the first element of `WORK` is modified. + + Parameters + ---------- + order: string + Storage layout. Must be either 'row-major' or 'column-major'. + + vect: string + Specifies whether the matrix `Q` or the matrix `P` is applied. Must be + either 'Q' or 'P'. + + side: string + Specifies the side of multiplication with `C`. Use `'left'` to form + `Q * C` or `P * C` (or the transposed variants), and `'right'` to form + `C * Q` or `C * P` (or the transposed variants). + + trans: string + Transpose operation. Use `'no-transpose'` for `Q` or `P` and + `'transpose'` for `Q^T` or `P^T`. + + M: integer + Number of rows of `C`. + + N: integer + Number of columns of `C`. + + K: integer + Number of elementary reflectors. + + A: Float64Array + Reflector vectors from `DGEBRD`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of + the matrix `A`). + + TAU: Float64Array + Scalar factors of elementary reflectors. + + C: Float64Array + Input/output matrix. + + LDC: integer + Stride of the first dimension of `C` (a.k.a., leading dimension of + the matrix `C`). + + WORK: Float64Array + Workspace array. + + LWORK: integer + Dimension of the array `WORK`. + + Returns + ------- + info: integer + Status code indicating whether the operation completed successfully. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1, 0, 0 ] ); + > var TAU = new {{alias:@stdlib/array/float64}}( [ 2 ] ); + > var C = new {{alias:@stdlib/array/float64}}( [ 1, 3, 5, 2, 4, 6 ] ); + > var WORK = new {{alias:@stdlib/array/float64}}( 3 ); + > {{alias}}( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ) + 0 + > C + [ -1, -3, -5, 2, 4, 6 ] + > WORK[ 0 ] + 96 + + +{{alias}}.ndarray( vect, side, trans, M, N, K, A, sa1, sa2, oa, TAU, st, ot, C, sc1, sc2, oc, WORK, sw, ow, LWORK ) + Multiplies a general matrix by the orthogonal matrix from a bi-diagonal + reduction determined by `DGEBRD` using alternative indexing semantics. + + `Q` and `P^T` are the orthogonal matrices determined by `DGEBRD` when + reducing a real matrix `A` to bi-diagonal form, `A = Q * B * P^T`. + + If VECT = 'Q', the function overwrites the general real `M` by `N` matrix + `C` with `Q * C`, `Q^T * C`, `C * Q`, or `C * Q^T`, depending on SIDE and + TRANS. If VECT = 'P', the function overwrites `C` with `P * C`, `P^T * C`, + `C * P`, or `C * P^T`, depending on SIDE and TRANS. + + If SIDE = 'left', `LWORK >= max(1,N)`. If SIDE = 'right', + `LWORK >= max(1,M)`. + + If `LWORK` is equal to `-1`, the function returns a workspace query and + only the first element of `WORK` is modified. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + vect: string + Specifies whether the matrix `Q` or the matrix `P` is applied. Must be + either 'Q' or 'P'. + + side: string + Specifies the side of multiplication with `C`. Use `'left'` to form + `Q * C` or `P * C` (or the transposed variants), and `'right'` to form + `C * Q` or `C * P` (or the transposed variants). + + trans: string + Transpose operation. Use `'no-transpose'` for `Q` or `P` and + `'transpose'` for `Q^T` or `P^T`. + + M: integer + Number of rows of `C`. + + N: integer + Number of columns of `C`. + + K: integer + Number of elementary reflectors. + + A: Float64Array + Reflector vectors from `DGEBRD`. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Starting index for `A`. + + TAU: Float64Array + Scalar factors of elementary reflectors. + + st: integer + Stride length for `TAU`. + + ot: integer + Starting index for `TAU`. + + C: Float64Array + Input/output matrix. + + sc1: integer + Stride of the first dimension of `C`. + + sc2: integer + Stride of the second dimension of `C`. + + oc: integer + Starting index for `C`. + + WORK: Float64Array + Workspace array. + + sw: integer + Stride length for `WORK`. + + ow: integer + Starting index for `WORK`. + + LWORK: integer + Dimension of the array `WORK`. + + Returns + ------- + info: integer + Status code indicating whether the operation completed successfully. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1, 0, 0 ] ); + > var TAU = new {{alias:@stdlib/array/float64}}( [ 2 ] ); + > var C = new {{alias:@stdlib/array/float64}}( [ 1, 3, 5, 2, 4, 6 ] ); + > var WORK = new {{alias:@stdlib/array/float64}}( 3 ); + > {{alias}}.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ) + 0 + > C + [ -1, -3, -5, 2, 4, 6 ] + > WORK[ 0 ] + 96 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dormbr/docs/types/index.d.ts new file mode 100644 index 000000000000..9740b1fa1c85 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/docs/types/index.d.ts @@ -0,0 +1,222 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout, OperationSide, TransposeOperation } from '@stdlib/types/blas'; + +/** +* Status code. +* +* ## Notes +* +* The status code indicates whether the operation completed successfully. A value of `0` indicates success. +*/ +type StatusCode = number; + +/** +* Interface describing `dormbr`. +*/ +interface Routine { + /** + * Multiplies a general matrix by the orthogonal matrix from a bi-diagonal reduction determined by `DGEBRD`. + * + * ## Notes + * + * - `Q` and `P^T` are the orthogonal matrices determined by `DGEBRD` when reducing a real matrix `A` to bi-diagonal form, `A = Q * B * P^T`. + * + * - If VECT = 'Q', `DORMBR` overwrites the general real `M` by `N` matrix `C` with, + * + * - `Q * C` if SIDE = 'left' and TRANS = 'no-transpose', or + * - `Q^T * C` if SIDE = 'left' and TRANS = 'transpose', or + * - `C * Q` if SIDE = 'right' and TRANS = 'no-transpose', or + * - `C * Q^T` if SIDE = 'right' and TRANS = 'transpose'. + * + * - If VECT = 'P', `DORMBR` overwrites the general real `M` by `N` matrix `C` with, + * + * - `P * C` if SIDE = 'left' and TRANS = 'no-transpose', or + * - `P^T * C` if SIDE = 'left' and TRANS = 'transpose', or + * - `C * P` if SIDE = 'right' and TRANS = 'no-transpose', or + * - `C * P^T` if SIDE = 'right' and TRANS = 'transpose'. + * + * - If SIDE = 'left', `LWORK >= max(1,N)`. + * + * - If SIDE = 'right', `LWORK >= max(1,M)`. + * + * @param order - storage layout + * @param vect - specifies whether the matrix `Q` or the matrix `P` is applied + * @param side - specifies the side of multiplication with `C` + * @param trans - `'no-transpose'` for `Q` or `P`, `'transpose'` for `Q^T` or `P^T` + * @param M - number of rows of `C` + * @param N - number of columns of `C` + * @param K - number of elementary reflectors + * @param A - reflector vectors from `DGEBRD` + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param TAU - scalar factors of elementary reflectors + * @param C - input/output matrix + * @param LDC - stride of the first dimension of `C` (a.k.a., leading dimension of the matrix `C`) + * @param WORK - workspace array + * @param LWORK - dimension of the array `WORK` + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1, 0, 0 ] ); + * var TAU = new Float64Array( [ 2 ] ); + * var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + * var WORK = new Float64Array( 3 ); + * + * var info = dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); + * // returns 0 + * // C => [ -1, -3, -5, 2, 4, 6 ] + */ + ( order: Layout, vect: 'Q' | 'P', side: OperationSide, trans: TransposeOperation, M: number, N: number, K: number, A: Float64Array, LDA: number, TAU: Float64Array, C: Float64Array, LDC: number, WORK: Float64Array, LWORK: number ): StatusCode; + + /** + * Multiplies a general matrix by the orthogonal matrix from a bi-diagonal reduction determined by `DGEBRD` using alternative indexing semantics. + * + * ## Notes + * + * - `Q` and `P^T` are the orthogonal matrices determined by `DGEBRD` when reducing a real matrix `A` to bi-diagonal form, `A = Q * B * P^T`. + * + * - If VECT = 'Q', `DORMBR` overwrites the general real `M` by `N` matrix `C` with, + * + * - `Q * C` if SIDE = 'left' and TRANS = 'no-transpose', or + * - `Q^T * C` if SIDE = 'left' and TRANS = 'transpose', or + * - `C * Q` if SIDE = 'right' and TRANS = 'no-transpose', or + * - `C * Q^T` if SIDE = 'right' and TRANS = 'transpose'. + * + * - If VECT = 'P', `DORMBR` overwrites the general real `M` by `N` matrix `C` with, + * + * - `P * C` if SIDE = 'left' and TRANS = 'no-transpose', or + * - `P^T * C` if SIDE = 'left' and TRANS = 'transpose', or + * - `C * P` if SIDE = 'right' and TRANS = 'no-transpose', or + * - `C * P^T` if SIDE = 'right' and TRANS = 'transpose'. + * + * - If SIDE = 'left', `LWORK >= max(1,N)`. + * + * - If SIDE = 'right', `LWORK >= max(1,M)`. + * + * @param vect - specifies whether the matrix `Q` or the matrix `P` is applied + * @param side - specifies the side of multiplication with `C` + * @param trans - `'no-transpose'` for `Q` or `P`, `'transpose'` for `Q^T` or `P^T` + * @param M - number of rows of `C` + * @param N - number of columns of `C` + * @param K - number of elementary reflectors + * @param A - reflector vectors from `DGEBRD` + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index for `A` + * @param TAU - scalar factors of elementary reflectors + * @param strideTAU - stride for `TAU` + * @param offsetTAU - starting index for `TAU` + * @param C - input/output matrix + * @param strideC1 - stride of the first dimension of `C` + * @param strideC2 - stride of the second dimension of `C` + * @param offsetC - starting index for `C` + * @param WORK - workspace array + * @param strideWORK - stride for `WORK` + * @param offsetWORK - starting index for `WORK` + * @param LWORK - dimension of the array `WORK` + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1, 0, 0 ] ); + * var TAU = new Float64Array( [ 2 ] ); + * var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + * var WORK = new Float64Array( 3 ); + * + * var info = dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); + * // returns 0 + * // C => [ -1, -3, -5, 2, 4, 6 ] + */ + ndarray( vect: 'Q' | 'P', side: OperationSide, trans: TransposeOperation, M: number, N: number, K: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, TAU: Float64Array, strideTAU: number, offsetTAU: number, C: Float64Array, strideC1: number, strideC2: number, offsetC: number, WORK: Float64Array, strideWORK: number, offsetWORK: number, LWORK: number ): StatusCode; +} + +/** +* Multiplies a general matrix by the orthogonal matrix from a bi-diagonal reduction determined by `DGEBRD`. +* +* ## Notes +* +* - `Q` and `P^T` are the orthogonal matrices determined by `DGEBRD` when reducing a real matrix `A` to bi-diagonal form, `A = Q * B * P^T`. +* +* - If VECT = 'Q', `DORMBR` overwrites the general real `M` by `N` matrix `C` with, +* +* - `Q * C` if SIDE = 'left' and TRANS = 'no-transpose', or +* - `Q^T * C` if SIDE = 'left' and TRANS = 'transpose', or +* - `C * Q` if SIDE = 'right' and TRANS = 'no-transpose', or +* - `C * Q^T` if SIDE = 'right' and TRANS = 'transpose'. +* +* - If VECT = 'P', `DORMBR` overwrites the general real `M` by `N` matrix `C` with, +* +* - `P * C` if SIDE = 'left' and TRANS = 'no-transpose', or +* - `P^T * C` if SIDE = 'left' and TRANS = 'transpose', or +* - `C * P` if SIDE = 'right' and TRANS = 'no-transpose', or +* - `C * P^T` if SIDE = 'right' and TRANS = 'transpose'. +* +* @param order - storage layout +* @param vect - specifies whether the matrix `Q` or the matrix `P` is applied +* @param side - specifies the side of multiplication with `C` +* @param trans - `'no-transpose'` for `Q` or `P`, `'transpose'` for `Q^T` or `P^T` +* @param M - number of rows of `C` +* @param N - number of columns of `C` +* @param K - number of elementary reflectors +* @param A - reflector vectors from `DGEBRD` +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param TAU - scalar factors of elementary reflectors +* @param C - input/output matrix +* @param LDC - stride of the first dimension of `C` (a.k.a., leading dimension of the matrix `C`) +* @param WORK - workspace array +* @param LWORK - dimension of the array `WORK` +* @returns status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1, 0, 0 ] ); +* var TAU = new Float64Array( [ 2 ] ); +* var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); +* var WORK = new Float64Array( 3 ); +* +* var info = dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); +* // returns 0 +* // C => [ -1, -3, -5, 2, 4, 6 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1, 0, 0 ] ); +* var TAU = new Float64Array( [ 2 ] ); +* var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); +* var WORK = new Float64Array( 3 ); +* +* var info = dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); +* // returns 0 +* // C => [ -1, -3, -5, 2, 4, 6 ] +*/ +declare var dormbr: Routine; + + +// EXPORTS // + +export = dormbr; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dormbr/docs/types/test.ts new file mode 100644 index 000000000000..3cfecea7702a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/docs/types/test.ts @@ -0,0 +1,451 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import dormbr = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectType number + dormbr( 'column-major', 'P', 'right', 'transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a valid layout... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 5, 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( true, 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( false, 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( null, 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( void 0, 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( [], 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( {}, 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( ( x: number ): number => x, 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a valid vector... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 5, 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', true, 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', false, 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', null, 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', void 0, 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', [], 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', {}, 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', ( x: number ): number => x, 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a valid operation side... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 'Q', 5, 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', true, 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', false, 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', null, 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', void 0, 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', [], 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', {}, 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', ( x: number ): number => x, 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a valid transpose operation... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 'Q', 'left', 5, 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', true, 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', false, 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', null, 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', void 0, 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', [], 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', {}, 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', ( x: number ): number => x, 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 'Q', 'left', 'no-transpose', '5', 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', true, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', false, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', null, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', void 0, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', [], 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', {}, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', ( x: number ): number => x, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, '5', 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, true, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, false, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, null, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, void 0, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, [], 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, {}, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, ( x: number ): number => x, 1, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, '5', A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, true, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, false, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, null, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, void 0, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, [], A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, {}, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, ( x: number ): number => x, A, 2, TAU, C, 3, WORK, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a Float64Array... +{ + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, 5, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, true, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, false, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, null, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, void 0, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, [], 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, {}, 2, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, ( x: number ): number => x, 2, TAU, C, 3, WORK, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, '5', TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, true, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, false, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, null, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, void 0, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, [], TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, {}, TAU, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, ( x: number ): number => x, TAU, C, 3, WORK, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a Float64Array... +{ + const A = new Float64Array( 3 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 5, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, true, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, false, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, null, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, void 0, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, [], C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, {}, C, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, ( x: number ): number => x, C, 3, WORK, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a Float64Array... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, 5, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, true, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, false, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, null, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, void 0, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, [], 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, {}, 3, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, ( x: number ): number => x, 3, WORK, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, '5', WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, true, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, false, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, null, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, void 0, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, [], WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, {}, WORK, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, ( x: number ): number => x, WORK, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not a Float64Array... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, 5, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, true, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, false, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, null, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, void 0, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, [], 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, {}, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, ( x: number ): number => x, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourteenth argument which is not a number... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, '5' ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, true ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, false ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, null ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, void 0 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, [] ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, {} ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr(); // $ExpectError + dormbr( 'row-major' ); // $ExpectError + dormbr( 'row-major', 'Q' ); // $ExpectError + dormbr( 'row-major', 'Q', 'left' ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose' ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3 ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK ); // $ExpectError + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3, 10 ); // $ExpectError +} + +// Attached to the main export is an `ndarray` method which returns a number... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectType number + dormbr.ndarray( 'P', 'right', 'transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectType number +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a valid vector... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr.ndarray( 5, 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( true, 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( false, 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( null, 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( void 0, 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( [], 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( {}, 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( ( x: number ): number => x, 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a valid operation side... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr.ndarray( 'Q', 5, 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', true, 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', false, 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', null, 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', void 0, 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', [], 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', {}, 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', ( x: number ): number => x, 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a valid transpose operation... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr.ndarray( 'Q', 'left', 5, 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', true, 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', false, 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', null, 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', void 0, 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', [], 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', {}, 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', ( x: number ): number => x, 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr.ndarray( 'Q', 'left', 'no-transpose', '5', 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', true, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', false, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', null, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', void 0, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', [], 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', {}, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', ( x: number ): number => x, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, '5', 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, true, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, false, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, null, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, void 0, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, [], 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, {}, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, ( x: number ): number => x, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, '5', A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, true, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, false, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, null, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, void 0, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, [], A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, {}, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, ( x: number ): number => x, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a Float64Array... +{ + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, 5, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, true, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, false, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, null, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, void 0, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, [], 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, {}, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, ( x: number ): number => x, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const A = new Float64Array( 3 ); + const TAU = new Float64Array( 1 ); + const C = new Float64Array( 6 ); + const WORK = new Float64Array( 3 ); + + dormbr.ndarray(); // $ExpectError + dormbr.ndarray( 'Q' ); // $ExpectError + dormbr.ndarray( 'Q', 'left' ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose' ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0 ); // $ExpectError + dormbr.ndarray( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dormbr/examples/index.js new file mode 100644 index 000000000000..2eb403fc778b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/examples/index.js @@ -0,0 +1,89 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var dormbr = require( './../lib' ); + +// Define a matrix C stored in column-major order: +var shape = [ 2, 3 ]; +var order = 'column-major'; +var strides = shape2strides( shape, order ); + +var C = new Float64Array( [ 1.0, 2.0, 4.0, 5.0, 3.0, 6.0 ] ); +console.log( ndarray2array( C, shape, strides, 0, order ) ); + +// Define the reflector vector A (stored in column-major order, LDA=2) and scalar factors: +var A = new Float64Array( [ 1.0, 0.0, 0.0 ] ); +var TAU = new Float64Array( [ 2.0 ] ); +var WORK = new Float64Array( 3 ); + +// Apply the orthogonal matrix Q from the left (no transpose): +var info = dormbr( order, 'Q', 'left', 'no-transpose', shape[ 0 ], shape[ 1 ], 1, A, 2, TAU, C, strides[ 1 ], WORK, WORK.length ); +console.log( ndarray2array( C, shape, strides, 0, order ) ); +console.log( info ); + +// Define a matrix C stored in column-major order: +shape = [ 4, 3 ]; +strides = shape2strides( shape, order ); + +C = new Float64Array([ + 4.0, + 5.0, + 6.0, + 7.0, + 7.0, + 8.0, + 9.0, + 10.0, + 10.0, + 11.0, + 12.0, + 13.0 +]); +console.log( ndarray2array( C, shape, strides, 0, order ) ); + +// Define the reflector vectors A (stored in column-major order, LDA=4) and scalar factors: +A = new Float64Array([ + 1.0, + 0.0, + 0.0, + -0.125, + 0.5, + 1.0, + 0.0, + 0.25, + 0.25, + 0.5, + 1.0, + 0.5, + 0.0, + 0.0, + 0.0, + 0.0 +]); +TAU = new Float64Array( [ 1.5, 0.75, 0.0 ] ); +WORK = new Float64Array( 3 ); + +// Apply the orthogonal matrix P^T from the left (no transpose): +info = dormbr( order, 'P', 'left', 'no-transpose', shape[ 0 ], shape[ 1 ], 3, A, 4, TAU, C, strides[ 1 ], WORK, WORK.length ); +console.log( ndarray2array( C, shape, strides, 0, order ) ); +console.log( info ); diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/base.js new file mode 100644 index 000000000000..d0a935317585 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/base.js @@ -0,0 +1,209 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var max = require( '@stdlib/math/base/special/max' ); +var dormlq = require( './dormlq.js' ); +var dormqr = require( './dormqr.js' ); + + +// FUNCTIONS // + +/** +* Tests whether an operation should be applied to the left side. +* +* @private +* @param {string} side - operation side +* @returns {boolean} boolean indicating if an operation should be applied to the left side +*/ +function isLeftSide( side ) { + return side === 'left'; +} + + +// MAIN // + +/** +* Multiply a general matrix by the orthogonal matrix from a bi-diagonal reduction determined by `DGEBRD`. +* +* ## Notes +* +* - `Q` and `P^T` are the orthogonal matrices determined by `DGEBRD` when reducing a real matrix `A` to bi-diagonal form, `A = Q * B * P^T`. +* +* - If VECT = 'Q', `DORMBR` overwrites the general real `M` by `N` matrix `C` with, +* +* - `Q * C` if SIDE = 'left' and TRANS = 'no-transpose', or +* - `Q^T * C` if SIDE = 'left' and TRANS = 'transpose', or +* - `C * Q` if SIDE = 'right' and TRANS = 'no-transpose', or +* - `C * Q^T` if SIDE = 'right' and TRANS = 'transpose'. +* +* - If VECT = 'P', `DORMBR` overwrites the general real `M` by `N` matrix `C` with, +* +* - `P * C` if SIDE = 'left' and TRANS = 'no-transpose', or +* - `P^T * C` if SIDE = 'left' and TRANS = 'transpose', or +* - `C * P` if SIDE = 'right' and TRANS = 'no-transpose', or +* - `C * P^T` if SIDE = 'right' and TRANS = 'transpose'. +* +* - If SIDE = 'left', `LWORK >= max(1,N)`. +* +* - If SIDE = 'right', `LWORK >= max(1,M)`. +* +* - For optimum performance, `LWORK >= N*NB` if SIDE = 'left', and `LWORK >= M*NB` if SIDE = 'right', where `NB` is the optimal blocksize. +* +* - If `LWORK = -1`, then a workspace query is assumed; the routine only calculates the optimal size of the `WORK` array and returns this value as the first entry of the `WORK` array. +* +* @private +* @param {string} vect - specifies whether the matrix `Q` or the matrix `P` is applied +* @param {string} side - specifies the side of multiplication with `C` +* @param {string} trans - `'no-transpose'` for `Q`, `'transpose'` for `Q^T` +* @param {NonNegativeInteger} M - number of rows of `C` +* @param {NonNegativeInteger} N - number of columns of `C` +* @param {NonNegativeInteger} K - number of elementary reflectors +* @param {Float64Array} A - reflector vectors from `DGEBRD` +* @param {integer} strideA1 - stride of the first dimension of A +* @param {integer} strideA2 - stride of the second dimension of A +* @param {NonNegativeInteger} offsetA - starting index for A +* @param {Float64Array} TAU - scalar factors of reflectors +* @param {integer} strideTAU - stride for TAU +* @param {NonNegativeInteger} offsetTAU - starting index for TAU +* @param {Float64Array} C - input/output 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 for `WORK` +* @param {NonNegativeInteger} offsetWORK - starting index for `WORK` +* @param {NonNegativeInteger} LWORK - dimension of the array `WORK` +* @returns {integer} status code (0 if successful) +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1, 0, 0 ] ); +* var TAU = new Float64Array( [ 2 ] ); +* var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); +* var WORK = new Float64Array( 3 ); +* +* var info = dormbr( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); +* // returns 0 +* // C => [ -1, -3, -5, 2, 4, 6 ] +* // WORK => [ 96, 0, 0 ] +*/ +function dormbr( vect, side, trans, M, N, K, A, strideA1, strideA2, offsetA, TAU, strideTAU, offsetTAU, C, strideC1, strideC2, offsetC, WORK, strideWORK, offsetWORK, LWORK ) { + var isTrans; + var applyq; + var isLeft; + var lquery; + var transt; + var lwkopt; + var mi; + var ni; + var i1; + var i2; + var nb; + var nq; + var nw; + + applyq = ( vect === 'Q' ); + isLeft = isLeftSide( side ); + isTrans = ( trans === 'transpose' ); + lquery = ( LWORK === -1 ); + + // NQ is the order of Q or P and NW is the minimum dimension of WORK... + if ( isLeft ) { + nq = M; + nw = max( 1, N ); + } else { + nq = N; + nw = max( 1, M ); + } + + nb = 32; + lwkopt = nw*nb; + WORK[ offsetWORK ] = lwkopt; + + if ( lquery ) { + return 0; + } + + // Quick return: + WORK[ offsetWORK ] = 1; + if ( M === 0 || N === 0 ) { + return 0; + } + + if ( applyq ) { + // Apply Q... + if ( nq >= K ) { + // Q was determined by a call to DGEBRD with NQ >= K + dormqr( side, trans, M, N, K, A, strideA1, strideA2, offsetA, TAU, strideTAU, offsetTAU, C, strideC1, strideC2, offsetC, WORK, strideWORK, offsetWORK, LWORK ); + } else if ( nq > 1 ) { + // Q was determined by a call to DGEBRD with NQ < K + if ( isLeft ) { + mi = M - 1; + ni = N; + i1 = 1; + i2 = 0; + } else { + mi = M; + ni = N - 1; + i1 = 0; + i2 = 1; + } + dormqr( side, trans, mi, ni, nq - 1, A, strideA1, strideA2, offsetA + strideA1, TAU, strideTAU, offsetTAU, C, strideC1, strideC2, offsetC + ( i1 * strideC1 ) + ( i2 * strideC2 ), WORK, strideWORK, offsetWORK, LWORK ); + } + } else { + // Apply P... + if ( isTrans ) { + transt = 'no-transpose'; + } else { + transt = 'transpose'; + } + if ( nq > K ) { + // P was determined by a call to DGEBRD with NQ > K + dormlq( side, transt, M, N, K, A, strideA1, strideA2, offsetA, TAU, strideTAU, offsetTAU, C, strideC1, strideC2, offsetC, WORK, strideWORK, offsetWORK, LWORK ); + } else if ( nq > 1 ) { + // P was determined by a call to DGEBRD with NQ <= K + if ( isLeft ) { + mi = M - 1; + ni = N; + i1 = 1; + i2 = 0; + } else { + mi = M; + ni = N - 1; + i1 = 0; + i2 = 1; + } + dormlq( side, transt, mi, ni, nq - 1, A, strideA1, strideA2, offsetA + strideA2, TAU, strideTAU, offsetTAU, C, strideC1, strideC2, offsetC + ( i1 * strideC1 ) + ( i2 * strideC2 ), WORK, strideWORK, offsetWORK, LWORK ); + } + } + + WORK[ offsetWORK ] = lwkopt; + return 0; +} + + +// EXPORTS // + +module.exports = dormbr; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dlarfb.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dlarfb.js new file mode 100644 index 000000000000..96be470af5ea --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dlarfb.js @@ -0,0 +1,118 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var leftForwardColumns = require( './left_forward_columns.js' ); +var leftBackwardColumns = require( './left_backward_columns.js' ); +var leftForwardRows = require( './left_forward_rows.js' ); +var leftBackwardRows = require( './left_backward_rows.js' ); +var rightForwardColumns = require( './right_forward_columns.js' ); +var rightBackwardColumns = require( './right_backward_columns.js' ); +var rightForwardRows = require( './right_forward_rows.js' ); +var rightBackwardRows = require( './right_backward_rows.js' ); + + +// MAIN // + +/** +* Applies a real block reflector `H` or its transpose `H^T` to a real `M` by `N` matrix `C`, from either the left or the right. +* +* ## Notes +* +* - `V` is a double-precision array with dimension `(LDV,K)` if `storev = 'C'`, `(LDV,M)` if `storev = 'R'` and `side = 'L'`, or `(LDV,N)` if `storev = 'R'` and `side = 'R'`. +* - `T` is a double-precision array with dimension `(LDT,K)`. The triangular `K` by `K` matrix `T` in the representation of the block reflector. +* - `C` is a double-precision array with dimension `(LDC,N)`. On entry, the `M` by `N` matrix `C`. On exit, `C` is overwritten by the desired matrix product. +* - `work` is a double-precision array with dimension `(LDWORK,K)`. +* +* @private +* @param {string} side - specifies whether `H` or `H^T` is applied from the left or right +* @param {string} trans - specifies whether to apply `H` or `H^T` +* @param {string} direct - indicates how `H` is formed from a product of elementary reflectors +* @param {string} storev - indicates how the vectors which define the elementary reflectors are stored +* @param {NonNegativeInteger} M - number of rows of the matrix `C` +* @param {NonNegativeInteger} N - number of columns of the matrix `C` +* @param {NonNegativeInteger} K - order of the matrix `T` +* @param {Float64Array} V - input matrix +* @param {integer} strideV1 - stride of the first dimension of `V` +* @param {integer} strideV2 - stride of the second dimension of `V` +* @param {integer} offsetV - index offset for `V` +* @param {Float64Array} T - input matrix +* @param {integer} strideT1 - stride of the first dimension of `T` +* @param {integer} strideT2 - stride of the second dimension of `T` +* @param {integer} offsetT - index offset for `T` +* @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 {integer} offsetC - index offset for `C` +* @param {Float64Array} work - work array +* @param {integer} strideWork1 - stride of the first dimension of `work` +* @param {integer} strideWork2 - stride of the second dimension of `work` +* @param {integer} offsetWork - index offset for `work` +* @returns {Float64Array} updated matrix `C` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 10.0, 40.0, 70.0, 20.0, 50.0, 80.0, 30.0, 60.0, 90.0 ] ); +* var T = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var C = new Float64Array( [ 11.0, 12.0, 13.0, 21.0, 22.0, 23.0, 31.0, 32.0, 33.0 ] ); +* var work = new Float64Array( 9 ); +* +* dlarfb( 'left', 'transpose', 'forward', 'columns', 3, 3, 3, V, 3, 1, 0, T, 3, 1, 0, C, 3, 1, 0, work, 3, 1, 0 ); +* +* // C => [ -1350.00, -1400.00, -1450.00, -30961.00, -32102.00, -33243.00, -266612.00, -275464.00, -284316.00 ] +*/ +function dlarfb( side, trans, direct, storev, M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork ) { + // Quick return if possible + if ( M <= 0 || N <= 0 ) { + return C; + } + + if ( side === 'left' ) { + if ( storev === 'columns' ) { + if ( direct === 'forward' ) { + return leftForwardColumns( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ); + } + return leftBackwardColumns( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ); + } + if ( direct === 'forward' ) { + return leftForwardRows( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ); + } + return leftBackwardRows( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ); + } + if ( storev === 'columns' ) { + if ( direct === 'forward' ) { + return rightForwardColumns( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ); + } + return rightBackwardColumns( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ); + } + if ( direct === 'forward' ) { + return rightForwardRows( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ); + } + return rightBackwardRows( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ); +} + + +// EXPORTS // + +module.exports = dlarfb; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dlarft.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dlarft.js new file mode 100644 index 000000000000..e6567023f56f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dlarft.js @@ -0,0 +1,571 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var dgemm = require( '@stdlib/blas/base/dgemm' ).ndarray; +var dlacpy = require( '@stdlib/lapack/base/dlacpy' ).ndarray; +var floor = require( '@stdlib/math/base/special/floor' ); +var dtrmm = require( './dtrmm.js' ); + + +// MAIN // + +/** +* Forms the triangular factor T of a real block reflector H of order N, which is defined as a product of K elementary reflectors. +* +* ## Notes +* +* - If `direct` = 'forward', `H = H(1) H(2) . . . H(k)` and `T` is upper triangular. +* - If `direct` = 'backward', `H = H(k) . . . H(2) H(1)` and `T` is lower triangular. +* - If `storev` = 'columns', the vector which defines the elementary reflector `H(i)` is stored in the i-th column of the array `V`, and `H = I - V * T * V**T`. +* - If `storev` = 'rows', the vector which defines the elementary reflector `H(i)` is stored in the i-th row of the array `V`, and `H = I - V**T * T * V`. +* +* ## Method +* +* ### QR Case +* +* - Break \\(V\\) apart into six components +* +* ```tex +* V = \left[ +* \begin{array}{cc} +* V_{1,1} & 0 \\ +* V_{2,1} & V_{2,2} \\ +* V_{3,1} & V_{3,2} +* \end{array} +* \right] +* ``` +* +* where +* +* - \\(V_{1,1} \in \mathbb{R}^{l,l}\\) is unit lower triangular +* - \\(V_{2,1} \in \mathbb{R}^{k-l,l}\\) is rectangular +* - \\(V_{3,1} \in \mathbb{R}^{n-k,l}\\) is rectangular +* - \\(V_{2,2} \in \mathbb{R}^{k-l,k-l}\\) is unit lower triangular +* - \\(V_{3,2} \in \mathbb{R}^{n-k,k-l}\\) is rectangular +* +* - We construct the \\(T\\) matrix +* +* ```tex +* T = \left[ +* \begin{array}{cc} +* T_{1,1} & T_{1,2} \\ +* 0 & T_{2,2} +* \end{array} +* \right] +* ``` +* +* where \\(T\\) is the triangular factor obtained from block reflectors. +* +* - Assume we have already computed \\(T_{1,1}\\) and \\(T_{2,2}\\), and collect the associated reflectors in \\(V_1\\) and \\(V_2\\) +* +* ```tex +* \begin{aligned} +* T_{1,1} &\in \mathbb{R}^{l,l} && \text{upper triangular} \\ +* T_{2,2} &\in \mathbb{R}^{k-l,k-l} && \text{upper triangular} \\ +* T_{1,2} &\in \mathbb{R}^{l,k-l} && \text{rectangular} +* \end{aligned} +* ``` +* +* with \\(l = \lfloor k/2 \rfloor\\). +* +* - Consider the product +* +* ```tex +* \begin{aligned} +* (I - V_1 T_{1,1} V_1^T)(I - V_2 T_{2,2} V_2^T) +* = I - V_1 T_{1,1} V_1^T - V_2 T_{2,2} V_2^T + V_1 T_{1,1} V_1^T V_2 T_{2,2} V_2^T +* \end{aligned} +* ``` +* +* - Define +* +* ```tex +* T_{1,2} = -T_{1,1} V_1^T V_2 T_{2,2} +* ``` +* +* - Define the matrix \\(V\\) as +* +* ```tex +* V = \left[ +* \begin{array}{cc} +* V_1 & V_2 +* \end{array} +* \right] +* ``` +* +* so the product is equivalent to \\(I - V T V^T\\). +* +* This means we can compute \\(T_{1,1}\\) and \\(T_{2,2}\\) recursively, then use this information to compute \\(T_{1,2}\\). +* +* ### LQ Case +* +* - Break \\(V\\) apart into six components +* +* ```tex +* V = \left[ +* \begin{array}{ccc} +* V_{1,1} & V_{1,2} & V_{1,3} \\ +* 0 & V_{2,2} & V_{2,3} +* \end{array} +* \right] +* ``` +* +* where +* +* - \\(V_{1,1} \in \mathbb{R}^{l,l}\\) is unit upper triangular +* - \\(V_{1,2} \in \mathbb{R}^{l,k-l}\\) is rectangular +* - \\(V_{1,3} \in \mathbb{R}^{l,n-k}\\) is rectangular +* - \\(V_{2,2} \in \mathbb{R}^{k-l,k-l}\\) is unit upper triangular +* - \\(V_{2,3} \in \mathbb{R}^{k-l,n-k}\\) is rectangular +* +* with \\(l = \lfloor k/2 \rfloor\\). +* +* - We construct the \\(T\\) matrix +* +* ```tex +* T = \left[ +* \begin{array}{cc} +* T_{1,1} & T_{1,2} \\ +* 0 & T_{2,2} +* \end{array} +* \right] +* ``` +* +* where \\(T\\) is the triangular factor obtained from block reflectors. +* +* - Assume we have already computed \\(T_{1,1}\\) and \\(T_{2,2}\\), and collect the associated reflectors in \\(V_1\\) and \\(V_2\\) +* +* ```tex +* \begin{aligned} +* T_{1,1} &\in \mathbb{R}^{l,l} && \text{upper triangular} \\ +* T_{2,2} &\in \mathbb{R}^{k-l,k-l} && \text{upper triangular} \\ +* T_{1,2} &\in \mathbb{R}^{l,k-l} && \text{rectangular} +* \end{aligned} +* ``` +* +* - Consider the product +* +* ```tex +* \begin{aligned} +* (I - V_1^T T_{1,1} V_1)(I - V_2^T T_{2,2} V_2) +* = I - V_1^T T_{1,1} V_1 - V_2^T T_{2,2} V_2 + V_1^T T_{1,1} V_1 V_2^T T_{2,2} V_2 +* \end{aligned} +* ``` +* +* - Define +* +* ```tex +* T_{1,2} = -T_{1,1} V_1 V_2^T T_{2,2} +* ``` +* +* - Define the matrix \\(V\\) as +* +* ```tex +* V = \left[ +* \begin{array}{c} +* V_1 \\ +* V_2 +* \end{array} +* \right] +* ``` +* +* so the product is equivalent to \\(I - V^T T V\\). +* +* This means we can compute \\(T_{1,1}\\) and \\(T_{2,2}\\) recursively, then use this information to compute \\(T_{1,2}\\). +* +* ### QL Case +* +* - Break \\(V\\) apart into six components +* +* ```tex +* V = \left[ +* \begin{array}{cc} +* V_{1,1} & V_{1,2} \\ +* V_{2,1} & V_{2,2} \\ +* 0 & V_{3,2} +* \end{array} +* \right] +* ``` +* +* where +* +* - \\(V_{1,1} \in \mathbb{R}^{n-k,k-l}\\) is rectangular +* - \\(V_{2,1} \in \mathbb{R}^{k-l,k-l}\\) is unit upper triangular +* - \\(V_{1,2} \in \mathbb{R}^{n-k,l}\\) is rectangular +* - \\(V_{2,2} \in \mathbb{R}^{k-l,l}\\) is rectangular +* - \\(V_{3,2} \in \mathbb{R}^{l,l}\\) is unit upper triangular +* +* - We construct the \\(T\\) matrix +* +* ```tex +* T = \left[ +* \begin{array}{cc} +* T_{1,1} & 0 \\ +* T_{2,1} & T_{2,2} +* \end{array} +* \right] +* ``` +* +* where \\(T\\) is the triangular factor obtained from block reflectors. +* +* - Assume we have already computed \\(T_{1,1}\\) and \\(T_{2,2}\\), and collect the associated reflectors in \\(V_1\\) and \\(V_2\\) +* +* ```tex +* \begin{aligned} +* T_{1,1} &\in \mathbb{R}^{k-l,k-l} && \text{non-unit lower triangular} \\ +* T_{2,2} &\in \mathbb{R}^{l,l} && \text{non-unit lower triangular} \\ +* T_{2,1} &\in \mathbb{R}^{l,k-l} && \text{rectangular} +* \end{aligned} +* ``` +* +* with \\(l = \lfloor k/2 \rfloor\\). +* +* - Consider the product +* +* ```tex +* \begin{aligned} +* (I - V_2 T_{2,2} V_2^T)(I - V_1 T_{1,1} V_1^T) +* = I - V_2 T_{2,2} V_2^T - V_1 T_{1,1} V_1^T + V_2 T_{2,2} V_2^T V_1 T_{1,1} V_1^T +* \end{aligned} +* ``` +* +* - Define +* +* ```tex +* T_{2,1} = -T_{2,2} V_2^T V_1 T_{1,1} +* ``` +* +* - Define the matrix \\(V\\) as +* +* ```tex +* V = \left[ +* \begin{array}{cc} +* V_1 & V_2 +* \end{array} +* \right] +* ``` +* +* so the product is equivalent to \\(I - V T V^T\\). +* +* This means we can compute \\(T_{1,1}\\) and \\(T_{2,2}\\) recursively, then use this information to compute \\(T_{2,1}\\). +* +* ### RQ Case +* +* - Break \\(V\\) apart into six components +* +* ```tex +* V = \left[ +* \begin{array}{ccc} +* V_{1,1} & V_{1,2} & 0 \\ +* V_{2,1} & V_{2,2} & V_{2,3} +* \end{array} +* \right] +* ``` +* +* where +* +* - \\(V_{1,1} \in \mathbb{R}^{k-l,n-k}\\) is rectangular +* - \\(V_{1,2} \in \mathbb{R}^{k-l,k-l}\\) is unit lower triangular +* - \\(V_{2,1} \in \mathbb{R}^{l,n-k}\\) is rectangular +* - \\(V_{2,2} \in \mathbb{R}^{l,k-l}\\) is rectangular +* - \\(V_{2,3} \in \mathbb{R}^{l,l}\\) is unit lower triangular +* +* - We construct the \\(T\\) matrix +* +* ```tex +* T = \left[ +* \begin{array}{cc} +* T_{1,1} & 0 \\ +* T_{2,1} & T_{2,2} +* \end{array} +* \right] +* ``` +* +* where \\(T\\) is the triangular factor obtained from block reflectors. +* +* - Assume we have already computed \\(T_{1,1}\\) and \\(T_{2,2}\\), and collect the associated reflectors in \\(V_1\\) and \\(V_2\\) +* +* ```tex +* \begin{aligned} +* T_{1,1} &\in \mathbb{R}^{k-l,k-l} && \text{non-unit lower triangular} \\ +* T_{2,2} &\in \mathbb{R}^{l,l} && \text{non-unit lower triangular} \\ +* T_{2,1} &\in \mathbb{R}^{l,k-l} && \text{rectangular} +* \end{aligned} +* ``` +* +* with \\(l = \lfloor k/2 \rfloor\\). +* +* - Consider the product +* +* ```tex +* \begin{aligned} +* (I - V_2^T T_{2,2} V_2)(I - V_1^T T_{1,1} V_1) +* = I - V_2^T T_{2,2} V_2 - V_1^T T_{1,1} V_1 + V_2^T T_{2,2} V_2 V_1^T T_{1,1} V_1 +* \end{aligned} +* ``` +* +* - Define +* +* ```tex +* T_{2,1} = -T_{2,2} V_2 V_1^T T_{1,1} +* ``` +* +* - Define the matrix \\(V\\) as +* +* ```tex +* V = \left[ +* \begin{array}{c} +* V_1 \\ +* V_2 +* \end{array} +* \right] +* ``` +* +* so the product is equivalent to \\(I - V^T T V\\). +* +* This means we can compute \\(T_{1,1}\\) and \\(T_{2,2}\\) recursively, then use this information to compute \\(T_{2,1}\\). +* +* @private +* @param {string} direct - specifies the order in which the elementary reflectors are multiplied to form the block reflector `H` +* @param {string} storev - specifies how the vectors which define the elementary reflectors are stored +* @param {NonNegativeInteger} N - order of the block reflector `H` +* @param {NonNegativeInteger} K - order of the triangular factor `T` (the number of elementary reflectors) +* @param {Float64Array} V - matrix of reflector vectors +* @param {integer} strideV1 - stride of first dimension of `V` +* @param {integer} strideV2 - stride of second dimension of `V` +* @param {NonNegativeInteger} offsetV - starting index for `V` +* @param {Float64Array} TAU - array of scalar factors of the elementary reflector `H(i)` +* @param {integer} strideTAU - stride length for `TAU` +* @param {NonNegativeInteger} offsetTAU - starting index for `TAU` +* @param {Float64Array} T - output triangular matrix +* @param {integer} strideT1 - stride of first dimension of `T` +* @param {integer} strideT2 - stride of second dimension of `T` +* @param {NonNegativeInteger} offsetT - starting index for `T` +* @returns {Float64Array} `T` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 1.0, 0.2, 0.3, -0.4, 0.5, 0.0, 1.0, -0.6, 0.7, -0.8, 0.0, 0.0, 1.0, 0.9, 1.1 ] ); +* var TAU = new Float64Array( [ 1.2, 0.7, 1.5 ] ); +* var T = new Float64Array( 9 ); +* +* dlarft( 'forward', 'rows', 5, 3, V, 5, 1, 0, TAU, 1, 0, T, 3, 1, 0 ); +* // T => [ ~1.2, ~0.5544, ~-0.17514, 0.0, 0.7, 0.8925, 0.0, 0.0, 1.5 ] +*/ +function dlarft( direct, storev, N, K, V, strideV1, strideV2, offsetV, TAU, strideTAU, offsetTAU, T, strideT1, strideT2, offsetT ) { + var colv; + var dirf; + var i0; + var i1; + var i2; + var i3; + var lq; + var ql; + var qr; + var i; + var j; + var l; + + if ( N === 0 || K === 0 ) { + return T; + } + + if ( N === 1 || K === 1 ) { + T[ offsetT ] = TAU[ offsetTAU ]; + return T; + } + + l = floor( K / 2 ); + + if ( direct === 'forward' ) { + dirf = true; + } + else { + dirf = false; + } + + if ( storev === 'columns' ) { + colv = true; + } + else { + colv = false; + } + + // QR happens when we have forward direction in column storage + qr = dirf & colv; + + // LQ happens when we have forward direction in row storage + lq = dirf & ( !colv ); + + // QL happens when we have backward direction in column storage + ql = ( !dirf ) & colv; + + // The last case is RQ. Due to how we structured this, if the above 3 are false, then RQ must be true, so we never store this RQ happens when we have backward direction in row storage `RQ = ( !dirf ) & ( !colv )` + if ( qr ) { + // Compute T_{1,1} recursively + dlarft( direct, storev, N, l, V, strideV1, strideV2, offsetV, TAU, strideTAU, offsetTAU, T, strideT1, strideT2, offsetT ); + + // Compute T_{2,2} recursively + dlarft( direct, storev, N - l, K - l, V, strideV1, strideV2, offsetV + ( ( strideV1 + strideV2 ) * l ), TAU, strideTAU, offsetTAU + ( strideTAU * l ), T, strideT1, strideT2, offsetT + ( ( strideT1 + strideT2 ) * l ) ); + + // Compute T_{1,2} = V_{2,1} + i0 = offsetT + ( strideT2 * l ); + i1 = offsetV + ( strideV1 * l ); + for ( j = 0; j < l; j++ ) { + i2 = i0; + i3 = i1; + for ( i = 0; i < K - l; i++ ) { + T[ i2 ] = V[ i3 ]; + i2 += strideT2; + i3 += strideV1; + } + i0 += strideT1; + i1 += strideV2; + } + + // T_{1,2} = T_{1,2}*V_{2,2} + dtrmm( 'right', 'lower', 'no-transpose', 'unit', l, K - l, 1, V, strideV1, strideV2, offsetV + ( ( strideV1 + strideV2 ) * l ), T, strideT1, strideT2, offsetT + ( strideT2 * l ) ); + + // T_{1,2} = V_{3,1}'*V_{3,2} + T_{1,2} + + // Note: We assume K <= N, and GEMM will do nothing if N=K + dgemm( 'transpose', 'no-transpose', l, K - l, N - K, 1, V, strideV1, strideV2, offsetV + ( strideV1 * K ), V, strideV1, strideV2, offsetV + ( strideV1 * K ) + ( strideV2 * l ), 1, T, strideT1, strideT2, offsetT + ( strideT2 * l ) ); + + /* + At this point, we have that T_{1,2} = V_1'*V_2 + All that is left is to pre and post multiply by -T_{1,1} and T_{2,2} respectively. + + T_{1,2} = -T_{1,1}*T_{1,2} + */ + dtrmm( 'left', 'upper', 'no-transpose', 'non-unit', l, K - l, -1, T, strideT1, strideT2, offsetT, T, strideT1, strideT2, offsetT + ( strideT2 * l ) ); + + // T_{1,2} = T_{1,2}*T_{2,2} + dtrmm( 'right', 'upper', 'no-transpose', 'non-unit', l, K - l, 1, T, strideT1, strideT2, offsetT + ( ( strideT1 + strideT2 ) * l ), T, strideT1, strideT2, offsetT + ( strideT2 * l ) ); + } else if ( lq ) { + // Compute T_{1,1} recursively + dlarft( direct, storev, N, l, V, strideV1, strideV2, offsetV, TAU, strideTAU, offsetTAU, T, strideT1, strideT2, offsetT ); + + // Compute T_{2,2} recursively + dlarft( direct, storev, N - l, K - l, V, strideV1, strideV2, offsetV + ( ( strideV1 + strideV2 ) * l ), TAU, strideTAU, offsetTAU + ( strideTAU * l ), T, strideT1, strideT2, offsetT + ( ( strideT1 + strideT2 ) * l ) ); + + // Compute T_{1,2} = V_{1,2} + dlacpy( 'all', l, K - l, V, strideV1, strideV2, offsetV + ( strideV2 * l ), T, strideT1, strideT2, offsetT + ( strideT2 * l ) ); + + // T_{1,2} = T_{1,2}*V_{2,2} + dtrmm( 'right', 'upper', 'transpose', 'unit', l, K - l, 1, V, strideV1, strideV2, offsetV + ( ( strideV1 + strideV2 ) * l ), T, strideT1, strideT2, offsetT + ( strideT2 * l ) ); + + // T_{1,2} = V_{1,3}*V_{2,3}' + T_{1,2} + + // Note: We assume K <= N, and GEMM will do nothing if N=K + dgemm( 'no-transpose', 'transpose', l, K - l, N - K, 1, V, strideV1, strideV2, offsetV + ( strideV2 * K ), V, strideV1, strideV2, offsetV + ( strideV1 * l ) + ( strideV2 * K ), 1, T, strideT1, strideT2, offsetT + ( strideT2 * l ) ); + + /* + At this point, we have that T_{1,2} = V_1*V_2' + All that is left is to pre and post multiply by -T_{1,1} and T_{2,2} respectively. + + T_{1,2} = -T_{1,1}*T_{1,2} + */ + dtrmm( 'left', 'upper', 'no-transpose', 'non-unit', l, K - l, -1, T, strideT1, strideT2, offsetT, T, strideT1, strideT2, offsetT + ( strideT2 * l ) ); + + // T_{1,2} = T_{1,2}*T_{2,2} + dtrmm( 'right', 'upper', 'no-transpose', 'non-unit', l, K - l, 1, T, strideT1, strideT2, offsetT + ( ( strideT1 + strideT2 ) * l ), T, strideT1, strideT2, offsetT + ( strideT2 * l ) ); + } else if ( ql ) { + // Compute T_{1,1} recursively + dlarft( direct, storev, N - l, K - l, V, strideV1, strideV2, offsetV, TAU, strideTAU, offsetTAU, T, strideT1, strideT2, offsetT ); + + // Compute T_{2,2} recursively + dlarft( direct, storev, N - l, K - l, V, strideV1, strideV2, offsetV + ( ( strideV1 + strideV2 ) * l ), TAU, strideTAU, offsetTAU + ( strideTAU * l ), T, strideT1, strideT2, offsetT + ( ( strideT1 + strideT2 ) * l ) ); + + // Compute T_{2,1} = V_{2,2} + i0 = offsetT + ( strideT1 * ( K - l ) ); + i1 = offsetV + ( strideV1 * ( N - K ) ) + ( strideV2 * ( K - l ) ); + for ( j = 0; j < K - l; j++ ) { + i2 = i0; + i3 = i1; + for ( i = 0; i < l; i++ ) { + T[ i2 ] = V[ i3 ]; + i2 += strideT1; + i3 += strideV2; + } + i0 += strideT2; + i1 += strideV1; + } + + // T_{2,1} = T_{2,1}*V_{2,1} + dtrmm( 'right', 'upper', 'no-transpose', 'unit', l, K - l, 1, V, strideV1, strideV2, offsetV + ( strideV1 * ( N - K ) ), T, strideT1, strideT2, offsetT + ( strideT1 * ( K - l ) ) ); + + // T_{2,1} = V_{2,2}'*V_{2,1} + T_{2,1} + + // Note: We assume K <= N, and GEMM will do nothing if N=K + dgemm( 'transpose', 'no-transpose', l, K - l, N - K, 1, V, strideV1, strideV2, offsetV + ( strideV2 * ( K - l ) ), V, strideV1, strideV2, offsetV, 1, T, strideT1, strideT2, offsetT + ( strideT1 * ( K - l ) ) ); + + /* + At this point, we have that T_{2,1} = V_2'*V_1 + All that is left is to pre and post multiply by -T_{2,2} and T_{1,1} respectively. + + T_{2,1} = -T_{2,2}*T_{2,1} + */ + dtrmm( 'left', 'lower', 'no-transpose', 'non-unit', l, K - l, -1, T, strideT1, strideT2, offsetT + ( ( strideT1 + strideT2 ) * ( K - l ) ), T, strideT1, strideT2, offsetT + ( strideT1 * ( K - l ) ) ); + + // T_{2,1} = T_{2,1}*T_{1,1} + dtrmm( 'right', 'lower', 'no-transpose', 'non-unit', l, K - l, 1, T, strideT1, strideT2, offsetT, T, strideT1, strideT2, offsetT + ( strideT1 * ( K - l ) ) ); + } else { + // Else means RQ case + + // Compute T_{1,1} recursively + dlarft( direct, storev, N - l, K - l, V, strideV1, strideV2, offsetV, TAU, strideTAU, offsetTAU, T, strideT1, strideT2, offsetT ); + + // Compute T_{2,2} recursively + dlarft( direct, storev, N, l, V, strideV1, strideV2, offsetV + ( strideV1 * ( K - l ) ), TAU, strideTAU, offsetTAU + ( strideTAU * ( K - l ) ), T, strideT1, strideT2, offsetT + ( ( strideT1 + strideT2 ) * ( K - l ) ) ); + + // Compute T_{2,1} = V_{2,2} + dlacpy( 'all', l, K - l, V, strideV1, strideV2, offsetV + ( strideV1 * ( K - l ) ) + ( strideV2 * ( N - K ) ), T, strideT1, strideT2, offsetT + ( strideT1 * ( K - l ) ) ); + + // T_{2,1} = T_{2,1}*V_{1,2} + dtrmm( 'right', 'lower', 'transpose', 'unit', l, K - l, 1, V, strideV1, strideV2, offsetV + ( strideV2 * ( N - K ) ), T, strideT1, strideT2, offsetT + ( strideT1 * ( K - l ) ) ); + + // T_{2,1} = V_{2,1}*V_{1,1}' + T_{2,1} + + // Note: We assume K <= N, and GEMM will do nothing if N=K + dgemm('no-transpose', 'transpose', l, K - l, N - K, 1, V, strideV1, strideV2, offsetV + ( strideV1 * ( K - l ) ), V, strideV1, strideV2, offsetV, 1, T, strideT1, strideT2, offsetT + ( strideT1 * ( K - l ) ) ); + + /* + At this point, we have that T_{2,1} = V_2*V_1' + All that is left is to pre and post multiply by -T_{2,2} and T_{1,1} respectively. + + T_{2,1} = -T_{2,2}*T_{2,1} + */ + dtrmm( 'left', 'lower', 'no-transpose', 'non-unit', l, K - l, -1, T, strideT1, strideT2, offsetT + ( ( strideT1 + strideT2 ) * ( K - l ) ), T, strideT1, strideT2, offsetT + ( strideT1 * ( K - l ) ) ); + + // T_{2,1} = T_{2,1}*T_{1,1} + dtrmm( 'right', 'lower', 'no-transpose', 'non-unit', l, K - l, 1, T, strideT1, strideT2, offsetT, T, strideT1, strideT2, offsetT + ( strideT1 * ( K - l ) ) ); + } + return T; +} + + +// EXPORTS // + +module.exports = dlarft; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dorm2r.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dorm2r.js new file mode 100644 index 000000000000..d32784c25365 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dorm2r.js @@ -0,0 +1,147 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dlarf1f = require( '@stdlib/lapack/base/dlarf1f' ).ndarray; + + +// MAIN // + +/** +* Multiplies a matrix `C` by an orthogonal matrix `Q` from a QR factorization. +* +* ## Notes +* +* `dorm2r` overwrites the general real M by N matrix C with +* +* - `Q * C` if side = 'left' and trans = 'no-transpose' +* - `Q^T * C` if side = 'left' and trans = 'transpose' +* - `C * Q` if side = 'right' and trans = 'no-transpose' +* - `C * Q^T` if side = 'right' and trans = 'transpose' +* +* where Q is a real orthogonal matrix defined as the product of K elementary reflectors `Q = H(1) H(2) ... H(K)` as returned by `dgeqrf`. Q is of order M if side = 'left' and of order N if side = 'right'. +* +* @private +* @param {string} side - specifies the side of multiplication with `C` +* @param {string} trans - specifies the operation to be performed +* @param {NonNegativeInteger} M - number of rows in matrix `C` +* @param {NonNegativeInteger} N - number of columns in matrix `C` +* @param {NonNegativeInteger} K - number of elementary reflectors whose product defines the matrix `Q` +* @param {Float64Array} A - input matrix containing the elementary reflectors +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} tau - array containing the scalar factors of the elementary reflectors +* @param {integer} strideTau - stride length for `tau` +* @param {NonNegativeInteger} offsetTau - starting index for `tau` +* @param {Float64Array} C - input/output matrix to be multiplied +* @param {integer} strideC1 - stride length for the first dimension of `C` +* @param {integer} strideC2 - stride length for the second dimension of `C` +* @param {NonNegativeInteger} offsetC - starting index for `C` +* @param {Float64Array} work - workspace array for intermediate calculations +* @param {integer} strideWork - stride length for `work` +* @param {NonNegativeInteger} offsetWork - starting index for `work` +* @returns {Float64Array} the modified matrix `C` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 4.0, 0.0, 3.0, 5.0, 6.0 ] ); +* var tau = new Float64Array( [ 7.0, 8.0, 9.0 ] ); +* var C = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +* var work = new Float64Array( 3 ); +* +* dorm2r( 'left', 'no-transpose', 3, 3, 3, A, 3, 1, 0, tau, 1, 0, C, 3, 1, 0, work, 1, 0 ); +* // C => [ -261638.0, -298618.0, -335598.0, -521066.0, -594715.0, -668364.0, -773933.0, -883324.0, -992715.0 ] +*/ +function dorm2r( side, trans, M, N, K, A, strideA1, strideA2, offsetA, tau, strideTau, offsetTau, C, strideC1, strideC2, offsetC, work, strideWork, offsetWork ) { // eslint-disable-line max-params, max-len + var aOffset; + var cOffset; + var tauVal; + var notran; + var passC1; + var passC2; + var passA; + var left; + var i1; + var i2; + var i3; + var mi; + var ni; + var ic; + var jc; + var i; + + // Quick return if possible + if ( M === 0 || N === 0 || K === 0 ) { + return C; + } + + left = ( side === 'left' ); + notran = ( trans === 'no-transpose' ); + + // Determine loop indices based on side and trans + if ( ( left && !notran ) || ( !left && notran ) ) { + i1 = 1; + i2 = K; + i3 = 1; + } else { + i1 = K; + i2 = 1; + i3 = -1; + } + + // Initialize dimensions + if ( left ) { + ni = N; + jc = 1; + } else { + mi = M; + ic = 1; + } + + for ( i = i1; ( i3 > 0 ) ? ( i <= i2 ) : ( i >= i2 ); i += i3 ) { // loop going from 1..K or K..1 + if ( left ) { + mi = M - i + 1; + ic = i; + } else { + ni = N - i + 1; + jc = i; + } + + tauVal = tau[ offsetTau + ( ( i - 1 ) * strideTau ) ]; + aOffset = offsetA + ( ( i - 1 ) * strideA1 ) + ( ( i - 1 ) * strideA2 ); + + passA = strideA1; + passC1 = strideC1; + passC2 = strideC2; + cOffset = offsetC + ( (ic-1) * strideC1 ) + ( (jc-1) * strideC2 ); + + dlarf1f( side, mi, ni, A, passA, aOffset, tauVal, C, passC1, passC2, cOffset, work, strideWork, offsetWork ); // eslint-disable-line max-len + } + + return C; +} + + +// EXPORTS // + +module.exports = dorm2r; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dormbr.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dormbr.js new file mode 100644 index 000000000000..b4a21f929d48 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dormbr.js @@ -0,0 +1,188 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var format = require( '@stdlib/string/format' ); +var isOperationSide = require( '@stdlib/blas/base/assert/is-operation-side' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var isMatrixTranspose = require( '@stdlib/blas/base/assert/is-transpose-operation' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var min = require( '@stdlib/math/base/special/min' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Multiplies a general matrix by the orthogonal matrix from a bi-diagonal reduction determined by `DGEBRD`. +* +* ## Notes +* +* - `Q` and `P^T` are the orthogonal matrices determined by `DGEBRD` when reducing a real matrix `A` to bi-diagonal form, `A = Q * B * P^T`. +* +* - If VECT = 'Q', `DORMBR` overwrites the general real `M` by `N` matrix `C` with, +* +* - `Q * C` if SIDE = 'left' and TRANS = 'no-transpose', or +* - `Q^T * C` if SIDE = 'left' and TRANS = 'transpose', or +* - `C * Q` if SIDE = 'right' and TRANS = 'no-transpose', or +* - `C * Q^T` if SIDE = 'right' and TRANS = 'transpose'. +* +* - If VECT = 'P', `DORMBR` overwrites the general real `M` by `N` matrix `C` with, +* +* - `P * C` if SIDE = 'left' and TRANS = 'no-transpose', or +* - `P^T * C` if SIDE = 'left' and TRANS = 'transpose', or +* - `C * P` if SIDE = 'right' and TRANS = 'no-transpose', or +* - `C * P^T` if SIDE = 'right' and TRANS = 'transpose'. +* +* - If SIDE = 'left', `LWORK >= max(1,N)`. +* +* - If SIDE = 'right', `LWORK >= max(1,M)`. +* +* - For optimum performance, `LWORK >= N*NB` if SIDE = 'left', and `LWORK >= M*NB` if SIDE = 'right', where `NB` is the optimal blocksize. +* +* - If `LWORK = -1`, then a workspace query is assumed; the routine only calculates the optimal size of the `WORK` array and returns this value as the first entry of the `WORK` array. +* +* @param {string} order - storage layout +* @param {string} vect - specifies whether the matrix `Q` or the matrix `P` is applied +* @param {string} side - specifies the side of multiplication with `C` +* @param {string} trans - `'no-transpose'` for `Q` or `P`, `'transpose'` for `Q^T` or `P^T` +* @param {NonNegativeInteger} M - number of rows of `C` +* @param {NonNegativeInteger} N - number of columns of `C` +* @param {NonNegativeInteger} K - number of elementary reflectors +* @param {Float64Array} A - reflector vectors from `DGEBRD` +* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float64Array} TAU - scalar factors of reflectors +* @param {Float64Array} C - input/output matrix +* @param {integer} LDC - stride of the first dimension of `C` (a.k.a., leading dimension of the matrix `C`) +* @param {Float64Array} WORK - workspace array +* @param {NonNegativeInteger} LWORK - dimension of the array `WORK` +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must be either `'Q'` or `'P'` +* @throws {TypeError} third argument must be a valid operation side +* @throws {TypeError} fourth argument must be a valid transpose operation +* @throws {RangeError} fifth argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be a nonnegative integer +* @throws {RangeError} seventh argument must be a nonnegative integer +* @throws {RangeError} ninth argument must be a valid `LDA` value +* @throws {RangeError} twelfth argument must be a valid `LDC` value +* @throws {RangeError} fourteenth argument must be a valid `LWORK` value +* @returns {integer} status code (0 if successful) +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1, 0, 0 ] ); +* var TAU = new Float64Array( [ 2 ] ); +* var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); +* var WORK = new Float64Array( 3 ); +* +* var info = dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); +* // returns 0 +* // C => [ -1, -3, -5, 2, 4, 6 ] +* // WORK[ 0 ] => 96 +*/ +function dormbr( order, vect, side, trans, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK ) { + var applyq; + var sa1; + var sa2; + var sc1; + var sc2; + var nq; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( vect !== 'Q' && vect !== 'P' ) { + throw new TypeError( format( 'invalid argument. Second argument must be either `\'Q\'` or `\'P\'`. Value: `%s`.', vect ) ); + } + if ( !isOperationSide( side ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be a valid operation side. Value: `%s`.', side ) ); + } + if ( !isMatrixTranspose( trans ) ) { + throw new TypeError( format( 'invalid argument. Fourth argument must be a valid transpose operation. Value: `%s`.', trans ) ); + } + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( K < 0 ) { + throw new RangeError( format( 'invalid argument. Seventh argument must be a nonnegative integer. Value: `%d`.', K ) ); + } + applyq = ( vect === 'Q' ); + if ( side === 'left' ) { + nq = M; + if ( ( !isRowMajor( order ) ) && LDA < max( 1, ( ( applyq ) ? nq : min( nq, K ) ) ) ) { + if ( applyq ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to `max(1,NQ)`. Value: `%d`.', LDA ) ); + } + throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to `max(1,min(NQ,K))`. Value: `%d`.', LDA ) ); + } + if ( isRowMajor( order ) && LDA < max( 1, K ) ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to `max(1,K)`. Value: `%d`.', LDA ) ); + } + if ( LWORK < max( 1, N ) && LWORK !== -1 ) { + throw new RangeError( format( 'invalid argument. Fourteenth argument must be greater than or equal to `max(1, N)` when `SIDE = \'left\'`. Value: `%d`.', LWORK ) ); + } + } else { + nq = N; + if ( ( !isRowMajor( order ) ) && LDA < max( 1, ( ( applyq ) ? nq : min( nq, K ) ) ) ) { + if ( applyq ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to `max(1,NQ)`. Value: `%d`.', LDA ) ); + } + throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to `max(1,min(NQ,K))`. Value: `%d`.', LDA ) ); + } + if ( isRowMajor( order ) && LDA < max( 1, K ) ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to `max(1,K)`. Value: `%d`.', LDA ) ); + } + if ( LWORK < max( 1, M ) && LWORK !== -1 ) { + throw new RangeError( format( 'invalid argument. Fourteenth argument must be greater than or equal to `max(1, M)` when `SIDE = \'right\'`. Value: `%d`.', LWORK ) ); + } + } + if ( isRowMajor( order ) ) { + if ( LDC < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Twelfth argument must be greater than or equal to `max(1,N)`. Value: `%d`.', LDC ) ); + } + } else if ( LDC < max( 1, M ) ) { + throw new RangeError( format( 'invalid argument. Twelfth argument must be greater than or equal to `max(1,M)`. Value: `%d`.', LDC ) ); + } + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + sc1 = 1; + sc2 = LDC; + } else { + sa1 = LDA; + sa2 = 1; + sc1 = LDC; + sc2 = 1; + } + return base( vect, side, trans, M, N, K, A, sa1, sa2, 0, TAU, 1, 0, C, sc1, sc2, 0, WORK, 1, 0, LWORK ); +} + + +// EXPORTS // + +module.exports = dormbr; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dorml2.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dorml2.js new file mode 100644 index 000000000000..c75c49430105 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dorml2.js @@ -0,0 +1,172 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var dlarf1f = require( '@stdlib/lapack/base/dlarf1f' ).ndarray; + + +// FUNCTIONS // + +/** +* Tests whether an operation should be applied to the left side. +* +* @private +* @param {string} side - operation side +* @returns {boolean} boolean indicating if an operation should be applied to the left side +*/ +function isLeftSide( side ) { + return side === 'left'; +} + + +// MAIN // + +/** +* Multiply a general matrix by the orthogonal matrix from a LQ factorization determined by `DGELQF`. +* +* ## Notes +* +* - `Q` is a real orthogonal matrix defined as the product of k elementary reflectors, Q = H(k) . . . H(2) H(1) as returned by `DGELQF`. +* +* - `Q` is of order `M` if SIDE = 'left' and of order `N` if SIDE = 'R'. +* +* - `DORML2` overwrites the general real `M` by `N` matrix `C` with, +* +* - `Q * C` if SIDE = 'left' and TRANS = 'no-transpose', or +* - `Q^T* C` if SIDE = 'left' and TRANS = 'transpose', or +* - `C * Q` if SIDE = 'right' and TRANS = 'no-transpose', or +* - `C * Q**T` if SIDE = 'right' and TRANS = 'transpose'. +* +* @private +* @param {string} side - specifies the side of multiplication with `C` +* @param {string} trans - `'no-transpose'` for `Q`, `'transpose'` for `Q^T` +* @param {NonNegativeInteger} M - number of rows of `C` +* @param {NonNegativeInteger} N - number of columns of `C` +* @param {NonNegativeInteger} K - number of elementary reflectors +* @param {Float64Array} A - reflector vectors from `DGELQ2` +* @param {integer} strideA1 - stride of the first dimension of A +* @param {integer} strideA2 - stride of the second dimension of A +* @param {NonNegativeInteger} offsetA - starting index for A +* @param {Float64Array} TAU - scalar factors of reflectors +* @param {integer} strideTAU - stride for TAU +* @param {NonNegativeInteger} offsetTAU - starting index for TAU +* @param {Float64Array} C - input/output 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 for `WORK` +* @param {NonNegativeInteger} offsetWORK - starting index for `WORK` +* @returns {integer} status code (0 if successful) +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1, 0 ] ); +* var TAU = new Float64Array( [ 2 ] ); +* var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); +* var WORK = new Float64Array( 3 ); +* +* var info = dorml2( 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0 ); +* // returns 0 +* // C => [ -1, -3, -5, 2, 4, 6 ] +* // WORK => [ 1, 3, 5 ] +*/ +function dorml2( side, trans, M, N, K, A, strideA1, strideA2, offsetA, TAU, strideTAU, offsetTAU, C, strideC1, strideC2, offsetC, WORK, strideWORK, offsetWORK ) { + var isTrans; + var isLeft; + var idx0; + var idx1; + var idx2; + var mi; + var ni; + var ic; + var jc; + var i1; + var i2; + var i3; + var i; + + isLeft = isLeftSide( side ); + isTrans = ( trans === 'transpose' ); + + // Quick return if possible + if ( M === 0 || N === 0 || K === 0 ) { + return 0; + } + + if ( ( isLeft && !isTrans ) || ( !isLeft && isTrans ) ) { + i1 = 0; + i2 = K - 1; + i3 = 1; + } else { + i1 = K - 1; + i2 = 0; + i3 = -1; + } + + if ( isLeft ) { + ni = N; + jc = 0; + + idx0 = offsetA + ( i1*strideA1 ) + ( i1*strideA2 ); + idx1 = offsetTAU + ( i1*strideTAU ); + idx2 = offsetC + ( i1*strideC1 ) + ( jc*strideC2 ); + for ( i = i1; ( i3 > 0 ) ? ( i <= i2 ) : ( i >= i2 ); i += i3 ) { + // Apply H(i) to C(i:M-1, 0:N-1) + mi = M - i; + ic = i; + + // Apply H(i): the reflector vector is row i of A starting at column i, + dlarf1f( side, mi, ni, A, strideA2, idx0, TAU[ idx1 ], C, strideC1, strideC2, idx2, WORK, strideWORK, offsetWORK ); + idx0 += i3*( strideA1 + strideA2 ); + idx1 += i3*strideTAU; + idx2 += i3*strideC1; + } + } else { + mi = M; + ic = 0; + + idx0 = offsetA + ( i1*strideA1 ) + ( i1*strideA2 ); + idx1 = offsetTAU + ( i1*strideTAU ); + idx2 = offsetC + ( ic*strideC1 ) + ( i1*strideC2 ); + for ( i = i1; ( i3 > 0 ) ? ( i <= i2 ) : ( i >= i2 ); i += i3 ) { + // Apply H(i) to C(0:M-1, i:N-1) + ni = N - i; + jc = i; + + // Apply H(i): the reflector vector is row i of A starting at column i, + dlarf1f( side, mi, ni, A, strideA2, idx0, TAU[ idx1 ], C, strideC1, strideC2, idx2, WORK, strideWORK, offsetWORK ); + idx0 += i3*( strideA1 + strideA2 ); + idx1 += i3*strideTAU; + idx2 += i3*strideC2; + } + } + + return 0; +} + + +// EXPORTS // + +module.exports = dorml2; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dormlq.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dormlq.js new file mode 100644 index 000000000000..ff55edc377d6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dormlq.js @@ -0,0 +1,250 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var max = require( '@stdlib/math/base/special/max' ); +var min = require( '@stdlib/math/base/special/min' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var dlarfb = require( './dlarfb.js' ); +var dlarft = require( './dlarft.js' ); +var dorml2 = require( './dorml2.js' ); + + +// VARIABLES // + +var NBMAX = 64; +var LDT = NBMAX + 1; +var TSIZE = LDT * NBMAX; + + +// FUNCTIONS // + +/** +* Tests whether an operation should be applied to the left side. +* +* @private +* @param {string} side - operation side +* @returns {boolean} boolean indicating if an operation should be applied to the left side +*/ +function isLeftSide( side ) { + return side === 'left'; +} + + +// MAIN // + +/** +* Applies an orthogonal matrix `Q`, formed from Householder reflectors returned by `DGELQF`, to overwrite matrix `C` by multiplying from the left or right with `Q` or `Q^T`. +* +* ## Notes +* +* - `Q` is a real orthogonal matrix defined as the product of k elementary reflectors, Q = H(k) . . . H(2) H(1) as returned by `DGELQF`. +* +* - `Q` is of order `M` if SIDE = 'left' and of order `N` if SIDE = 'R'. +* +* - `DORMQR` overwrites the general real `M` by `N` matrix `C` with, +* +* - `Q * C` if SIDE = 'left' and TRANS = 'no-transpose', or +* - `Q^T * C` if SIDE = 'left' and TRANS = 'transpose', or +* - `C * Q` if SIDE = 'right' and TRANS = 'no-transpose', or +* - `C * Q^T` if SIDE = 'right' and TRANS = 'transpose'. +* +* - `WORK` must have length, `LWORK >= max(1,N)` if SIDE = `left`, and `LWORK >= max(1,M)` if SIDE = `right`. +* +* @private +* @param {string} side - specifies the side of multiplication with `C` +* @param {string} trans - `'no-transpose'` for `Q`, `'transpose'` for `Q^T` +* @param {NonNegativeInteger} M - number of rows of `C` +* @param {NonNegativeInteger} N - number of columns of `C` +* @param {NonNegativeInteger} K - number of elementary reflectors +* @param {Float64Array} A - reflector vectors from `DGELQF` +* @param {integer} strideA1 - stride of the first dimension of A +* @param {integer} strideA2 - stride of the second dimension of A +* @param {NonNegativeInteger} offsetA - starting index for A +* @param {Float64Array} TAU - scalar factors of reflectors +* @param {integer} strideTAU - stride for TAU +* @param {NonNegativeInteger} offsetTAU - starting index for TAU +* @param {Float64Array} C - input/output 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 for `WORK` +* @param {NonNegativeInteger} offsetWORK - starting index for `WORK` +* @param {NonNegativeInteger} LWORK - dimension of the array `WORK` +* @returns {integer} status code (0 if successful) +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1, 0, 0 ] ); +* var TAU = new Float64Array( [ 2 ] ); +* var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); +* var WORK = new Float64Array( 64 ); +* +* var info = dormlq( 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 64 ); +* // returns 0 +* // C => [ -1, -3, -5, 2, 4, 6 ] +* // WORK[ 0 ] => 4256 +*/ +function dormlq( side, trans, M, N, K, A, strideA1, strideA2, offsetA, TAU, strideTAU, offsetTAU, C, strideC1, strideC2, offsetC, WORK, strideWORK, offsetWORK, LWORK ) { + var isTrans; + var isLeft; + var ldwork; + var lwkopt; + var lquery; + var transt; + var nbmin; + var idx0; + var idx1; + var idx2; + var iwt; + var mi; + var nb; + var ni; + var nq; + var nw; + var ic; + var jc; + var ib; + var i1; + var i2; + var i3; + var i; + + isLeft = isLeftSide( side ); + isTrans = ( trans === 'transpose' ); + lquery = ( LWORK === -1 ); + + // NQ is the order of Q and NW is the minimum dimension of WORK + if ( isLeft ) { + nq = M; + nw = max( 1, N ); + } else { + nq = N; + nw = max( 1, M ); + } + + nb = min( NBMAX, 32 ); // The optimal block size derived from fortran LAPACK call `ilaenv( 1, 'DORMLQ', side // trans, m, n, k, -1 ) )` + lwkopt = ( nw * nb ) + TSIZE; + WORK[ offsetWORK ] = lwkopt; + + if ( lquery ) { + return 0; + } + + // Quick return if possible + if ( M === 0 || N === 0 || K === 0 ) { + WORK[ offsetWORK ] = 1; + return 0; + } + + nbmin = 2; + ldwork = nw; + if ( nb > 1 && nb < K ) { + if ( LWORK < lwkopt ) { + nb = floor( ( LWORK - TSIZE ) / ldwork ); + nbmin = 2; // The minimal block size derived from fortran LAPACK call `ilaenv( 2, 'DORMLQ', side // trans, m, n, k, -1 ) )` + } + } + + if ( nb < nbmin || nb >= K ) { + // Use unblocked code + dorml2( side, trans, M, N, K, A, strideA1, strideA2, offsetA, TAU, strideTAU, offsetTAU, C, strideC1, strideC2, offsetC, WORK, strideWORK, offsetWORK ); + } else { + // Use blocked code + iwt = nw * nb; + + if ( ( isLeft && !isTrans ) || ( !isLeft && isTrans ) ) { + i1 = 0; + i2 = K; + i3 = nb; + } else { + i1 = floor( ( K - 1 ) / nb ) * nb; + i2 = -1; + i3 = -nb; + } + + if ( isTrans ) { + transt = 'no-transpose'; + } else { + transt = 'transpose'; + } + + if ( isLeft ) { + ni = N; + jc = 0; + + idx0 = offsetA + ( i1*strideA1 ) + ( i1*strideA2 ); + idx1 = offsetTAU + ( i1*strideTAU ); + idx2 = offsetC + ( i1*strideC1 ) + ( jc*strideC2 ); + for ( i = i1; ( i3 > 0 ) ? ( i < i2 ) : ( i > i2 ); i += i3 ) { + ib = min( nb, K - i ); + + // Form the triangular factor of the block reflector H = H(i) H(i+1) ... H(i+ib-1) + dlarft( 'forward', 'rows', nq - i, ib, A, strideA1, strideA2, idx0, TAU, strideTAU, idx1, WORK, 1, LDT, offsetWORK + ( iwt * strideWORK ) ); + + // H or H**T is applied to C(i:m,1:n) + mi = M - i; + ic = i; + + // Apply H or H**T + dlarfb( side, transt, 'forward', 'rows', mi, ni, ib, A, strideA1, strideA2, idx0, WORK, 1, LDT, offsetWORK + ( iwt * strideWORK ), C, strideC1, strideC2, idx2, WORK, 1, ldwork, offsetWORK ); + idx0 += i3 * ( strideA1 + strideA2 ); + idx1 += i3 * strideTAU; + idx2 += i3 * strideC1; + } + } else { + mi = M; + ic = 0; + + idx0 = offsetA + ( i1*strideA1 ) + ( i1*strideA2 ); + idx1 = offsetTAU + ( i1*strideTAU ); + idx2 = offsetC + ( ic*strideC1 ) + ( i1*strideC2 ); + for ( i = i1; ( i3 > 0 ) ? ( i < i2 ) : ( i > i2 ); i += i3 ) { + ib = min( nb, K - i ); + + // Form the triangular factor of the block reflector H = H(i) H(i+1) ... H(i+ib-1) + dlarft( 'forward', 'rows', nq - i, ib, A, strideA1, strideA2, idx0, TAU, strideTAU, idx1, WORK, 1, LDT, offsetWORK + ( iwt * strideWORK ) ); + + // H or H**T is applied to C(1:m,i:n) + ni = N - i; + jc = i; + + // Apply H or H**T + dlarfb( side, transt, 'forward', 'rows', mi, ni, ib, A, strideA1, strideA2, idx0, WORK, 1, LDT, offsetWORK + ( iwt * strideWORK ), C, strideC1, strideC2, idx2, WORK, 1, ldwork, offsetWORK ); + idx0 += i3 * ( strideA1 + strideA2 ); + idx1 += i3 * strideTAU; + idx2 += i3 * strideC2; + } + } + } + + WORK[ offsetWORK ] = lwkopt; + return 0; +} + + +// EXPORTS // + +module.exports = dormlq; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dormqr.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dormqr.js new file mode 100644 index 000000000000..fd4fe632f24a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dormqr.js @@ -0,0 +1,243 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var max = require( '@stdlib/math/base/special/max' ); +var min = require( '@stdlib/math/base/special/min' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var dlarfb = require( './dlarfb.js' ); +var dlarft = require( './dlarft.js' ); +var dorm2r = require( './dorm2r.js' ); + + +// VARIABLES // + +var NBMAX = 64; +var LDT = NBMAX + 1; +var TSIZE = LDT * NBMAX; + + +// FUNCTIONS // + +/** +* Tests whether an operation should be applied to the left side. +* +* @private +* @param {string} side - operation side +* @returns {boolean} boolean indicating if an operation should be applied to the left side +*/ +function isLeftSide( side ) { + return side === 'left'; +} + + +// MAIN // + +/** +* Applies an orthogonal matrix `Q`, formed from Householder reflectors returned by `DGEQRF`, to overwrite matrix `C` by multiplying from the left or right with `Q` or `Q^T`. +* +* ## Notes +* +* - `Q` is a real orthogonal matrix defined as the product of k elementary reflectors, Q = H(k) . . . H(2) H(1) as returned by `DGELQF`. +* +* - `Q` is of order `M` if SIDE = 'left' and of order `N` if SIDE = 'R'. +* +* - `DORML2` overwrites the general real `M` by `N` matrix `C` with, +* +* - `Q * C` if SIDE = 'left' and TRANS = 'no-transpose', or +* - `Q^T * C` if SIDE = 'left' and TRANS = 'transpose', or +* - `C * Q` if SIDE = 'right' and TRANS = 'no-transpose', or +* - `C * Q^T` if SIDE = 'right' and TRANS = 'transpose'. +* +* - `WORK` must have length, `LWORK >= max(1,N)` if SIDE = `left`, and `LWORK >= max(1,M)` if SIDE = `right`. +* +* @private +* @param {string} side - specifies the side of multiplication with `C` +* @param {string} trans - `'no-transpose'` for `Q`, `'transpose'` for `Q^T` +* @param {NonNegativeInteger} M - number of rows of `C` +* @param {NonNegativeInteger} N - number of columns of `C` +* @param {NonNegativeInteger} K - number of elementary reflectors +* @param {Float64Array} A - reflector vectors from `DGEQRF` +* @param {integer} strideA1 - stride of the first dimension of A +* @param {integer} strideA2 - stride of the second dimension of A +* @param {NonNegativeInteger} offsetA - starting index for A +* @param {Float64Array} TAU - scalar factors of reflectors +* @param {integer} strideTAU - stride for TAU +* @param {NonNegativeInteger} offsetTAU - starting index for TAU +* @param {Float64Array} C - input/output 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 for `WORK` +* @param {NonNegativeInteger} offsetWORK - starting index for `WORK` +* @param {NonNegativeInteger} LWORK - dimension of the array `WORK` +* @returns {integer} status code (0 if successful) +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1, 0, 0 ] ); +* var TAU = new Float64Array( [ 2 ] ); +* var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); +* var WORK = new Float64Array( 64 ); +* +* var info = dormqr( 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 64 ); +* // returns 0 +* // C => [ -1, -3, -5, 2, 4, 6 ] +* // WORK[ 0 ] => 4256 +*/ +function dormqr( side, trans, M, N, K, A, strideA1, strideA2, offsetA, TAU, strideTAU, offsetTAU, C, strideC1, strideC2, offsetC, WORK, strideWORK, offsetWORK, LWORK ) { + var isTrans; + var isLeft; + var ldwork; + var lwkopt; + var lquery; + var nbmin; + var idx0; + var idx1; + var idx2; + var iwt; + var mi; + var nb; + var ni; + var nq; + var nw; + var ic; + var jc; + var ib; + var i1; + var i2; + var i3; + var i; + + isLeft = isLeftSide( side ); + isTrans = ( trans === 'transpose' ); + lquery = ( LWORK === -1 ); + + // NQ is the order of Q and NW is the minimum dimension of WORK + if ( isLeft ) { + nq = M; + nw = max( 1, N ); + } else { + nq = N; + nw = max( 1, M ); + } + + nb = min( NBMAX, 32 ); // The optimal block size derived from fortran LAPACK call `ilaenv( 1, 'DORMQR', side // trans, m, n, k, -1 ) )` + lwkopt = ( nw * nb ) + TSIZE; + WORK[ offsetWORK ] = lwkopt; + + if ( lquery ) { + return 0; + } + + // Quick return if possible + if ( M === 0 || N === 0 || K === 0 ) { + WORK[ offsetWORK ] = 1; + return 0; + } + + nbmin = 2; + ldwork = nw; + if ( nb > 1 && nb < K ) { + if ( LWORK < lwkopt ) { + nb = floor( ( LWORK - TSIZE ) / ldwork ); + nbmin = 2; // The minimal block size derived from fortran LAPACK call `ilaenv( 2, 'DORMQR', side // trans, m, n, k, -1 ) )` + } + } + + if ( nb < nbmin || nb >= K ) { + // Use unblocked code + dorm2r( side, trans, M, N, K, A, strideA1, strideA2, offsetA, TAU, strideTAU, offsetTAU, C, strideC1, strideC2, offsetC, WORK, strideWORK, offsetWORK ); + } else { + // Use blocked code + iwt = nw * nb; + + if ( ( isLeft && isTrans ) || ( !isLeft && !isTrans ) ) { + i1 = 0; + i2 = K; + i3 = nb; + } else { + i1 = floor( ( K - 1 ) / nb ) * nb; + i2 = -1; + i3 = -nb; + } + + if ( isLeft ) { + ni = N; + jc = 0; + + idx0 = offsetA + ( i1*strideA1 ) + ( i1*strideA2 ); + idx1 = offsetTAU + ( i1*strideTAU ); + idx2 = offsetC + ( i1*strideC1 ) + ( jc*strideC2 ); + for ( i = i1; ( i3 > 0 ) ? ( i < i2 ) : ( i > i2 ); i += i3 ) { + ib = min( nb, K - i ); + + // Form the triangular factor of the block reflector H = H(i) H(i+1) ... H(i+ib-1) + dlarft( 'forward', 'columns', nq - i, ib, A, strideA1, strideA2, idx0, TAU, strideTAU, idx1, WORK, 1, LDT, offsetWORK + ( iwt * strideWORK ) ); + + // H or H**T is applied to C(i:m,1:n) + mi = M - i; + ic = i; + + // Apply H or H**T + dlarfb( side, trans, 'forward', 'columns', mi, ni, ib, A, strideA1, strideA2, idx0, WORK, 1, LDT, offsetWORK + ( iwt * strideWORK ), C, strideC1, strideC2, idx2, WORK, 1, ldwork, offsetWORK ); + idx0 += i3 * ( strideA1 + strideA2 ); + idx1 += i3 * strideTAU; + idx2 += i3 * strideC1; + } + } else { + mi = M; + ic = 0; + + idx0 = offsetA + ( i1*strideA1 ) + ( i1*strideA2 ); + idx1 = offsetTAU + ( i1*strideTAU ); + idx2 = offsetC + ( ic*strideC1 ) + ( i1*strideC2 ); + for ( i = i1; ( i3 > 0 ) ? ( i < i2 ) : ( i > i2 ); i += i3 ) { + ib = min( nb, K - i ); + + // Form the triangular factor of the block reflector H = H(i) H(i+1) ... H(i+ib-1) + dlarft( 'forward', 'columns', nq - i, ib, A, strideA1, strideA2, idx0, TAU, strideTAU, idx1, WORK, 1, LDT, offsetWORK + ( iwt * strideWORK ) ); + + // H or H**T is applied to C(1:m,i:n) + ni = N - i; + jc = i; + + // Apply H or H**T + dlarfb( side, trans, 'forward', 'columns', mi, ni, ib, A, strideA1, strideA2, idx0, WORK, 1, LDT, offsetWORK + ( iwt * strideWORK ), C, strideC1, strideC2, idx2, WORK, 1, ldwork, offsetWORK ); + idx0 += i3 * ( strideA1 + strideA2 ); + idx1 += i3 * strideTAU; + idx2 += i3 * strideC2; + } + } + } + + WORK[ offsetWORK ] = lwkopt; + return 0; +} + + +// EXPORTS // + +module.exports = dormqr; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dtrmm.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dtrmm.js new file mode 100644 index 000000000000..f360237c6ef3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/dtrmm.js @@ -0,0 +1,362 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-statements, max-lines-per-function */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); + + +// FUNCTIONS // + +/** +* Fills a matrix with zeros. +* +* @private +* @param {NonNegativeInteger} M - number of rows +* @param {NonNegativeInteger} N - number of columns +* @param {Float64Array} X - matrix to fill +* @param {integer} strideX1 - stride of the first dimension of `X` +* @param {integer} strideX2 - stride of the second dimension of `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` +* @returns {Float64Array} input matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* zeros( 2, 3, X, 3, 1, 0 ); +* // X => [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* zeros( 2, 3, X, 1, 2, 0 ); +* // X => [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] +*/ +function zeros( M, N, X, strideX1, strideX2, offsetX ) { // TODO: consider moving to a separate package + var dx0; + var dx1; + var S0; + var S1; + var i0; + var i1; + var ix; + + if ( isRowMajor( [ strideX1, strideX2 ] ) ) { + // For row-major matrices, the last dimension has the fastest changing index... + S0 = N; + S1 = M; + dx0 = strideX2; // offset increment for innermost loop + dx1 = strideX1 - ( S0*strideX2 ); // offset increment for outermost loop + } else { // column-major + // For column-major matrices, the first dimension has the fastest changing index... + S0 = M; + S1 = N; + dx0 = strideX1; // offset increment for innermost loop + dx1 = strideX2 - ( S0*strideX1 ); // offset increment for outermost loop + } + ix = offsetX; + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + X[ ix ] = 0.0; + ix += dx0; + } + ix += dx1; + } + return X; +} + + +// MAIN // + +/** +* Performs one of the matrix-matrix operations `B = α * op(A) * B` or `B = α * B * op(A)` where `α` is a scalar, `B` is an `M` by `N` matrix, `A` is a unit, or non-unit, upper or lower triangular matrix and `op( A )` is one of `op( A ) = A` or `op( A ) = A^T`. +* +* @private +* @param {string} side - specifies whether `op( A )` appears on the left or right side of `B` +* @param {string} uplo - specifies whether the upper or lower triangular part of the matrix `A` should be referenced +* @param {string} transa - specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param {string} diag - specifies whether or not `A` is unit triangular +* @param {NonNegativeInteger} M - number of rows in `B` +* @param {NonNegativeInteger} N - number of columns in `B` +* @param {number} alpha - scalar constant +* @param {Float64Array} A - first input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} B - second input matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` +* @returns {Float64Array} `B` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 3.0, 0.0, 4.0, 5.0, 6.0 ] ); +* var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +* +* dtrmm( 'left', 'lower', 'no-transpose', 'unit', 3, 3, 1.0, A, 3, 1, 0, B, 3, 1, 0 ); +* // B => [ 1.0, 2.0, 3.0, 6.0, 9.0, 12.0, 31.0, 41.0, 51.0 ] +*/ +function dtrmm( side, uplo, transa, diag, M, N, alpha, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-params + var nonunit; + var isrma; + var tmp; + var oa2; + var ob2; + var sa0; + var sa1; + var sb0; + var sb1; + var oa; + var ob; + var ia; + var ib; + var i; + var j; + var k; + var t; + + // Note on variable naming convention: sa#, sb# where # corresponds to the loop number, with `0` being the innermost loop... + + nonunit = ( diag === 'non-unit' ); + + if ( M === 0 || N === 0 ) { + return B; + } + + // Handle alpha = 0 before any layout conversion (zeroing uses original layout)... + if ( alpha === 0.0 ) { + if ( isRowMajor( [ strideB1, strideB2 ] ) ) { + sb0 = strideB2; + sb1 = strideB1; + } else { + sb0 = strideB1; + sb1 = strideB2; + } + zeros( M, N, B, sb0, sb1, offsetB ); + return B; + } + + // Detect layout and convert column-major to an equivalent row-major problem... + isrma = isRowMajor( [ strideA1, strideA2 ] ); + if ( !isrma ) { + // Swap strides: effectively view A and B as transposed (row-major)... + t = strideA1; + strideA1 = strideA2; + strideA2 = t; + + t = strideB1; + strideB1 = strideB2; + strideB2 = t; + + side = ( side === 'left' ) ? 'right' : 'left'; + uplo = ( uplo === 'upper' ) ? 'lower' : 'upper'; + t = M; + M = N; + N = t; + } + + // For row-major matrices, the last dimension has the fastest changing index... + sa0 = strideA2; // stride for innermost loop + sa1 = strideA1; // stride for outermost loop + sb0 = strideB2; // stride for innermost loop + sb1 = strideB1; // stride for outermost loop + + if ( side === 'left' && uplo === 'upper' && transa === 'no-transpose' ) { + for ( j = 0; j < N; j++ ) { + ib = offsetB + ( j*sb0 ); + for ( k = 0; k < M; k++ ) { + ob2 = ib + ( k * sb1 ); + tmp = alpha * B[ ob2 ]; + ia = offsetA + ( k*sa0 ); + for ( i = 0; i < k; i++ ) { + B[ ib + ( i*sb1 ) ] += ( tmp * A[ ia + ( i*sa1 ) ] ); + } + if ( nonunit ) { + tmp *= A[ ia + ( k*sa1 ) ]; + } + B[ ob2 ] = tmp; + } + } + return B; + } + if ( side === 'left' && uplo === 'lower' && transa === 'no-transpose' ) { + for ( j = 0; j < N; j++ ) { + ib = offsetB + ( j*sb0 ); + for ( k = M - 1; k >= 0; k-- ) { + ob2 = ib + ( k*sb1 ); + tmp = alpha * B[ ob2 ]; + ia = offsetA + ( k*sa0 ); + for ( i = k + 1; i < M; i++ ) { + oa2 = ia + ( i*sa1 ); + B[ ib + ( i*sb1 ) ] += ( tmp * A[ oa2 ] ); + } + if ( nonunit ) { + tmp *= A[ ia + ( k*sa1 ) ]; + } + B[ ob2 ] = tmp; + } + } + return B; + } + if ( side === 'left' && uplo === 'upper' && transa !== 'no-transpose' ) { + for ( j = 0; j < N; j++ ) { + ib = offsetB + ( j*sb0 ); + for ( i = M - 1; i >= 0; i-- ) { + ob2 = ib + ( i*sb1 ); + tmp = 0.0; + ia = offsetA + ( i*sa0 ); + if ( nonunit ) { + tmp += ( A[ ia + ( i*sa1 ) ] * B[ ob2 ] ); + } else { + tmp += B[ ob2 ]; + } + for ( k = 0; k < i; k++ ) { + oa2 = ia + ( k*sa1 ); + tmp += A[ oa2 ] * B[ ib + ( k*sb1 ) ]; + } + B[ ob2 ] = alpha * tmp; + } + } + return B; + } + if ( side === 'left' && uplo === 'lower' && transa !== 'no-transpose' ) { + for ( j = 0; j < N; j++ ) { + ib = offsetB + ( j * sb0 ); + for ( i = 0; i < M; i++ ) { + ia = offsetA + ( i * sa0 ); + ob2 = ib + ( i * sb1 ); + tmp = 0.0; + for ( k = i + 1; k < M; k++ ) { + tmp += A[ ia + ( k * sa1 ) ] * B[ ib + ( k * sb1 ) ]; + } + if ( nonunit ) { + tmp += ( A[ ia + ( i * sa1 ) ] * B[ ob2 ] ); + } else { + tmp += B[ ob2 ]; + } + B[ ob2 ] = alpha * tmp; + } + } + return B; + } + if ( side === 'right' && uplo === 'upper' && transa === 'no-transpose' ) { + for ( j = N - 1; j >= 0; j-- ) { + ia = offsetA + ( j*sa0 ); + ib = offsetB + ( j*sb0 ); + for ( i = 0; i < M; i++ ) { + ob = ib + ( i*sb1 ); + B[ ob ] *= alpha; + if ( nonunit ) { + oa2 = ia + ( j*sa1 ); + tmp = A[ oa2 ]; + B[ ob ] *= tmp; + } + for ( k = 0; k < j; k++ ) { + oa2 = ia + ( k*sa1 ); + ob2 = offsetB + ( k*sb0 ); + if ( A[ oa2 ] !== 0.0 ) { + tmp = alpha * A[ oa2 ]; + B[ ob ] += ( tmp * B[ ob2 + ( i*sb1 ) ] ); + } + } + } + } + return B; + } + if ( side === 'right' && uplo === 'lower' && transa === 'no-transpose' ) { + for ( j = 0; j < N; j++ ) { + ia = offsetA + ( j*sa0 ); + for ( i = 0; i < M; i++ ) { + ib = offsetB + ( i*sb1 ); + ob = ib + ( j*sb0 ); + B[ ob ] *= alpha; + if ( nonunit ) { + oa = ia + ( j*sa1 ); + B[ ob ] *= A[ oa ]; + } + for ( k = j + 1; k < N; k++ ) { + oa2 = ia + ( k*sa1 ); + ob2 = ib + ( k*sb0 ); + if ( A[ oa2 ] !== 0.0 ) { + tmp = alpha * A[ oa2 ]; + B[ ob ] += ( tmp * B[ ob2 ] ); + } + } + } + } + return B; + } + if ( side === 'right' && uplo === 'upper' && transa !== 'no-transpose' ) { + for ( j = 0; j < N; j++ ) { + ia = offsetA + ( j*sa1 ); + for ( i = 0; i < M; i++ ) { + ib = offsetB + ( i*sb1 ); + oa = ia + ( j*sa0 ); + ob = ib + ( j*sb0 ); + if ( nonunit ) { + tmp = B[ ob ] * A[ oa ]; + } else { + tmp = B[ ob ]; + } + for ( k = j + 1; k < N; k++ ) { + oa2 = ia + ( k*sa0 ); + ob2 = ib + ( k*sb0 ); + tmp += ( B[ ob2 ] * A[ oa2 ] ); + } + B[ ob ] = alpha * tmp; + } + } + return B; + } + // side === 'right', uplo === 'lower', transa !== 'no-transpose' + for ( i = 0; i < M; i++ ) { + ib = offsetB + ( i*sb1 ); + for ( j = N - 1; j >= 0; j-- ) { + ia = offsetA + ( j*sa1 ); + oa = ia + ( j*sa0 ); + ob = ib + ( j*sb0 ); + if ( nonunit ) { + tmp = B[ ob ] * A[ oa ]; + } else { + tmp = B[ ob ]; + } + for ( k = 0; k < j; k++ ) { + oa2 = ia + ( k*sa0 ); + ob2 = ib + ( k*sb0 ); + tmp += ( B[ ob2 ] * A[ oa2 ] ); + } + B[ ob ] = alpha * tmp; + } + } + return B; +} + + +// EXPORTS // + +module.exports = dtrmm; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/index.js new file mode 100644 index 000000000000..65945e878986 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/index.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to multiply a general matrix by the orthogonal matrix from a bi-diagonal reduction determined by `DGEBRD`. +* +* @module @stdlib/lapack/base/dormbr +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dormbr = require( '@stdlib/lapack/base/dormbr' ); +* +* var A = new Float64Array( [ 1, 0, 0 ] ); +* var TAU = new Float64Array( [ 2 ] ); +* var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); +* var WORK = new Float64Array( 3 ); +* +* var info = dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); +* // returns 0 +* // C => [ -1, -3, -5, 2, 4, 6 ] +* // WORK[ 0 ] => 96 +*/ + +// 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 dormbr; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dormbr = main; +} else { + dormbr = tmp; +} + + +// EXPORTS // + +module.exports = dormbr; + +// exports: { "ndarray": "dormbr.ndarray" } diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/left_backward_columns.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/left_backward_columns.js new file mode 100644 index 000000000000..5a71b0c9aec0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/left_backward_columns.js @@ -0,0 +1,162 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dgemm = require( '@stdlib/blas/base/dgemm' ).ndarray; +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var dtrmm = require( './dtrmm.js' ); + + +// MAIN // + +/** +* Applies a real block reflector H or its transpose H^T to a real M by N matrix C from the left, with backward direction and column storage. +* +* @private +* @param {NonNegativeInteger} M - number of rows of the matrix C +* @param {NonNegativeInteger} N - number of columns of the matrix C +* @param {NonNegativeInteger} K - order of the matrix T +* @param {Float64Array} V - input matrix +* @param {integer} strideV1 - stride of the first dimension of V +* @param {integer} strideV2 - stride of the second dimension of V +* @param {integer} offsetV - index offset for V +* @param {Float64Array} T - input matrix +* @param {integer} strideT1 - stride of the first dimension of T +* @param {integer} strideT2 - stride of the second dimension of T +* @param {integer} offsetT - index offset for T +* @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 {integer} offsetC - index offset for C +* @param {Float64Array} work - work array +* @param {integer} strideWork1 - stride of the first dimension of work +* @param {integer} strideWork2 - stride of the second dimension of work +* @param {integer} offsetWork - index offset for work +* @param {string} trans - specifies whether to apply H or H^T +* @returns {Float64Array} updated matrix C +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 10.0, 40.0, 70.0, 20.0, 50.0, 80.0, 30.0, 60.0, 90.0 ] ); +* var T = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var C = new Float64Array( [ 11.0, 12.0, 13.0, 21.0, 22.0, 23.0, 31.0, 32.0, 33.0 ] ); +* var work = new Float64Array( 9 ); +* +* var result = leftBackwardColumns( 3, 3, 3, V, 3, 1, 0, T, 3, 1, 0, C, 3, 1, 0, work, 3, 1, 0, 'no-transpose' ); +* // returns [ -557890.0, -592880.0, -627870.0, -596341.0, -632662.0, -668983.0, -7412.0, -7864.0, -8316.0 ] +*/ +function leftBackwardColumns( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ) { // eslint-disable-line max-params, max-len + var transt; + var da0; + var da1; + var db0; + var db1; + var sh; + var sa; + var sb; + var S0; + var S1; + var ia; + var ib; + var ic; + var iv; + var iw; + var i; + var j; + var o; + + if ( trans === 'no-transpose' ) { + transt = 'transpose'; + } else { + transt = 'no-transpose'; + } + + /* Let V = ( V1 ) + * ( V2 ) (last K rows) + * Where V2 is unit upper triangular. + */ + + /* Form H * C or H^T * C where C = ( C1 ) + * ( C2 ) + * W := C**T * V = (C1**T * V1 + C2**T * V2) (stored in WORK) + * W := C2**T + */ + ic = offsetC + ( (M-K) * strideC1 ); + iw = offsetWork; + for ( j = 0; j < K; j++ ) { + iw = offsetWork + ( j * strideWork2 ); + dcopy( N, C, strideC2, ic, work, strideWork1, iw ); + ic += strideC1; + iw += strideWork2; + } + // W := W * V2 + iv = offsetV + ( (M-K) * strideV1 ); + dtrmm( 'right', 'upper', 'no-transpose', 'unit', N, K, 1.0, V, strideV1, strideV2, iv, work, strideWork1, strideWork2, offsetWork ); + if ( M > K ) { + // W := W + C1**T * V1 + dgemm( 'transpose', 'no-transpose', N, K, M-K, 1.0, C, strideC1, strideC2, offsetC, V, strideV1, strideV2, offsetV, 1.0, work, strideWork1, strideWork2, offsetWork ); + } + // W := W * T**T or W * T + dtrmm( 'right', 'lower', transt, 'non-unit', N, K, 1.0, T, strideT1, strideT2, offsetT, work, strideWork1, strideWork2, offsetWork ); + + // C := C - V * W**T + if ( M > K ) { + // C1 := C1 - V1 * W**T + dgemm( 'no-transpose', 'transpose', M-K, N, K, -1.0, V, strideV1, strideV2, offsetV, work, strideWork1, strideWork2, offsetWork, 1.0, C, strideC1, strideC2, offsetC ); + } + // W := W * V2**T + iv = offsetV + ( (M-K) * strideV1 ); + dtrmm( 'right', 'upper', 'transpose', 'unit', N, K, 1.0, V, strideV1, strideV2, iv, work, strideWork1, strideWork2, offsetWork ); + + // C2 := C2 - W**T + o = loopOrder( [ K, N ], [ strideC2, strideC1 ], [ strideWork1, strideWork2 ] ); // eslint-disable-line max-len + sh = o.sh; + sa = o.sx; + sb = o.sy; + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + da0 = sa[ 0 ]; + da1 = sa[ 1 ] - ( S0 * sa[ 0 ] ); + db0 = sb[ 0 ]; + db1 = sb[ 1 ] - ( S0 * sb[ 0 ] ); + + ia = offsetC + ( (M-K) * strideC1 ); + ib = offsetWork; + + for ( j = 0; j < S1; j++ ) { + for ( i = 0; i < S0; i++ ) { + C[ ia ] -= work[ ib ]; + ia += da0; + ib += db0; + } + ia += da1; + ib += db1; + } + + return C; +} + + +// EXPORTS // + +module.exports = leftBackwardColumns; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/left_backward_rows.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/left_backward_rows.js new file mode 100644 index 000000000000..89bedab3ecee --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/left_backward_rows.js @@ -0,0 +1,165 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dgemm = require( '@stdlib/blas/base/dgemm' ).ndarray; +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var dtrmm = require( './dtrmm.js' ); + + +// MAIN // + +/** +* Applies a real block reflector H or its transpose H^T to a real M by N matrix C from the left, with backward direction and row storage. +* +* @private +* @param {NonNegativeInteger} M - number of rows of the matrix C +* @param {NonNegativeInteger} N - number of columns of the matrix C +* @param {NonNegativeInteger} K - order of the matrix T +* @param {Float64Array} V - input matrix +* @param {integer} strideV1 - stride of the first dimension of V +* @param {integer} strideV2 - stride of the second dimension of V +* @param {integer} offsetV - index offset for V +* @param {Float64Array} T - input matrix +* @param {integer} strideT1 - stride of the first dimension of T +* @param {integer} strideT2 - stride of the second dimension of T +* @param {integer} offsetT - index offset for T +* @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 {integer} offsetC - index offset for C +* @param {Float64Array} work - work array +* @param {integer} strideWork1 - stride of the first dimension of work +* @param {integer} strideWork2 - stride of the second dimension of work +* @param {integer} offsetWork - index offset for work +* @param {string} trans - specifies whether to apply H or H^T +* @returns {Float64Array} updated matrix C +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 10.0, 40.0, 70.0, 20.0, 50.0, 80.0, 30.0, 60.0, 90.0 ] ); +* var T = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var C = new Float64Array( [ 11.0, 12.0, 13.0, 21.0, 22.0, 23.0, 31.0, 32.0, 33.0 ] ); +* var work = new Float64Array( 9 ); +* +* var result = leftBackwardRows( 3, 3, 3, V, 3, 1, 0, T, 3, 1, 0, C, 3, 1, 0, work, 3, 1, 0, 'no-transpose' ); +* // returns [ -155530.0, -164560.0, -173590.0, -292241.0, -308662.0, -325083.0, -4832.0, -5104.0, -5376.0 ] +*/ +function leftBackwardRows( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ) { // eslint-disable-line max-params, max-len + var transt; + var da0; + var da1; + var db0; + var db1; + var i0; + var i1; + var sh; + var sa; + var sb; + var S0; + var S1; + var ia; + var ib; + var ic; + var iv; + var iw; + var j; + var o; + + if ( trans === 'no-transpose' ) { + transt = 'transpose'; + } else { + transt = 'no-transpose'; + } + + /* Let V = ( V1 V2 ) (V2: last K columns) + * Where V2 is unit lower triangular. + */ + + /* Form H * C or H^T * C where C = ( C1 ) + * ( C2 ) + * W := C**T * V**T = (C1**T * V1**T + C2**T * V2**T) (stored in WORK) + * W := C2**T + */ + ic = offsetC; + iw = offsetWork; + for ( j = 0; j < K; j++ ) { + dcopy( N, C, strideC2, ic, work, strideWork1, iw ); + ic += strideC1; + iw += strideWork2; + } + // W := W * V2**T + iv = offsetV + ( (M-K) * strideV2 ); + dtrmm( 'right', 'lower', 'transpose', 'unit', N, K, 1.0, V, strideV1, strideV2, iv, work, strideWork1, strideWork2, offsetWork ); + if ( M > K ) { + // W := W + C1**T * V1**T + dgemm( 'transpose', 'transpose', N, K, M-K, 1.0, C, strideC1, strideC2, offsetC, V, strideV1, strideV2, offsetV, 1.0, work, strideWork1, strideWork2, offsetWork ); + } + // W := W * T**T or W * T + dtrmm( 'right', 'lower', transt, 'non-unit', N, K, 1.0, T, strideT1, strideT2, offsetT, work, strideWork1, strideWork2, offsetWork ); + + // C := C - V**T * W**T + if ( M > K ) { + // C1 := C1 - V1**T * W**T + dgemm( 'transpose', 'transpose', M-K, N, K, -1.0, V, strideV1, strideV2, offsetV, work, strideWork1, strideWork2, offsetWork, 1.0, C, strideC1, strideC2, offsetC ); + } + // W := W * V2 + iv = offsetV + ( (M-K) * strideV2 ); + dtrmm( 'right', 'lower', 'no-transpose', 'unit', N, K, 1.0, V, strideV1, strideV2, iv, work, strideWork1, strideWork2, offsetWork ); + + // C2 := C2 - W**T + o = loopOrder( [ K, N ], [ strideC1, strideC2 ], [ strideWork2, strideWork1 ] ); // eslint-disable-line max-len + sh = o.sh; + sa = o.sx; + sb = o.sy; + + // Extract loop variables for loop interchange + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + da0 = sa[ 0 ]; + da1 = sa[ 1 ] - ( S0 * sa[ 0 ] ); + db0 = sb[ 0 ]; + db1 = sb[ 1 ] - ( S0 * sb[ 0 ] ); + + // Set pointers to first indexed elements + ia = offsetC + ( (M-K) * strideC1 ); + ib = offsetWork; + + // Iterate over matrix dimensions with optimized loop order + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + C[ ia ] -= work[ ib ]; + ia += da0; + ib += db0; + } + ia += da1; + ib += db1; + } + + return C; +} + + +// EXPORTS // + +module.exports = leftBackwardRows; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/left_forward_columns.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/left_forward_columns.js new file mode 100644 index 000000000000..e7b134abf652 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/left_forward_columns.js @@ -0,0 +1,168 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dgemm = require( '@stdlib/blas/base/dgemm' ).ndarray; +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var dtrmm = require( './dtrmm.js' ); + + +// MAIN // + +/** +* Applies a real block reflector H or its transpose H^T to a real M by N matrix C from the left, with forward direction and column storage. +* +* @private +* @param {NonNegativeInteger} M - number of rows of the matrix C +* @param {NonNegativeInteger} N - number of columns of the matrix C +* @param {NonNegativeInteger} K - order of the matrix T +* @param {Float64Array} V - input matrix +* @param {integer} strideV1 - stride of the first dimension of V +* @param {integer} strideV2 - stride of the second dimension of V +* @param {integer} offsetV - index offset for V +* @param {Float64Array} T - input matrix +* @param {integer} strideT1 - stride of the first dimension of T +* @param {integer} strideT2 - stride of the second dimension of T +* @param {integer} offsetT - index offset for T +* @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 {integer} offsetC - index offset for C +* @param {Float64Array} work - work array +* @param {integer} strideWork1 - stride of the first dimension of work +* @param {integer} strideWork2 - stride of the second dimension of work +* @param {integer} offsetWork - index offset for work +* @param {string} trans - specifies whether to apply H or H^T +* @returns {Float64Array} updated matrix C +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 10.0, 40.0, 70.0, 20.0, 50.0, 80.0, 30.0, 60.0, 90.0 ] ); +* var T = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var C = new Float64Array( [ 11.0, 12.0, 13.0, 21.0, 22.0, 23.0, 31.0, 32.0, 33.0 ] ); +* var work = new Float64Array( 9 ); +* +* var result = leftForwardColumns( 3, 3, 3, V, 3, 1, 0, T, 3, 1, 0, C, 3, 1, 0, work, 3, 1, 0, 'no-transpose' ); +* // returns [ -1350.0, -1400.0, -1450.0, -30961.0, -32102.0, -33243.0, -266612.0, -275464.0, -284316.0 ] +*/ +function leftForwardColumns( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ) { // eslint-disable-line max-params, max-len + var transt; + var da0; + var da1; + var db0; + var db1; + var i0; + var i1; + var sh; + var sa; + var sb; + var S0; + var S1; + var ia; + var ib; + var ic; + var iv; + var iw; + var j; + var o; + + if ( trans === 'no-transpose' ) { + transt = 'transpose'; + } else { + transt = 'no-transpose'; + } + + /* Let V = ( V1 ) (first K rows) + * ( V2 ) + * Where V1 is unit lower triangular. + */ + + /* Form H * C or H^T * C where C = ( C1 ) + * ( C2 ) + * W := C**T * V = (C1**T * V1 + C2**T * V2) (stored in WORK) + * W := C1**T + */ + ic = offsetC; + iw = offsetWork; + for ( j = 0; j < K; j++ ) { + dcopy( N, C, strideC2, ic, work, strideWork1, iw ); + ic += strideC1; + iw += strideWork2; + } + // W := W * V1 + dtrmm( 'right', 'lower', 'no-transpose', 'unit', N, K, 1.0, V, strideV1, strideV2, offsetV, work, strideWork1, strideWork2, offsetWork ); + if ( M > K ) { + // W := W + C2**T * V2 + ic = offsetC + ( K * strideC1 ); // C( k+1, 1 ) - 0 based index + iv = offsetV + ( K * strideV1 ); // V( k+1, 1 ) - 0 based index + dgemm( 'transpose', 'no-transpose', N, K, M-K, 1.0, C, strideC1, strideC2, ic, V, strideV1, strideV2, iv, 1.0, work, strideWork1, strideWork2, offsetWork ); + } + // W := W * T**T or W * T + dtrmm( 'right', 'upper', transt, 'non-unit', N, K, 1.0, T, strideT1, strideT2, offsetT, work, strideWork1, strideWork2, offsetWork ); + + // C := C - V * W**T + if ( M > K ) { + // C2 := C2 - V2 * W**T + ic = offsetC + ( K * strideC1 ); // C( k+1, 1 ) - 0 based index + iv = offsetV + ( K * strideV1 ); // V( k+1, 1 ) - 0 based index + dgemm( 'no-transpose', 'transpose', M-K, N, K, -1.0, V, strideV1, strideV2, iv, work, strideWork1, strideWork2, offsetWork, 1.0, C, strideC1, strideC2, ic ); + } + // W := W * V1**T + dtrmm( 'right', 'lower', 'transpose', 'unit', N, K, 1.0, V, strideV1, strideV2, offsetV, work, strideWork1, strideWork2, offsetWork ); + + // C1 := C1 - W**T + o = loopOrder( [ K, N ], [ strideC1, strideC2 ], [ strideWork2, strideWork1 ] ); // eslint-disable-line max-len + sh = o.sh; + sa = o.sx; + sb = o.sy; + + // Extract loop variables for loop interchange + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + da0 = sa[ 0 ]; + da1 = sa[ 1 ] - ( S0 * sa[ 0 ] ); + db0 = sb[ 0 ]; + db1 = sb[ 1 ] - ( S0 * sb[ 0 ] ); + + // Set pointers to first indexed elements + ia = offsetC; + ib = offsetWork; + + // Iterate over matrix dimensions with optimized loop order + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + C[ ia ] -= work[ ib ]; + ia += da0; + ib += db0; + } + ia += da1; + ib += db1; + } + + return C; +} + + +// EXPORTS // + +module.exports = leftForwardColumns; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/left_forward_rows.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/left_forward_rows.js new file mode 100644 index 000000000000..d62c3646d67f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/left_forward_rows.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dgemm = require( '@stdlib/blas/base/dgemm' ).ndarray; +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var dtrmm = require( './dtrmm.js' ); + + +// MAIN // + +/** +* Applies a real block reflector H or its transpose H^T to a real M by N matrix C from the left, with forward direction and row storage. +* +* @private +* @param {NonNegativeInteger} M - number of rows of the matrix C +* @param {NonNegativeInteger} N - number of columns of the matrix C +* @param {NonNegativeInteger} K - order of the matrix T +* @param {Float64Array} V - input matrix +* @param {integer} strideV1 - stride of the first dimension of V +* @param {integer} strideV2 - stride of the second dimension of V +* @param {integer} offsetV - index offset for V +* @param {Float64Array} T - input matrix +* @param {integer} strideT1 - stride of the first dimension of T +* @param {integer} strideT2 - stride of the second dimension of T +* @param {integer} offsetT - index offset for T +* @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 {integer} offsetC - index offset for C +* @param {Float64Array} work - work array +* @param {integer} strideWork1 - stride of the first dimension of work +* @param {integer} strideWork2 - stride of the second dimension of work +* @param {integer} offsetWork - index offset for work +* @param {string} trans - specifies whether to apply H or H^T +* @returns {Float64Array} updated matrix C +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 10.0, 40.0, 70.0, 20.0, 50.0, 80.0, 30.0, 60.0, 90.0 ] ); +* var T = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var C = new Float64Array( [ 11.0, 12.0, 13.0, 21.0, 22.0, 23.0, 31.0, 32.0, 33.0 ] ); +* var work = new Float64Array( 9 ); +* +* var result = leftForwardRows( 3, 3, 3, V, 3, 1, 0, T, 3, 1, 0, C, 3, 1, 0, work, 3, 1, 0, 'no-transpose' ); +* // returns [ -3010.0, -3120.0, -3230.0, -125821.0, -130422.0, -135023.0, -611692.0, -632424.0, -653156.0 ] +*/ +function leftForwardRows( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ) { // eslint-disable-line max-params, max-len + var transt; + var da0; + var da1; + var db0; + var db1; + var i0; + var i1; + var sh; + var sa; + var sb; + var S0; + var S1; + var ia; + var ib; + var ic; + var iv; + var iw; + var j; + var o; + + if ( trans === 'no-transpose' ) { + transt = 'transpose'; + } else { + transt = 'no-transpose'; + } + + /* Let V = ( V1 V2 ) (V1: first K columns) + * Where V1 is unit upper triangular. + */ + + /* Form H * C or H^T * C where C = ( C1 ) + * ( C2 ) + * W := C**T * V**T = (C1**T * V1**T + C2**T * V2**T) (stored in work) + * W := C1**T + */ + ic = offsetC; + iw = offsetWork; + for ( j = 0; j < K; j++ ) { + dcopy( N, C, strideC2, ic, work, strideWork1, iw ); + ic += strideC1; + iw += strideWork2; + } + // W := W * V1**T + dtrmm( 'right', 'upper', 'transpose', 'unit', N, K, 1.0, V, strideV1, strideV2, offsetV, work, strideWork1, strideWork2, offsetWork ); + if ( M > K ) { + // W := W + C2**T * V2**T + ic = offsetC + ( K * strideC1 ); + iv = offsetV + ( K * strideV2 ); + dgemm( 'transpose', 'transpose', N, K, M-K, 1.0, C, strideC1, strideC2, ic, V, strideV1, strideV2, iv, 1.0, work, strideWork1, strideWork2, offsetWork ); + } + // W := W * T**T or W * T + dtrmm( 'right', 'upper', transt, 'non-unit', N, K, 1.0, T, strideT1, strideT2, offsetT, work, strideWork1, strideWork2, offsetWork ); + + // C := C - V**T * W**T + if ( M > K ) { + // C2 := C2 - V2**T * W**T + ic = offsetC + ( K * strideC1 ); + iv = offsetV + ( K * strideV2 ); + dgemm( 'transpose', 'transpose', M-K, N, K, -1.0, V, strideV1, strideV2, iv, work, strideWork1, strideWork2, offsetWork, 1.0, C, strideC1, strideC2, ic ); + } + // W := W * V1 + dtrmm( 'right', 'upper', 'no-transpose', 'unit', N, K, 1.0, V, strideV1, strideV2, offsetV, work, strideWork1, strideWork2, offsetWork ); + + // C1 := C1 - W**T + o = loopOrder( [ K, N ], [ strideC1, strideC2 ], [ strideWork2, strideWork1 ] ); // eslint-disable-line max-len + sh = o.sh; + sa = o.sx; + sb = o.sy; + + // Extract loop variables for loop interchange + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + da0 = sa[ 0 ]; + da1 = sa[ 1 ] - ( S0 * sa[ 0 ] ); + db0 = sb[ 0 ]; + db1 = sb[ 1 ] - ( S0 * sb[ 0 ] ); + + // Set pointers to first indexed elements + ia = offsetC; + ib = offsetWork; + + // Iterate over matrix dimensions with optimized loop order + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + C[ ia ] -= work[ ib ]; + ia += da0; + ib += db0; + } + ia += da1; + ib += db1; + } + + return C; +} + + +// EXPORTS // + +module.exports = leftForwardRows; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/main.js new file mode 100644 index 000000000000..1dc8ff7e7ff7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dormbr = require( './dormbr.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dormbr, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dormbr; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/ndarray.js new file mode 100644 index 000000000000..efe2ff6b5569 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/ndarray.js @@ -0,0 +1,138 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var format = require( '@stdlib/string/format' ); +var max = require( '@stdlib/math/base/special/max' ); +var isOperationSide = require( '@stdlib/blas/base/assert/is-operation-side' ); +var isMatrixTranspose = require( '@stdlib/blas/base/assert/is-transpose-operation' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Multiplies a general matrix by the orthogonal matrix from a bi-diagonal reduction determined by `DGEBRD` using alternative indexing semantics. +* +* ## Notes +* +* - `Q` and `P^T` are the orthogonal matrices determined by `DGEBRD` when reducing a real matrix `A` to bi-diagonal form, `A = Q * B * P^T`. +* +* - If VECT = 'Q', `DORMBR` overwrites the general real `M` by `N` matrix `C` with, +* +* - `Q * C` if SIDE = 'left' and TRANS = 'no-transpose', or +* - `Q^T * C` if SIDE = 'left' and TRANS = 'transpose', or +* - `C * Q` if SIDE = 'right' and TRANS = 'no-transpose', or +* - `C * Q^T` if SIDE = 'right' and TRANS = 'transpose'. +* +* - If VECT = 'P', `DORMBR` overwrites the general real `M` by `N` matrix `C` with, +* +* - `P * C` if SIDE = 'left' and TRANS = 'no-transpose', or +* - `P^T * C` if SIDE = 'left' and TRANS = 'transpose', or +* - `C * P` if SIDE = 'right' and TRANS = 'no-transpose', or +* - `C * P^T` if SIDE = 'right' and TRANS = 'transpose'. +* +* - If SIDE = 'left', `LWORK >= max(1,N)`. +* +* - If SIDE = 'right', `LWORK >= max(1,M)`. +* +* - For optimum performance, `LWORK >= N*NB` if SIDE = 'left', and `LWORK >= M*NB` if SIDE = 'right', where `NB` is the optimal blocksize. +* +* - If `LWORK = -1`, then a workspace query is assumed; the routine only calculates the optimal size of the `WORK` array and returns this value as the first entry of the `WORK` array. +* +* @param {string} vect - specifies whether the matrix `Q` or the matrix `P` is applied +* @param {string} side - specifies the side of multiplication with `C` +* @param {string} trans - `'no-transpose'` for `Q` or `P`, `'transpose'` for `Q^T` or `P^T` +* @param {NonNegativeInteger} M - number of rows of `C` +* @param {NonNegativeInteger} N - number of columns of `C` +* @param {NonNegativeInteger} K - number of elementary reflectors +* @param {Float64Array} A - reflector vectors from `DGEBRD` +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} TAU - scalar factors of reflectors +* @param {integer} strideTAU - stride for `TAU` +* @param {NonNegativeInteger} offsetTAU - starting index for `TAU` +* @param {Float64Array} C - input/output 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 for `WORK` +* @param {NonNegativeInteger} offsetWORK - starting index for `WORK` +* @param {NonNegativeInteger} LWORK - dimension of the array `WORK` +* @throws {TypeError} first argument must be either `'Q'` or `'P'` +* @throws {TypeError} second argument must be a valid operation side +* @throws {TypeError} third argument must be a valid transpose operation +* @throws {RangeError} fourth argument must be a nonnegative integer +* @throws {RangeError} fifth argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be a nonnegative integer +* @throws {RangeError} twenty-first argument must be a valid `LWORK` value +* @returns {integer} status code (0 if successful) +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1, 0, 0 ] ); +* var TAU = new Float64Array( [ 2 ] ); +* var C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); +* var WORK = new Float64Array( 3 ); +* +* var info = dormbr( 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, 1, 0, TAU, 1, 0, C, 3, 1, 0, WORK, 1, 0, 3 ); +* // returns 0 +* // C => [ -1, -3, -5, 2, 4, 6 ] +* // WORK[ 0 ] => 96 +*/ +function dormbr( vect, side, trans, M, N, K, A, strideA1, strideA2, offsetA, TAU, strideTAU, offsetTAU, C, strideC1, strideC2, offsetC, WORK, strideWORK, offsetWORK, LWORK ) { + if ( vect !== 'Q' && vect !== 'P' ) { + throw new TypeError( format( 'invalid argument. First argument must be either `\'Q\'` or `\'P\'`. Value: `%s`.', vect ) ); + } + if ( !isOperationSide( side ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a valid operation side. Value: `%s`.', side ) ); + } + if ( !isMatrixTranspose( trans ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be a valid transpose operation. Value: `%s`.', trans ) ); + } + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( K < 0 ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be a nonnegative integer. Value: `%d`.', K ) ); + } + if ( side === 'left' ) { + if ( LWORK < max( 1, N ) && LWORK !== -1 ) { + throw new RangeError( format( 'invalid argument. Twenty-first argument must be greater than or equal to `max(1, N)` when `SIDE = \'left\'`. Value: `%d`.', LWORK ) ); + } + } else if ( LWORK < max( 1, M ) && LWORK !== -1 ) { + throw new RangeError( format( 'invalid argument. Twenty-first argument must be greater than or equal to `max(1, M)` when `SIDE = \'right\'`. Value: `%d`.', LWORK ) ); + } + return base( vect, side, trans, M, N, K, A, strideA1, strideA2, offsetA, TAU, strideTAU, offsetTAU, C, strideC1, strideC2, offsetC, WORK, strideWORK, offsetWORK, LWORK ); +} + + +// EXPORTS // + +module.exports = dormbr; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/right_backward_columns.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/right_backward_columns.js new file mode 100644 index 000000000000..20f98fd01d52 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/right_backward_columns.js @@ -0,0 +1,158 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dgemm = require( '@stdlib/blas/base/dgemm' ).ndarray; +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var dtrmm = require( './dtrmm.js' ); + + +// MAIN // + +/** +* Applies a real block reflector H or its transpose H^T to a real M by N matrix C from the right, with backward direction and column storage. +* +* @private +* @param {NonNegativeInteger} M - number of rows of the matrix C +* @param {NonNegativeInteger} N - number of columns of the matrix C +* @param {NonNegativeInteger} K - order of the matrix T +* @param {Float64Array} V - input matrix +* @param {integer} strideV1 - stride of the first dimension of V +* @param {integer} strideV2 - stride of the second dimension of V +* @param {integer} offsetV - index offset for V +* @param {Float64Array} T - input matrix +* @param {integer} strideT1 - stride of the first dimension of T +* @param {integer} strideT2 - stride of the second dimension of T +* @param {integer} offsetT - index offset for T +* @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 {integer} offsetC - index offset for C +* @param {Float64Array} work - work array +* @param {integer} strideWork1 - stride of the first dimension of work +* @param {integer} strideWork2 - stride of the second dimension of work +* @param {integer} offsetWork - index offset for work +* @param {string} trans - specifies whether to apply H or H^T +* @returns {Float64Array} updated matrix C +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 10.0, 40.0, 70.0, 20.0, 50.0, 80.0, 30.0, 60.0, 90.0 ] ); +* var T = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var C = new Float64Array( [ 11.0, 12.0, 13.0, 21.0, 22.0, 23.0, 31.0, 32.0, 33.0 ] ); +* var work = new Float64Array( 9 ); +* +* var result = rightBackwardColumns( 3, 3, 3, V, 3, 1, 0, T, 3, 1, 0, C, 3, 1, 0, work, 3, 1, 0, 'no-transpose' ); +* // returns [ -402190.0, -419212.0, -5216.0, -752090.0, -782422.0, -9736.0, -1101990.0, -1145632.0, -14256.0 ] +*/ +function rightBackwardColumns( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ) { // eslint-disable-line max-params, max-len + var da0; + var da1; + var db0; + var db1; + var i0; + var i1; + var sh; + var sa; + var sb; + var S0; + var S1; + var ia; + var ib; + var ic; + var iv; + var iw; + var j; + var o; + + /* Let V = ( V1 ) + * ( V2 ) (last K rows) + * Where V2 is unit upper triangular. + */ + + /* Form C * H or C * H^T where C = ( C1 C2 ) + * W := C * V = (C1*V1 + C2*V2) (stored in WORK) + * W := C2 + */ + ic = offsetC + ( (N-K) * strideC2 ); + iw = offsetWork; + for ( j = 0; j < K; j++ ) { + dcopy( M, C, strideC1, ic, work, strideWork1, iw ); + ic += strideC2; + iw += strideWork2; + } + // W := W * V2 + iv = offsetV + ( (N-K) * strideV1 ); + dtrmm( 'right', 'upper', 'no-transpose', 'unit', M, K, 1.0, V, strideV1, strideV2, iv, work, strideWork1, strideWork2, offsetWork ); + if ( N > K ) { + // W := W + C1 * V1 + dgemm( 'no-transpose', 'no-transpose', M, K, N-K, 1.0, C, strideC1, strideC2, offsetC, V, strideV1, strideV2, offsetV, 1.0, work, strideWork1, strideWork2, offsetWork ); + } + // W := W * T or W * T**T + dtrmm( 'right', 'upper', trans, 'non-unit', M, K, 1.0, T, strideT1, strideT2, offsetT, work, strideWork1, strideWork2, offsetWork ); + + // C := C - W * V**T + if ( N > K ) { + // C1 := C1 - W * V1**T + dgemm( 'no-transpose', 'transpose', M, N-K, K, -1.0, work, strideWork1, strideWork2, offsetWork, V, strideV1, strideV2, offsetV, 1.0, C, strideC1, strideC2, offsetC ); + } + // W := W * V2**T + iv = offsetV + ( (N-K) * strideV1 ); + dtrmm( 'right', 'upper', 'transpose', 'unit', M, K, 1.0, V, strideV1, strideV2, iv, work, strideWork1, strideWork2, offsetWork ); + + // C2 := C2 - W + o = loopOrder( [ K, M ], [ strideC1, strideC2 ], [ strideWork1, strideWork2 ] ); // eslint-disable-line max-len + sh = o.sh; + sa = o.sx; + sb = o.sy; + + // Extract loop variables for loop interchange + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + da0 = sa[ 0 ]; + da1 = sa[ 1 ] - ( S0 * sa[ 0 ] ); + db0 = sb[ 0 ]; + db1 = sb[ 1 ] - ( S0 * sb[ 0 ] ); + + // Set pointers to first indexed elements + ia = offsetC + ( (N-K) * strideC2 ); + ib = offsetWork; + + // Iterate over matrix dimensions with optimized loop order + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + C[ ia ] -= work[ ib ]; + ia += da0; + ib += db0; + } + ia += da1; + ib += db1; + } + + return C; +} + + +// EXPORTS // + +module.exports = rightBackwardColumns; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/right_backward_rows.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/right_backward_rows.js new file mode 100644 index 000000000000..e10b8b011af6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/right_backward_rows.js @@ -0,0 +1,157 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dgemm = require( '@stdlib/blas/base/dgemm' ).ndarray; +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var dtrmm = require( './dtrmm.js' ); + + +// MAIN // + +/** +* Applies a real block reflector H or its transpose H^T to a real M by N matrix C from the right, with backward direction and row storage. +* +* @private +* @param {NonNegativeInteger} M - number of rows of the matrix C +* @param {NonNegativeInteger} N - number of columns of the matrix C +* @param {NonNegativeInteger} K - order of the matrix T +* @param {Float64Array} V - input matrix +* @param {integer} strideV1 - stride of the first dimension of V +* @param {integer} strideV2 - stride of the second dimension of V +* @param {integer} offsetV - index offset for V +* @param {Float64Array} T - input matrix +* @param {integer} strideT1 - stride of the first dimension of T +* @param {integer} strideT2 - stride of the second dimension of T +* @param {integer} offsetT - index offset for T +* @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 {integer} offsetC - index offset for C +* @param {Float64Array} work - work array +* @param {integer} strideWork1 - stride of the first dimension of work +* @param {integer} strideWork2 - stride of the second dimension of work +* @param {integer} offsetWork - index offset for work +* @param {string} trans - specifies whether to apply H or H^T +* @returns {Float64Array} updated matrix C +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 10.0, 40.0, 70.0, 20.0, 50.0, 80.0, 30.0, 60.0, 90.0 ] ); +* var T = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var C = new Float64Array( [ 11.0, 12.0, 13.0, 21.0, 22.0, 23.0, 31.0, 32.0, 33.0 ] ); +* var work = new Float64Array( 9 ); +* +* var result = rightBackwardRows( 3, 3, 3, V, 3, 1, 0, T, 3, 1, 0, C, 3, 1, 0, work, 3, 1, 0, 'no-transpose' ); +* // returns [ -104950.0, -191792.0, -3176.0, -195250.0, -356002.0, -5896.0, -285550.0, -520212.0, -8616.0 ] +*/ +function rightBackwardRows( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ) { // eslint-disable-line max-params, max-len + var da0; + var da1; + var db0; + var db1; + var i0; + var i1; + var sh; + var sa; + var sb; + var S0; + var S1; + var ia; + var ib; + var ic; + var iv; + var iw; + var j; + var o; + + /* Let V = ( V1 V2 ) (V2: last K columns) + * Where V2 is unit lower triangular. + */ + + /* Form C * H or C * H^T where C = ( C1 C2 ) + * W := C * V**T = (C1*V1**T + C2*V2**T) (stored in WORK) + * W := C2 + */ + ic = offsetC + ( (N-K) * strideC2 ); + iw = offsetWork; + for ( j = 0; j < K; j++ ) { + dcopy( M, C, strideC1, ic, work, strideWork1, iw ); + iw += strideWork2; + ic += strideC2; + } + // W := W * V2**T + iv = offsetV + ( (N-K) * strideV2 ); + dtrmm( 'right', 'lower', 'transpose', 'unit', M, K, 1.0, V, strideV1, strideV2, iv, work, strideWork1, strideWork2, offsetWork ); + if ( N > K ) { + // W := W + C1 * V1**T + dgemm( 'no-transpose', 'transpose', M, K, N-K, 1.0, C, strideC1, strideC2, offsetC, V, strideV1, strideV2, offsetV, 1.0, work, strideWork1, strideWork2, offsetWork ); + } + // W := W * T or W * T**T + dtrmm( 'right', 'lower', trans, 'non-unit', M, K, 1.0, T, strideT1, strideT2, offsetT, work, strideWork1, strideWork2, offsetWork ); + + // C := C - W * V + if ( N > K ) { + // C1 := C1 - W * V1 + dgemm( 'no-transpose', 'no-transpose', M, N-K, K, -1.0, work, strideWork1, strideWork2, offsetWork, V, strideV1, strideV2, offsetV, 1.0, C, strideC1, strideC2, offsetC ); + } + // W := W * V2 + iv = offsetV + ( (N-K) * strideV2 ); + dtrmm( 'right', 'lower', 'no-transpose', 'unit', M, K, 1.0, V, strideV1, strideV2, iv, work, strideWork1, strideWork2, offsetWork ); + + // C1 := C1 - W + o = loopOrder( [ K, M ], [ strideC1, strideC2 ], [ strideWork1, strideWork2 ] ); // eslint-disable-line max-len + sh = o.sh; + sa = o.sx; + sb = o.sy; + + // Extract loop variables for loop interchange + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + da0 = sa[ 0 ]; + da1 = sa[ 1 ] - ( S0 * sa[ 0 ] ); + db0 = sb[ 0 ]; + db1 = sb[ 1 ] - ( S0 * sb[ 0 ] ); + + // Set pointers to first indexed elements + ia = offsetC; + ib = offsetWork; + + // Iterate over matrix dimensions with optimized loop order + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + C[ ia ] -= work[ ib ]; + ia += da0; + ib += db0; + } + ia += da1; + ib += db1; + } + + return C; +} + + +// EXPORTS // + +module.exports = rightBackwardRows; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/right_forward_columns.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/right_forward_columns.js new file mode 100644 index 000000000000..0c7574a3b7b9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/right_forward_columns.js @@ -0,0 +1,160 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dgemm = require( '@stdlib/blas/base/dgemm' ).ndarray; +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var dtrmm = require( './dtrmm.js' ); + + +// MAIN // + +/** +* Applies a real block reflector H or its transpose H^T to a real M by N matrix C from the right, with forward direction and column storage. +* +* @private +* @param {NonNegativeInteger} M - number of rows of the matrix C +* @param {NonNegativeInteger} N - number of columns of the matrix C +* @param {NonNegativeInteger} K - order of the matrix T +* @param {Float64Array} V - input matrix +* @param {integer} strideV1 - stride of the first dimension of V +* @param {integer} strideV2 - stride of the second dimension of V +* @param {integer} offsetV - index offset for V +* @param {Float64Array} T - input matrix +* @param {integer} strideT1 - stride of the first dimension of T +* @param {integer} strideT2 - stride of the second dimension of T +* @param {integer} offsetT - index offset for T +* @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 {integer} offsetC - index offset for C +* @param {Float64Array} work - work array +* @param {integer} strideWork1 - stride of the first dimension of work +* @param {integer} strideWork2 - stride of the second dimension of work +* @param {integer} offsetWork - index offset for work +* @param {string} trans - specifies whether to apply H or H^T +* @returns {Float64Array} updated matrix C +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 10.0, 40.0, 70.0, 20.0, 50.0, 80.0, 30.0, 60.0, 90.0 ] ); +* var T = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var C = new Float64Array( [ 11.0, 12.0, 13.0, 21.0, 22.0, 23.0, 31.0, 32.0, 33.0 ] ); +* var work = new Float64Array( 9 ); +* +* var result = rightForwardColumns( 3, 3, 3, V, 3, 1, 0, T, 3, 1, 0, C, 3, 1, 0, work, 3, 1, 0, 'no-transpose' ); +* // returns [ -630.0, -14392.0, -114296.0, -1130.0, -25802.0, -202816.0, -1630.0, -37212.0, -291336.0 ] +*/ +function rightForwardColumns( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ) { // eslint-disable-line max-params, max-len + var da0; + var da1; + var db0; + var db1; + var i0; + var i1; + var sh; + var sa; + var sb; + var S0; + var S1; + var ia; + var ib; + var ic; + var iv; + var iw; + var j; + var o; + + /* Let V = ( V1 ) (first K rows) + * ( V2 ) + * Where V1 is unit lower triangular. + */ + + /* Form C * H or C * H^T where C = ( C1 C2 ) + * W := C * V = (C1*V1 + C2*V2) (stored in WORK) + * W := C1 + */ + ic = offsetC; + iw = offsetWork; + for ( j = 0; j < K; j++ ) { + dcopy( M, C, strideC1, ic, work, strideWork1, iw ); + ic += strideC2; + iw += strideWork2; + } + // W := W * V1 + dtrmm( 'right', 'lower', 'no-transpose', 'unit', M, K, 1.0, V, strideV1, strideV2, offsetV, work, strideWork1, strideWork2, offsetWork ); + if ( N > K ) { + // W := W + C2 * V2 + ic = offsetC + ( K * strideC2 ); + iv = offsetV + ( K * strideV1 ); + dgemm( 'no-transpose', 'no-transpose', M, K, N-K, 1.0, C, strideC1, strideC2, ic, V, strideV1, strideV2, iv, 1.0, work, strideWork1, strideWork2, offsetWork ); + } + // W := W * T or W * T**T + dtrmm( 'right', 'upper', trans, 'non-unit', M, K, 1.0, T, strideT1, strideT2, offsetT, work, strideWork1, strideWork2, offsetWork ); + + // C := C - W * V**T + if ( N > K ) { + // C2 := C2 - W * V2**T + ic = offsetC + ( K * strideC2 ); + iv = offsetV + ( K * strideV1 ); + dgemm( 'no-transpose', 'transpose', M, N-K, K, -1.0, work, strideWork1, strideWork2, offsetWork, V, strideV1, strideV2, iv, 1.0, C, strideC1, strideC2, ic ); + } + // W := W * V1**T + dtrmm( 'right', 'lower', 'transpose', 'unit', M, K, 1.0, V, strideV1, strideV2, offsetV, work, strideWork1, strideWork2, offsetWork ); + + // C1 := C1 - W + o = loopOrder( [ K, M ], [ strideC2, strideC1 ], [ strideWork2, strideWork1 ] ); // eslint-disable-line max-len + sh = o.sh; + sa = o.sx; + sb = o.sy; + + // Extract loop variables for loop interchange + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + da0 = sa[ 0 ]; + da1 = sa[ 1 ] - ( S0 * sa[ 0 ] ); + db0 = sb[ 0 ]; + db1 = sb[ 1 ] - ( S0 * sb[ 0 ] ); + + // Set pointers to first indexed elements + ia = offsetC; + ib = offsetWork; + + // Iterate over matrix dimensions with optimized loop order + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + C[ ia ] -= work[ ib ]; + ia += da0; + ib += db0; + } + ia += da1; + ib += db1; + } + + return C; +} + + +// EXPORTS // + +module.exports = rightForwardColumns; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/lib/right_forward_rows.js b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/right_forward_rows.js new file mode 100644 index 000000000000..830e208c4700 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/lib/right_forward_rows.js @@ -0,0 +1,159 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dgemm = require( '@stdlib/blas/base/dgemm' ).ndarray; +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var dtrmm = require( './dtrmm.js' ); + + +// MAIN // + +/** +* Applies a real block reflector H or its transpose H^T to a real M by N matrix C from the right, with forward direction and row storage. +* +* @private +* @param {NonNegativeInteger} M - number of rows of the matrix C +* @param {NonNegativeInteger} N - number of columns of the matrix C +* @param {NonNegativeInteger} K - order of the matrix T +* @param {Float64Array} V - input matrix +* @param {integer} strideV1 - stride of the first dimension of V +* @param {integer} strideV2 - stride of the second dimension of V +* @param {integer} offsetV - index offset for V +* @param {Float64Array} T - input matrix +* @param {integer} strideT1 - stride of the first dimension of T +* @param {integer} strideT2 - stride of the second dimension of T +* @param {integer} offsetT - index offset for T +* @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 {integer} offsetC - index offset for C +* @param {Float64Array} work - work array +* @param {integer} strideWork1 - stride of the first dimension of work +* @param {integer} strideWork2 - stride of the second dimension of work +* @param {integer} offsetWork - index offset for work +* @param {string} trans - specifies whether to apply H or H^T +* @returns {Float64Array} updated matrix C +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 10.0, 40.0, 70.0, 20.0, 50.0, 80.0, 30.0, 60.0, 90.0 ] ); +* var T = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var C = new Float64Array( [ 11.0, 12.0, 13.0, 21.0, 22.0, 23.0, 31.0, 32.0, 33.0 ] ); +* var work = new Float64Array( 9 ); +* +* var result = rightForwardRows( 3, 3, 3, V, 3, 1, 0, T, 3, 1, 0, C, 3, 1, 0, work, 3, 1, 0, 'no-transpose' ); +* // returns [ -1390.0, -58132.0, -266416.0, -2490.0, -104142.0, -473736.0, -3590.0, -150152.0, -681056.0 ] +*/ +function rightForwardRows( M, N, K, V, strideV1, strideV2, offsetV, T, strideT1, strideT2, offsetT, C, strideC1, strideC2, offsetC, work, strideWork1, strideWork2, offsetWork, trans ) { // eslint-disable-line max-params, max-len + var da0; + var da1; + var db0; + var db1; + var i0; + var i1; + var sh; + var sa; + var sb; + var S0; + var S1; + var ia; + var ib; + var ic; + var iv; + var iw; + var j; + var o; + + /* Let V = ( V1 V2 ) (V1: first K columns) + * Where V1 is unit upper triangular. + */ + + /* Form C * H or C * H^T where C = ( C1 C2 ) + * W := C * V**T = (C1*V1**T + C2*V2**T) (stored in WORK) + * W := C1 + */ + ic = offsetC; + iw = offsetWork; + for ( j = 0; j < K; j++ ) { + dcopy( M, C, strideC1, ic, work, strideWork1, iw ); + ic += strideC2; + iw += strideWork2; + } + // W := W * V1**T + dtrmm( 'right', 'upper', 'transpose', 'unit', M, K, 1.0, V, strideV1, strideV2, offsetV, work, strideWork1, strideWork2, offsetWork ); + if ( N > K ) { + // W := W + C2 * V2**T + ic = offsetC + ( K * strideC2 ); + iv = offsetV + ( K * strideV2 ); + dgemm( 'no-transpose', 'transpose', M, K, N-K, 1.0, C, strideC1, strideC2, ic, V, strideV1, strideV2, iv, 1.0, work, strideWork1, strideWork2, offsetWork ); + } + // W := W * T or W * T**T + dtrmm( 'right', 'upper', trans, 'non-unit', M, K, 1.0, T, strideT1, strideT2, offsetT, work, strideWork1, strideWork2, offsetWork ); + + // C := C - W * V + if ( N > K ) { + // C2 := C2 - W * V2 + ic = offsetC + ( K * strideC2 ); + iv = offsetV + ( K * strideV2 ); + dgemm( 'no-transpose', 'no-transpose', M, N-K, K, -1.0, work, strideWork1, strideWork2, offsetWork, V, strideV1, strideV2, iv, 1.0, C, strideC1, strideC2, ic ); + } + // W := W * V1 + dtrmm( 'right', 'upper', 'no-transpose', 'unit', M, K, 1.0, V, strideV1, strideV2, offsetV, work, strideWork1, strideWork2, offsetWork ); + + // C1 := C1 - W + o = loopOrder( [ K, M ], [ strideC1, strideC2 ], [ strideWork1, strideWork2 ] ); // eslint-disable-line max-len + sh = o.sh; + sa = o.sx; + sb = o.sy; + + // Extract loop variables for loop interchange + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + da0 = sa[ 0 ]; + da1 = sa[ 1 ] - ( S0 * sa[ 0 ] ); + db0 = sb[ 0 ]; + db1 = sb[ 1 ] - ( S0 * sb[ 0 ] ); + + // Set pointers to first indexed elements + ia = offsetC; + ib = offsetWork; + + // Iterate over matrix dimensions with optimized loop order + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + C[ ia ] -= work[ ib ]; + ia += da0; + ib += db0; + } + ia += da1; + ib += db1; + } + + return C; +} + + +// EXPORTS // + +module.exports = rightForwardRows; diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/package.json b/lib/node_modules/@stdlib/lapack/base/dormbr/package.json new file mode 100644 index 000000000000..b808cc921c9d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dormbr", + "version": "0.0.0", + "description": "LAPACK routine to multiply a general matrix by the orthogonal matrix from a bi-diagonal reduction determined by `DGEBRD`.", + "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", + "dormbr", + "reflector", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/p_nq_gt_k_left.json b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/p_nq_gt_k_left.json new file mode 100644 index 000000000000..845d3deeebf7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/p_nq_gt_k_left.json @@ -0,0 +1,150 @@ +{ + "order": "column-major", + "vect": "P", + "side": "left", + "trans": "no-transpose", + "M": 4, + "N": 3, + "K": 3, + "LDA": 4, + "LDC": 4, + "LWORK": 3, + "A": [ + 1, + 0, + 0, + -0.125, + 0.5, + 1, + 0, + 0.25, + 0.25, + 0.5, + 1, + 0.5, + 0, + 0, + 0, + 0 + ], + "TAU": [ + 1.5, + 0.75, + 0 + ], + "C": [ + 4, + 5, + 6, + 7, + 7, + 8, + 9, + 10, + 10, + 11, + 12, + 13 + ], + "WORK": [ + 0, + 0, + 0 + ], + "info": 0, + "strideA1": 1, + "strideA2": 4, + "offsetA": 0, + "strideTAU": 1, + "offsetTAU": 0, + "strideC1": 1, + "strideC2": 4, + "offsetC": 0, + "strideWORK": 1, + "offsetWORK": 0, + "A_mat": [ + [ + 1, + 0.5, + 0.25 + ], + [ + 0, + 1, + 0.5 + ], + [ + 0, + 0, + 1 + ], + [ + -0.125, + 0.25, + 0.5 + ] + ], + "C_mat": [ + [ + 4, + 7, + 10 + ], + [ + 5, + 8, + 11 + ], + [ + 6, + 9, + 12 + ], + [ + 7, + 10, + 13 + ] + ], + "C_out_mat": [ + [ + -2.375, + -4.0859375, + -5.796875 + ], + [ + -4.1875, + -6.91796875, + -9.6484375 + ], + [ + 1.40625, + 1.541015625, + 1.67578125 + ], + [ + 7, + 10, + 13 + ] + ], + "C_out": [ + -2.375, + -4.1875, + 1.40625, + 7, + -4.0859375, + -6.91796875, + 1.541015625, + 10, + -5.796875, + -9.6484375, + 1.67578125, + 13 + ], + "WORK_out": [ + 96, + 7.390625, + 10.53125 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/p_nq_gt_k_left_transpose.json b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/p_nq_gt_k_left_transpose.json new file mode 100644 index 000000000000..44db10ecc613 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/p_nq_gt_k_left_transpose.json @@ -0,0 +1,150 @@ +{ + "order": "column-major", + "vect": "P", + "side": "left", + "trans": "transpose", + "M": 4, + "N": 3, + "K": 3, + "LDA": 4, + "LDC": 4, + "LWORK": 3, + "A": [ + 1, + 0, + 0, + -0.125, + 0.5, + 1, + 0, + 0.25, + 0.25, + 0.5, + 1, + 0.5, + 0, + 0, + 0, + 0 + ], + "TAU": [ + 1.5, + 0.75, + 0 + ], + "C": [ + 4, + 5, + 6, + 7, + 7, + 8, + 9, + 10, + 10, + 11, + 12, + 13 + ], + "WORK": [ + 0, + 0, + 0 + ], + "info": 0, + "strideA1": 1, + "strideA2": 4, + "offsetA": 0, + "strideTAU": 1, + "offsetTAU": 0, + "strideC1": 1, + "strideC2": 4, + "offsetC": 0, + "strideWORK": 1, + "offsetWORK": 0, + "A_mat": [ + [ + 1, + 0.5, + 0.25 + ], + [ + 0, + 1, + 0.5 + ], + [ + 0, + 0, + 1 + ], + [ + -0.125, + 0.25, + 0.5 + ] + ], + "C_mat": [ + [ + 4, + 7, + 10 + ], + [ + 5, + 8, + 11 + ], + [ + 6, + 9, + 12 + ], + [ + 7, + 10, + 13 + ] + ], + "C_out_mat": [ + [ + -8, + -12.875, + -17.75 + ], + [ + -1.375, + -1.99609375, + -2.6171875 + ], + [ + 2.8125, + 4.001953125, + 5.19140625 + ], + [ + 7, + 10, + 13 + ] + ], + "C_out": [ + -8, + -1.375, + 2.8125, + 7, + -12.875, + -1.99609375, + 4.001953125, + 10, + -17.75, + -2.6171875, + 5.19140625, + 13 + ], + "WORK_out": [ + 96, + 0.078125, + -0.34375 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/p_nq_le_k_left.json b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/p_nq_le_k_left.json new file mode 100644 index 000000000000..063c27e9d55a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/p_nq_le_k_left.json @@ -0,0 +1,122 @@ +{ + "order": "column-major", + "vect": "P", + "side": "left", + "trans": "no-transpose", + "M": 3, + "N": 3, + "K": 3, + "LDA": 3, + "LDC": 3, + "LWORK": 3, + "A": [ + 1, + 0, + -0.125, + 0.5, + 1, + 0.25, + 0.25, + 0.5, + 1 + ], + "TAU": [ + 1.5, + 0.75, + 1.25 + ], + "C": [ + -1, + 0, + 1, + -3, + -2, + -1, + -5, + -4, + -3 + ], + "WORK": [ + 0, + 0, + 0 + ], + "info": 0, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "strideTAU": 1, + "offsetTAU": 0, + "strideC1": 1, + "strideC2": 3, + "offsetC": 0, + "strideWORK": 1, + "offsetWORK": 0, + "A_mat": [ + [ + 1, + 0.5, + 0.25 + ], + [ + 0, + 1, + 0.5 + ], + [ + -0.125, + 0.25, + 1 + ] + ], + "C_mat": [ + [ + -1, + -3, + -5 + ], + [ + 0, + -2, + -4 + ], + [ + 1, + -1, + -3 + ] + ], + "C_out_mat": [ + [ + -1, + -3, + -5 + ], + [ + -0.09375, + 1.09375, + 2.28125 + ], + [ + 0.2265625, + 0.5234375, + 0.8203125 + ] + ], + "C_out": [ + -1, + -0.09375, + 0.2265625, + -3, + 1.09375, + 0.5234375, + -5, + 2.28125, + 0.8203125 + ], + "WORK_out": [ + 96, + -2.0625, + -4.1875 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/p_nq_le_k_right.json b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/p_nq_le_k_right.json new file mode 100644 index 000000000000..f505da53f01b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/p_nq_le_k_right.json @@ -0,0 +1,122 @@ +{ + "order": "column-major", + "vect": "P", + "side": "right", + "trans": "transpose", + "M": 3, + "N": 3, + "K": 3, + "LDA": 3, + "LDC": 3, + "LWORK": 3, + "A": [ + 1, + 0, + -0.125, + 0.5, + 1, + 0.25, + 0.25, + 0.5, + 1 + ], + "TAU": [ + 1.5, + 0.75, + 1.25 + ], + "C": [ + 3, + 5, + 7, + 4, + 6, + 8, + 5, + 7, + 9 + ], + "WORK": [ + 0, + 0, + 0 + ], + "info": 0, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "strideTAU": 1, + "offsetTAU": 0, + "strideC1": 1, + "strideC2": 3, + "offsetC": 0, + "strideWORK": 1, + "offsetWORK": 0, + "A_mat": [ + [ + 1, + 0.5, + 0.25 + ], + [ + 0, + 1, + 0.5 + ], + [ + -0.125, + 0.25, + 1 + ] + ], + "C_mat": [ + [ + 3, + 4, + 5 + ], + [ + 5, + 6, + 7 + ], + [ + 7, + 8, + 9 + ] + ], + "C_out_mat": [ + [ + 3, + -2.46875, + -0.3671875 + ], + [ + 5, + -3.65625, + -0.6640625 + ], + [ + 7, + -4.84375, + -0.9609375 + ] + ], + "C_out": [ + 3, + 5, + 7, + -2.46875, + -3.65625, + -4.84375, + -0.3671875, + -0.6640625, + -0.9609375 + ], + "WORK_out": [ + 96, + 6.4375, + 8.5625 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/q_nq_ge_k_left.json b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/q_nq_ge_k_left.json new file mode 100644 index 000000000000..e8f903c6e55b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/q_nq_ge_k_left.json @@ -0,0 +1,146 @@ +{ + "order": "column-major", + "vect": "Q", + "side": "left", + "trans": "no-transpose", + "M": 4, + "N": 3, + "K": 3, + "LDA": 4, + "LDC": 4, + "LWORK": 3, + "A": [ + 1, + 0.5, + 0.25, + -0.125, + 0, + 1, + 0.5, + 0.25, + 0, + 0, + 1, + 0.5 + ], + "TAU": [ + 1.5, + 0.75, + 1.25 + ], + "C": [ + 2, + 3, + 4, + 5, + 3, + 4, + 5, + 6, + 4, + 5, + 6, + 7 + ], + "WORK": [ + 0, + 0, + 0 + ], + "info": 0, + "strideA1": 1, + "strideA2": 4, + "offsetA": 0, + "strideTAU": 1, + "offsetTAU": 0, + "strideC1": 1, + "strideC2": 4, + "offsetC": 0, + "strideWORK": 1, + "offsetWORK": 0, + "A_mat": [ + [ + 1, + 0, + 0 + ], + [ + 0.5, + 1, + 0 + ], + [ + 0.25, + 0.5, + 1 + ], + [ + -0.125, + 0.25, + 0.5 + ] + ], + "C_mat": [ + [ + 2, + 3, + 4 + ], + [ + 3, + 4, + 5 + ], + [ + 4, + 5, + 6 + ], + [ + 5, + 6, + 7 + ] + ], + "C_out_mat": [ + [ + -0.74456787109375, + -1.2685546875, + -1.79254150390625 + ], + [ + 0.748809814453125, + 0.55322265625, + 0.357635498046875 + ], + [ + -5.2505950927734375, + -6.723388671875, + -8.196182250976562 + ], + [ + 1.0608444213867188, + 1.2054443359375, + 1.3500442504882812 + ] + ], + "C_out": [ + -0.74456787109375, + 0.748809814453125, + -5.2505950927734375, + 1.0608444213867188, + -1.2685546875, + 0.55322265625, + -6.723388671875, + 1.2054443359375, + -1.79254150390625, + 0.357635498046875, + -8.196182250976562, + 1.3500442504882812 + ], + "WORK_out": [ + 96, + 2.845703125, + 3.8616943359375 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/q_nq_lt_k_left.json b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/q_nq_lt_k_left.json new file mode 100644 index 000000000000..018a7a9b3b1f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/q_nq_lt_k_left.json @@ -0,0 +1,129 @@ +{ + "order": "column-major", + "vect": "Q", + "side": "left", + "trans": "no-transpose", + "M": 3, + "N": 3, + "K": 4, + "LDA": 3, + "LDC": 3, + "LWORK": 3, + "A": [ + 1, + 0.5, + 0.25, + 0, + 1, + 0.5, + 0, + 0, + 1, + 0.25, + 0.5, + -0.125 + ], + "TAU": [ + 1.5, + 0.75, + 1.25, + 0.5 + ], + "C": [ + 3, + 4, + 5, + 5, + 6, + 7, + 7, + 8, + 9 + ], + "WORK": [ + 0, + 0, + 0 + ], + "info": 0, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "strideTAU": 1, + "offsetTAU": 0, + "strideC1": 1, + "strideC2": 3, + "offsetC": 0, + "strideWORK": 1, + "offsetWORK": 0, + "A_mat": [ + [ + 1, + 0, + 0, + 0.25 + ], + [ + 0.5, + 1, + 0, + 0.5 + ], + [ + 0.25, + 0.5, + 1, + -0.125 + ] + ], + "C_mat": [ + [ + 3, + 5, + 7 + ], + [ + 4, + 6, + 8 + ], + [ + 5, + 7, + 9 + ] + ], + "C_out_mat": [ + [ + 3, + 5, + 7 + ], + [ + -2.46875, + -3.65625, + -4.84375 + ], + [ + -0.3671875, + -0.6640625, + -0.9609375 + ] + ], + "C_out": [ + 3, + -2.46875, + -0.3671875, + 5, + -3.65625, + -0.6640625, + 7, + -4.84375, + -0.9609375 + ], + "WORK_out": [ + 96, + 6.4375, + 8.5625 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/q_nq_lt_k_right.json b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/q_nq_lt_k_right.json new file mode 100644 index 000000000000..038761fb3194 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/test/fixtures/q_nq_lt_k_right.json @@ -0,0 +1,129 @@ +{ + "order": "column-major", + "vect": "Q", + "side": "right", + "trans": "transpose", + "M": 3, + "N": 3, + "K": 4, + "LDA": 3, + "LDC": 3, + "LWORK": 3, + "A": [ + 1, + 0.5, + 0.25, + 0, + 1, + 0.5, + 0, + 0, + 1, + 0.25, + 0.5, + -0.125 + ], + "TAU": [ + 1.5, + 0.75, + 1.25, + 0.5 + ], + "C": [ + 0, + 1, + 2, + -1, + 0, + 1, + -2, + -1, + 0 + ], + "WORK": [ + 0, + 0, + 0 + ], + "info": 0, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "strideTAU": 1, + "offsetTAU": 0, + "strideC1": 1, + "strideC2": 3, + "offsetC": 0, + "strideWORK": 1, + "offsetWORK": 0, + "A_mat": [ + [ + 1, + 0, + 0, + 0.25 + ], + [ + 0.5, + 1, + 0, + 0.5 + ], + [ + 0.25, + 0.5, + 1, + -0.125 + ] + ], + "C_mat": [ + [ + 0, + -1, + -2 + ], + [ + 1, + 0, + -1 + ], + [ + 2, + 1, + 0 + ] + ], + "C_out_mat": [ + [ + 0, + 0.6875, + -0.078125 + ], + [ + 1, + 0.09375, + -0.2265625 + ], + [ + 2, + -0.5, + -0.375 + ] + ], + "C_out": [ + 0, + 1, + 2, + 0.6875, + 0.09375, + -0.5, + -0.078125, + -0.2265625, + -0.375 + ], + "WORK_out": [ + 96, + -0.0625, + 1 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/test/test.dormbr.js b/lib/node_modules/@stdlib/lapack/base/dormbr/test/test.dormbr.js new file mode 100644 index 000000000000..421955d6666e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/test/test.dormbr.js @@ -0,0 +1,881 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isAlmostEqual = require( '@stdlib/assert/is-almost-equal-float64array' ); +var dormbr = require( './../lib/dormbr.js' ); + + +// FIXTURES // + +var Q_NQ_GE_K_LEFT = require( './fixtures/q_nq_ge_k_left.json' ); +var Q_NQ_LT_K_LEFT = require( './fixtures/q_nq_lt_k_left.json' ); +var Q_NQ_LT_K_RIGHT = require( './fixtures/q_nq_lt_k_right.json' ); +var P_NQ_GT_K_LEFT = require( './fixtures/p_nq_gt_k_left.json' ); +var P_NQ_GT_K_LEFT_TRANSPOSE = require( './fixtures/p_nq_gt_k_left_transpose.json' ); +var P_NQ_LE_K_LEFT = require( './fixtures/p_nq_le_k_left.json' ); +var P_NQ_LE_K_RIGHT = require( './fixtures/p_nq_le_k_right.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dormbr, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 14', function test( t ) { + t.strictEqual( dormbr.length, 14, '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 C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dormbr( value, 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not a valid vector', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + 'q', + 'p', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dormbr( 'row-major', value, 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a third argument which is not a valid operation side', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dormbr( 'row-major', 'Q', value, 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a fourth argument which is not a valid transpose operation', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dormbr( 'row-major', 'Q', 'left', value, 2, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a fifth argument which is smaller than 0', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + -1, + -2, + -3 + ]; + + 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() { + dormbr( 'row-major', 'Q', 'left', 'no-transpose', value, 3, 1, A, 2, TAU, C, 3, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is smaller than 0', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + -1, + -2, + -3 + ]; + + 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() { + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, value, 1, A, 2, TAU, C, 3, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a seventh argument which is smaller than 0', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + -1, + -2, + -3 + ]; + + 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() { + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, value, A, 2, TAU, C, 3, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a ninth argument which is not a valid LDA value (column-major, Q, left)', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + 1, + 0, + -1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dormbr( 'column-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, value, TAU, C, 3, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a ninth argument which is not a valid LDA value (column-major, Q, right)', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + 2, + 1, + 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() { + dormbr( 'column-major', 'Q', 'right', 'no-transpose', 2, 3, 1, A, value, TAU, C, 3, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a ninth argument which is not a valid LDA value (column-major, P)', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + 0, + -1, + -2 + ]; + + 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() { + dormbr( 'column-major', 'P', 'left', 'no-transpose', 2, 3, 1, A, value, TAU, C, 3, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a ninth argument which is not a valid LDA value (row-major)', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + 0, + -1, + -2 + ]; + + 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() { + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, value, TAU, C, 3, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a twelfth argument which is not a valid LDC value (column-major)', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + 1, + 0, + -1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dormbr( 'column-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, value, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a twelfth argument which is not a valid LDC value (row-major)', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + 2, + 1, + 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() { + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, value, WORK, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided a fourteenth argument which is not a valid LWORK value (left)', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + 2, + 1, + 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() { + dormbr( 'row-major', 'Q', 'left', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, value ); + }; + } +}); + +tape( 'the function throws an error if provided a fourteenth argument which is not a valid LWORK value (right)', function test( t ) { + var values; + var WORK; + var TAU; + var A; + var C; + var i; + + A = new Float64Array( [ 1, 0, 0 ] ); + TAU = new Float64Array( [ 2 ] ); + C = new Float64Array( [ 1, 3, 5, 2, 4, 6 ] ); + WORK = new Float64Array( 3 ); + + values = [ + 1, + 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() { + dormbr( 'row-major', 'Q', 'right', 'no-transpose', 2, 3, 1, A, 2, TAU, C, 3, WORK, value ); + }; + } +}); + +tape( 'the function quick returns when `LWORK` is equal to -1', function test( t ) { + var expectedWORK; + var expectedA; + var expectedC; + var info; + var data; + var WORK; + var TAU; + var A; + var C; + + data = Q_NQ_GE_K_LEFT; + + A = new Float64Array( data.A ); + TAU = new Float64Array( data.TAU ); + C = new Float64Array( data.C ); + WORK = new Float64Array( data.WORK ); + + expectedA = new Float64Array( data.A ); + expectedC = new Float64Array( data.C ); + expectedWORK = new Float64Array( data.WORK ); + expectedWORK[ 0 ] = 96; + + info = dormbr( data.order, data.vect, data.side, data.trans, data.M, data.N, data.K, A, data.LDA, TAU, C, data.LDC, WORK, -1 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.strictEqual( isAlmostEqual( A, expectedA, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( C, expectedC, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( WORK, expectedWORK, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function quick returns when `M` is equal to 0', function test( t ) { + var expectedWORK; + var expectedC; + var info; + var data; + var WORK; + var TAU; + var A; + var C; + + data = Q_NQ_GE_K_LEFT; + + A = new Float64Array( data.A ); + TAU = new Float64Array( data.TAU ); + C = new Float64Array( data.C ); + WORK = new Float64Array( data.WORK ); + + expectedC = new Float64Array( data.C ); + expectedWORK = new Float64Array( data.WORK ); + expectedWORK[ 0 ] = 1; + + info = dormbr( data.order, data.vect, data.side, data.trans, 0, data.N, data.K, A, data.LDA, TAU, C, data.LDC, WORK, data.LWORK ); + t.strictEqual( info, 0, 'returns expected value' ); + t.strictEqual( isAlmostEqual( C, expectedC, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( WORK, expectedWORK, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function quick returns when `N` is equal to 0', function test( t ) { + var expectedWORK; + var expectedC; + var info; + var data; + var WORK; + var TAU; + var A; + var C; + + data = Q_NQ_GE_K_LEFT; + + A = new Float64Array( data.A ); + TAU = new Float64Array( data.TAU ); + C = new Float64Array( data.C ); + WORK = new Float64Array( data.WORK ); + + expectedC = new Float64Array( data.C ); + expectedWORK = new Float64Array( data.WORK ); + expectedWORK[ 0 ] = 1; + + info = dormbr( data.order, data.vect, data.side, data.trans, data.M, 0, data.K, A, data.LDA, TAU, C, data.LDC, WORK, data.LWORK ); + t.strictEqual( info, 0, 'returns expected value' ); + t.strictEqual( isAlmostEqual( C, expectedC, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( WORK, expectedWORK, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function multiplies a general matrix by the orthogonal matrix `Q` (nq >= K, left)', function test( t ) { + var expectedWORK; + var expectedC; + var info; + var data; + var WORK; + var TAU; + var A; + var C; + + data = Q_NQ_GE_K_LEFT; + + A = new Float64Array( data.A ); + TAU = new Float64Array( data.TAU ); + C = new Float64Array( data.C ); + WORK = new Float64Array( data.WORK ); + + expectedC = new Float64Array( data.C_out ); + expectedWORK = new Float64Array( data.WORK_out ); + + info = dormbr( data.order, data.vect, data.side, data.trans, data.M, data.N, data.K, A, data.LDA, TAU, C, data.LDC, WORK, data.LWORK ); + t.strictEqual( info, 0, 'returns expected value' ); + t.strictEqual( isAlmostEqual( C, expectedC, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( WORK, expectedWORK, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function multiplies a general matrix by the orthogonal matrix `P^T` (nq > K, left)', function test( t ) { + var expectedWORK; + var expectedC; + var info; + var data; + var WORK; + var TAU; + var A; + var C; + + data = P_NQ_GT_K_LEFT; + + A = new Float64Array( data.A ); + TAU = new Float64Array( data.TAU ); + C = new Float64Array( data.C ); + WORK = new Float64Array( data.WORK ); + + expectedC = new Float64Array( data.C_out ); + expectedWORK = new Float64Array( data.WORK_out ); + + info = dormbr( data.order, data.vect, data.side, data.trans, data.M, data.N, data.K, A, data.LDA, TAU, C, data.LDC, WORK, data.LWORK ); + t.strictEqual( info, 0, 'returns expected value' ); + t.strictEqual( isAlmostEqual( C, expectedC, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( WORK, expectedWORK, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function multiplies a general matrix by the orthogonal matrix `P^T` (nq > K, left, transpose)', function test( t ) { + var expectedWORK; + var expectedC; + var info; + var data; + var WORK; + var TAU; + var A; + var C; + + data = P_NQ_GT_K_LEFT_TRANSPOSE; + + A = new Float64Array( data.A ); + TAU = new Float64Array( data.TAU ); + C = new Float64Array( data.C ); + WORK = new Float64Array( data.WORK ); + + expectedC = new Float64Array( data.C_out ); + expectedWORK = new Float64Array( data.WORK_out ); + + info = dormbr( data.order, data.vect, data.side, data.trans, data.M, data.N, data.K, A, data.LDA, TAU, C, data.LDC, WORK, data.LWORK ); + t.strictEqual( info, 0, 'returns expected value' ); + t.strictEqual( isAlmostEqual( C, expectedC, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( WORK, expectedWORK, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function multiplies a general matrix by the orthogonal matrix `Q` (nq < K, left)', function test( t ) { + var expectedWORK; + var expectedC; + var info; + var data; + var WORK; + var TAU; + var A; + var C; + + data = Q_NQ_LT_K_LEFT; + + A = new Float64Array( data.A ); + TAU = new Float64Array( data.TAU ); + C = new Float64Array( data.C ); + WORK = new Float64Array( data.WORK ); + + expectedC = new Float64Array( data.C_out ); + expectedWORK = new Float64Array( data.WORK_out ); + + info = dormbr( data.order, data.vect, data.side, data.trans, data.M, data.N, data.K, A, data.LDA, TAU, C, data.LDC, WORK, data.LWORK ); + t.strictEqual( info, 0, 'returns expected value' ); + t.strictEqual( isAlmostEqual( C, expectedC, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( WORK, expectedWORK, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function multiplies a general matrix by the orthogonal matrix `Q` (nq < K, right)', function test( t ) { + var expectedWORK; + var expectedC; + var info; + var data; + var WORK; + var TAU; + var A; + var C; + + data = Q_NQ_LT_K_RIGHT; + + A = new Float64Array( data.A ); + TAU = new Float64Array( data.TAU ); + C = new Float64Array( data.C ); + WORK = new Float64Array( data.WORK ); + + expectedC = new Float64Array( data.C_out ); + expectedWORK = new Float64Array( data.WORK_out ); + + info = dormbr( data.order, data.vect, data.side, data.trans, data.M, data.N, data.K, A, data.LDA, TAU, C, data.LDC, WORK, data.LWORK ); + t.strictEqual( info, 0, 'returns expected value' ); + t.strictEqual( isAlmostEqual( C, expectedC, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( WORK, expectedWORK, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function multiplies a general matrix by the orthogonal matrix `P^T` (nq <= K, left)', function test( t ) { + var expectedWORK; + var expectedC; + var info; + var data; + var WORK; + var TAU; + var A; + var C; + + data = P_NQ_LE_K_LEFT; + + A = new Float64Array( data.A ); + TAU = new Float64Array( data.TAU ); + C = new Float64Array( data.C ); + WORK = new Float64Array( data.WORK ); + + expectedC = new Float64Array( data.C_out ); + expectedWORK = new Float64Array( data.WORK_out ); + + info = dormbr( data.order, data.vect, data.side, data.trans, data.M, data.N, data.K, A, data.LDA, TAU, C, data.LDC, WORK, data.LWORK ); + t.strictEqual( info, 0, 'returns expected value' ); + t.strictEqual( isAlmostEqual( C, expectedC, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( WORK, expectedWORK, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function multiplies a general matrix by the orthogonal matrix `P^T` (nq <= K, right)', function test( t ) { + var expectedWORK; + var expectedC; + var info; + var data; + var WORK; + var TAU; + var A; + var C; + + data = P_NQ_LE_K_RIGHT; + + A = new Float64Array( data.A ); + TAU = new Float64Array( data.TAU ); + C = new Float64Array( data.C ); + WORK = new Float64Array( data.WORK ); + + expectedC = new Float64Array( data.C_out ); + expectedWORK = new Float64Array( data.WORK_out ); + + info = dormbr( data.order, data.vect, data.side, data.trans, data.M, data.N, data.K, A, data.LDA, TAU, C, data.LDC, WORK, data.LWORK ); + t.strictEqual( info, 0, 'returns expected value' ); + t.strictEqual( isAlmostEqual( C, expectedC, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( WORK, expectedWORK, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns early without modifying `C` when `vect = \'Q\'` and the order of `Q` is one', function test( t ) { + var expectedWORK; + var expectedC; + var info; + var WORK; + var TAU; + var A; + var C; + + A = new Float64Array( [ 1, 0 ] ); + TAU = new Float64Array( [ 2, 3 ] ); + C = new Float64Array( [ 1, 2, 3 ] ); + WORK = new Float64Array( 3 ); + + expectedC = new Float64Array( [ 1, 2, 3 ] ); + expectedWORK = new Float64Array( [ 96, 0, 0 ] ); + + info = dormbr( 'column-major', 'Q', 'left', 'no-transpose', 1, 3, 2, A, 1, TAU, C, 1, WORK, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.strictEqual( isAlmostEqual( C, expectedC, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( WORK, expectedWORK, 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns early without modifying `C` when `vect = \'P\'` and the order of `P` is one', function test( t ) { + var expectedWORK; + var expectedC; + var info; + var WORK; + var TAU; + var A; + var C; + + A = new Float64Array( [ 1, 0 ] ); + TAU = new Float64Array( [ 2, 3 ] ); + C = new Float64Array( [ 1, 2, 3 ] ); + WORK = new Float64Array( 3 ); + + expectedC = new Float64Array( [ 1, 2, 3 ] ); + expectedWORK = new Float64Array( [ 96, 0, 0 ] ); + + info = dormbr( 'column-major', 'P', 'left', 'no-transpose', 1, 3, 2, A, 1, TAU, C, 1, WORK, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.strictEqual( isAlmostEqual( C, expectedC, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqual( WORK, expectedWORK, 1 ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dormbr/test/test.js b/lib/node_modules/@stdlib/lapack/base/dormbr/test/test.js new file mode 100644 index 000000000000..8fc25c3f47b1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dormbr/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dormbr = 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 dormbr, '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 dormbr.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 dormbr = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dormbr, 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 dormbr; + var main; + + main = require( './../lib/dormbr.js' ); + + dormbr = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dormbr, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +});