Skip to content

Commit 4dc4f6c

Browse files
aman-095kgryteShabiShett07stdlib-bot
authored
refactor: update implementation for blas/base/ssymv
PR-URL: #2843 Ref: #2039 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]> Co-authored-by: Shabareesh Shetty <[email protected]> Reviewed-by: Shabareesh Shetty <[email protected]> Co-authored-by: stdlib-bot <[email protected]>
1 parent 25ed2e6 commit 4dc4f6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2018
-962
lines changed

lib/node_modules/@stdlib/blas/base/ssymv/README.md

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# ssymv
2222

23-
> 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.
23+
> Perform the matrix-vector operation `y = α*A*x + β*y`.
2424
2525
<section class="usage">
2626

@@ -37,12 +37,12 @@ Performs the matrix-vector operation `y = α*A*x + β*y` where `α` and `β` are
3737
```javascript
3838
var Float32Array = require( '@stdlib/array/float32' );
3939

40-
var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] );
40+
var A = new Float32Array( [ 1.0, 4.0, 5.0, 4.0, 2.0, 6.0, 5.0, 6.0, 3.0 ] );
4141
var x = new Float32Array( [ 1.0, 1.0, 1.0 ] );
4242
var y = new Float32Array( [ 0.0, 0.0, 0.0 ] );
4343

4444
ssymv( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0.0, y, 1 );
45-
// y => <Float32Array>[ 1.0, 2.0, 3.0 ]
45+
// y => <Float32Array>[ 10.0, 12.0, 14.0 ]
4646
```
4747

4848
The function has the following parameters:
@@ -54,22 +54,22 @@ The function has the following parameters:
5454
- **A**: input matrix stored in linear memory as a [`Float32Array`][mdn-float32array].
5555
- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`).
5656
- **x**: input [`Float32Array`][mdn-float32array].
57-
- **sx**: index increment for `x`.
57+
- **sx**: stride length for `x`.
5858
- **β**: scalar constant.
5959
- **y**: output [`Float32Array`][mdn-float32array].
60-
- **sy**: index increment for `y`.
60+
- **sy**: stride length for `y`.
6161

6262
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,
6363

6464
```javascript
6565
var Float32Array = require( '@stdlib/array/float32' );
6666

67-
var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] );
68-
var x = new Float32Array( [ 1.0, 2.0, 3.0 ] );
69-
var y = new Float32Array( [ 1.0, 2.0, 3.0 ] );
67+
var A = new Float32Array( [ 1.0, 4.0, 5.0, 4.0, 2.0, 6.0, 5.0, 6.0, 3.0 ] );
68+
var x = new Float32Array( [ 1.0, 1.0, 1.0 ] );
69+
var y = new Float32Array( [ 0.0, 0.0, 0.0 ] );
7070

71-
ssymv( 'row-major', 'upper', 3, 2.0, A, 3, x, -1, 1.0, y, 1 );
72-
// y => <Float32Array>[ 7.0, 10.0, 9.0 ]
71+
ssymv( 'row-major', 'upper', 3, 1.0, A, 3, x, -1, 1.0, y, 1 );
72+
// y => <Float32Array>[ 10.0, 12.0, 14.0 ]
7373
```
7474

7575
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
@@ -80,35 +80,38 @@ Note that indexing is relative to the first index. To introduce an offset, use [
8080
var Float32Array = require( '@stdlib/array/float32' );
8181

8282
// Initial arrays...
83-
var x0 = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] );
84-
var y0 = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] );
85-
var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] );
83+
var x0 = new Float32Array( [ 0.0, 1.0, 1.0, 1.0 ] );
84+
var y0 = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] );
85+
var A = new Float32Array( [ 1.0, 4.0, 5.0, 4.0, 2.0, 6.0, 5.0, 6.0, 3.0 ] );
8686

8787
// Create offset views...
8888
var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
8989
var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
9090

9191
ssymv( 'row-major', 'upper', 3, 1.0, A, 3, x1, -1, 1.0, y1, -1 );
92-
// y0 => <Float32Array>[ 1.0, 4.0, 3.0, 2.0 ]
92+
// y0 => <Float32Array>[ 0.0, 14.0, 12.0, 10.0 ]
9393
```
9494

95-
#### ssymv.ndarray( order, uplo, N, α, A, LDA, x, sx, ox, β, y, sy, oy )
95+
#### ssymv.ndarray( uplo, N, α, A, sa1, sa2, oa, x, sx, ox, β, y, sy, oy )
9696

9797
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.
9898

