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 119 120 121 122 123 124 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 68x 68x 68x 68x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 19x 68x 8288x 8288x 68x 19x 19x 19x 1x 1x 1x 1x 1x | /**
* @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 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 <Float64Array>[ -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 ic;
var iv;
var iw;
var j;
var i;
/* 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
for ( j = 0; j < K; j++ ) {
for ( i = 0; i < M; i++ ) {
C[ offsetC + ( i * strideC1 ) + ( j * strideC2 ) ] -= work[ offsetWork + ( i * strideWork1 ) + ( j * strideWork2 ) ];
}
}
return C;
}
// EXPORTS //
module.exports = rightForwardRows;
|