|
| 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 | +# strmv |
| 22 | + |
| 23 | +> Perform one of the matrix-vector operations `x = A*x` or `x = A^T*x`. |
| 24 | +
|
| 25 | +<section class = "usage"> |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```javascript |
| 30 | +var strmv = require( '@stdlib/blas/base/strmv' ); |
| 31 | +``` |
| 32 | + |
| 33 | +#### strmv( order, uplo, trans, diag, N, A, LDA, x, sx ) |
| 34 | + |
| 35 | +Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. |
| 36 | + |
| 37 | +```javascript |
| 38 | +var Float32Array = require( '@stdlib/array/float32' ); |
| 39 | + |
| 40 | +var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); |
| 41 | +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); |
| 42 | + |
| 43 | +strmv( 'row-major', 'upper', 'no-transpose', 'unit', 3, A, 3, x, 1 ); |
| 44 | +// x => <Float32Array>[ 14.0, 8.0, 3.0 ] |
| 45 | +``` |
| 46 | + |
| 47 | +The function has the following parameters: |
| 48 | + |
| 49 | +- **order**: storage layout. |
| 50 | +- **uplo**: specifies whether `A` is an upper or lower triangular matrix. |
| 51 | +- **trans**: specifies whether `A` should be transposed, conjugate-transposed, or not transposed. |
| 52 | +- **diag**: specifies whether `A` has a unit diagonal. |
| 53 | +- **N**: number of elements along each dimension of `A`. |
| 54 | +- **A**: input matrix stored in linear memory as a [`Float32Array`][mdn-float32array]. |
| 55 | +- **lda**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). |
| 56 | +- **x**: input vector [`Float32Array`][mdn-float32array]. |
| 57 | +- **sx**: `x` stride length. |
| 58 | + |
| 59 | +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, |
| 60 | + |
| 61 | +```javascript |
| 62 | +var Float32Array = require( '@stdlib/array/float32' ); |
| 63 | + |
| 64 | +var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); |
| 65 | +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); |
| 66 | + |
| 67 | +strmv( 'row-major', 'upper', 'no-transpose', 'unit', 3, A, 3, x, -1 ); |
| 68 | +// x => <Float32Array>[ 1.0, 4.0, 10.0 ] |
| 69 | +``` |
| 70 | + |
| 71 | +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. |
| 72 | + |
| 73 | +<!-- eslint-disable stdlib/capitalized-comments --> |
| 74 | + |
| 75 | +```javascript |
| 76 | +var Float32Array = require( '@stdlib/array/float32' ); |
| 77 | + |
| 78 | +// Initial arrays... |
| 79 | +var x0 = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); |
| 80 | +var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); |
| 81 | + |
| 82 | +// Create offset views... |
| 83 | +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element |
| 84 | + |
| 85 | +strmv( 'row-major', 'upper', 'no-transpose', 'unit', 3, A, 3, x1, 1 ); |
| 86 | +// x0 => <Float32Array>[ 1.0, 6.0, 3.0, 1.0 ] |
| 87 | +``` |
| 88 | + |
| 89 | +#### strmv.ndarray( uplo, trans, diag, N, A, sa1, sa2, oa, x, sx, ox ) |
| 90 | + |
| 91 | +Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, using alternative indexing semantics and where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. |
| 92 | + |
| 93 | +```javascript |
| 94 | +var Float32Array = require( '@stdlib/array/float32' ); |
| 95 | + |
| 96 | +var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); |
| 97 | +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); |
| 98 | + |
| 99 | +strmv.ndarray( 'upper', 'no-transpose', 'unit', 3, A, 3, 1, 0, x, 1, 0 ); |
| 100 | +// x => <Float32Array>[ 14.0, 8.0, 3.0 ] |
| 101 | +``` |
| 102 | + |
| 103 | +The function has the following additional parameters: |
| 104 | + |
| 105 | +- **sa1**: stride of the first dimension of `A`. |
| 106 | +- **sa2**: stride of the second dimension of `A`. |
| 107 | +- **oa**: starting index for `A`. |
| 108 | +- **ox**: starting index for `x`. |
| 109 | + |
| 110 | +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, |
| 111 | + |
| 112 | +```javascript |
| 113 | +var Float32Array = require( '@stdlib/array/float32' ); |
| 114 | + |
| 115 | +var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); |
| 116 | +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); |
| 117 | + |
| 118 | +strmv.ndarray( 'upper', 'no-transpose', 'unit', 3, A, 3, 1, 0, x, -1, 2 ); |
| 119 | +// x => <Float32Array>[ 1.0, 4.0, 10.0 ] |
| 120 | +``` |
| 121 | + |
| 122 | +</section> |
| 123 | + |
| 124 | +<!-- /.usage --> |
| 125 | + |
| 126 | +<section class="notes"> |
| 127 | + |
| 128 | +## Notes |
| 129 | + |
| 130 | +- `strmv()` corresponds to the [BLAS][blas] level 2 function [`strmv`][blas-strmv]. |
| 131 | + |
| 132 | +</section> |
| 133 | + |
| 134 | +<!-- /.notes --> |
| 135 | + |
| 136 | +<section class="examples"> |
| 137 | + |
| 138 | +## Examples |
| 139 | + |
| 140 | +<!-- eslint no-undef: "error" --> |
| 141 | + |
| 142 | +```javascript |
| 143 | +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); |
| 144 | +var strmv = require( '@stdlib/blas/base/strmv' ); |
| 145 | + |
| 146 | +var opts = { |
| 147 | + 'dtype': 'float32' |
| 148 | +}; |
| 149 | + |
| 150 | +var N = 5; |
| 151 | + |
| 152 | +var A = discreteUniform( N*N, -10.0, 10.0, opts ); |
| 153 | +var x = discreteUniform( N, -10.0, 10.0, opts ); |
| 154 | + |
| 155 | +strmv( 'column-major', 'upper', 'no-transpose', 'unit', N, A, N, x, 1 ); |
| 156 | +console.log( x ); |
| 157 | + |
| 158 | +strmv.ndarray( 'upper', 'no-transpose', 'unit', N, A, 1, N, 0, x, 1, 0 ); |
| 159 | +console.log( x ); |
| 160 | +``` |
| 161 | + |
| 162 | +</section> |
| 163 | + |
| 164 | +<!-- /.examples --> |
| 165 | + |
| 166 | +<!-- C interface documentation. --> |
| 167 | + |
| 168 | +* * * |
| 169 | + |
| 170 | +<section class="c"> |
| 171 | + |
| 172 | +## C APIs |
| 173 | + |
| 174 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 175 | + |
| 176 | +<section class="intro"> |
| 177 | + |
| 178 | +</section> |
| 179 | + |
| 180 | +<!-- /.intro --> |
| 181 | + |
| 182 | +<!-- C usage documentation. --> |
| 183 | + |
| 184 | +<section class="usage"> |
| 185 | + |
| 186 | +### Usage |
| 187 | + |
| 188 | +```c |
| 189 | +TODO |
| 190 | +``` |
| 191 | + |
| 192 | +#### TODO |
| 193 | + |
| 194 | +TODO. |
| 195 | + |
| 196 | +```c |
| 197 | +TODO |
| 198 | +``` |
| 199 | + |
| 200 | +TODO |
| 201 | + |
| 202 | +```c |
| 203 | +TODO |
| 204 | +``` |
| 205 | + |
| 206 | +</section> |
| 207 | + |
| 208 | +<!-- /.usage --> |
| 209 | + |
| 210 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 211 | + |
| 212 | +<section class="notes"> |
| 213 | + |
| 214 | +</section> |
| 215 | + |
| 216 | +<!-- /.notes --> |
| 217 | + |
| 218 | +<!-- C API usage examples. --> |
| 219 | + |
| 220 | +<section class="examples"> |
| 221 | + |
| 222 | +### Examples |
| 223 | + |
| 224 | +```c |
| 225 | +TODO |
| 226 | +``` |
| 227 | + |
| 228 | +</section> |
| 229 | + |
| 230 | +<!-- /.examples --> |
| 231 | + |
| 232 | +</section> |
| 233 | + |
| 234 | +<!-- /.c --> |
| 235 | + |
| 236 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 237 | + |
| 238 | +<section class="related"> |
| 239 | + |
| 240 | +</section> |
| 241 | + |
| 242 | +<!-- /.related --> |
| 243 | + |
| 244 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 245 | + |
| 246 | +<section class="links"> |
| 247 | + |
| 248 | +[blas]: http://www.netlib.org/blas |
| 249 | + |
| 250 | +[blas-strmv]: https://www.netlib.org/lapack/explore-html/d6/d1c/group__trmv_ga7b90369d2b2b19f78f168e10dd9eb8ad.html#ga7b90369d2b2b19f78f168e10dd9eb8ad |
| 251 | + |
| 252 | +[mdn-float32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array |
| 253 | + |
| 254 | +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray |
| 255 | + |
| 256 | +</section> |
| 257 | + |
| 258 | +<!-- /.links --> |
0 commit comments