Skip to content

feat: add lapack/base/dlarfb #7833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
435 changes: 435 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlarfb/lib/base.js

Large diffs are not rendered by default.

185 changes: 185 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlarfb/lib/dlarfb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var isLayout = require( '@stdlib/blas/base/assert/is-layout' );
var isOperationSide = require( '@stdlib/blas/base/assert/is-operation-side' );
var isTransposeOperation = require( '@stdlib/blas/base/assert/is-transpose-operation' );
var isMatrixOrientation = require( '@stdlib/blas/base/assert/is-matrix-orientation' );
var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' );
var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' );
var max = require( '@stdlib/math/base/special/max' );
var format = require( '@stdlib/string/format' );
var base = require( './base.js' );


// MAIN //

/**
* 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.
*
* @param {string} order - storage layout
* @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` (`'no-transpose'` or `'transpose'`)
* @param {string} direct - indicates how `H` is formed from a product of elementary reflectors (`'forward'` or `'backward'`)
* @param {string} storev - indicates how the vectors which define the elementary reflectors are stored (`'column-major'` or `'row-major'`)
* @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 {PositiveInteger} LDV - leading dimension of `V`
* @param {Float64Array} T - input matrix (upper/lower triangular as dictated by `direct`/`storev`)
* @param {PositiveInteger} LDT - leading dimension of `T` (must be ≥ max(1,K))
* @param {Float64Array} C - input/output matrix
* @param {PositiveInteger} LDC - leading dimension of `C`
* @param {Float64Array} work - work array
* @param {PositiveInteger} LDWORK - leading dimension of `work`
* @throws {TypeError} first argument must be a valid order
* @throws {TypeError} invalid `side`
* @throws {TypeError} invalid `trans`
* @throws {TypeError} invalid `direct`
* @throws {TypeError} invalid `storev`
* @throws {RangeError} invalid leading dimension(s)
* @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( 'row-major', 'left', 'transpose', 'forward', 'columns', 3, 3, 3, V, 3, T, 3, C, 3, work, 3 );
*
* // C => <Float64Array>[ -1350.00, -1400.00, -1450.00, -30961.00, -32102.00, -33243.00, -266612.00, -275464.00, -284316.00 ]
*/
function dlarfb( order, side, trans, direct, storev, M, N, K, V, LDV, T, LDT, C, LDC, work, LDWORK ) { // eslint-disable-line max-params, max-len
var requiredLdwork;
var sv1;
var sv2;
var st1;
var st2;
var sc1;
var sc2;
var sw1;
var sw2;

if ( !isLayout( order ) ) {
throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) );
}
if ( !isOperationSide( side ) ) {
throw new TypeError( format( 'invalid argument. Second argument must be a valid BLAS operation side. Value: `%s`.', side ) );
}
if ( !isTransposeOperation( trans ) ) {
throw new TypeError( format( 'invalid argument. Third argument must be a valid BLAS transpose operation. Value: `%s`.', trans ) );
}
if ( direct !== 'forward' && direct !== 'backward' ) {
throw new TypeError( format( 'invalid argument. Fourth argument must be either `forward` or `backward`. Value: `%s`.', direct ) );
}
if ( !isMatrixOrientation( storev ) ) {
throw new TypeError( format( 'invalid argument. Fifth argument must be a valid matrix orientation. Value: `%s`.', storev ) );
}

if ( isRowMajor( order ) ) {
if ( LDC < max( 1, N ) ) {
throw new RangeError( format( 'invalid argument. Thirteenth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDC ) );
}
if ( LDT < max( 1, K ) ) {
throw new RangeError( format( 'invalid argument. Twelfth argument must be greater than or equal to max(1,%d). Value: `%d`.', K, LDT ) );
}
if ( storev === 'columns' ) {
if ( LDV < max( 1, K ) ) {
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', K, LDV ) );
}
} else if ( storev === 'rows' ) {
if ( side === 'left' ) {
if ( LDV < max( 1, M ) ) {
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDV ) );
}
} else if ( side === 'right' ) {
if ( LDV < max( 1, N ) ) {
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDV ) );
}
}
}
if ( LDWORK < max( 1, K ) ) {
throw new RangeError( format( 'invalid argument. Fifteenth argument must be greater than or equal to max(1,%d). Value: `%d`.', K, LDWORK ) );
}
} else if ( isColumnMajor( order ) ) {
if ( LDC < max( 1, M ) ) {
throw new RangeError( format( 'invalid argument. Thirteenth argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDC ) );
}
if ( LDT < max( 1, K ) ) {
throw new RangeError( format( 'invalid argument. Twelfth argument must be greater than or equal to max(1,%d). Value: `%d`.', K, LDT ) );
}
if ( storev === 'columns' ) {
if ( side === 'left' ) {
if ( LDV < max( 1, M ) ) {
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDV ) );
}
} else if ( side === 'right' ) {
if ( LDV < max( 1, N ) ) {
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDV ) );
}
}
} else if ( storev === 'rows' ) {
if ( LDV < max( 1, K ) ) {
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', K, LDV ) );
}
}
if ( side === 'left' ) {
requiredLdwork = N;
} else {
requiredLdwork = M;
}
if ( LDWORK < max( 1, requiredLdwork ) ) {
throw new RangeError( format( 'invalid argument. Fifteenth argument must be greater than or equal to max(1,%d). Value: `%d`.', requiredLdwork, LDWORK ) );
}
}

if ( isColumnMajor( order ) ) {
sv1 = 1;
sv2 = LDV;
st1 = 1;
st2 = LDT;
sc1 = 1;
sc2 = LDC;
sw1 = 1;
sw2 = LDWORK;
} else {
sv1 = LDV;
sv2 = 1;
st1 = LDT;
st2 = 1;
sc1 = LDC;
sc2 = 1;
sw1 = LDWORK;
sw2 = 1;
}

return base( side, trans, direct, storev, M, N, K, V, sv1, sv2, 0, T, st1, st2, 0, C, sc1, sc2, 0, work, sw1, sw2, 0 ); // eslint-disable-line max-len
}


// EXPORTS //

module.exports = dlarfb;
Loading