diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/LICENSE b/lib/node_modules/@stdlib/math/base/special/gammaf/LICENSE new file mode 100644 index 000000000000..a806fb1b162b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/LICENSE @@ -0,0 +1,222 @@ + + 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: + +* Boost + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +* Cephes + +Copyright (c) 1984-2000 Stephen L. Moshier + +Some software in this archive may be from the book _Methods and Programs for +Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989) +or from the Cephes Mathematical Library, a commercial product. In either event, +it is copyrighted by the author. What you see here may be used freely but it +comes with no support or guarantee. + +Stephen L. Moshier +moshier@na-net.ornl.gov diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/README.md b/lib/node_modules/@stdlib/math/base/special/gammaf/README.md new file mode 100644 index 000000000000..9b943a105613 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/README.md @@ -0,0 +1,249 @@ + + +# gammaf + +> Evaluate the [gamma function][gamma-function] for a single-precision floating-point number. + +
+ +The [gamma function][gamma-function] extends the [factorial function][@stdlib/math/base/special/factorial] to [real][real] and [complex][complex] numbers. If `n` is a positive `integer`, + + + +```math +\Gamma ( n ) = (n-1)! +``` + + + + + +Generalized to all complex numbers `z`, except for nonpositive integers, the [gamma function][gamma-function] can be expressed as an infinite product + + + +```math +\Gamma ( z ) = \frac{e^{-\gamma z}}{z} \prod^{\infty}_{n=1} \left ( 1+\frac{z}{n}\right )^{-1} e^{z/n} +``` + + + + + +where `γ ≈ 0.577216` is the [Euler–Mascheroni constant][@stdlib/constants/float32/eulergamma]. + +
+ + + +
+ +## Usage + +```javascript +var gammaf = require( '@stdlib/math/base/special/gammaf' ); +``` + +#### gammaf( x ) + +Evaluates the [gamma function][gamma-function] for a single-precision floating-point number. + +```javascript +var v = gammaf( 4.0 ); +// returns 6.0 + +v = gammaf( -1.5 ); +// returns ~2.363 + +v = gammaf( -0.5 ); +// returns ~-3.545 + +v = gammaf( 0.5 ); +// returns ~1.772 + +v = gammaf( 0.0 ); +// returns Infinity + +v = gammaf( -0.0 ); +// returns -Infinity + +v = gammaf( NaN ); +// returns NaN +``` + +
+ + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var gammaf = require( '@stdlib/math/base/special/gammaf' ); + +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -10.0, 10.0, opts ); + +logEachMap( 'x: %0.4f, f(x): %0.4f', x, gammaf ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/gammaf.h" +``` + +#### stdlib_base_gammaf( x ) + +Evaluates the [gamma function][gamma-function] for a single-precision floating-point number. + +```c +float out = stdlib_base_gammaf( 4.0f ); +// returns 6.0 + +out = stdlib_base_gammaf( -1.5f ); +// returns ~2.363 +``` + +The function accepts the following arguments: + +- **x**: `[in] float` input value. + +```c +float stdlib_base_gammaf( const float x ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/gammaf.h" +#include + +int main( void ) { + const float x[] = { 4.0f, -1.5f, -0.5f, 0.5f }; + + float y; + int i; + for ( i = 0; i < 4; i++ ) { + y = stdlib_base_gammaf( x[ i ] ); + printf( "gammaf(%f) = %f\n", x[ i ], y ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/gammaf/benchmark/benchmark.js new file mode 100644 index 000000000000..fcc6bb1b6e28 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/benchmark/benchmark.js @@ -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. +*/ + +'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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gammaf = require( './../lib' ); + + +// MAIN // + +bench( format( '%s', pkg ), function benchmark( b ) { + var x; + var y; + var i; + + x = uniform( 100, 0.0, 35.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = gammaf( 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/gammaf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/gammaf/benchmark/benchmark.native.js new file mode 100644 index 000000000000..10f723336480 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/benchmark/benchmark.native.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 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 format = require( '@stdlib/string/format' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var gammaf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( gammaf instanceof Error ) +}; + + +// MAIN // + +bench( format( '%s::native', pkg ), opts, function benchmark( b ) { + var x; + var y; + var i; + + x = uniform( 100, 0.0, 35.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = gammaf( 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/gammaf/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/gammaf/benchmark/c/Makefile new file mode 100644 index 000000000000..c95d08ae96a1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/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 +# @param {string} [CFLAGS] - C compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @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/gammaf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/gammaf/benchmark/c/benchmark.c new file mode 100644 index 000000000000..e3b87cdaf3f7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/benchmark/c/benchmark.c @@ -0,0 +1,137 @@ +/** +* @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 "gammaf" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* 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 [min,max). +* +* @param min minimum value (inclusive) +* @param max maximum value (exclusive) +* @return random number +*/ +static float random_uniform( const float min, const float max ) { + float v = (float)rand() / ( (float)RAND_MAX + 1.0f ); + return min + ( v * ( max - min ) ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + float x[ 100 ]; + double elapsed; + float y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + x[ i ] = random_uniform( 0.0, 35.0 ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = tgammaf( x[ i % 100 ] ); + 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/gammaf/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/gammaf/benchmark/c/native/Makefile new file mode 100644 index 000000000000..e790d7bffa7f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/benchmark/c/native/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 := benchmark.out + + +# RULES # + +#/ +# Compiles C source files. +# +# @param {string} SOURCE_FILES - list of C source files +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [C_COMPILER] - C compiler +# @param {string} [CFLAGS] - C compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} SOURCE_FILES - list of C source files +# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) +# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @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) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# 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/gammaf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/gammaf/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..5fc962a54a3d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/benchmark/c/native/benchmark.c @@ -0,0 +1,138 @@ +/** +* @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/gammaf.h" +#include +#include +#include +#include +#include + +#define NAME "gammaf" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* 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 [min,max). +* +* @param min minimum value (inclusive) +* @param max maximum value (exclusive) +* @return random number +*/ +static float random_uniform( const float min, const float max ) { + float v = (float)rand() / ( (float)RAND_MAX + 1.0f ); + return min + ( v*(max-min) ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + float x[ 100 ]; + double elapsed; + float y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + x[ i ] = random_uniform( 0.0, 35.0 ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_gammaf( x[ i % 100 ] ); + 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::native::%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/gammaf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/gammaf/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/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/gammaf/docs/img/equation_gamma_function_infinite_product.svg b/lib/node_modules/@stdlib/math/base/special/gammaf/docs/img/equation_gamma_function_infinite_product.svg new file mode 100644 index 000000000000..6b6c59d75c6b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/docs/img/equation_gamma_function_infinite_product.svg @@ -0,0 +1,76 @@ + +normal upper Gamma left-parenthesis z right-parenthesis equals StartFraction e Superscript minus gamma z Baseline Over z EndFraction product Underscript n equals 1 Overscript normal infinity Endscripts left-parenthesis 1 plus StartFraction z Over n EndFraction right-parenthesis Superscript negative 1 Baseline e Superscript z slash n + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/docs/img/equation_gamma_function_positive_integers.svg b/lib/node_modules/@stdlib/math/base/special/gammaf/docs/img/equation_gamma_function_positive_integers.svg new file mode 100644 index 000000000000..38f0c2bce2a2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/docs/img/equation_gamma_function_positive_integers.svg @@ -0,0 +1,26 @@ + +normal upper Gamma left-parenthesis n right-parenthesis equals left-parenthesis n minus 1 right-parenthesis factorial + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/gammaf/docs/repl.txt new file mode 100644 index 000000000000..7637bc647af8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/docs/repl.txt @@ -0,0 +1,34 @@ + +{{alias}}( x ) + Evaluates the gamma function of a single-precision floating-point number. + + Parameters + ---------- + x: number + Input value. + + Returns + ------- + y: number + Function value. + + Examples + -------- + > var y = {{alias}}( 4.0 ) + 6.0 + > y = {{alias}}( -1.5 ) + ~2.363 + > y = {{alias}}( -0.5 ) + ~-3.545 + > y = {{alias}}( 0.5 ) + ~1.772 + > y = {{alias}}( 0.0 ) + Infinity + > y = {{alias}}( -0.0 ) + -Infinity + > y = {{alias}}( NaN ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/gammaf/docs/types/index.d.ts new file mode 100644 index 000000000000..42a83d322960 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/docs/types/index.d.ts @@ -0,0 +1,60 @@ +/* +* @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 gamma function of a single-precision floating-point number. +* +* @param x - input value +* @returns function value +* +* @example +* var v = gammaf( 4.0 ); +* // returns 6.0 +* +* @example +* var v = gammaf( -1.5 ); +* // returns ~2.363 +* +* @example +* var v = gammaf( -0.5 ); +* // returns ~-3.545 +* +* @example +* var v = gammaf( 0.5 ); +* // returns ~1.772 +* +* @example +* var v = gammaf( 0.0 ); +* // returns Infinity +* +* @example +* var v = gammaf( -0.0 ); +* // returns -Infinity +* +* @example +* var v = gammaf( NaN ); +* // returns NaN +*/ +declare function gammaf( x: number ): number; + + +// EXPORTS // + +export = gammaf; diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/gammaf/docs/types/test.ts new file mode 100644 index 000000000000..a644086bed81 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/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 gammaf = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + gammaf( 8 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a number... +{ + gammaf( true ); // $ExpectError + gammaf( false ); // $ExpectError + gammaf( null ); // $ExpectError + gammaf( undefined ); // $ExpectError + gammaf( '5' ); // $ExpectError + gammaf( [] ); // $ExpectError + gammaf( {} ); // $ExpectError + gammaf( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + gammaf(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/gammaf/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/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/gammaf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/gammaf/examples/c/example.c new file mode 100644 index 000000000000..57a01d32277c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/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/gammaf.h" +#include + +int main( void ) { + const float x[] = { 4.0f, -1.5f, -0.5f, 0.5f }; + + float y; + int i; + for ( i = 0; i < 4; i++ ) { + y = stdlib_base_gammaf( x[ i ] ); + printf( "gammaf(%f) = %f\n", x[ i ], y ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/gammaf/examples/index.js new file mode 100644 index 000000000000..bc99cc5c1dab --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/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 gammaf = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -10.0, 10.0, opts ); + +logEachMap( 'x: %0.4f, f(x): %0.4f', x, gammaf ); diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/include.gypi b/lib/node_modules/@stdlib/math/base/special/gammaf/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/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': [ + ' MAX_ARG ) { + return PINF; + } + + if ( x < MIN_ARG ) { + return 0.0; + } + + if ( x < ZERO ) { + negative = 1; + q = -x; + p = floorf( q ); + if ( p === q ) { + return NaN; + } + if ( (p&1) === 0 ) { + sign = -ONE; + } else { + sign = ONE; + } + nz = f32( q - p ); + if ( nz > HALF ) { + p += ONE; + nz = f32( q - p ); + } + nz = f32( q * sinf( f32( PI * nz ) ) ); + if ( nz === ZERO ) { + return NaN; + } + if ( nz < 0 ) { + nz = f32( -nz ); + } + x = f32( q ); + } + if ( x >= TEN ) { + z = stirlingApprox( x ); + } + if ( x < TWO ) { + direction = 1; + } else { + direction = 0; + } + z = ONE; + while ( x >= THREE ) { + x = f32( x - ONE ); + z = f32( z * x ); + } + small = 0; + while ( x < TWO ) { + if ( x < SMALL_X ) { + small = 1; + break; + } + z = f32( z * x ); + x = f32( x + ONE ); + } + + if ( small ) { + if ( x === ZERO ) { + return PINF; + } + p = smallApprox( x, z ); + } else { + if ( direction ) { + z = f32( ONE / z ); + } + if ( x === TWO ) { + p = z; + } else { + x = f32( x - TWO ); + p = f32( z * polyeval( x ) ); + } + } + if ( negative ) { + p = f32( f32( sign * PI ) / f32( nz * p ) ); + } + return p; +} + + +// EXPORTS // + +module.exports = gammaf; diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/gammaf/lib/native.js new file mode 100644 index 000000000000..b746b9d0a42f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/lib/native.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Evaluates the gamma function of a single-precision floating-point number. +* +* @private +* @param {number} x - input value +* @returns {number} function value +* +* @example +* var v = gammaf( 4.0 ); +* // returns 6.0 +* +* @example +* var v = gammaf( -1.5 ); +* // returns ~2.363 +* +* @example +* var v = gammaf( -0.5 ); +* // returns ~-3.545 +* +* @example +* var v = gammaf( 0.5 ); +* // returns ~1.772 +* +* @example +* var v = gammaf( 0.0 ); +* // returns Infinity +* +* @example +* var v = gammaf( -0.0 ); +* // returns -Infinity +* +* @example +* var v = gammaf( NaN ); +* // returns NaN +*/ +function gammaf( x ) { + return addon( x ); +} + + +// EXPORTS // + +module.exports = gammaf; diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/lib/polyval_p.js b/lib/node_modules/@stdlib/math/base/special/gammaf/lib/polyval_p.js new file mode 100644 index 000000000000..5259e367de0c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/lib/polyval_p.js @@ -0,0 +1,47 @@ +/** +* @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'; + +// 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 0.9999999822945073; + } + return 0.9999999822945073 + (x * (0.4227867745131584 + (x * (0.4117857447645796 + (x * (0.08203960091619193 + (x * (0.07232307985516519 + (x * (0.004130370201859976 + (x * (0.005397581592950993 + (x * 0.001536830450601906))))))))))))); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/lib/polyval_s.js b/lib/node_modules/@stdlib/math/base/special/gammaf/lib/polyval_s.js new file mode 100644 index 000000000000..377a2b6629a2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/lib/polyval_s.js @@ -0,0 +1,47 @@ +/** +* @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'; + +// 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 0.08333331788340907; + } + return 0.08333331788340907 + (x * (0.00347325578615491 + (x * -0.002705194986674176))); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/lib/small_approximation.js b/lib/node_modules/@stdlib/math/base/special/gammaf/lib/small_approximation.js new file mode 100644 index 000000000000..e4bafd745910 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/lib/small_approximation.js @@ -0,0 +1,58 @@ +/** +* @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 original C code, copyright, license, and constants are from [Cephes]{@link http://www.netlib.org/cephes}. The implementation follows the original, but has been modified for JavaScript. +* +* ```text +* Copyright 1984, 1987, 1989, 1992, 2000 by Stephen L. Moshier +* +* Some software in this archive may be from the book _Methods and Programs for Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989) or from the Cephes Mathematical Library, a commercial product. In either event, it is copyrighted by the author. What you see here may be used freely but it comes with no support or guarantee. +* +* Stephen L. Moshier +* moshier@na-net.ornl.gov +* ``` +*/ + +'use strict'; + +// MODULES // + +var EULER = require( '@stdlib/constants/float32/eulergamma' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// MAIN // + +/** +* Evaluates the gamma function of a single-precision floating-point value using a small-value approximation. +* +* @private +* @param {number} x - input value +* @param {number} z - scale factor +* @returns {number} function value +*/ +function gammaf( x, z ) { + return f32( z / f32( f32( 1.0 + f32( EULER*x ) ) * x ) ); +} + + +// EXPORTS // + +module.exports = gammaf; diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/lib/stirling_approximation.js b/lib/node_modules/@stdlib/math/base/special/gammaf/lib/stirling_approximation.js new file mode 100644 index 000000000000..0636df9d3a22 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/lib/stirling_approximation.js @@ -0,0 +1,81 @@ +/** +* @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 original C code, copyright, license, and constants are from [Cephes]{@link http://www.netlib.org/cephes}. The implementation follows the original, but has been modified for JavaScript. +* +* ```text +* Copyright 1984, 1987, 1989, 1992, 2000 by Stephen L. Moshier +* +* Some software in this archive may be from the book _Methods and Programs for Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989) or from the Cephes Mathematical Library, a commercial product. In either event, it is copyrighted by the author. What you see here may be used freely but it comes with no support or guarantee. +* +* Stephen L. Moshier +* moshier@na-net.ornl.gov +* ``` +*/ + +'use strict'; + +// MODULES // + +var SQRT_TWO_PI = require( '@stdlib/constants/float32/sqrt-two-pi' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var powf = require( '@stdlib/math/base/special/powf' ); +var exp = require( '@stdlib/math/base/special/exp' ); +var polyval = require( './polyval_s.js' ); + + +// VARIABLES // + +var MAX_STIRLING = 26.77; + + +// MAIN // + +/** +* Evaluates the gamma function using Stirling's formula. The polynomial is valid for \\(33 \leq x \leq 172\\). +* +* @private +* @param {number} x - input value +* @returns {number} function value +*/ +function gammaf( x ) { + var w; + var y; + var v; + + w = f32( 1.0 / x ); + w = f32( 1.0 + f32( w * polyval( w ) ) ); + y = f32( exp( -x ) ); + + // Check `x` to avoid `pow()` overflow... + if ( x > MAX_STIRLING ) { + v = powf( x, f32( f32( 0.5*x ) - 0.25 ) ); + y = f32( y * v ); + y = f32( y * v ); + } else { + y = f32( powf( x, f32( x-0.5 ) ) * y ); + } + return f32( f32( SQRT_TWO_PI * y ) * w ); +} + + +// EXPORTS // + +module.exports = gammaf; diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/manifest.json b/lib/node_modules/@stdlib/math/base/special/gammaf/manifest.json new file mode 100644 index 000000000000..668782eed389 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/manifest.json @@ -0,0 +1,105 @@ +{ + "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/math/base/assert/is-nanf", + "@stdlib/math/base/assert/is-negative-zerof", + "@stdlib/math/base/assert/is-integerf", + "@stdlib/math/base/special/floorf", + "@stdlib/math/base/special/sinf", + "@stdlib/constants/float32/pinf", + "@stdlib/constants/float32/ninf", + "@stdlib/constants/float32/pi", + "@stdlib/constants/float32/eulergamma", + "@stdlib/constants/float32/sqrt-two-pi", + "@stdlib/math/base/special/powf", + "@stdlib/math/base/special/exp" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/assert/is-negative-zerof", + "@stdlib/math/base/assert/is-integerf", + "@stdlib/math/base/special/floorf", + "@stdlib/math/base/special/sinf", + "@stdlib/constants/float32/pinf", + "@stdlib/constants/float32/ninf", + "@stdlib/constants/float32/pi", + "@stdlib/constants/float32/eulergamma", + "@stdlib/constants/float32/sqrt-two-pi", + "@stdlib/math/base/special/powf", + "@stdlib/math/base/special/exp" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/assert/is-negative-zerof", + "@stdlib/math/base/assert/is-integerf", + "@stdlib/math/base/special/floorf", + "@stdlib/math/base/special/sinf", + "@stdlib/constants/float32/pinf", + "@stdlib/constants/float32/ninf", + "@stdlib/constants/float32/pi", + "@stdlib/constants/float32/eulergamma", + "@stdlib/constants/float32/sqrt-two-pi", + "@stdlib/math/base/special/powf", + "@stdlib/math/base/special/exp" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/package.json b/lib/node_modules/@stdlib/math/base/special/gammaf/package.json new file mode 100644 index 000000000000..f39f9c6a906e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/package.json @@ -0,0 +1,139 @@ +{ + "name": "@stdlib/math/base/special/gammaf", + "version": "0.0.0", + "description": "Gamma 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", + "scripts": "./scripts", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "special function", + "special", + "function", + "gamma", + "factorial", + "number" + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "gamma", + "alias": "gammaf", + "pkg_desc": "evaluate the gamma function for a single-precision floating-point number", + "desc": "evaluates the gamma function for a single-precision floating-point number", + "short_desc": "gamma 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": [ + -10, + 10 + ] + }, + "example_values": [ + 1, + 3.5, + 4.5, + -0.5, + 2, + 3, + -3.5, + 0.1, + 4, + 1.5, + 5, + 0.5, + 2.5, + -1.5, + -2.5, + 50, + 100, + -50.5, + -100.5, + 2.2 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + } + }, + "keywords": [ + "gamma", + "factorial" + ], + "extra_keywords": [] + } + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/scripts/evalpoly.js b/lib/node_modules/@stdlib/math/base/special/gammaf/scripts/evalpoly.js new file mode 100644 index 000000000000..e0c1454aae95 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/scripts/evalpoly.js @@ -0,0 +1,138 @@ +/** +* @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 script compiles modules for evaluating polynomial functions. If any polynomial coefficients change, this script should be rerun to update the compiled files. +*/ +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var readFileSync = require( '@stdlib/fs/read-file' ).sync; +var writeFileSync = require( '@stdlib/fs/write-file' ).sync; +var currentYear = require( '@stdlib/time/current-year' ); +var licenseHeader = require( '@stdlib/_tools/licenses/header' ); +var compile = require( '@stdlib/math/base/tools/evalpoly-compile' ); +var compileC = require( '@stdlib/math/base/tools/evalpoly-compile-c' ); +var substringBefore = require( '@stdlib/string/substring-before' ); +var substringAfter = require( '@stdlib/string/substring-after' ); +var format = require( '@stdlib/string/format' ); + + +// VARIABLES // + +// Polynomial coefficients ordered in ascending degree... +var S = [ + 8.333331788340907E-002, + 3.473255786154910E-003, + -2.705194986674176E-003 +]; +var P = [ + 9.999999822945073e-01, + 4.227867745131584e-01, + 4.117857447645796e-01, + 8.203960091619193e-02, + 7.232307985516519e-02, + 4.130370201859976e-03, + 5.397581592950993e-03, + 1.536830450601906e-03 +]; + +// Header to add to output files: +var header = licenseHeader( 'Apache-2.0', 'js', { + 'year': currentYear(), + 'copyright': 'The Stdlib Authors' +}); +header += '\n/* This is a generated file. Do not edit directly. */\n'; + + +// FUNCTIONS // + +/** +* Inserts a compiled function into file content. +* +* @private +* @param {string} text - source content +* @param {string} id - function identifier +* @param {string} str - function string +* @returns {string} updated content +*/ +function insert( text, id, str ) { + var before; + var after; + var begin; + var end; + + begin = '// BEGIN: '+id; + end = '// END: '+id; + + before = substringBefore( text, begin ); + after = substringAfter( text, end ); + + return format( '%s// BEGIN: %s\n\n%s\n%s%s', before, id, str, end, after ); +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var fpath; + var copts; + var opts; + var file; + var str; + + opts = { + 'dtype': 'float32', + 'encoding': 'utf8' + }; + + fpath = resolve( __dirname, '..', 'lib', 'polyval_s.js' ); + str = header + compile( S ); + writeFileSync( fpath, str, opts ); + + fpath = resolve( __dirname, '..', 'lib', 'polyval_p.js' ); + str = header + compile( P ); + writeFileSync( fpath, str, opts ); + + copts = { + 'dtype': 'float', + 'name': '' + }; + + fpath = resolve( __dirname, '..', 'src', 'main.c' ); + file = readFileSync( fpath, opts ); + + copts.name = 'poly_s'; + str = compileC( S, copts ); + file = insert( file, copts.name, str ); + + copts.name = 'poly_p'; + str = compileC( P, copts ); + file = insert( file, copts.name, str ); + + writeFileSync( fpath, file, opts ); +} + +main(); diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/gammaf/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/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/gammaf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/gammaf/src/addon.c new file mode 100644 index 000000000000..96b2119f8772 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/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/gammaf.h" +#include "stdlib/math/base/napi/unary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_F_F( stdlib_base_gammaf ) diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/src/main.c b/lib/node_modules/@stdlib/math/base/special/gammaf/src/main.c new file mode 100644 index 000000000000..d6a93580a345 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/src/main.c @@ -0,0 +1,262 @@ +/** +* @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 original C code, long comment, copyright, license, and constants are from [Cephes]{@link http://www.netlib.org/cephes}. The implementation follows the original, but has been modified for c. +* +* ```text +* Copyright 1984, 1987, 1989, 1992, 2000 by Stephen L. Moshier +* +* Some software in this archive may be from the book _Methods and Programs for Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989) or from the Cephes Mathematical Library, a commercial product. In either event, it is copyrighted by the author. What you see here may be used freely but it comes with no support or guarantee. +* +* Stephen L. Moshier +* moshier@na-net.ornl.gov +* ``` +*/ + +#include "stdlib/constants/float32/eulergamma.h" +#include "stdlib/constants/float32/ninf.h" +#include "stdlib/constants/float32/pi.h" +#include "stdlib/constants/float32/pinf.h" +#include "stdlib/constants/float32/sqrt_two_pi.h" +#include "stdlib/math/base/assert/is_integerf.h" +#include "stdlib/math/base/assert/is_nanf.h" +#include "stdlib/math/base/assert/is_negative_zerof.h" +#include "stdlib/math/base/special/exp.h" +#include "stdlib/math/base/special/floorf.h" +#include "stdlib/math/base/special/gammaf.h" +#include "stdlib/math/base/special/powf.h" +#include "stdlib/math/base/special/sinf.h" +#include +#include + +static const float MAX_STIRLING = 26.77f; + +/* Begin auto-generated functions. The following functions are auto-generated. Do not edit directly. */ + +// BEGIN: poly_s + +/** +* 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 +* +* @param x value at which to evaluate the polynomial +* @return evaluated polynomial +*/ +static float poly_s( const float x ) { + return 0.08333331788340907f + (x * (0.00347325578615491f + (x * -0.002705194986674176f))); +} + +// END: poly_s + +// BEGIN: poly_p + +/** +* 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 +* +* @param x value at which to evaluate the polynomial +* @return evaluated polynomial +*/ +static float poly_p( const float x ) { + return 0.9999999822945073f + (x * (0.4227867745131584f + (x * (0.4117857447645796f + (x * (0.08203960091619193f + (x * (0.07232307985516519f + (x * (0.004130370201859976f + (x * (0.005397581592950993f + (x * 0.001536830450601906f))))))))))))); +} + +// END: poly_p + +/* End auto-generated functions. */ + +/** +* Evaluates the gamma function using Stirling's formula. The polynomial is valid for \\(33 \leq x \leq 172\\). +* +* @param x input value +* @return function value +*/ +static float stirlingApprox( const float x ) { + float w; + float y; + float v; + + w = 1.0f / x; + w = 1.0f + ( w * poly_s( w ) ); + y = (float)stdlib_base_exp( -x ); + + // Check `x` to avoid `pow()` overflow... + if ( x > MAX_STIRLING ) { + v = stdlib_base_powf( x, ( 0.5f * x ) - 0.25f ); + y *= v; + y *= v; + } else { + y = stdlib_base_powf( x, x - 0.5f ) * y; + } + return STDLIB_CONSTANT_FLOAT32_SQRT_TWO_PI * y * w; +} + +/** +* Evaluates the gamma function using a small-value approximation. +* +* @param x input value +* @param z scale factor +* @return function value +*/ +static float smallApprox( const float x, const float z ) { + return z / ( ( 1.0f + ( STDLIB_CONSTANT_FLOAT32_EULERGAMMA * x ) ) * x ); +} + +/** +* Evaluates the gamma function of a single-precision floating-point number. +* +* ## Method +* +* 1. Arguments between 0 and 10 are reduced by recurrence and the function is approximated by a polynomial function covering the interval (2,3) +* 2. Large arguments are handled by Stirling's formula. +* 3. Negative arguments are made positive using a reflection formula. +* +* ## Notes +* +* - Relative error: +* +* | arithmetic | domain | # trials | peak | rms | +* |:----------:|:---------:|:--------:|:-------:|:-------:| +* | IEEE | 0,-33 | 100,000 | 5.7e-7 | 1.0e-7 | +* | IEEE | -33,0 | 100,000 | 6.1e-7 | 1.2e-7 | +* +* @param x input value +* @return function value +* +* @example +* float v = stdlib_base_gammaf( 4.0f ); +* // returns 6.0 +*/ +float stdlib_base_gammaf( const float x ) { + bool direction; + bool negative; + bool small; + float sign; + float nz; + int32_t i; + float q; + float p; + float z; + float xc; + + negative = 0; + xc = x; + + if ( ( stdlib_base_is_integerf( x ) && x < 0 ) || stdlib_base_is_nanf( x ) || x == STDLIB_CONSTANT_FLOAT32_NINF ) { + return 0.0f / 0.0f; //NaN + } + + if ( x == 0.0f ) { + if ( stdlib_base_is_negative_zerof( x ) ) { + return STDLIB_CONSTANT_FLOAT32_NINF; + } + return STDLIB_CONSTANT_FLOAT32_PINF; + } + + if ( x > 35.040096282958984f ) { + return STDLIB_CONSTANT_FLOAT32_PINF; + } + + if ( x < -40.00199890136719f ) { + return 0.0f; + } + + if ( xc < 0.0f ) { + negative = 1; + q = -xc; + p = stdlib_base_floorf( q ); + if ( p == q ) { + return 0.0f / 0.0f; + } + i = (int32_t)p; + if ( ( i & 1 ) == 0 ) { + sign = -1.0f; + } else { + sign = 1.0f; + } + nz = q - p; + if ( nz > 0.5f ) { + p += 1.0f; + nz = q - p; + } + nz = q * stdlib_base_sinf( STDLIB_CONSTANT_FLOAT32_PI * nz ); + if ( nz == 0.0f ) { + return 0.0f / 0.0f; + } + if ( nz < 0.0f ) { + nz = -nz; + } + xc = q; + } + // if ( xc >= 10.0f ) { + // z = stirlingApprox( xc ); + // } + if ( xc < 2.0f ) { + direction = 1; + } else { + direction = 0; + } + z = 1.0f; + while ( xc >= 3.0f ) { + xc -= 1.0f; + z *= xc; + } + small = 0; + while ( xc < 2.0f ) { + if ( xc < 1.0e-4f ) { + small = 1; + break; + } + z *= xc; + xc += 1.0f; + } + + if ( small ) { + if ( xc == 0.0f ) { + return STDLIB_CONSTANT_FLOAT32_PINF; + } + p = smallApprox( xc, z ); + } else { + if ( direction ) { + z = 1.0f / z; + } + if ( xc == 2.0f ) { + p = z; + } else { + xc -= 2.0f; + p = z * poly_p( xc ); + } + } + + if ( negative ) { + p = sign * STDLIB_CONSTANT_FLOAT32_PI / ( nz * p ); + } + return p; +} diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/DESCRIPTION b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/DESCRIPTION new file mode 100644 index 000000000000..9fbf18257b72 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/DESCRIPTION @@ -0,0 +1,9 @@ +Package: gammaf-test-fixtures +Title: Test Fixtures +Version: 0.0.0 +Authors@R: person("stdlib", "js", role = c("aut","cre")) +Description: Generates test fixtures. +Depends: R (>=3.4.0) +Imports: + jsonlite +LazyData: true diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/data1.json b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/data1.json new file mode 100644 index 000000000000..e6d2a724d885 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/data1.json @@ -0,0 +1 @@ +[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35] diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/data2.json b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/data2.json new file mode 100644 index 000000000000..05f4be593bc4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/data2.json @@ -0,0 +1 @@ +[-40.000100000000003,-39.925024824824831,-39.849949649649652,-39.77487447447448,-39.699799299299301,-39.624724124124128,-39.549648948948949,-39.474573773773777,-39.399498598598605,-39.324423423423426,-39.249348248248253,-39.174273073073074,-39.099197897897902,-39.024122722722723,-38.949047547547551,-38.873972372372378,-38.798897197197199,-38.723822022022027,-38.648746846846848,-38.573671671671676,-38.498596496496504,-38.423521321321324,-38.348446146146152,-38.273370970970973,-38.198295795795801,-38.123220620620621,-38.048145445445449,-37.97307027027027,-37.897995095095098,-37.822919919919926,-37.747844744744746,-37.672769569569574,-37.597694394394395,-37.522619219219223,-37.447544044044051,-37.372468868868872,-37.297393693693699,-37.22231851851852,-37.147243343343348,-37.072168168168169,-36.997092992992997,-36.922017817817824,-36.846942642642645,-36.771867467467473,-36.696792292292294,-36.621717117117122,-36.546641941941942,-36.47156676676677,-36.396491591591598,-36.321416416416419,-36.246341241241247,-36.171266066066067,-36.096190890890895,-36.021115715715716,-35.946040540540544,-35.870965365365372,-35.795890190190192,-35.72081501501502,-35.645739839839841,-35.570664664664669,-35.49558948948949,-35.420514314314318,-35.345439139139145,-35.270363963963966,-35.195288788788794,-35.120213613613615,-35.045138438438443,-34.97006326326327,-34.894988088088091,-34.819912912912919,-34.74483773773774,-34.669762562562568,-34.594687387387388,-34.519612212212216,-34.444537037037037,-34.369461861861865,-34.294386686686693,-34.219311511511513,-34.144236336336341,-34.069161161161162,-33.99408598598599,-33.919010810810818,-33.843935635635638,-33.768860460460466,-33.693785285285287,-33.618710110110115,-33.543634934934936,-33.468559759759763,-33.393484584584584,-33.318409409409412,-33.24333423423424,-33.168259059059061,-33.093183883883889,-33.018108708708709,-32.943033533533537,-32.867958358358365,-32.792883183183186,-32.717808008008014,-32.642732832832834,-32.567657657657662,-32.492582482482483,-32.417507307307311,-32.342432132132139,-32.267356956956959,-32.192281781781787,-32.117206606606608,-32.042131431431436,-31.96705625625626,-31.891981081081084,-31.816905905905909,-31.741830730730733,-31.666755555555561,-31.591680380380382,-31.516605205205209,-31.441530030030034,-31.366454854854858,-31.291379679679682,-31.216304504504507,-31.141229329329335,-31.066154154154155,-30.991078978978983,-30.916003803803807,-30.840928628628632,-30.76585345345346,-30.69077827827828,-30.615703103103108,-30.540627927927929,-30.465552752752757,-30.390477577577581,-30.315402402402405,-30.240327227227233,-30.165252052052054,-30.090176876876882,-30.015101701701703,-29.94002652652653,-29.864951351351355,-29.789876176176179,-29.714801001001007,-29.639725825825828,-29.564650650650655,-29.48957547547548,-29.414500300300304,-29.339425125125128,-29.264349949949953,-29.18927477477478,-29.114199599599601,-29.039124424424429,-28.964049249249253,-28.888974074074078,-28.813898898898902,-28.738823723723726,-28.663748548548554,-28.588673373373375,-28.513598198198203,-28.438523023023027,-28.363447847847851,-28.288372672672676,-28.2132974974975,-28.138222322322328,-28.063147147147149,-27.988071971971976,-27.912996796796801,-27.837921621621625,-27.762846446446449,-27.687771271271274,-27.612696096096101,-27.537620920920922,-27.46254574574575,-27.387470570570574,-27.312395395395399,-27.237320220220223,-27.162245045045047,-27.087169869869875,-27.012094694694696,-26.937019519519524,-26.861944344344348,-26.786869169169172,-26.711793993994,-26.636718818818821,-26.561643643643649,-26.486568468468469,-26.411493293293297,-26.336418118118122,-26.261342942942946,-26.186267767767774,-26.111192592592595,-26.036117417417422,-25.961042242242247,-25.885967067067071,-25.810891891891895,-25.73581671671672,-25.660741541541547,-25.585666366366368,-25.510591191191196,-25.43551601601602,-25.360440840840845,-25.285365665665669,-25.210290490490493,-25.135215315315321,-25.060140140140142,-24.98506496496497,-24.909989789789794,-24.834914614614618,-24.759839439439443,-24.684764264264267,-24.609689089089095,-24.534613913913915,-24.459538738738743,-24.384463563563568,-24.309388388388392,-24.234313213213216,-24.15923803803804,-24.084162862862868,-24.009087687687689,-23.934012512512517,-23.858937337337341,-23.783862162162166,-23.70878698698699,-23.633711811811814,-23.558636636636642,-23.483561461461466,-23.408486286286291,-23.333411111111115,-23.258335935935939,-23.183260760760763,-23.108185585585588,-23.033110410410416,-22.95803523523524,-22.882960060060064,-22.807884884884889,-22.732809709709713,-22.657734534534537,-22.582659359359361,-22.507584184184189,-22.432509009009014,-22.357433833833838,-22.282358658658662,-22.207283483483486,-22.132208308308311,-22.057133133133135,-21.982057957957963,-21.906982782782787,-21.831907607607612,-21.756832432432436,-21.68175725725726,-21.606682082082084,-21.531606906906912,-21.456531731731737,-21.381456556556561,-21.306381381381385,-21.231306206206209,-21.156231031031034,-21.081155855855858,-21.006080680680686,-20.93100550550551,-20.855930330330334,-20.780855155155159,-20.705779979979983,-20.630704804804807,-20.555629629629632,-20.48055445445446,-20.405479279279284,-20.330404104104108,-20.255328928928932,-20.180253753753757,-20.105178578578581,-20.030103403403405,-19.955028228228233,-19.879953053053057,-19.804877877877882,-19.729802702702706,-19.65472752752753,-19.579652352352355,-19.504577177177183,-19.429502002002007,-19.354426826826831,-19.279351651651655,-19.20427647647648,-19.129201301301304,-19.054126126126128,-18.979050950950956,-18.90397577577578,-18.828900600600605,-18.753825425425429,-18.678750250250253,-18.603675075075078,-18.528599899899902,-18.45352472472473,-18.378449549549554,-18.303374374374378,-18.228299199199203,-18.153224024024027,-18.078148848848851,-18.003073673673676,-17.927998498498503,-17.852923323323328,-17.777848148148152,-17.702772972972976,-17.627697797797801,-17.552622622622625,-17.477547447447453,-17.402472272272277,-17.327397097097101,-17.252321921921926,-17.17724674674675,-17.102171571571574,-17.027096396396399,-16.952021221221226,-16.876946046046051,-16.801870870870875,-16.726795695695699,-16.651720520520524,-16.576645345345348,-16.501570170170172,-16.426494994995,-16.351419819819824,-16.276344644644649,-16.201269469469473,-16.126194294294297,-16.051119119119122,-15.976043943943949,-15.900968768768774,-15.825893593593598,-15.750818418418422,-15.675743243243247,-15.600668068068071,-15.525592892892895,-15.450517717717723,-15.375442542542547,-15.300367367367372,-15.225292192192196,-15.15021701701702,-15.075141841841845,-15.000066666666669,-14.924991491491497,-14.849916316316321,-14.774841141141145,-14.69976596596597,-14.624690790790794,-14.549615615615618,-14.474540440440443,-14.39946526526527,-14.324390090090095,-14.249314914914919,-14.174239739739743,-14.099164564564568,-14.024089389389392,-13.94901421421422,-13.873939039039044,-13.798863863863868,-13.723788688688693,-13.648713513513517,-13.573638338338341,-13.498563163163166,-13.423487987987993,-13.348412812812818,-13.273337637637642,-13.198262462462466,-13.123187287287291,-13.048112112112115,-12.973036936936939,-12.897961761761767,-12.822886586586591,-12.747811411411416,-12.67273623623624,-12.597661061061064,-12.522585885885889,-12.447510710710713,-12.372435535535541,-12.297360360360365,-12.222285185185189,-12.147210010010014,-12.072134834834838,-11.997059659659662,-11.92198448448449,-11.846909309309314,-11.771834134134139,-11.696758958958963,-11.621683783783787,-11.546608608608611,-11.471533433433436,-11.396458258258264,-11.321383083083088,-11.246307907907912,-11.171232732732737,-11.096157557557561,-11.021082382382385,-10.946007207207209,-10.870932032032037,-10.795856856856862,-10.720781681681686,-10.64570650650651,-10.570631331331334,-10.495556156156159,-10.420480980980983,-10.345405805805811,-10.270330630630635,-10.19525545545546,-10.120180280280284,-10.045105105105108,-9.9700299299299324,-9.8949547547547603,-9.8198795795795846,-9.7448044044044089,-9.6697292292292332,-9.5946540540540575,-9.5195788788788818,-9.4445037037037061,-9.3694285285285339,-9.2943533533533582,-9.2192781781781825,-9.1442030030030068,-9.0691278278278311,-8.9940526526526554,-8.9189774774774797,-8.8439023023023076,-8.7688271271271319,-8.6937519519519562,-8.6186767767767805,-8.5436016016016048,-8.4685264264264291,-8.3934512512512534,-8.3183760760760812,-8.2433009009009055,-8.1682257257257298,-8.0931505505505541,-8.0180753753753784,-7.9430002002002027,-7.8679250250250305,-7.7928498498498513,-7.7177746746746791,-7.6426994994994999,-7.5676243243243277,-7.4925491491491556,-7.4174739739739763,-7.3423987987988042,-7.2673236236236249,-7.1922484484484528,-7.1171732732732806,-7.0420980980981014,-6.9670229229229292,-6.89194774774775,-6.8168725725725778,-6.7417973973973986,-6.6667222222222264,-6.5916470470470543,-6.516571871871875,-6.4414966966967029,-6.3664215215215236,-6.2913463463463515,-6.2162711711711722,-6.1411959959960001,-6.0661208208208279,-5.9910456456456487,-5.9159704704704765,-5.8408952952952973,-5.7658201201201251,-5.6907449449449459,-5.6156697697697737,-5.5405945945946016,-5.4655194194194223,-5.3904442442442502,-5.3153690690690709,-5.2402938938938988,-5.1652187187187195,-5.0901435435435474,-5.0150683683683752,-4.939993193193196,-4.8649180180180238,-4.7898428428428446,-4.7147676676676724,-4.6396924924924932,-4.564617317317321,-4.4895421421421489,-4.4144669669669696,-4.3393917917917975,-4.2643166166166182,-4.1892414414414461,-4.1141662662662668,-4.0390910910910947,-3.9640159159159225,-3.8889407407407433,-3.8138655655655711,-3.7387903903903918,-3.6637152152152197,-3.5886400400400404,-3.5135648648648683,-3.4384896896896961,-3.3634145145145169,-3.2883393393393447,-3.2132641641641655,-3.1381889889889933,-3.0631138138138212,-2.9880386386386419,-2.9129634634634698,-2.8378882882882905,-2.7628131131131184,-2.6877379379379391,-2.612662762762767,-2.5375875875875948,-2.4625124124124156,-2.3874372372372434,-2.3123620620620642,-2.237286886886892,-2.1622117117117128,-2.0871365365365406,-2.0120613613613685,-1.9369861861861892,-1.8619110110110171,-1.7868358358358378,-1.7117606606606657,-1.6366854854854864,-1.5616103103103143,-1.4865351351351421,-1.4114599599599629,-1.3363847847847907,-1.2613096096096115,-1.1862344344344393,-1.1111592592592601,-1.0360840840840879,-0.96100890890891577,-0.88593373373373652,-0.81085855855856437,-0.73578338338338511,-0.66070820820821297,-0.58563303303303371,-0.51055785785786156,-0.43548268268268941,-0.36040750750751016,-0.28533233233233801,-0.21025715715715876,-0.13518198198198661,-0.060106806806807356,0.014968368368364793,0.090043543543536941,0.1651187187187162,0.24019389389388834,0.3152690690690676,0.39034424424423975,0.46541941941941189,0.54049459459459115,0.6155697697697633,0.69064494494494255,0.7657201201201147,0.84079529529529395,0.9158704704704661,0.99094564564563825,1.0660208208208175,1.1410959959959897,1.2161711711711689,1.2912463463463411,1.3663215215215203,1.4413966966966925,1.5164718718718646,1.5915470470470439,1.666622222222216,1.7416973973973953,1.8167725725725674,1.8918477477477467,1.9669229229229188,2.041998098098091,2.1170732732732702,2.1921484484484424,2.2672236236236216,2.3422987987987938,2.417373973973973,2.4924491491491452,2.5675243243243173,2.6425994994994966,2.7176746746746687,2.792749849849848,2.8678250250250201,2.9429002002001994,3.0179753753753715,3.0930505505505437,3.1681257257257229,3.2432009009008951,3.3182760760760743,3.3933512512512465,3.4684264264264257,3.5435016016015979,3.61857677677677,3.6936519519519493,3.7687271271271214,3.8438023023023007,3.9188774774774728,3.9939526526526521,4.0690278278278242,4.1441030030029964,4.2191781781781756,4.2942533533533478,4.369328528528527,4.4444037037036992,4.5194788788788713,4.5945540540540506,4.6696292292292227,4.744704404404402,4.8197795795795741,4.8948547547547534,4.9699299299299255,5.0450051051050977,5.120080280280277,5.1951554554554491,5.2702306306306284,5.3453058058058005,5.4203809809809798,5.4954561561561519,5.5705313313313241,5.6456065065065033,5.7206816816816755,5.7957568568568547,5.8708320320320269,5.9459072072072061,6.0209823823823783,6.0960575575575504,6.1711327327327297,6.2462079079079018,6.3212830830830811,6.3963582582582532,6.4714334334334325,6.5465086086086046,6.6215837837837768,6.696658958958956,6.7717341341341282,6.8468093093093074,6.9218844844844796,6.9969596596596588,7.072034834834831,7.1471100100100031,7.2221851851851824,7.2972603603603545,7.3723355355355338,7.4474107107107059,7.5224858858858852,7.5975610610610573,7.6726362362362295,7.7477114114114087,7.8227865865865809,7.8978617617617601,7.9729369369369323,8.0480121121121044,8.1230872872872837,8.1981624624624558,8.2732376376376351,8.3483128128128072,8.4233879879879865,8.4984631631631586,8.5735383383383308,8.64861351351351,8.7236886886886822,8.7987638638638614,8.8738390390390336,8.9489142142142128,9.023989389389385,9.0990645645645571,9.1741397397397364,9.2492149149149085,9.3242900900900878,9.3993652652652599,9.4744404404404392,9.5495156156156114,9.6245907907907835,9.6996659659659628,9.7747411411411349,9.8498163163163142,9.9248914914914863,9.9999666666666656,10.075041841841838,10.15011701701701,10.225192192192189,10.300267367367361,10.375342542542541,10.450417717717713,10.525492892892892,10.600568068068064,10.675643243243236,10.750718418418415,10.825793593593588,10.900868768768767,10.975943943943939,11.051019119119118,11.12609429429429,11.201169469469463,11.276244644644642,11.351319819819814,11.426394994994993,11.501470170170165,11.576545345345345,11.651620520520517,11.726695695695689,11.801770870870868,11.87684604604604,11.95192122122122,12.026996396396392,12.102071571571564,12.177146746746743,12.252221921921915,12.327297097097095,12.402372272272267,12.477447447447446,12.552522622622618,12.62759779779779,12.702672972972969,12.777748148148142,12.852823323323321,12.927898498498493,13.002973673673672,13.078048848848844,13.153124024024017,13.228199199199196,13.303274374374368,13.378349549549547,13.453424724724719,13.528499899899899,13.603575075075071,13.678650250250243,13.753725425425422,13.828800600600594,13.903875775775774,13.978950950950946,14.054026126126125,14.129101301301297,14.204176476476469,14.279251651651649,14.354326826826821,14.429402002002,14.504477177177172,14.579552352352351,14.654627527527524,14.729702702702696,14.804777877877875,14.879853053053047,14.954928228228226,15.030003403403398,15.105078578578578,15.18015375375375,15.255228928928922,15.330304104104101,15.405379279279273,15.480454454454453,15.555529629629625,15.630604804804804,15.705679979979976,15.780755155155148,15.855830330330328,15.9309055055055,16.005980680680679,16.081055855855851,16.156131031031023,16.231206206206203,16.306281381381375,16.381356556556554,16.456431731731726,16.531506906906905,16.606582082082078,16.68165725725725,16.756732432432429,16.831807607607601,16.90688278278278,16.981957957957952,17.057033133133132,17.132108308308304,17.207183483483476,17.282258658658655,17.357333833833827,17.432409009009007,17.507484184184179,17.582559359359358,17.65763453453453,17.732709709709702,17.807784884884882,17.882860060060054,17.957935235235233,18.033010410410405,18.108085585585584,18.183160760760757,18.258235935935929,18.333311111111108,18.40838628628628,18.483461461461459,18.558536636636632,18.633611811811811,18.708686986986983,18.783762162162155,18.858837337337334,18.933912512512507,19.008987687687686,19.084062862862858,19.159138038038037,19.234213213213209,19.309288388388381,19.384363563563561,19.459438738738733,19.534513913913912,19.609589089089084,19.684664264264256,19.759739439439436,19.834814614614608,19.909889789789787,19.984964964964959,20.060040140140138,20.135115315315311,20.210190490490483,20.285265665665662,20.360340840840834,20.435416016016013,20.510491191191186,20.585566366366365,20.660641541541537,20.735716716716709,20.810791891891888,20.885867067067061,20.96094224224224,21.036017417417412,21.111092592592591,21.186167767767763,21.261242942942935,21.336318118118115,21.411393293293287,21.486468468468466,21.561543643643638,21.636618818818818,21.71169399399399,21.786769169169162,21.861844344344341,21.936919519519513,22.011994694694692,22.087069869869865,22.162145045045044,22.237220220220216,22.312295395395388,22.387370570570567,22.46244574574574,22.537520920920919,22.612596096096091,22.68767127127127,22.762746446446442,22.837821621621615,22.912896796796794,22.987971971971966,23.063047147147145,23.138122322322317,23.213197497497497,23.288272672672669,23.363347847847841,23.43842302302302,23.513498198198192,23.588573373373372,23.663648548548544,23.738723723723716,23.813798898898895,23.888874074074067,23.963949249249247,24.039024424424426,24.114099599599598,24.18917477477477,24.264249949949942,24.339325125125114,24.414400300300301,24.489475475475473,24.564550650650645,24.639625825825817,24.714701001001004,24.789776176176176,24.864851351351348,24.93992652652652,25.015001701701692,25.090076876876878,25.165152052052051,25.240227227227223,25.315302402402395,25.390377577577567,25.465452752752753,25.540527927927926,25.615603103103098,25.69067827827827,25.765753453453442,25.840828628628628,25.915903803803801,25.990978978978973,26.066054154154145,26.141129329329331,26.216204504504503,26.291279679679675,26.366354854854848,26.44143003003002,26.516505205205206,26.591580380380378,26.66665555555555,26.741730730730723,26.816805905905895,26.891881081081081,26.966956256256253,27.042031431431425,27.117106606606598,27.192181781781784,27.267256956956956,27.342332132132128,27.4174073073073,27.492482482482473,27.567557657657659,27.642632832832831,27.717708008008003,27.792783183183175,27.867858358358347,27.942933533533534,28.018008708708706,28.093083883883878,28.16815905905905,28.243234234234237,28.318309409409409,28.393384584584581,28.468459759759753,28.543534934934925,28.618610110110112,28.693685285285284,28.768760460460456,28.843835635635628,28.9189108108108,28.993985985985987,29.069061161161159,29.144136336336331,29.219211511511503,29.294286686686675,29.369361861861861,29.444437037037034,29.519512212212206,29.594587387387378,29.669662562562564,29.744737737737736,29.819812912912909,29.894888088088081,29.969963263263253,30.045038438438439,30.120113613613611,30.195188788788784,30.270263963963956,30.345339139139128,30.420414314314314,30.495489489489486,30.570564664664658,30.645639839839831,30.720715015015017,30.795790190190189,30.870865365365361,30.945940540540533,31.021015715715706,31.096090890890892,31.171166066066064,31.246241241241236,31.321316416416408,31.396391591591581,31.471466766766767,31.546541941941939,31.621617117117111,31.696692292292283,31.77176746746747,31.846842642642642,31.921917817817814,31.996992992992986,32.072068168168158,32.147143343343345,32.222218518518517,32.297293693693689,32.372368868868861,32.447444044044033,32.52251921921922,32.597594394394392,32.672669569569564,32.747744744744736,32.822819919919922,32.897895095095095,32.972970270270267,33.048045445445439,33.123120620620611,33.198195795795797,33.27327097097097,33.348346146146142,33.423421321321314,33.498496496496486,33.573571671671672,33.648646846846844,33.723722022022017,33.798797197197189,33.873872372372361,33.948947547547547,34.024022722722719,34.099097897897892,34.174173073073064,34.24924824824825,34.324323423423422,34.399398598598594,34.474473773773767,34.549548948948939,34.624624124124125,34.699699299299297,34.774774474474469,34.849849649649641,34.924924824824814,35] diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/expected1.json b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/expected1.json new file mode 100644 index 000000000000..b9d11e26afa0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/expected1.json @@ -0,0 +1 @@ +[1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368000,20922789888000,355687428096000,6402373705728000,1.21645100408832e+17,2.43290200817664e+18,5.109094217170944e+19,1.1240007277776077e+21,2.5852016738884978e+22,6.2044840173323941e+23,1.5511210043330986e+25,4.0329146112660565e+26,1.0888869450418352e+28,3.0488834461171384e+29,8.8417619937397008e+30,2.6525285981219103e+32,8.2228386541779224e+33,2.6313083693369352e+35,8.6833176188118859e+36,2.9523279903960412e+38] diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/expected2.json b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/expected2.json new file mode 100644 index 000000000000..f3447a0488d2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/expected2.json @@ -0,0 +1 @@ +[-1.2251639018952047e-44,2.1774618177331901e-47,1.4770773003584878e-47,1.3626030487267966e-47,1.4435319767029023e-47,1.6680903659365798e-47,2.0589314444332792e-47,2.6915971786033686e-47,3.7227512505593992e-47,5.479334408733365e-47,8.7200345944426247e-47,1.5584386659488514e-46,3.4876331309209338e-46,1.861601139726466e-45,-1.1653138893468973e-45,-6.3457800301581344e-46,-5.4593691745239667e-46,-5.5677486585394202e-46,-6.2654254256697626e-46,-7.5679619993917366e-46,-9.6989857862785698e-46,-1.3146122356076716e-45,-1.8910395903288858e-45,-2.9217918971415424e-45,-4.9890188901331268e-45,-1.0144930811094336e-44,-3.3437604140568323e-44,7.8425628110605681e-44,2.7668432298834208e-44,2.170327954521085e-44,2.1166526487268874e-44,2.3132509799183601e-44,2.73112885515148e-44,3.4301294333208218e-44,4.5575118166621851e-44,6.4144752790435899e-44,9.6480534612116767e-44,1.5847625172079383e-43,2.9987128149466763e-43,7.8166113235003936e-43,-2.5257990390890778e-41,-1.248340226697473e-42,-8.5912949172083765e-43,-7.9378451036695485e-43,-8.3953286682130329e-43,-9.6732390147856246e-43,-1.1898790911674575e-42,-1.5498891767874037e-42,-2.1360910428701801e-42,-3.1341477099922679e-42,-4.976898321954149e-42,-8.8963046482435681e-42,-2.0073656445904956e-41,-1.1808255625194295e-40,6.0780344970180779e-41,3.4057389054960393e-41,2.9404617969157374e-41,2.9954671980405005e-41,3.3615140946272994e-41,4.0463005290695839e-41,5.1662999415282346e-41,6.976284088765756e-41,1.0000492731538969e-40,1.540914823320465e-40,2.6284968639903824e-40,5.367085018431325e-40,1.8310042476563435e-39,-3.6025253499395844e-39,-1.3650919050908082e-39,-1.0781659638145519e-39,-1.0511536849261193e-39,-1.1458607887741975e-39,-1.348176238955445e-39,-1.6867155300517865e-39,-2.2322809035147977e-39,-3.1300406480120462e-39,-4.6928234390220578e-39,-7.6935719889811762e-39,-1.4580875848728631e-38,-3.8637331212443817e-38,5.8488783208739008e-37,5.6313299074437302e-38,3.92573055254954e-38,3.6302713221798723e-38,3.830963412970411e-38,4.3990239956694977e-38,5.3898409909261574e-38,6.9917762814929544e-38,9.5975342265579618e-38,1.4031014642591992e-37,2.2222073264567016e-37,3.9715880213453278e-37,9.0370601777491152e-37,5.9709318105251523e-36,-2.4824019704788903e-36,-1.4268862012938158e-36,-1.2353097537183613e-36,-1.2562313326197246e-36,-1.405065935293832e-36,-1.6845388445350447e-36,-2.1416447790349537e-36,-2.8796488305191633e-36,-4.1115939248830801e-36,-6.3148805248325228e-36,-1.0756576341290793e-35,-2.2051508286905463e-35,-7.8123280156625229e-35,1.296078492578116e-34,5.223143903683946e-35,4.1492353284443015e-35,4.0411802105105895e-35,4.3914252771772365e-35,5.1459642722619867e-35,6.4098110493714021e-35,8.4450431838120948e-35,1.1790569442259063e-34,1.7611493542407121e-34,2.880382527370837e-34,5.4657745173778382e-34,1.4736733280054181e-33,-1.4060041355930033e-32,-1.9569325437539529e-33,-1.379692251168309e-33,-1.2759621096203412e-33,-1.3426362605819336e-33,-1.5355181363736388e-33,-1.8728543739419161e-33,-2.418097338826847e-33,-3.3040523979003962e-33,-4.8101634478789262e-33,-7.5941484458993337e-33,-1.3564354976371864e-32,-3.1128667940002895e-32,-2.3716991784763063e-31,7.7615318927011419e-32,4.5633430241311006e-32,3.9577947792959308e-32,4.0149833897379129e-32,4.472832307419157e-32,5.3376680997710026e-32,6.7529036223601102e-32,9.035685141423901e-32,1.2842238737385433e-31,1.9648929571889595e-31,3.340431561691449e-31,6.8738851840805685e-31,2.5385707944589434e-30,-3.5604866102426847e-30,-1.5134868163223809e-30,-1.2078864406806854e-30,-1.1743166420632935e-30,-1.271181060873503e-30,-1.4825849609805659e-30,-1.8373448529080247e-30,-2.4082938864134041e-30,-3.345726591346837e-30,-4.9756836421110758e-30,-8.1135430433411176e-30,-1.5409055628540382e-29,-4.2311340182380634e-29,2.8624953157191153e-28,5.1081709652391169e-29,3.6363651223740094e-29,3.3602832581098337e-29,3.5230279961343363e-29,4.0099978850403415e-29,4.8653254090833424e-29,6.2478761738789074e-29,8.4918499980921042e-29,1.2302690520735903e-28,1.9348996248766943e-28,3.4520776513561396e-28,7.9903225073811361e-28,7.2965417533326379e-27,-1.8082922326598287e-27,-1.084490473946819e-27,-9.4130996893557705e-28,-9.5178221698131786e-28,-1.0552796537162518e-27,-1.252530228605855e-27,-1.5756890418875766e-27,-2.0964913739263935e-27,-2.9638730139845697e-27,-4.5142839056759068e-27,-7.6546503843778572e-27,-1.5805761351478751e-26,-6.1119669833676655e-26,7.2494794155919716e-26,3.2275532282696724e-26,2.5845479507013989e-26,2.5058962064389995e-26,2.699866851860563e-26,3.1314672237601697e-26,3.8579653401980262e-26,5.0267664834744786e-26,6.9433735906229128e-26,1.0272916910063691e-25,1.6689207956468827e-25,3.1704741924714314e-25,8.8747231778517428e-25,-4.5322376838436207e-24,-9.7140940966029029e-25,-6.9704987788065284e-25,-6.4295001778056664e-25,-6.7102357113810829e-25,-7.5947269777137757e-25,-9.1583827803590637e-25,-1.1687267085820008e-24,-1.5787204255724291e-24,-2.27414814373406e-24,-3.5600906510829343e-24,-6.3398425049322404e-24,-1.4800095378806129e-23,-1.7229577310984195e-22,3.0379375080326457e-23,1.8534413949214619e-23,1.6080797189252911e-23,1.6190142711592692e-23,1.7848245846306449e-23,2.105031131302733e-23,2.6307388027043075e-23,3.4773480123596815e-23,4.8854118099298115e-23,7.4006688311322104e-23,1.2506067423460249e-22,2.5899332489800026e-22,1.054184539925168e-21,-1.0553614015210316e-21,-4.8904478840289283e-22,-3.9237898257288595e-22,-3.7898539135580394e-22,-4.0598234455650031e-22,-4.6780358556194401e-22,-5.7236670333685224e-22,-7.4059246640554408e-22,-1.0160794246955485e-21,-1.4941158934144336e-21,-2.4160361568604909e-21,-4.5876599041742142e-21,-1.3103636408072839e-20,5.246262105611082e-20,1.2958798604598757e-20,9.3559018248425953e-21,8.603324242957089e-21,8.9280106448294122e-21,1.0036808440168046e-20,1.2016158853476214e-20,1.5221584737575128e-20,2.0412808884299854e-20,2.9205517879514866e-20,4.5460880125926925e-20,8.0732348131772324e-20,1.9004078645917702e-19,3.159566941961332e-18,-3.5329145889979269e-19,-2.1866209225620204e-19,-1.8936982211500265e-19,-1.8960582690363766e-19,-2.0758178096540222e-19,-2.4298418468497195e-19,-3.0131413697444211e-19,-3.9520684655437289e-19,-5.5112943233729786e-19,-8.2939746047025559e-19,-1.3952638727306757e-18,-2.8959434338882932e-18,-1.2485565604822558e-17,1.0503972135654716e-17,5.0372443534459274e-18,4.0427098068232244e-18,3.884453219111983e-18,4.1318943835678011e-18,4.7238207276275139e-18,5.7324956562692731e-18,7.3563630440973045e-18,1.0011973080337325e-17,1.4613598678758398e-17,2.3492077167453041e-17,4.4541430898136371e-17,1.2993723133473804e-16,-4.1790323668503732e-16,-1.1558675918327745e-16,-8.3787868036436981e-17,-7.6693874474312362e-17,-7.9022346515810081e-17,-8.811325121219729e-17,-1.0458304733981629e-16,-1.3132355584785043e-16,-1.7459180945568266e-16,-2.4775688070737722e-16,-3.8294236620798555e-16,-6.7731651905793251e-16,-1.6069575820884679e-15,-5.0363143079070036e-14,2.6990345948187757e-15,1.6896805001900299e-15,1.4581111381371477e-15,1.4495606008954701e-15,1.5735820611758844e-15,1.8252844449431026e-15,2.2424418684594938e-15,2.9139841749163738e-15,4.0273596376762801e-15,6.0118025761055972e-15,1.005333048107563e-14,2.0890375962943298e-14,9.6128470429670284e-14,-6.7474819451507353e-14,-3.3303315767064568e-14,-2.6681039986969897e-14,-2.5458278901559802e-14,-2.6843242776130217e-14,-3.0396556670981499e-14,-3.6523453850766609e-14,-4.6404725618128286e-14,-6.2543632936417041e-14,-9.0461103060917919e-14,-1.4432816532058499e-13,-2.7284788524418682e-13,-8.1356267003011192e-13,2.1356756428237469e-12,6.4726677049067607e-13,4.6992020007996207e-13,4.2730194317025152e-13,4.3630885912333801e-13,4.8162918087851489e-13,5.6566631271521685e-13,7.0275553638874533e-13,9.244801134270473e-13,1.2987156109526793e-12,1.9894943154182164e-12,3.4985532313894392e-12,8.3585585173244504e-12,1.146864977328195e-08,-1.2636546107659593e-11,-7.9748710582720728e-12,-6.8417850546279863e-12,-6.7389289562152465e-12,-7.2383961138021407e-12,-8.3027050950497787e-12,-1.0084176158691687e-11,-1.2955233969508848e-11,-1.7707569808423761e-11,-2.6163764863853065e-11,-4.3403979434596748e-11,-9.0149027478716363e-11,-4.468822373905988e-10,2.5892851945594194e-10,1.3079735924754901e-10,1.0432759658894523e-10,9.8615967486044215e-11,1.0282801644316079e-10,1.1505866334263235e-10,1.3656319496744575e-10,1.7137993700724144e-10,2.2819515375833273e-10,3.2627843549385163e-10,5.1544375905415095e-10,9.6950734530017635e-10,2.9559390513320409e-09,-6.3964378231611072e-09,-2.0873726495373496e-09,-1.51294143577601e-09,-1.3629260182142999e-09,-1.3754343127743355e-09,-1.4990898831295536e-09,-1.7375606750759771e-09,-2.1299891230816963e-09,-2.7650772376179368e-09,-3.8349490534346487e-09,-5.8068102516979307e-09,-1.0126303394530192e-08,-2.4323031315572043e-08,7.1531459894742411e-07,3.2909249223527406e-08,2.0850861100750904e-08,1.7727847559957546e-08,1.7247664888155429e-08,1.827524301952602e-08,2.0665901261310617e-08,2.4738572440591447e-08,3.1324096073769046e-08,4.2211008944921212e-08,6.1542731421197576e-08,1.0097397013760165e-07,2.0907650186504071e-07,1.1294548185532997e-06,-5.3188213418734964e-07,-2.7327289612839546e-07,-2.1620775097390728e-07,-2.017528756595175e-07,-2.0731533241725239e-07,-2.284235738378271e-07,-2.6686667888848629e-07,-3.2962219371545816e-07,-4.3205279528037604e-07,-6.0850413109170691e-07,-9.4844408904457219e-07,-1.7689985094255247e-06,-5.5125864599488044e-06,9.8805816286505549e-06,3.4184700437044576e-06,2.4626113865474632e-06,2.1888477606257127e-06,2.1744056099231619e-06,2.3304487448021889e-06,2.6548781840409094e-06,3.1980623986073138e-06,4.0798900321494157e-06,5.5631172841029879e-06,8.2913377548852452e-06,1.428002281340041e-05,3.4378952211441412e-05,-0.0004696282098151308,-4.1249109253329207e-05,-2.609043866770909e-05,-2.1878178345614474e-05,-2.0925910744717547e-05,-2.1768924881959876e-05,-2.4152498423521848e-05,-2.8358277952246263e-05,-3.5217469759648808e-05,-4.655786260612977e-05,-6.6649051205045404e-05,-0.00010761779912431255,-0.00022115197102140998,-0.0013207272444296732,0.00049412576389814623,0.00025617184153527779,0.00019988086070085324,0.00018309482253341529,0.00018436692260446059,0.00019889215174844665,0.00022740717840386481,0.00027484308610480415,0.00035254223338200601,0.00048617012276092709,0.00074317018354294725,0.001366556367457841,0.0043418092521156949,-0.0064412554232104588,-0.0023257145112690436,-0.0016533790630660844,-0.0014401327095634891,-0.0013986792805456322,-0.0014639583289256899,-0.0016277452696302802,-0.0019131553996517433,-0.002381309897605184,-0.003169084854279153,-0.0046149632153260674,-0.00779258638530119,-0.018686719148926324,0.15775050821742617,0.019561390296762085,0.012239873719290893,0.010037931500526563,0.0093594672563540263,0.0094779087412704254,0.010228298032355188,0.011675857387413146,0.014094439273726842,0.018113959044875668,0.025226085744647457,0.039714961124303713,0.080277523918438107,0.53918871064289264,-0.15470838876562898,-0.079928490927878224,-0.060849049225176338,-0.054133464330256773,-0.052838694775674842,-0.055196532721827819,-0.061071705430835746,-0.07139908579786583,-0.088581155808420187,-0.11819262124879636,-0.17505900555511622,-0.31354888771595635,-1.0073039094137917,1.2248374835289575,0.45198851468617107,0.31265329061549818,0.26314721683407671,0.24631839410591569,0.24813022601363816,0.2652822081429822,0.29961365483204916,0.35821569392412028,0.45789566915370089,0.64096354830791225,1.0436542271725433,2.4541409241366736,-14.147729484673322,-2.1606393746846044,-1.3114890019078578,-1.0317228966835168,-0.91943707404404296,-0.88815455261782328,-0.91306076383784063,-0.99186223531034812,-1.138470500029559,-1.3904980747110618,-1.8403952643310064,-2.7582414077305653,-5.3535610033593608,-41.004492118446983,8.4583308349173567,4.2285828595270942,3.0523511606316966,2.5608749246520479,2.350504505336279,2.3040156741378306,2.3877830370517672,2.6105203366079643,3.0244178848386278,3.7645346161206361,5.2015507410229427,8.7260133889539642,27.340622246490568,-26.125573958171788,-9.3595451026056153,-6.0060141244873027,-4.6479228671839339,-3.980386102361686,-3.6534638786467379,-3.5453082304319339,-3.6203326131306688,-3.898174565841678,-4.4699381429050575,-5.5929318417318514,-8.1277421931850586,-17.277220891711931,66.244937595787349,10.610880268697112,5.6213970533316528,3.7822730497161321,2.8397105760868984,2.2744857879083216,1.9028199004389383,1.6433280495204843,1.4545278684775165,1.3131194082999798,1.2050508697282143,1.1213764486200135,1.0561552621146912,1.0053080795668996,0.96595914799109983,0.9360393637753972,0.91403764401291865,0.89884005059768013,0.88962284191509666,0.88577975864284197,0.88687167867592076,0.8925912770903951,0.90273800090490752,0.91720030386370155,0.93594311348880221,0.9589991633518451,0.98646325827971393,1.0184888326026107,1.0552863625400164,1.0971233351768397,1.1443255784429591,1.1972798322214779,1.2564374988919358,1.3223195581672778,1.3955226701024086,1.4767265245550194,1.5667025273192423,1.6663239442837532,1.7765776566259559,1.8985777133899899,2.0335809038497383,2.1830046118373878,2.3484472587427816,2.5317116922417715,2.7348319351708872,2.9601037746450989,3.2101197470063365,3.4878091611923101,3.7964839035954525,4.1398908837083104,4.5222721144693061,4.9484335773042449,5.4238242029907582,5.9546265098506233,6.5478606852919219,7.2115041811249299,7.9546292240712564,8.7875610283598053,9.7220599464873683,10.771531317953382,11.951267386796092,13.278726371997887,14.773854607884127,16.459458645174088,18.361635341674603,20.510269303389972,22.939608595753757,25.688931470554706,28.803318993751983,32.3345509680737,36.342145487291099,40.894565913387765,46.070623124554842,51.961105648538521,58.670675899638745,66.320077329002672,75.04870505499413,85.017601674253683,96.412950714492794,109.45015287345826,124.37858514601042,141.48716058995242,161.11082731569124,183.63816989285496,209.52030544670492,239.28130109842039,273.5303800733688,312.97623193414472,358.44379938886829,410.89398164395573,471.44677429817688,541.40846067496477,622.30358208151506,715.91254813017406,824.31590697300021,949.94648387915868,1095.6508207516274,1264.7616157800624,1461.1831796430113,1689.4923022932537,1955.0573741017638,2264.1791410205678,2624.2571122564809,3043.9864008519162,3533.59068668286,4105.0980766482407,4772.667932964092,5552.9782891801342,6465.6853248522202,7533.9685838757641,8785.1782705820769,10251.604128716801,11971.389205899382,13989.616355867571,16359.600784197017,19144.428482593597,22418.78824204468,26271.154350919678,30806.388389882177,36148.842116508706,42446.059753659909,49873.197618299149,58638.30262942049,68988.61963420939,81218.131680531369,95676.578538468471,112780.24838224659,133024.8973388584,157001.22371296008,185413.4106784715,219101.35619923851,259067.33567730142,306507.99590278108,362852.76384404663,429809.97740385146,509422.31565155601,604133.43314856093,716868.09887307894,851128.61957472609,1011110.9079638351,1201844.2596324489,1429359.7553697047,1700893.2396583415,2025130.0806753295,2412500.4396429299,2875535.6258467427,3429298.3586963867,4091902.4859955101,4885141.0231629973,5835245.4097110759,6973803.7832965124,8338872.0391859189,9976318.707378557,11941453.526055211,14301000.367035992,17135488.302695088,20542150.615635332,24638441.08020917,29566300.669500366,35497336.918653429,42639113.676480114,51242792.336951315,61612418.619152196,74116213.715018868,89200307.793566972,107405450.6836091,129387353.03734414,155941456.29490232,188033107.33170527,226834331.15531537,273768661.4963361,330565815.75867158,399328401.27077204,482613330.98154992,583531229.43203664,705867849.56404316,854232429.17008865,1034239031.3122199,1252728283.6099417,1518038615.7996621,1840338166.0021675,2232031073.2442584,2708255007.4498959,3287490644.6954784,3992308543.3542476,4850284723.7276945,5895123456.6894751,7168034643.1151199,8719424107.7144432,10610968623.401487,12918164125.471176,15733456110.929533,19170086566.036457,23366823061.830227,28493774311.632793,34759544241.045753,42420035641.830963,51789287446.145355,63252819889.624451,77284073451.795685,94464665582.786224,115509360191.05585,141296856553.76825,172907766499.35663,211671473547.92264,259223970271.85342,317579269213.36078,389217601585.29572,477194385683.8739,585274899524.54626,718100774554.65967,881395895252.93896,1082221112535.3127,1329289443745.2078,1633356246483.0706,2007702352035.4053,2468732494216.0649,3036716779888.8779,3736709678751.5483,4599689387019.6064,5663970847850.6328,6976958696654.8848,8597322573542.2607,10597697396880.098,13068036306670.889,16119775295394.613,19891007585872.984,24552914514355.531,30317760437972.035,37448835018032.844,46272820899156.773,57195183020619.797,70719323458973.734,87470430195577.906,108225178780071.98,133948734110495.06,165840859996934.91,205393395023537.38,254461917300885.03,315355126635277.44,390946356347587.25,484812733517907.94,601408892375696.25,746283881912783.25,926352084744155.75,1150231691795648.2,1428667697298406.2,1775060667690204.8,2206127918709488.5,2742730486785859.5,3410907755405032.5,4243172236790960.5,5280130370626186,6572511985205888,8183712154398167,10192975686778494,12699387800326644,15826876429786134,19730484305466960,24604235231950620,30691002413170348,38294891668906760,47796784583250408,59673853104263024,74524066819542096,93096978354398432,1.1633240533337186e+17,1.4540904711599466e+17,1.8180560380824054e+17,2.2737763260113264e+17,2.844542186199329e+17,3.5595960009968992e+17,4.4556622889803814e+17,5.5788744054977542e+17,6.9872004616233075e+17,8.7534985900053248e+17,1.0969365804000407e+18,1.3749987810354959e+18,1.7240251630599959e+18,2.162245178307105e+18,2.712600790290263e+18,3.4039721880678426e+18,4.2727242027519872e+18,5.3646578216644844e+18,6.7374735288149535e+18,8.4638814764972616e+18,1.0635529300909451e+19,1.3367963751682304e+19,1.680689977086575e+19,2.1136143480700445e+19,2.6587607847414133e+19,3.3453976820284813e+19,4.2104722157738418e+19,5.3006365402752557e+19,6.6748116306517164e+19,8.4074322084901175e+19,1.0592554659758653e+20,1.3349058695568271e+20,1.6827235528917474e+20,2.1217134119034755e+20,2.675913711860273e+20,3.3757365338399913e+20,4.2596671190537745e+20,5.376418707237058e+20,6.7876655964213726e+20,8.5715103865668305e+20,1.0826883649471505e+21,1.3679128065416686e+21,1.7287087536046911e+21,2.1852108943011301e+21,2.7629475199524164e+21,3.4942929576578709e+21,4.4203131320082314e+21,5.5931111956255311e+21,7.0788093999118822e+21,8.9613406373808544e+21,1.1347270590468092e+22,1.4371931997907532e+22,1.8207229812704815e+22,2.3071574593115188e+22,2.9242527241099578e+22,3.7072898724667597e+22,4.701125333520278e+22,5.9628025670485741e+22,7.5648795671876289e+22,9.5996692858188589e+22,1.2184644620815467e+23,1.5469329299144216e+23,1.9644085053190087e+23,2.4951319356107962e+23,3.1699783583344536e+23,4.028281768529377e+23,5.1201635669623362e+23,6.5095050982222857e+23,8.2777430930096039e+23,1.0528716856221823e+24,1.3394859962824434e+24,1.7045111075446444e+24,2.1695023332878031e+24,2.7619686057779462e+24,3.5170244610575524e+24,4.4795024746878614e+24,5.7066550516990426e+24,7.2716107166531913e+24,9.2677965242831216e+24,1.1814597819161938e+25,1.506460304094209e+25,1.9212879388175225e+25,2.450885107232946e+25,3.1271513524145956e+25,3.990892442621372e+25,5.0943178914862682e+25,6.5042418539215948e+25,8.3061863219495513e+25,1.0609642034532433e+26,1.3554815111751798e+26,1.7321280736715443e+26,2.2139085173549716e+26,2.8302991668808363e+26,3.61907641783264e+26,4.6286638068944231e+26,5.9211455296402918e+26,7.5761364101889723e+26,9.6957527122320352e+26,1.2410998193548215e+27,1.5889969953571339e+27,2.0348404718500612e+27,2.606323574754939e+27,3.3390023198065162e+27,4.2785369033997813e+27,5.4835747503328623e+27,7.0294594628541627e+27,9.0130031879111721e+27,1.1558628486769439e+28,1.4826274226833961e+28,1.902157409783619e+28,2.440896354844729e+28,3.1328560890203589e+28,4.0217913488624764e+28,5.1640016468641293e+28,6.6319420033001538e+28,8.5188769261921523e+28,1.0944880196270156e+29,1.4064571082551206e+29,1.807709141061679e+29,2.3238974972417255e+29,2.9880750864848851e+29,3.842836810981944e+29,4.9430846699336964e+29,6.3595971207049046e+29,8.1836374745326509e+29,1.0532904885826639e+30,1.3559220496209721e+30,1.7458456482775702e+30,2.2483364865533458e+30,2.8960155972750672e+30,3.7309926436630244e+30,4.8076360341670002e+30,6.1961546521625198e+30,7.9872298337448209e+30,1.0298006633304394e+31,1.3279844666364896e+31,1.7128347103445136e+31,2.2096339743571201e+31,2.8510670954247029e+31,3.6793961172493388e+31,4.7492765211081028e+31,6.1314044655599409e+31,7.9172410856081255e+31,1.0225132998185434e+32,1.3208243044330275e+32,1.7064828483777799e+32,2.2051563813987886e+32,2.8500813124403843e+32,3.6843026737341153e+32,4.7635787453575447e+32,6.1601487240530897e+32,7.9676207194621172e+32,1.0307314309392088e+33,1.333649192157282e+33,1.7259043381422067e+33,2.2339357120407644e+33,2.892033155764908e+33,3.7446766390023017e+33,4.8495745936270985e+33,6.2816111311650957e+33,8.1379748981933875e+33,1.0544824436363815e+34,1.3665951821709588e+34,1.7714045572846648e+34,2.29653351323193e+34,2.9778635409535322e+34,3.8620117582389423e+34,5.0095533313051283e+34,6.4992142085279872e+34,8.4333272500706983e+34,1.0944933634670465e+35,1.420702720707605e+35,1.8444590421235354e+35,2.3950267474217828e+35,3.1104777137713265e+35,4.0403502994125527e+35,5.2491136199307404e+35,6.8206816783959876e+35,8.8642964718553845e+35,1.1522196488652987e+36,1.4979614051742915e+36,1.9477810874918454e+36,2.5331077909455594e+36,3.2948908666255542e+36,4.2864925104288806e+36,5.5774618567544629e+36,7.2584600045413277e+36,9.4476879913984618e+36,1.2299277708180935e+37,1.601424693788356e+37,2.0854804355164197e+37,2.7163031851518753e+37,3.538528752396199e+37,4.610408609092574e+37,6.0079754518210865e+37,7.8304868737267739e+37,1.0207540425878468e+38,1.3308374703403028e+38,1.7354029997039688e+38,2.263325015753581e+38,2.9523279903960412e+38] diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/runner.R b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/runner.R new file mode 100644 index 000000000000..41969b68e026 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/runner.R @@ -0,0 +1,117 @@ +#!/usr/bin/env Rscript +# +# @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. + +# Set the precision to 16 digits: +options( digits = 16L ); + +#' Generate test fixtures. +#' +#' @examples +#' main(); +main <- function() { + #' Get the script filepath. + #' + #' @return The absolute path of this script + #' + #' @examples + #' filepath <- get_script_path(); + get_script_path <- function() { + args <- commandArgs( trailingOnly = FALSE ); + needle <- '--file='; + match <- grep( needle, args ); + if ( length( match ) > 0L ) { + # Rscript: + filepath <- sub( needle, '', args[match] ); + } else { + ls_vars <- ls( sys.frames()[[1L]] ) + if ( 'fileName' %in% ls_vars ) { + # Source'd via RStudio: + filepath <- sys.frames()[[1L]]$fileName; # nolint + } else { + # Source'd via R console: + filepath <- sys.frames()[[1L]][['ofile']]; + } + } + return( normalizePath( filepath ) ); + } + + #' Convert a data structure to JSON. + #' + #' @param x A data structure to convert + #' @return JSON blob + #' + #' @examples + #' x <- seq( -6.5, 25, 0.5 ); + #' json <- to_json( x ); + to_json <- function( x ) { + return( jsonlite::toJSON( x, digits = 16L, auto_unbox = TRUE ) ); + } + + #' Generate an output absolute filepath based on the script directory. + #' + #' @param name An output filename + #' @return An absolute filepath + #' + #' @examples + #' filepath <- get_filepath( 'data.json' ); + get_filepath <- function( name ) { + return( paste( source_dir, '/', name, sep = '' ) ); + } + + # Get the directory of this script: + source_dir <- dirname( get_script_path() ); + + # Generate integer test data: + x <- seq( 1L, 35L, 1L ); + y <- gamma( x ); + + # Deal with NaNs: + cat( y, sep = ',\n' ); + + # Convert fixture data to JSON: + x <- to_json( x ); + y <- to_json( y ); + + # Write the data to file... + filepath <- get_filepath( 'data1.json' ); + write( x, filepath ); + + filepath <- get_filepath( 'expected1.json' ); + write( y, filepath ); + + + # Generate decimal test data: + x <- seq( -40.0001, 35.00, length.out = 1000L ); + y <- gamma( x ); + + # Deal with NaNs: + cat( y, sep = ',\n' ); + + # Convert fixture data to JSON: + x <- to_json( x ); + y <- to_json( y ); + + # Write the data to file... + filepath <- get_filepath( 'data2.json' ); + write( x, filepath ); + + filepath <- get_filepath( 'expected2.json' ); + write( y, filepath ); +} + +main(); diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/test/test.js b/lib/node_modules/@stdlib/math/base/special/gammaf/test/test.js new file mode 100644 index 000000000000..0cdb6359fadf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/test.js @@ -0,0 +1,163 @@ +/** +* @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 incrspace = require( '@stdlib/array/base/incrspace' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var max = require( '@stdlib/math/base/special/maxn' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var gammaf = require( './../lib' ); + + +// FIXTURES // + +var data1 = require( './fixtures/r/data1.json' ); +var expected1 = require( './fixtures/r/expected1.json' ); +var data2 = require( './fixtures/r/data2.json' ); +var expected2 = require( './fixtures/r/expected2.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gammaf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided a negative integer, the function returns `NaN`', function test( t ) { + var values = incrspace( -1.0, -1000.0, -1.0 ); + var v; + var i; + + for ( i = 0; i < values.length; i++ ) { + v = gammaf( values[ i ] ); + t.strictEqual( isnanf( v ), true, 'returns expected value when provided ' + values[ i ] ); + } + t.end(); +}); + +tape( 'if provided negative infinity, the function returns `NaN`', function test( t ) { + var v = gammaf( NINF ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { + var v = gammaf( NaN ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided `-0`, the function returns negative infinity', function test( t ) { + var v = gammaf( -0.0 ); + t.strictEqual( v, NINF, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided `+0`, the function returns positive infinity', function test( t ) { + var v = gammaf( 0.0 ); + t.strictEqual( v, PINF, 'returns expected value' ); + t.end(); +}); + +tape( 'if `x > 35.0400...`, the function returns positive infinity', function test( t ) { + var values = incrspace( 35.05, 100.0, 10.1234 ); + var v; + var i; + + for ( i = 0; i < values.length; i++ ) { + v = gammaf( values[ i ] ); + t.strictEqual( v, PINF, 'returns expected value when provided ' + values[ i ] ); + } + t.end(); +}); + +tape( 'if `x < -40.0019...`, the function returns zero', function test( t ) { + var values = incrspace( -40.002, -100.0, -10.1234 ); + var v; + var i; + + for ( i = 0; i < values.length; i++ ) { + v = gammaf( values[ i ] ); + t.strictEqual( v, 0.0, 'returns expected value when provided ' + values[ i ] ); + } + t.end(); +}); + +tape( 'the function evaluates the gamma function (positive integers)', function test( t ) { + var delta; + var tol; + var v; + var i; + + for ( i = 0; i < data1.length; i++ ) { + v = gammaf( data1[ i ] ); + delta = absf( v - expected1[ i ] ); + tol = 2.75e-5 * max( 1.0, absf( v ), absf( expected1[ i ] ) ); + t.ok( delta <= tol, 'within tolerance. x: ' + data1[ i ] + '. Value: ' + v + '. Expected: ' + expected1[ i ] + '. Tolerance: ' + tol + '.' ); + } + t.end(); +}); + +tape( 'the function evaluates the gamma function (decimal values)', function test( t ) { + var delta; + var tol; + var v; + var i; + + for ( i = 0; i < data2.length; i++ ) { + v = gammaf( data2[ i ] ); + delta = absf( v - expected2[ i ] ); + tol = 2.75e-5 * max( 1.0, absf( v ), absf( expected2[ i ] ) ); + t.ok( delta <= tol, 'within tolerance. x: ' + data2[ i ] + '. Value: ' + v + '. Expected: ' + expected2[ i ] + '. Tolerance: ' + tol + '.' ); + } + t.end(); +}); + +tape( 'if provided a positive integer, the function returns the factorial of (n-1)', function test( t ) { + t.strictEqual( gammaf( 4.0 ), 6.0, 'returns 6' ); + t.strictEqual( gammaf( 5.0 ), 24.0, 'returns 24' ); + t.strictEqual( gammaf( 6.0 ), 120.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function uses a small value approximation for tiny positive x', function test( t ) { + var expected; + var delta; + var tol; + var x; + var v; + + x = 0.000009999999747378752; // f32(1e-5) — triggers x < 1e-4 check + v = gammaf( x ); + + expected = 9.9999422e+4; + delta = absf( v - expected ); + tol = 1.0; + + t.ok( delta < tol, 'within tolerance. x: ' + x + '. Value: ' + v + + '. Expected: ' + expected + '. Tolerance: ' + tol + '.' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/gammaf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/gammaf/test/test.native.js new file mode 100644 index 000000000000..1aa109a12a7f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/test.native.js @@ -0,0 +1,172 @@ +/** +* @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 incrspace = require( '@stdlib/array/base/incrspace' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var max = require( '@stdlib/math/base/special/maxn' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var gammaf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( gammaf instanceof Error ) +}; + + +// FIXTURES // + +var data1 = require( './fixtures/r/data1.json' ); +var expected1 = require( './fixtures/r/expected1.json' ); +var data2 = require( './fixtures/r/data2.json' ); +var expected2 = require( './fixtures/r/expected2.json' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gammaf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided a negative integer, the function returns `NaN`', opts, function test( t ) { + var values = incrspace( -1.0, -1000.0, -1.0 ); + var v; + var i; + + for ( i = 0; i < values.length; i++ ) { + v = gammaf( values[ i ] ); + t.strictEqual( isnanf( v ), true, 'returns expected value when provided ' + values[ i ] ); + } + t.end(); +}); + +tape( 'if provided negative infinity, the function returns `NaN`', opts, function test( t ) { + var v = gammaf( NINF ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided `NaN`, the function returns `NaN`', opts, function test( t ) { + var v = gammaf( NaN ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided `-0`, the function returns negative infinity', opts, function test( t ) { + var v = gammaf( -0.0 ); + t.strictEqual( v, NINF, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided `+0`, the function returns positive infinity', opts, function test( t ) { + var v = gammaf( 0.0 ); + t.strictEqual( v, PINF, 'returns expected value' ); + t.end(); +}); + +tape( 'if `x > 35.0400...`, the function returns positive infinity', opts, function test( t ) { + var values = incrspace( 35.05, 100.0, 10.1234 ); + var v; + var i; + + for ( i = 0; i < values.length; i++ ) { + v = gammaf( values[ i ] ); + t.strictEqual( v, PINF, 'returns expected value when provided ' + values[ i ] ); + } + t.end(); +}); + +tape( 'if `x < -40.0019...`, the function returns zero', opts, function test( t ) { + var values = incrspace( -40.002, -100.0, -10.1234 ); + var v; + var i; + + for ( i = 0; i < values.length; i++ ) { + v = gammaf( values[ i ] ); + t.strictEqual( v, 0.0, 'returns expected value when provided ' + values[ i ] ); + } + t.end(); +}); + +tape( 'the function evaluates the gamma function (positive integers)', opts, function test( t ) { + var delta; + var tol; + var v; + var i; + + for ( i = 0; i < data1.length; i++ ) { + v = gammaf( data1[ i ] ); + delta = absf( v - expected1[ i ] ); + tol = 2.75e-5 * max( 1.0, absf( v ), absf( expected1[ i ] ) ); + t.ok( delta <= tol, 'within tolerance. x: ' + data1[ i ] + '. Value: ' + v + '. Expected: ' + expected1[ i ] + '. Tolerance: ' + tol + '.' ); + } + t.end(); +}); + +tape( 'the function evaluates the gamma function (decimal values)', opts, function test( t ) { + var delta; + var tol; + var v; + var i; + + for ( i = 0; i < data2.length; i++ ) { + v = gammaf( data2[ i ] ); + delta = absf( v - expected2[ i ] ); + tol = 2.75e-5 * max( 1.0, absf( v ), absf( expected2[ i ] ) ); + t.ok( delta <= tol, 'within tolerance. x: ' + data2[ i ] + '. Value: ' + v + '. Expected: ' + expected2[ i ] + '. Tolerance: ' + tol + '.' ); + } + t.end(); +}); + +tape( 'if provided a positive integer, the function returns the factorial of (n-1)', opts, function test( t ) { + t.strictEqual( gammaf( 4.0 ), 6.0, 'returns 6' ); + t.strictEqual( gammaf( 5.0 ), 24.0, 'returns 24' ); + t.strictEqual( gammaf( 6.0 ), 120.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function uses a small value approximation for tiny positive x', opts, function test( t ) { + var expected; + var delta; + var tol; + var x; + var v; + + x = 0.000009999999747378752; // f32(1e-5) — triggers x < 1e-4 check + v = gammaf( x ); + + expected = 9.9999422e+4; + delta = absf( v - expected ); + tol = 1.0; + + t.ok( delta < tol, 'within tolerance. x: ' + x + '. Value: ' + v + + '. Expected: ' + expected + '. Tolerance: ' + tol + '.' ); + t.end(); +});