|
| 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 | +# cidentity |
| 22 | + |
| 23 | +> Evaluate the [identity function][identity-function] of a double-precision [complex][@stdlib/complex/float64/ctor] floating-point number. |
| 24 | +
|
| 25 | +<section class="intro"> |
| 26 | + |
| 27 | +The [identity-function][identity-function] is defined as |
| 28 | + |
| 29 | +<!-- <equation class="equation" label="eq:identity_function" align="center" raw="f(z) = z" alt="Identity function"> --> |
| 30 | + |
| 31 | +```math |
| 32 | +f(z) = z |
| 33 | +``` |
| 34 | + |
| 35 | +<!-- <div class="equation" align="center" data-raw-text="f(z) = z" data-equation="eq:identity_function"> |
| 36 | + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@3ac3ef7b03afae265d5c85a664dc22e0a373c0c2/lib/node_modules/@stdlib/complex/float64/base/identity/docs/img/equation_identity_function.svg" alt="Identity function"> |
| 37 | + <br> |
| 38 | +</div> --> |
| 39 | + |
| 40 | +<!-- </equation> --> |
| 41 | + |
| 42 | +for all `z`. |
| 43 | + |
| 44 | +</section> |
| 45 | + |
| 46 | +<!-- /.intro --> |
| 47 | + |
| 48 | +<section class="usage"> |
| 49 | + |
| 50 | +## Usage |
| 51 | + |
| 52 | +```javascript |
| 53 | +var cidentity = require( '@stdlib/complex/float64/base/identity' ); |
| 54 | +``` |
| 55 | + |
| 56 | +#### cidentity( z ) |
| 57 | + |
| 58 | +Evaluates the [identity function][identity-function] for a double-precision [complex][@stdlib/complex/float64/ctor] floating-point number. |
| 59 | + |
| 60 | +```javascript |
| 61 | +var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
| 62 | +var real = require( '@stdlib/complex/float64/real' ); |
| 63 | +var imag = require( '@stdlib/complex/float64/imag' ); |
| 64 | + |
| 65 | +var v = cidentity( new Complex128( -1.0, 2.0 ) ); |
| 66 | +// returns <Complex128> |
| 67 | + |
| 68 | +var re = real( v ); |
| 69 | +// returns -1.0 |
| 70 | + |
| 71 | +var im = imag( v ); |
| 72 | +// returns 2.0 |
| 73 | +``` |
| 74 | + |
| 75 | +</section> |
| 76 | + |
| 77 | +<!-- /.usage --> |
| 78 | + |
| 79 | +<section class="examples"> |
| 80 | + |
| 81 | +## Examples |
| 82 | + |
| 83 | +<!-- eslint-disable max-len --> |
| 84 | + |
| 85 | +<!-- eslint no-undef: "error" --> |
| 86 | + |
| 87 | +```javascript |
| 88 | +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); |
| 89 | +var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
| 90 | +var cidentity = require( '@stdlib/complex/float64/base/identity' ); |
| 91 | + |
| 92 | +var z; |
| 93 | +var i; |
| 94 | +for ( i = 0; i < 100; i++ ) { |
| 95 | + z = new Complex128( discreteUniform( -50, 50 ), discreteUniform( -50, 50 ) ); |
| 96 | + console.log( 'identity(%s) = %s', z, cidentity( 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/base/identity.h" |
| 128 | +``` |
| 129 | + |
| 130 | +#### stdlib_base_complex128_identity( z ) |
| 131 | + |
| 132 | +Evaluates the identity function for a double-precision complex floating-point number. |
| 133 | + |
| 134 | +```c |
| 135 | +#include "stdlib/complex/float64/ctor.h" |
| 136 | +#include "stdlib/complex/float64/real.h" |
| 137 | +#include "stdlib/complex/float64/imag.h" |
| 138 | + |
| 139 | +stdlib_complex128_t z = stdlib_complex128( 2.5, -1.5 ); |
| 140 | +stdlib_complex128_t out = stdlib_base_complex128_identity( z ); |
| 141 | + |
| 142 | +double re = stdlib_complex128_real( out ); |
| 143 | +// returns 2.5 |
| 144 | + |
| 145 | +double im = stdlib_complex128_imag( out ); |
| 146 | +// returns -1.5 |
| 147 | +``` |
| 148 | + |
| 149 | +The function accepts the following arguments: |
| 150 | + |
| 151 | +- **z**: `[in] stdlib_complex128_t` input value. |
| 152 | + |
| 153 | +```c |
| 154 | +stdlib_complex128_t stdlib_base_complex128_identity( const stdlib_complex128_t z ); |
| 155 | +``` |
| 156 | +
|
| 157 | +</section> |
| 158 | +
|
| 159 | +<!-- /.usage --> |
| 160 | +
|
| 161 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 162 | +
|
| 163 | +<section class="notes"> |
| 164 | +
|
| 165 | +</section> |
| 166 | +
|
| 167 | +<!-- /.notes --> |
| 168 | +
|
| 169 | +<!-- C API usage examples. --> |
| 170 | +
|
| 171 | +<section class="examples"> |
| 172 | +
|
| 173 | +### Examples |
| 174 | +
|
| 175 | +```c |
| 176 | +#include "stdlib/complex/float64/base/identity.h" |
| 177 | +#include "stdlib/complex/float64/ctor.h" |
| 178 | +#include "stdlib/complex/float64/reim.h" |
| 179 | +#include <stdio.h> |
| 180 | +
|
| 181 | +int main() { |
| 182 | + const stdlib_complex128_t x[] = { |
| 183 | + stdlib_complex128( 3.14, 1.5 ), |
| 184 | + stdlib_complex128( -3.14, -1.5 ), |
| 185 | + stdlib_complex128( 0.0, 0.0 ), |
| 186 | + stdlib_complex128( 0.0/0.0, 0.0/0.0 ) |
| 187 | + }; |
| 188 | +
|
| 189 | + stdlib_complex128_t v; |
| 190 | + stdlib_complex128_t y; |
| 191 | + double re1; |
| 192 | + double im1; |
| 193 | + double re2; |
| 194 | + double im2; |
| 195 | + int i; |
| 196 | + for ( i = 0; i < 4; i++ ) { |
| 197 | + v = x[ i ]; |
| 198 | + y = stdlib_base_complex128_identity( v ); |
| 199 | + stdlib_complex128_reim( v, &re1, &im1 ); |
| 200 | + stdlib_complex128_reim( y, &re2, &im2 ); |
| 201 | + printf( "cidentity(%lf + %lfi) = %lf + %lfi\n", re1, im1, re2, im2 ); |
| 202 | + } |
| 203 | +} |
| 204 | +``` |
| 205 | + |
| 206 | +</section> |
| 207 | + |
| 208 | +<!-- /.examples --> |
| 209 | + |
| 210 | +</section> |
| 211 | + |
| 212 | +<!-- /.c --> |
| 213 | + |
| 214 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 215 | + |
| 216 | +<section class="related"> |
| 217 | + |
| 218 | +* * * |
| 219 | + |
| 220 | +## See Also |
| 221 | + |
| 222 | +- <span class="package-name">[`@stdlib/math/base/special/cidentityf`][@stdlib/math/base/special/cidentityf]</span><span class="delimiter">: </span><span class="description">evaluate the identity function for a single-precision complex floating-point number.</span> |
| 223 | +- <span class="package-name">[`@stdlib/number/float64/base/identity`][@stdlib/number/float64/base/identity]</span><span class="delimiter">: </span><span class="description">evaluate the identity function for a double-precision floating-point number.</span> |
| 224 | + |
| 225 | +</section> |
| 226 | + |
| 227 | +<!-- /.related --> |
| 228 | + |
| 229 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 230 | + |
| 231 | +<section class="links"> |
| 232 | + |
| 233 | +[identity-function]: https://en.wikipedia.org/wiki/Identity_function |
| 234 | + |
| 235 | +[@stdlib/complex/float64/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/ctor |
| 236 | + |
| 237 | +<!-- <related-links> --> |
| 238 | + |
| 239 | +[@stdlib/math/base/special/cidentityf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/cidentityf |
| 240 | + |
| 241 | +[@stdlib/number/float64/base/identity]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/number/float64/base/identity |
| 242 | + |
| 243 | +<!-- </related-links> --> |
| 244 | + |
| 245 | +</section> |
| 246 | + |
| 247 | +<!-- /.links --> |
0 commit comments