|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2023 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 | +# add3 |
| 22 | + |
| 23 | +> Compute the sum of three double-precision floating-point numbers. |
| 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 add3 = require( '@stdlib/number/float64/base/add3' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### add3( x, y, z ) |
| 44 | + |
| 45 | +Computes the sum of three double-precision floating-point numbers. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var v = add3( -1.0, 5.0, 2.0 ); |
| 49 | +// returns 6.0 |
| 50 | + |
| 51 | +v = add3( 2.0, 5.0, 2.0 ); |
| 52 | +// returns 9.0 |
| 53 | + |
| 54 | +v = add3( 0.0, 5.0, 2.0 ); |
| 55 | +// returns 7.0 |
| 56 | + |
| 57 | +v = add3( -0.0, 0.0, 0.0 ); |
| 58 | +// returns 0.0 |
| 59 | + |
| 60 | +v = add3( NaN, NaN, NaN ); |
| 61 | +// returns NaN |
| 62 | +``` |
| 63 | + |
| 64 | +</section> |
| 65 | + |
| 66 | +<!-- /.usage --> |
| 67 | + |
| 68 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 69 | + |
| 70 | +<section class="notes"> |
| 71 | + |
| 72 | +</section> |
| 73 | + |
| 74 | +<!-- /.notes --> |
| 75 | + |
| 76 | +<!-- Package usage examples. --> |
| 77 | + |
| 78 | +<section class="examples"> |
| 79 | + |
| 80 | +## Examples |
| 81 | + |
| 82 | +<!-- eslint no-undef: "error" --> |
| 83 | + |
| 84 | +```javascript |
| 85 | +var rand = require( '@stdlib/random/base/discrete-uniform' ).factory; |
| 86 | +var filledBy = require( '@stdlib/array/base/filled-by' ); |
| 87 | +var add3 = require( '@stdlib/number/float64/base/add3' ); |
| 88 | + |
| 89 | +var x = filledBy( 100, rand( -50, 50 ) ); |
| 90 | +var y = filledBy( x.length, rand( -50, 50 ) ); |
| 91 | +var z = filledBy( x.length, rand( -50, 50 ) ); |
| 92 | + |
| 93 | +var i; |
| 94 | +for ( i = 0; i < x.length; i++ ) { |
| 95 | + console.log( '%d + %d + %d = %d', x[i], y[i], z[i], add3( x[i], y[i], z[i] ) ); |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +</section> |
| 100 | + |
| 101 | +<!-- /.examples --> |
| 102 | + |
| 103 | +<!-- C interface documentation. --> |
| 104 | + |
| 105 | +* * * |
| 106 | + |
| 107 | +<section class="c"> |
| 108 | + |
| 109 | +## C APIs |
| 110 | + |
| 111 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 112 | + |
| 113 | +<section class="intro"> |
| 114 | + |
| 115 | +</section> |
| 116 | + |
| 117 | +<!-- /.intro --> |
| 118 | + |
| 119 | +<!-- C usage documentation. --> |
| 120 | + |
| 121 | +<section class="usage"> |
| 122 | + |
| 123 | +### Usage |
| 124 | + |
| 125 | +```c |
| 126 | +#include "stdlib/number/float64/base/add3.h" |
| 127 | +``` |
| 128 | + |
| 129 | +#### stdlib_base_float64_add3( x, y, z ) |
| 130 | + |
| 131 | +Computes the sum of three double-precision floating-point numbers. |
| 132 | + |
| 133 | +```c |
| 134 | +double out = stdlib_base_float64_add3( -5.0, 2.0, 4.0 ); |
| 135 | +// returns 1.0 |
| 136 | +``` |
| 137 | + |
| 138 | +The function accepts the following arguments: |
| 139 | + |
| 140 | +- **x**: `[in] double` first input value. |
| 141 | +- **y**: `[in] double` second input value. |
| 142 | +- **z**: `[in] double` third input value. |
| 143 | + |
| 144 | +```c |
| 145 | +double stdlib_base_float64_add3( const double x, const double y, const double z ); |
| 146 | +``` |
| 147 | +
|
| 148 | +</section> |
| 149 | +
|
| 150 | +<!-- /.usage --> |
| 151 | +
|
| 152 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 153 | +
|
| 154 | +<section class="notes"> |
| 155 | +
|
| 156 | +</section> |
| 157 | +
|
| 158 | +<!-- /.notes --> |
| 159 | +
|
| 160 | +<!-- C API usage examples. --> |
| 161 | +
|
| 162 | +<section class="examples"> |
| 163 | +
|
| 164 | +### Examples |
| 165 | +
|
| 166 | +```c |
| 167 | +#include "stdlib/number/float64/base/add3.h" |
| 168 | +#include <stdio.h> |
| 169 | +
|
| 170 | +int main( void ) { |
| 171 | + const double x[] = { 3.14, -3.14, 0.0, 0.0/0.0 }; |
| 172 | + const double y[] = { 3.14, -3.14, -0.0, 0.0/0.0 }; |
| 173 | + const double z[] = { 2.0, -3.0, -0.0, 0.0/0.0 }; |
| 174 | +
|
| 175 | + double out; |
| 176 | + int i; |
| 177 | + for ( i = 0; i < 4; i++ ) { |
| 178 | + out = stdlib_base_float64_add3( x[ i ], y[ i ], z[ i ] ); |
| 179 | + printf( "%lf + %lf + %lf = %lf\n", x[ i ], y[ i ], z[ i ], out ); |
| 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/number/float64/base/add`][@stdlib/number/float64/base/add]</span><span class="delimiter">: </span><span class="description">compute the sum of two double-precision floating-point numbers.</span> |
| 201 | + |
| 202 | +</section> |
| 203 | + |
| 204 | +<!-- /.related --> |
| 205 | + |
| 206 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 207 | + |
| 208 | +<section class="links"> |
| 209 | + |
| 210 | +<!-- <related-links> --> |
| 211 | + |
| 212 | +[@stdlib/number/float64/base/add]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/number/float64/base/add |
| 213 | + |
| 214 | +<!-- </related-links> --> |
| 215 | + |
| 216 | +</section> |
| 217 | + |
| 218 | +<!-- /.links --> |
0 commit comments