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

35.07% Statements 262/747
36.36% Branches 4/11
100% Functions 2/2
35.07% Lines 262/747

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 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 7482x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                     1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 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 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 3x 3x     3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 3x 3x 3x 3x                                                                                                                                                                                                                                                                                                           3x 1x 2x 2x 2x 2x 2x  
/**
* @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, max-lines-per-function, max-statements, max-lines, max-depth */
 
'use strict';
 
// MODULES //
 
var floor = require( '@stdlib/math/base/special/floor' );
var abs = require( '@stdlib/math/base/special/abs' );
var dlamch = require( '@stdlib/lapack/base/dlamch' );
var dgemm = require( '@stdlib/blas/base/dgemm' ).ndarray;
var dlacpy = require( '@stdlib/lapack/base/dlacpy' ).ndarray;
var Float64Array = require( '@stdlib/array/float64' );
var dlaset = require( '@stdlib/lapack/base/dlaset' ).ndarray;
var mod = require( '@stdlib/math/base/special/fmod' );
var min = require( '@stdlib/math/base/special/fast/min' );
var max = require( '@stdlib/math/base/special/fast/max' );
var dtrmm = require( './dtrmm.js' );
var dlarfg = require( './dlarfg.js' );
var dlaqr1 = require( './dlaqr1.js' );
 
 
// VARIABLES //
 
var safmin = dlamch( 'safe minimum' );
var ulp = dlamch( 'precision' );
 
 
// FUNCTIONS //
 
/**
* Shuffle shifts into pairs of real shifts and pairs of complex conjugate shifts, assuming that complex conjugate shifts are already adjacent to one another.
*
* @private
* @param {integer} nshifts - number of simultaneous shifts, must be even and positive
* @param {Float64Array} SR - real parts of the shifts of origin that define the QR sweep
* @param {integer} strideSR - stride length of `SR`
* @param {NonNegativeInteger} offsetSR - starting index for `SR`
* @param {Float64Array} SI - imaginary parts of the shifts of origin that define the QR sweep
* @param {integer} strideSI - stride length of `SI`
* @param {NonNegativeInteger} offsetSI - starting index of `SI`
* @returns {void}
*/
function shuffleShifts( nshifts, SR, strideSR, offsetSR, SI, strideSI, offsetSI ) {
	var swap;
	var isi;
	var isr;
	var i;
 
	isi = offsetSI;
	isr = offsetSR;
	for ( i = 0; i <= nshifts - 2; i += 2 ) {
		if ( SI[ isi ] !== -SI[ isi + strideSI ] ) {
			swap = SR[ isr ];
			SR[ isr ] = SR[ isr + strideSR ];
			SR[ isr + strideSR ] = SR[ isr + (2*strideSR) ];
			SR[ isr + (2*strideSR) ] = swap;

			swap = SI[ isi ];
			SI[ isi ] = SI[ isi + strideSI ];
			SI[ isi + strideSI ] = SI[ isi + (2*strideSI) ];
			SI[ isi + (2*strideSI) ] = swap;
		}
		isi += (2*strideSI);
		isr += (2*strideSR);
	}
}
 
 
// MAIN //
 
