Skip to content

Commit

Permalink
chore: apply review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-095 committed Aug 2, 2024
1 parent fce1241 commit 3411ac6
Show file tree
Hide file tree
Showing 13 changed files with 451 additions and 160 deletions.
38 changes: 19 additions & 19 deletions lib/node_modules/@stdlib/blas/base/dgemv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.

# dgemv

> Perform one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A**T*x + β*y`, where α and β are scalars, x and y are vectors and A is an m by n matrix.
> Perform one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A**T*x + β*y`.
<section class = "usage">

Expand All @@ -32,7 +32,7 @@ var dgemv = require( '@stdlib/blas/base/dgemv' );

#### dgemv( ord, trans, M, N, α, A, LDA, x, sx, β, y, sy )

Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A**T*x + β*y`, where α and β are scalars, x and y are vectors and A is an m by n matrix.
Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A**T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix.

```javascript
var Float64Array = require( '@stdlib/array/float64' );
Expand All @@ -48,29 +48,29 @@ dgemv( 'row-major', 'no-transpose', 2, 3, 1.0, A, 3, x, 1, 1.0, y, 1 );
The function has the following parameters:

- **ord**: storage layout.
- **trans**: specifies the operation to be performed.
- **trans**: specifies whether `A` should be transposed, conjugate-transposed, or not transposed.
- **M**: number of rows in the matrix `A`.
- **N**: number of columns in the matrix `A`.
- **α**: scalar constant.
- **A**: matrix of coefficients [`Float64Array`][mdn-float64array].
- **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array].
- **lda**: stride of the first dimension of `A` (leading dimension of `A`).
- **x**: input [`Float64Array`][mdn-float64array].
- **sx**: index increment for `x`.
- **β**: scalar constant.
- **y**: output [`Float64Array`][mdn-float64array].
- **sy**: index increment for `y`.

The stride parameters determine how operations are performed. For example, to perform one of the vector-matrix operation starting from first index of `x`,
The stride parameters determine how operations are performed. For example, to iterate over every other element in `x` and `y`,

```javascript
var Float64Array = require( '@stdlib/array/float64' );

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

dgemv( 'row-major', 'no-transpose', 2, 2, 1.0, A, 2, x, 1, 1.0, y, 1 );
// y => <Float64Array>[ 4.0, 8.0 ]
dgemv( 'row-major', 'no-transpose', 2, 2, 1.0, A, 2, x, 2, 1.0, y, 2 );
// y => <Float64Array>[ 4.0, 0.0, 8.0, 0.0 ]
```

Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
Expand All @@ -81,21 +81,21 @@ Note that indexing is relative to the first index. To introduce an offset, use [
var Float64Array = require( '@stdlib/array/float64' );

// Initial arrays...
var x0 = new Float64Array( [ 1.0, 1.0, 1.0 ] );
var y0 = new Float64Array( [ 1.0, 1.0 ] );
var x0 = new Float64Array( [ 0.0, 1.0, 1.0 ] );
var y0 = new Float64Array( [ 0.0, 1.0, 1.0 ] );
var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );

// Create offset views...
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 4th element
var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

dgemv( 'row-major', 'no-transpose', 2, 2, 1.0, A, 2, x1, -1, 1.0, y1, -1 );
// y0 => <Float64Array>[ 1.0, 8.0 ]
// y0 => <Float64Array>[ 0.0, 8.0, 4.0 ]
```

#### dgemv.ndarray( trans, M, N, α, A, sa1, sa2, oa, x, sx, ox, β, y, sy, oy )

Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A**T*x + β*y`, where α and β are scalars, x and y are vectors and A is an m by n matrix using alternative indexing semantics.
Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A**T*x + β*y`, using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix.

```javascript
var Float64Array = require( '@stdlib/array/float64' );
Expand All @@ -116,16 +116,16 @@ The function has the following additional parameters:
- **ox**: starting index for `x`.
- **oy**: starting index for `y`.

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, to perform operation with given `x` and `y` offset values`,...,
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,

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var x = new Float64Array( [ 1.0, 2.0, 3.0 ] );
var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );
var y = new Float64Array( [ 7.0, 8.0, 9.0, 10.0 ] );

dgemv.ndarray( 'no-transpose', 2, 3, 1.0, A, 3, 1, 0, x, 1, 0, 1.0, y, -2, 2 );
dgemv.ndarray( 'no-transpose', 2, 3, 1.0, A, 3, 1, 0, x, 1, 1, 1.0, y, -2, 2 );
// y => <Float64Array>[ 39, 8, 23, 10 ]
```

