Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: update implementation
  • Loading branch information
ShabiShett07 committed Jun 29, 2025
commit c632a9a2950b1b80fc36a96345d809da912dc432
23 changes: 12 additions & 11 deletions lib/node_modules/@stdlib/blas/base/dspr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The function has the following parameters:
- **N**: number of elements along each dimension of `A`.
- **α**: scalar constant.
- **x**: input [`Float64Array`][mdn-float64array].
- **sx**: index increment for `x`.
- **sx**: stride length for `x`.
- **AP**: packed form of a symmetric matrix `A` stored as a [`Float64Array`][mdn-float64array].

The stride parameters determine how elements in the input arrays are accessed at runtime. For example, to iterate over the elements of `x` in reverse order,
Expand Down Expand Up @@ -101,7 +101,7 @@ dspr.ndarray( 'row-major', 'lower', 3, 1.0, x, 1, 0, AP, 1, 0 );
The function has the following additional parameters:

- **ox**: starting index for `x`.
- **sap**: `AP` stride length.
- **sap**: stride length for `AP`.
- **oap**: starting index for `AP`.

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example,
Expand Down Expand Up @@ -186,7 +186,7 @@ console.log( AP );
#include "stdlib/blas/base/dspr.h"
```

#### c_dspr( order, uplo, N, alpha, \*X, strideX, \*AP )
#### c_dspr( layout, 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.

Expand All @@ -201,19 +201,19 @@ c_dspr( CblasRowMajor, CblasUpper, 3, 1.0, x, 1, AP );

The function accepts the following arguments:

- **order**: `[in] CBLAS_LAYOUT` storage layout.
- **layout**: `[in] CBLAS_LAYOUT` storage layout.
- **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] double` scalar.
- **X**: `[in] double*` input vector.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **sx**: `[in] CBLAS_INT` stride length for `X`.
- **AP**: `[inout] double*` packed form of a symmetric matrix `A`.

```c
void c_dspr( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *AP )
void c_dspr( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *x, const CBLAS_INT strideX, double *ap )
```

#### c_dspr_ndarray( order, uplo, N, alpha, \*X, strideX, \*AP, strideAP, offsetAP )
#### c_dspr_ndarray( layout, uplo, N, alpha, \*X, sx, \*AP, sap, offsetAP )

Performs the symmetric rank 1 operation `A = α*x*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form.

Expand All @@ -228,18 +228,19 @@ c_dspr_ndarray( CblasRowMajor, CblasUpper, 3, 1.0, x, 1, AP, 1, 0 );

The function accepts the following arguments:

- **order**: `[in] CBLAS_LAYOUT` storage layout.
- **layout**: `[in] CBLAS_LAYOUT` storage layout.
- **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] double` scalar.
- **X**: `[in] double*` input vector.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **sx**: `[in] CBLAS_INT` stride length for `X`.
- **ox**: `[in] CBLAS_INT` starting index for `x`.
- **AP**: `[inout] double*` packed form of a symmetric matrix `A`.
- **strideAP**: `[in] CBLAS_INT` stride length for `AP`.
- **sap**: `[in] CBLAS_INT` stride length for `AP`.
- **offsetAP**: `[in] CBLAS_INT` starting index for `AP`.

```c
void c_dspr_ndarray( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *AP, const CBLAS_INT strideAP, const CBLAS_INT offsetAP )
void c_dspr_ndarray( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *ap, const CBLAS_INT strideAP, const CBLAS_INT offsetAP )
```

