|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2021 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 single-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/float32/conj' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### conj( z ) |
| 44 | + |
| 45 | +Returns the [complex conjugate][complex-conjugate] of a single-precision complex floating-point number. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var Complex64 = require( '@stdlib/complex/float32/ctor' ); |
| 49 | + |
| 50 | +var z = new Complex64( 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 Complex64 = require( '@stdlib/complex/float32/ctor' ); |
| 83 | +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); |
| 84 | +var filledarrayBy = require( '@stdlib/array/filled-by' ); |
| 85 | +var conj = require( '@stdlib/complex/float32/conj' ); |
| 86 | + |
| 87 | +function random() { |
| 88 | + return new Complex64( discreteUniform( -10, 10 ), discreteUniform( -10, 10 ) ); |
| 89 | +} |
| 90 | + |
| 91 | +// Generate an array of random complex numbers: |
| 92 | +var x = filledarrayBy( 100, 'complex64', random ); |
| 93 | +// returns <Complex64Array> |
| 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/float32/conj.h" |
| 132 | +``` |
| 133 | + |
| 134 | +#### stdlib_complex64_conj( z ) |
| 135 | + |
| 136 | +Returns the [complex conjugate][complex-conjugate] of a single-precision complex floating-point number. |
| 137 | + |
| 138 | +```c |
| 139 | +#include "stdlib/complex/float32/ctor.h" |
| 140 | +#include "stdlib/complex/realf.h" |
| 141 | +#include "stdlib/complex/imagf.h" |
| 142 | + |
| 143 | +stdlib_complex64_t z = stdlib_complex64( 5.0f, 2.0f ); |
| 144 | + |
| 145 | +// ... |
| 146 | + |
| 147 | +stdlib_complex64_t v = stdlib_complex64_conj( z ); |
| 148 | + |
| 149 | +float re = stdlib_realf( v ); |
| 150 | +// returns 5.0f |
| 151 | + |
| 152 | +float im = stdlib_imagf( v ); |
| 153 | +// returns -2.0f |
| 154 | +``` |
| 155 | + |
| 156 | +The function accepts the following arguments: |
| 157 | + |
| 158 | +- **z**: `[in] stdlib_complex64_t` single-precision complex floating-point number. |
| 159 | + |
| 160 | +```c |
| 161 | +stdlib_complex64_t stdlib_complex64_conj( const stdlib_complex64_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/float32/conj.h" |
| 184 | +#include "stdlib/complex/realf.h" |
| 185 | +#include "stdlib/complex/imagf.h" |
| 186 | +#include "stdlib/complex/float32/ctor.h" |
| 187 | +#include <stdio.h> |
| 188 | +
|
| 189 | +int main( void ) { |
| 190 | + const stdlib_complex64_t x[] = { |
| 191 | + stdlib_complex64( 5.0f, 2.0f ), |
| 192 | + stdlib_complex64( -2.0f, 1.0f ), |
| 193 | + stdlib_complex64( 0.0f, -0.0f ), |
| 194 | + stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f ) |
| 195 | + }; |
| 196 | +
|
| 197 | + stdlib_complex64_t z; |
| 198 | + stdlib_complex64_t v; |
| 199 | + int i; |
| 200 | + for ( i = 0; i < 4; i++ ) { |
| 201 | + z = x[ i ]; |
| 202 | + v = stdlib_complex64_conj( z ); |
| 203 | + printf( "conj(%f + %fi) = %f + %fi\n", stdlib_realf( z ), stdlib_imagf( z ), stdlib_realf( v ), stdlib_imagf( 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/conj`][@stdlib/complex/conj]</span><span class="delimiter">: </span><span class="description">return the complex conjugate of a double-precision complex floating-point number.</span> |
| 233 | +- <span class="package-name">[`@stdlib/complex/imagf`][@stdlib/complex/imagf]</span><span class="delimiter">: </span><span class="description">return the imaginary component of a single-precision complex floating-point number.</span> |
| 234 | +- <span class="package-name">[`@stdlib/complex/realf`][@stdlib/complex/realf]</span><span class="delimiter">: </span><span class="description">return the real component of a single-precision complex floating-point number.</span> |
| 235 | +- <span class="package-name">[`@stdlib/complex/reimf`][@stdlib/complex/reimf]</span><span class="delimiter">: </span><span class="description">return the real and imaginary components of a single-precision complex floating-point number.</span> |
| 236 | + |
| 237 | +</section> |
| 238 | + |
| 239 | +<!-- /.related --> |
| 240 | + |
| 241 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 242 | + |
| 243 | +<section class="links"> |
| 244 | + |
| 245 | +[complex-conjugate]: https://en.wikipedia.org/wiki/Complex_conjugate |
| 246 | + |
| 247 | +<!-- <related-links> --> |
| 248 | + |
| 249 | +[@stdlib/complex/conj]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/conj |
| 250 | + |
| 251 | +[@stdlib/complex/imagf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/imagf |
| 252 | + |
| 253 | +[@stdlib/complex/realf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/realf |
| 254 | + |
| 255 | +[@stdlib/complex/reimf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/reimf |
| 256 | + |
| 257 | +<!-- </related-links> --> |
| 258 | + |
| 259 | +</section> |
| 260 | + |
| 261 | +<!-- /.links --> |
0 commit comments