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