|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 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 | +# csignumf |
| 22 | + |
| 23 | +> Evaluate the [signum][signum] function 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 csignumf = require( '@stdlib/math/base/special/csignumf' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### csignumf( z ) |
| 44 | + |
| 45 | +Evaluates the [signum][signum] function of a single-precision complex floating-point number. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var Complex64 = require( '@stdlib/complex/float32/ctor' ); |
| 49 | +var real = require( '@stdlib/complex/float32/real' ); |
| 50 | +var imag = require( '@stdlib/complex/float32/imag' ); |
| 51 | + |
| 52 | +var v = csignumf( new Complex64( -4.2, 5.5 ) ); |
| 53 | +// returns <Complex64> |
| 54 | + |
| 55 | +var re = real( v ); |
| 56 | +// returns ~-0.607 |
| 57 | + |
| 58 | +var im = imag( v ); |
| 59 | +// returns ~0.795 |
| 60 | + |
| 61 | +v = csignumf( new Complex64( 0.0, 0.0 ) ); |
| 62 | +// returns <Complex64> |
| 63 | + |
| 64 | +re = real( v ); |
| 65 | +// returns 0.0 |
| 66 | + |
| 67 | +im = imag( v ); |
| 68 | +// returns 0.0 |
| 69 | + |
| 70 | +v = csignumf( new Complex64( NaN, NaN ) ); |
| 71 | +// returns <Complex64> |
| 72 | + |
| 73 | +re = real( v ); |
| 74 | +// returns NaN |
| 75 | + |
| 76 | +im = imag( v ); |
| 77 | +// returns NaN |
| 78 | +``` |
| 79 | + |
| 80 | +</section> |
| 81 | + |
| 82 | +<!-- /.usage --> |
| 83 | + |
| 84 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 85 | + |
| 86 | +<section class="notes"> |
| 87 | + |
| 88 | +</section> |
| 89 | + |
| 90 | +<!-- /.notes --> |
| 91 | + |
| 92 | +<!-- Package usage examples. --> |
| 93 | + |
| 94 | +<section class="examples"> |
| 95 | + |
| 96 | +## Examples |
| 97 | + |
| 98 | +<!-- eslint no-undef: "error" --> |
| 99 | + |
| 100 | +```javascript |
| 101 | +var uniform = require( '@stdlib/random/base/uniform' ).factory; |
| 102 | +var Complex64 = require( '@stdlib/complex/float32/ctor' ); |
| 103 | +var csignumf = require( '@stdlib/math/base/special/csignumf' ); |
| 104 | + |
| 105 | +var rand = uniform( -50.0, 50.0 ); |
| 106 | + |
| 107 | +var z; |
| 108 | +var i; |
| 109 | +for ( i = 0; i < 100; i++ ) { |
| 110 | + z = new Complex64( rand(), rand() ); |
| 111 | + console.log( 'csignumf(%s) = %s', z, csignumf( z ) ); |
| 112 | +} |
| 113 | +``` |
| 114 | + |
| 115 | +</section> |
| 116 | + |
| 117 | +<!-- /.examples --> |
| 118 | + |
| 119 | +<!-- C interface documentation. --> |
| 120 | + |
| 121 | +* * * |
| 122 | + |
| 123 | +<section class="c"> |
| 124 | + |
| 125 | +## C APIs |
| 126 | + |
| 127 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 128 | + |
| 129 | +<section class="intro"> |
| 130 | + |
| 131 | +</section> |
| 132 | + |
| 133 | +<!-- /.intro --> |
| 134 | + |
| 135 | +<!-- C usage documentation. --> |
| 136 | + |
| 137 | +<section class="usage"> |
| 138 | + |
| 139 | +### Usage |
| 140 | + |
| 141 | +```c |
| 142 | +#include "stdlib/math/base/special/csignumf.h" |
| 143 | +``` |
| 144 | + |
| 145 | +#### stdlib_base_csignumf( z ) |
| 146 | + |
| 147 | +Evaluates the [signum][signum] function of a single-precision complex floating-point number. |
| 148 | + |
| 149 | +```c |
| 150 | +#include "stdlib/complex/float32/ctor.h" |
| 151 | +#include "stdlib/complex/float32/real.h" |
| 152 | +#include "stdlib/complex/float32/imag.h" |
| 153 | + |
| 154 | +stdlib_complex64_t z = stdlib_complex64( -4.2f, 5.5f ); |
| 155 | + |
| 156 | +stdlib_complex64_t out = stdlib_base_csignumf( z ); |
| 157 | + |
| 158 | +float re = stdlib_complex64_real( out ); |
| 159 | +// returns ~-0.607f |
| 160 | + |
| 161 | +float im = stdlib_complex64_imag( out ); |
| 162 | +// returns ~0.795f |
| 163 | +``` |
| 164 | + |
| 165 | +The function accepts the following arguments: |
| 166 | + |
| 167 | +- **z**: `[in] stdlib_complex64_t` input value. |
| 168 | + |
| 169 | +```c |
| 170 | +stdlib_complex64_t stdlib_base_csignumf( const stdlib_complex64_t z ); |
| 171 | +``` |
| 172 | +
|
| 173 | +</section> |
| 174 | +
|
| 175 | +<!-- /.usage --> |
| 176 | +
|
| 177 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 178 | +
|
| 179 | +<section class="notes"> |
| 180 | +
|
| 181 | +</section> |
| 182 | +
|
| 183 | +<!-- /.notes --> |
| 184 | +
|
| 185 | +<!-- C API usage examples. --> |
| 186 | +
|
| 187 | +<section class="examples"> |
| 188 | +
|
| 189 | +### Examples |
| 190 | +
|
| 191 | +```c |
| 192 | +#include "stdlib/math/base/special/csignumf.h" |
| 193 | +#include "stdlib/complex/float32/ctor.h" |
| 194 | +#include "stdlib/complex/float32/reim.h" |
| 195 | +#include <stdio.h> |
| 196 | +
|
| 197 | +int main( void ) { |
| 198 | + const stdlib_complex64_t x[] = { |
| 199 | + stdlib_complex64( 3.14f, 1.5f ), |
| 200 | + stdlib_complex64( -3.14f, -1.5f ), |
| 201 | + stdlib_complex64( 0.0f, 0.0f ), |
| 202 | + stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f ) |
| 203 | + }; |
| 204 | +
|
| 205 | + stdlib_complex64_t v; |
| 206 | + stdlib_complex64_t y; |
| 207 | + float re1; |
| 208 | + float im1; |
| 209 | + float re2; |
| 210 | + float im2; |
| 211 | + int i; |
| 212 | + for ( i = 0; i < 4; i++ ) { |
| 213 | + v = x[ i ]; |
| 214 | + y = stdlib_base_csignumf( v ); |
| 215 | + stdlib_complex64_reim( v, &re1, &im1 ); |
| 216 | + stdlib_complex64_reim( y, &re2, &im2 ); |
| 217 | + printf( "csignumf(%f + %fi) = %f + %fi\n", re1, im1, re2, im2 ); |
| 218 | + } |
| 219 | +} |
| 220 | +``` |
| 221 | + |
| 222 | +</section> |
| 223 | + |
| 224 | +<!-- /.examples --> |
| 225 | + |
| 226 | +</section> |
| 227 | + |
| 228 | +<!-- /.c --> |
| 229 | + |
| 230 | +<!-- 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. --> |
| 231 | + |
| 232 | +<section class="references"> |
| 233 | + |
| 234 | +</section> |
| 235 | + |
| 236 | +<!-- /.references --> |
| 237 | + |
| 238 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 239 | + |
| 240 | +<section class="related"> |
| 241 | + |
| 242 | +</section> |
| 243 | + |
| 244 | +<!-- /.related --> |
| 245 | + |
| 246 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 247 | + |
| 248 | +<section class="links"> |
| 249 | + |
| 250 | +[signum]: https://en.wikipedia.org/wiki/Sign_function |
| 251 | + |
| 252 | +<!-- <related-links> --> |
| 253 | + |
| 254 | +<!-- </related-links> --> |
| 255 | + |
| 256 | +</section> |
| 257 | + |
| 258 | +<!-- /.links --> |
0 commit comments