Skip to content

Commit 7f1a1c7

Browse files
committed
refactor: undo precomputing indices because its not performant
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 42f9f66 commit 7f1a1c7

File tree

1 file changed

+36
-50
lines changed
  • lib/node_modules/@stdlib/lapack/base/dgttrf/lib

1 file changed

+36
-50
lines changed

lib/node_modules/@stdlib/lapack/base/dgttrf/lib/base.js

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ var abs = require( '@stdlib/math/base/special/abs' );
3030
*
3131
* ## Notes
3232
*
33-
* - On exit, `DL` is overwritten by the multipliers that define the matrix `L` from the `LU` factorization of `A`.
34-
* - On exit, `D` is overwritten by the diagonal elements of the upper triangular matrix `U` from the `LU` factorization of `A`.
35-
* - On exit, `DU` is overwritten by the elements of the first super-diagonal of `U`.
36-
* - On exit, `DU2` is overwritten by the elements of the second super-diagonal of `U`.
37-
* - On exit, for 0 <= i < n, row i of the matrix was interchanged with row IPIV(i). IPIV(i) will always be either i or i+1; IPIV(i) = i indicates a row interchange was not required.
33+
* - `DL` is overwritten by the multipliers that define the matrix `L` from the `LU` factorization of `A`.
34+
* - `D` is overwritten by the diagonal elements of the upper triangular matrix `U` from the `LU` factorization of `A`.
35+
* - `DU` is overwritten by the elements of the first super-diagonal of `U`.
36+
* - `DU2` is overwritten by the elements of the second super-diagonal of `U`.
37+
* - For 0 <= i < n, row i of the matrix was interchanged with row IPIV(i). IPIV(i) will always be either i or i+1; IPIV(i) = i indicates a row interchange was not required.
3838
*
3939
* @private
40-
* @param {NonNegativeInteger} N - order of matrix A.
41-
* @param {Float64Array} DL - sub diagonal elements of A.
40+
* @param {NonNegativeInteger} N - order of matrix A
41+
* @param {Float64Array} DL - sub diagonal elements of A
4242
* @param {integer} strideDL - stride length for `DL`
4343
* @param {NonNegativeInteger} offsetDL - starting index of `DL`
44-
* @param {Float64Array} D - diagonal elements of A.
44+
* @param {Float64Array} D - diagonal elements of A
4545
* @param {integer} strideD - stride length for `D`
4646
* @param {NonNegativeInteger} offsetD - starting index of `D`
47-
* @param {Float64Array} DU - super diagonal elements of A.
47+
* @param {Float64Array} DU - super diagonal elements of A
4848
* @param {integer} strideDU - stride length for `DU`
4949
* @param {NonNegativeInteger} offsetDU - starting index of `DU`
5050
* @param {Float64Array} DU2 - vector to store the second super diagonal of `U`
@@ -78,12 +78,8 @@ function dgttrf( N, DL, strideDL, offsetDL, D, strideD, offsetD, DU, strideDU, o
7878
var idu2;
7979
var idu;
8080
var idl;
81-
var dli;
82-
var dui;
8381
var id;
8482
var ip;
85-
var di;
86-
var ii;
8783
var i;
8884

8985
// Quick return if possible
@@ -97,12 +93,12 @@ function dgttrf( N, DL, strideDL, offsetDL, D, strideD, offsetD, DU, strideDU, o
9793
idu2 = offsetDU2;
9894
ip = offsetIPIV;
9995

100-
// Initialise ith element of IPIV as i
96+
// Initialize ith element of IPIV as i
10197
for ( i = 0; i < N; i++ ) {
10298
IPIV[ ip ] = i;
10399

104100
if ( i < N-2 ) {
105-
// Initialise ith element of DU2 as 0
101+
// Initialize ith element of DU2 as 0
106102
DU2[ idu2 ] = 0;
107103
}
108104

@@ -115,51 +111,41 @@ function dgttrf( N, DL, strideDL, offsetDL, D, strideD, offsetD, DU, strideDU, o
115111
ip = offsetIPIV;
116112

117113
for ( i = 0; i < N-2; i++ ) {
118-
di = strideD * i;
119-
dli = strideDL * i;
120-
ii = strideIPIV * i;
121-
dui = strideDU * i;
122-
123-
if ( abs( D[ id + di ] ) >= abs( DL[ idl + dli ] ) ) { // No row interchange required, eleminate ith element of DL
114+
if ( abs( D[ id + (strideD*i) ] ) >= abs( DL[ idl + (strideDL*i) ] ) ) { // No row interchange required, eleminate ith element of DL
124115
if ( D[ id ] !== 0.0 ) {
125-
fact = DL[ idl + dli ] / D[ id + di ];
126-
DL[ idl + dli ] = fact;
127-
D[ id + di + strideD ] = D[ id + di + strideD ] - ( fact*DU[ idu + dui ] ); // eslint-disable-line max-len
116+
fact = DL[ idl + (strideDL*i) ] / D[ id + (strideD*i) ];
117+
DL[ idl + (strideDL*i) ] = fact;
118+
D[ id + (strideD*(i+1)) ] = D[ id + (strideD*(i+1)) ] - ( fact*DU[ idu + (strideDU*i) ] ); // eslint-disable-line max-len
128119
}
129120
} else { // Interchange the ith and (i+1)th rows and eliminate ith element of DL
130-
fact = D[ id + di ] / DL[ idl + dli ];
131-
D[ id + di ] = DL[ idl + dli ];
132-
DL[ idl + dli ] = fact;
133-
temp = DU[ idu + dui ];
134-
DU[ idu + dui ] = D[ id + di + strideD ];
135-
D[ id + di + strideD ] = temp - ( fact * D[ id + di + strideD ] );
136-
DU2[ idu2 + ( strideDU2 * i ) ] = DU[ idu + dui + strideDU ];
137-
DU[ idu + dui + strideDU ] = -fact * DU[ idu + dui + strideDU ];
138-
IPIV[ ip + ii ] = i + 1;
121+
fact = D[ id+(strideD*i) ] / DL[ idl+(strideDL*i) ];
122+
D[ id+(strideD*i) ] = DL[ idl+(strideDL*i) ];
123+
DL[ idl+(strideDL*i) ] = fact;
124+
temp = DU[ idu+(strideDU*i) ];
125+
DU[ idu+(strideDU*i) ] = D[ id + (strideD*(i+1)) ];
126+
D[ id+(strideD*(i+1)) ] = temp - ( fact*D[ id+(strideD*(i+1)) ] );
127+
DU2[ idu2+(strideDU2*i) ] = DU[ idu+(strideDU*(i+1)) ];
128+
DU[ idu+(strideDU*(i+1)) ] = -fact*DU[ idu+(strideDU*(i+1)) ];
129+
IPIV[ ip+(strideIPIV*i) ] = i + 1;
139130
}
140131
}
141132

142133
if ( N > 1 ) {
143134
i = N - 2;
144-
di = strideD * i;
145-
dli = strideDL * i;
146-
ii = strideIPIV * i;
147-
dui = strideDU * i;
148-
149-
if ( abs( D[ id + di ] ) >= abs( DL[ idl + dli ] ) ) {
150-
if ( D[ id + di ] !== 0 ) {
151-
fact = DL[ idl + dli ] / D[ id + di ];
152-
DL[ idl + dli ] = fact;
153-
D[ id + di + strideD ] = D[ id + di + strideD ] - (fact*DU[ idu + dui ]); // eslint-disable-line max-len
135+
if ( abs( D[ id + (strideD*i) ] ) >= abs( DL[ idl + (strideDL*i) ] ) ) {
136+
if ( D[ id + (strideD*i) ] !== 0 ) {
137+
fact = DL[ idl + (strideDL*i) ] / D[ id + (strideD*i) ];
138+
DL[ idl + (strideDL*i) ] = fact;
139+
D[ id + (strideD*(i+1)) ] = D[ id + (strideD*(i+1)) ] - (fact*DU[ idu + (strideDU*i) ]); // eslint-disable-line max-len
154140
}
155141
} else {
156-
fact = D[ id + di ] / DL[ idl + dli ];
157-
D[ id + di ] = DL[ idl + dli ];
158-
DL[ idl + dli ] = fact;
159-
temp = DU[ idu + dui ];
160-
DU[ idu + dui ] = D[ id + di + strideD ];
161-
D[ id + di + strideD ] = temp - ( fact * D[ id + di + strideD ] );
162-
IPIV[ ip + ii ] = i + 1;
142+
fact = D[ id+(strideD*i) ] / DL[ idl+(strideDL*i) ];
143+
D[ id+(strideD*i) ] = DL[ idl+(strideDL*i) ];
144+
DL[ idl+(strideDL*i) ] = fact;
145+
temp = DU[ idu+(strideDU*i) ];
146+
DU[ idu+(strideDU*i) ] = D[ id + (strideD*(i+1)) ];
147+
D[ id+(strideD*(i+1)) ] = temp - ( fact*D[ id+(strideD*(i+1)) ] );
148+
IPIV[ ip+(strideIPIV*i) ] = i + 1;
163149
}
164150
}
165151

0 commit comments

Comments
 (0)