diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/LICENSE b/lib/node_modules/@stdlib/math/base/special/erfcf/LICENSE new file mode 100644 index 000000000000..d9e0343f8e48 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/LICENSE @@ -0,0 +1,199 @@ + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + +DEPENDENCIES & ATTRIBUTION + +The library links against the following external libraries or contains +implementations from the following external libraries, which have their own +licenses: + +* FreeBSD + +Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved. + +Developed at SunPro, a Sun Microsystems, Inc. business. +Permission to use, copy, modify, and distribute this +software is freely granted, provided that this notice +is preserved. diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/README.md b/lib/node_modules/@stdlib/math/base/special/erfcf/README.md new file mode 100644 index 000000000000..b85c902ea039 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/README.md @@ -0,0 +1,234 @@ + + +# erfcf + +> [Complementary error function][complementary-error-function] for single-precision floating-point numbers. + +
+ +The [complementary error function][complementary-error-function] is defined as + + + +```math +\operatorname{erfc}(x) = 1 - \operatorname{erf}(x) = \frac{2}{\sqrt{\pi}} \int_x^\infty e^{-t^2}\,\mathrm{d}t +``` + + + + + +
+ + + +
+ +## Usage + +```javascript +var erfcf = require( '@stdlib/math/base/special/erfcf' ); +``` + +#### erfcf( x ) + +Evaluates the [complementary error function][complementary-error-function] for a single-precision floating-point number. + +```javascript +var y = erfcf( 0.0 ); +// returns 1.0 + +y = erfcf( 1.0 ); +// returns ~0.1573 + +y = erfcf( -1.0 ); +// returns ~1.8427 + +y = erfcf( Infinity ); +// returns 0.0 + +y = erfcf( -Infinity ); +// returns 2.0 + +y = erfcf( NaN ); +// returns NaN +``` + +
+ + + +
+ +## Notes + +- For very large positive `x`, the function approaches `0`, and for very large negative `x`, the function approaches `2`. + +
+ + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var erfcf = require( '@stdlib/math/base/special/erfcf' ); + +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -5.0, 5.0, opts ); + +logEachMap( 'erfcf(%0.4f) = %0.4f', x, erfcf ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/erfcf.h" +``` + +#### stdlib_base_erfcf( x ) + +Evaluates the [complementary error function][complementary-error-function] for a single-precision floating-point number. + +```c +float out = stdlib_base_erfcf( 0.0f ); +// returns 1.0f + +out = stdlib_base_erfcf( 1.0f ); +// returns ~0.1573f +``` + +The function accepts the following arguments: + +- **x**: `[in] float` input value. + +```c +float stdlib_base_erfcf( const float x ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/erfcf.h" +#include + +int main( void ) { + const float x[] = { -3.0f, -2.0f, -1.0f, 0.0f, 1.0f, 2.0f, 3.0f, 5.0f }; + + float y; + int i; + for ( i = 0; i < 8; i++ ) { + y = stdlib_base_erfcf( x[ i ] ); + printf( "erfcf(%f) = %f\n", x[ i ], y ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/erfcf/benchmark/benchmark.js new file mode 100644 index 000000000000..4d8dc4c11efc --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/benchmark/benchmark.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pkg = require( './../package.json' ).name; +var erfcf = require( './../lib' ); + + +// MAIN // + +bench( pkg, benchmark ); + +/** +* Benchmark function. +* +* @private +* @param {Object} b - benchmark instance +*/ +function benchmark( b ) { + var opts = { + 'dtype': 'float32' + }; + var x; + var y; + var i; + x = uniform( 100, -5.0, 5.0, opts ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = erfcf( x[ i%x.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +} diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/erfcf/benchmark/benchmark.native.js new file mode 100644 index 000000000000..2864d57cb09b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/benchmark/benchmark.native.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var erfcf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( erfcf instanceof Error ) +}; + + +// MAIN // + +bench( format( '%s::native', pkg ), opts, benchmark ); + +/** +* Benchmark function. +* +* @private +* @param {Object} b - benchmark instance +*/ +function benchmark( b ) { + var x; + var y; + var i; + + x = uniform( 100, -5.0, 5.0, { + 'dtype': 'float32' + }); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = erfcf( x[ i%x.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +} diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/erfcf/benchmark/c/Makefile new file mode 100644 index 000000000000..ff0ad2332400 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/benchmark/c/Makefile @@ -0,0 +1,126 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles C source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler +# @param {string} CFLAGS - C compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $< -lm + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/erfcf/benchmark/c/benchmark.c new file mode 100644 index 000000000000..f499ac95a799 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/benchmark/c/benchmark.c @@ -0,0 +1,142 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include +#include +#include +#include +#include + +#define NAME "erfcf" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Define prototypes for local functions. +*/ +static void print_version( void ); +static void print_summary( int total, int passing ); +static void print_results( double elapsed ); +static double tic( void ); +static float rand_float( void ); +static double benchmark( void ); + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + float x; + float y; + double t; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + x = ( rand_float() * 10.0f ) - 5.0f; + y = erfcf( x ); + if ( y != y ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y != y ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/erfcf/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/erfcf/docs/repl.txt new file mode 100644 index 000000000000..b5aefd377e40 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/docs/repl.txt @@ -0,0 +1,36 @@ + +{{alias}}( x ) + Evaluates the complementary error function for a single-precision + floating-point number. + + The complementary error function is defined as + + erfc(x) = 1 - erf(x) = (2/√π) ∫_x^∞ exp(-t²) dt + + Parameters + ---------- + x: number + Input value. + + Returns + ------- + y: number + Function value. + + Examples + -------- + > var y = {{alias}}( 0.0 ) + 1.0 + > y = {{alias}}( 1.0 ) + ~0.1573 + > y = {{alias}}( -1.0 ) + ~1.8427 + > y = {{alias}}( {{alias:@stdlib/constants/float32/pinf}} ) + 0.0 + > y = {{alias}}( {{alias:@stdlib/constants/float64/ninf}} ) + 2.0 + > y = {{alias}}( NaN ) + NaN + + See Also + -------- diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/erfcf/docs/types/index.d.ts new file mode 100644 index 000000000000..66b3567e3c59 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/docs/types/index.d.ts @@ -0,0 +1,64 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +// TypeScript Version: 4.1 + +/** +* Evaluates the complementary error function for a single-precision floating-point number. +* +* ## Notes +* +* - The complementary error function is defined as +* +* ```tex +* \operatorname{erfc}(x) = 1 - \operatorname{erf}(x) = \frac{2}{\sqrt{\pi}} \int_x^\infty e^{-t^2}\,\mathrm{d}t +* ``` +* +* @param x - input value +* @returns function value +* +* @example +* var y = erfcf( 0.0 ); +* // returns 1.0 +* +* @example +* var y = erfcf( 1.0 ); +* // returns ~0.1573 +* +* @example +* var y = erfcf( -1.0 ); +* // returns ~1.8427 +* +* @example +* var y = erfcf( Infinity ); +* // returns 0.0 +* +* @example +* var y = erfcf( -Infinity ); +* // returns 2.0 +* +* @example +* var y = erfcf( NaN ); +* // returns NaN +*/ +declare function erfcf( x: number ): number; + + +// EXPORTS // + +export = erfcf; diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/erfcf/docs/types/test.ts new file mode 100644 index 000000000000..d89748539a38 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/docs/types/test.ts @@ -0,0 +1,44 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +import erfcf = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + erfcf( 8 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a number... +{ + erfcf( true ); // $ExpectError + erfcf( false ); // $ExpectError + erfcf( null ); // $ExpectError + erfcf( undefined ); // $ExpectError + erfcf( '5' ); // $ExpectError + erfcf( [] ); // $ExpectError + erfcf( {} ); // $ExpectError + erfcf( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + erfcf(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/erfcf/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/erfcf/examples/c/example.c new file mode 100644 index 000000000000..98410d02e1bf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/examples/c/example.c @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include "stdlib/math/base/special/erfcf.h" +#include + +int main( void ) { + const float x[] = { -3.0f, -2.0f, -1.0f, 0.0f, 1.0f, 2.0f, 3.0f, 5.0f }; + + float y; + int i; + for ( i = 0; i < 8; i++ ) { + y = stdlib_base_erfcf( x[ i ] ); + printf( "erfcf(%f) = %f\n", x[ i ], y ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/erfcf/examples/index.js new file mode 100644 index 000000000000..019be5a30dfe --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/examples/index.js @@ -0,0 +1,30 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var erfcf = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -5.0, 5.0, opts ); + +logEachMap( 'erfcf(%0.4f) = %0.4f', x, erfcf ); diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/include.gypi b/lib/node_modules/@stdlib/math/base/special/erfcf/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '= 0x7f800000 ) { + // ((hx >>> 31) << 1) gives 0 for positive, 2 for negative + // ONE/x gives: 1/NaN=NaN, 1/+Inf=0, 1/-Inf=-0 + return f32( f32( ((hx >>> 31) << 1) ) + f32( ONE / x ) ); + } + + // Case: |x| < 0.84375 + if ( ix < 0x3f580000 ) { // 0x3f580000 is the float32 representation of 0.84375 + // Case: |x| < 2**-24 + if ( ix < 0x33800000 ) { + return f32( ONE - x ); + } + z = f32( x * x ); + r = f32( polyvalPP( z ) ); + s = f32( polyvalQQ( z ) ); + y = f32( r / s ); + if ( hx < 0x3e800000 ) { + // Case: x < 1/4 + return f32( ONE - f32( x + f32( x * y ) ) ); + } + r = f32( x * y ); + r = f32( r + f32( x - HALF ) ); + return f32( HALF - r ); + } + + // Case: 0.84375 <= |x| < 1.25 + if ( ix < 0x3fa00000 ) { + ax = absf( x ); + s = f32( f32( ax ) - ONE ); + P = f32( polyvalPA( s ) ); + Q = f32( polyvalQA( s ) ); + if ( hx >= 0 ) { + z = f32( ONE - ERX ); + return f32( z - f32( P / Q ) ); + } + z = f32( ERX + f32( P / Q ) ); + return f32( ONE + z ); + } + + // Case: |x| < 11 + if ( ix < 0x41300000 ) { + ax = absf( x ); + ax = f32( ax ); + s = f32( ONE / f32( ax * ax ) ); + + // Case: |x| < 2.85715 ~ 1/0.35 + if ( ix < 0x4036db8c ) { + R = f32( polyvalRA( s ) ); + S = f32( polyvalSA( s ) ); + } else { + // Case: x < -5 + if ( hx < 0 && ix >= 0x40a00000 ) { + return TWO-TINY; + } + R = f32( polyvalRB( s ) ); + S = f32( polyvalSB( s ) ); + } + + z = f32( fromWordf( (hx & 0xffffe000) >>> 0 ) ); + xm2 = f32( f32( z - ax ) * f32( z + ax ) ); + r = f32( exp( f32( f32( f32( -z * z ) - f32( 0.5625 ) ) + + f32( xm2 + f32( R / S ) ) ) ) ); + + if ( hx > 0 ) { + r = f32( r / ax ); + return r; + } + return f32( TWO - f32( r / ax ) ); + } + // Case: |x| >= 11 + if ( hx > 0 ) { + return TINY * TINY; + } + return TWO - TINY; +} + + +// EXPORTS // + +module.exports = erfcf; diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/native.js new file mode 100644 index 000000000000..dadc71f5309e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/native.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 complementary error function for a single-precision floating-point number. +* +* @private +* @param {number} x - input value +* @returns {number} function value +* +* @example +* var y = erfcf( 0.0 ); +* // returns 1.0 +* +* @example +* var y = erfcf( 1.0 ); +* // returns ~0.1573 +* +* @example +* var y = erfcf( -1.0 ); +* // returns ~1.8427 +* +* @example +* var y = erfcf( NaN ); +* // returns NaN +*/ +function erfcf( x ) +{ + return addon( x ); +} + + +// EXPORTS // + +module.exports = erfcf; diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_pa.js b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_pa.js new file mode 100644 index 000000000000..ba588077d865 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_pa.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// 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 f32( 3.65041046e-06 ); + } + return f32( 3.65041046e-06 + f32( x * f32( 4.15109307e-01 + f32( x * f32( -2.09395722e-01 + f32( x * 8.67677554e-02 ) ) ) ) ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_pp.js b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_pp.js new file mode 100644 index 000000000000..229853b4972a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_pp.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// 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 f32( 1.28379166e-01 ); + } + return f32( 1.28379166e-01 + f32( x * f32( -3.36030394e-01 + f32( x * -1.86261395e-03 ) ) ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_qa.js b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_qa.js new file mode 100644 index 000000000000..a1a0e40a8774 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_qa.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// 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 f32( 1.0 ); + } + return f32( 1.0 + f32( x * f32( 4.95560974e-01 + f32( x * f32( 3.71248513e-01 + f32( x * 3.92478965e-02 ) ) ) ) ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_qq.js b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_qq.js new file mode 100644 index 000000000000..cffc6396f32e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_qq.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// 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 f32( 1.0 ); + } + return f32( 1.0 + f32( x * f32( 3.12324315e-01 + f32( x * f32( 2.16070414e-02 + f32( x * -1.98859372e-03 ) ) ) ) ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_ra.js b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_ra.js new file mode 100644 index 000000000000..344c89f04f53 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_ra.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// 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 f32( -9.88156721e-03 ); + } + return f32( -9.88156721e-03 + f32( x * f32( -5.43658376e-01 + f32( x * f32( -1.66828310e+00 + f32( x * -6.91554189e-01 ) ) ) ) ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_rb.js b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_rb.js new file mode 100644 index 000000000000..03154540eab4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_rb.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// 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 f32( -9.86496918e-03 ); + } + return f32( -9.86496918e-03 + f32( x * f32( -5.48049808e-01 + f32( x * -1.84115684e+00 ) ) ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_sa.js b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_sa.js new file mode 100644 index 000000000000..8a1be0a4dc5a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_sa.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// 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 f32( 1.0 ); + } + return f32( 1.0 + f32( x * f32( 4.48581553e+00 + f32( x * f32( 4.10799170e+00 + f32( x * 5.53855181e-01 ) ) ) ) ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_sb.js b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_sb.js new file mode 100644 index 000000000000..3028304ff212 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/lib/polyval_sb.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MODULES // + +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// 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 f32( 1.0 ); + } + return f32( 1.0 + f32( x * f32( 4.87132740e+00 + f32( x * f32( 3.04982710e+00 + f32( x * -7.61900663e-01 ) ) ) ) ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/manifest.json b/lib/node_modules/@stdlib/math/base/special/erfcf/manifest.json new file mode 100644 index 000000000000..9c6d0ff6c0fc --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/manifest.json @@ -0,0 +1,78 @@ +{ + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/unary", + "@stdlib/number/float32/base/to-word", + "@stdlib/math/base/special/exp", + "@stdlib/math/base/special/absf" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/number/float32/base/to-word", + "@stdlib/math/base/special/exp", + "@stdlib/math/base/special/absf" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/number/float32/base/to-word", + "@stdlib/math/base/special/exp", + "@stdlib/math/base/special/absf" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/package.json b/lib/node_modules/@stdlib/math/base/special/erfcf/package.json new file mode 100644 index 000000000000..5a948b3048c9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/package.json @@ -0,0 +1,148 @@ +{ + "name": "@stdlib/math/base/special/erfcf", + "version": "0.0.0", + "description": "Complementary error function for single-precision floating-point numbers.", + "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", + "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", + "erfc", + "erfcf", + "complementary", + "error", + "function", + "special", + "float", + "float32", + "single", + "precision" + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "erfc", + "alias": "erfcf", + "pkg_desc": "evaluate the complementary error function for a single-precision floating-point number", + "desc": "evaluates the complementary error function for a single-precision floating-point number", + "short_desc": "complementary error function", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -5, + 5 + ] + }, + "example_values": [ + 0, + 0.5, + 1, + -1, + 2, + -2, + 3, + -3, + 0.1, + -0.1, + 0.25, + -0.25, + 1.5, + -1.5, + 2.5, + -2.5, + 4, + -4, + 5, + -5 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + } + }, + "keywords": [ + "erf", + "erfc", + "erfcf", + "complementary", + "error", + "function", + "special" + ], + "extra_keywords": [] + } + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/erfcf/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/erfcf/src/addon.c new file mode 100644 index 000000000000..ab38672a42c5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/src/addon.c @@ -0,0 +1,22 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include "stdlib/math/base/special/erfcf.h" +#include "stdlib/math/base/napi/unary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_F_F( stdlib_base_erfcf ) diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/src/main.c b/lib/node_modules/@stdlib/math/base/special/erfcf/src/main.c new file mode 100644 index 000000000000..9021f9405701 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/src/main.c @@ -0,0 +1,236 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 following copyright, license, and long comment were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/s_erff.c}. The implementation follows the original, but has been modified according to stdlib conventions. +* +* ```text +* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +* +* Developed at SunPro, a Sun Microsystems, Inc. business. +* Permission to use, copy, modify, and distribute this +* software is freely granted, provided that this notice +* is preserved. +* ``` +*/ + +#include "stdlib/math/base/special/erfcf.h" +#include "stdlib/math/base/special/exp.h" +#include "stdlib/math/base/special/absf.h" +#include "stdlib/number/float32/base/to_word.h" +#include +#include + +static const float tiny = 1.0e-30f; +static const float half = 0.5f; +static const float one = 1.0f; +static const float two = 2.0f; + +// 0x3f57bb00 +static const float erx = 8.42697144e-01f; + +// Polynomial coefficients for domain [0, 0.84375]: +static const float pp0 = 1.28379166e-01f; // 0x3e0375d4 +static const float pp1 = -3.36030394e-01f; // 0xbeac0c2d +static const float pp2 = -1.86261395e-03f; // 0xbaf422f4 +static const float qq1 = 3.12324315e-01f; // 0x3e9fe8f9 +static const float qq2 = 2.16070414e-02f; // 0x3cb10140 +static const float qq3 = -1.98859372e-03f; // 0xbb025311 + +// Polynomial coefficients for domain [0.84375, 1.25]: +static const float pa0 = 3.65041046e-06f; // 0x3674f993 +static const float pa1 = 4.15109307e-01f; // 0x3ed48935 +static const float pa2 = -2.09395722e-01f; // 0xbe566bd5 +static const float pa3 = 8.67677554e-02f; // 0x3db1b34b +static const float qa1 = 4.95560974e-01f; // 0x3efdba2b +static const float qa2 = 3.71248513e-01f; // 0x3ebe1449 +static const float qa3 = 3.92478965e-02f; // 0x3d20c267 + +// Polynomial coefficients for domain [1.25, 1/0.35]: +static const float ra0 = -9.88156721e-03f; // 0xbc21e64c +static const float ra1 = -5.43658376e-01f; // 0xbf0b2d32 +static const float ra2 = -1.66828310e+00f; // 0xbfd58a4d +static const float ra3 = -6.91554189e-01f; // 0xbf3109b2 +static const float sa1 = 4.48581553e+00f; // 0x408f8bcd +static const float sa2 = 4.10799170e+00f; // 0x408374ab +static const float sa3 = 5.53855181e-01f; // 0x3f0dc974 + +// Polynomial coefficients for domain [2.85715, 11]: +static const float rb0 = -9.86496918e-03f; // 0xbc21a0ae +static const float rb1 = -5.48049808e-01f; // 0xbf0c4cfe +static const float rb2 = -1.84115684e+00f; // 0xbfebab07 +static const float sb1 = 4.87132740e+00f; // 0x409be1ea +static const float sb2 = 3.04982710e+00f; // 0x4043305e +static const float sb3 = -7.61900663e-01f; // 0xbf430bec + +/** +* Evaluates the complementary error function for a single-precision floating-point number. +* +* ## Method +* +* 1. For \\( x \in [0, 0.84375] \\), we use the approximation +* +* ```tex +* \operatorname{erfc}(x) = 1 - \operatorname{erf}(x) = 1 - x \cdot \frac{P(x^2)}{Q(x^2)} +* ``` +* +* where \\( P \\) and \\( Q \\) are polynomials (pp and qq). +* +* 2. For \\( x \in [0.84375, 1.25] \\), we use the approximation +* +* ```tex +* \operatorname{erfc}(x) = 1 - \operatorname{erf}(x) = 1 - \operatorname{erx} - \frac{P(x-1)}{Q(x-1)} +* ``` +* +* where \\( P \\) and \\( Q \\) are polynomials (pa and qa). +* +* 3. For \\( x \in [1.25, 11] \\), we use the approximation +* +* ```tex +* \operatorname{erfc}(x) = \frac{1}{x} e^{-x^2 - 0.5625 + \frac{R(1/x^2)}{S(1/x^2)}} +* ``` +* +* where \\( R \\) and \\( S \\) are rational functions (ra/sa for x < 2.85715, rb/sb for x >= 2.85715). +* +* 4. For \\( x \geq 11 \\), we use the approximation +* +* ```tex +* \operatorname{erfc}(x) = 0 +* ``` +* +* ## Notes +* +* - Relative error: +* - \\( |x| < 0.84375 \\): \\( 2^{-31} \\) +* - \\( 0.84375 \leq |x| < 1.25 \\): \\( 2^{-31} \\) +* - \\( 1.25 \leq |x| < 2.85715 \\): \\( 2^{-30} \\) +* - \\( 2.85715 \leq |x| < 11 \\): \\( 2^{-30} \\) +* +* @param x input value +* @return function value +* +* @example +* float y = stdlib_base_erfcf( 0.0f ); +* // returns 1.0f +* +* @example +* float y = stdlib_base_erfcf( 1.0f ); +* // returns ~0.1573f +*/ +float stdlib_base_erfcf( const float x ) +{ + stdlib_base_float32_word_t wx; + float R; + float S; + float P; + float Q; + float s; + float y; + float z; + float r; + int32_t hx; + int32_t ix; + + // Handle NaN: + if ( x != x ) + { + return x; + } + + wx.value = x; + hx = (int32_t)wx.word; + ix = hx & 0x7fffffff; + + // Case: |x| < 0.84375 + if ( ix < 0x3f580000 ) + { + // Case: |x| < 2**-24 + if ( ix < 0x33800000 ) + { + return one - x; + } + z = x * x; + r = pp0 + ( z * ( pp1 + ( z * pp2 ) ) ); + s = one + ( z * ( qq1 + ( z * ( qq2 + ( z * qq3 ) ) ) ) ); + y = r / s; + if ( hx < 0x3e800000 ) + { + // Case: x < 1/4 + return one - ( x + ( x * y ) ); + } + r = x * y; + r += ( x - half ); + return half - r; + } + // Case: 0.84375 <= |x| < 1.25 + if ( ix < 0x3fa00000 ) + { + s = stdlib_base_absf( x ) - one; + P = pa0 + ( s * ( pa1 + ( s * ( pa2 + ( s * pa3 ) ) ) ) ); + Q = one + ( s * ( qa1 + ( s * ( qa2 + ( s * qa3 ) ) ) ) ); + if ( hx >= 0 ) + { + z = one - erx; + return z - ( P / Q ); + } + z = erx + ( P / Q ); + return one + z; + } + // Case: |x| < 11 + if ( ix < 0x41300000 ) + { + float ax; + float xm2; + + ax = stdlib_base_absf( x ); + s = one / ( ax * ax ); + + // Case: |x| < 2.85715 ~ 1/0.35 + if ( ix < 0x4036db8c ) + { + R = ra0 + ( s * ( ra1 + ( s * ( ra2 + ( s * ra3 ) ) ) ) ); + S = one + ( s * ( sa1 + ( s * ( sa2 + ( s * sa3 ) ) ) ) ); + } + else + { + // Case: x < -5 + if ( hx < 0 && ix >= 0x40a00000 ) + { + return two - tiny; + } + R = rb0 + ( s * ( rb1 + ( s * rb2 ) ) ); + S = one + ( s * ( sb1 + ( s * ( sb2 + ( s * sb3 ) ) ) ) ); + } + wx.word = (uint32_t)( hx & 0xffffe000 ); + z = wx.value; + xm2 = ( z - ax ) * ( z + ax ); + r = (float)stdlib_base_exp( (double)( ( -z * z ) - 0.5625 + xm2 + ( R / S ) ) ); + if ( hx > 0 ) + { + return r / ax; + } + return two - ( r / ax ); + } + // Case: |x| >= 11 + if ( hx > 0 ) + { + return tiny*tiny; + } + return two-tiny; +} diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/test/test.js b/lib/node_modules/@stdlib/math/base/special/erfcf/test/test.js new file mode 100644 index 000000000000..2f936dd62aa1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/test/test.js @@ -0,0 +1,179 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var erfc = require( '@stdlib/math/base/special/erfc' ); +var erfcf = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof erfcf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `1.0` if provided `0`', function test( t ) +{ + var y = erfcf( 0.0 ); + t.strictEqual( y, 1.0, 'returns 1.0' ); + t.end(); +}); + +tape( 'the function returns `0.0` if provided `+infinity`', function test( t ) { + var y = erfcf( PINF ); + t.strictEqual( y, 0.0, 'returns 0.0' ); + t.end(); +}); + +tape( 'the function returns `2.0` if provided `-infinity`', function test( t ) { + var y = erfcf( NINF ); + t.strictEqual( y, 2.0, 'returns 2.0' ); + t.end(); +}); + +tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { + var y = erfcf( NaN ); + t.strictEqual( isnanf( y ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'the function evaluates the complementary error function (positive values)', function test( t ) { + var delta; + var tol; + var x; + var y; + var e; + + // Test against the double-precision reference implementation: + x = f32( 0.5 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + delta = absf( y - e ); + tol = f32( 2.0 * EPS * absf( e ) ); + t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x+'. y: '+y+'. E: '+e+'. tol: '+tol+'. delta: '+delta+'.' ); + + x = f32( 1.0 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + delta = absf( y - e ); + tol = f32( 2.0 * EPS * absf( e ) ); + t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x+'. y: '+y+'. E: '+e+'. tol: '+tol+'. delta: '+delta+'.' ); + + x = f32( 2.0 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + delta = absf( y - e ); + tol = f32( 5.0 * EPS * absf( e ) ); + t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x+'. y: '+y+'. E: '+e+'. tol: '+tol+'. delta: '+delta+'.' ); + + x = f32( 3.0 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + delta = absf( y - e ); + tol = f32( 10.0 * EPS * absf( e ) ); + t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x+'. y: '+y+'. E: '+e+'. tol: '+tol+'. delta: '+delta+'.' ); + + t.end(); +}); + +tape( 'the function evaluates the complementary error function (negative values)', function test( t ) { + var delta; + var tol; + var x; + var y; + var e; + + // Test against the double-precision reference implementation: + x = f32( -0.5 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + delta = absf( y - e ); + tol = f32( 2.0 * EPS * absf( e ) ); + t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x+'. y: '+y+'. E: '+e+'. tol: '+tol+'. delta: '+delta+'.' ); + + x = f32( -1.0 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + delta = absf( y - e ); + tol = f32( 2.0 * EPS * absf( e ) ); + t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x+'. y: '+y+'. E: '+e+'. tol: '+tol+'. delta: '+delta+'.' ); + + x = f32( -2.0 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + delta = absf( y - e ); + tol = f32( 2.0 * EPS * absf( e ) ); + t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x+'. y: '+y+'. E: '+e+'. tol: '+tol+'. delta: '+delta+'.' ); + + t.end(); +}); + +tape( 'the function evaluates the complementary error function (very small positive values)', function test( t ) { + var x; + var y; + var e; + + x = f32( 1.0e-10 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + t.strictEqual( absf( y - e ) < f32( 1.0e-15 ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function evaluates the complementary error function (large positive values)', function test( t ) { + var x; + var y; + + x = f32( 10.0 ); + y = erfcf( x ); + t.strictEqual( y < f32( 1.0e-30 ), true, 'returns value very close to 0' ); + + x = f32( 100.0 ); + y = erfcf( x ); + t.strictEqual( y < f32( 1.0e-30 ), true, 'returns value very close to 0' ); + + t.end(); +}); + +tape( 'the function evaluates the complementary error function (large negative values)', function test( t ) { + var x; + var y; + + x = f32( -10.0 ); + y = erfcf( x ); + t.strictEqual( y, 2.0, 'returns 2.0' ); + + x = f32( -100.0 ); + y = erfcf( x ); + t.strictEqual( y, 2.0, 'returns 2.0' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/erfcf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/erfcf/test/test.native.js new file mode 100644 index 000000000000..64a2afa461e7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/erfcf/test/test.native.js @@ -0,0 +1,150 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var erfc = require( '@stdlib/math/base/special/erfc' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var erfcf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( erfcf instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof erfcf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `1.0` if provided `0`', opts, function test( t ) { + var y = erfcf( 0.0 ); + t.strictEqual( y, 1.0, 'returns 1.0' ); + t.end(); +}); + +tape( 'the function returns `0.0` if provided `+infinity`', opts, function test( t ) { + var y = erfcf( PINF ); + t.strictEqual( y, 0.0, 'returns 0.0' ); + t.end(); +}); + +tape( 'the function returns `2.0` if provided `-infinity`', opts, function test( t ) { + var y = erfcf( NINF ); + t.strictEqual( y, 2.0, 'returns 2.0' ); + t.end(); +}); + +tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { + var y = erfcf( NaN ); + t.strictEqual( isnanf( y ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'the function evaluates the complementary error function (positive values)', opts, function test( t ) { + var delta; + var tol; + var x; + var y; + var e; + + x = f32( 0.5 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + delta = absf( y - e ); + tol = f32( 2.0 * EPS * absf( e ) ); + t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x+'. y: '+y+'. E: '+e+'. tol: '+tol+'. delta: '+delta+'.' ); + + x = f32( 1.0 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + delta = absf( y - e ); + tol = f32( 2.0 * EPS * absf( e ) ); + t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x+'. y: '+y+'. E: '+e+'. tol: '+tol+'. delta: '+delta+'.' ); + + x = f32( 2.0 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + delta = absf( y - e ); + tol = f32( 5.0 * EPS * absf( e ) ); + t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x+'. y: '+y+'. E: '+e+'. tol: '+tol+'. delta: '+delta+'.' ); + + t.end(); +}); + +tape( 'the function evaluates the complementary error function (negative values)', opts, function test( t ) { + var delta; + var tol; + var x; + var y; + var e; + + x = f32( -0.5 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + delta = absf( y - e ); + tol = f32( 2.0 * EPS * absf( e ) ); + t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x+'. y: '+y+'. E: '+e+'. tol: '+tol+'. delta: '+delta+'.' ); + + x = f32( -1.0 ); + y = erfcf( x ); + e = f32( erfc( x ) ); + delta = absf( y - e ); + tol = f32( 2.0 * EPS * absf( e ) ); + t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x+'. y: '+y+'. E: '+e+'. tol: '+tol+'. delta: '+delta+'.' ); + + t.end(); +}); + +tape( 'the function evaluates the complementary error function (large positive values)', opts, function test( t ) { + var x; + var y; + + x = f32( 10.0 ); + y = erfcf( x ); + t.strictEqual( y < f32( 1.0e-30 ), true, 'returns value very close to 0' ); + + t.end(); +}); + +tape( 'the function evaluates the complementary error function (large negative values)', opts, function test( t ) { + var x; + var y; + + x = f32( -10.0 ); + y = erfcf( x ); + t.strictEqual( y, 2.0, 'returns 2.0' ); + + t.end(); +});