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