9999
```javascript
100100
var Float32Array = require( '@stdlib/array/float32' );
101101

102-
var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] );
103-
var x = new Float32Array( [ 1.0, 2.0, 3.0 ] );
104-
var y = new Float32Array( [ 1.0, 2.0, 3.0 ] );
102+
var A = new Float32Array( [ 1.0, 4.0, 5.0, 4.0, 2.0, 6.0, 5.0, 6.0, 3.0 ] );
103+
var x = new Float32Array( [ 1.0, 1.0, 1.0 ] );
104+
var y = new Float32Array( [ 0.0, 0.0, 0.0 ] );
105105

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

110110
The function has the following additional parameters:
111111

112+
- **sa1**: stride for the first dimension of `A`.
113+
- **sa2**: stride for the second dimension of `A`.
114+
- **oa**: starting index for `A`.
112115
- **ox**: starting index for `x`.
113116
- **oy**: starting index for `y`.
114117

@@ -117,12 +120,12 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the
117120
```javascript
118121
var Float32Array = require( '@stdlib/array/float32' );
119122

120-
var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] );
123+
var A = new Float32Array( [ 1.0, 4.0, 5.0, 4.0, 2.0, 6.0, 5.0, 6.0, 3.0 ] );
121124
var x = new Float32Array( [ 1.0, 1.0, 1.0 ] );
122-
var y = new Float32Array( [ 1.0, 1.0, 1.0 ] );
125+
var y = new Float32Array( [ 0.0, 0.0, 0.0 ] );
123126

124-
ssymv.ndarray( 'row-major', 'lower', 3, 1.0, A, 3, x, -1, 2, 1.0, y, -1, 2 );
125-
// y => <Float32Array>[ 4.0, 3.0, 2.0 ]
127+
ssymv.ndarray( 'lower', 3, 1.0, A, 3, 1, 0, x, -1, 2, 1.0, y, -1, 2 );
128+
// y => <Float32Array>[ 14.0, 12.0, 10.0 ]
126129
```
127130

128131
</section>
@@ -154,13 +157,16 @@ var opts = {
154157
'dtype': 'float32'
155158
};
156159

157-
var N = 3;
160+
var N = 5;
158161
var A = ones( N*N, opts.dtype );
159162

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

163-
ssymv.ndarray( 'row-major', 'upper', N, 1.0, A, N, x, 1, 0, 1.0, y, 1, 0 );
166+
ssymv( 'row-major', 'upper', N, 1.0, A, N, x, 1, 1.0, y, 1 );
167+
console.log( y );
168+
169+
ssymv.ndarray( 'upper', N, 1.0, A, N, 1, 0, x, 1, 0, 1.0, y, 1, 0 );
164170
console.log( y );
165171
```
166172

@@ -252,7 +258,7 @@ TODO
252258

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

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

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

lib/node_modules/@stdlib/blas/base/ssymv/benchmark/benchmark.ndarray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function createBenchmark( N ) {
6464

6565
b.tic();
6666
for ( i = 0; i < b.iterations; i++ ) {
67-
z = ssymv( 'row-major', 'upper', N, 1.0, A, N, x, 1, 0, 1.0, y, 1, 0 );
67+
z = ssymv( 'upper', N, 1.0, A, N, 1, 0, x, 1, 0, 1.0, y, 1, 0 );
6868
if ( isnanf( z[ i%z.length ] ) ) {
6969
b.fail( 'should not return NaN' );
7070
}

lib/node_modules/@stdlib/blas/base/ssymv/docs/repl.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Scalar constant.
2929

3030
A: Float32Array
31-
Matrix.
31+
Input matrix.
3232

3333
lda: integer
3434
Stride of the first dimension of `A` (a.k.a., leading dimension of the
@@ -63,7 +63,7 @@
6363
<Float32Array>[ 4.0, 4.0 ]
6464

6565

66-
{{alias}}.ndarray( order, uplo, N, α, A, lda, x, sx, ox, β, y, sy, oy )
66+
{{alias}}.ndarray( uplo, N, α, A, sa1, sa2, oa, x, sx, ox, β, y, sy, oy )
6767
Performs the matrix-vector operation `y = α*A*x + β*y` using alternative
6868
indexing semantics and where `α` and `β` are scalars, `x` and `y` are `N`
6969
element vectors, and `A` is an `N` by `N` symmetric matrix.
@@ -74,10 +74,6 @@
7474

7575
Parameters
7676
----------
77-
order: string
78-
Row-major (C-style) or column-major (Fortran-style) order. Must be
79-
either 'row-major' or 'column-major'.
80-
8177
uplo: string
8278
Specifies whether to reference the upper or lower triangular part of
8379
`A`. Must be either 'upper' or 'lower'.
@@ -89,11 +85,16 @@
8985
Scalar constant.
9086

9187
A: Float32Array
92-
Matrix.
88+
Input matrix.
9389

94-
lda: integer
95-
Stride of the first dimension of `A` (a.k.a., leading dimension of the
96-
matrix `A`).
90+
sa1: integer
91+
Stride for the first dimension of `A`.
92+
93+
sa2: integer
94+
Stride for the second dimension of `A`.
95+
96+
oa: integer
97+
Starting index for `A`.
9798

9899
x: Float32Array
99100
Input vector.
@@ -126,8 +127,7 @@
126127
> var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] );
127128
> var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] );
128129
> var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 2.0, 1.0 ] );
129-
> var ord = 'row-major';
130-
> {{alias}}.ndarray( ord, 'upper', 2, 1.0, A, 2, x, 1, 0, 1.0, y, 1, 0 )
130+
> {{alias}}.ndarray( 'upper', 2, 1.0, A, 2, 1, 0, x, 1, 0, 1.0, y, 1, 0 )
131131
<Float32Array>[ 4.0, 4.0 ]
132132

