Skip to content

refactor: update implementation for blas/base/dspmv #2840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions lib/node_modules/@stdlib/blas/base/dspmv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.

# dspmv

> Perform the matrix-vector operation `y = α*A*x + β*y` where `α` and `β` are scalars, `x` and `y` are `N` element vectors and, `A` is an `N` by `N` symmetric matrix supplied in packed form.
> Perform the matrix-vector operation `y = α*A*x + β*y`.

<section class = "usage">

Expand Down Expand Up @@ -91,7 +91,7 @@ dspmv( 'row-major', 'upper', 2, 1.0, AP, x1, -1, 1.0, y1, -1 );
// y0 => <Float64Array>[ 0.0, 6.0, 4.0 ]
```

#### dspmv.ndarray( order, uplo, N, α, AP, oa, x, sx, ox, β, y, sy, oy )
#### dspmv.ndarray( order, uplo, N, α, AP, sap, oap x, sx, ox, β, y, sy, oy )

Performs the matrix-vector operation `y = α*A*x + β*y` using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix supplied in packed form `AP`.

Expand All @@ -102,13 +102,14 @@ var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var x = new Float64Array( [ 1.0, 1.0, 1.0 ] );
var y = new Float64Array( [ 1.0, 1.0, 1.0 ] );

dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, 0, x, 1, 0, 1.0, y, 1, 0 );
dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, 1, 0, x, 1, 0, 1.0, y, 1, 0 );
// y => <Float64Array>[ 7.0, 12.0, 15.0 ]
```

The function has the following additional parameters:

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

Expand All @@ -117,11 +118,11 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the
```javascript
var Float64Array = require( '@stdlib/array/float64' );

var AP = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var x = new Float64Array( [ 1.0, 1.0, 1.0 ] );
var y = new Float64Array( [ 1.0, 1.0, 1.0 ] );

dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, 2, x, 1, 0, 1.0, y, -1, 2 );
dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, 1, 0, x, 1, 0, 1.0, y, -1, 2 );
// y => <Float64Array>[ 15.0, 12.0, 7.0 ]
```

Expand Down Expand Up @@ -153,13 +154,16 @@ var opts = {
'dtype': 'float64'
};

var N = 3;
var N = 5;
var AP = discreteUniform( N * ( N + 1 ) / 2, -10, 10, opts );

var x = discreteUniform( N, -10, 10, opts );
var y = discreteUniform( N, -10, 10, opts );

dspmv.ndarray( 'row-major', 'upper', N, 1.0, AP, 0, x, 1, 0, 1.0, y, 1, 0 );
dspmv( 'row-major', 'upper', N, 1.0, AP, x, 1, 1.0, y, 1 );
console.log( y );

