Skip to content

Commit 47d2714

Browse files
committed
chore: clean-up
--- 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: passed - 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: passed - task: lint_javascript_tests status: passed - 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: passed - task: lint_c_benchmarks status: passed - 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 704d508 commit 47d2714

File tree

9 files changed

+257
-58
lines changed

9 files changed

+257
-58
lines changed

lib/node_modules/@stdlib/blas/base/dsyr2/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ var N = 3;
162162
var A1 = ones( N*N, opts.dtype );
163163
var A2 = ones( N*N, opts.dtype );
164164

165+
// Create random vectors:
165166
var x = discreteUniform( N, -10.0, 10.0, opts );
166167
var y = discreteUniform( N, -10.0, 10.0, opts );
167168

@@ -266,7 +267,7 @@ The function accepts the following arguments:
266267
- **oa**: `[in] CBLAS_INT` starting index for `A`.
267268
268269
```c
269-
void c_dsyr2_ndarray( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *y, CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA )
270+
void c_dsyr2_ndarray( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA )
270271
```
271272

272273
</section>
@@ -321,7 +322,7 @@ int main( void ) {
321322
printf( "A1[ %i ] = %lf\n", i, A1[ i ] );
322323
}
323324

324-
// Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative semantics indexing:
325+
// Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics:
325326
c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A2, N, 1, 0 );
326327

327328
// Print the result:

lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ static double benchmark1( int iterations, int N ) {
100100
t = tic();
101101
for ( i = 0; i < iterations; i++ ) {
102102
c_dsyr2( CblasRowMajor, CblasUpper, N, 1.0, x, 1, y, 1, A, N );
103-
if ( A[ i%N ] != A[ i%N ] ) {
103+
if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) {
104104
printf( "should not return NaN\n" );
105105
break;
106106
}
107107
}
108108
elapsed = tic() - t;
109-
if ( A[ i%N ] != A[ i%N ] ) {
109+
if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) {
110110
printf( "should not return NaN\n" );
111111
}
112112
return elapsed;
@@ -133,13 +133,13 @@ static double benchmark2( int iterations, int N ) {
133133
t = tic();
134134
for ( i = 0; i < iterations; i++ ) {
135135
c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 );
136-
if ( A[ i%N ] != A[ i%N ] ) {
136+
if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) {
137137
printf( "should not return NaN\n" );
138138
break;
139139
}
140140
}
141141
elapsed = tic() - t;
142-
if ( A[ i%N ] != A[ i%N ] ) {
142+
if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) {
143143
printf( "should not return NaN\n" );
144144
}
145145
return elapsed;

lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ int main( void ) {
4646

4747
// Print the result:
4848
for ( int i = 0; i < N*N; i++ ) {
49-
printf( "A1[ %i ] = %f\n", i, A1[ i ] );
49+
printf( "A1[ %i ] = %lf\n", i, A1[ i ] );
5050
}
5151

52-
// Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative semantics indexing:
52+
// Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics:
5353
c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A2, N, 1, 0 );
5454

5555
// Print the result:
5656
for ( int i = 0; i < N*N; i++ ) {
57-
printf( "A2[ %i ] = %f\n", i, A2[ i ] );
57+
printf( "A2[ %i ] = %lf\n", i, A2[ i ] );
5858
}
5959
}

lib/node_modules/@stdlib/blas/base/dsyr2/examples/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ var opts = {
2828

2929
var N = 3;
3030

31-
// Define 3x3 symmetric matrices:
31+
// Define N-by-N symmetric matrices:
3232
var A1 = ones( N*N, opts.dtype );
3333
var A2 = ones( N*N, opts.dtype );
3434

35+
// Create random vectors:
3536
var x = discreteUniform( N, -10.0, 10.0, opts );
3637
var y = discreteUniform( N, -10.0, 10.0, opts );
3738

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, str
6666
var sa1;
6767
var i0;
6868
var i1;
69-
var oa;
69+
var ia;
7070
var ox;
7171
var oy;
7272

@@ -92,13 +92,14 @@ function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, str
9292
if ( ( x[ ix1 ] !== 0.0 ) || ( y[ iy1 ] !== 0.0 ) ) {
9393
tmp1 = alpha * y[ iy1 ];
9494
tmp2 = alpha * x[ ix1 ];
95-
oa = offsetA + (sa1*i1);
95+
ia = offsetA + ( sa1*i1 );
9696
ix0 = ox;
9797
iy0 = oy;
9898
for ( i0 = 0; i0 <= i1; i0++ ) {
99-
A[ oa+(sa0*i0) ] += ( x[ ix0 ] * tmp1 ) + ( y[ iy0 ] * tmp2 ); // eslint-disable-line max-len
99+
A[ ia ] += ( x[ ix0 ] * tmp1 ) + ( y[ iy0 ] * tmp2 );
100100
ix0 += strideX;
101101
iy0 += strideY;
102+
ia += sa0;
102103
}
103104
}
104105
ix1 += strideX;
@@ -111,13 +112,14 @@ function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, str
111112
if ( ( x[ ix1 ] !== 0.0 ) || ( y[ iy1 ] !== 0.0 ) ) {
112113
tmp1 = alpha * y[ iy1 ];
113114
tmp2 = alpha * x[ ix1 ];
114-
oa = offsetA + (sa1*i1);
115+
ia = offsetA + ( sa1*i1 ) + ( sa0*i1 );
115116
ix0 = ix1;
116117
iy0 = iy1;
117118
for ( i0 = i1; i0 < N; i0++ ) {
118-
A[ oa+(sa0*i0) ] += ( x[ ix0 ] * tmp1 ) + ( y[ iy0 ] * tmp2 );
119+
A[ ia ] += ( x[ ix0 ] * tmp1 ) + ( y[ iy0 ] * tmp2 );
119120
ix0 += strideX;
120121
iy0 += strideY;
122+
ia += sa0;
121123
}
122124
}
123125
ix1 += strideX;

lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535
* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
3636
*/
3737
void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) {
38-
API_SUFFIX(cblas_dsyr2)( layout, uplo, N, alpha, X, strideX, A, LDA );
38+
API_SUFFIX(cblas_dsyr2)( layout, uplo, N, alpha, X, strideX, Y, strideY, A, LDA );
3939
}

lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424
/**
2525
* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix.
2626
*
27-
* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced
28-
* @param N number of elements along each dimension of `A`
29-
* @param alpha scalar constant
30-
* @param X first input vector
31-
* @param strideX `X` stride length
32-
* @param offsetX starting index of `X`
33-
* @param Y second input vector
34-
* @param strideY `Y` stride length
35-
* @param offsetY starting index of `Y`
36-
* @param A input matrix
27+
* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced
28+
* @param N number of elements along each dimension of `A`
29+
* @param alpha scalar constant
30+
* @param X first input vector
31+
* @param strideX `X` stride length
32+
* @param offsetX starting index of `X`
33+
* @param Y second input vector
34+
* @param strideY `Y` stride length
35+
* @param offsetY starting index of `Y`
36+
* @param A input matrix
3737
* @param strideA1 stride of the first dimension of `A`
3838
* @param strideA2 stride of the second dimension of `A`
3939
* @param offsetA starting index of `A`
@@ -49,7 +49,7 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons
4949
CBLAS_INT sa1;
5050
CBLAS_INT i0;
5151
CBLAS_INT i1;
52-
CBLAS_INT oa;
52+
CBLAS_INT ia;
5353
CBLAS_INT ox;
5454
CBLAS_INT oy;
5555
double tmp1;
@@ -111,13 +111,14 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons
111111
if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) {
112112
tmp1 = alpha * Y[ iy1 ];
113113
tmp2 = alpha * X[ ix1 ];
114-
oa = offsetA + (sa1*i1);
114+
ia = offsetA + ( sa1*i1 );
115115
ix0 = ox;
116116
iy0 = oy;
117117
for ( i0 = 0; i0 <= i1; i0++ ) {
118-
A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); // eslint-disable-line max-len
118+
A[ ia ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 );
119119
ix0 += strideX;
120120
iy0 += strideY;
121+
ia += sa0;
121122
}
122123
}
123124
ix1 += strideX;
@@ -130,13 +131,14 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons
130131
if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) {
131132
tmp1 = alpha * Y[ iy1 ];
132133
tmp2 = alpha * X[ ix1 ];
133-
oa = offsetA + (sa1*i1);
134+
ia = offsetA + ( sa1*i1 ) + ( sa0*i1 );
134135
ix0 = ix1;
135136
iy0 = iy1;
136137
for ( i0 = i1; i0 < N; i0++ ) {
137-
A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 );
138+
A[ ia ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 );
138139
ix0 += strideX;
139140
iy0 += strideY;
141+
ia += sa0;
140142
}
141143
}
142144
ix1 += strideX;

lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ var tryRequire = require( '@stdlib/utils/try-require' );
3232

3333
var ru = require( './fixtures/row_major_u.json' );
3434
var rl = require( './fixtures/row_major_l.json' );
35+
var rx0 = require( './fixtures/row_major_x0.json' );
3536
var rxpyp = require( './fixtures/row_major_xpyp.json' );
3637
var rxnyp = require( './fixtures/row_major_xnyp.json' );
3738
var rxpyn = require( './fixtures/row_major_xpyn.json' );
3839
var rxnyn = require( './fixtures/row_major_xnyn.json' );
3940

4041
var cu = require( './fixtures/column_major_u.json' );
4142
var cl = require( './fixtures/column_major_l.json' );
43+
var cx0 = require( './fixtures/column_major_x0.json' );
4244
var cxpyp = require( './fixtures/column_major_xpyp.json' );
4345
var cxnyp = require( './fixtures/column_major_xnyp.json' );
4446
var cxpyn = require( './fixtures/column_major_xpyn.json' );
@@ -309,6 +311,52 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y
309311
t.end();
310312
});
311313

314+
tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, zero-vector)', opts, function test( t ) {
315+
var expected;
316+
var data;
317+
var out;
318+
var a;
319+
var x;
320+
var y;
321+
322+
data = rx0;
323+
324+
a = new Float64Array( data.A );
325+
x = new Float64Array( data.x );
326+
y = new Float64Array( data.y );
327+
328+
expected = new Float64Array( data.A_out );
329+
330+
out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda );
331+
t.strictEqual( out, a, 'returns expected value' );
332+
t.deepEqual( out, expected, 'returns expected value' );
333+
334+
t.end();
335+
});
336+
337+
tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, zero-vector)', opts, function test( t ) {
338+
var expected;
339+
var data;
340+
var out;
341+
var a;
342+
var x;
343+
var y;
344+
345+
data = cx0;
346+
347+
a = new Float64Array( data.A );
348+
x = new Float64Array( data.x );
349+
y = new Float64Array( data.y );
350+
351+
expected = new Float64Array( data.A_out );
352+
353+
out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda );
354+
t.strictEqual( out, a, 'returns expected value' );
355+
t.deepEqual( out, expected, 'returns expected value' );
356+
357+
t.end();
358+
});
359+
312360
tape( 'the function returns a reference to the input matrix `A`', opts, function test( t ) {
313361
var data;
314362
var out;

0 commit comments

Comments
 (0)