/**
* Performs a single, small shift multiline QR sweep.
*
* @private
* @param {boolean} wantT - boolean value indicating whether the quasi triangular Schur factor is being computed
* @param {boolean} wantZ - boolean value indicating whether the orthogonal Schur factor is being computed
* @param {integer} kacc22 - integer value ranging from 0 to 2 (inclusive), specifies the computation mode for far-from-diagonal updates
* @param {integer} N - number of rows/columns in `H`
* @param {integer} KTOP - first row and column of the submatrix of `H` where the QR sweep will be applied
* @param {integer} KBOT - last row and column of the submatrix of `H` where the QR sweep will be applied
* @param {integer} nshifts - number of simultaneous shifts, must be even and positive
* @param {Float64Array} SR - real parts of the shifts of origin that define the QR sweep
* @param {integer} strideSR - stride length of `SR`
* @param {NonNegativeInteger} offsetSR - starting index for `SR`
* @param {Float64Array} SI - imaginary parts of the shifts of origin that define the QR sweep
* @param {integer} strideSI - stride length of `SI`
* @param {NonNegativeInteger} offsetSI - starting index of `SI`
* @param {Float64Array} H - input upper hessenberg matrix
* @param {integer} strideH1 - stride of the first dimension of `H`
* @param {integer} strideH2 - stride of the second dimension of `H`
* @param {NonNegativeInteger} offsetH - starting index of `H`
* @param {integer} iloZ - starting row from where the transformation must be applied if `wantZ` is true
* @param {integer} ihiZ - ending row from where the transformation must be applied if `wantZ` is true
* @param {Float64Array} Z - the QR sweep orthogonal similarity transformation is accumulated into `Z` between the rows and columns `iloZ` and `ihiZ` if `wantZ` is true, otherwise `Z` is not referenced
* @param {integer} strideZ1 - stride of the first dimension of `Z`
* @param {integer} strideZ2 - stride of the second dimension of `Z`
* @param {NonNegativeInteger} offsetZ - starting index of `Z`
* @param {Float64Array} V - householder vectors are stored column-wise, used in forming bulges for the multi shift QR algorithm
* @param {integer} strideV1 - stride of the first dimension of `V`
* @param {integer} strideV2 - stride of the second dimension of `V`
* @param {NonNegativeInteger} offsetV - starting index of `V`
* @param {Float64Array} U - used to hold the product of householder reflector that represent accumulated orthogonal transformations from the bulge-chasing process
* @param {integer} strideU1 - stride of the first dimension of `U`
* @param {integer} strideU2 - stride of the second dimension of `U`
* @param {NonNegativeInteger} offsetU - starting index of `U`
* @param {integer} NH - number of columns in `WH` available for workspace
* @param {Float64Array} WH - workspace array
* @param {integer} strideWH1 - stride of the first dimension of `WH`
* @param {integer} strideWH2 - stride of the second dimension of `WH`
* @param {NonNegativeInteger} offsetWH - starting index of `WH`
* @param {integer} NV - number of rows in `WV` available for workspace
* @param {Float64Array} WV - workspace array
* @param {integer} strideWV1 - stride of the first dimension of `WV`
* @param {integer} strideWV2 - stride of the second dimension of `WV`
* @param {NonNegativeInteger} offsetWV - starting index of `WV`
* @returns {void}
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var H = new Float64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 2.0, 1.5, 0.0, 0.0, 0.0, 3, 2.0, 0.0, 0.0, 0.0, 4.0 ] );
* var Z = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] );
* var V = new Float64Array( 6 );
* var U = new Float64Array( 10 );
* var WH = new Float64Array( 16 );
* var WV = new Float64Array( 16 );
* var SR = new Float64Array( [ 1.1, 2.2 ] );
* var SI = new Float64Array( [ 0.0, 0.0 ] );
*
* dlaqr5( true, true, 0, 4, 1, 4, 2, SR, 1, 0, SI, 1, 0, H, 4, 1, 0, 1, 4, Z, 4, 1, 0, V, 2, 1, 0, U, 2, 1, 0, 4, WH, 4, 1, 0, 4, WV, 4, 1, 0 );
* // H => <Float64Array>[ 1.0, 1.0, 0.0, 0.0, 0.0, 2.0, 1.5, 0.0, 0.0, 0.0, 3, 2.0, 0.0, 0.0, 0.0, 4.0 ]
* // Z => <Float64Array>[ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ]
*/
function dlaqr5( wantT, wantZ, kacc22, N, KTOP, KBOT, nshifts, SR, strideSR, offsetSR, SI, strideSI, offsetSI, H, strideH1, strideH2, offsetH, iloZ, ihiZ, Z, strideZ1, strideZ2, offsetZ, V, strideV1, strideV2, offsetV, U, strideU1, strideU2, offsetU, NH, WH, strideWH1, strideWH2, offsetWH, NV, WV, strideWV1, strideWV2, offsetWV ) {
	var dlarfgOut;
	var block22;
	var smlnum;
	var refsum;
	var mstart;
	var incol;
	var accum;
	var nbmps;
	var krcol;
	var bmp22;
	var alpha;
	var start;
	var ndcol;
	var beta;
	var jcol;
	var jlen;
	var jrow;
	var jtop;
	var jbot;
	var mend;
	var mtop;
	var mbot;
	var tst1;
	var tst2;
	var step;
	var h11;
	var h12;
	var h21;
	var h22;
	var kdu;
	var end;
	var kms;
	var knz;
	var kzs;
	var m22;
	var scl;
	var k1;
	var nu;
	var vt;
	var i2;
	var i4;
	var j2;
	var j4;
	var ns;
	var ih;
	var k;
	var m;
	var j;
 
	dlarfgOut = new Float64Array( 2 ); // Workspace array to pass `alpha` to the `dlarfg` routine
	vt = new Float64Array( 3 ); // local array
 
	// If there are no shifts, then there is nothing to do.
	if ( nshifts < 2 ) {
		return;
	}
 
	// If the active block is empty or 1-by-1, then there is nothing to do.
	if ( KTOP >= KBOT ) {
		return;
	}
 
	/*
	* Shuffle shifts into pairs of real shifts and pairs of complex conjugate shifts,
	* assuming that complex conjugate shifts are already adjacent to one another.
	*/
	shuffleShifts( nshifts, SR, strideSR, offsetSR, SI, strideSI, offsetSI );
 
	// `nshifts` is supposed to be even, but if it is odd, then simply reduce it by one. The shuffle above ensures that the dropped shift is real and that the remaining shifts are paired.
	ns = nshifts - mod( nshifts, 2.0 );
 
	// Machine constants for deflation
	smlnum = safmin * N / ulp;
 
	// Use accumulated reflections to update far-from-diagonal entries?
	accum = ( kacc22 === 1 ) || ( kacc22 === 2 );
 
	// If so, exploit the 2-by-2 block structure?
	block22 = ( ns > 2 ) && ( kacc22 === 2 );
 
	// Clear trash
	if ( KTOP + 2 <= KBOT ) {
		ih = offsetH + ( (KTOP+2) * strideH1 ) + ( KTOP * strideH2 );
		H[ ih ] = 0.0;
	}
 
	// `nbmps` = number of 2-shift bulges in the chain
	nbmps = ns / 2;
 
	// KDU = width of slab
	kdu = ( 6 * nbmps ) - 3;
 
	start = ( 3 * ( 1 - nbmps ) ) + KTOP - 1;
	end = KBOT - 2;
	step = ( 3 * nbmps ) - 2;
 
	// Create and chase chains of `nbmps` bulges
	for ( incol = start; incol <= end; incol += step ) {
		ndcol = incol + kdu;
		if ( accum ) {
			dlaset( 'all', kdu, kdu, 0.0, 1.0, U, strideU1, strideU2, offsetU );
		}
 
		/*
		* Near-the-diagonal bulge chase. The following loop performs the
		* near-the-diagonal part of a small bulge multi-shift QR sweep. Each
		* `6*nbmps-2` column diagonal chunk extends from column `incol` to column
		* `ndcol` (including both column `incol` and column `ndcol`). The following
		* loop chases a 3*`nbmps` column long chain of `nbmps` bulges `3*nbmps-2`
		* columns to the right. (`incol` may be less than `KTOP` and and `ndcol`
		* may be greater than `KBOT` indicating phantom columns from which to
		* chase bulges before they are actually introduced or to which to
		* chase bulges beyond column `KBOT`.)
		*/
		for ( krcol = incol; krcol < min( incol + ( 3*nbmps ) - 3, KBOT - 2 ); krcol+= 1 ) {
			/*
			* Bulges number `mtop` to `mbot` are active double implicit shift bulges.
			* There may or may not also be small 2-by-2 bulge, if there is room.
			* The inactive bulges (if any) must wait until the active bulges
			* have moved down the diagonal to make room. The phantom matrix
			* paradigm described above helps keep track.
			*/
			mtop = max( 1, floor( ( KTOP - 1 - krcol + 2 ) / 3 ) + 1 );
			mbot = min( nbmps, floor( ( KBOT - krcol ) / 3 ) );
			m22 = mbot + 1;
			bmp22 = ( mbot < nbmps ) && ( krcol + ( 3 * ( m22 - 1 ) ) === KBOT - 2 );

			/*
			* Generate reflections to chase the chain right one column.
			* (The minimum value of K is KTOP-1.)
			*/
			for ( m = mtop; m <= mbot; m++ ) {
				k = krcol + ( 3 * ( m - 1 ) );
				if ( k === KTOP - 1 ) {
					dlaqr1( 3, H, strideH1, strideH2, offsetH + (KTOP*strideH1) + (KTOP*strideH2), SR[ offsetSR + (((2*m)-2)*strideSR) ], SI[ offsetSI + (((2*m)-2)*strideSI) ], SR[ offsetSR + (((2*m)-1)*strideSR) ], SI[ offsetSI + (((2*m)-1)*strideSI) ], vt, 1, 0 );

					alpha = V[ offsetV + (m*strideV2) ];

					// Prepare the `dlarfgOut` array to pass into the routine
					dlarfgOut[ 0 ] = alpha;
					dlarfgOut[ 1 ] = 0.0;

					// Call `dlarfg` using the `dlarfgOut` array to store outputs
					dlarfg( 3, V, strideV1, offsetV + (m*strideV2), dlarfgOut, 1, 0 );

					// Write the outputs to their expected positions
					alpha = dlarfgOut[ 0 ];
					V[ offsetV + (m*strideV2) ] = dlarfgOut[ 1 ];
				} else {
					beta = H[ offsetH + ((k+1)*strideH1) + (k*strideH2) ];
					V[ offsetV + (m*strideV2) + strideV1 ] = H[ offsetH + ((k+2)*strideH1) + (k*strideH2) ];
					V[ offsetV + (m*strideV2) + (2*strideV1) ] = H[ offsetH + ((k+3)*strideH1) + (k*strideH2) ];

					// Prepare the `dlarfgOut` array to pass into the routine
					dlarfgOut[ 0 ] = beta;
					dlarfgOut[ 1 ] = 0.0;

					// Call `dlarfg` using the `dlarfgOut` array to store outputs
					dlarfg( 3, V, strideV1, offsetV + (m*strideV2), dlarfgOut, 1, 0 );

					// Write the outputs to their expected positions
					beta = dlarfgOut[ 0 ];
					V[ offsetV + (m*strideV2) ] = dlarfgOut[ 1 ];

					/*
					* A Bulge may collapse because of vigilant deflation or
					* destructive underflow. In the underflow case, try the
					* two-small-subdiagonals trick to try to reinflate the bulge.
					*/
					if ( H[ offsetH + ((k+3)*strideH1) + (k*strideH2) ] !== 0.0 || H[ offsetH + ((k+3)*strideH1) + ((k+1)*strideH2) ] !== 0.0 || H[ offsetH + ((k+3)*strideH1) + ((k+2)*strideH2) ] === 0.0 ) {
						// Typical case: not collapsed (yet).
						H[ offsetH + ((k+1)*strideH1) + (k*strideH2) ] = beta;
						H[ offsetH + ((k+2)*strideH1) + (k*strideH2) ] = 0.0;
						H[ offsetH + ((k+3)*strideH1) + (k*strideH2) ] = 0.0;
					} else {
						/*
						* Atypical case: collapsed. Attempt to reintroduce
						* ignoring H(K+1,K) and H(K+2,K). If the fill
						* resulting from the new reflector is too large,
						* then abandon it. Otherwise, use the new one.
						*/
						dlaqr1( 3, H, strideH1, strideH2, offsetH + ((k+1)*strideH1) + ((k+1)*strideH2), SR, strideSR, offsetSR + (((2*m)-1)*strideSR), SI, strideSI, offsetSI + (((2*m)-1)*strideSI), SR, strideSR, offsetSR + (2*m*strideSR), SI, strideSI, offsetSI + (2*m*strideSI), vt );
						alpha = vt[ 0 ];

						// Prepare the `dlarfgOut` array to pass into the routine
						dlarfgOut[ 0 ] = alpha;
						dlarfgOut[ 1 ] = 0.0;

						// Call `dlarfg` using the `dlarfgOut` array to store outputs
						dlarfg( 3, vt, 1, 1, dlarfgOut, 1, 0 );

						// Write the outputs to their expected positions
						alpha = dlarfgOut[ 0 ];
						vt[ 0 ] = dlarfgOut[ 1 ];

						refsum = vt[ 0 ] * ( H[ offsetH + ((k+1)*strideH1) + (k*strideH2) ] + ( vt[ 1 ] * H[ offsetH + ((k+2)*strideH1) + (k*strideH2) ] ) );

						if ( abs( H[ offsetH + ((k+2)*strideH1) + (k*strideH2) ] - ( refsum * vt[ 1 ] ) ) + abs( refsum * vt[ 2 ] ) > ulp * ( abs( H[ offsetH + (k*strideH1) + (k*strideH2) ] ) + abs( H[ offsetH + ((k+1)*strideH1) + ((k+1)*strideH2) ] ) + abs( H[ offsetH + ((k+2)*strideH1) + ((k+2)*strideH2) ] ) ) ) {
							/*
							* Starting a new bulge here would create
							* non-negligible fill. Use the old one with
							* trepidation.
							*/
							H[ offsetH + ((k+1)*strideH1) + (k*strideH2) ] = beta;
							H[ offsetH + ((k+2)*strideH1) + (k*strideH2) ] = 0.0;
							H[ offsetH + ((k+3)*strideH1) + (k*strideH2) ] = 0.0;
						} else {
							/*
							* Stating a new bulge here would create only
							* negligible fill. Replace the old reflector
							* with the new one.
							*/
							H[ offsetH + ((k+1)*strideH1) + (k*strideH2) ] -= refsum;
							H[ offsetH + ((k+2)*strideH1) + (k*strideH2) ] = 0.0;
							H[ offsetH + ((k+3)*strideH1) + (k*strideH2) ] = 0.0;
							V[ offsetV + (m*strideV2) ] = vt[ 0 ];
							V[ offsetV + (m*strideV2) + strideV1 ] = vt[ 1 ];
							V[ offsetV + (m*strideV2) + (2*strideV1) ] = vt[ 2 ];
						}
					}
				}
			}

			// Generate a 2-by-2 reflection, if needed.
			k = krcol + ( 3 * ( m22 - 1 ) );
			if ( bmp22 ) {
				if ( k === KTOP - 1 ) {
					dlaqr1( 2, H, strideH1, strideH2, offsetH + ((k+1)*strideH1) + ((k+1)*strideH2), SR[ offsetSR + (((2*m22)-2)*strideSR) ], SI[ offsetSI + (((2*m22)-2)*strideSI) ], SR[ offsetSR + (((2*m22)-1)*strideSR) ], SI[ offsetSI + (((2*m22)-1)*strideSI) ], vt, 1, 0 );
					beta = V[ offsetV + (m22*strideV2) ];

					// Prepare the `dlarfgOut` array to pass into the routine
					dlarfgOut[ 0 ] = beta;
					dlarfgOut[ 1 ] = 0.0;

					// Call `dlarfg` using the `dlarfgOut` array to store outputs
					dlarfg( 2, V, strideV1, offsetV + (m22*strideV2), dlarfgOut, 1, 0 );

					// Write the outputs to their expected positions
					beta = dlarfgOut[ 0 ];
					V[ offsetV + (m22*strideV2) ] = dlarfgOut[ 1 ];
				} else {
					beta = H[ offsetH + ((k+1)*strideH1) + (k*strideH2) ];
					V[ offsetV + (m22*strideV2) + strideV1 ] = H[ offsetH + ((k+2)*strideH1) + (k*strideH2) ];

					// Prepare the `dlarfgOut` array to pass into the routine
					dlarfgOut[ 0 ] = beta;
					dlarfgOut[ 1 ] = 0.0;

					// Call `dlarfg` using the `dlarfgOut` array to store outputs
					dlarfg( 2, V, strideV1, offsetV + (m22*strideV2), dlarfgOut, 1, 0 );

					// Write the outputs to their expected positions
					beta = dlarfgOut[ 0 ];
					V[ offsetV + (m22*strideV2) ] = dlarfgOut[ 1 ];

					H[ offsetH + ((k+1)*strideH1) + (k*strideH2) ] = beta;
					H[ offsetH + ((k+2)*strideH1) + (k*strideH2) ] = 0.0;
				}
			}

			// Multiply H by reflections from the left
			if ( accum ) {
				jbot = min( ndcol, KBOT );
			} else if ( wantT ) {
				jbot = N;
			} else {
				jbot = KBOT;
			}

			for ( j = max( KTOP, krcol ); j <= jbot; j++ ) {
				mend = min( mbot, floor( ( j - krcol + 2 ) / 3 ) );
				for ( m = mtop; m <= mend; m++ ) {
					k = krcol + ( 3 * ( m - 1 ) );
					refsum = V[ offsetV + (m*strideV2) ] * ( H[ offsetH + ((k+1)*strideH1) + (j*strideH2) ] + ( V[ offsetV + (m*strideV2) + strideV1 ] * H[ offsetH + ((k+2)*strideH1) + (j*strideH2) ] ) + ( V[ offsetV + (m*strideV2) + (2*strideV1) ] * H[ offsetH + ((k+3)*strideH1) + (j*strideH2) ] ) );
					H[ offsetH + ((k+1)*strideH1) + (j*strideH2) ] -= refsum;
					H[ offsetH + ((k+2)*strideH1) + (j*strideH2) ] -= refsum * V[ offsetV + (m*strideV2) + strideV1 ];
					H[ offsetH + ((k+3)*strideH1) + (j*strideH2) ] -= refsum * V[ offsetV + (m*strideV2) + (2*strideV1) ];
				}
			}

			if ( bmp22 ) {
				k = krcol + ( 3 * ( m22 - 1 ) );
				for ( j = max( k + 1, KTOP ); j <= jbot; j++ ) {
					refsum = V[ offsetV + (m22*strideV2) ] * ( H[ offsetH + ((k+1)*strideH1) + (j*strideH2) ] + ( V[ offsetV + (m22*strideV2) + strideV1 ] * H[ offsetH + ((k+2)*strideH1) + (j*strideH2) ] ) );
					H[ offsetH + ((k+1)*strideH1) + (j*strideH2) ] -= refsum;
					H[ offsetH + ((k+2)*strideH1) + (j*strideH2) ] -= refsum * V[ offsetV + (m22*strideV2) + strideV1 ];
				}
			}

			/*
			* Multiply H by reflections from the right.
			* Delay filling in the last row until the
			* vigilant deflation check is complete.
			*/
			if ( accum ) {
				jtop = max( KTOP, incol );
			} else if ( wantT ) {
				jtop = 1;
			} else {
				jtop = KTOP;
			}

			for ( m = mtop; m <= mbot; m++ ) {
				if ( V[ offsetV + (m*strideV2) ] !== 0.0 ) {
					k = krcol + ( 3 * ( m - 1 ) );
					for ( j = jtop; j <= min( KBOT, k + 3 ); j++ ) {
						refsum = V[ offsetV + (m*strideV2) ] * ( H[ offsetH + (j*strideH1) + ((k+1)*strideH2) ] + ( V[ offsetV + (m*strideV2) + strideV1 ] * H[ offsetH + (j*strideH1) + ((k+2)*strideH2) ] ) + ( V[ offsetV + (m*strideV2) + (2*strideV1) ] * H[ offsetH + (j*strideH1) + ((k+3)*strideH2) ] ) );
						H[ offsetH + (j*strideH1) + ((k+1)*strideH2) ] -= refsum;
						H[ offsetH + (j*strideH1) + ((k+2)*strideH2) ] -= refsum * V[ offsetV + (m*strideV2) + strideV1 ];
						H[ offsetH + (j*strideH1) + ((k+3)*strideH2) ] -= refsum * V[ offsetV + (m*strideV2) + (2*strideV1) ];
					}

					if ( accum ) {
						/*
						* Accumulate U. (If necessary, update Z later
						* with with an efficient matrix-matrix multiply.)
						*/
						kms = k - incol;
						for ( j = max( 1, KTOP - incol ); j <= kdu; j++ ) {
							refsum = V[ offsetV + (m*strideV2) ] * ( U[ offsetU + (j*strideU1) + ((kms+1)*strideU2) ] + ( V[ offsetV + (m*strideV2) + strideV1 ] * U[ offsetU + (j*strideU1) + ((kms+2)*strideU2) ] ) + ( V[ offsetV + (m*strideV2) + (2*strideV1) ] * U[ offsetU + (j*strideU1) + ((kms+3)*strideU2) ] ) );
							U[ offsetU + (j*strideU1) + ((kms+1)*strideU2) ] -= refsum;
							U[ offsetU + (j*strideU1) + ((kms+2)*strideU2) ] -= refsum * V[ offsetV + (m*strideV2) + strideV1 ];
							U[ offsetU + (j*strideU1) + ((kms+3)*strideU2) ] -= refsum * V[ offsetV + (m*strideV2) + (2*strideV1) ];
						}
					} else if ( wantZ ) {
						/*
						* U is not accumulated, so update Z now by
						* multiplying by reflections from the right.
						*/
						for ( j = iloZ; j <= ihiZ; j++ ) {
							refsum = V[ offsetV + (m*strideV2) ] * ( Z[ offsetZ + (j*strideZ1) + ((k+1)*strideZ2) ] + ( V[ offsetV + (m*strideV2) + strideV1 ] * Z[ offsetZ + (j*strideZ1) + ((k+2)*strideZ2) ] ) + ( V[ offsetV + (m*strideV2) + (2*strideV1) ] * Z[ offsetZ + (j*strideZ1) + ((k+3)*strideZ2) ] ) );
							Z[ offsetZ + (j*strideZ1) + ((k+1)*strideZ2) ] -= refsum;
							Z[ offsetZ + (j*strideZ1) + ((k+2)*strideZ2) ] -= refsum * V[ offsetV + (m*strideV2) + strideV1 ];
							Z[ offsetZ + (j*strideZ1) + ((k+3)*strideZ2) ] -= refsum * V[ offsetV + (m*strideV2) + (2*strideV1) ];
						}
					}
				}
			}

			// Special case: 2-by-2 reflection (if needed)
			k = krcol + ( 3 * ( m22 - 1 ) );
			if ( bmp22 ) {
				if ( V[ offsetV + (m22*strideV2) ] !== 0.0 ) {
					for ( j = jtop; j <= min( KBOT, k + 3 ); j++ ) {
						refsum = V[ offsetV + (m22*strideV2) ] * ( H[ offsetH + (j*strideH1) + ((k+1)*strideH2) ] + ( V[ offsetV + (m22*strideV2) + strideV1 ] * H[ offsetH + (j*strideH1) + ((k+2)*strideH2) ] ) );
						H[ offsetH + (j*strideH1) + ((k+1)*strideH2) ] -= refsum;
						H[ offsetH + (j*strideH1) + ((k+2)*strideH2) ] -= refsum * V[ offsetV + (m22*strideV2) + strideV1 ];
					}

					if ( accum ) {
						kms = k - incol;
						for ( j = max( 1, KTOP - incol ); j <= kdu; j++ ) {
							refsum = V[ offsetV + (m22*strideV2) ] * ( U[ offsetU + (j*strideU1) + ((kms+1)*strideU2) ] + ( V[ offsetV + (m22*strideV2) + strideV1 ] * U[ offsetU + (j*strideU1) + ((kms+2)*strideU2) ] ) );
							U[ offsetU + (j*strideU1) + ((kms+1)*strideU2) ] -= refsum;
							U[ offsetU + (j*strideU1) + ((kms+2)*strideU2) ] -= refsum * V[ offsetV + (m22*strideV2) + strideV1 ];
						}
					} else if ( wantZ ) {
						for ( j = iloZ; j <= ihiZ; j++ ) {
							refsum = V[ offsetV + (m22*strideV2) ] * ( Z[ offsetZ + (j*strideZ1) + ((k+1)*strideZ2) ] + ( V[ offsetV + (m22*strideV2) + strideV1 ] * Z[ offsetZ + (j*strideZ1) + ((k+2)*strideZ2) ] ) );
							Z[ offsetZ + (j*strideZ1) + ((k+1)*strideZ2) ] -= refsum;
							Z[ offsetZ + (j*strideZ1) + ((k+2)*strideZ2) ] -= refsum * V[ offsetV + (m22*strideV2) + strideV1 ];
						}
					}
				}
			}

			// Vigilant deflation check
			mstart = mtop;
			if ( krcol + ( 3 * ( mstart - 1 ) ) < KTOP ) {
				mstart += 1;
			}
			mend = mbot;
			if ( bmp22 ) {
				mend += 1;
			}
			if ( krcol === KBOT - 2 ) {
				mend += 1;
			}
			for ( m = mstart; m <= mend; m++ ) {
				k = min( KBOT - 1, krcol + ( 3 * ( m - 1 ) ) );

				/*
				* The following convergence test requires that the tradition
				* small-compared-to-nearby-diagonals criterion and the
				* Ahues & Tisseur (LAWN 122, 1997) criteria both be satisfied.
				* The latter improves accuracy in some examples. Falling
				* back on an alternate convergence criterion when TST1 or
				* TST2 is zero (as done here) is traditional but probably
				* unnecessary.
				*/
				if ( H[ offsetH + ((k+1)*strideH1) + (k*strideH2) ] !== 0.0 ) {
					tst1 = abs( H[ offsetH + (k*strideH1) + (k*strideH2) ] ) + abs( H[ offsetH + ((k+1)*strideH1) + ((k+1)*strideH2) ] );
					if ( tst1 === 0.0 ) {
						if ( k >= KTOP + 1 ) {
							tst1 += abs( H[ offsetH + (k*strideH1) + ((k-1)*strideH2) ] );
						}
						if ( k >= KTOP + 2 ) {
							tst1 += abs( H[ offsetH + (k*strideH1) + ((k-2)*strideH2) ] );
						}
						if ( k >= KTOP + 3 ) {
							tst1 += abs( H[ offsetH + (k*strideH1) + ((k-3)*strideH2) ] );
						}
						if ( k <= KBOT - 2 ) {
							tst1 += abs( H[ offsetH + ((k+2)*strideH1) + ((k+1)*strideH2) ] );
						}
						if ( k <= KBOT - 3 ) {
							tst1 += abs( H[ offsetH + ((k+3)*strideH1) + ((k+1)*strideH2) ] );
						}
						if ( k <= KBOT - 4 ) {
							tst1 += abs( H[ offsetH + ((k+4)*strideH1) + ((k+1)*strideH2) ] );
						}
					}
					if ( abs( H[ offsetH + ((k+1)*strideH1) + (k*strideH2) ] ) <= max( smlnum, ulp * tst1 ) ) {
						h12 = max( abs( H[ offsetH + ((k+1)*strideH1) + (k*strideH2) ] ), abs( H[ offsetH + (k*strideH1) + ((k+1)*strideH2) ] ) );
						h21 = min( abs( H[ offsetH + ((k+1)*strideH1) + (k*strideH2) ] ), abs( H[ offsetH + (k*strideH1) + ((k+1)*strideH2) ] ) );
						h11 = max( abs( H[ offsetH + ((k+1)*strideH1) + ((k+1)*strideH2) ] ), abs( H[ offsetH + (k*strideH1) + (k*strideH2) ] - H[ offsetH + ((k+1)*strideH1) + ((k+1)*strideH2) ] ) );
						h22 = min( abs( H[ offsetH + ((k+1)*strideH1) + ((k+1)*strideH2) ] ), abs( H[ offsetH + (k*strideH1) + (k*strideH2) ] - H[ offsetH + ((k+1)*strideH1) + ((k+1)*strideH2) ] ) );
						scl = h11 + h12;
						tst2 = h22 * ( h11 / scl );
						if ( tst2 === 0.0 || h21 * ( h12 / scl ) <= max( smlnum, ulp * tst2 ) ) {
							H[ offsetH + ((k+1)*strideH1) + (k*strideH2) ] = 0.0;
						}
					}
				}
			}

			// Fill in the last row of each bulge.
			mend = min( nbmps, floor( ( KBOT - krcol - 1 ) / 3 ) );
			for ( m = mtop; m <= mend; m++ ) {
				k = krcol + ( 3 * ( m - 1 ) );
				refsum = V[ offsetV + (m*strideV2) ] * V[ offsetV + (m*strideV2) + (2*strideV1) ] * H[ offsetH + ((k+4)*strideH1) + ((k+3)*strideH2) ];
				H[ offsetH + ((k+4)*strideH1) + ((k+1)*strideH2) ] = -refsum;
				H[ offsetH + ((k+4)*strideH1) + ((k+2)*strideH2) ] = -refsum * V[ offsetV + (m*strideV2) + strideV1 ];
				H[ offsetH + ((k+4)*strideH1) + ((k+3)*strideH2) ] -= refsum * V[ offsetV + (m*strideV2) + (2*strideV1) ];
			}
		} // End of near-the-diagonal bulge chase.
 
		// Use U (if accumulated) to update far-from-diagonal entries in H. If required, use U to update Z as well.
		if ( accum ) {
			if ( wantT ) {
				jtop = 1;
				jbot = N;
			} else {
				jtop = KTOP;
				jbot = KBOT;
			}

			/*
			* Updates not exploiting the 2-by-2 block structure of U. K1 and NU
			* keep track of the location and size of U in the special cases of
			* introducing bulges and chasing bulges off the bottom. In these
			* special cases and in case the number of shifts is NS = 2, there
			* is no 2-by-2 block structure to exploit.
			*/
			if ( !block22 || incol < KTOP || ndcol > KBOT || ns <= 2 ) {
				k1 = max( 1, KTOP - incol );
				nu = kdu - max( 0, ndcol - KBOT ) - k1 + 1;

				// Horizontal Multiply
				for ( jcol = min( ndcol, KBOT ) + 1; jcol <= jbot; jcol += NH ) {
					jlen = min( NH, jbot - jcol + 1 );
					dgemm( 'conjugate-transpose', 'no-transpose', nu, jlen, nu, 1.0, U, strideU1, strideU2, offsetU + (k1*strideU1) + (k1*strideU2), H, strideH1, strideH2, offsetH + ((incol+k1)*strideH1) + (jcol*strideH2), 0.0, WH, strideWH1, strideWH2, offsetWH );
					dlacpy( 'all', nu, jlen, WH, strideWH1, strideWH2, offsetWH, H, strideH1, strideH2, offsetH + ((incol+k1)*strideH1) + (jcol*strideH2) );
				}

				// Vertical multiply
				for ( jrow = jtop; jrow <= max( KTOP, incol ) - 1; jrow += NV ) {
					jlen = min( NV, max( KTOP, incol ) - jrow );
					dgemm( 'no-transpose', 'no-transpose', jlen, nu, nu, 1.0, H, strideH1, strideH2, offsetH + (jrow*strideH1) + ((incol+k1)*strideH2), U, strideU1, strideU2, offsetU + (k1*strideU1) + (k1*strideU2), 0.0, WV, strideWV1, strideWV2, offsetWV );
					dlacpy( 'all', jlen, nu, WV, strideWV1, strideWV2, offsetWV, H, strideH1, strideH2, offsetH + (jrow*strideH1) + ((incol+k1)*strideH2) );
				}

				// Z multiply (also vertical)
				if ( wantZ ) {
					for ( jrow = iloZ; jrow <= ihiZ; jrow += NV ) {
						jlen = min( NV, ihiZ - jrow + 1 );
						dgemm( 'no-transpose', 'no-transpose', jlen, nu, nu, 1.0, Z, strideZ1, strideZ2, offsetZ + (jrow*strideZ1) + ((incol+k1)*strideZ2), U, strideU1, strideU2, offsetU + (k1*strideU1) + (k1*strideU2), 0.0, WV, strideWV1, strideWV2, offsetWV );
						dlacpy( 'all', jlen, nu, WV, strideWV1, strideWV2, offsetWV, Z, strideZ1, strideZ2, offsetZ + (jrow*strideZ1) + ((incol+k1)*strideZ2) );
					}
				}
			} else {
				/*
				* Updates exploiting U's 2-by-2 block structure.
				* (I2, I4, J2, J4 are the last rows and columns of the blocks.)
				*/
				i2 = floor( ( kdu + 1 ) / 2 );
				i4 = kdu;
				j2 = i4 - i2;
				j4 = kdu;

				/*
				* KZS and KNZ deal with the band of zeros along the diagonal
				* of one of the triangular blocks.
				*/
				kzs = j4 - j2 - ( ns + 1 );
				knz = ns + 1;

				// Horizontal multiply
				for ( jcol = min( ndcol, KBOT ) + 1; jcol <= jbot; jcol += NH ) {
					jlen = min( NH, jbot - jcol + 1 );

					/*
					* Copy bottom of H to top+KZS of scratch
					* (The first KZS rows get multiplied by zero.)
					*/
					dlacpy( 'all', knz, jlen, H, strideH1, strideH2, offsetH + ((incol+1+j2)*strideH1) + (jcol*strideH2), WH, strideWH1, strideWH2, offsetWH + ((kzs+1)*strideWH1) );

					// Multiply by U21**T
					dlaset( 'all', kzs, jlen, 0.0, 0.0, WH, strideWH1, strideWH2, offsetWH );
					dtrmm( 'left', 'upper', 'conjugate-transpose', 'non-unit', knz, jlen, 1.0, U, strideU1, strideU2, offsetU + ((j2+1)*strideU1) + ((1+kzs)*strideU2), WH, strideWH1, strideWH2, offsetWH + ((kzs+1)*strideWH1) );

					// Multiply top of H by U11**T
					dgemm( 'conjugate-transpose', 'no-transpose', i2, jlen, j2, 1.0, U, strideU1, strideU2, offsetU, H, strideH1, strideH2, offsetH + ((incol+1)*strideH1) + (jcol*strideH2), 1.0, WH, strideWH1, strideWH2, offsetWH );

					// Copy top of H to bottom of WH
					dlacpy( 'all', j2, jlen, H, strideH1, strideH2, offsetH + ((incol+1)*strideH1) + (jcol*strideH2), WH, strideWH1, strideWH2, offsetWH + ((i2+1)*strideWH1) );

					// Multiply by U21**T
					dtrmm( 'left', 'lower', 'conjugate-transpose', 'non-unit', j2, jlen, 1.0, U, strideU1, strideU2, offsetU + (1*strideU1) + ((i2+1)*strideU2), WH, strideWH1, strideWH2, offsetWH + ((i2+1)*strideWH1) );

					// Multiply by U22
					dgemm( 'conjugate-transpose', 'no-transpose', i4 - i2, jlen, j4 - j2, 1.0, U, strideU1, strideU2, offsetU + ((j2+1)*strideU1) + ((i2+1)*strideU2), H, strideH1, strideH2, offsetH + ((incol+1+j2)*strideH1) + (jcol*strideH2), 1.0, WH, strideWH1, strideWH2, offsetWH + ((i2+1)*strideWH1) );

					// Copy it back
					dlacpy( 'all', kdu, jlen, WH, strideWH1, strideWH2, offsetWH, H, strideH1, strideH2, offsetH + ((incol+1)*strideH1) + (jcol*strideH2) );
				}

				// Vertical multiply
				for ( jrow = jtop; jrow <= max( incol, KTOP ) - 1; jrow += NV ) {
					jlen = min( NV, max( incol, KTOP ) - jrow );

					/*
					* Copy right of H to scratch (the first KZS columns get multiplied by zero)
					*/
					dlacpy( 'all', jlen, knz, H, strideH1, strideH2, offsetH + (jrow*strideH1) + ((incol+1+j2)*strideH2), WV, strideWV1, strideWV2, offsetWV + (1*strideWV1) + ((1+kzs)*strideWV2) );

					// Multiply by U21
					dlaset( 'all', jlen, kzs, 0.0, 0.0, WV, strideWV1, strideWV2, offsetWV );
					dtrmm( 'right', 'upper', 'no-transpose', 'non-unit', jlen, knz, 1.0, U, strideU1, strideU2, offsetU + ((j2+1)*strideU1) + ((1+kzs)*strideU2), WV, strideWV1, strideWV2, offsetWV + (1*strideWV1) + ((1+kzs)*strideWV2) );

					// Multiply by U11
					dgemm( 'no-transpose', 'no-transpose', jlen, i2, j2, 1.0, H, strideH1, strideH2, offsetH + (jrow*strideH1) + ((incol+1)*strideH2), U, strideU1, strideU2, offsetU, 1.0, WV, strideWV1, strideWV2, offsetWV );

					// Copy left of H to right of scratch
					dlacpy( 'all', jlen, j2, H, strideH1, strideH2, offsetH + (jrow*strideH1) + ((incol+1)*strideH2), WV, strideWV1, strideWV2, offsetWV + (1*strideWV1) + ((1+i2)*strideWV2) );

					// Multiply by U21
					dtrmm( 'right', 'lower', 'no-transpose', 'non-unit', jlen, i4 - i2, 1.0, U, strideU1, strideU2, offsetU + (1*strideU1) + ((i2+1)*strideU2), WV, strideWV1, strideWV2, offsetWV + (1*strideWV1) + ((1+i2)*strideWV2) );

					// Multiply by U22
					dgemm( 'no-transpose', 'no-transpose', jlen, i4 - i2, j4 - j2, 1.0, H, strideH1, strideH2, offsetH + (jrow*strideH1) + ((incol+1+j2)*strideH2), U, strideU1, strideU2, offsetU + ((j2+1)*strideU1) + ((i2+1)*strideU2), 1.0, WV, strideWV1, strideWV2, offsetWV + (1*strideWV1) + ((1+i2)*strideWV2) );

					// Copy it back
					dlacpy( 'all', jlen, kdu, WV, strideWV1, strideWV2, offsetWV, H, strideH1, strideH2, offsetH + (jrow*strideH1) + ((incol+1)*strideH2) );
				}

				// Multiply Z (also vertical)
				if ( wantZ ) {
					for ( jrow = iloZ; jrow <= ihiZ; jrow += NV ) {
						jlen = min( NV, ihiZ - jrow + 1 );

						/*
						* Copy right of Z to left of scratch (first KZS columns get multiplied by zero)
						*/
						dlacpy( 'all', jlen, knz, Z, strideZ1, strideZ2, offsetZ + (jrow*strideZ1) + ((incol+1+j2)*strideZ2), WV, strideWV1, strideWV2, offsetWV + (1*strideWV1) + ((1+kzs)*strideWV2) );

						// Multiply by U12
						dlaset( 'all', jlen, kzs, 0.0, 0.0, WV, strideWV1, strideWV2, offsetWV );
						dtrmm( 'right', 'upper', 'no-transpose', 'non-unit', jlen, knz, 1.0, U, strideU1, strideU2, offsetU + ((j2+1)*strideU1) + ((1+kzs)*strideU2), WV, strideWV1, strideWV2, offsetWV + (1*strideWV1) + ((1+kzs)*strideWV2) );

						// Multiply by U11
						dgemm( 'no-transpose', 'no-transpose', jlen, i2, j2, 1.0, Z, strideZ1, strideZ2, offsetZ + (jrow*strideZ1) + ((incol+1)*strideZ2), U, strideU1, strideU2, offsetU, 1.0, WV, strideWV1, strideWV2, offsetWV );

						// Copy left of Z to right of scratch
						dlacpy( 'all', jlen, j2, Z, strideZ1, strideZ2, offsetZ + (jrow*strideZ1) + ((incol+1)*strideZ2), WV, strideWV1, strideWV2, offsetWV + (1*strideWV1) + ((1+i2)*strideWV2) );

						// Multiply by U21
						dtrmm( 'right', 'lower', 'no-transpose', 'non-unit', jlen, i4 - i2, 1.0, U, strideU1, strideU2, offsetU + (1*strideU1) + ((i2+1)*strideU2), WV, strideWV1, strideWV2, offsetWV + (1*strideWV1) + ((1+i2)*strideWV2) );

						// Multiply by U22
						dgemm( 'no-transpose', 'no-transpose', jlen, i4 - i2, j4 - j2, 1.0, Z, strideZ1, strideZ2, offsetZ + (jrow*strideZ1) + ((incol+1+j2)*strideZ2), U, strideU1, strideU2, offsetU + ((j2+1)*strideU1) + ((i2+1)*strideU2), 1.0, WV, strideWV1, strideWV2, offsetWV + (1*strideWV1) + ((1+i2)*strideWV2) );

						// Copy the result back to Z
						dlacpy( 'all', jlen, kdu, WV, strideWV1, strideWV2, offsetWV, Z, strideZ1, strideZ2, offsetZ + (jrow*strideZ1) + ((incol+1)*strideZ2) );
					}
				}
			}
		}
	}
}
 
 
// EXPORTS //
 
module.exports = dlaqr5;