133133
See Also

lib/node_modules/@stdlib/blas/base/ssymv/docs/types/index.d.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ import { Layout, MatrixTriangle } from '@stdlib/types/blas';
2727
*/
2828
interface Routine {
2929
/**
30-
* 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.
30+
* 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.
3131
*
3232
* @param order - storage layout
33-
* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is to be referenced
33+
* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced
3434
* @param N - number of elements along each dimension in the matrix `A`
3535
* @param alpha - scalar constant
36-
* @param A - matrix
36+
* @param A - input matrix
3737
* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
3838
* @param x - first input array
3939
* @param strideX - `x` stride length
@@ -55,21 +55,23 @@ interface Routine {
5555
( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array;
5656

5757
/**
58-
* 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.
58+
* 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.
5959
*
6060
* @param order - storage layout
6161
* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced
6262
* @param N - number of elements along each dimension in the matrix `A`
6363
* @param alpha - scalar constant
64-
* @param A - matrix
65-
* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
64+
* @param A - input
65+
* @param strideA1 - stride for the first dimension of `A`
66+
* @param strideA2 - stride for the second dimension of `A`
67+
* @param offsetA - starting index for `A`
6668
* @param x - first input array
6769
* @param strideX - `x` stride length
68-
* @param offsetX - starting `x` index
70+
* @param offsetX - starting index for `x`
6971
* @param beta - scalar constant
7072
* @param y - second input array
7173
* @param strideY - `y` stride length
72-
* @param offsetY - starting `y` index
74+
* @param offsetY - starting index for `y`
7375
* @returns `y`
7476
*
7577
* @example
@@ -79,20 +81,20 @@ interface Routine {
7981
* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] );
8082
* var y = new Float32Array( [ 0.0, 0.0, 0.0 ] );
8183
*
82-
* ssymv.ndarray( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0, 0.0, y, 1, 0 );
84+
* ssymv.ndarray( 'lower', 3, 1.0, A, 3, 1, 0, x, 1, 0, 0.0, y, 1, 0 );
8385
* // y => <Float32Array>[ 1.0, 2.0, 3.0 ]
8486
*/
85-
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;
87+
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;
8688
}
8789

8890
/**
89-
* 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.
91+
* 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.
9092
*
9193
* @param order - storage layout
92-
* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is to be referenced
94+
* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced
9395
* @param N - number of elements along each dimension in the matrix `A`
9496
* @param alpha - scalar constant
95-
* @param A - matrix
97+
* @param A - input matrix
9698
* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
9799
* @param x - first input array
98100
* @param strideX - `x` stride length
@@ -118,7 +120,7 @@ interface Routine {
118120
* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] );
119121
* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] );
120122
*
121-
* ssymv.ndarray( 'row-major', 'upper', 3, 2.0, A, 3, x, 1, 0, 1.0, y, 2, 0 );
123+
* ssymv.ndarray( 'upper', 3, 2.0, A, 3, 1, 0, x, 1, 0, 1.0, y, 2, 0 );
122124
* // y => <Float32Array>[ 3.0, 2.0, 11.0 ]
123125
*/
124126
declare var ssymv: Routine;

0 commit comments

Comments
 (0)