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