|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2018 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 | +# conj |
| 22 | + |
| 23 | +> Return the [complex conjugate][complex-conjugate] of a double-precision complex floating-point number. |
| 24 | +
|
| 25 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 26 | + |
| 27 | +<section class="intro"> |
| 28 | + |
| 29 | +</section> |
| 30 | + |
| 31 | +<!-- /.intro --> |
| 32 | + |
| 33 | +<!-- Package usage documentation. --> |
| 34 | + |
| 35 | +<section class="usage"> |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +```javascript |
| 40 | +var conj = require( '@stdlib/complex/float64/conj' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### conj( z ) |
| 44 | + |
| 45 | +Returns the [complex conjugate][complex-conjugate] of a double-precision complex floating-point number. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
| 49 | + |
| 50 | +var z = new Complex128( 5.0, 3.0 ); |
| 51 | +var str = z.toString(); |
| 52 | +// returns '5 + 3i' |
| 53 | + |
| 54 | +var v = conj( z ); |
| 55 | +str = v.toString(); |
| 56 | +// returns '5 - 3i' |
| 57 | +``` |
| 58 | + |
| 59 | +</section> |
| 60 | + |
| 61 | +<!-- /.usage --> |
| 62 | + |
| 63 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 64 | + |
| 65 | +<section class="notes"> |
| 66 | + |
| 67 | +</section> |
| 68 | + |
| 69 | +<!-- /.notes --> |
| 70 | + |
| 71 | +<!-- Package usage examples. --> |
| 72 | + |
| 73 | +<section class="examples"> |
| 74 | + |
| 75 | +## Examples |
| 76 | + |
| 77 | +<!-- eslint-disable max-len --> |
| 78 | + |
| 79 | +<!-- eslint no-undef: "error" --> |
| 80 | + |
| 81 | +```javascript |
| 82 | +var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
| 83 | +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); |
| 84 | +var filledarrayBy = require( '@stdlib/array/filled-by' ); |
| 85 | +var conj = require( '@stdlib/complex/float64/conj' ); |
| 86 | + |
| 87 | +function random() { |
| 88 | + return new Complex128( discreteUniform( -10, 10 ), discreteUniform( -10, 10 ) ); |
| 89 | +} |
| 90 | + |
| 91 | +// Generate an array of random complex numbers: |
| 92 | +var x = filledarrayBy( 100, 'complex128', random ); |
| 93 | +// returns <Complex128Array> |
| 94 | + |
| 95 | +// Compute the complex conjugate of each complex number... |
| 96 | +var z; |
| 97 | +var i; |
| 98 | +for ( i = 0; i < 100; i++ ) { |
| 99 | + z = x.get( i ); |
| 100 | + console.log( 'conj(%s) = %s', z.toString(), conj( z ).toString() ); |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +</section> |
| 105 | + |
| 106 | +<!-- /.examples --> |
| 107 | + |
| 108 | +<!-- C interface documentation. --> |
| 109 | + |
| 110 | +* * * |
| 111 | + |
| 112 | +<section class="c"> |
| 113 | + |
| 114 | +## C APIs |
| 115 | + |
| 116 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 117 | + |
| 118 | +<section class="intro"> |
| 119 | + |
| 120 | +</section> |
| 121 | + |
| 122 | +<!-- /.intro --> |
| 123 | + |
| 124 | +<!-- C usage documentation. --> |
| 125 | + |
| 126 | +<section class="usage"> |
| 127 | + |
| 128 | +### Usage |
| 129 | + |
| 130 | +```c |
| 131 | +#include "stdlib/complex/float64/conj.h" |
| 132 | +``` |
| 133 | + |
| 134 | +#### stdlib_complex128_conj( z ) |
| 135 | + |
| 136 | +Returns the [complex conjugate][complex-conjugate] of a double-precision complex floating-point number. |
| 137 | + |
| 138 | +```c |
| 139 | +#include "stdlib/complex/float64/ctor.h" |
| 140 | +#include "stdlib/complex/real.h" |
| 141 | +#include "stdlib/complex/imag.h" |
| 142 | + |
| 143 | +stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 ); |
| 144 | + |
| 145 | +// ... |
| 146 | + |
| 147 | +stdlib_complex128_t v = stdlib_complex128_conj( z ); |
| 148 | + |
| 149 | +double re = stdlib_real( v ); |
| 150 | +// returns 5.0 |
| 151 | + |
| 152 | +double im = stdlib_imag( v ); |
| 153 | +// returns -2.0 |
| 154 | +``` |
| 155 | + |
| 156 | +The function accepts the following arguments: |
| 157 | + |
| 158 | +- **z**: `[in] stdlib_complex128_t` double-precision complex floating-point number. |
| 159 | + |
| 160 | +```c |
| 161 | +stdlib_complex128_t stdlib_complex128_conj( const stdlib_complex128_t z ); |
| 162 | +``` |
| 163 | +
|
| 164 | +</section> |
| 165 | +
|
| 166 | +<!-- /.usage --> |
| 167 | +
|
| 168 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 169 | +
|
| 170 | +<section class="notes"> |
| 171 | +
|
| 172 | +</section> |
| 173 | +
|
| 174 | +<!-- /.notes --> |
| 175 | +
|
| 176 | +<!-- C API usage examples. --> |
| 177 | +
|
| 178 | +<section class="examples"> |
| 179 | +
|
| 180 | +### Examples |
| 181 | +
|
| 182 | +```c |
| 183 | +#include "stdlib/complex/float64/conj.h" |
| 184 | +#include "stdlib/complex/real.h" |
| 185 | +#include "stdlib/complex/imag.h" |
| 186 | +#include "stdlib/complex/float64/ctor.h" |
| 187 | +#include <stdio.h> |
| 188 | +
|
| 189 | +int main( void ) { |
| 190 | + const stdlib_complex128_t x[] = { |
| 191 | + stdlib_complex128( 5.0, 2.0 ), |
| 192 | + stdlib_complex128( -2.0, 1.0 ), |
| 193 | + stdlib_complex128( 0.0, -0.0 ), |
| 194 | + stdlib_complex128( 0.0/0.0, 0.0/0.0 ) |
| 195 | + }; |
| 196 | +
|
| 197 | + stdlib_complex128_t z; |
| 198 | + stdlib_complex128_t v; |
| 199 | + int i; |
| 200 | + for ( i = 0; i < 4; i++ ) { |
| 201 | + z = x[ i ]; |
| 202 | + v = stdlib_complex128_conj( z ); |
| 203 | + printf( "conj(%lf + %lfi) = %lf + %lfi\n", stdlib_real( z ), stdlib_imag( z ), stdlib_real( v ), stdlib_imag( v ) ); |
| 204 | + } |
| 205 | +} |
| 206 | +``` |
| 207 | + |
| 208 | +</section> |
| 209 | + |
| 210 | +<!-- /.examples --> |
| 211 | + |
| 212 | +</section> |
| 213 | + |
| 214 | +<!-- /.c --> |
| 215 | + |
| 216 | +<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 217 | + |
| 218 | +<section class="references"> |
| 219 | + |
| 220 | +</section> |
| 221 | + |
| 222 | +<!-- /.references --> |
| 223 | + |
| 224 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 225 | + |
| 226 | +<section class="related"> |
| 227 | + |
| 228 | +* * * |
| 229 | + |
| 230 | +## See Also |
| 231 | + |
| 232 | +- <span class="package-name">[`@stdlib/complex/imag`][@stdlib/complex/imag]</span><span class="delimiter">: </span><span class="description">return the imaginary component of a double-precision complex floating-point number.</span> |
| 233 | +- <span class="package-name">[`@stdlib/complex/real`][@stdlib/complex/real]</span><span class="delimiter">: </span><span class="description">return the real component of a double-precision complex floating-point number.</span> |
| 234 | +- <span class="package-name">[`@stdlib/complex/reim`][@stdlib/complex/reim]</span><span class="delimiter">: </span><span class="description">return the real and imaginary components of a double-precision complex floating-point number.</span> |
| 235 | + |
| 236 | +</section> |
| 237 | + |
| 238 | +<!-- /.related --> |
| 239 | + |
| 240 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 241 | + |
| 242 | +<section class="links"> |
| 243 | + |
| 244 | +[complex-conjugate]: https://en.wikipedia.org/wiki/Complex_conjugate |
| 245 | + |
| 246 | +<!-- <related-links> --> |
| 247 | + |
| 248 | +[@stdlib/complex/imag]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/imag |
| 249 | + |
| 250 | +[@stdlib/complex/real]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/real |
| 251 | + |
| 252 | +[@stdlib/complex/reim]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/reim |
| 253 | + |
| 254 | +<!-- </related-links> --> |
| 255 | + |
| 256 | +</section> |
| 257 | + |
| 258 | +<!-- /.links --> |
0 commit comments