Skip to content

Commit 5636f41

Browse files
Shabareesh ShettyShabareesh Shetty
authored andcommitted
refactor: reduce arithmetic operations
--- 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 9cea5f5 commit 5636f41

File tree

1 file changed

+22
-13
lines changed
  • lib/node_modules/@stdlib/blas/base/dtbmv/lib

1 file changed

+22
-13
lines changed

lib/node_modules/@stdlib/blas/base/dtbmv/lib/base.js

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var min = require( '@stdlib/math/base/special/min' );
4141
* @param {integer} strideA2 - stride of the second dimension of `A`
4242
* @param {NonNegativeInteger} offsetA - starting index for `A`
4343
* @param {Float64Array} x - input vector
44-
* @param {integer} strideX - `x` stride length
44+
* @param {integer} strideX - stride length for `x`
4545
* @param {NonNegativeInteger} offsetX - starting index for `x`
4646
* @returns {Float64Array} `x`
4747
*
@@ -57,14 +57,16 @@ var min = require( '@stdlib/math/base/special/min' );
5757
function dtbmv( uplo, trans, diag, N, K, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-params, max-len
5858
var nonunit;
5959
var isrm;
60-
var idx;
60+
var ida;
6161
var tmp;
6262
var sa0;
6363
var sa1;
6464
var ix0;
6565
var ix1;
66+
var oa2;
6667
var i0;
6768
var i1;
69+
var ia;
6870
var oa;
6971
var ox;
7072

@@ -92,12 +94,14 @@ function dtbmv( uplo, trans, diag, N, K, A, strideA1, strideA2, offsetA, x, stri
9294
oa = offsetA + ( sa1 * i1 );
9395
tmp = x[ ix1 ];
9496
if ( nonunit ) {
95-
tmp = A[ oa + ( sa0 * K ) ] * x[ ix1 ];
97+
oa2 = oa + ( sa0 * K );
98+
tmp = A[ oa2 ] * x[ ix1 ];
9699
}
97100
for ( i0 = i1 + 1; i0 <= min( N - 1, i1 + K ); i0++ ) {
98101
ix0 = ox + ( i0 * strideX );
99-
idx = oa + ( sa0 * ( K + i0 - i1 ) );
100-
tmp += A[ idx ] * x[ ix0 ];
102+
ia = sa0 * ( K + i0 - i1 );
103+
ida = oa + ia;
104+
tmp += A[ ida ] * x[ ix0 ];
101105
}
102106
x[ ix1 ] = tmp;
103107
ix1 += strideX;
@@ -113,12 +117,14 @@ function dtbmv( uplo, trans, diag, N, K, A, strideA1, strideA2, offsetA, x, stri
113117
oa = offsetA;
114118
tmp = x[ ix1 ];
115119
if ( nonunit ) {
116-
tmp = A[ oa + ( sa1 * i1 ) ] * x[ ix1 ];
120+
oa2 = oa + ( sa1 * K );
121+
tmp = A[ oa2 ] * x[ ix1 ];
117122
}
118123
for ( i0 = max( 0, i1 - K ); i0 < i1; i0++ ) {
119-
idx = oa + ( sa1 * i0 ) + ( sa0 * ( i1 - i0 ) );
124+
ia = sa0 * ( i1 - i0 );
125+
ida = oa + ( sa1 * i0 ) + ia;
120126
ix0 = ox + ( i0 * strideX );
121-
tmp += A[ idx ] * x[ ix0 ];
127+
tmp += A[ ida ] * x[ ix0 ];
122128
}
123129
x[ ix1 ] = tmp;
124130
ix1 -= strideX;
@@ -134,12 +140,14 @@ function dtbmv( uplo, trans, diag, N, K, A, strideA1, strideA2, offsetA, x, stri
134140
oa = offsetA + ( sa1 * i1 );
135141
tmp = x[ ix1 ];
136142
if ( nonunit ) {
137-
tmp = A[ oa + ( sa0 * K ) ] * x[ ix1 ];
143+
oa2 = oa + ( sa0 * K );
144+
tmp = A[ oa2 ] * x[ ix1 ];
138145
}
139146
for ( i0 = max( 0, i1 - K ); i0 < i1; i0++ ) {
140-
idx = oa + ( sa0 * ( K + i0 - i1 ) );
147+
ia = sa0 * ( K + i0 - i1 );
148+
ida = oa + ia;
141149
ix0 = ox + ( i0 * strideX );
142-
tmp += A[ idx ] * x[ ix0 ];
150+
tmp += A[ ida ] * x[ ix0 ];
143151
}
144152
x[ ix1 ] = tmp;
145153
ix1 -= strideX;
@@ -156,8 +164,9 @@ function dtbmv( uplo, trans, diag, N, K, A, strideA1, strideA2, offsetA, x, stri
156164
}
157165
for ( i0 = i1 + 1; i0 <= min( N - 1, i1 + K ); i0++ ) {
158166
ix0 = ox + ( i0 * strideX );
159-
idx = oa + ( sa0 * ( i0 - i1 ) );
160-
tmp += A[ idx ] * x[ ix0 ];
167+
ia = sa0 * ( i0 - i1 );
168+
ida = oa + ia;
169+
tmp += A[ ida ] * x[ ix0 ];
161170
}
162171
x[ ix1 ] = tmp;
163172
ix1 += strideX;

0 commit comments

Comments
 (0)