Skip to content
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

refactor: update implementation for blas/base/ssymv #2843

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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: 13 additions & 7 deletions lib/node_modules/@stdlib/blas/base/ssymv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.

# ssymv

> 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.
> Perform the matrix-vector operation `y = α*A*x + β*y`.

<section class = "usage">

Expand Down Expand Up @@ -92,7 +92,7 @@ ssymv( 'row-major', 'upper', 3, 1.0, A, 3, x1, -1, 1.0, y1, -1 );
// y0 => <Float32Array>[ 1.0, 4.0, 3.0, 2.0 ]
```

#### ssymv.ndarray( order, uplo, N, α, A, LDA, x, sx, ox, β, y, sy, oy )
#### ssymv.ndarray( uplo, N, α, A, sa1, sa2, oa, 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.

Expand All @@ -103,12 +103,15 @@ var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] );
var x = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var y = new Float32Array( [ 1.0, 2.0, 3.0 ] );

ssymv.ndarray( 'row-major', 'upper', 3, 2.0, A, 3, x, -1, 2, 1.0, y, 1, 0 );
ssymv.ndarray( 'upper', 3, 2.0, A, 3, 1, 0, x, -1, 2, 1.0, y, 1, 0 );
// y => <Float32Array>[ 7.0, 10.0, 9.0 ]
```

The function has the following additional parameters:

- **sa1**: stride for the first dimension of `A`.
- **sa2**: stride for the second dimension of `A`.
- **oa**: starting index for `A`.
- **ox**: starting index for `x`.
- **oy**: starting index for `y`.

Expand All @@ -121,7 +124,7 @@ var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] );
var x = new Float32Array( [ 1.0, 1.0, 1.0 ] );
var y = new Float32Array( [ 1.0, 1.0, 1.0 ] );

ssymv.ndarray( 'row-major', 'lower', 3, 1.0, A, 3, x, -1, 2, 1.0, y, -1, 2 );
ssymv.ndarray( 'lower', 3, 1.0, A, 3, 1, 0, x, -1, 2, 1.0, y, -1, 2 );
// y => <Float32Array>[ 4.0, 3.0, 2.0 ]
```

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

var N = 3;
var N = 5;
var A = ones( N*N, opts.dtype );

var x = discreteUniform( N, 0, 255, opts );
var y = discreteUniform( N, 0, 255, opts );

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

ssymv.ndarray( 'upper', N, 1.0, A, N, 1, 0, x, 1, 0, 1.0, y, 1, 0 );
console.log( y );
```

Expand Down Expand Up @@ -252,7 +258,7 @@ TODO

[blas]: http://www.netlib.org/blas

[ssymv]: https://netlib.org/lapack/explore-html/d2/d94/ssymv_8f.html
[ssymv]: https://www.netlib.org/lapack/explore-html/db/d17/group__hemv_ga8990fe737209f3401522103c85016d27.html#ga8990fe737209f3401522103c85016d27

[mdn-float32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function createBenchmark( N ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = ssymv( 'row-major', 'upper', N, 1.0, A, N, x, 1, 0, 1.0, y, 1, 0 );
z = ssymv( 'upper', N, 1.0, A, N, 1, 0, x, 1, 0, 1.0, y, 1, 0 );
if ( isnanf( z[ i%z.length ] ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
24 changes: 12 additions & 12 deletions lib/node_modules/@stdlib/blas/base/ssymv/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Scalar constant.

A: Float32Array
Matrix.
Input matrix.

lda: integer
Stride of the first dimension of `A` (a.k.a., leading dimension of the
Expand Down Expand Up @@ -63,7 +63,7 @@
<Float32Array>[ 4.0, 4.0 ]


{{alias}}.ndarray( order, uplo, N, α, A, lda, x, sx, ox, β, y, sy, oy )
{{alias}}.ndarray( uplo, N, α, A, sa1, sa2, oa, 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.
Expand All @@ -74,10 +74,6 @@

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

uplo: string
Specifies whether to reference the upper or lower triangular part of
`A`. Must be either 'upper' or 'lower'.
Expand All @@ -89,11 +85,16 @@
Scalar constant.

A: Float32Array
Matrix.
Input matrix.

lda: integer
Stride of the first dimension of `A` (a.k.a., leading dimension of the
matrix `A`).
sa1: integer
Stride for the first dimension of `A`.

sa2: integer
Stride for the second dimension of `A`.

oa: integer
Starting index for `A`.

x: Float32Array
Input vector.
Expand Down Expand Up @@ -126,8 +127,7 @@
> var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] );
> var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] );
> var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 2.0, 1.0 ] );
> var ord = 'row-major';
> {{alias}}.ndarray( ord, 'upper', 2, 1.0, A, 2, x, 1, 0, 1.0, y, 1, 0 )
> {{alias}}.ndarray( 'upper', 2, 1.0, A, 2, 1, 0, x, 1, 0, 1.0, y, 1, 0 )
<Float32Array>[ 4.0, 4.0 ]

See Also
Expand Down
26 changes: 14 additions & 12 deletions lib/node_modules/@stdlib/blas/base/ssymv/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ 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.
* 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.
*
* @param order - storage layout
* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is to be referenced
* @param N - number of elements along each dimension in the matrix `A`
* @param alpha - scalar constant
* @param A - matrix
* @param A - input matrix
* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
* @param x - first input array
* @param strideX - `x` stride length
Expand All @@ -55,21 +55,23 @@ interface Routine {
( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array;

/**
* 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.
* 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.
*
* @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 in the matrix `A`
* @param alpha - scalar constant
* @param A - matrix
* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
* @param A - input
* @param strideA1 - stride for the first dimension of `A`
* @param strideA2 - stride for the second dimension of `A`
* @param offsetA - starting index for `A`
* @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 @@ -79,20 +81,20 @@ interface Routine {
* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] );
* var y = new Float32Array( [ 0.0, 0.0, 0.0 ] );
*
* ssymv.ndarray( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0, 0.0, y, 1, 0 );
* ssymv.ndarray( 'lower', 3, 1.0, A, 3, 1, 0, x, 1, 0, 0.0, y, 1, 0 );
* // y => <Float32Array>[ 1.0, 2.0, 3.0 ]
*/
ndarray( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, offsetX: number, beta: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array;
ndarray( uplo: MatrixTriangle, N: number, alpha: number, A: Float32Array, strideA1: number, strideA2: number, offsetA: number, x: Float32Array, strideX: number, offsetX: number, beta: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array;
}

/**
* 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.
* 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.
*
* @param order - storage layout
* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is to be referenced
* @param N - number of elements along each dimension in the matrix `A`
* @param alpha - scalar constant
* @param A - matrix
* @param A - input matrix
* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
* @param x - first input array
* @param strideX - `x` stride length
Expand All @@ -118,7 +120,7 @@ interface Routine {
* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] );
* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] );
*
* ssymv.ndarray( 'row-major', 'upper', 3, 2.0, A, 3, x, 1, 0, 1.0, y, 2, 0 );
* ssymv.ndarray( 'upper', 3, 2.0, A, 3, 1, 0, x, 1, 0, 1.0, y, 2, 0 );
* // y => <Float32Array>[ 3.0, 2.0, 11.0 ]
*/
declare var ssymv: Routine;
Expand Down
Loading
Loading