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