|
| 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 | +# minabsf |
| 22 | + |
| 23 | +> Return the minimum absolute single-precision 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 minabsf = require( '@stdlib/math/base/special/minabsf' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### minabsf( x, y ) |
| 44 | + |
| 45 | +Returns the minimum absolute single-precision floating-point number. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var v = minabsf( -4.2, 3.14 ); |
| 49 | +// returns ~3.14 |
| 50 | + |
| 51 | +v = minabsf( +0.0, -0.0 ); |
| 52 | +// returns +0.0 |
| 53 | +``` |
| 54 | + |
| 55 | +If any argument is `NaN`, the function returns `NaN`. |
| 56 | + |
| 57 | +```javascript |
| 58 | +var v = minabsf( 4.2, NaN ); |
| 59 | +// returns NaN |
| 60 | + |
| 61 | +v = minabsf( NaN, 3.14 ); |
| 62 | +// returns NaN |
| 63 | +``` |
| 64 | + |
| 65 | +</section> |
| 66 | + |
| 67 | +<!-- /.usage --> |
| 68 | + |
| 69 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 70 | + |
| 71 | +<section class="notes"> |
| 72 | + |
| 73 | +</section> |
| 74 | + |
| 75 | +<!-- /.notes --> |
| 76 | + |
| 77 | +<!-- Package usage examples. --> |
| 78 | + |
| 79 | +<section class="examples"> |
| 80 | + |
| 81 | +## Examples |
| 82 | + |
| 83 | +<!-- eslint no-undef: "error" --> |
| 84 | + |
| 85 | +```javascript |
| 86 | +var randu = require( '@stdlib/random/base/randu' ); |
| 87 | +var minabsf = require( '@stdlib/math/base/special/minabsf' ); |
| 88 | + |
| 89 | +var x; |
| 90 | +var y; |
| 91 | +var v; |
| 92 | +var i; |
| 93 | + |
| 94 | +for ( i = 0; i < 100; i++ ) { |
| 95 | + x = ( randu() * 1000.0 ) - 500.0; |
| 96 | + y = ( randu() * 1000.0 ) - 500.0; |
| 97 | + v = minabsf( x, y ); |
| 98 | + console.log( 'minabsf(%d,%d) = %d', x, y, v ); |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +</section> |
| 103 | + |
| 104 | +<!-- /.examples --> |
| 105 | + |
| 106 | +<!-- C interface documentation. --> |
| 107 | + |
| 108 | +* * * |
| 109 | + |
| 110 | +<section class="c"> |
| 111 | + |
| 112 | +## C APIs |
| 113 | + |
| 114 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 115 | + |
| 116 | +<section class="intro"> |
| 117 | + |
| 118 | +</section> |
| 119 | + |
| 120 | +<!-- /.intro --> |
| 121 | + |
| 122 | +<!-- C usage documentation. --> |
| 123 | + |
| 124 | +<section class="usage"> |
| 125 | + |
| 126 | +### Usage |
| 127 | + |
| 128 | +```c |
| 129 | +#include "stdlib/math/base/special/minabsf.h" |
| 130 | +``` |
| 131 | + |
| 132 | +#### stdlib_base_minabsf( x, y ) |
| 133 | + |
| 134 | +Returns the minimum absolute single-precision floating-point number. |
| 135 | + |
| 136 | +```c |
| 137 | +float out = stdlib_base_minabsf( -4.2f, 3.14f ); |
| 138 | +// returns 3.14f |
| 139 | + |
| 140 | +out = stdlib_base_minabsf( 0.0f, -0.0f ); |
| 141 | +// returns +0.0f |
| 142 | +``` |
| 143 | + |
| 144 | +The function accepts the following arguments: |
| 145 | + |
| 146 | +- **x**: `[in] float` input value. |
| 147 | +- **y**: `[in] float` input value. |
| 148 | + |
| 149 | +```c |
| 150 | +float stdlib_base_minabsf( const float x, const float y ); |
| 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/math/base/special/minabsf.h" |
| 173 | +#include <stdlib.h> |
| 174 | +#include <stdio.h> |
| 175 | +
|
| 176 | +int main( void ) { |
| 177 | + float x; |
| 178 | + float y; |
| 179 | + float v; |
| 180 | + int i; |
| 181 | + |
| 182 | + for ( i = 0; i < 100; i++ ) { |
| 183 | + x = ( ( (float)rand() / (float)RAND_MAX ) * 1000.0f ) - 500.0f; |
| 184 | + y = ( ( (float)rand() / (float)RAND_MAX ) * 1000.0f ) - 500.0f; |
| 185 | + v = stdlib_base_minabsf( x, y ); |
| 186 | + printf( "x: %f, y: %f, minabsf(x, y): %f\n", x, y, v ); |
| 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 | +</section> |
| 212 | + |
| 213 | +<!-- /.related --> |
| 214 | + |
| 215 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 216 | + |
| 217 | +<section class="links"> |
| 218 | + |
| 219 | +<!-- <related-links> --> |
| 220 | + |
| 221 | +<!-- </related-links> --> |
| 222 | + |
| 223 | +</section> |
| 224 | + |
| 225 | +<!-- /.links --> |
0 commit comments