All files base.js

100% Statements 445/445
100% Branches 22/22
100% Functions 1/1
100% Lines 445/445

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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 4463x 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 266x 266x 266x 266x 266x 266x 266x 266x 266x 266x 266x 2x 2x 264x 266x 156x 156x 156x 108x 108x 108x 266x 48x 48x 60x 60x 60x 108x 266x 60x 60x 48x 48x 48x 108x 108x 108x 108x 108x 108x 108x 108x 108x 108x 108x 266x 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 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 36x 36x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 266x 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 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 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 84x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 48x 48x 48x 48x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 60x 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 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 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 108x 266x 3x 3x 3x 3x 3x  
/**
* @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` = 'columnwise', 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` = 'rowwise', 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`.
*
* @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', 'rowwise', 5, 3, V, 5, 1, 0, TAU, 1, 0, T, 3, 1, 0 );
* // T => <Float64Array>[ ~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 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 === 'columnwise' ) {
		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 ) {
		/*
		Break V apart into 6 components
 
		V = |---------------|
			|V_{1,1} 0      |
			|V_{2,1} V_{2,2}|
			|V_{3,1} V_{3,2}|
			|---------------|
 
		V_{1,1}\in\R^{l,l}      unit lower triangular
		V_{2,1}\in\R^{k-l,l}    rectangular
		V_{3,1}\in\R^{n-k,l}    rectangular
 
		V_{2,2}\in\R^{k-l,k-l}  unit lower triangular
		V_{3,2}\in\R^{n-k,k-l}  rectangular
 
		We will construct the T matrix
		T = |---------------|
			|T_{1,1} T_{1,2}|
			|0       T_{2,2}|
			|---------------|
 
		T is the triangular factor obtained from block reflectors.
		To motivate the structure, assume we have already computed T_{1,1}
		and T_{2,2}. Then collect the associated reflectors in V_1 and V_2
 
		T_{1,1}\in\R^{l, l}     upper triangular
		T_{2,2}\in\R^{k-l, k-l} upper triangular
		T_{1,2}\in\R^{l, k-l}   rectangular
 
		Where l = floor(k/2)
 
		Then, consider the product:
 
		(I - V_1*T_{1,1}*V_1')*(I - V_2*T_{2,2}*V_2')
		= I - V_1*T_{1,1}*V_1' - V_2*T_{2,2}*V_2' + V_1*T_{1,1}*V_1'*V_2*T_{2,2}*V_2'
 
		Define T_{1,2} = -T_{1,1}*V_1'*V_2*T_{2,2}
 
		Then, we can define the matrix V as
		V = |-------|
			|V_1 V_2|
			|-------|
 
		So, our product is equivalent to the matrix product
		I - V*T*V'
		This means, we can compute T_{1,1} and T_{2,2}, then use this information
		to compute T_{1,2}
		*/
 
		// 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}
		for ( j = 0; j < l; j++ ) {
			for ( i = 0; i < K - l; i++ ) {
				T[ offsetT + ( strideT1 * j ) + ( strideT2 * ( l + i ) ) ] = V[ offsetV + ( strideV1 * ( l + i ) ) + ( strideV2 * j ) ];
			}
		}
 
		// 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 ) {
		/*
		Break V apart into 6 components
 
		V = |----------------------|
			|V_{1,1} V_{1,2} V{1,3}|
			|0       V_{2,2} V{2,3}|
			|----------------------|
 
		V_{1,1}\in\R^{l,l}      unit upper triangular
		V_{1,2}\in\R^{l,k-l}    rectangular
		V_{1,3}\in\R^{l,n-k}    rectangular
 
		V_{2,2}\in\R^{k-l,k-l}  unit upper triangular
		V_{2,3}\in\R^{k-l,n-k}  rectangular
 
		Where l = floor(k/2)
 
		We will construct the T matrix
		T = |---------------|
			|T_{1,1} T_{1,2}|
			|0       T_{2,2}|
			|---------------|
 
		T is the triangular factor obtained from block reflectors.
		To motivate the structure, assume we have already computed T_{1,1}
		and T_{2,2}. Then collect the associated reflectors in V_1 and V_2
 
		T_{1,1}\in\R^{l, l}     upper triangular
		T_{2,2}\in\R^{k-l, k-l} upper triangular
		T_{1,2}\in\R^{l, k-l}   rectangular
 
		Then, consider the product:
 
		(I - V_1'*T_{1,1}*V_1)*(I - V_2'*T_{2,2}*V_2)
		= I - V_1'*T_{1,1}*V_1 - V_2'*T_{2,2}*V_2 + V_1'*T_{1,1}*V_1*V_2'*T_{2,2}*V_2
 
		Define T_{1,2} = -T_{1,1}*V_1*V_2'*T_{2,2}
 
		Then, we can define the matrix V as
		V = |---|
			|V_1|
			|V_2|
			|---|
 
		So, our product is equivalent to the matrix product
		I - V'*T*V
		This means, we can compute T_{1,1} and T_{2,2}, then use this information
		to compute T_{1,2}
		*/
 
		// 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 ) {
		/*
		Break V apart into 6 components
 
		V = |---------------|
			|V_{1,1} V_{1,2}|
			|V_{2,1} V_{2,2}|
			|0       V_{3,2}|
			|---------------|
 
		V_{1,1}\in\R^{n-k,k-l}  rectangular
		V_{2,1}\in\R^{k-l,k-l}  unit upper triangular
 
		V_{1,2}\in\R^{n-k,l}    rectangular
		V_{2,2}\in\R^{k-l,l}    rectangular
		V_{3,2}\in\R^{l,l}      unit upper triangular
 
		We will construct the T matrix
		T = |---------------|
			|T_{1,1} 0      |
			|T_{2,1} T_{2,2}|
			|---------------|
 
		T is the triangular factor obtained from block reflectors.
		To motivate the structure, assume we have already computed T_{1,1}
		and T_{2,2}. Then collect the associated reflectors in V_1 and V_2
 
		T_{1,1}\in\R^{k-l, k-l} non-unit lower triangular
		T_{2,2}\in\R^{l, l}     non-unit lower triangular
		T_{2,1}\in\R^{k-l, l}   rectangular
 
		Where l = floor(k/2)
 
		Then, consider the product:
 
		(I - V_2*T_{2,2}*V_2')*(I - V_1*T_{1,1}*V_1')
		= I - V_2*T_{2,2}*V_2' - V_1*T_{1,1}*V_1' + V_2*T_{2,2}*V_2'*V_1*T_{1,1}*V_1'
 
		Define T_{2,1} = -T_{2,2}*V_2'*V_1*T_{1,1}
 
		Then, we can define the matrix V as
		V = |-------|
			|V_1 V_2|
			|-------|
 
		So, our product is equivalent to the matrix product
		I - V*T*V'
		This means, we can compute T_{1,1} and T_{2,2}, then use this information
		to compute T_{2,1}
		*/
 
		// 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}
		for ( j = 0; j < K - l; j++ ) {
			for ( i = 0; i < l; i++ ) {
				T[ offsetT + ( strideT1 * ( K - l + i ) ) + ( strideT2 * j ) ] = V[ offsetV + ( strideV1 * ( N - K + j ) ) + ( strideV2 * ( K - l + i ) ) ];
			}
		}
 
		// 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
 
		Break V apart into 6 components
 
		V = |-----------------------|
			|V_{1,1} V_{1,2} 0      |
			|V_{2,1} V_{2,2} V_{2,3}|
			|-----------------------|
 
		V_{1,1}\in\R^{k-l,n-k}  rectangular
		V_{1,2}\in\R^{k-l,k-l}  unit lower triangular
 
		V_{2,1}\in\R^{l,n-k}    rectangular
		V_{2,2}\in\R^{l,k-l}    rectangular
		V_{2,3}\in\R^{l,l}      unit lower triangular
 
		We will construct the T matrix
		T = |---------------|
			|T_{1,1} 0      |
			|T_{2,1} T_{2,2}|
			|---------------|
 
		T is the triangular factor obtained from block reflectors.
		To motivate the structure, assume we have already computed T_{1,1}
		and T_{2,2}. Then collect the associated reflectors in V_1 and V_2
 
		T_{1,1}\in\R^{k-l, k-l} non-unit lower triangular
		T_{2,2}\in\R^{l, l}     non-unit lower triangular
		T_{2,1}\in\R^{k-l, l}   rectangular
 
		Where l = floor(k/2)
 
		Then, consider the product:
 
		(I - V_2'*T_{2,2}*V_2)*(I - V_1'*T_{1,1}*V_1)
		= I - V_2'*T_{2,2}*V_2 - V_1'*T_{1,1}*V_1 + V_2'*T_{2,2}*V_2*V_1'*T_{1,1}*V_1
 
		Define T_{2,1} = -T_{2,2}*V_2*V_1'*T_{1,1}
 
		Then, we can define the matrix V as
		V = |---|
			|V_1|
			|V_2|
			|---|
 
		So, our product is equivalent to the matrix product
		I - V'*T*V
		This means, we can compute T_{1,1} and T_{2,2}, then use this information
		to compute T_{2,1}
		*/
 
		// 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;