Skip to content

Commit

Permalink
refactor: update implementation, apply corresponding changes and add …
Browse files Browse the repository at this point in the history
…test cases supporting ndarray
  • Loading branch information
aman-095 committed Aug 29, 2024
1 parent 0ab9fc7 commit 12f5df7
Show file tree
Hide file tree
Showing 41 changed files with 1,762 additions and 878 deletions.
18 changes: 12 additions & 6 deletions lib/node_modules/@stdlib/blas/base/dsymv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.

# dsymv

> 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 @@ dsymv( 'row-major', 'upper', 3, 1.0, A, 3, x1, -1, 1.0, y1, -1 );
// y0 => <Float64Array>[ 1.0, 4.0, 3.0, 2.0 ]
```

#### dsymv.ndarray( order, uplo, N, α, A, LDA, x, sx, ox, β, y, sy, oy )
#### dsymv.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 Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] );
var x = new Float64Array( [ 1.0, 2.0, 3.0 ] );
var y = new Float64Array( [ 1.0, 2.0, 3.0 ] );

dsymv.ndarray( 'row-major', 'upper', 3, 2.0, A, 3, x, -1, 2, 1.0, y, 1, 0 );
dsymv.ndarray( 'upper', 3, 2.0, A, 3, 1, 0, x, -1, 2, 1.0, y, 1, 0 );
// y => <Float64Array>[ 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 Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] );
var x = new Float64Array( [ 1.0, 1.0, 1.0 ] );
var y = new Float64Array( [ 1.0, 1.0, 1.0 ] );

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

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

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 );

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

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

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

A: Float64Array
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 @@
<Float64Array>[ 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: Float64Array
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: Float64Array
Input vector.
Expand Down Expand Up @@ -126,8 +127,7 @@
> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> var y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> var A = new {{alias:@stdlib/array/float64}}( [ 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 )
<Float64Array>[ 4.0, 4.0 ]

See Also
Expand Down
26 changes: 14 additions & 12 deletions lib/node_modules/@stdlib/blas/base/dsymv/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: Float64Array, LDA: number, 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.
* 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 matrix
* @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 Float64Array( [ 1.0, 1.0, 1.0 ] );
* var y = new Float64Array( [ 0.0, 0.0, 0.0 ] );
*
* dsymv.ndarray( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0, 0.0, y, 1, 0 );
* dsymv.ndarray( 'lower', 3, 1.0, A, 3, 1, 0, x, 1, 0, 0.0, y, 1, 0 );
* // y => <Float64Array>[ 1.0, 2.0, 3.0 ]
*/
ndarray( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, A: Float64Array, LDA: number, x: Float64Array, strideX: number, offsetX: number, beta: number, y: Float64Array, strideY: number, offsetY: number ): Float64Array;
ndarray( uplo: MatrixTriangle, N: number, alpha: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: 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.
* 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 Float64Array( [ 1.0, 2.0, 3.0 ] );
* var y = new Float64Array( [ 1.0, 2.0, 3.0 ] );
*
* dsymv.ndarray( 'row-major', 'upper', 3, 2.0, A, 3, x, 1, 0, 1.0, y, 2, 0 );
* dsymv.ndarray( 'upper', 3, 2.0, A, 3, 1, 0, x, 1, 0, 1.0, y, 2, 0 );
* // y => <Float64Array>[ 3.0, 2.0, 11.0 ]
*/
declare var dsymv: Routine;
Expand Down
Loading

0 comments on commit 12f5df7

Please sign in to comment.