</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function createBenchmark( N ) {
* @private
*/
function main() {
var len;
var N;
var min;
var max;
var f;
Expand All @@ -95,9 +95,9 @@ function main() {
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = floor( pow( pow( 10, i ), 1.0/2.0 ) );
f = createBenchmark( len );
bench( pkg+':size='+( len * ( len + 1 ) / 2 ), f );
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
f = createBenchmark( N );
bench( pkg+':size='+( N * ( N + 1 ) / 2 ), f );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function createBenchmark( N ) {
* @private
*/
function main() {
var len;
var N;
var min;
var max;
var f;
Expand All @@ -100,9 +100,9 @@ function main() {
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = floor( pow( pow( 10, i ), 1.0/2.0 ) );
f = createBenchmark( len );
bench( pkg+'::native:size='+( len * ( len + 1 ) / 2 ), opts, f );
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
f = createBenchmark( N );
bench( pkg+'::native:size='+( N * ( N + 1 ) / 2 ), opts, f );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function createBenchmark( N ) {
* @private
*/
function main() {
var len;
var N;
var min;
var max;
var f;
Expand All @@ -95,9 +95,9 @@ function main() {
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = floor( pow( pow( 10, i ), 1.0/2.0 ) );
f = createBenchmark( len );
bench( pkg+':ndarray:size='+( len * ( len + 1 ) / 2 ), f );
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
f = createBenchmark( N );
bench( pkg+':ndarray:size='+( N * ( N + 1 ) / 2 ), f );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function createBenchmark( N ) {
* @private
*/
function main() {
var len;
var N;
var min;
var max;
var f;
Expand All @@ -100,9 +100,9 @@ function main() {
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = floor( pow( pow( 10, i ), 1.0/2.0 ) );
f = createBenchmark( len );
bench( pkg+'::native:ndarray:size='+( len * ( len + 1 ) / 2 ), opts, f );
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
f = createBenchmark( N );
bench( pkg+'::native:ndarray:size='+( N * ( N + 1 ) / 2 ), opts, f );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,28 @@ static double tic( void ) {
* Runs a benchmark.
*
* @param iterations number of iterations
* @param len array length
* @param N array dimension size
* @return elapsed time in seconds
*/
static double benchmark1( int iterations, int len ) {
static double benchmark1( int iterations, int N ) {
double elapsed;
double AP[ len*(len+1)/2 ];
double x[ len ];
double AP[ N*(N+1)/2 ];
double x[ N ];
double t;
int i;

stdlib_strided_dfill( len, 1.0, x, 1 );
stdlib_strided_dfill( len*(len+1)/2, 1.0, AP, 1 );
stdlib_strided_dfill( N, 1.0, x, 1 );
stdlib_strided_dfill( N*(N+1)/2, 1.0, AP, 1 );
t = tic();
for ( i = 0; i < iterations; i++ ) {
c_dspr( CblasRowMajor, CblasUpper, len, 1.0, x, 1, AP );
if ( AP[ i%len ] != AP[ i%len ] ) {
c_dspr( CblasRowMajor, CblasUpper, N, 1.0, x, 1, AP );
if ( AP[ i%N ] != AP[ i%N ] ) {
printf( "should not return NaN\n" );
break;
}
}
elapsed = tic() - t;
if ( AP[ i%len ] != AP[ i%len ] ) {
if ( AP[ i%N ] != AP[ i%N ] ) {
printf( "should not return NaN\n" );
}
return elapsed;
Expand All @@ -114,28 +114,28 @@ static double benchmark1( int iterations, int len ) {
* Runs a benchmark.
*
* @param iterations number of iterations
* @param len array length
* @param N array dimension size
* @return elapsed time in seconds
*/
static double benchmark2( int iterations, int len ) {
static double benchmark2( int iterations, int N ) {
double elapsed;
double AP[ len*(len+1)/2 ];
double x[ len ];
double AP[ N*(N+1)/2 ];
double x[ N ];
double t;
int i;

stdlib_strided_dfill( len, 1.0, x, 1 );
stdlib_strided_dfill( len*(len+1)/2, 1.0, AP, 1 );
stdlib_strided_dfill( N, 1.0, x, 1 );
stdlib_strided_dfill( N*(N+1)/2, 1.0, AP, 1 );
t = tic();
for ( i = 0; i < iterations; i++ ) {
c_dspr_ndarray( CblasRowMajor, CblasUpper, len, 1.0, x, 1, 0, AP, 1, 0 );
if ( AP[ i%len ] != AP[ i%len ] ) {
c_dspr_ndarray( CblasRowMajor, CblasUpper, N, 1.0, x, 1, 0, AP, 1, 0 );
if ( AP[ i%N ] != AP[ i%N ] ) {
printf( "should not return NaN\n" );
break;
}
}
elapsed = tic() - t;
if ( AP[ i%len ] != AP[ i%len ] ) {
if ( AP[ i%N ] != AP[ i%N ] ) {
printf( "should not return NaN\n" );
}
return elapsed;
Expand All @@ -148,7 +148,7 @@ int main( void ) {
double elapsed;
int count;
int iter;
int len;
int N;
int i;
int j;

Expand All @@ -158,19 +158,19 @@ int main( void ) {
print_version();
count = 0;
for ( i = MIN; i <= MAX; i++ ) {
len = floor( pow( pow( 10, i ), 1.0/2.0 ) );
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
iter = ITERATIONS / pow( 10, i-1 );
for ( j = 0; j < REPEATS; j++ ) {
count += 1;
printf( "# c::%s:len=%d\n", NAME, len );
elapsed = benchmark1( iter, len );
printf( "# c::%s:N=%d\n", NAME, N );
elapsed = benchmark1( iter, N );
print_results( iter, elapsed );
printf( "ok %d benchmark finished\n", count );
}
for ( j = 0; j < REPEATS; j++ ) {
count += 1;
printf( "# c::%s:ndarray:len=%d\n", NAME, len );
elapsed = benchmark2( iter, len );
printf( "# c::%s:ndarray:N=%d\n", NAME, N );
elapsed = benchmark2( iter, N );
print_results( iter, elapsed );
printf( "ok %d benchmark finished\n", count );
}
Expand Down
12 changes: 6 additions & 6 deletions lib/node_modules/@stdlib/blas/base/dspr/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

{{alias}}( ord, uplo, N, α, x, sx, AP )
{{alias}}( order, uplo, N, α, 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.
Expand All @@ -12,7 +12,7 @@

Parameters
----------
ord: string
order: string
Row-major (C-style) or column-major (Fortran-style) order. Must be
either 'row-major' or 'column-major'.

Expand Down Expand Up @@ -48,7 +48,7 @@
<Float64Array>[ 2.0, 3.0, 4.0 ]


{{alias}}.ndarray( ord, uplo, N, α, x, sx, ox, AP, sap, oap )
{{alias}}.ndarray( order, uplo, N, α, x, sx, ox, AP, sap, oap )
Performs the symmetric rank 1 operation `A = α*x*x^T + A` using alternative
indexing semantics and where `α` is a scalar, `x` is an `N` element vector,
and `A` is an `N` by `N` symmetric matrix supplied in packed form.
Expand All @@ -59,7 +59,7 @@

Parameters
----------
ord: string
order: string
Row-major (C-style) or column-major (Fortran-style) order. Must be
either 'row-major' or 'column-major'.

Expand Down Expand Up @@ -100,9 +100,9 @@
--------
> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> var AP = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0 ] );
> var ord = 'row-major';
> var order = 'row-major';
> var uplo = 'upper';
> {{alias}}.ndarray( ord, uplo, 2, 1.0, x, 1, 0, AP, 1, 0 )
> {{alias}}.ndarray( order, uplo, 2, 1.0, x, 1, 0, AP, 1, 0 )
<Float64Array>[ 2.0, 3.0, 4.0 ]

See Also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ extern "C" {
/**
* 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.
*/
void API_SUFFIX(c_dspr)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *AP );
void API_SUFFIX(c_dspr)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *AP );

/**
* Performs the symmetric rank 1 operation `A = α*x*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix supplied in packed form.
*/
void API_SUFFIX(c_dspr_ndarray)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *AP, const CBLAS_INT strideAP, const CBLAS_INT offsetAP );
void API_SUFFIX(c_dspr_ndarray)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *AP, const CBLAS_INT strideAP, const CBLAS_INT offsetAP );

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C" {
/**
* 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.
*/
void API_SUFFIX(cblas_dspr)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *AP );
void API_SUFFIX(cblas_dspr)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *AP );

#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions lib/node_modules/@stdlib/blas/base/dspr/lib/dspr.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function dspr( order, uplo, N, alpha, x, strideX, AP ) {
if ( strideX === 0 ) {
throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) );
}
// Check if we can early return...
if ( N === 0 || alpha === 0.0 ) {
return AP;
}
Expand Down
23 changes: 23 additions & 0 deletions lib/node_modules/@stdlib/blas/base/dspr/lib/dspr.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@

// MODULES //

var isLayout = require( '@stdlib/blas/base/assert/is-layout' );
var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' );
var resolveOrder = require( '@stdlib/blas/base/layout-resolve-enum' );
var resolveUplo = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' );
var format = require( '@stdlib/string/format' );
var addon = require( './../src/addon.node' );


Expand All @@ -37,6 +40,10 @@ var addon = require( './../src/addon.node' );
* @param {Float64Array} x - input vector
* @param {integer} strideX - `x` stride length
* @param {Float64Array} AP - packed form of a symmetric matrix `A`
* @throws {TypeError} first argument must be a valid order
* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied
* @throws {RangeError} third argument must be a nonnegative integer
* @throws {RangeError} sixth argument must be non-zero
* @returns {Float64Array} `AP`
*
* @example
Expand All @@ -49,6 +56,22 @@ var addon = require( './../src/addon.node' );
* // AP => <Float64Array>[ 2.0, 4.0, 6.0, 5.0, 8.0, 10.0 ]
*/
function dspr( order, uplo, N, alpha, x, strideX, AP ) {
if ( !isLayout( order ) ) {
throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) );
}
if ( !isMatrixTriangle( uplo ) ) {
throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) );
}
if ( N < 0 ) {
throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) );
}
if ( strideX === 0 ) {
throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) );
}
// Check if we can early return...
if ( N === 0 || alpha === 0.0 ) {
return AP;
}
addon( resolveOrder( order ), resolveUplo( uplo ), N, alpha, x, strideX, AP ); // eslint-disable-line max-len
return AP;
}
Expand Down
Loading
Loading