Skip to content

Commit 1b91fad

Browse files
committed
refactor: refactor conjugation logic in base implementation
--- 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_pkg_readmes status: na - task: lint_markdown_docs status: na - 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 f3b6595 commit 1b91fad

3 files changed

Lines changed: 48 additions & 11 deletions

File tree

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var muladd = require( '@stdlib/complex/float32/base/mul-add' ).assign;
3131
// MAIN //
3232

3333
/**
34-
* Performs the rank 1 operation `A = α*x*y^T + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix.
34+
* Performs the rank 1 operation `A = α*x*y^H + A`, where `α` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M` by `N` matrix.
3535
*
3636
* @private
3737
* @param {NonNegativeInteger} M - number of rows in the matrix `A`
@@ -69,8 +69,6 @@ function cgerc( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, stride
6969
var viewY;
7070
var retmp;
7171
var imtmp;
72-
var sign;
73-
var cimy;
7472
var tmp;
7573
var rex;
7674
var imx;
@@ -129,16 +127,12 @@ function cgerc( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, stride
129127
tmp = ox;
130128
ox = oy;
131129
oy = tmp;
132-
133-
sign = -1;
134130
} else { // order === 'column-major'
135131
// For column-major matrices, the first dimension has the fastest changing index...
136132
S0 = M;
137133
S1 = N;
138134
da0 = sa1; // offset increment for innermost loop
139135
da1 = sa2 - (S0*sa1); // offset increment for outermost loop
140-
141-
sign = 1;
142136
}
143137
// Reinterpret arrays as real-valued views of interleaved real and imaginary components:
144138
viewA = reinterpret( A, 0 );
@@ -155,14 +149,13 @@ function cgerc( M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, stride
155149
if ( rey === 0.0 && imy === 0.0 ) {
156150
ia += da0 * S0;
157151
} else {
158-
cimy = sign * imy;
159-
retmp = f32(f32(realpha*rey) - f32(imalpha*cimy));
160-
imtmp = f32(f32(realpha*cimy) + f32(imalpha*rey));
152+
retmp = f32(f32(realpha*rey) - f32(imalpha*imy));
153+
imtmp = f32(f32(realpha*imy) + f32(imalpha*rey));
161154
ix = ox;
162155
for ( i0 = 0; i0 < S0; i0++ ) {
163156
rex = viewX[ ix ];
164157
imx = viewX[ ix+1 ];
165-
muladd( rex, imx, retmp, imtmp, viewA[ ia ], viewA[ ia+1 ], viewA, 1, ia ); // eslint-disable-line max-len
158+
muladd( rex, -imx, retmp, imtmp, viewA[ ia ], viewA[ ia+1 ], viewA, 1, ia ); // eslint-disable-line max-len
166159
ix += sx;
167160
ia += da0;
168161
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"order": "column-major",
3+
"M": 2,
4+
"N": 3,
5+
"alpha": [ 0.5, 0.5 ],
6+
"x": [ 1.0, 1.0, 2.0, 2.0 ],
7+
"strideX": 1,
8+
"offsetX": 0,
9+
"y": [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ],
10+
"strideY": 1,
11+
"offsetY": 0,
12+
"A": [ 1.0, 1.0, 4.0, 4.0, 2.0, 2.0, 5.0, 5.0, 3.0, 3.0, 6.0, 6.0 ],
13+
"A_mat": [
14+
[ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ],
15+
[ 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ]
16+
],
17+
"lda": 2,
18+
"strideA1": 1,
19+
"strideA2": 2,
20+
"offsetA": 0,
21+
"A_out": [ 4.0, 4.0, 10.0, 10.0, 4.0, 4.0, 9.0, 9.0, 4.0, 4.0, 8.0, 8.0 ]
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"order": "row-major",
3+
"M": 2,
4+
"N": 3,
5+
"alpha": [ 0.5, 0.5 ],
6+
"x": [ 1.0, 1.0, 2.0, 2.0 ],
7+
"strideX": 1,
8+
"offsetX": 0,
9+
"y": [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ],
10+
"strideY": 1,
11+
"offsetY": 0,
12+
"A": [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ],
13+
"A_mat": [
14+
[ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ],
15+
[ 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ]
16+
],
17+
"lda": 3,
18+
"strideA1": 3,
19+
"strideA2": 1,
20+
"offsetA": 0,
21+
"A_out": [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 10.0, 10.0, 9.0, 9.0, 8.0, 8.0 ]
22+
}

0 commit comments

Comments
 (0)