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