Skip to content

Commit 9afb978

Browse files
committed
chore: clean up in lib
--- 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 3382c53 commit 9afb978

4 files changed

Lines changed: 68 additions & 77 deletions

File tree

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

Lines changed: 65 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var f32 = require( '@stdlib/number/float64/base/to-float32' );
2828
// MAIN //
2929

3030
/**
31-
* Solves one of the systems of equations `A*x = b` or `A^T*x = b` or `A^H*x = b` where `b` and `x` are `N` element complex vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular complex matrix.
31+
* Solves one of the systems of equations `A*x = b` or `A^T*x = b` or `A^H*x = b` where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix.
3232
*
3333
* @private
3434
* @param {string} uplo - specifies whether `A` is an upper or lower triangular matrix
@@ -82,61 +82,52 @@ function ctrsv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX
8282
var i1;
8383
var ia;
8484

85-
// Layout
86-
isrm = isRowMajor( [ strideA1, strideA2 ] );
85+
// Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop...
8786

88-
// Diagonal
87+
isrm = isRowMajor( [ strideA1, strideA2 ] );
8988
nonunit = ( diag === 'non-unit' );
9089

91-
// Reinterpret arrays to raw numeric views
90+
if ( isrm ) {
91+
// For row-major matrices, the last dimension has the fastest changing index...
92+
sa0 = strideA2 * 2; // stride increment for innermost loop
93+
sa1 = strideA1 * 2; // stride increment for outermost loop
94+
} else { // isColMajor
95+
// For column-major matrices, the first dimension has the fastest changing index...
96+
sa0 = strideA1 * 2; // stride increment for innermost loop
97+
sa1 = strideA2 * 2; // stride increment for outermost loop
98+
}
99+
// Reinterpret arrays to real-valued views
92100
viewA = reinterpret( A, 0 );
93101
viewX = reinterpret( x, 0 );
94-
95-
// Set sign to handle conjugation: flip the imaginary part for conjugate-transpose
96102
if ( trans === 'conjugate-transpose' ) {
97103
sign = -1;
98104
} else {
99105
sign = 1;
100106
}
101-
102-
if ( isrm ) {
103-
// For row-major matrices, the last dimension has the fastest changing index...
104-
sa0 = strideA2 * 2; // offset increment for innermost loop
105-
sa1 = strideA1 * 2; // offset increment for outermost loop
106-
} else { // isColMajor
107-
// For column-major matrices, the first dimension has the fastest changing index...
108-
sa0 = strideA1 * 2; // offset increment for innermost loop
109-
sa1 = strideA2 * 2; // offset increment for outermost loop
110-
}
111-
112-
// Vector indexing base
113107
oa = offsetA * 2;
114108
ox = offsetX * 2;
115-
116-
// Vector strides
117109
sx = strideX * 2;
118-
119110
doa2 = sa1 + sa0;
120111

121112
if (
122113
( !isrm && uplo === 'upper' && trans === 'no-transpose' ) ||
123114
( isrm && uplo === 'lower' && trans !== 'no-transpose' )
124115
) {
125-
ix1 = ox + ( ( N - 1 ) * sx );
126-
oa2 = oa + ( doa2 * ( N - 1 ) );
116+
ix1 = ox + ((N-1)*sx);
117+
oa2 = oa + (doa2*(N-1));
127118
for ( i1 = N - 1; i1 >= 0; i1-- ) {
128119
rex = viewX[ ix1 ];
129-
imx = viewX[ ix1 + 1 ];
120+
imx = viewX[ ix1+1 ];
130121
if ( rex !== 0.0 || imx !== 0.0 ) {
131122
if ( nonunit ) {
132123
ia = oa2;
133124
rea = viewA[ ia ];
134-
ima = sign * viewA[ ia + 1 ];
135-
magsq = f32( ( rea * rea ) + ( ima * ima ) );
136-
retmp = f32( f32( ( rex * rea ) + ( imx * ima ) ) / magsq );
137-
imtmp = f32( f32( ( imx * rea ) - ( rex * ima ) ) / magsq );
125+
ima = sign * viewA[ ia+1 ];
126+
magsq = f32(f32(rea*rea) + f32(ima*ima));
127+
retmp = f32((f32(rex*rea) + f32(imx*ima)) / magsq );
128+
imtmp = f32((f32(imx*rea) - f32(rex*ima)) / magsq );
138129
viewX[ ix1 ] = retmp;
139-
viewX[ ix1 + 1 ] = imtmp;
130+
viewX[ ix1+1 ] = imtmp;
140131
} else {
141132
retmp = rex;
142133
imtmp = imx;
@@ -145,13 +136,13 @@ function ctrsv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX
145136
ix0 = ix1 - sx;
146137
for ( i0 = i1 - 1; i0 >= 0; i0-- ) {
147138
rea = viewA[ ia ];
148-
ima = sign * viewA[ ia + 1 ];
139+
ima = sign * viewA[ ia+1 ];
149140
rex = viewX[ ix0 ];
150-
imx = viewX[ ix0 + 1 ];
151-
remul = f32( ( retmp * rea ) - ( imtmp * ima ) );
152-
immul = f32( ( retmp * ima ) + ( imtmp * rea ) );
153-
viewX[ ix0 ] = f32( rex - remul );
154-
viewX[ ix0 + 1 ] = f32( imx - immul );
141+
imx = viewX[ ix0+1 ];
142+
remul = f32(f32(retmp*rea) - f32(imtmp*ima));
143+
immul = f32(f32(retmp*ima) + f32(imtmp*rea));
144+
viewX[ ix0 ] = f32(rex-remul);
145+
viewX[ ix0+1 ] = f32(imx-immul);
155146
ix0 -= sx;
156147
ia -= sa0;
157148
}
@@ -169,17 +160,17 @@ function ctrsv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX
169160
oa2 = oa;
170161
for ( i1 = 0; i1 < N; i1++ ) {
171162
rex = viewX[ ix1 ];
172-
imx = viewX[ ix1 + 1 ];
163+
imx = viewX[ ix1+1 ];
173164
if ( rex !== 0.0 || imx !== 0.0 ) {
174165
if ( nonunit ) {
175166
ia = oa2;
176167
rea = viewA[ ia ];
177-
ima = sign * viewA[ ia + 1 ];
178-
magsq = f32( ( rea * rea ) + ( ima * ima ) );
179-
retmp = f32( f32( ( rex * rea ) + ( imx * ima ) ) / magsq );
180-
imtmp = f32( f32( ( imx * rea ) - ( rex * ima ) ) / magsq );
168+
ima = sign * viewA[ ia+1 ];
169+
magsq = f32(f32(rea*rea) + f32(ima*ima));
170+
retmp = f32(f32(f32(rex*rea) + f32(imx*ima)) / magsq );
171+
imtmp = f32(f32(f32(imx*rea) - f32(rex*ima)) / magsq );
181172
viewX[ ix1 ] = retmp;
182-
viewX[ ix1 + 1 ] = imtmp;
173+
viewX[ ix1+1 ] = imtmp;
183174
} else {
184175
retmp = rex;
185176
imtmp = imx;
@@ -188,13 +179,13 @@ function ctrsv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX
188179
ix0 = ix1 + sx;
189180
for ( i0 = i1 + 1; i0 < N; i0++ ) {
190181
rea = viewA[ ia ];
191-
ima = sign * viewA[ ia + 1 ];
182+
ima = sign * viewA[ ia+1 ];
192183
rex = viewX[ ix0 ];
193-
imx = viewX[ ix0 + 1 ];
194-
remul = f32( ( retmp * rea ) - ( imtmp * ima ) );
195-
immul = f32( ( retmp * ima ) + ( imtmp * rea ) );
196-
viewX[ ix0 ] = f32( rex - remul );
197-
viewX[ ix0 + 1 ] = f32( imx - immul );
184+
imx = viewX[ ix0+1 ];
185+
remul = f32(f32(retmp*rea) - f32(imtmp*ima));
186+
immul = f32(f32(retmp*ima) + f32(imtmp*rea));
187+
viewX[ ix0 ] = f32(rex-remul);
188+
viewX[ ix0+1 ] = f32(imx-immul);
198189
ia += sa0;
199190
ix0 += sx;
200191
}
@@ -212,69 +203,69 @@ function ctrsv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX
212203
oa2 = oa;
213204
for ( i1 = 0; i1 < N; i1++ ) {
214205
rex = viewX[ ix1 ];
215-
imx = viewX[ ix1 + 1 ];
206+
imx = viewX[ ix1+1 ];
216207
retmp = rex;
217208
imtmp = imx;
218209
ix0 = ox;
219210
ia = oa2;
220211
for ( i0 = 0; i0 < i1; i0++ ) {
221212
rea = viewA[ ia ];
222-
ima = sign * viewA[ ia + 1 ];
213+
ima = sign * viewA[ ia+1 ];
223214
rex = viewX[ ix0 ];
224-
imx = viewX[ ix0 + 1 ];
225-
retmp = f32( retmp - f32( ( rex * rea ) - ( imx * ima ) ) );
226-
imtmp = f32( imtmp - f32( ( rex * ima ) + ( imx * rea ) ) );
215+
imx = viewX[ ix0+1 ];
216+
retmp = f32(retmp - f32(rex*rea) - f32(imx*ima));
217+
imtmp = f32(imtmp - f32(rex*ima) + f32(imx*rea));
227218
ix0 += sx;
228219
ia += sa0;
229220
}
230221
if ( nonunit ) {
231222
rea = viewA[ ia ];
232-
ima = sign * viewA[ ia + 1 ];
233-
magsq = f32( ( rea * rea ) + ( ima * ima ) );
234-
remul = f32( ( retmp * rea ) + ( imtmp * ima ) );
235-
immul = f32( ( imtmp * rea ) - ( retmp * ima ) );
236-
retmp = f32( remul / magsq );
237-
imtmp = f32( immul / magsq );
223+
ima = sign * viewA[ ia+1 ];
224+
magsq = f32(f32(rea*rea) + f32(ima*ima));
225+
remul = f32(f32(retmp*rea) + f32(imtmp*ima));
226+
immul = f32(f32(imtmp*rea) - f32(retmp*ima));
227+
retmp = f32(remul / magsq);
228+
imtmp = f32(immul / magsq);
238229
}
239230
viewX[ ix1 ] = retmp;
240-
viewX[ ix1 + 1 ] = imtmp;
231+
viewX[ ix1+1 ] = imtmp;
241232
ix1 += sx;
242233
oa2 += sa1;
243234
}
244235
return x;
245236
}
246237
// ( !isrm && uplo === 'lower' && trans !== 'no-transpose' ) || ( isrm && uplo === 'upper' && trans === 'no-transpose' )
247-
ix1 = ox + ( ( N - 1 ) * sx );
238+
ix1 = ox + ((N-1)*sx);
248239
ixend = ix1;
249-
oa2 = oa + ( doa2 * ( N - 1 ) );
240+
oa2 = oa + (doa2*(N-1));
250241
for ( i1 = N - 1; i1 >= 0; i1-- ) {
251242
rex = viewX[ ix1 ];
252-
imx = viewX[ ix1 + 1 ];
243+
imx = viewX[ ix1+1 ];
253244
retmp = rex;
254245
imtmp = imx;
255246
ix0 = ixend;
256247
ia = oa2;
257248
for ( i0 = N - 1; i0 > i1; i0-- ) {
258249
rea = viewA[ ia ];
259-
ima = sign * viewA[ ia + 1 ];
250+
ima = sign * viewA[ ia+1 ];
260251
rex = viewX[ ix0 ];
261-
imx = viewX[ ix0 + 1 ];
262-
retmp = f32( retmp - f32( ( rex * rea ) - ( imx * ima ) ) );
263-
imtmp = f32( imtmp - f32( ( rex * ima ) + ( imx * rea ) ) );
252+
imx = viewX[ ix0+1 ];
253+
retmp = f32(retmp - f32(rex*rea) - f32(imx*ima));
254+
imtmp = f32(imtmp - f32(rex*ima) + f32(imx*rea));
264255
ia -= sa0;
265256
ix0 -= sx;
266257
}
267258
if ( nonunit ) {
268259
rea = viewA[ ia ];
269-
ima = sign * viewA[ ia + 1 ];
270-
magsq = f32( ( rea * rea ) + ( ima * ima ) );
271-
remul = f32( ( retmp * rea ) + ( imtmp * ima ) );
272-
immul = f32( ( imtmp * rea ) - ( retmp * ima ) );
273-
retmp = f32( remul / magsq );
274-
imtmp = f32( immul / magsq );
260+
ima = sign * viewA[ ia+1 ];
261+
magsq = f32(f32(rea*rea) + f32(ima*ima));
262+
remul = f32(f32(retmp*rea) + f32(imtmp*ima));
263+
immul = f32(f32(imtmp*rea) - f32(retmp*ima));
264+
retmp = f32(remul / magsq);
265+
imtmp = f32(immul / magsq);
275266
}
276267
viewX[ ix1 ] = retmp;
277-
viewX[ ix1 + 1 ] = imtmp;
268+
viewX[ ix1+1 ] = imtmp;
278269
ix1 -= sx;
279270
oa2 -= sa1;
280271
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var base = require( './base.js' );
3333
// MAIN //
3434

3535
/**
36-
* Solves one of the systems of equations `A*x = b` or `A^T*x = b` or `A^H*x = b` where `b` and `x` are `N` element complex vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular complex matrix.
36+
* Solves one of the systems of equations `A*x = b` or `A^T*x = b` or `A^H*x = b` where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix.
3737
*
3838
* @param {string} order - storage layout
3939
* @param {string} uplo - specifies whether `A` is an upper or lower triangular matrix

lib/node_modules/@stdlib/blas/base/ctrsv/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* BLAS level 2 routine to solve one of the systems of equations `A*x = b` or `A^T*x = b` or `A^H*x = b` where `b` and `x` are `N` element complex vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular complex matrix.
22+
* BLAS level 2 routine to solve one of the systems of equations `A*x = b` or `A^T*x = b` or `A^H*x = b` where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix.
2323
* @module @stdlib/blas/base/ctrsv
2424
*
2525
* @example

lib/node_modules/@stdlib/blas/base/ctrsv/lib/ndarray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var base = require( './base.js' );
3030
// MAIN //
3131

3232
/**
33-
* Solves one of the systems of equations `A*x = b` or `A^T*x = b` or `A^H*x = b` where `b` and `x` are `N` element complex vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular complex matrix.
33+
* Solves one of the systems of equations `A*x = b` or `A^T*x = b` or `A^H*x = b` where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix.
3434
*
3535
* @param {string} uplo - specifies whether `A` is an upper or lower triangular matrix
3636
* @param {string} trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed

0 commit comments

Comments
 (0)