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 | 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 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 6x 6x 19x 19x 19x 19x 19x 19x 25x 56x 56x 56x 19x 19x 19x 25x 60x 60x 60x 177x 177x 177x 177x 60x 60x 19x 19x 19x 19x 19x 25x 56x 56x 56x 56x 19x 19x 25x 1x 1x 1x 2x 1x 1x 1x 1x 25x 18x 18x 18x 53x 53x 53x 18x 18x 18x 18x 18x 18x 25x 58x 58x 58x 18x 18x 18x 18x 25x 58x 58x 58x 171x 171x 171x 171x 58x 58x 58x 18x 18x 18x 18x 18x 25x 58x 58x 58x 58x 18x 25x 1x 1x 1x 2x 1x 1x 1x 1x 25x 17x 17x 17x 55x 55x 55x 17x 17x 17x 17x 17x 25x 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 FLOAT64_SMALLEST_NORMAL = require( '@stdlib/constants/float64/smallest-normal' );
var abs = require( '@stdlib/math/base/special/abs' );
var max = require( '@stdlib/math/base/special/max' );
var min = require( '@stdlib/math/base/special/min' );
// MAIN //
/**
* Computes row and column scaling factors intended to equilibrate an M-by-N real matrix `A` and reduce its condition number.
*
* @private
* @param {NonNegativeInteger} M - number of rows of matrix `A`
* @param {NonNegativeInteger} N - number of columns of matrix `A`
* @param {Float64Array} A - input matrix
* @param {integer} strideA1 - stride of the first dimension of `A`
* @param {integer} strideA2 - stride of the second dimension of `A`
* @param {NonNegativeInteger} offsetA - starting index for `A`
* @param {Float64Array} R - output row scale factors
* @param {integer} strideR - stride length for `R`
* @param {NonNegativeInteger} offsetR - starting index for `R`
* @param {Float64Array} C - output column scale factors
* @param {integer} strideC - stride length for `C`
* @param {NonNegativeInteger} offsetC - starting index for `C`
* @returns {Array} a 4-element array containing `[ rowcnd, colcnd, amax, info ]`
*/
function dgeequ( M, N, A, strideA1, strideA2, offsetA, R, strideR, offsetR, C, strideC, offsetC ) { // eslint-disable-line max-len, max-params
var smlnum;
var bignum;
var rowcnd;
var colcnd;
var rcmin;
var rcmax;
var amax;
var iaJ;
var ia;
var ir;
var ic;
var i;
var j;
if ( M === 0 || N === 0 ) {
return [ 1.0, 1.0, 0.0, 0 ];
}
smlnum = FLOAT64_SMALLEST_NORMAL;
bignum = 1.0 / smlnum;
// Initialize R to zero:
ir = offsetR;
for ( i = 0; i < M; i++ ) {
R[ ir ] = 0.0;
ir += strideR;
}
// Find the maximum element in each row:
iaJ = offsetA;
for ( j = 0; j < N; j++ ) {
ia = iaJ;
ir = offsetR;
for ( i = 0; i < M; i++ ) {
R[ ir ] = max( R[ ir ], abs( A[ ia ] ) );
ia += strideA1;
ir += strideR;
}
iaJ += strideA2;
}
// Find the maximum and minimum row scale factors:
rcmin = bignum;
rcmax = 0.0;
ir = offsetR;
for ( i = 0; i < M; i++ ) {
rcmax = max( rcmax, R[ ir ] );
rcmin = min( rcmin, R[ ir ] );
ir += strideR;
}
amax = rcmax;
if ( rcmin === 0.0 ) {
// Find the first zero scale factor and return an error code:
ir = offsetR;
for ( i = 0; i < M; i++ ) {
if ( R[ ir ] === 0.0 ) {
return [ 0.0, 0.0, amax, i + 1 ];
}
ir += strideR;
}
} else {
// Invert the scale factors:
ir = offsetR;
for ( i = 0; i < M; i++ ) {
R[ ir ] = 1.0 / min( max( R[ ir ], smlnum ), bignum );
ir += strideR;
}
// Compute ROWCND = min(R(i)) / max(R(i))
rowcnd = max( rcmin, smlnum ) / min( rcmax, bignum );
}
// Initialize C to zero:
ic = offsetC;
for ( j = 0; j < N; j++ ) {
C[ ic ] = 0.0;
ic += strideC;
}
// Find the maximum element in each column, assuming the row scaling:
iaJ = offsetA;
ic = offsetC;
for ( j = 0; j < N; j++ ) {
ia = iaJ;
ir = offsetR;
for ( i = 0; i < M; i++ ) {
C[ ic ] = max( C[ ic ], abs( A[ ia ] ) * R[ ir ] );
ia += strideA1;
ir += strideR;
}
iaJ += strideA2;
ic += strideC;
}
// Find the maximum and minimum col scale factors:
rcmin = bignum;
rcmax = 0.0;
ic = offsetC;
for ( j = 0; j < N; j++ ) {
rcmin = min( rcmin, C[ ic ] );
rcmax = max( rcmax, C[ ic ] );
ic += strideC;
}
if ( rcmin === 0.0 ) {
// Find the first zero scale factor and return an error code:
ic = offsetC;
for ( j = 0; j < N; j++ ) {
if ( C[ ic ] === 0.0 ) {
return [ rowcnd, 0.0, amax, M + j + 1 ];
}
ic += strideC;
}
} else {
// Invert the scale factors:
ic = offsetC;
for ( j = 0; j < N; j++ ) {
C[ ic ] = 1.0 / min( max( C[ ic ], smlnum ), bignum );
ic += strideC;
}
// Compute COLCND = min(C(j)) / max(C(j))
colcnd = max( rcmin, smlnum ) / min( rcmax, bignum );
}
return [ rowcnd, colcnd, amax, 0 ];
}
// EXPORTS //
module.exports = dgeequ;
|