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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | 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 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 72x 72x 72x 72x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 72x 216x 216x 216x 216x 72x 72x 72x 24x 24x 24x 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. */ '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 <Float64Array>[ -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; |