|
| 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 | +# quinary |
| 22 | + |
| 23 | +> C APIs for registering a Node-API module exporting interfaces for invoking quinary numerical functions. |
| 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 headerDir = require( '@stdlib/math/base/napi/quinary' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### headerDir |
| 44 | + |
| 45 | +Absolute file path for the directory containing header files for C APIs. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var dir = headerDir; |
| 49 | +// returns <string> |
| 50 | +``` |
| 51 | + |
| 52 | +</section> |
| 53 | + |
| 54 | +<!-- /.usage --> |
| 55 | + |
| 56 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 57 | + |
| 58 | +<section class="notes"> |
| 59 | + |
| 60 | +</section> |
| 61 | + |
| 62 | +<!-- /.notes --> |
| 63 | + |
| 64 | +<!-- Package usage examples. --> |
| 65 | + |
| 66 | +<section class="examples"> |
| 67 | + |
| 68 | +## Examples |
| 69 | + |
| 70 | +```javascript |
| 71 | +var headerDir = require( '@stdlib/math/base/napi/quinary' ); |
| 72 | + |
| 73 | +console.log( headerDir ); |
| 74 | +// => <string> |
| 75 | +``` |
| 76 | + |
| 77 | +</section> |
| 78 | + |
| 79 | +<!-- /.examples --> |
| 80 | + |
| 81 | +<!-- C interface documentation. --> |
| 82 | + |
| 83 | +* * * |
| 84 | + |
| 85 | +<section class="c"> |
| 86 | + |
| 87 | +## C APIs |
| 88 | + |
| 89 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 90 | + |
| 91 | +<section class="intro"> |
| 92 | + |
| 93 | +</section> |
| 94 | + |
| 95 | +<!-- /.intro --> |
| 96 | + |
| 97 | +<!-- C usage documentation. --> |
| 98 | + |
| 99 | +<section class="usage"> |
| 100 | + |
| 101 | +### Usage |
| 102 | + |
| 103 | +```c |
| 104 | +#include "stdlib/math/base/napi/quinary.h" |
| 105 | +``` |
| 106 | + |
| 107 | +#### stdlib_math_base_napi_ddddd_d( env, info, fcn ) |
| 108 | + |
| 109 | +Invokes a quinary function accepting and returning double-precision floating-point numbers. |
| 110 | + |
| 111 | +```c |
| 112 | +#include <node_api.h> |
| 113 | + |
| 114 | +// ... |
| 115 | + |
| 116 | +static double add( const double x, const double y, const double z, const double w, const double u ) { |
| 117 | + return x + y + z + w + u; |
| 118 | +} |
| 119 | + |
| 120 | +// ... |
| 121 | + |
| 122 | +/** |
| 123 | +* Receives JavaScript callback invocation data. |
| 124 | +* |
| 125 | +* @param env environment under which the function is invoked |
| 126 | +* @param info callback data |
| 127 | +* @return Node-API value |
| 128 | +*/ |
| 129 | +napi_value addon( napi_env env, napi_callback_info info ) { |
| 130 | + return stdlib_math_base_napi_ddddd_d( env, info, add ); |
| 131 | +} |
| 132 | + |
| 133 | +// ... |
| 134 | +``` |
| 135 | +
|
| 136 | +The function accepts the following arguments: |
| 137 | +
|
| 138 | +- **env**: `[in] napi_env` environment under which the function is invoked. |
| 139 | +- **info**: `[in] napi_callback_info` callback data. |
| 140 | +- **fcn**: `[in] double (*fcn)( double, double, double, double, double )` quinary function. |
| 141 | +
|
| 142 | +```c |
| 143 | +void stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) ); |
| 144 | +``` |
| 145 | + |
| 146 | +#### stdlib_math_base_napi_fffff_f( env, info, fcn ) |
| 147 | + |
| 148 | +Invokes a quinary function accepting and returning single-precision floating-point numbers. |
| 149 | + |
| 150 | +```c |
| 151 | +#include <node_api.h> |
| 152 | + |
| 153 | +// ... |
| 154 | + |
| 155 | +static float addf( const float x, const float y, const float z, const float w, const float u ) { |
| 156 | + return x + y + z + w + u; |
| 157 | +} |
| 158 | + |
| 159 | +// ... |
| 160 | + |
| 161 | +/** |
| 162 | +* Receives JavaScript callback invocation data. |
| 163 | +* |
| 164 | +* @param env environment under which the function is invoked |
| 165 | +* @param info callback data |
| 166 | +* @return Node-API value |
| 167 | +*/ |
| 168 | +napi_value addon( napi_env env, napi_callback_info info ) { |
| 169 | + return stdlib_math_base_napi_fffff_f( env, info, addf ); |
| 170 | +} |
| 171 | + |
| 172 | +// ... |
| 173 | +``` |
| 174 | +
|
| 175 | +The function accepts the following arguments: |
| 176 | +
|
| 177 | +- **env**: `[in] napi_env` environment under which the function is invoked. |
| 178 | +- **info**: `[in] napi_callback_info` callback data. |
| 179 | +- **fcn**: `[in] float (*fcn)( float, float, float, float, float )` quinary function. |
| 180 | +
|
| 181 | +```c |
| 182 | +void stdlib_math_base_napi_fffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float, float ) ); |
| 183 | +``` |
| 184 | + |
| 185 | +#### STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn ) |
| 186 | + |
| 187 | +Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning double-precision floating-point numbers. |
| 188 | + |
| 189 | +```c |
| 190 | +static double add( const double x, const double y, const double z, const double w, const double u ) { |
| 191 | + return x + y + z + w + u; |
| 192 | +} |
| 193 | + |
| 194 | +// ... |
| 195 | + |
| 196 | +// Register a Node-API module: |
| 197 | +STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add ); |
| 198 | +``` |
| 199 | +
|
| 200 | +The macro expects the following arguments: |
| 201 | +
|
| 202 | +- **fcn**: `double (*fcn)( double, double, double, double, double )` quinary function. |
| 203 | +
|
| 204 | +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. |
| 205 | +
|
| 206 | +#### STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( fcn ) |
| 207 | +
|
| 208 | +Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning single-precision floating-point numbers. |
| 209 | +
|
| 210 | +```c |
| 211 | +static float addf( const float x, const float y, const float z, const float w, const float u ) { |
| 212 | + return x + y + z + w + u; |
| 213 | +} |
| 214 | +
|
| 215 | +// ... |
| 216 | +
|
| 217 | +// Register a Node-API module: |
| 218 | +STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf ); |
| 219 | +``` |
| 220 | + |
| 221 | +The macro expects the following arguments: |
| 222 | + |
| 223 | +- **fcn**: `float (*fcn)( float, float, float, float, float )` quinary function. |
| 224 | + |
| 225 | +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. |
| 226 | + |
| 227 | +</section> |
| 228 | + |
| 229 | +<!-- /.usage --> |
| 230 | + |
| 231 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 232 | + |
| 233 | +<section class="notes"> |
| 234 | + |
| 235 | +### Notes |
| 236 | + |
| 237 | +- The C-API functions expect that the callback `info` argument provides access to the following JavaScript arguments: |
| 238 | + |
| 239 | + - `x`: input value. |
| 240 | + - `y`: input value. |
| 241 | + - `z`: input value. |
| 242 | + - `w`: input value. |
| 243 | + - `u`: input value. |
| 244 | + |
| 245 | +</section> |
| 246 | + |
| 247 | +<!-- /.notes --> |
| 248 | + |
| 249 | +<!-- C API usage examples. --> |
| 250 | + |
| 251 | +<section class="examples"> |
| 252 | + |
| 253 | +</section> |
| 254 | + |
| 255 | +<!-- /.examples --> |
| 256 | + |
| 257 | +</section> |
| 258 | + |
| 259 | +<!-- /.c --> |
| 260 | + |
| 261 | +<!-- 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. --> |
| 262 | + |
| 263 | +<section class="references"> |
| 264 | + |
| 265 | +</section> |
| 266 | + |
| 267 | +<!-- /.references --> |
| 268 | + |
| 269 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 270 | + |
| 271 | +<section class="related"> |
| 272 | + |
| 273 | +</section> |
| 274 | + |
| 275 | +<!-- /.related --> |
| 276 | + |
| 277 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 278 | + |
| 279 | +<section class="links"> |
| 280 | + |
| 281 | +</section> |
| 282 | + |
| 283 | +<!-- /.links --> |
0 commit comments