diff --git a/lib/node_modules/@stdlib/math/base/special/exp2f/include/stdlib/math/base/special/exp2f.h b/lib/node_modules/@stdlib/math/base/special/exp2f/include/stdlib/math/base/special/exp2f.h new file mode 100644 index 000000000000..e5f55832fe8d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/exp2f/include/stdlib/math/base/special/exp2f.h @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_MATH_BASE_SPECIAL_EXP2F_H +#define STDLIB_MATH_BASE_SPECIAL_EXP2F_H + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Evaluates the base `2` exponential function (single-precision). +*/ +float stdlib_base_exp2f( const float x ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_EXP2F_H diff --git a/lib/node_modules/@stdlib/math/base/special/exp2f/lib/index.js b/lib/node_modules/@stdlib/math/base/special/exp2f/lib/index.js new file mode 100644 index 000000000000..f4af7f468e2f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/exp2f/lib/index.js @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Evaluate the base `2` exponential function (single-precision). +* +* @module @stdlib/math/base/special/exp2f +* +* @example +* var exp2f = require( '@stdlib/math/base/special/exp2f' ); +* +* var v = exp2f( 3.0 ); +* // returns 8.0 +* +* v = exp2f( -9.0 ); +* // returns ~0.002 +* +* v = exp2f( 0.0 ); +* // returns 1.0 +* +* v = exp2f( NaN ); +* // returns NaN +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/base/special/exp2f/lib/main.js b/lib/node_modules/@stdlib/math/base/special/exp2f/lib/main.js new file mode 100644 index 000000000000..670c55a36340 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/exp2f/lib/main.js @@ -0,0 +1,125 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* ## Notice +* +* The original C code, long comment, copyright, license, and constants are from [Cephes]{@link http://www.netlib.org/cephes}. The implementation follows the original, but has been modified for JavaScript. +* +* ```text +* Copyright 1984, 1995, 2000 by Stephen L. Moshier +* +* Some software in this archive may be from the book _Methods and Programs for Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989) or from the Cephes Mathematical Library, a commercial product. In either event, it is copyrighted by the author. What you see here may be used freely but it comes with no support or guarantee. +* +* Stephen L. Moshier +* moshier@na-net.ornl.gov +* ``` +*/ + +'use strict'; + +// TODO: replace with TOMS (Openlibm) algo (updating license header and long comment) + +// MODULES // + +var FLOAT32_MAX_BASE2_EXPONENT = require( '@stdlib/constants/float32/max-base2-exponent' ); // eslint-disable-line id-length +var FLOAT32_MIN_BASE2_EXPONENT = require( '@stdlib/constants/float32/min-base2-exponent' ); // eslint-disable-line id-length +var roundf = require( '@stdlib/math/base/special/roundf' ); +var ldexpf = require( '@stdlib/math/base/special/ldexpf' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var polyvalP = require( './polyval_p.js' ); +var polyvalQ = require( './polyval_q.js' ); + + +// MAIN // + +/** +* Evaluates the base `2` exponential function (single-precision). +* +* ## Method +* +* - Range reduction is accomplished by separating the argument into an integer \\( k \\) and fraction \\( f \\) such that +* +* ```tex +* 2^x = 2^k 2^f +* ``` +* +* - A Pade' approximate +* +* ```tex +* 1 + 2x \frac{\mathrm{P}\left(x^2\right)}{\mathrm{Q}\left(x^2\right) - x \mathrm{P}\left(x^2\right)} +* ``` +* +* approximates \\( 2^x \\) in the basic range \\( \[-0.5, 0.5] \\). +* +* ## Notes +* +* - Relative error: +* +* | arithmetic | domain | # trials | peak | rms | +* |:----------:|:-----------:|:--------:|:-------:|:-------:| +* | IEEE | -1022,+1024 | 30000 | 1.8e-16 | 5.4e-17 | +* +* @param {number} x - input value +* @returns {number} function value +* +* @example +* var v = exp2f( 3.0 ); +* // returns 8.0 +* +* @example +* var v = exp2f( -9.0 ); +* // returns ~0.002 +* +* @example +* var v = exp2f( 0.0 ); +* // returns 1.0 +* +* @example +* var v = exp2f( NaN ); +* // returns NaN +*/ +function exp2f( x ) { + var px; + var xx; + var n; + if ( isnanf( x ) ) { + return x; + } + if ( x > FLOAT32_MAX_BASE2_EXPONENT ) { + return PINF; + } + if ( x < FLOAT32_MIN_BASE2_EXPONENT ) { + return 0.0; + } + // Separate into integer and fractional parts... + n = roundf( x ); + x -= n; + + xx = x * x; + px = x * polyvalP( xx ); + x = px / ( polyvalQ( xx ) - px ); + x = 1.0 + ldexpf( x, 1 ); + + // Scale by power of 2: + return ldexpf( x, n ); +} + + +// EXPORTS // + +module.exports = exp2f; diff --git a/lib/node_modules/@stdlib/math/base/special/exp2f/lib/native.js b/lib/node_modules/@stdlib/math/base/special/exp2f/lib/native.js new file mode 100644 index 000000000000..2408a295ae28 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/exp2f/lib/native.js @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Evaluates the base `2` exponential function (single-precision). +* +* @private +* @param {number} x - input value +* @returns {number} function value +*/ +function exp2f( x ) { + return addon( x ); +} + + +// EXPORTS // + +module.exports = exp2f; diff --git a/lib/node_modules/@stdlib/math/base/special/exp2f/lib/polyval_p.js b/lib/node_modules/@stdlib/math/base/special/exp2f/lib/polyval_p.js new file mode 100644 index 000000000000..5c7eb002067d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/exp2f/lib/polyval_p.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* This is a generated file. Do not edit directly. */ +'use strict'; + +// MAIN // + +/** +* Evaluates a polynomial. +* +* ## Notes +* +* - The implementation uses [Horner's rule][horners-method] for efficient computation. +* +* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method +* +* @private +* @param {number} x - value at which to evaluate the polynomial +* @returns {number} evaluated polynomial +*/ +function evalpoly( x ) { + if ( x === 0.0 ) { + return 1513.906801156151; + } + return 1513.906801156151 + (x * (20.202065669316532 + (x * 0.023093347705734523))); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/exp2f/lib/polyval_q.js b/lib/node_modules/@stdlib/math/base/special/exp2f/lib/polyval_q.js new file mode 100644 index 000000000000..69f4d97f7f1f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/exp2f/lib/polyval_q.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* This is a generated file. Do not edit directly. */ +'use strict'; + +// MAIN // + +/** +* Evaluates a polynomial. +* +* ## Notes +* +* - The implementation uses [Horner's rule][horners-method] for efficient computation. +* +* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method +* +* @private +* @param {number} x - value at which to evaluate the polynomial +* @returns {number} evaluated polynomial +*/ +function evalpoly( x ) { + if ( x === 0.0 ) { + return 4368.211668792106; + } + return 4368.211668792106 + (x * (233.1842117223149 + (x * 1.0))); +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/exp2f/package.json b/lib/node_modules/@stdlib/math/base/special/exp2f/package.json new file mode 100644 index 000000000000..7373fd4d37ca --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/exp2f/package.json @@ -0,0 +1,151 @@ +{ + "name": "@stdlib/math/base/special/exp2f", + "version": "0.0.0", + "description": "Base 2 exponential function (single-precision).", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "scripts": "./scripts", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "special", + "function", + "math.exp", + "exp", + "exp2", + "base 2", + "natural", + "exponential", + "euler", + "power", + "number" + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "exp2", + "alias": "exp2", + "pkg_desc": "evaluate the base 2 exponential function for a double-precision floating-point number", + "desc": "evaluates the base 2 exponential function for a double-precision floating-point number", + "short_desc": "base 2 exponential function", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -5, + 5 + ] + }, + "example_values": [ + -4.62, + 3.17, + -2.41, + 1.28, + -0.73, + 2.56, + -3.09, + 0.41, + 4.12, + -1.85, + 2.93, + -4.37, + 1.67, + -0.28, + 3.74, + -2.96, + 0.83, + -1.12, + 4.89, + -3.51 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "exp", + "exp2", + "base 2", + "natural", + "exponential", + "euler", + "power" + ], + "extra_keywords": [ + "math.exp" + ] + } + } +}