Skip to content

Commit a41c427

Browse files
committed
refactor: reduce pointer 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: passed - 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 90f0ddf commit a41c427

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offse
5959
var sa1;
6060
var i0;
6161
var i1;
62-
var oa;
62+
var ia;
6363
var ox;
6464

6565
isrm = isRowMajor( [ strideA1, strideA2 ] );
@@ -81,11 +81,12 @@ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offse
8181
for ( i1 = 0; i1 < N; i1++ ) {
8282
if ( x[ ix1 ] !== 0.0 ) {
8383
tmp = alpha * x[ ix1 ];
84-
oa = offsetA + (sa1*i1);
84+
ia = offsetA + (sa1*i1);
8585
ix0 = ox;
8686
for ( i0 = 0; i0 <= i1; i0++ ) {
87-
A[ oa+(sa0*i0) ] += x[ ix0 ] * tmp;
87+
A[ ia ] += x[ ix0 ] * tmp;
8888
ix0 += strideX;
89+
ia += sa0;
8990
}
9091
}
9192
ix1 += strideX;
@@ -97,11 +98,12 @@ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offse
9798
for ( i1 = 0; i1 < N; i1++ ) {
9899
if ( x[ ix1 ] !== 0.0 ) {
99100
tmp = alpha * x[ ix1 ];
100-
oa = offsetA + (sa1*i1);
101+
ia = offsetA + (sa1*i1) + (sa0*i1);
101102
ix0 = ix1;
102103
for ( i0 = i1; i0 < N; i0++ ) {
103-
A[ oa+(sa0*i0) ] += x[ ix0 ] * tmp;
104+
A[ ia ] += x[ ix0 ] * tmp;
104105
ix0 += strideX;
106+
ia += sa0;
105107
}
106108
}
107109
ix1 += strideX;

lib/node_modules/@stdlib/blas/base/dsyr/src/dsyr_ndarray.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void API_SUFFIX(c_dsyr_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const
4444
CBLAS_INT sa1;
4545
CBLAS_INT i0;
4646
CBLAS_INT i1;
47-
CBLAS_INT oa;
47+
CBLAS_INT ia;
4848
CBLAS_INT ox;
4949
double tmp;
5050

@@ -89,11 +89,12 @@ void API_SUFFIX(c_dsyr_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const
8989
for ( i1 = 0; i1 < N; i1++ ) {
9090
if ( X[ ix1 ] != 0.0 ) {
9191
tmp = alpha * X[ ix1 ];
92-
oa = offsetA + (sa1*i1);
92+
ia = offsetA + (sa1*i1);
9393
ix0 = ox;
9494
for ( i0 = 0; i0 <= i1; i0++ ) {
95-
A[ oa+(sa0*i0) ] += X[ ix0 ] * tmp;
95+
A[ ia ] += X[ ix0 ] * tmp;
9696
ix0 += strideX;
97+
ia += sa0;
9798
}
9899
}
99100
ix1 += strideX;
@@ -105,11 +106,12 @@ void API_SUFFIX(c_dsyr_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const
105106
for ( i1 = 0; i1 < N; i1++ ) {
106107
if ( X[ ix1 ] != 0.0 ) {
107108
tmp = alpha * X[ ix1 ];
108-
oa = offsetA + (sa1*i1);
109+
ia = offsetA + (sa1*i1) + (sa0*i1);
109110
ix0 = ix1;
110111
for ( i0 = i1; i0 < N; i0++ ) {
111-
A[ oa+(sa0*i0) ] += X[ ix0 ] * tmp;
112+
A[ ia ] += X[ ix0 ] * tmp;
112113
ix0 += strideX;
114+
ia += sa0;
113115
}
114116
}
115117
ix1 += strideX;

0 commit comments

Comments
 (0)