|
| 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 | +# xlogyf |
| 22 | + |
| 23 | +> Compute `x * ln(y)` so that the result is `0` if `x = 0` for single-precision floating-point numbers `x` and `y`. |
| 24 | +
|
| 25 | +<section class="usage"> |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```javascript |
| 30 | +var xlogyf = require( '@stdlib/math/base/special/xlogyf' ); |
| 31 | +``` |
| 32 | + |
| 33 | +#### xlogyf( x, y ) |
| 34 | + |
| 35 | +Computes `x * ln(y)` so that the result is `0` if `x = 0` for single-precision floating-point numbers `x` and `y`. |
| 36 | + |
| 37 | +```javascript |
| 38 | +var out = xlogyf( 3.0, 2.0 ); |
| 39 | +// returns ~2.079 |
| 40 | + |
| 41 | +out = xlogyf( 1.5, 5.9 ); |
| 42 | +// returns ~2.662 |
| 43 | + |
| 44 | +out = xlogyf( 0.9, 1.0 ); |
| 45 | +// returns 0.0 |
| 46 | + |
| 47 | +out = xlogyf( 0.0, -2.0 ); |
| 48 | +// returns 0.0 |
| 49 | + |
| 50 | +out = xlogyf( 1.5, NaN ); |
| 51 | +// returns NaN |
| 52 | + |
| 53 | +out = xlogyf( 0.0, NaN ); |
| 54 | +// returns NaN |
| 55 | + |
| 56 | +out = xlogyf( NaN, 2.3 ); |
| 57 | +// returns NaN |
| 58 | +``` |
| 59 | + |
| 60 | +</section> |
| 61 | + |
| 62 | +<!-- /.usage --> |
| 63 | + |
| 64 | +<section class="examples"> |
| 65 | + |
| 66 | +## Examples |
| 67 | + |
| 68 | +<!-- eslint no-undef: "error" --> |
| 69 | + |
| 70 | +```javascript |
| 71 | +var randu = require( '@stdlib/random/base/randu' ); |
| 72 | +var xlogyf = require( '@stdlib/math/base/special/xlogyf' ); |
| 73 | + |
| 74 | +var x; |
| 75 | +var y; |
| 76 | +var i; |
| 77 | + |
| 78 | +for ( i = 0; i < 100; i++ ) { |
| 79 | + x = randu(); |
| 80 | + if ( x < 0.5 ) { |
| 81 | + x = 0.0; |
| 82 | + } |
| 83 | + y = ( randu() * 20.0 ) - 5.0; |
| 84 | + console.log( 'xlogyf(%d, %d) = %d', x, y, xlogyf( x, y ) ); |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +</section> |
| 89 | + |
| 90 | +<!-- /.examples --> |
| 91 | + |
| 92 | +<!-- C interface documentation. --> |
| 93 | + |
| 94 | +* * * |
| 95 | + |
| 96 | +<section class="c"> |
| 97 | + |
| 98 | +## C APIs |
| 99 | + |
| 100 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 101 | + |
| 102 | +<section class="intro"> |
| 103 | + |
| 104 | +</section> |
| 105 | + |
| 106 | +<!-- /.intro --> |
| 107 | + |
| 108 | +<!-- C usage documentation. --> |
| 109 | + |
| 110 | +<section class="usage"> |
| 111 | + |
| 112 | +### Usage |
| 113 | + |
| 114 | +```c |
| 115 | +#include "stdlib/math/base/special/xlogyf.h" |
| 116 | +``` |
| 117 | + |
| 118 | +#### stdlib_base_xlogyf( x, y ) |
| 119 | + |
| 120 | +Computes `x * ln(y)` so that the result is `0` if `x = 0` for single-precision floating-point numbers `x` and `y`. |
| 121 | + |
| 122 | +```c |
| 123 | +float v = stdlib_base_xlogyf( 3.0f, 2.0f ); |
| 124 | +// returns ~2.079f |
| 125 | +``` |
| 126 | + |
| 127 | +The function accepts the following arguments: |
| 128 | + |
| 129 | +- **x**: `[in] float` input value. |
| 130 | +- **y**: `[in] float` input value. |
| 131 | + |
| 132 | +```c |
| 133 | +float stdlib_base_xlogyf( const float x, const float y ); |
| 134 | +``` |
| 135 | +
|
| 136 | +</section> |
| 137 | +
|
| 138 | +<!-- /.usage --> |
| 139 | +
|
| 140 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 141 | +
|
| 142 | +<section class="notes"> |
| 143 | +
|
| 144 | +</section> |
| 145 | +
|
| 146 | +<!-- /.notes --> |
| 147 | +
|
| 148 | +<!-- C API usage examples. --> |
| 149 | +
|
| 150 | +<section class="examples"> |
| 151 | +
|
| 152 | +### Examples |
| 153 | +
|
| 154 | +```c |
| 155 | +#include "stdlib/math/base/special/xlogyf.h" |
| 156 | +#include <stdio.h> |
| 157 | +#include <stdlib.h> |
| 158 | +
|
| 159 | +int main( void ) { |
| 160 | + float out; |
| 161 | + float x; |
| 162 | + float y; |
| 163 | + int i; |
| 164 | +
|
| 165 | + for ( i = 0; i < 100; i++ ) { |
| 166 | + x = ( (float)rand() / (float)RAND_MAX ) * 100.0f; |
| 167 | + y = ( (float)rand() / (float)RAND_MAX ) * 5.0f; |
| 168 | + out = stdlib_base_xlogyf( x, y ); |
| 169 | + printf( "xlogyf(%f, %f) = %f\n", x, y, out ); |
| 170 | + } |
| 171 | +} |
| 172 | +``` |
| 173 | + |
| 174 | +</section> |
| 175 | + |
| 176 | +<!-- /.examples --> |
| 177 | + |
| 178 | +</section> |
| 179 | + |
| 180 | +<!-- /.c --> |
| 181 | + |
| 182 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 183 | + |
| 184 | +<section class="related"> |
| 185 | + |
| 186 | +</section> |
| 187 | + |
| 188 | +<!-- /.related --> |
| 189 | + |
| 190 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 191 | + |
| 192 | +<section class="links"> |
| 193 | + |
| 194 | +<!-- <related-links> --> |
| 195 | + |
| 196 | +<!-- </related-links> --> |
| 197 | + |
| 198 | +</section> |
| 199 | + |
| 200 | +<!-- /.links --> |
0 commit comments