Skip to content

Commit 9c4b307

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 ac5310c commit 9c4b307

File tree

5 files changed

+140
-83
lines changed

5 files changed

+140
-83
lines changed

lib/node_modules/@stdlib/blas/base/dsyr/include/stdlib/blas/base/dsyr_cblas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern "C" {
3434
/**
3535
* Performs the symmetric rank 1 operation `A = α*x*x^T + A`.
3636
*/
37-
void API_SUFFIX(cblas_ssyr)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *A, const CBLAS_INT LDA );
37+
void API_SUFFIX(cblas_dsyr)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *A, const CBLAS_INT LDA );
3838

3939
#ifdef __cplusplus
4040
}

lib/node_modules/@stdlib/blas/base/dsyr/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/dsyr.c"
238+
"./src/dsyr.c",
239+
"./src/dsyr_ndarray.c"
239240
],
240241
"include": [
241242
"./include"
@@ -261,7 +262,8 @@
261262
"blas": "",
262263
"wasm": false,
263264
"src": [
264-
"./src/dsyr.c"
265+
"./src/dsyr.c",
266+
"./src/dsyr_ndarray.c"
265267
],
266268
"include": [
267269
"./include"
@@ -282,7 +284,8 @@
282284
"blas": "",
283285
"wasm": false,
284286
"src": [
285-
"./src/dsyr.c"
287+
"./src/dsyr.c",
288+
"./src/dsyr_ndarray.c"
286289
],
287290
"include": [
288291
"./include"
@@ -302,7 +305,8 @@
302305
"blas": "",
303306
"wasm": true,
304307
"src": [
305-
"./src/dsyr.c"
308+
"./src/dsyr.c",
309+
"./src/dsyr_ndarray.c"
306310
],
307311
"include": [
308312
"./include"

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

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -52,80 +52,3 @@ void API_SUFFIX(c_dsyr)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const
5252
API_SUFFIX(c_dsyr_ndarray)( uplo, N, alpha, X, strideX, ox, A, sa1, sa2, 0 );
5353
return;
5454
}
55-
56-
/**
57-
* Performs the symmetric rank 1 operation `A = α*x*x^T + A` using alternative indexing semantics.
58-
*
59-
* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced
60-
* @param N number of elements along each dimension of `A`
61-
* @param alpha scalar
62-
* @param X input vector
63-
* @param strideX `X` stride length
64-
* @param offsetX starting index of `X`
65-
* @param A input matrix
66-
* @param strideA1 stride of the first dimension of `A`
67-
* @param strideA2 stride of the second dimension of `A`
68-
* @param offsetA starting index of `A`
69-
*/
70-
void API_SUFFIX(c_dsyr_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) {
71-
CBLAS_INT isrm;
72-
CBLAS_INT ix0;
73-
CBLAS_INT ix1;
74-
CBLAS_INT sa0;
75-
CBLAS_INT sa1;
76-
CBLAS_INT i0;
77-
CBLAS_INT i1;
78-
CBLAS_INT oa;
79-
CBLAS_INT ox;
80-
double tmp;
81-
82-
int64_t strides[] = { strideA1, strideA2 };
83-
if ( N == 0 || alpha == 0.0 ) {
84-
return;
85-
}
86-
isrm = stdlib_ndarray_is_row_major( 2, strides );
87-
if ( isrm ) {
88-
// For row-major matrices, the last dimension has the fastest changing index...
89-
sa0 = strideA2; // stride for innermost loop
90-
sa1 = strideA1; // stride for outermost loop
91-
} else { // isColMajor
92-
// For column-major matrices, the first dimension has the fastest changing index...
93-
sa0 = strideA1; // stride for innermost loop
94-
sa1 = strideA2; // stride for outermost loop
95-
}
96-
ox = offsetX;
97-
if (
98-
( isrm && uplo == CblasLower ) ||
99-
( !isrm && uplo == CblasUpper )
100-
) {
101-
ix1 = ox;
102-
for ( i1 = 0; i1 < N; i1++ ) {
103-
if ( X[ ix1 ] != 0.0 ) {
104-
tmp = alpha * X[ ix1 ];
105-
oa = offsetA + (sa1*i1);
106-
ix0 = ox;
107-
for ( i0 = 0; i0 <= i1; i0++ ) {
108-
A[ oa+(sa0*i0) ] += X[ ix0 ] * tmp;
109-
ix0 += strideX;
110-
}
111-
}
112-
ix1 += strideX;
113-
}
114-
return;
115-
}
116-
// ( isrm && uplo == 'CblasUpper' ) || ( !isrm && uplo === 'CblasLower' )
117-
ix1 = ox;
118-
for ( i1 = 0; i1 < N; i1++ ) {
119-
if ( X[ ix1 ] != 0.0 ) {
120-
tmp = alpha * X[ ix1 ];
121-
oa = offsetA + (sa1*i1);
122-
ix0 = ix1;
123-
for ( i0 = i1; i0 < N; i0++ ) {
124-
A[ oa+(sa0*i0) ] += X[ ix0 ] * tmp;
125-
ix0 += strideX;
126-
}
127-
}
128-
ix1 += strideX;
129-
}
130-
return;
131-
}

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "stdlib/blas/base/dsyr.h"
2020
#include "stdlib/blas/base/dsyr_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 1 operation `A = α*x*x^T + A`.
@@ -33,5 +35,35 @@
3335
* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
3436
*/
3537
void API_SUFFIX(c_dsyr)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *A, const CBLAS_INT LDA ) {
36-
API_SUFFIX(cblas_dsyr)( order, uplo, N, alpha, X, strideX, A, LDA );
38+
CBLAS_INT sx = strideX;
39+
if ( sx < 0 ) {
40+
sx = -sx;
41+
}
42+
API_SUFFIX(cblas_dsyr)( order, uplo, N, alpha, X, sx, AP );
43+
}
44+
45+
/**
46+
* Performs the symmetric rank 1 operation `A = α*x*x^T + A` using alternative indexing semantics.
47+
*
48+
* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced
49+
* @param N number of elements along each dimension of `A`
50+
* @param alpha scalar
51+
* @param X input vector
52+
* @param strideX `x` stride length
53+
* @param offsetX starting index for `x`
54+
* @param A input matrix
55+
* @param strideA1 stride of the first dimension of `A`
56+
* @param strideA2 stride of the second dimension of `A`
57+
* @param offsetA starting index for `AP`
58+
*/
59+
void API_SUFFIX(c_dsyr_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) {
60+
CBLAS_INT sx = strideX;
61+
X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer
62+
CBLAS_INT shape[] = { N, N };
63+
CBLAS_INT strides[] = { strideA1, strideA2 };
64+
A += stdlib_ndarray_min_view_buffer_index( 2, shape, strides, offsetA); // adjust array pointer
65+
if ( sx < 0 ) {
66+
sx = -sx;
67+
}
68+
API_SUFFIX(cblas_dsyr)( uplo, N, alpha, X, sx, offsetX, A, strideA1, strideA2, offsetA );
3769
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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/dsyr.h"
20+
#include "stdlib/blas/base/shared.h"
21+
#include "stdlib/ndarray/base/assert/is_row_major.h"
22+
23+
/**
24+
* Performs the symmetric rank 1 operation `A = α*x*x^T + A` using alternative indexing semantics.
25+
*
26+
* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced
27+
* @param N number of elements along each dimension of `A`
28+
* @param alpha scalar
29+
* @param X input vector
30+
* @param strideX `X` stride length
31+
* @param offsetX starting index of `X`
32+
* @param A input matrix
33+
* @param strideA1 stride of the first dimension of `A`
34+
* @param strideA2 stride of the second dimension of `A`
35+
* @param offsetA starting index of `A`
36+
*/
37+
void API_SUFFIX(c_dsyr_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) {
38+
CBLAS_INT isrm;
39+
CBLAS_INT ix0;
40+
CBLAS_INT ix1;
41+
CBLAS_INT sa0;
42+
CBLAS_INT sa1;
43+
CBLAS_INT i0;
44+
CBLAS_INT i1;
45+
CBLAS_INT oa;
46+
CBLAS_INT ox;
47+
double tmp;
48+
49+
int64_t strides[] = { strideA1, strideA2 };
50+
if ( N == 0 || alpha == 0.0 ) {
51+
return;
52+
}
53+
isrm = stdlib_ndarray_is_row_major( 2, strides );
54+
if ( isrm ) {
55+
// For row-major matrices, the last dimension has the fastest changing index...
56+
sa0 = strideA2; // stride for innermost loop
57+
sa1 = strideA1; // stride for outermost loop
58+
} else { // isColMajor
59+
// For column-major matrices, the first dimension has the fastest changing index...
60+
sa0 = strideA1; // stride for innermost loop
61+
sa1 = strideA2; // stride for outermost loop
62+
}
63+
ox = offsetX;
64+
if (
65+
( isrm && uplo == CblasLower ) ||
66+
( !isrm && uplo == CblasUpper )
67+
) {
68+
ix1 = ox;
69+
for ( i1 = 0; i1 < N; i1++ ) {
70+
if ( X[ ix1 ] != 0.0 ) {
71+
tmp = alpha * X[ ix1 ];
72+
oa = offsetA + (sa1*i1);
73+
ix0 = ox;
74+
for ( i0 = 0; i0 <= i1; i0++ ) {
75+
A[ oa+(sa0*i0) ] += X[ ix0 ] * tmp;
76+
ix0 += strideX;
77+
}
78+
}
79+
ix1 += strideX;
80+
}
81+
return;
82+
}
83+
// ( isrm && uplo == 'CblasUpper' ) || ( !isrm && uplo === 'CblasLower' )
84+
ix1 = ox;
85+
for ( i1 = 0; i1 < N; i1++ ) {
86+
if ( X[ ix1 ] != 0.0 ) {
87+
tmp = alpha * X[ ix1 ];
88+
oa = offsetA + (sa1*i1);
89+
ix0 = ix1;
90+
for ( i0 = i1; i0 < N; i0++ ) {
91+
A[ oa+(sa0*i0) ] += X[ ix0 ] * tmp;
92+
ix0 += strideX;
93+
}
94+
}
95+
ix1 += strideX;
96+
}
97+
return;
98+
}

0 commit comments

Comments
 (0)