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