Skip to content

Commit dc00b12

Browse files
committed
chore: update 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - 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: missing_dependencies - 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 5bdfcf1 commit dc00b12

File tree

4 files changed

+168
-103
lines changed

4 files changed

+168
-103
lines changed

lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@
235235
"blas": "",
236236
"wasm": false,
237237
"src": [
238-
"./src/dsyr2.c"
238+
"./src/dsyr2.c",
239+
"./src/dsyr2_ndarray.c"
239240
],
240241
"include": [
241242
"./include"
@@ -261,7 +262,8 @@
261262
"blas": "",
262263
"wasm": false,
263264
"src": [
264-
"./src/dsyr2.c"
265+
"./src/dsyr2.c",
266+
"./src/dsyr2_ndarray.c"
265267
],
266268
"include": [
267269
"./include"
@@ -282,7 +284,8 @@
282284
"blas": "",
283285
"wasm": false,
284286
"src": [
285-
"./src/dsyr2.c"
287+
"./src/dsyr2.c",
288+
"./src/dsyr2_ndarray.c"
286289
],
287290
"include": [
288291
"./include"
@@ -302,7 +305,8 @@
302305
"blas": "",
303306
"wasm": true,
304307
"src": [
305-
"./src/dsyr2.c"
308+
"./src/dsyr2.c",
309+
"./src/dsyr2_ndarray.c"
306310
],
307311
"include": [
308312
"./include"

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

Lines changed: 2 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "stdlib/blas/base/dsyr2.h"
2020
#include "stdlib/blas/base/shared.h"
2121
#include "stdlib/strided/base/stride2offset.h"
22-
#include "stdlib/ndarray/base/assert/is_row_major.h"
2322

2423
/**
2524
* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`.
@@ -51,101 +50,8 @@ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const
5150
sa1 = LDA;
5251
sa2 = 1;
5352
}
54-
ox = STDLIB_BLAS_BASE_STRIDE2OFFSET( N, strideX );
55-
oy = STDLIB_BLAS_BASE_STRIDE2OFFSET( N, strideY );
53+
ox = stdlib_strided_stride2offset( N, strideX );
54+
oy = stdlib_strided_stride2offset( N, strideY );
5655
API_SUFFIX(c_dsyr2_ndarray)( uplo, N, alpha, X, strideX, ox, Y, strideY, oy, A, sa1, sa2, 0 );
5756
return;
5857
}
59-
60-
/**
61-
* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics.
62-
*
63-
* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced
64-
* @param N number of elements along each dimension of `A`
65-
* @param alpha scalar
66-
* @param X first input vector
67-
* @param strideX `X` stride length
68-
* @param offsetX starting index of `X`
69-
* @param Y second input vector
70-
* @param strideY `Y` stride length
71-
* @param offsetY starting index of `Y`
72-
* @param A input matrix
73-
* @param strideA1 stride of the first dimension of `A`
74-
* @param strideA2 stride of the second dimension of `A`
75-
* @param offsetA starting index of `A`
76-
*/
77-
void API_SUFFIX(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, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) {
78-
CBLAS_INT isrm;
79-
CBLAS_INT ix0;
80-
CBLAS_INT ix1;
81-
CBLAS_INT iy0;
82-
CBLAS_INT iy1;
83-
CBLAS_INT sa0;
84-
CBLAS_INT sa1;
85-
CBLAS_INT i0;
86-
CBLAS_INT i1;
87-
CBLAS_INT oa;
88-
CBLAS_INT ox;
89-
CBLAS_INT oy;
90-
double tmp1;
91-
double tmp2;
92-
93-
int64_t strides[] = { strideA1, strideA2 };
94-
if ( N == 0 || alpha == 0.0 ) {
95-
return;
96-
}
97-
isrm = stdlib_ndarray_is_row_major( 2, strides );
98-
if ( isrm ) {
99-
// For row-major matrices, the last dimension has the fastest changing index...
100-
sa0 = strideA2; // stride for innermost loop
101-
sa1 = strideA1; // stride for outermost loop
102-
} else { // isColMajor
103-
// For column-major matrices, the first dimension has the fastest changing index...
104-
sa0 = strideA1; // stride for innermost loop
105-
sa1 = strideA2; // stride for outermost loop
106-
}
107-
ox = offsetX;
108-
oy = offsetY;
109-
ix1 = ox;
110-
iy1 = oy;
111-
if (
112-
( isrm && uplo == CblasLower ) ||
113-
( !isrm && uplo == CblasUpper )
114-
) {
115-
for ( i1 = 0; i1 < N; i1++ ) {
116-
if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) {
117-
tmp1 = alpha * Y[ iy1 ];
118-
tmp2 = alpha * X[ ix1 ];
119-
oa = offsetA + (sa1*i1);
120-
ix0 = ox;
121-
iy0 = oy;
122-
for ( i0 = 0; i0 <= i1; i0++ ) {
123-
A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); // eslint-disable-line max-len
124-
ix0 += strideX;
125-
iy0 += strideY;
126-
}
127-
}
128-
ix1 += strideX;
129-
iy1 += strideY;
130-
}
131-
return;
132-
}
133-
// ( order == CblasRowMajor && uplo == CblasUpper ) || ( order == CblasColMajor && uplo == CblasLower )
134-
for ( i1 = 0; i1 < N; i1++ ) {
135-
if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) {
136-
tmp1 = alpha * Y[ iy1 ];
137-
tmp2 = alpha * X[ ix1 ];
138-
oa = offsetA + (sa1*i1);
139-
ix0 = ix1;
140-
iy0 = iy1;
141-
for ( i0 = i1; i0 < N; i0++ ) {
142-
A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 );
143-
ix0 += strideX;
144-
iy0 += strideY;
145-
}
146-
}
147-
ix1 += strideX;
148-
iy1 += strideY;
149-
}
150-
return;
151-
}

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

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "stdlib/blas/base/dsyr2.h"
20-
#include "stdlib/blas/base/dsyr2_cblas.h"
19+
#include "stdlib/blas/base/dsyr22.h"
20+
#include "stdlib/blas/base/dsyr22_cblas.h"
2121
#include "stdlib/blas/base/shared.h"
22+
#include "stdlib/strided/base/min_view_buffer_index.h"
23+
#include "stdlib/ndarray/base/min_view_buffer_index.h"
2224

