Skip to content

Commit a108554

Browse files
committed
refactor: pointer arithmetic
--- 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 f94763c commit a108554

File tree

1 file changed

+38
-24
lines changed
  • lib/node_modules/@stdlib/lapack/base/dgtts2/lib

1 file changed

+38
-24
lines changed

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

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@
6666
function transpose( N, nrhs, DL, strideDL, offsetDL, D, strideD, offsetD, DU, strideDU, offsetDU, DU2, strideDU2, offsetDU2, IPIV, strideIPIV, offsetIPIV, B, strideB1, strideB2, offsetB ) {
6767
var idu2;
6868
var temp;
69-
var ipi;
7069
var idu;
7170
var idl;
7271
var ib1;
7372
var ib2;
73+
var ib3;
7474
var id;
7575
var ip;
7676
var i;
7777
var j;
7878

7979
if ( nrhs <= 1 ) {
80-
ib1 = offsetB; // ib1 = offsetB + (j*strideB2);
80+
ib1 = offsetB;
8181
for ( j = 0; j < nrhs; j++) {
8282
ip = offsetIPIV + ( (N-2) * strideIPIV );
8383
idl = offsetDL + ( (N-2) * strideDL );
@@ -105,10 +105,10 @@ function transpose( N, nrhs, DL, strideDL, offsetDL, D, strideD, offsetD, DU, st
105105

106106
ib2 = strideB1 * ( N-2 );
107107
for ( i = N - 2; i >= 0; i-- ) {
108-
ipi = IPIV[ ip ];
108+
ib3 = offsetB + ( strideB1 * IPIV[ ip ] ) + ( strideB2 * j );
109109
temp = B[ ib1 + ib2 ] - ( DL[ idl ] * B[ ib1 + ib2 + strideB1 ] );
110-
B[ ib1 + ib2 ] = B[ offsetB + (strideB1*ipi) + (strideB2*j) ];
111-
B[ offsetB + (strideB1*ipi) + (strideB2*j) ] = temp;
110+
B[ ib1 + ib2 ] = B[ ib3 ];
111+
B[ ib3 ] = temp;
112112

113113
ip -= strideIPIV;
114114
idl -= strideDL;
@@ -211,79 +211,93 @@ function noTranspose( N, nrhs, DL, strideDL, offsetDL, D, strideD, offsetD, DU,
211211
var ipi;
212212
var idl;
213213
var idu;
214+
var ib3;
215+
var ib1;
216+
var ib2;
214217
var ip;
215218
var id;
216219
var j;
217220
var i;
218221

219222
if ( nrhs <= 1 ) {
223+
ib1 = offsetB;
220224
for ( j = 0; j < nrhs; j++ ) {
221225
ip = offsetIPIV;
222226
idl = offsetDL;
223227
id = offsetD;
224-
idu = offsetDU;
225228
idu2 = offsetDU2;
226229

230+
ib2 = 0;
227231
for ( i = 0; i < N - 1; i++ ) {
228232
ipi = IPIV[ ip ];
229-
temp = B[ offsetB + (strideB1*(i+1-ipi+i)) + (strideB2*j) ] - ( DL[ idl ] * B[ offsetB + (strideB1*ipi) + (strideB2*j) ] );
230-
B[ offsetB + (strideB1*i) + (strideB2*j) ] = B[ offsetB + (strideB1*ipi) + (strideB2*j) ];
231-
B[ offsetB + (strideB1*(i+1)) + (strideB2*j) ] = temp;
233+
ib3 = offsetB + (strideB1*ipi) + (strideB2*j);
234+
temp = B[ offsetB + (strideB1*(i+1-ipi+i)) + (strideB2*j) ] - ( DL[ idl ] * B[ ib3 ] );
235+
B[ ib1 + ib2 ] = B[ ib3 ];
236+
B[ ib1 + ib2 + strideB1 ] = temp;
232237

233238
ip += strideIPIV;
234239
idl += strideDL;
240+
ib2 += strideB1;
235241
}
236242

237-
B[ offsetB + (strideB1*(N-1)) + (strideB2*j) ] /= D[ offsetD + (strideD*(N-1)) ];
243+
B[ ib1 + ib2 ] /= D[ offsetD + (strideD*(N-1)) ];
238244

245+
idu = offsetDU + ( (N-3) * strideDU );
246+
id = offsetD + ( (N-3) * strideD );
239247
if ( N > 1 ) {
240-
B[ offsetB + (strideB1*(N-2)) + (strideB2*j) ] = ( B[ offsetB + (strideB1*(N-2)) + (strideB2*j) ] - ( DU[ offsetDU + (strideDU*(N-2)) ] * B[ offsetB + (strideB1*(N-1)) + (strideB2*j) ] ) ) / D[ offsetD + (strideD*(N-2)) ];
248+
B[ ib1 + ib2 - strideB1 ] = ( B[ ib1 + ib2 - strideB1 ] - ( DU[ idu + strideDU ] * B[ ib1 + ib2 ] ) ) / D[ id + strideD ];
241249
}
242250

243-
idu = offsetDU + ( (N-3) * strideDU );
244251
idu2 = offsetDU2 + ( (N-3) * strideDU2 );
245-
id = offsetD + ( (N-3) * strideD );
252+
ib2 = ( N - 3 ) * strideB1;
246253
for ( i = N - 3; i >= 0; i-- ) {
247-
B[ offsetB + (strideB1*i) + (strideB2*j) ] = ( B[ offsetB + (strideB1*i) + (strideB2*j) ] - ( DU[ idu ] * B[ offsetB + (strideB1*(i+1)) + (strideB2*j) ] ) - ( DU2[ idu2 ] * B[ offsetB + (strideB1*(i+2)) + (strideB2*j) ] ) ) / D[ id ];
254+
B[ ib1 + ib2 ] = ( B[ ib1 + ib2 ] - ( DU[ idu ] * B[ ib1 + ib2 + strideB1 ] ) - ( DU2[ idu2 ] * B[ ib1 + ib2 + ( 2 * strideB1 ) ] ) ) / D[ id ];
248255

249256
idu -= strideDU;
250257
idu2 -= strideDU2;
251258
id -= strideD;
259+
ib2 -= strideB1;
252260
}
261+
ib1 += strideB2;
253262
}
254263
} else {
264+
ib1 = offsetB;
255265
for ( j = 0; j < nrhs; j++ ) {
256266
ip = offsetIPIV;
257267
idl = offsetDL;
258-
268+
ib2 = 0;
259269
for ( i = 0; i < N - 1; i++ ) {
260270
if ( IPIV[ ip ] === i ) {
261-
B[ offsetB + (strideB1*(i+1)) + (strideB2*j) ] -= DL[ idl ] * B[ offsetB + (strideB1*i) + (strideB2*j) ];
271+
B[ ib1 + ib2 + strideB1 ] -= DL[ idl ] * B[ ib1 + ib2 ];
262272
} else {
263-
temp = B[ offsetB + (strideB1*i) + (strideB2*j) ];
264-
B[ offsetB + (strideB1*i) + (strideB2*j) ] = B[ offsetB + (strideB1*(i+1)) + (strideB2*j) ];
265-
B[ offsetB + (strideB1*(i+1)) + (strideB2*j) ] = temp - ( DL[ idl ] * B[ offsetB + (strideB1*i) + (strideB2*j) ] );
273+
temp = B[ ib1 + ib2 ];
274+
B[ ib1 + ib2 ] = B[ ib1 + ib2 + strideB1 ];
275+
B[ ib1 + ib2 + strideB1 ] = temp - ( DL[ idl ] * B[ ib1 + ib2 ] );
266276
}
267277

268278
ip += strideIPIV;
269279
idl += strideDL;
280+
ib2 += strideB1;
270281
}
271-
B[ offsetB + (strideB1*(N-1)) + (strideB2*j) ] /= D[ offsetD + (strideD*(N-1)) ];
282+
B[ ib1 + ib2 ] /= D[ offsetD + (strideD*(N-1)) ];
272283

284+
idu = offsetDU + ( (N-3) * strideDU );
285+
id = offsetD + ( (N-3) * strideD );
273286
if ( N > 1 ) {
274-
B[ offsetB + (strideB1*(N-2)) + (strideB2 * j) ] = ( B[ offsetB + (strideB1*(N-2)) + (strideB2*j) ] - ( DU[ offsetDU + (strideDU*(N-2)) ] * B[ offsetB + (strideB1*(N-1)) + (strideB2*j) ] ) ) / D[ offsetD + (strideD*(N-2)) ];
287+
B[ ib1 + ib2 - strideB1 ] = ( B[ ib1 + ib2 - strideB1 ] - ( DU[ idu + strideDU ] * B[ ib1 + ib2 ] ) ) / D[ id + strideD ];
275288
}
276289

277-
idu = offsetDU + ( (N-3) * strideDU );
278290
idu2 = offsetDU2 + ( (N-3) * strideDU2 );
279-
id = offsetD + ( (N-3) * strideD );
291+
ib2 = ( N - 3 ) * strideB1;
280292
for ( i = N - 3; i >= 0; i-- ) {
281-
B[ offsetB + (strideB1*i) + (strideB2*j) ] = ( B[ offsetB + (strideB1*i) + (strideB2*j) ] - ( DU[ idu ] * B[ offsetB + (strideB1*(i+1)) + (strideB2*j) ] ) - ( DU2[ idu2 ] * B[ offsetB + (strideB1*(i+2)) + (strideB2*j) ] ) ) / D[ id ];
293+
B[ ib1 + ib2 ] = ( B[ ib1 + ib2 ] - ( DU[ idu ] * B[ ib1 + ib2 + strideB1 ] ) - ( DU2[ idu2 ] * B[ ib1 + ib2 + ( 2 * strideB1 ) ] ) ) / D[ id ];
282294

283295
idu -= strideDU;
284296
idu2 -= strideDU2;
285297
id -= strideD;
286298
}
299+
300+
ib1 += strideB2;
287301
}
288302
}
289303

0 commit comments

Comments
 (0)