Expand All @@ -137,7 +137,7 @@ dgemv.ndarray( 'no-transpose', 2, 3, 1.0, A, 3, 1, 0, x, 1, 0, 1.0, y, -2, 2 );

## Notes

- `dgemv()` corresponds to the [BLAS][blas] level 2 function [`dgemv`][dgemv].
- `dgemv()` corresponds to the [BLAS][blas] level 2 function [`dgemv`][blas-dgemv].

</section>

Expand Down Expand Up @@ -257,7 +257,7 @@ TODO

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

[dgemv]: https://www.netlib.org/lapack/explore-html/d7/dda/group__gemv_ga4ac1b675072d18f902db8a310784d802.html#ga4ac1b675072d18f902db8a310784d802
[blas-dgemv]: https://www.netlib.org/lapack/explore-html/d7/dda/group__gemv_ga4ac1b675072d18f902db8a310784d802.html#ga4ac1b675072d18f902db8a310784d802

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

Expand Down
12 changes: 6 additions & 6 deletions lib/node_modules/@stdlib/blas/base/dgemv/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 x = uniform( len, -10.0, 10.0, options );
var y = uniform( len, -10.0, 10.0, options );
var A = uniform( len*len, -10.0, 10.0, options );
function createBenchmark( N ) {
var x = uniform( N, -10.0, 10.0, options );
var y = uniform( N, -10.0, 10.0, options );
var A = uniform( N*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 = dgemv( 'row-major', 'no-transpose', len, len, 1.0, A, len, x, 1, 1.0, y, 1 );
z = dgemv( 'row-major', 'no-transpose', N, N, 1.0, A, N, 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 x = uniform( len, -10.0, 10.0, options );
var y = uniform( len, -10.0, 10.0, options );
var A = uniform( len*len, -10.0, 10.0, options );
function createBenchmark( N ) {
var x = uniform( N, -10.0, 10.0, options );
var y = uniform( N, -10.0, 10.0, options );
var A = uniform( N*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 = dgemv( 'no-transpose', len, len, 1.0, A, len, 1, 0, x, 1, 0, 1.0, y, 1, 0 );
z = dgemv( 'no-transpose', N, 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
53 changes: 25 additions & 28 deletions lib/node_modules/@stdlib/blas/base/dgemv/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@

{{alias}}( ord, tp, M, N, α, A, lda, x, sx, β, y, sy )
Perform one of the matrix-vector operations `y = α*A*x + β*y`
or `y = α*A**T*x + β*y`, where `α` and `β` are scalars, `x` and `y`
are vectors and `A` is an `M` by `N` matrix.

The stride parameters determine how operations are performed.
{{alias}}( ord, trans, M, N, α, A, lda, x, sx, β, y, sy )
Performs one of the matrix-vector operations `y = α*A*x + β*y` or
`y = α*A**T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are
vectors, and `A` is an `M` by `N` matrix.

Indexing is relative to the first index. To introduce an offset, use typed
array views.

If `M` or `N` is equal to `0`, the function returns `y` unchanged.

If `α` equals `0` and β equals `1`, the function returns `y`
unchanged.
If `α` equals `0` and β equals `1`, the function returns `y` unchanged.

Parameters
----------
ord: string
Row-major (C-style) or column-major (Fortran-style) order.

tp: string
Specifies whether `A` should be transposed, conjugate-transposed, or
not transposed.
trans: string
Specifies whether `A` should be transposed, conjugate-transposed, or not
transposed.

M: integer
Number of rows in `A`.
Expand Down Expand Up @@ -57,7 +54,7 @@
Returns
-------
y: Float64Array
Output array.
Second input vector.

Examples
--------
Expand All @@ -66,43 +63,43 @@
> var y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] );
> var ord = 'row-major';
> var tp = 'no-transpose';
> {{alias}}( ord, tp, 2, 2, 1.0, A, 2, x, 1, 1.0, y, 1 )
> var trans = 'no-transpose';
> {{alias}}( ord, trans, 2, 2, 1.0, A, 2, x, 1, 1.0, y, 1 )
<Float64Array>[ 4.0, 8.0 ]

// Advanced indexing:
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] );
> {{alias}}( ord, tp, 2, 2, 1.0, A, 2, x, -1, 1.0, y, -1 )
> {{alias}}( ord, trans, 2, 2, 1.0, A, 2, x, -1, 1.0, y, -1 )
<Float64Array>[ 8.0, 4.0 ]

// Using typed array views:
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0, 1.0 ] );
> var y0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 );
> {{alias}}( ord, tp, 2, 2, 1.0, A, 2, x1, -1, 1.0, y1, -1 );
> {{alias}}( ord, trans, 2, 2, 1.0, A, 2, x1, -1, 1.0, y1, -1 );
> y0
<Float64Array>[ 1.0, 8.0 ]


{{alias}}.ndarray( tp, M, N, α, A, sa1, sa2, oa, x, sx, ox, β, y, sy, oy )
Perform one of the matrix-vector operations `y = α*A*x + β*y`
or `y = α*A**T*x + β*y`, where `α` and `β` are scalars, `x` and `y`
are vectors and `A` is an `M` by `N` matrix using alternative indexing
semantics.
{{alias}}.ndarray( trans, M, N, α, A, sa1, sa2, oa, x, sx, ox, β, y, sy, oy )
Performs one of the matrix-vector operations `y = α*A*x + β*y` or
`y = α*A**T*x + β*y`, using alternative indexing semantics and where `α`
and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N`
matrix.

While typed array views mandate a view offset based on the underlying
buffer, the offset parameters support indexing semantics based on starting
indices.

Parameters
----------
tp: string
Specifies whether `A` should be transposed, conjugate-transposed, or
not transposed.
trans: string
Specifies whether `A` should be transposed, conjugate-transposed, or not
transposed.

M: integer
Number of rows in `A`.
Expand Down Expand Up @@ -149,15 +146,15 @@
Returns
-------
y: Float64Array
Output array.
Second input vector.

Examples
--------
> 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, 3.0, 4.0 ] );
> var tp = 'no-transpose';
> {{alias}}.ndarray( tp, 2, 2, 1, A, 2, 1, 0, x, 1, 0, 1, y, 1, 0 )
> var trans = 'no-transpose';
> {{alias}}.ndarray( trans, 2, 2, 1, A, 2, 1, 0, x, 1, 0, 1, y, 1, 0 )
<Float64Array>[ 4.0, 8.0 ]

See Also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Layout, TransposeOperation } from '@stdlib/types/blas';
*/
interface Routine {
/**
* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y`, where alpha and beta are scalars, x and y are vectors and A is an m by n matrix.
* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix.
*
* @param order - storage layout
* @param trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed
Expand Down Expand Up @@ -56,7 +56,7 @@ interface Routine {
( order: Layout, trans: TransposeOperation, M: number, N: number, alpha: number, A: Float64Array, LDA: number, x: Float64Array, strideX: number, beta: number, y: Float64Array, strideY: number ): Float64Array;

/**
* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y`, using alternative indexing semantics, where alpha and beta are scalars, x and y are vectors and A is an m by n matrix.
* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix.
*
* @param trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed
* @param M - number of rows in the matrix `A`
Expand Down Expand Up @@ -89,7 +89,7 @@ interface Routine {
}

/**
* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y`, where alpha and beta are scalars, x and y are vectors and A is an m by n matrix.
* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix.
*
* @param order - storage layout
* @param trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed
Expand Down
Loading

0 comments on commit 3411ac6

Please sign in to comment.