All files dlasq6.js

77.72% Statements 171/220
15.38% Branches 2/13
100% Functions 1/1
77.72% Lines 171/220

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 2213x 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 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 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 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.
*/
 
'use strict';
 
// MODULES //
 
var dlamch = require( '@stdlib/lapack/base/dlamch' );
var min = require( '@stdlib/math/base/special/min' );
 
 
// VARIABLES //
 
var SFMIN = dlamch( 'S' );
 
 
// MAIN //
 
/**
* Computes one dqd transform in ping-pong form.
*
* ## Notes
*
* -   Z is a 1-D array of length >= 4*N0 storing interleaved q/e values.
* -   PP is 0 for ping, 1 for pong.
*
* @private
* @param {integer} I0 - the first index
* @param {integer} N0 - the last index
* @param {Float64Array} Z - the QD array
* @param {integer} strideZ - stride length for `z`
* @param {NonNegativeInteger} offsetZ - starting index for `z`
* @param {boolean} PP - ping-pong flag (0 or 1)
* @param {Float64Array} out - output array containing `DMIN`, `DMIN1`, `DMIN2`, `DN`, `DNM1`, and `DNM2` respectively
* @param {integer} strideOut - stride length for `out`
* @param {NonNegativeInteger} offsetOut - starting index of `out`
* @returns {Float64Array} output array
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var out = new Float64Array( 6 );
* var Z = new Float64Array( [ 5, 0, 7, 0, 9, 0, 3, 0, 11, 0, 4, 0, 20, 0, 0, 0 ] );
*
* dlasq6( 0, 3, Z, 1, 0, 0, out, 1, 0 );
* // out => <Float64Array>[ 3.75, 3.75, 3.75, ~12.088, ~6.111, 3.75 ]
*/
function dlasq6( I0, N0, Z, strideZ, offsetZ, PP, out, strideOut, offsetOut ) {
	var dmin1;
	var dmin2;
	var dnm1;
	var dnm2;
	var emin;
	var dmin;
	var temp;
	var j4p2;
	var idx;
	var iz1;
	var iz2;
	var iz3;
	var iz4;
	var j4;
	var dn;
	var d;
 
	// Quick return...
	if ( ( N0 - I0 - 1 ) <= 0 ) {
		return out;
	}
 
	idx = offsetZ;
 
	j4 = offsetZ + ( strideZ*( ( 4*I0 ) + PP ) );
	emin = Z[ j4 + ( 4*strideZ ) ];
	d = Z[ j4 ];
	dmin = d;
 
	j4 = offsetZ + ( strideZ*( ( 4*I0 ) + 3 ) );
 
	if ( PP === 0 ) {
		for ( idx = ( 4*I0 ) + 3; idx <= ( 4*N0 ) - 9; idx += 4 ) {
			iz1 = j4 + strideZ;
			iz2 = j4 - strideZ;
			iz3 = j4 - ( 2*strideZ );
 
			Z[ iz3 ] = d + Z[ iz2 ];
			if ( Z[ iz3 ] === 0 ) {
				Z[ j4 ] = 0;
				d = Z[ iz1 ];
				dmin = d;
				emin = 0;
			} else if ( ( SFMIN*Z[ iz1 ] < Z[ iz3 ] ) &&
				( SFMIN*Z[ iz3 ] < Z[ iz1 ] ) ) {
				temp = Z[ iz1 ] / Z[ iz3 ];
				Z[ j4 ] = Z[ iz2 ]*temp;
				d *= temp;
			} else {
				Z[ j4 ] = Z[ iz1 ]*( Z[ iz2 ] / Z[ iz3 ] );
				d = Z[ iz1 ]*( d / Z[ iz3 ] );
			}
			dmin = min( dmin, d );
			emin = min( emin, Z[ j4 ] );
			j4 += 4*strideZ;
		}
	} else {
		for ( idx = ( 4*I0 ) + 3; idx <= ( 4*N0 ) - 9; idx += 4 ) {
			iz1 = j4 + ( 2*strideZ );
			iz2 = j4 - strideZ;
			iz3 = j4 - ( 2*strideZ );
			iz4 = j4 - ( 3*strideZ );

			Z[ iz4 ] = d + Z[ j4 ];
			if ( Z[ iz4 ] === 0 ) {
				Z[ iz2 ] = 0;
				d = Z[ iz1 ];
				dmin = d;
				emin = 0;
			} else if ( ( SFMIN*Z[ iz1 ] < Z[ iz4 ] ) &&
				( SFMIN*Z[ iz4 ] < Z[ iz1 ] ) ) {
				temp = Z[ iz1 ] / Z[ iz4 ];
				Z[ j4 - strideZ ] = Z[ j4 ]*temp;
				d *= temp;
			} else {
				Z[ iz2 ] = Z[ iz1 ]*( Z[ j4 ] / Z[ iz4 ] );
				d = Z[ iz1 ]*( d / Z[ iz4 ] );
			}
			dmin = min( dmin, d );
			emin = min( emin, Z[ iz2 ] );
			j4 += 4*strideZ;
		}
	}
 
	// Unroll last two steps.
	dnm2 = d;
	dmin2 = dmin;
	j4 = offsetZ + ( strideZ*( ( 4*N0 ) - 5 - PP ) );
	j4p2 = j4 + ( strideZ*( ( 2*PP ) - 1 ) );
 
	iz1 = j4 - ( 2*strideZ );
	iz2 = j4p2 + ( 2*strideZ );
 
	Z[ j4 - ( 2*strideZ ) ] = dnm2 + Z[ j4p2 ];
	if ( Z[ iz1 ] === 0 ) {
		Z[ j4 ] = 0;
		dnm1 = Z[ iz2 ];
		dmin = dnm1;
		emin = 0;
	} else if ( ( SFMIN*Z[ iz2 ] < Z[ iz1 ] ) &&
		( SFMIN*Z[ iz1 ] < Z[ iz2 ] ) ) {
		temp = Z[ iz2 ] / Z[ iz1 ];
		Z[ j4 ] = Z[ j4p2 ]*temp;
		dnm1 = dnm2*temp;
	} else {
		Z[ j4 ] = Z[ iz2 ]*( Z[ j4p2 ] / Z[ iz1 ] );
		dnm1 = Z[ iz2 ]*( dnm2 / Z[ iz1 ] );
	}
	dmin = min( dmin, dnm1 );
 
	dmin1 = dmin;
	j4 += 4*strideZ;
	j4p2 = j4 + ( strideZ*( ( 2*PP ) - 1 ) );
 
	iz1 = j4 - ( 2*strideZ );
	iz2 = j4p2 + ( 2*strideZ );
 
	Z[ iz1 ] = dnm1 + Z[ j4p2 ];
	if ( Z[ iz1 ] === 0 ) {
		Z[ j4 ] = 0;
		dn = Z[ iz2 ];
		dmin = dn;
		emin = 0;
	} else if ( ( SFMIN*Z[ iz2 ] < Z[ iz1 ] ) &&
		( SFMIN*Z[ iz1 ] < Z[ iz2 ] ) ) {
		temp = Z[ iz2 ] / Z[ iz1 ];
		Z[ j4 ] = Z[ j4p2 ]*temp;
		dn = dnm1*temp;
	} else {
		Z[ j4 ] = Z[ iz2 ]*( Z[ j4p2 ] / Z[ iz1 ] );
		dn = Z[ iz2 ]*( dnm1 / Z[ iz1 ] );
	}
	dmin = min( dmin, dn );
 
	Z[ j4 + ( 2*strideZ ) ] = dn;
	Z[ offsetZ + ( strideZ*( ( 4*( N0 ) ) + 3 - PP ) ) ] = emin;
 
	idx = offsetOut;
	out[ idx ] = dmin;
	idx += strideOut;
	out[ idx ] = dmin1;
	idx += strideOut;
	out[ idx ] = dmin2;
	idx += strideOut;
	out[ idx ] = dn;
	idx += strideOut;
	out[ idx ] = dnm1;
	idx += strideOut;
	out[ idx ] = dnm2;
 
	return out;
}
 
 
// EXPORTS //
 
module.exports = dlasq6;