dspmv.ndarray( 'row-major', 'upper', N, 1.0, AP, 1, 0, x, 1, 0, 1.0, y, 1, 0 );
console.log( y );
```

Expand Down
12 changes: 6 additions & 6 deletions lib/node_modules/@stdlib/blas/base/dspmv/benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ var options = {
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @param {PositiveInteger} N - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var AP = uniform( len * ( len + 1 ) / 2, -10.0, 10.0, options );
var x = uniform( len, -10.0, 10.0, options );
var y = uniform( len, -10.0, 10.0, options );
function createBenchmark( N ) {
var AP = uniform( N*(N+1)/2, -10.0, 10.0, options );
var x = uniform( N, -10.0, 10.0, options );
var y = uniform( N, -10.0, 10.0, options );
return benchmark;

/**
Expand All @@ -63,7 +63,7 @@ function createBenchmark( len ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = dspmv( 'row-major', 'upper', len, 1.0, AP, x, 1, 1.0, y, 1 );
z = dspmv( 'row-major', 'upper', N, 1.0, AP, x, 1, 1.0, y, 1 );
if ( isnan( z[ i%z.length ] ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ var options = {
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @param {PositiveInteger} N - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var AP = uniform( len * ( len + 1 ) / 2, -10.0, 10.0, options );
var x = uniform( len, -10.0, 10.0, options );
var y = uniform( len, -10.0, 10.0, options );
function createBenchmark( N ) {
var AP = uniform( N * ( N + 1 ) / 2, -10.0, 10.0, options );
var x = uniform( N, -10.0, 10.0, options );
var y = uniform( N, -10.0, 10.0, options );
return benchmark;

/**
Expand All @@ -63,7 +63,7 @@ function createBenchmark( len ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = dspmv( 'row-major', 'upper', len, 1.0, AP, 0, x, 1, 0, 1.0, y, 1, 0 );
z = dspmv( 'row-major', 'upper', N, 1.0, AP, 1, 0, x, 1, 0, 1.0, y, 1, 0 );
if ( isnan( z[ i%z.length ] ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
11 changes: 7 additions & 4 deletions lib/node_modules/@stdlib/blas/base/dspmv/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<Float64Array>[ ~6.0, ~4.0 ]


{{alias}}.ndarray( ord, uplo, N, α, AP, oa, x, sx, ox, β, y, sy, oy )
{{alias}}.ndarray( ord, uplo, N, α, AP, sap, oap, x, sx, ox, β, y, sy, oy )
Performs the matrix-vector operation `y = α*A*x + β*y` using alternative
indexing semantics and where `α` and `β` are scalars, `x` and `y` are `N`
element vectors, and `A` is an `N` by `N` symmetric matrix supplied in
Expand Down Expand Up @@ -106,7 +106,10 @@
AP: Float64Array
Matrix in packed form.

oa: integer
sap: integer
Index increment for `AP`.

oap: integer
Starting index for `AP`.

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

// Advanced indexing:
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> AP = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] );
> {{alias}}.ndarray( ord, uplo, 2, 1.0, AP, 0, x, -1, 1, 1.0, y, -1, 1 )
> {{alias}}.ndarray( ord, uplo, 2, 1.0, AP, 1, 0, x, -1, 1, 1.0, y, -1, 1 )
<Float64Array>[ ~6.0, ~4.0 ]

See Also
Expand Down
19 changes: 10 additions & 9 deletions lib/node_modules/@stdlib/blas/base/dspmv/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Layout, MatrixTriangle } from '@stdlib/types/blas';
*/
interface Routine {
/**
* Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix supplied in packed form.
* Performs the matrix-vector operation `y = α*A*x + β*y` where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix supplied in packed form.
*
* @param order - storage layout
* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied
Expand All @@ -54,21 +54,22 @@ interface Routine {
( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, AP: Float64Array, x: Float64Array, strideX: number, beta: number, y: Float64Array, strideY: number ): Float64Array;

/**
* Performs the matrix-vector operation `y = alpha*A*x + beta*y` using alternative indexing semantics and where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix supplied in packed form.
* Performs the matrix-vector operation `y = α*A*x + β*y`, using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix supplied in packed form.
*
* @param order - storage layout
* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied
* @param N - number of columns in the matrix `A`
* @param alpha - scalar constant
* @param AP - packed form of a symmetric matrix `A`
* @param offsetAP - starting `AP` index
* @param sap - `AP` stride length
* @param oap - starting index for `AP`
* @param x - first input array
* @param strideX - `x` stride length
* @param offsetX - starting `x` index
* @param offsetX - starting index for `x`
* @param beta - scalar constant
* @param y - second input array
* @param strideY - `y` stride length
* @param offsetY - starting `y` index
* @param offsetY - starting index for `y`
* @returns `y`
*
* @example
Expand All @@ -78,14 +79,14 @@ interface Routine {
* var x = new Float64Array( [ 1.0, 1.0, 1.0 ] );
* var y = new Float64Array( [ 1.0, 1.0, 1.0 ] );
*
* dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, 0, x, 1, 0, 1.0, y, 1, 0 );
* dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, 1, 0, x, 1, 0, 1.0, y, 1, 0 );
* // y => <Float64Array>[ 7.0, 12.0, 15.0 ]
*/
ndarray( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, AP: Float64Array, offsetAP: number, x: Float64Array, strideX: number, offsetX: number, beta: number, y: Float64Array, strideY: number, offsetY: number ): Float64Array;
ndarray( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, AP: Float64Array, strideAP: number, offsetAP: number, x: Float64Array, strideX: number, offsetX: number, beta: number, y: Float64Array, strideY: number, offsetY: number ): Float64Array;
}

/**
* Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix supplied in packed form.
* Performs the matrix-vector operation `y = α*A*x + β*y` where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix supplied in packed form.
*
* @param order - storage layout
* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied
Expand Down Expand Up @@ -116,7 +117,7 @@ interface Routine {
* var x = new Float64Array( [ 1.0, 1.0, 1.0 ] );
* var y = new Float64Array( [ 1.0, 1.0, 1.0 ] );
*
* dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, 0, x, 1, 0, 1.0, y, -1, 2 );
* dspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, 1, 0, x, 1, 0, 1.0, y, -1, 2 );
* // y => <Float64Array>[ 15.0, 12.0, 7.0 ]
*/
declare var dspmv: Routine;
Expand Down
Loading
Loading