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 | 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 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 46x 2x 2x 44x 44x 44x 44x 44x 44x 46x 8x 8x 36x 46x 22x 22x 22x 22x 66x 66x 66x 66x 140x 140x 140x 140x 66x 66x 66x 46x 14x 14x 14x 14x 42x 42x 42x 42x 92x 92x 92x 92x 42x 42x 42x 14x 36x 46x 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' );
// MAIN //
/**
* Equilibrates a real symmetric matrix `A` stored in packed format using scaling factors `S`.
*
* @private
* @param {boolean} isUpper - boolean indicating whether `AP` contains the upper triangular part of `A` stored in column-major order
* @param {NonNegativeInteger} N - order of matrix `A`
* @param {Float64Array} AP - packed symmetric matrix `A`
* @param {integer} strideAP - `AP` stride length
* @param {NonNegativeInteger} offsetAP - starting index of `AP`
* @param {Float64Array} S - scale factors vector
* @param {integer} strideS - `S` stride length
* @param {NonNegativeInteger} offsetS - starting index of `S`
* @param {number} scond - ratio of smallest `S[i]` to largest `S[i]`
* @param {number} amax - absolute value of largest matrix entry
* @returns {string} character flag indicating whether the matrix was equilibrated ('Y') or not ('N')
*/
function dlaqsp( isUpper, N, AP, strideAP, offsetAP, S, strideS, offsetS, scond, amax ) { // eslint-disable-line max-len
var thresh;
var small;
var large;
var iap;
var cj;
var jc;
var is;
var js;
var i;
var j;
if ( N <= 0 ) {
return 'N';
}
thresh = 0.1;
small = dlamch( 'Safe minimum' ) / dlamch( 'Precision' );
large = 1.0 / small;
// If the matrix is already well-conditioned (`scond` above threshold) and its largest entry is within safe bounds, no equilibration is needed...
if ( scond >= thresh && amax >= small && amax <= large ) {
return 'N';
}
// Replace A by diag(S) * A * diag(S):
if ( isUpper ) {
// Upper triangle of A is stored:
jc = 0;
js = offsetS;
for ( j = 0; j < N; j++ ) {
cj = S[ js ];
iap = offsetAP + ( jc * strideAP );
is = offsetS;
for ( i = 0; i <= j; i++ ) {
AP[ iap ] *= cj * S[ is ];
iap += strideAP;
is += strideS;
}
jc += j + 1;
js += strideS;
}
} else {
// Lower triangle of A is stored:
jc = 0;
js = offsetS;
for ( j = 0; j < N; j++ ) {
cj = S[ js ];
iap = offsetAP + ( jc * strideAP );
is = js;
for ( i = j; i < N; i++ ) {
AP[ iap ] *= cj * S[ is ];
iap += strideAP;
is += strideS;
}
jc += N - j;
js += strideS;
}
}
return 'Y';
}
// EXPORTS //
module.exports = dlaqsp;
|