diff --git a/lib/node_modules/@stdlib/blas/base/sspr/README.md b/lib/node_modules/@stdlib/blas/base/sspr/README.md index 8c1cba2cb9a0..e1048467d97d 100644 --- a/lib/node_modules/@stdlib/blas/base/sspr/README.md +++ b/lib/node_modules/@stdlib/blas/base/sspr/README.md @@ -196,7 +196,7 @@ Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scala float AP[] = { 1.0f, 2.0f, 3.0f, 1.0f, 2.0f, 1.0f }; const float x[] = { 1.0f, 2.0f, 3.0f }; -c_sspr( CblasColMajor, CblasUpper, 3, 1.0f, x, 1, AP ); +c_sspr( CblasRowMajor, CblasUpper, 3, 1.0f, x, 1, AP ); ``` The function accepts the following arguments: @@ -223,13 +223,13 @@ Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scala float AP[] = { 1.0f, 2.0f, 3.0f, 1.0f, 2.0f, 1.0f }; const float x[] = { 1.0f, 2.0f, 3.0f }; -c_sspr_ndarray( CblasColMajor, CblasUpper, 3, 1.0f, x, 1, AP, 1, 0 ); +c_sspr_ndarray( CblasRowMajor, CblasUpper, 3, 1.0f, x, 1, AP, 1, 0 ); ``` The function accepts the following arguments: - **order**: `[in] CBLAS_LAYOUT` storage layout. -- **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced. +- **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. - **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. - **alpha**: `[in] float` scalar. - **X**: `[in] float*` input vector. diff --git a/lib/node_modules/@stdlib/blas/base/sspr/manifest.json b/lib/node_modules/@stdlib/blas/base/sspr/manifest.json index d0128506d0dd..120a7ea4f81f 100644 --- a/lib/node_modules/@stdlib/blas/base/sspr/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/sspr/manifest.json @@ -232,7 +232,8 @@ "blas": "", "wasm": false, "src": [ - "./src/sspr.c" + "./src/sspr.c", + "./src/sspr_ndarray.c" ], "include": [ "./include" @@ -256,7 +257,8 @@ "blas": "", "wasm": false, "src": [ - "./src/sspr.c" + "./src/sspr.c", + "./src/sspr_ndarray.c" ], "include": [ "./include" @@ -276,7 +278,8 @@ "blas": "", "wasm": false, "src": [ - "./src/sspr.c" + "./src/sspr.c", + "./src/sspr_ndarray.c" ], "include": [ "./include" @@ -295,7 +298,8 @@ "blas": "", "wasm": true, "src": [ - "./src/sspr.c" + "./src/sspr.c", + "./src/sspr_ndarray.c" ], "include": [ "./include" diff --git a/lib/node_modules/@stdlib/blas/base/sspr/src/Makefile b/lib/node_modules/@stdlib/blas/base/sspr/src/Makefile index 7733b6180cb4..dd720a3de8f2 100644 --- a/lib/node_modules/@stdlib/blas/base/sspr/src/Makefile +++ b/lib/node_modules/@stdlib/blas/base/sspr/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2025 The Stdlib Authors. +# Copyright (c) 2020 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/sspr/src/sspr.c b/lib/node_modules/@stdlib/blas/base/sspr/src/sspr.c index 64d49d168a50..471cd2ab3550 100644 --- a/lib/node_modules/@stdlib/blas/base/sspr/src/sspr.c +++ b/lib/node_modules/@stdlib/blas/base/sspr/src/sspr.c @@ -32,75 +32,8 @@ * @param AP packed form of a symmetric matrix `A` */ void API_SUFFIX(c_sspr)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, float *AP ) { - const CBLAS_INT ox = STDLIB_BLAS_BASE_STRIDE2OFFSET( N, strideX ); + const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); API_SUFFIX(c_sspr_ndarray)( order, uplo, N, alpha, X, strideX, ox, AP, 1, 0 ); return; } -/** -* Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form using alternative indexing semantics. -* -* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced -* @param N number of elements along each dimension of `A` -* @param alpha scalar -* @param X input vector -* @param strideX `X` stride length -* @param offsetX starting index of `x` -* @param AP packed form of a symmetric matrix `A` -* @param strideAP stride of the first dimension of `AP` -* @param offsetAP starting index of `AP` -*/ -void API_SUFFIX(c_sspr_ndarray)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *AP, const CBLAS_INT strideAP, const CBLAS_INT offsetAP ) { - CBLAS_INT iap; - CBLAS_INT ix0; - CBLAS_INT ix1; - CBLAS_INT i0; - CBLAS_INT i1; - CBLAS_INT kk; - CBLAS_INT ox; - float tmp; - - if ( N == 0 || alpha == 0.0f ) { - return; - } - ox = offsetX; - kk = offsetAP; - if ( - ( order == CblasRowMajor && uplo == CblasLower ) || - ( order == CblasColMajor && uplo == CblasUpper ) - ) { - ix1 = ox; - for ( i1 = 0; i1 < N; i1++ ) { - if ( X[ ix1 ] != 0.0f ) { - tmp = alpha * X[ ix1 ]; - ix0 = ox; - iap = kk; - for ( i0 = 0; i0 <= i1; i0++ ) { - AP[ iap ] += X[ ix0 ] * tmp; - ix0 += strideX; - iap += strideAP; - } - } - ix1 += strideX; - kk += ( i1 + 1 ) * strideAP; - } - return; - } - // ( order == CblasColMajor && uplo == CblasLower ) || ( order == CblasRowMajor && uplo == CblasUpper ) - ix1 = ox; - for ( i1 = 0; i1 < N; i1++ ) { - if ( X[ ix1 ] != 0.0f ) { - tmp = alpha * X[ ix1 ]; - ix0 = ix1; - iap = kk; - for ( i0 = 0; i0 < N - i1; i0++ ) { - AP[ iap ] += X[ ix0 ] * tmp; - ix0 += strideX; - iap += strideAP; - } - } - ix1 += strideX; - kk += ( N - i1 ) * strideAP; - } - return; -} diff --git a/lib/node_modules/@stdlib/blas/base/sspr/src/sspr_cblas.c b/lib/node_modules/@stdlib/blas/base/sspr/src/sspr_cblas.c index 479ba609ce96..248bcedd1446 100644 --- a/lib/node_modules/@stdlib/blas/base/sspr/src/sspr_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/sspr/src/sspr_cblas.c @@ -32,5 +32,33 @@ * @param AP packed form of a symmetric matrix `A` */ void API_SUFFIX(c_sspr)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, float *AP ) { - API_SUFFIX(cblas_sspr)( order, uplo, N, alpha, X, strideX, AP ); + CBLAS_INT sx = strideX; + if ( sx < 0 ) { + sx = -sx; + } + API_SUFFIX(cblas_sspr)( order, uplo, N, alpha, X, sx, AP ); +} + +/** +* Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form using alternative indexing semantics. +* +* @param order storage layout +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param N number of elements along each dimension of `A` +* @param alpha scalar +* @param X input vector +* @param strideX `x` stride length +* @param offsetX starting index for `x` +* @param AP packed form of a symmetric matrix `A` +* @param strideAP `AP` stride length +* @param offsetAP starting index for `AP` +*/ +void API_SUFFIX(c_sspr_ndarray)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *AP, const CBLAS_INT strideAP, const CBLAS_INT offsetAP ) { + CBLAS_INT sx = strideX; + X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer + AP += stdlib_strided_min_view_buffer_index( N, strideAP, offsetAP ); // adjust array pointer + if ( sx < 0 ) { + sx = -sx; + } + API_SUFFIX(cblas_sspr)( order, uplo, N, alpha, X, sx, AP ); } diff --git a/lib/node_modules/@stdlib/blas/base/sspr/src/sspr_ndarray.c b/lib/node_modules/@stdlib/blas/base/sspr/src/sspr_ndarray.c new file mode 100644 index 000000000000..07c88f8cf7a8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspr/src/sspr_ndarray.c @@ -0,0 +1,88 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/sspr.h" +#include "stdlib/blas/base/shared.h" + +/** +* Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form using alternative indexing semantics. +* +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param N number of elements along each dimension of `A` +* @param alpha scalar +* @param X input vector +* @param strideX `X` stride length +* @param offsetX starting index of `x` +* @param AP packed form of a symmetric matrix `A` +* @param strideAP stride of the first dimension of `AP` +* @param offsetAP starting index of `AP` +*/ +void API_SUFFIX(c_sspr_ndarray)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *AP, const CBLAS_INT strideAP, const CBLAS_INT offsetAP ) { + CBLAS_INT iap; + CBLAS_INT ix0; + CBLAS_INT ix1; + CBLAS_INT i0; + CBLAS_INT i1; + CBLAS_INT kk; + CBLAS_INT ox; + float tmp; + + if ( N == 0 || alpha == 0.0f ) { + return; + } + ox = offsetX; + kk = offsetAP; + if ( + ( order == CblasRowMajor && uplo == CblasLower ) || + ( order == CblasColMajor && uplo == CblasUpper ) + ) { + ix1 = ox; + for ( i1 = 0; i1 < N; i1++ ) { + if ( X[ ix1 ] != 0.0f ) { + tmp = alpha * X[ ix1 ]; + ix0 = ox; + iap = kk; + for ( i0 = 0; i0 <= i1; i0++ ) { + AP[ iap ] += X[ ix0 ] * tmp; + ix0 += strideX; + iap += strideAP; + } + } + ix1 += strideX; + kk += ( i1 + 1 ) * strideAP; + } + return; + } + // ( order == CblasColMajor && uplo == CblasLower ) || ( order == CblasRowMajor && uplo == CblasUpper ) + ix1 = ox; + for ( i1 = 0; i1 < N; i1++ ) { + if ( X[ ix1 ] != 0.0f ) { + tmp = alpha * X[ ix1 ]; + ix0 = ix1; + iap = kk; + for ( i0 = 0; i0 < N - i1; i0++ ) { + AP[ iap ] += X[ ix0 ] * tmp; + ix0 += strideX; + iap += strideAP; + } + } + ix1 += strideX; + kk += ( N - i1 ) * strideAP; + } + return; +}