All files / lapack/base/dlarfb/lib base.js

98.3% Statements 116/118
92.85% Branches 13/14
100% Functions 1/1
98.3% Lines 116/118

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 1193x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 193x 193x 193x     193x 193x 97x 48x 24x 24x 24x 24x 97x 24x 24x 25x 25x 193x 48x 24x 24x 24x 24x 193x 24x 24x 24x 193x 3x 3x 3x 3x 3x  
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
 
/* eslint-disable max-len, 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 => <Float64Array>[ -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;