|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 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 | +# zlacgv |
| 22 | + |
| 23 | +> Conjugate each element in a double-precision complex floating-point vector. |
| 24 | +
|
| 25 | +<section class="usage"> |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```javascript |
| 30 | +var zlacgv = require( '@stdlib/lapack/base/zlacgv' ); |
| 31 | +``` |
| 32 | + |
| 33 | +#### zlacgv( N, zx, strideZX ) |
| 34 | + |
| 35 | +Conjugates each element in a double-precision complex floating-point vector. |
| 36 | + |
| 37 | +```javascript |
| 38 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 39 | +var real = require( '@stdlib/complex/float64/real' ); |
| 40 | +var imag = require( '@stdlib/complex/float64/imag' ); |
| 41 | + |
| 42 | +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); |
| 43 | + |
| 44 | +zlacgv( 2, zx, 1 ); |
| 45 | + |
| 46 | +var z = zx.get( 0 ); |
| 47 | +// returns <Complex128> |
| 48 | + |
| 49 | +var re = real( z ); |
| 50 | +// returns 1.0 |
| 51 | + |
| 52 | +var im = imag( z ); |
| 53 | +// returns -2.0 |
| 54 | +``` |
| 55 | + |
| 56 | +The function has the following parameters: |
| 57 | + |
| 58 | +- **N**: number of indexed elements. |
| 59 | +- **zx**: input [`Complex128Array`][@stdlib/array/complex128]. |
| 60 | +- **strideZX**: stride length for `zx`. |
| 61 | + |
| 62 | +The `N` and stride parameters determine which elements in `zx` are conjugated. For example, to conjugate every other element in `zx`, |
| 63 | + |
| 64 | +```javascript |
| 65 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 66 | +var real = require( '@stdlib/complex/float64/real' ); |
| 67 | +var imag = require( '@stdlib/complex/float64/imag' ); |
| 68 | + |
| 69 | +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); |
| 70 | + |
| 71 | +zlacgv( 2, zx, 2 ); |
| 72 | + |
| 73 | +var z = zx.get( 0 ); |
| 74 | +// returns <Complex128> |
| 75 | + |
| 76 | +var re = real( z ); |
| 77 | +// returns 1.0 |
| 78 | + |
| 79 | +var im = imag( z ); |
| 80 | +// returns -2.0 |
| 81 | +``` |
| 82 | + |
| 83 | +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. |
| 84 | + |
| 85 | +<!-- eslint-disable stdlib/capitalized-comments --> |
| 86 | + |
| 87 | +```javascript |
| 88 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 89 | +var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
| 90 | +var real = require( '@stdlib/complex/float64/real' ); |
| 91 | +var imag = require( '@stdlib/complex/float64/imag' ); |
| 92 | + |
| 93 | +// Initial array: |
| 94 | +var zx0 = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); |
| 95 | + |
| 96 | +// Create an offset view: |
| 97 | +var zx1 = new Complex128Array( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element |
| 98 | + |
| 99 | +// Conjugate every element in `zx1`: |
| 100 | +zlacgv( 3, zx1, 1 ); |
| 101 | + |
| 102 | +var z = zx0.get( 1 ); |
| 103 | +// returns <Complex128> |
| 104 | + |
| 105 | +var re = real( z ); |
| 106 | +// returns 3.0 |
| 107 | + |
| 108 | +var im = imag( z ); |
| 109 | +// returns -4.0 |
| 110 | +``` |
| 111 | + |
| 112 | +#### zlacgv.ndarray( N, zx, strideZX, offsetZX ) |
| 113 | + |
| 114 | +Conjugates each element in a double-precision floating-point vector using alternative indexing semantics. |
| 115 | + |
| 116 | +```javascript |
| 117 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 118 | +var real = require( '@stdlib/complex/float64/real' ); |
| 119 | +var imag = require( '@stdlib/complex/float64/imag' ); |
| 120 | + |
| 121 | +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); |
| 122 | + |
| 123 | +zlacgv.ndarray( 3, zx, 1, 0 ); |
| 124 | + |
| 125 | +var z = zx.get( 0 ); |
| 126 | +// returns <Complex128> |
| 127 | + |
| 128 | +var re = real( z ); |
| 129 | +// returns 1.0 |
| 130 | + |
| 131 | +var im = imag( z ); |
| 132 | +// returns -2.0 |
| 133 | +``` |
| 134 | + |
| 135 | +The function has the following additional parameters: |
| 136 | + |
| 137 | +- **offsetZX**: starting index for `zx`. |
| 138 | + |
| 139 | +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to conjugate every other element in the input strided array starting from the second element, |
| 140 | + |
| 141 | +```javascript |
| 142 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 143 | +var real = require( '@stdlib/complex/float64/real' ); |
| 144 | +var imag = require( '@stdlib/complex/float64/imag' ); |
| 145 | + |
| 146 | +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); |
| 147 | + |
| 148 | +zlacgv.ndarray( 2, zx, 2, 1 ); |
| 149 | + |
| 150 | +var z = zx.get( 3 ); |
| 151 | +// returns <Complex128> |
| 152 | + |
| 153 | +var re = real( z ); |
| 154 | +// returns 7.0 |
| 155 | + |
| 156 | +var im = imag( z ); |
| 157 | +// returns -8.0 |
| 158 | +``` |
| 159 | + |
| 160 | +</section> |
| 161 | + |
| 162 | +<!-- /.usage --> |
| 163 | + |
| 164 | +<section class="notes"> |
| 165 | + |
| 166 | +## Notes |
| 167 | + |
| 168 | +- If `N <= 0`, both functions return `zx` unchanged. |
| 169 | +- `zlacgv()` corresponds to the [LAPACK][lapack] BLAS-like level 1 routine [`zlacgv`][zlacgv]. |
| 170 | + |
| 171 | +</section> |
| 172 | + |
| 173 | +<!-- /.notes --> |
| 174 | + |
| 175 | +<section class="examples"> |
| 176 | + |
| 177 | +## Examples |
| 178 | + |
| 179 | +<!-- eslint no-undef: "error" --> |
| 180 | + |
| 181 | +```javascript |
| 182 | +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); |
| 183 | +var filledarrayBy = require( '@stdlib/array/filled-by' ); |
| 184 | +var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
| 185 | +var zlacgv = require( '@stdlib/lapack/base/zlacgv' ); |
| 186 | + |
| 187 | +function rand() { |
| 188 | + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); |
| 189 | +} |
| 190 | + |
| 191 | +var zx = filledarrayBy( 10, 'complex128', rand ); |
| 192 | +console.log( zx.toString() ); |
| 193 | + |
| 194 | +// Conjugate elements: |
| 195 | +zlacgv( zx.length, zx, 1 ); |
| 196 | +console.log( zx.get( zx.length-1 ).toString() ); |
| 197 | +``` |
| 198 | + |
| 199 | +</section> |
| 200 | + |
| 201 | +<!-- /.examples --> |
| 202 | + |
| 203 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 204 | + |
| 205 | +<section class="related"> |
| 206 | + |
| 207 | +</section> |
| 208 | + |
| 209 | +<!-- /.related --> |
| 210 | + |
| 211 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 212 | + |
| 213 | +<section class="links"> |
| 214 | + |
| 215 | +[lapack]: https://www.netlib.org/lapack |
| 216 | + |
| 217 | +[zlacgv]: https://www.netlib.org/lapack/explore-html/d9/d50/group__lacgv_gae42087fcabd33130fcbac2aff031de8b.html#gae42087fcabd33130fcbac2aff031de8b |
| 218 | + |
| 219 | +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray |
| 220 | + |
| 221 | +[@stdlib/array/complex128]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex128 |
| 222 | + |
| 223 | +</section> |
| 224 | + |
| 225 | +<!-- /.links --> |
0 commit comments