Skip to content

Commit 6390231

Browse files
committed
chore: implementation complete
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: failed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: failed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
1 parent e512edc commit 6390231

File tree

13 files changed

+673
-247
lines changed

13 files changed

+673
-247
lines changed
Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2024 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# sgbmv
22+
23+
> Perform one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var sgbmv = require( '@stdlib/blas/base/sgbmv' );
31+
```
32+
33+
#### sgbmv( ord, trans, M, N, KL, KU, α, A, LDA, x, sx, β, y, sy )
34+
35+
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` band matrix, with `KL` sub-diagonals and `KU` super-diagonals.
36+
37+
```javascript
38+
var Float32Array = require( '@stdlib/array/float32' );
39+
40+
var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 0.0 ] );
41+
var x = new Float32Array( [ 1.0, 1.0, 1.0 ] );
42+
var y = new Float32Array( [ 0.0, 0.0, 0.0 ] );
43+
44+
sgbmv( 'row-major', 'no-transpose', 3, 3, 1, 1, 1.0, A, 3, x, 1, 1.0, y, 1 );
45+
// y => <Float32Array>[ 3.0, 12.0, 13.0 ]
46+
```
47+
48+
The function has the following parameters:
49+
50+
- **ord**: storage layout.
51+
- **trans**: specifies whether `A` should be transposed, conjugate-transposed, or not transposed.
52+
- **M**: number of rows in the matrix `A`.
53+
- **N**: number of columns in the matrix `A`.
54+
- **α**: scalar constant.
55+
- **A**: input matrix stored in linear memory as a [`Float32Array`][mdn-float32array].
56+
- **lda**: stride of the first dimension of `A` (leading dimension of `A`).
57+
- **x**: input [`Float32Array`][mdn-float32array].
58+
- **sx**: index increment for `x`.
59+
- **β**: scalar constant.
60+
- **y**: output [`Float32Array`][mdn-float32array].
61+
- **sy**: index increment for `y`.
62+
63+
The stride parameters determine how operations are performed. For example, to iterate over every other element in `x` and `y`,
64+
65+
```javascript
66+
var Float32Array = require( '@stdlib/array/float32' );
67+
68+
var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 0.0 ] );
69+
var x = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );
70+
var y = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] );
71+
72+
sgbmv( 'row-major', 'no-transpose', 3, 3, 1, 1, 1.0, A, 3, x, 2, 1.0, y, 2 );
73+
// y => <Float32Array>[ 3.0, 0.0, 12.0, 0.0, 13.0 ]
74+
```
75+
76+
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
77+
78+
<!-- eslint-disable stdlib/capitalized-comments -->
79+
80+
```javascript
81+
var Float32Array = require( '@stdlib/array/float32' );
82+
83+
// Initial arrays...
84+
var x0 = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] );
85+
var y0 = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] );
86+
var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 0.0 ] );
87+
88+
// Create offset views...
89+
var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
90+
var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
91+
92+
sgbmv( 'row-major', 'no-transpose', 3, 3, 1, 1, 1.0, A, 3, x1, 1, 1.0, y1, 1 );
93+
// y0 => <Float32Array>[ 0.0, 3.0, 12.0, 13.0 ]
94+
```
95+
96+
#### sgbmv.ndarray( trans, M, N, KL, KU, α, A, sa1, sa2, oa, x, sx, ox, β, y, sy, oy )
97+
98+
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` band matrix, with `KL` sub-diagonals and `KU` super-diagonals.
99+
100+
```javascript
101+
var Float32Array = require( '@stdlib/array/float32' );
102+
103+
var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 0.0 ] );
104+
var x = new Float32Array( [ 1.0, 1.0, 1.0 ] );
105+
var y = new Float32Array( [ 0.0, 0.0, 0.0 ] );
106+
107+
sgbmv.ndarray( 'no-transpose', 3, 3, 1, 1, 1.0, A, 3, 1, 0, x, 1, 0, 1.0, y, 1, 0 );
108+
// y => <Float32Array>[ 3.0, 12.0, 13.0 ]
109+
```
110+
111+
The function has the following additional parameters:
112+
113+
- **sa1**: stride of the first dimension of `A`.
114+
- **sa2**: stride of the second dimension of `A`.
115+
- **oa**: starting index for `A`.
116+
- **ox**: starting index for `x`.
117+
- **oy**: starting index for `y`.
118+
119+
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,
120+
121+
```javascript
122+
var Float32Array = require( '@stdlib/array/float32' );
123+
124+
var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 0.0 ] );
125+
var x = new Float32Array( [ 1.0, 1.0, 1.0 ] );
126+
var y = new Float32Array( [ 0.0, 0.0, 0.0 ] );
127+
128+
sgbmv.ndarray( 'no-transpose', 3, 3, 1, 1, 1.0, A, 3, 1, 0, x, 1, 1, 1.0, y, -2, 2 );
129+
// y => <Float32Array>[ 12.0, 0.0, 3.0 ]
130+
```
131+
132+
</section>
133+
134+
<!-- /.usage -->
135+
136+
<section class="notes">
137+
138+
## Notes
139+
140+
- `sgbmv()` corresponds to the [BLAS][blas] level 2 function [`sgbmv`][blas-sgbmv].
141+
142+
</section>
143+
144+
<!-- /.notes -->
145+
146+
<section class="examples">
147+
148+
## Examples
149+
150+
<!-- eslint no-undef: "error" -->
151+
152+
```javascript
153+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
154+
var sgbmv = require( '@stdlib/blas/base/sgbmv' );
155+
156+
var opts = {
157+
'dtype': 'float32'
158+
};
159+
160+
var M = 3;
161+
var N = 3;
162+
163+
var A = [ 0, 9, 10, 11, 12, 5, 1, 2, 0 ];
164+
165+
var x = discreteUniform( N, 0, 255, opts );
166+
var y = discreteUniform( M, 0, 255, opts );
167+
168+
sgbmv( 'row-major', 'no-transpose', M, N, 1, 1, 1.0, A, N, x, 1, 1.0, y, 1 );
169+
console.log( y );
170+
171+
```
172+
173+
</section>
174+
175+
<!-- /.examples -->
176+
177+
<!-- C interface documentation. -->
178+
179+
* * *
180+
181+
<section class="c">
182+
183+
## C APIs
184+
185+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
186+
187+
<section class="intro">
188+
189+
</section>
190+
191+
<!-- /.intro -->
192+
193+
<!-- C usage documentation. -->
194+
195+
<section class="usage">
196+
197+
### Usage
198+
199+
```c
200+
#include "stdlib/blas/base/sgbmv.h"
201+
```
202+
203+
#### TODO
204+
205+
TODO.
206+
207+
```c
208+
TODO
209+
```
210+
211+
TODO
212+
213+
```c
214+
TODO
215+
```
216+
217+
</section>
218+
219+
<!-- /.usage -->
220+
221+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
222+
223+
<section class="notes">
224+
225+
</section>
226+
227+
<!-- /.notes -->
228+
229+
<!-- C API usage examples. -->
230+
231+
<section class="examples">
232+
233+
### Examples
234+
235+
```c
236+
TODO
237+
```
238+
239+
</section>
240+
241+
<!-- /.examples -->
242+
243+
</section>
244+
245+
<!-- /.c -->
246+
247+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
248+
249+
<section class="related">
250+
251+
</section>
252+
253+
<!-- /.related -->
254+
255+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
256+
257+
<section class="links">
258+
259+
[blas]: http://www.netlib.org/blas
260+
261+
[blas-sgbmv]: https://www.netlib.org/lapack/explore-html/d7/dda/group__gemv_ga0d35d880b663ad18204bb23bd186e380.html#ga0d35d880b663ad18204bb23bd186e380
262+
263+
[mdn-float32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array
264+
265+
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
266+
267+
</section>
268+
269+
<!-- /.links -->

0 commit comments

Comments
 (0)