2325
/**
2426
* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`.
@@ -35,5 +37,43 @@
3537
* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
3638
*/
3739
void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, 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)( order, uplo, N, alpha, X, strideX, Y, strideY, A, LDA );
40+
CBLAS_INT sx = strideX;
41+
if ( sx < 0 ) {
42+
sx = -sx;
43+
}
44+
API_SUFFIX(cblas_dsyr2)( order, uplo, N, alpha, X, sx, A, LDA );
45+
}
46+
47+
/**
48+
* Performs the symmetric rank 2 operation `A = α*x*x^T + A` using alternative indexing semantics.
49+
*
50+
* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced
51+
* @param N number of elements along each dimension of `A`
52+
* @param alpha scalar
53+
* @param X input vector
54+
* @param strideX `x` stride length
55+
* @param offsetX starting index for `x`
56+
* @param Y input vector
57+
* @param strideY `y` stride length
58+
* @param offsetY starting index for `y`
59+
* @param A input matrix
60+
* @param strideA1 stride of the first dimension of `A`
61+
* @param strideA2 stride of the second dimension of `A`
62+
* @param offsetA starting index for `A`
63+
*/
64+
void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) {
65+
CBLAS_INT sx = strideX;
66+
CBLAS_INT sy = strideY;
67+
X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer
68+
Y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer
69+
CBLAS_INT shape[] = { N, N };
70+
CBLAS_INT strides[] = { strideA1, strideA2 };
71+
A += stdlib_ndarray_min_view_buffer_index( 2, shape, strides, offsetA ); // adjust array pointer
72+
if ( sx < 0 ) {
73+
sx = -sx;
74+
}
75+
if ( sy < 0 ) {
76+
sy = -sy;
77+
}
78+
API_SUFFIX(cblas_dsyr2)( order, uplo, N, alpha, X, sx, Y, sy, A, LDA );
3979
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include "stdlib/blas/base/dsyr2.h"
20+
#include "stdlib/blas/base/shared.h"
21+
#include "stdlib/strided/base/stride2offset.h"
22+
#include "stdlib/ndarray/base/assert/is_row_major.h"
23+
24+
/**
25+
* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics.
26+
*
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
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
37+
* @param strideA1 stride of the first dimension of `A`
38+
* @param strideA2 stride of the second dimension of `A`
39+
* @param offsetA starting index of `A`
40+
*/
41+
void API_SUFFIX(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, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) {
42+
CBLAS_INT isrm;
43+
CBLAS_INT ix0;
44+
CBLAS_INT ix1;
45+
CBLAS_INT iy0;
46+
CBLAS_INT iy1;
47+
CBLAS_INT sa0;
48+
CBLAS_INT sa1;
49+
CBLAS_INT i0;
50+
CBLAS_INT i1;
51+
CBLAS_INT oa;
52+
CBLAS_INT ox;
53+
CBLAS_INT oy;
54+
double tmp1;
55+
double tmp2;
56+
57+
int64_t strides[] = { strideA1, strideA2 };
58+
if ( N == 0 || alpha == 0.0 ) {
59+
return;
60+
}
61+
isrm = stdlib_ndarray_is_row_major( 2, strides );
62+
if ( isrm ) {
63+
// For row-major matrices, the last dimension has the fastest changing index...
64+
sa0 = strideA2; // stride for innermost loop
65+
sa1 = strideA1; // stride for outermost loop
66+
} else { // isColMajor
67+
// For column-major matrices, the first dimension has the fastest changing index...
68+
sa0 = strideA1; // stride for innermost loop
69+
sa1 = strideA2; // stride for outermost loop
70+
}
71+
ox = offsetX;
72+
oy = offsetY;
73+
ix1 = ox;
74+
iy1 = oy;
75+
if (
76+
( isrm && uplo == CblasLower ) ||
77+
( !isrm && uplo == CblasUpper )
78+
) {
79+
for ( i1 = 0; i1 < N; i1++ ) {
80+
if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) {
81+
tmp1 = alpha * Y[ iy1 ];
82+
tmp2 = alpha * X[ ix1 ];
83+
oa = offsetA + (sa1*i1);
84+
ix0 = ox;
85+
iy0 = oy;
86+
for ( i0 = 0; i0 <= i1; i0++ ) {
87+
A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); // eslint-disable-line max-len
88+
ix0 += strideX;
89+
iy0 += strideY;
90+
}
91+
}
92+
ix1 += strideX;
93+
iy1 += strideY;
94+
}
95+
return;
96+
}
97+
// ( order == CblasRowMajor && uplo == CblasUpper ) || ( order == CblasColMajor && uplo == CblasLower )
98+
for ( i1 = 0; i1 < N; i1++ ) {
99+
if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) {
100+
tmp1 = alpha * Y[ iy1 ];
101+
tmp2 = alpha * X[ ix1 ];
102+
oa = offsetA + (sa1*i1);
103+
ix0 = ix1;
104+
iy0 = iy1;
105+
for ( i0 = i1; i0 < N; i0++ ) {
106+
A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 );
107+
ix0 += strideX;
108+
iy0 += strideY;
109+
}
110+
}
111+
ix1 += strideX;
112+
iy1 += strideY;
113+
}
114+
return;
115+
}

0 commit comments

Comments
 (0)