Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: add blas/base/sgbmv #2300

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
318 changes: 318 additions & 0 deletions lib/node_modules/@stdlib/blas/base/sgbmv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
<!--

@license Apache-2.0

Copyright (c) 2024 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# sgbmv

> Perform one of the matrix-vector operations `y = al*A*x + b*y` or `y = al*A**T*x + b*y` with kl as sub-diagonals and ku as super-diagonals.

<section class = "usage">

## Usage

```javascript
var sgbmv = require( '@stdlib/blas/base/sgbmv' );
```

#### sgbmv( ord, trans, M, N, kl, ku, a, A, LDA, x, sx, b, y, sy )

Performs one of the matrix-vector operations `y = a*A*x + b*y` or `y = a*A**T*x + b*y` with kl as sub-diagonals and ku as super-diagonals.

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

var trans = 'N';

var M = 4;
var N = 3;
var kl = 1;
var ku = 1;
var lda = 4;

var l = 2.0;
var b = 3.0;

var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); // eslint-disable-line max-len
var x = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );

sgbmv( 'row-major', trans, M, N, kl, ku, l, A, lda, x, 1, b, y, 1 );
// y => <Float32Array>[ 32.0, 77.0, 110.0, 99.0, 10.0 ]
```

The function has the following parameters:

- **ord**: storage layout.
- **trans**: specifies the operation to be performed.
- **M**: number of rows in the matrix `A`.
- **N**: number of columns in the matrix `A`.
- **kl**: number of sub-diagonals within the band of `A`.
- **ku**: number of super-diagonals within the band of `A`.
- **a**: scalar constant.
- **A**: matrix of coefficients [`Float32Array`][mdn-float32array].
- **lda**: stride of the first dimension of `A` (leading dimension of `A`).
- **x**: input [`Float32Array`][mdn-float32array].
- **sx**: index increment for `x`.
- **b**: scalar constant.
- **y**: output [`Float32Array`][mdn-float32array].
- **sy**: index increment for `y`.

The stride parameters determine how operations are performed. For example, to perform vector-matrix operation `y = a*A*x + b*y` or `y = a*A**T*x + b*y` with kl as sub-diagonals and ku as super-diagonals,

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

var trans = 'N';

var M = 4;
var N = 3;
var kl = 1;
var ku = 1;
var lda = 4;

var a = 2.0;
var b = 3.0;

var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); // eslint-disable-line max-len
var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0, 11.0 ] );

sgbmv( 'row-major', trans, M, N, kl, ku, a, A, lda, x, 1, b, y, 1 );
// y => <Float32Array>[ 32.0, 77.0, 110.0, 99.0, 10.0, 11.0 ]
```

Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.

<!-- eslint-disable stdlib/capitalized-comments -->

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

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

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

sgbmv( 'row-major', 'N', 2, 2, 1, 1, 1.0, A, 2, x1, -1, 1.0, y1, -1 );
// y0 => <Float32Array>[ 1.0, 1.0 ]
```

#### sgbmv.ndarray( ord, trans, M, N, kl, ku, a, A, LDA, x, sx, ox, b, y, sy, oy )

Performs one of the matrix-vector operations `y = a*A*x + b*y` or `y = a*A**T*x + b*y` with kl as sub-diagonals and ku as super-diagonals using alternative indexing semantics.

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

var trans = 'N';

var M = 4;
var N = 3;
var kl = 1;
var ku = 1;
var lda = 4;

var a = 2.0;
var b = 3.0;

var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); // eslint-disable-line max-len
var x = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );

sgbmv.ndarray( 'row-major', trans, M, N, kl, ku, a, A, lda, x, 1, 0, b, y, 1, 0 );
// y => <Float32Array>[ 32.0, 77.0, 110.0, 99.0, 10.0 ]
```

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`,...,

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

var trans = 'N';

var M = 4;
var N = 3;
var kl = 1;
var ku = 1;
var lda = 4;

var a = 2.0;
var b = 3.0;

var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); // eslint-disable-line max-len
var x = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] );

sgbmv.ndarray( 'column-major', 'N', M, N, kl, ku, a, A, 3, x, -1, 2, b, y, -1, 3 ); // eslint-disable-line max-len
// y => <Float32Array>[ 38.0, 61.0, 70.0, 45.0, 10.0 ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

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

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var sgbmv = require( '@stdlib/blas/base/sgbmv' );

var opts = {
'dtype': 'float32'
};

var trans = 'N';

var M = 3;
var N = 3;
var lda = 3;

var a = 1;
var b = 1;

var A = discreteUniform( M*N, 0, 255, opts );

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

sgbmv.ndarray( 'row-major', trans, M, N, 1, 1, a, A, lda, x, 1, 0, b, y, 1, 0 );
console.log( y );

```

</section>

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
#include "stdlib/blas/base/sgbmv.h"
```

#### TODO

TODO.

```c
TODO
```

TODO

```c
TODO
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
TODO
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

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

[sgbmv]: https://www.netlib.org/lapack/explore-html/d7/dda/group__gemv_ga0d35d880b663ad18204bb23bd186e380.html#ga0d35d880b663ad18204bb23bd186e380

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

[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

</section>

<!-- /.links -->
Loading
Loading