From 4b40066a0dbde480f7ffdad1cd7b4ba291d445ea Mon Sep 17 00:00:00 2001 From: Vishal Gaikwad Date: Fri, 27 Feb 2026 03:22:29 +0530 Subject: [PATCH] feat: add math/base/special/erfinvf --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../stdlib/math/base/special/erfinvf.h | 38 ++++ .../math/base/special/erfinvf/lib/index.js | 58 ++++++ .../math/base/special/erfinvf/lib/main.js | 166 ++++++++++++++++++ .../math/base/special/erfinvf/lib/native.js | 42 +++++ .../base/special/erfinvf/lib/rational_p1q1.js | 64 +++++++ .../base/special/erfinvf/lib/rational_p2q2.js | 64 +++++++ .../base/special/erfinvf/lib/rational_p3q3.js | 64 +++++++ .../base/special/erfinvf/lib/rational_p4q4.js | 64 +++++++ .../base/special/erfinvf/lib/rational_p5q5.js | 64 +++++++ .../math/base/special/erfinvf/package.json | 142 +++++++++++++++ 10 files changed, 766 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/erfinvf/include/stdlib/math/base/special/erfinvf.h create mode 100644 lib/node_modules/@stdlib/math/base/special/erfinvf/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/erfinvf/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/erfinvf/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p1q1.js create mode 100644 lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p2q2.js create mode 100644 lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p3q3.js create mode 100644 lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p4q4.js create mode 100644 lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p5q5.js create mode 100644 lib/node_modules/@stdlib/math/base/special/erfinvf/package.json diff --git a/lib/node_modules/@stdlib/math/base/special/erfinvf/include/stdlib/math/base/special/erfinvf.h b/lib/node_modules/@stdlib/math/base/special/erfinvf/include/stdlib/math/base/special/erfinvf.h new file mode 100644 index 000000000000..283fdb01592a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfinvf/include/stdlib/math/base/special/erfinvf.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_ERFINVF_H +#define STDLIB_MATH_BASE_SPECIAL_ERFINVF_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 inverse error function (single-precision). +*/ +float stdlib_base_erfinvf( const float x ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_ERFINVF_H diff --git a/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/index.js new file mode 100644 index 000000000000..774183c53163 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/index.js @@ -0,0 +1,58 @@ +/** +* @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 inverse error function (single-precision). +* +* @module @stdlib/math/base/special/erfinvf +* +* @example +* var erfinvf = require( '@stdlib/math/base/special/erfinvf' ); +* +* var y = erfinvf( 0.5 ); +* // returns ~0.4769 +* +* y = erfinvf( 0.8 ); +* // returns ~0.9062 +* +* y = erfinvf( 0.0 ); +* // returns 0.0 +* +* y = erfinvf( -0.0 ); +* // returns -0.0 +* +* y = erfinvf( -1.0 ); +* // returns -Infinity +* +* y = erfinvf( 1.0 ); +* // returns Infinity +* +* y = erfinvf( NaN ); +* // returns NaN +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/main.js new file mode 100644 index 000000000000..122ea5b7e2bf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/main.js @@ -0,0 +1,166 @@ +/** +* @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 and copyright notice are from the [Boost library]{@link http://www.boost.org/doc/libs/1_48_0/boost/math/special_functions/detail/erf_inv.hpp}. This implementation follows the original, but has been modified for JavaScript. +* +* ```text +* (C) Copyright John Maddock 2006. +* +* Use, modification and distribution are subject to the +* Boost Software License, Version 1.0. (See accompanying file +* LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) +* ``` +*/ + +'use strict'; + +// MODULES // + +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var sqrtf = require( '@stdlib/math/base/special/sqrtf' ); +var lnf = require( '@stdlib/math/base/special/lnf' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var rationalFcnR1 = require( './rational_p1q1.js' ); +var rationalFcnR2 = require( './rational_p2q2.js' ); +var rationalFcnR3 = require( './rational_p3q3.js' ); +var rationalFcnR4 = require( './rational_p4q4.js' ); +var rationalFcnR5 = require( './rational_p5q5.js' ); + + +// VARIABLES // + +var Y1 = 8.91314744949340820313e-2; +var Y2 = 2.249481201171875; +var Y3 = 8.07220458984375e-1; +var Y4 = 9.3995571136474609375e-1; +var Y5 = 9.8362827301025390625e-1; + + +// MAIN // + +/** +* Evaluates the inverse error function (single-precision). +* +* @param {number} x - input value +* @returns {number} function value +* +* @example +* var y = erfinvf( 0.5 ); +* // returns ~0.4769 +* +* @example +* var y = erfinvf( 0.8 ); +* // returns ~0.9062 +* +* @example +* var y = erfinvf( 0.0 ); +* // returns 0.0 +* +* @example +* var y = erfinvf( -0.0 ); +* // returns -0.0 +* +* @example +* var y = erfinvf( -1.0 ); +* // returns -Infinity +* +* @example +* var y = erfinvf( 1.0 ); +* // returns Infinity +* +* @example +* var y = erfinvf( NaN ); +* // returns NaN +*/ +function erfinvf( x ) { + var sign; + var ax; + var qs; + var q; + var g; + var r; + + // Special case: NaN + if ( isnanf( x ) ) { + return NaN; + } + // Special case: 1 + if ( x === 1.0 ) { + return PINF; + } + // Special case: -1 + if ( x === -1.0 ) { + return NINF; + } + // Special case: +-0 + if ( x === 0.0 ) { + return x; + } + // Special case: |x| > 1 (range error) + if ( x > 1.0 || x < -1.0 ) { + return NaN; + } + // Argument reduction (reduce to interval [0,1]). If `x` is negative, we can safely negate the value, taking advantage of the error function being an odd function; i.e., `erf(-x) = -erf(x)`. + if ( x < 0.0 ) { + sign = -1.0; + ax = -x; + } else { + sign = 1.0; + ax = x; + } + q = 1.0 - ax; + + // |x| <= 0.5 + if ( ax <= 0.5 ) { + g = ax * ( ax + 10.0 ); + r = rationalFcnR1( ax ); + return sign * ( (g*Y1) + (g*r) ); + } + // 1-|x| >= 0.25 + if ( q >= 0.25 ) { + g = sqrtf( -2.0 * lnf(q) ); + q -= 0.25; + r = rationalFcnR2( q ); + return sign * ( g / (Y2+r) ); + } + q = sqrtf( -lnf( q ) ); + + // q < 3 + if ( q < 3.0 ) { + qs = q - 1.125; + r = rationalFcnR3( qs ); + return sign * ( (Y3*q) + (r*q) ); + } + // q < 6 + if ( q < 6.0 ) { + qs = q - 3.0; + r = rationalFcnR4( qs ); + return sign * ( (Y4*q) + (r*q) ); + } + // q < 18 + qs = q - 6.0; + r = rationalFcnR5( qs ); + return sign * ( (Y5*q) + (r*q) ); +} + + +// EXPORTS // + +module.exports = erfinvf; diff --git a/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/native.js new file mode 100644 index 000000000000..e72be98beebf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfinvf/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 inverse error function (single-precision). +* +* @private +* @param {number} x - input value +* @returns {number} evaluated inverse error function +*/ +function erfinvf( x ) { + return addon( x ); +} + + +// EXPORTS // + +module.exports = erfinvf; diff --git a/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p1q1.js b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p1q1.js new file mode 100644 index 000000000000..b2efa93ed4c5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p1q1.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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 rational function (i.e., the ratio of two polynomials described by the coefficients stored in \\(P\\) and \\(Q\\)). +* +* ## Notes +* +* - Coefficients should be sorted in ascending degree. +* - 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 rational function +* @returns {number} evaluated rational function +*/ +function evalrational( x ) { + var ax; + var s1; + var s2; + if ( x === 0.0 ) { + return -0.0005087819496582806; + } + if ( x < 0.0 ) { + ax = -x; + } else { + ax = x; + } + if ( ax <= 1.0 ) { + s1 = -0.0005087819496582806 + (x * (-0.008368748197417368 + (x * (0.03348066254097446 + (x * (-0.012692614766297404 + (x * (-0.03656379714117627 + (x * (0.02198786811111689 + (x * (0.008226878746769157 + (x * (-0.005387729650712429 + (x * (0.0 + (x * 0.0))))))))))))))))); // eslint-disable-line max-len + s2 = 1.0 + (x * (-0.9700050433032906 + (x * (-1.5657455823417585 + (x * (1.5622155839842302 + (x * (0.662328840472003 + (x * (-0.7122890234154284 + (x * (-0.05273963823400997 + (x * (0.07952836873415717 + (x * (-0.0023339375937419 + (x * 0.0008862163904564247))))))))))))))))); // eslint-disable-line max-len + } else { + x = 1.0 / x; + s1 = 0.0 + (x * (0.0 + (x * (-0.005387729650712429 + (x * (0.008226878746769157 + (x * (0.02198786811111689 + (x * (-0.03656379714117627 + (x * (-0.012692614766297404 + (x * (0.03348066254097446 + (x * (-0.008368748197417368 + (x * -0.0005087819496582806))))))))))))))))); // eslint-disable-line max-len + s2 = 0.0008862163904564247 + (x * (-0.0023339375937419 + (x * (0.07952836873415717 + (x * (-0.05273963823400997 + (x * (-0.7122890234154284 + (x * (0.662328840472003 + (x * (1.5622155839842302 + (x * (-1.5657455823417585 + (x * (-0.9700050433032906 + (x * 1.0))))))))))))))))); // eslint-disable-line max-len + } + return s1 / s2; +} + + +// EXPORTS // + +module.exports = evalrational; diff --git a/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p2q2.js b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p2q2.js new file mode 100644 index 000000000000..4a8f2b5fc65a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p2q2.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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 rational function (i.e., the ratio of two polynomials described by the coefficients stored in \\(P\\) and \\(Q\\)). +* +* ## Notes +* +* - Coefficients should be sorted in ascending degree. +* - 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 rational function +* @returns {number} evaluated rational function +*/ +function evalrational( x ) { + var ax; + var s1; + var s2; + if ( x === 0.0 ) { + return -0.20243350835593876; + } + if ( x < 0.0 ) { + ax = -x; + } else { + ax = x; + } + if ( ax <= 1.0 ) { + s1 = -0.20243350835593876 + (x * (0.10526468069939171 + (x * (8.3705032834312 + (x * (17.644729840837403 + (x * (-18.851064805871424 + (x * (-44.6382324441787 + (x * (17.445385985570866 + (x * (21.12946554483405 + (x * -3.6719225470772936))))))))))))))); // eslint-disable-line max-len + s2 = 1.0 + (x * (6.242641248542475 + (x * (3.971343795334387 + (x * (-28.66081804998 + (x * (-20.14326346804852 + (x * (48.560921310873994 + (x * (10.826866735546016 + (x * (-22.643693341313973 + (x * 1.7211476576120028))))))))))))))); // eslint-disable-line max-len + } else { + x = 1.0 / x; + s1 = -3.6719225470772936 + (x * (21.12946554483405 + (x * (17.445385985570866 + (x * (-44.6382324441787 + (x * (-18.851064805871424 + (x * (17.644729840837403 + (x * (8.3705032834312 + (x * (0.10526468069939171 + (x * -0.20243350835593876))))))))))))))); // eslint-disable-line max-len + s2 = 1.7211476576120028 + (x * (-22.643693341313973 + (x * (10.826866735546016 + (x * (48.560921310873994 + (x * (-20.14326346804852 + (x * (-28.66081804998 + (x * (3.971343795334387 + (x * (6.242641248542475 + (x * 1.0))))))))))))))); // eslint-disable-line max-len + } + return s1 / s2; +} + + +// EXPORTS // + +module.exports = evalrational; diff --git a/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p3q3.js b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p3q3.js new file mode 100644 index 000000000000..d663453bfcee --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p3q3.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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 rational function (i.e., the ratio of two polynomials described by the coefficients stored in \\(P\\) and \\(Q\\)). +* +* ## Notes +* +* - Coefficients should be sorted in ascending degree. +* - 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 rational function +* @returns {number} evaluated rational function +*/ +function evalrational( x ) { + var ax; + var s1; + var s2; + if ( x === 0.0 ) { + return -0.1311027816799519; + } + if ( x < 0.0 ) { + ax = -x; + } else { + ax = x; + } + if ( ax <= 1.0 ) { + s1 = -0.1311027816799519 + (x * (-0.16379404719331705 + (x * (0.11703015634199525 + (x * (0.38707973897260434 + (x * (0.3377855389120359 + (x * (0.14286953440815717 + (x * (0.029015791000532906 + (x * (0.0021455899538880526 + (x * (-6.794655751811263e-7 + (x * (2.8522533178221704e-8 + (x * -6.81149956853777e-10))))))))))))))))))); // eslint-disable-line max-len + s2 = 1.0 + (x * (3.4662540724256723 + (x * (5.381683457070069 + (x * (4.778465929458438 + (x * (2.5930192162362027 + (x * (0.848854343457902 + (x * (0.15226433829533179 + (x * (0.011059242293464892 + (x * (0.0 + (x * (0.0 + (x * 0.0))))))))))))))))))); // eslint-disable-line max-len + } else { + x = 1.0 / x; + s1 = -6.81149956853777e-10 + (x * (2.8522533178221704e-8 + (x * (-6.794655751811263e-7 + (x * (0.0021455899538880526 + (x * (0.029015791000532906 + (x * (0.14286953440815717 + (x * (0.3377855389120359 + (x * (0.38707973897260434 + (x * (0.11703015634199525 + (x * (-0.16379404719331705 + (x * -0.1311027816799519))))))))))))))))))); // eslint-disable-line max-len + s2 = 0.0 + (x * (0.0 + (x * (0.0 + (x * (0.011059242293464892 + (x * (0.15226433829533179 + (x * (0.848854343457902 + (x * (2.5930192162362027 + (x * (4.778465929458438 + (x * (5.381683457070069 + (x * (3.4662540724256723 + (x * 1.0))))))))))))))))))); // eslint-disable-line max-len + } + return s1 / s2; +} + + +// EXPORTS // + +module.exports = evalrational; diff --git a/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p4q4.js b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p4q4.js new file mode 100644 index 000000000000..3cc8919fc59f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p4q4.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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 rational function (i.e., the ratio of two polynomials described by the coefficients stored in \\(P\\) and \\(Q\\)). +* +* ## Notes +* +* - Coefficients should be sorted in ascending degree. +* - 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 rational function +* @returns {number} evaluated rational function +*/ +function evalrational( x ) { + var ax; + var s1; + var s2; + if ( x === 0.0 ) { + return -0.0350353787183178; + } + if ( x < 0.0 ) { + ax = -x; + } else { + ax = x; + } + if ( ax <= 1.0 ) { + s1 = -0.0350353787183178 + (x * (-0.0022242652921344794 + (x * (0.018557330651423107 + (x * (0.009508047013259196 + (x * (0.0018712349281955923 + (x * (0.00015754461742496055 + (x * (0.00000460469890584318 + (x * (-2.304047769118826e-10 + (x * 2.6633922742578204e-12))))))))))))))); // eslint-disable-line max-len + s2 = 1.0 + (x * (1.3653349817554064 + (x * (0.7620591645536234 + (x * (0.22009110576413124 + (x * (0.03415891436709477 + (x * (0.00263861676657016 + (x * (0.00007646752923027944 + (x * (0.0 + (x * 0.0))))))))))))))); // eslint-disable-line max-len + } else { + x = 1.0 / x; + s1 = 2.6633922742578204e-12 + (x * (-2.304047769118826e-10 + (x * (0.00000460469890584318 + (x * (0.00015754461742496055 + (x * (0.0018712349281955923 + (x * (0.009508047013259196 + (x * (0.018557330651423107 + (x * (-0.0022242652921344794 + (x * -0.0350353787183178))))))))))))))); // eslint-disable-line max-len + s2 = 0.0 + (x * (0.0 + (x * (0.00007646752923027944 + (x * (0.00263861676657016 + (x * (0.03415891436709477 + (x * (0.22009110576413124 + (x * (0.7620591645536234 + (x * (1.3653349817554064 + (x * 1.0))))))))))))))); // eslint-disable-line max-len + } + return s1 / s2; +} + + +// EXPORTS // + +module.exports = evalrational; diff --git a/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p5q5.js b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p5q5.js new file mode 100644 index 000000000000..00e5c1dd3d2b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfinvf/lib/rational_p5q5.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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 rational function (i.e., the ratio of two polynomials described by the coefficients stored in \\(P\\) and \\(Q\\)). +* +* ## Notes +* +* - Coefficients should be sorted in ascending degree. +* - 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 rational function +* @returns {number} evaluated rational function +*/ +function evalrational( x ) { + var ax; + var s1; + var s2; + if ( x === 0.0 ) { + return -0.016743100507663373; + } + if ( x < 0.0 ) { + ax = -x; + } else { + ax = x; + } + if ( ax <= 1.0 ) { + s1 = -0.016743100507663373 + (x * (-0.0011295143874558028 + (x * (0.001056288621524929 + (x * (0.00020938631748758808 + (x * (0.000014962478375834237 + (x * (4.4969678992770644e-7 + (x * (4.625961635228786e-9 + (x * (-2.811287356288318e-14 + (x * 9.905570997331033e-17))))))))))))))); // eslint-disable-line max-len + s2 = 1.0 + (x * (0.5914293448864175 + (x * (0.1381518657490833 + (x * (0.016074608709367652 + (x * (0.0009640118070051656 + (x * (0.000027533547476472603 + (x * (2.82243172016108e-7 + (x * (0.0 + (x * 0.0))))))))))))))); // eslint-disable-line max-len + } else { + x = 1.0 / x; + s1 = 9.905570997331033e-17 + (x * (-2.811287356288318e-14 + (x * (4.625961635228786e-9 + (x * (4.4969678992770644e-7 + (x * (0.000014962478375834237 + (x * (0.00020938631748758808 + (x * (0.001056288621524929 + (x * (-0.0011295143874558028 + (x * -0.016743100507663373))))))))))))))); // eslint-disable-line max-len + s2 = 0.0 + (x * (0.0 + (x * (2.82243172016108e-7 + (x * (0.000027533547476472603 + (x * (0.0009640118070051656 + (x * (0.016074608709367652 + (x * (0.1381518657490833 + (x * (0.5914293448864175 + (x * 1.0))))))))))))))); // eslint-disable-line max-len + } + return s1 / s2; +} + + +// EXPORTS // + +module.exports = evalrational; diff --git a/lib/node_modules/@stdlib/math/base/special/erfinvf/package.json b/lib/node_modules/@stdlib/math/base/special/erfinvf/package.json new file mode 100644 index 000000000000..c650844e4ec9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfinvf/package.json @@ -0,0 +1,142 @@ +{ + "name": "@stdlib/math/base/special/erfinvf", + "version": "0.0.0", + "description": "Inverse error function (single-precision).", + "license": "Apache-2.0 AND BSL-1.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", + "erf", + "erfinv", + "inverse", + "error", + "function", + "special", + "number" + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "erfinv", + "alias": "erfinv", + "pkg_desc": "evaluate the inverse error function for a double-precision floating-point number", + "desc": "evaluates the inverse error function for a double-precision floating-point number", + "short_desc": "inverse error function", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": -1, + "max": 1 + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -0.9, + 0.75 + ] + }, + "example_values": [ + -0.841, + 0.736, + -0.512, + 0.183, + -0.927, + 0.264, + -0.376, + 0.918, + -0.152, + 0.587, + -0.698, + 0.311, + -0.045, + 0.829, + -0.619, + 0.472, + -0.298, + 0.105, + -0.771, + 0.946 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "erf", + "erfinv", + "inverse", + "error" + ], + "extra_keywords": [] + } + } +}