|
| 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 | +# Identity Function |
| 22 | + |
| 23 | +> Evaluate the [identity function][identity-function] of a single-precision [complex][@stdlib/complex/float32/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@79c18caa8e6697ecbe8bcf813a8d54a470168a75/lib/node_modules/@stdlib/complex/float32/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 cidentityf = require( '@stdlib/complex/float32/base/identity' ); |
| 54 | +``` |
| 55 | + |
| 56 | +#### cidentityf( z ) |
| 57 | + |
| 58 | +Evaluates the [identity function][identity-function] for a single-precision [complex][@stdlib/complex/float32/ctor] floating-point number. |
| 59 | + |
| 60 | +```javascript |
| 61 | +var Complex64 = require( '@stdlib/complex/float32/ctor' ); |
| 62 | +var real = require( '@stdlib/complex/float32/real' ); |
| 63 | +var imag = require( '@stdlib/complex/float32/imag' ); |
| 64 | + |
| 65 | +var v = cidentityf( new Complex64( -1.0, 2.0 ) ); |
| 66 | +// returns <Complex64> |
| 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 no-undef: "error" --> |
| 84 | + |
| 85 | +```javascript |
| 86 | +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); |
| 87 | +var Complex64 = require( '@stdlib/complex/float32/ctor' ); |
| 88 | +var cidentityf = require( '@stdlib/complex/float32/base/identity' ); |
| 89 | + |
| 90 | +var z; |
| 91 | +var i; |
| 92 | +for ( i = 0; i < 100; i++ ) { |
| 93 | + z = new Complex64( discreteUniform( -50, 50 ), discreteUniform( -50, 50 ) ); |
| 94 | + console.log( 'identity(%s) = %s', z, cidentityf( z ) ); |
| 95 | +} |
| 96 | +``` |
| 97 | + |
| 98 | +</section> |
| 99 | + |
| 100 | +<!-- /.examples --> |
| 101 | + |
| 102 | +<!-- C interface documentation. --> |
| 103 | + |
| 104 | +* * * |
| 105 | + |
| 106 | +<section class="c"> |
| 107 | + |
| 108 | +## C APIs |
| 109 | + |
| 110 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 111 | + |
| 112 | +<section class="intro"> |
| 113 | + |
| 114 | +</section> |
| 115 | + |
| 116 | +<!-- /.intro --> |
| 117 | + |
| 118 | +<!-- C usage documentation. --> |
| 119 | + |
| 120 | +<section class="usage"> |
| 121 | + |
| 122 | +### Usage |
| 123 | + |
| 124 | +```c |
| 125 | +#include "stdlib/complex/float32/base/identity.h" |
| 126 | +``` |
| 127 | + |
| 128 | +#### stdlib_base_complex64_identity( z ) |
| 129 | + |
| 130 | +Evaluates the identity function for a single-precision complex floating-point number. |
| 131 | + |
| 132 | +```c |
| 133 | +#include <complex.h> |
| 134 | + |
| 135 | +float complex y = stdlib_base_complex64_identity( 2.0f+2.0f*I ); |
| 136 | +// returns 2.0f+2.0f*I |
| 137 | +``` |
| 138 | + |
| 139 | +The function accepts the following arguments: |
| 140 | + |
| 141 | +- **z**: `[in] float complex` input value. |
| 142 | + |
| 143 | +```c |
| 144 | +float complex stdlib_base_complex64_identity( const float complex z ); |
| 145 | +``` |
| 146 | +
|
| 147 | +</section> |
| 148 | +
|
| 149 | +<!-- /.usage --> |
| 150 | +
|
| 151 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 152 | +
|
| 153 | +<section class="notes"> |
| 154 | +
|
| 155 | +</section> |
| 156 | +
|
| 157 | +<!-- /.notes --> |
| 158 | +
|
| 159 | +<!-- C API usage examples. --> |
| 160 | +
|
| 161 | +<section class="examples"> |
| 162 | +
|
| 163 | +### Examples |
| 164 | +
|
| 165 | +```c |
| 166 | +#include "stdlib/complex/float32/base/identity.h" |
| 167 | +#include <stdio.h> |
| 168 | +#include <complex.h> |
| 169 | +
|
| 170 | +int main( void ) { |
| 171 | + const float complex x[] = { 3.14f+1.0f*I, -3.14f-1.0f*I, 0.0f+0.0f*I, 0.0f/0.0f+0.0f/0.0f*I }; |
| 172 | +
|
| 173 | + float complex v; |
| 174 | + float complex y; |
| 175 | + int i; |
| 176 | + for ( i = 0; i < 4; i++ ) { |
| 177 | + v = x[ i ]; |
| 178 | + y = stdlib_base_complex64_identity( v ); |
| 179 | + printf( "f(%f + %f) = %f + %f\n", crealf( v ), cimagf( v ), crealf( y ), cimagf( y ) ); |
| 180 | + } |
| 181 | +} |
| 182 | +``` |
| 183 | + |
| 184 | +</section> |
| 185 | + |
| 186 | +<!-- /.examples --> |
| 187 | + |
| 188 | +</section> |
| 189 | + |
| 190 | +<!-- /.c --> |
| 191 | + |
| 192 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 193 | + |
| 194 | +<section class="related"> |
| 195 | + |
| 196 | +* * * |
| 197 | + |
| 198 | +## See Also |
| 199 | + |
| 200 | +- <span class="package-name">[`@stdlib/complex/float64/base/identity`][@stdlib/complex/float64/base/identity]</span><span class="delimiter">: </span><span class="description">evaluate the identity function for a double-precision complex floating-point number.</span> |
| 201 | +- <span class="package-name">[`@stdlib/number/float32/base/identity`][@stdlib/number/float32/base/identity]</span><span class="delimiter">: </span><span class="description">evaluate the identity function for a single-precision floating-point number.</span> |
| 202 | + |
| 203 | +</section> |
| 204 | + |
| 205 | +<!-- /.related --> |
| 206 | + |
| 207 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 208 | + |
| 209 | +<section class="links"> |
| 210 | + |
| 211 | +[identity-function]: https://en.wikipedia.org/wiki/Identity_function |
| 212 | + |
| 213 | +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float32/ctor |
| 214 | + |
| 215 | +<!-- <related-links> --> |
| 216 | + |
| 217 | +[@stdlib/complex/float64/base/identity]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/base/identity |
| 218 | + |
| 219 | +[@stdlib/number/float32/base/identity]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/number/float32/base/identity |
| 220 | + |
| 221 | +<!-- </related-links> --> |
| 222 | + |
| 223 | +</section> |
| 224 | + |
| 225 | +<!-- /.links --> |
0 commit comments