Skip to content

Commit 253a601

Browse files
refactor: eliminate the row-major check for each element
--- 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent c4adfea commit 253a601

1 file changed

Lines changed: 20 additions & 13 deletions

File tree

  • lib/node_modules/@stdlib/lapack/base/dgetc2/lib

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

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,31 +114,38 @@ function dgetc2( N, A, strideA1, strideA2, offsetA, IPIV, strideIPIV, offsetIPIV
114114
// Find max element in matrix A
115115
xmax = 0.0;
116116

117+
ix1 = offsetA + ( i*( strideA1 + strideA2 ) ); // Index of `A( i, i )`
118+
117119
if ( isRowMajor( [ strideA1, strideA2 ] ) ) {
118120
dx0 = strideA2;
119121
dx1 = strideA1 - ( N*strideA2 ) + ( i*dx0 );
122+
123+
for ( i1 = i; i1 < N; i1++ ) {
124+
for ( i0 = i; i0 < N; i0++ ) {
125+
if ( abs( A[ ix1 ] ) >= xmax ) {
126+
xmax = abs( A[ ix1 ] );
127+
ipv = i1;
128+
jpv = i0;
129+
}
130+
ix1 += dx0;
131+
}
132+
ix1 += dx1;
133+
}
120134
} else { // column-major
121135
dx0 = strideA1;
122136
dx1 = strideA2 - ( N*strideA1 ) + ( i*dx0 );
123-
}
124-
125-
ix1 = offsetA + ( i*( strideA1 + strideA2 ) ); // Index of `A( i, i )`
126137

127-
for ( i1 = i; i1 < N; i1++ ) {
128-
for ( i0 = i; i0 < N; i0++ ) {
129-
if ( abs( A[ ix1 ] ) >= xmax ) {
130-
xmax = abs( A[ ix1 ] );
131-
if ( isRowMajor( [ strideA1, strideA2 ] ) ) {
132-
ipv = i1;
133-
jpv = i0;
134-
} else { // column-major
138+
for ( i1 = i; i1 < N; i1++ ) {
139+
for ( i0 = i; i0 < N; i0++ ) {
140+
if ( abs( A[ ix1 ] ) >= xmax ) {
141+
xmax = abs( A[ ix1 ] );
135142
ipv = i0;
136143
jpv = i1;
137144
}
145+
ix1 += dx0;
138146
}
139-
ix1 += dx0;
147+
ix1 += dx1;
140148
}
141-
ix1 += dx1;
142149
}
143150

144151
if ( i === 0 ) {

0 commit comments

Comments
 (0)