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..754201f2f0f9 --- /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 > 34.84425627277176174f ) { + return STDLIB_CONSTANT_FLOAT32_PINF; + } + + if ( x < -34.1955451965332f ) { + 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..2f88d2dfbe93 --- /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] 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..1b487eb335c0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/data2.json @@ -0,0 +1 @@ +[-34.0989990234375,-34.030033111572266,-33.961063385009766,-33.892097473144531,-33.823127746582031,-33.754161834716797,-33.685192108154297,-33.616222381591797,-33.547256469726562,-33.478286743164062,-33.409320831298828,-33.340351104736328,-33.271385192871094,-33.202415466308594,-33.133449554443359,-33.064479827880859,-32.995513916015625,-32.926544189453125,-32.857578277587891,-32.788608551025391,-32.719638824462891,-32.650672912597656,-32.581703186035156,-32.512737274169922,-32.443767547607422,-32.374801635742188,-32.305831909179688,-32.236865997314453,-32.167896270751953,-32.098930358886719,-32.029960632324219,-31.960992813110352,-31.892024993896484,-31.823057174682617,-31.75408935546875,-31.685121536254883,-31.616153717041016,-31.547185897827148,-31.478218078613281,-31.409248352050781,-31.340280532836914,-31.271312713623047,-31.20234489440918,-31.133377075195312,-31.064409255981445,-30.995441436767578,-30.926473617553711,-30.857505798339844,-30.788537979125977,-30.719570159912109,-30.650602340698242,-30.581634521484375,-30.512664794921875,-30.443696975708008,-30.374729156494141,-30.305761337280273,-30.236793518066406,-30.167825698852539,-30.098857879638672,-30.029890060424805,-29.960922241210938,-29.89195442199707,-29.822986602783203,-29.754018783569336,-29.685050964355469,-29.616081237792969,-29.547113418579102,-29.478145599365234,-29.409177780151367,-29.3402099609375,-29.271242141723633,-29.202274322509766,-29.133306503295898,-29.064338684082031,-28.995370864868164,-28.926403045654297,-28.85743522644043,-28.788467407226562,-28.719497680664062,-28.650529861450195,-28.581562042236328,-28.512594223022461,-28.443626403808594,-28.374658584594727,-28.305690765380859,-28.236722946166992,-28.167755126953125,-28.098787307739258,-28.029819488525391,-27.960851669311523,-27.891881942749023,-27.822914123535156,-27.753946304321289,-27.684978485107422,-27.616010665893555,-27.547042846679688,-27.47807502746582,-27.409107208251953,-27.340139389038086,-27.271171569824219,-27.202203750610352,-27.133235931396484,-27.064268112182617,-26.995298385620117,-26.92633056640625,-26.857362747192383,-26.788394927978516,-26.719427108764648,-26.650459289550781,-26.581491470336914,-26.512523651123047,-26.44355583190918,-26.374588012695312,-26.305620193481445,-26.236652374267578,-26.167684555053711,-26.098714828491211,-26.029747009277344,-25.960779190063477,-25.891811370849609,-25.822843551635742,-25.753875732421875,-25.684907913208008,-25.615940093994141,-25.546972274780273,-25.478004455566406,-25.409036636352539,-25.340068817138672,-25.271100997924805,-25.202131271362305,-25.133163452148438,-25.06419563293457,-24.995227813720703,-24.926259994506836,-24.857292175292969,-24.788324356079102,-24.719356536865234,-24.650388717651367,-24.5814208984375,-24.512453079223633,-24.443485260009766,-24.374517440795898,-24.305547714233398,-24.236579895019531,-24.167612075805664,-24.098644256591797,-24.02967643737793,-23.960708618164062,-23.891740798950195,-23.822772979736328,-23.753805160522461,-23.684837341308594,-23.615869522094727,-23.546901702880859,-23.477933883666992,-23.408964157104492,-23.339996337890625,-23.271028518676758,-23.202060699462891,-23.133092880249023,-23.064125061035156,-22.995157241821289,-22.926189422607422,-22.857221603393555,-22.788253784179688,-22.71928596496582,-22.650318145751953,-22.581348419189453,-22.512380599975586,-22.443412780761719,-22.374444961547852,-22.305477142333984,-22.236509323120117,-22.16754150390625,-22.098573684692383,-22.029605865478516,-21.960638046264648,-21.891670227050781,-21.822702407836914,-21.753734588623047,-21.684764862060547,-21.61579704284668,-21.546829223632812,-21.477861404418945,-21.408893585205078,-21.339925765991211,-21.270957946777344,-21.201990127563477,-21.133022308349609,-21.064054489135742,-20.995086669921875,-20.926118850708008,-20.857151031494141,-20.788181304931641,-20.719213485717773,-20.650245666503906,-20.581277847290039,-20.512310028076172,-20.443342208862305,-20.374374389648438,-20.30540657043457,-20.236438751220703,-20.167470932006836,-20.098503112792969,-20.029535293579102,-19.960567474365234,-19.891597747802734,-19.822629928588867,-19.753662109375,-19.684694290161133,-19.615726470947266,-19.546758651733398,-19.477790832519531,-19.408823013305664,-19.339855194091797,-19.27088737487793,-19.201919555664062,-19.132951736450195,-19.063983917236328,-18.995014190673828,-18.926046371459961,-18.857078552246094,-18.788110733032227,-18.719142913818359,-18.650175094604492,-18.581207275390625,-18.512239456176758,-18.443271636962891,-18.374303817749023,-18.305335998535156,-18.236368179321289,-18.167398452758789,-18.098430633544922,-18.029462814331055,-17.960494995117188,-17.89152717590332,-17.822559356689453,-17.753591537475586,-17.684623718261719,-17.615655899047852,-17.546688079833984,-17.477720260620117,-17.40875244140625,-17.339784622192383,-17.270814895629883,-17.201847076416016,-17.132879257202148,-17.063911437988281,-16.994943618774414,-16.925975799560547,-16.85700798034668,-16.788040161132812,-16.719072341918945,-16.650104522705078,-16.581136703491211,-16.512168884277344,-16.443201065063477,-16.374231338500977,-16.305263519287109,-16.236295700073242,-16.167327880859375,-16.098360061645508,-16.029392242431641,-15.960424423217773,-15.891456604003906,-15.822488784790039,-15.753520965576172,-15.684552192687988,-15.615584373474121,-15.546616554260254,-15.477648735046387,-15.40868091583252,-15.339713096618652,-15.270744323730469,-15.201776504516602,-15.132808685302734,-15.063840866088867,-14.994873046875,-14.925905227661133,-14.856937408447266,-14.787968635559082,-14.719000816345215,-14.650032997131348,-14.58106517791748,-14.512097358703613,-14.443129539489746,-14.374160766601562,-14.305192947387695,-14.236225128173828,-14.167257308959961,-14.098289489746094,-14.029321670532227,-13.960352897644043,-13.891385078430176,-13.822417259216309,-13.753449440002441,-13.684481620788574,-13.615513801574707,-13.54654598236084,-13.477577209472656,-13.408609390258789,-13.339641571044922,-13.270673751831055,-13.201705932617188,-13.13273811340332,-13.063769340515137,-12.99480152130127,-12.925833702087402,-12.856865882873535,-12.787898063659668,-12.718930244445801,-12.649962425231934,-12.58099365234375,-12.512025833129883,-12.443058013916016,-12.374090194702148,-12.305122375488281,-12.236154556274414,-12.16718578338623,-12.098217964172363,-12.029250144958496,-11.960282325744629,-11.891314506530762,-11.822346687316895,-11.753377914428711,-11.684410095214844,-11.615442276000977,-11.546474456787109,-11.477506637573242,-11.408538818359375,-11.339570999145508,-11.270602226257324,-11.201634407043457,-11.13266658782959,-11.063698768615723,-10.994730949401855,-10.925763130187988,-10.856794357299805,-10.787826538085938,-10.71885871887207,-10.649890899658203,-10.580923080444336,-10.511955261230469,-10.442987442016602,-10.374018669128418,-10.305050849914551,-10.236083030700684,-10.167115211486816,-10.098147392272949,-10.029179573059082,-9.9602108001708984,-9.8912429809570312,-9.8222751617431641,-9.7533073425292969,-9.6843395233154297,-9.6153717041015625,-9.5464029312133789,-9.4774351119995117,-9.4084672927856445,-9.3394994735717773,-9.2705316543579102,-9.201563835144043,-9.1325960159301758,-9.0636272430419922,-8.994659423828125,-8.9256916046142578,-8.8567237854003906,-8.7877559661865234,-8.7187881469726562,-8.6498193740844727,-8.5808515548706055,-8.5118837356567383,-8.4429159164428711,-8.3739480972290039,-8.3049802780151367,-8.2360124588012695,-8.1670436859130859,-8.0980758666992188,-8.0291080474853516,-7.9601402282714844,-7.8911724090576172,-7.8222041130065918,-7.7532362937927246,-7.6842684745788574,-7.615300178527832,-7.5463323593139648,-7.4773645401000977,-7.4083962440490723,-7.3394284248352051,-7.2704606056213379,-7.2014923095703125,-7.1325244903564453,-7.0635566711425781,-6.9945883750915527,-6.9256205558776855,-6.8566527366638184,-6.7876849174499512,-6.7187166213989258,-6.6497488021850586,-6.5807809829711914,-6.511812686920166,-6.4428448677062988,-6.3738770484924316,-6.3049087524414062,-6.2359409332275391,-6.1669731140136719,-6.0980048179626465,-6.0290369987487793,-5.9600691795349121,-5.8911008834838867,-5.8221330642700195,-5.7531652450561523,-5.6841974258422852,-5.6152291297912598,-5.5462613105773926,-5.4772934913635254,-5.4083251953125,-5.3393573760986328,-5.2703895568847656,-5.2014212608337402,-5.132453441619873,-5.0634856224060059,-4.9945173263549805,-4.9255495071411133,-4.8565816879272461,-4.7876133918762207,-4.7186455726623535,-4.6496777534484863,-4.5807099342346191,-4.5117416381835938,-4.4427738189697266,-4.3738059997558594,-4.304837703704834,-4.2358698844909668,-4.1669020652770996,-4.0979337692260742,-4.028965950012207,-3.9599978923797607,-3.8910300731658936,-3.8220620155334473,-3.7530941963195801,-3.6841261386871338,-3.6151580810546875,-3.5461902618408203,-3.477222204208374,-3.4082541465759277,-3.3392863273620605,-3.2703182697296143,-3.2013504505157471,-3.1323823928833008,-3.0634143352508545,-2.9944465160369873,-2.925478458404541,-2.8565104007720947,-2.7875425815582275,-2.7185745239257812,-2.6496067047119141,-2.5806386470794678,-2.5116705894470215,-2.4427027702331543,-2.373734712600708,-2.3047666549682617,-2.2357988357543945,-2.1668307781219482,-2.0978629589080811,-2.0288949012756348,-1.959926962852478,-1.8909589052200317,-1.821990966796875,-1.7530230283737183,-1.6840550899505615,-1.6150870323181152,-1.5461190938949585,-1.4771511554718018,-1.408183217048645,-1.3392151594161987,-1.270247220993042,-1.2012792825698853,-1.1323113441467285,-1.0633432865142822,-0.99437534809112549,-0.92540740966796875,-0.85643941164016724,-0.7874714732170105,-0.71850347518920898,-0.64953553676605225,-0.58056753873825073,-0.51159960031509399,-0.44263163208961487,-0.37366366386413574,-0.30469569563865662,-0.23572772741317749,-0.16675975918769836,-0.097791790962219238,-0.028823824599385262,0.040144145488739014,0.10911211371421814,0.17808008193969727,0.24704805016517639,0.31601601839065552,0.38498398661613464,0.45395195484161377,0.52291989326477051,0.59188789129257202,0.66085582971572876,0.72982382774353027,0.79879176616668701,0.86775976419448853,0.93672770261764526,1.0056957006454468,1.0746636390686035,1.1436315774917603,1.2125996351242065,1.2815675735473633,1.35053551197052,1.4195034503936768,1.488471508026123,1.5574394464492798,1.6264073848724365,1.6953753232955933,1.7643433809280396,1.8333113193511963,1.902279257774353,1.9712471961975098,2.0402152538299561,2.1091830730438232,2.1781511306762695,2.2471191883087158,2.316087007522583,2.3850550651550293,2.4540231227874756,2.5229909420013428,2.5919589996337891,2.6609268188476562,2.7298948764801025,2.7988629341125488,2.867830753326416,2.9367988109588623,3.0057668685913086,3.0747346878051758,3.1437027454376221,3.2126705646514893,3.2816386222839355,3.3506066799163818,3.419574499130249,3.4885425567626953,3.5575106143951416,3.6264784336090088,3.6954464912414551,3.7644143104553223,3.8333823680877686,3.9023504257202148,3.971318244934082,4.0402860641479492,4.1092543601989746,4.1782221794128418,4.247189998626709,4.3161582946777344,4.3851261138916016,4.4540939331054688,4.5230622291564941,4.5920300483703613,4.6609978675842285,4.7299661636352539,4.7989339828491211,4.8679018020629883,4.9368700981140137,5.0058379173278809,5.074805736541748,5.1437735557556152,5.2127418518066406,5.2817096710205078,5.350677490234375,5.4196457862854004,5.4886136054992676,5.5575814247131348,5.6265497207641602,5.6955175399780273,5.7644853591918945,5.8334536552429199,5.9024214744567871,5.9713892936706543,6.0403575897216797,6.1093254089355469,6.1782932281494141,6.2472610473632812,6.3162293434143066,6.3851971626281738,6.454164981842041,6.5231332778930664,6.5921010971069336,6.6610689163208008,6.7300372123718262,6.7990050315856934,6.8679728507995605,6.9369411468505859,7.0059089660644531,7.0748767852783203,7.1438450813293457,7.2128129005432129,7.2817807197570801,7.3507485389709473,7.4197168350219727,7.4886846542358398,7.557652473449707,7.6266207695007324,7.6955885887145996,7.7645564079284668,7.8335247039794922,7.9024925231933594,7.9714603424072266,8.0404281616210938,8.1093959808349609,8.1783647537231445,8.2473325729370117,8.3163003921508789,8.3852682113647461,8.4542360305786133,8.5232038497924805,8.5921726226806641,8.6611404418945312,8.7301082611083984,8.7990760803222656,8.8680438995361328,8.93701171875,9.0059795379638672,9.0749483108520508,9.143916130065918,9.2128839492797852,9.2818517684936523,9.3508195877075195,9.4197874069213867,9.4887561798095703,9.5577239990234375,9.6266918182373047,9.6956596374511719,9.7646274566650391,9.8335952758789062,9.9025630950927734,9.971531867980957,10.040499687194824,10.109467506408691,10.178435325622559,10.247403144836426,10.316370964050293,10.385339736938477,10.454307556152344,10.523275375366211,10.592243194580078,10.661211013793945,10.730178833007812,10.799147605895996,10.868115425109863,10.93708324432373,11.006051063537598,11.075018882751465,11.143986701965332,11.212954521179199,11.281923294067383,11.35089111328125,11.419858932495117,11.488826751708984,11.557794570922852,11.626762390136719,11.695731163024902,11.76469898223877,11.833666801452637,11.902634620666504,11.971602439880371,12.040570259094238,12.109538078308105,12.178506851196289,12.247474670410156,12.316442489624023,12.385410308837891,12.454378128051758,12.523345947265625,12.592314720153809,12.661282539367676,12.730250358581543,12.79921817779541,12.868185997009277,12.937153816223145,13.006122589111328,13.075090408325195,13.144058227539062,13.21302604675293,13.281993865966797,13.350961685180664,13.419929504394531,13.488898277282715,13.557866096496582,13.626833915710449,13.695801734924316,13.764769554138184,13.833737373352051,13.902706146240234,13.971673965454102,14.040641784667969,14.109609603881836,14.178577423095703,14.24754524230957,14.316513061523438,14.385481834411621,14.454449653625488,14.523417472839355,14.592385292053223,14.66135311126709,14.730320930480957,14.799289703369141,14.868257522583008,14.937225341796875,15.006193161010742,15.075160980224609,15.144128799438477,15.21309757232666,15.282065391540527,15.351033210754395,15.420001029968262,15.488968849182129,15.557936668395996,15.626904487609863,15.695873260498047,15.764841079711914,15.833808898925781,15.902776718139648,15.971744537353516,16.040712356567383,16.10968017578125,16.178647994995117,16.247615814208984,16.316583633422852,16.385553359985352,16.454521179199219,16.523488998413086,16.592456817626953,16.66142463684082,16.730392456054688,16.799360275268555,16.868328094482422,16.937295913696289,17.006263732910156,17.075231552124023,17.144199371337891,17.213169097900391,17.282136917114258,17.351104736328125,17.420072555541992,17.489040374755859,17.558008193969727,17.626976013183594,17.695943832397461,17.764911651611328,17.833879470825195,17.902847290039062,17.97181510925293,18.040782928466797,18.109752655029297,18.178720474243164,18.247688293457031,18.316656112670898,18.385623931884766,18.454591751098633,18.5235595703125,18.592527389526367,18.661495208740234,18.730463027954102,18.799430847167969,18.868398666381836,18.937366485595703,19.006336212158203,19.07530403137207,19.144271850585938,19.213239669799805,19.282207489013672,19.351175308227539,19.420143127441406,19.489110946655273,19.558078765869141,19.627046585083008,19.696014404296875,19.764982223510742,19.833950042724609,19.902919769287109,19.971887588500977,20.040855407714844,20.109823226928711,20.178791046142578,20.247758865356445,20.316726684570312,20.38569450378418,20.454662322998047,20.523630142211914,20.592597961425781,20.661565780639648,20.730533599853516,20.799503326416016,20.868471145629883,20.93743896484375,21.006406784057617,21.075374603271484,21.144342422485352,21.213310241699219,21.282278060913086,21.351245880126953,21.42021369934082,21.489181518554688,21.558149337768555,21.627119064331055,21.696086883544922,21.765054702758789,21.834022521972656,21.902990341186523,21.971958160400391,22.040925979614258,22.109893798828125,22.178861618041992,22.247829437255859,22.316797256469727,22.385765075683594,22.454732894897461,22.523702621459961,22.592670440673828,22.661638259887695,22.730606079101562,22.79957389831543,22.868541717529297,22.937509536743164,23.006477355957031,23.075445175170898,23.144412994384766,23.213380813598633,23.2823486328125,23.351316452026367,23.420286178588867,23.489253997802734,23.558221817016602,23.627189636230469,23.696157455444336,23.765125274658203,23.83409309387207,23.903060913085938,23.972028732299805,24.040996551513672,24.109964370727539,24.178932189941406,24.247900009155273,24.316869735717773,24.385837554931641,24.454805374145508,24.523773193359375,24.592741012573242,24.661708831787109,24.730676651000977,24.799644470214844,24.868612289428711,24.937580108642578,25.006547927856445,25.075515747070312,25.14448356628418,25.21345329284668,25.282421112060547,25.351388931274414,25.420356750488281,25.489324569702148,25.558292388916016,25.627260208129883,25.69622802734375,25.765195846557617,25.834163665771484,25.903131484985352,25.972099304199219,26.041067123413086,26.110036849975586,26.179004669189453,26.24797248840332,26.316940307617188,26.385908126831055,26.454875946044922,26.523843765258789,26.592811584472656,26.661779403686523,26.730747222900391,26.799715042114258,26.868682861328125,26.937652587890625,27.006620407104492,27.075588226318359,27.144556045532227,27.213523864746094,27.282491683959961,27.351459503173828,27.420427322387695,27.489395141601562,27.55836296081543,27.627330780029297,27.696298599243164,27.765266418457031,27.834236145019531,27.903203964233398,27.972171783447266,28.041139602661133,28.110107421875,28.179075241088867,28.248043060302734,28.317010879516602,28.385978698730469,28.454946517944336,28.523914337158203,28.59288215637207,28.661849975585938,28.730819702148438,28.799787521362305,28.868755340576172,28.937723159790039,29.006690979003906,29.075658798217773,29.144626617431641,29.213594436645508,29.282562255859375,29.351530075073242,29.420497894287109,29.489465713500977,29.558433532714844,29.627403259277344,29.696371078491211,29.765338897705078,29.834306716918945,29.903274536132812,29.97224235534668,30.041210174560547,30.110177993774414,30.179145812988281,30.248113632202148,30.317081451416016,30.386049270629883,30.45501708984375,30.52398681640625,30.592954635620117,30.661922454833984,30.730890274047852,30.799858093261719,30.868825912475586,30.937793731689453,31.00676155090332,31.075729370117188,31.144697189331055,31.213665008544922,31.282632827758789,31.351602554321289,31.420570373535156,31.489538192749023,31.558506011962891,31.627473831176758,31.696441650390625,31.765409469604492,31.834377288818359,31.903345108032227,31.972312927246094,32.041282653808594,32.110248565673828,32.179218292236328,32.248184204101562,32.317153930664062,32.386119842529297,32.455089569091797,32.524055480957031,32.593025207519531,32.661991119384766,32.730960845947266,32.799930572509766,32.868896484375,32.9378662109375,33.006832122802734,33.075801849365234,33.144767761230469,33.213737487792969,33.282703399658203,33.351673126220703,33.420639038085938,33.489608764648438,33.558574676513672,33.627544403076172,33.696514129638672,33.765480041503906,33.834449768066406,33.903415679931641,33.972385406494141,34.041351318359375,34.110321044921875,34.179286956787109,34.248256683349609,34.317222595214844,34.386192321777344,34.455162048339844,34.524127960205078,34.593097686767578,34.662063598632812,34.731033325195312,34.799999237060547] 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..bdb7588909b9 --- /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] 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..6fbf04e2c7a7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/expected2.json @@ -0,0 +1 @@ +[-2.4486292873710267e-38,-1.0155188774822322e-37,1.0009890168632449e-37,4.6883096666096378e-38,3.7719159148376291e-38,3.638568551555058e-38,3.877466914233474e-38,4.4244296045608186e-38,5.3301298260459553e-38,6.7388109571317379e-38,8.933253324078244e-38,1.2466386812946558e-37,1.8506516295085481e-37,2.9907801174522957e-37,5.5611029049399799e-37,1.4338445988445726e-36,-2.6079707204687923e-35,-2.047100966335932e-36,-1.378468146916096e-36,-1.2323318798601411e-36,-1.2541049177458273e-36,-1.3835782164060016e-36,-1.6207642271568951e-36,-1.9969672151885315e-36,-2.5795765863014139e-36,-3.4984629655418022e-36,-5.0157916211811322e-36,-7.7211450603972807e-36,-1.3215536612296623e-35,-2.7661452981085467e-35,-1.1444985278742055e-34,1.1187575088256007e-34,5.2243880054610361e-35,4.1870411550490453e-35,4.0228351535689973e-35,4.2695416454405325e-35,4.8518516834059469e-35,5.8210463883041632e-35,7.3290781396398447e-35,9.6757625498345487e-35,1.344665854192104e-34,1.9879637982148208e-34,3.1994771576313289e-34,5.9253720343466229e-34,1.5221689267864948e-33,-2.7101615317385132e-32,-2.1504699999173328e-33,-1.4426052045694458e-33,-1.284413118937377e-33,-1.301655070436161e-33,-1.429996235621887e-33,-1.6680423711974897e-33,-2.0465141767037976e-33,-2.6323078478332581e-33,-3.554793676928096e-33,-5.0747895010829443e-33,-7.7788829473859843e-33,-1.3258219618606679e-32,-2.7639276528639845e-32,-1.1404567288684175e-31,1.1053370796876386e-31,5.1451229224105053e-32,4.1065248741735696e-32,3.9286243399528615e-32,4.1515055842639532e-32,4.6971734774138024e-32,5.6108059458726159e-32,7.0333607266344767e-32,9.2444444028289432e-32,1.2790683920016373e-31,1.8826693501173365e-31,3.0167642552923243e-31,5.5630091847131876e-31,1.423482138559329e-30,-2.4818788203708181e-29,-1.9889038530917591e-30,-1.3288163147041293e-30,-1.1779410681539999e-30,-1.1884426822192641e-30,-1.2997594330689429e-30,-1.5092809912778529e-30,-1.8433284128777439e-30,-2.3601889722649562e-30,-3.1728076857415251e-30,-4.5088582637968743e-30,-6.8800293045726707e-30,-1.1673512413343699e-29,-2.4230117602656802e-29,-9.9679130519058415e-29,9.5760252435984444e-29,4.4417320798225597e-29,3.5294802713894051e-29,3.3611544376196144e-29,3.5354051039121292e-29,3.9814371466443347e-29,4.7335867925433439e-29,5.9058647373828125e-29,7.7259634312958173e-29,1.0639344410124019e-28,1.5586414277135361e-28,2.4858480066456034e-28,4.5628735759730469e-28,1.1626234002291516e-27,-1.984052318038099e-26,-1.6054900821819046e-27,-1.067977742791983e-27,-9.4229000956971784e-28,-9.4615506496131682e-28,-1.0297955986331937e-27,-1.1900105560286399e-27,-1.4463327583860276e-27,-1.8428561530571691e-27,-2.4652671848906623e-27,-3.4862752986766586e-27,-5.2937672933134541e-27,-8.9386860253578293e-27,-1.8467354750195598e-26,-7.572245319634238e-26,7.2073091021643273e-26,3.3302688590407968e-26,2.6336906996282299e-26,2.4957583763822816e-26,2.612083672070602e-26,2.9268943219154615e-26,3.4623189333985667e-26,4.2979632355365138e-26,5.594087921208317e-26,7.6645422811586597e-26,1.1171547054045311e-25,1.7727718752276357e-25,3.2378571682720375e-25,8.2123281696845128e-25,-1.3720357052216054e-23,-1.1199964688898122e-24,-7.4149572061406967e-25,-6.5092624280290757e-25,-6.5023498231490399e-25,-7.0404512257970603e-25,-8.0933735411345607e-25,-9.7851526494922189e-25,-1.2402377625865833e-24,-1.6503924337956753e-24,-2.3216541112323914e-24,-3.5068208387909456e-24,-5.8905142435526915e-24,-1.2108045275586708e-23,-4.9462687088952206e-23,4.6630515474466922e-23,2.145477340907088e-23,1.687965073144836e-23,1.5910631957326922e-23,1.6562697004934635e-23,1.845842429012797e-23,2.1716388561664628e-23,2.6810700919932331e-23,3.4705404680580333e-23,4.7290074267603516e-23,6.8550920913267496e-23,1.0818610038502136e-22,1.9653172682189226e-22,4.9597463716919779e-22,-8.1109035014385497e-21,-6.674785059246959e-22,-4.3962265543066321e-22,-3.8381020941351879e-22,-3.8126547348710514e-22,-4.1049668670674722e-22,-4.6922322442512345e-22,-5.6408841353765183e-22,-7.1089692416690531e-22,-9.4060131488925352e-22,-1.3156050305672993e-21,-1.9758667846622282e-21,-3.3001186764241141e-21,-6.7460492303733024e-21,-2.7443528258774612e-20,2.561386769999154e-20,1.1729346513799639e-20,9.1762390161900272e-21,8.5994594155741098e-21,8.8995864751268734e-21,9.8598806442354708e-21,1.1531636594839952e-20,1.4152350607811696e-20,1.8210590555115182e-20,2.4666148557393626e-20,3.5542495802234574e-20,5.5759183075497115e-20,1.0069768146836945e-19,2.5272547976245876e-19,-4.0443064099525138e-18,-3.3528852173064845e-19,-2.1957974663520335e-19,-1.9055495118202279e-19,-1.8814056628562648e-19,-2.0132319275358421e-19,-2.2870530281562897e-19,-2.7324150632608233e-19,-3.4221573987852065e-19,-4.49972446848322e-19,-6.2544454512198058e-19,-9.3348033152215965e-19,-1.5494447530547413e-18,-3.1481876146735126e-18,-1.2746880432689555e-17,1.1771807735640602e-17,5.3621829126671772e-18,4.1691392112716228e-18,3.8823503006423613e-18,3.9921247357523242e-18,4.3943879055310601e-18,5.1061875425061966e-18,6.2259082711665159e-18,7.9589860349525297e-18,1.0709967696919068e-17,1.5331516054785044e-17,2.3895128701972481e-17,4.2874414996789978e-17,1.0694811047396823e-16,-1.6734752692065631e-15,-1.3970286481983633e-16,-9.091848254236444e-17,-7.8380977057992792e-17,-7.6869961339834025e-17,-8.1701186636697542e-17,-9.2183852717124163e-17,-1.0938467558281007e-16,-1.3605994406277129e-16,-1.776757074816241e-16,-2.4526573943415571e-16,-3.6354538599680499e-16,-5.9931453402878773e-16,-1.2095534810473776e-15,-4.8714569891057775e-15,4.4480096608255543e-15,2.0141768970366437e-15,1.5553302403988216e-15,1.438198859241951e-15,1.4684006775696494e-15,1.6048518273720638e-15,1.851458438180969e-15,2.2412368523289827e-15,2.8444596139824311e-15,3.7999563089563901e-15,5.4003729283701559e-15,8.3559551344479759e-15,1.4885448380343084e-14,3.6878744388590744e-14,-5.6415078298389044e-13,-4.7362059074859708e-14,-3.0607276926411785e-14,-2.6193188510432061e-14,-2.5497251272977271e-14,-2.6896656156557477e-14,-3.0118917723379355e-14,-3.5468293808251703e-14,-4.3782472821209946e-14,-5.6738328714972543e-14,-7.7723583005266222e-14,-1.1432447454100818e-13,-1.8702695636739972e-13,-3.7463629880045573e-13,-1.4995713227993403e-12,1.3528114042371333e-12,6.0845467212462686e-13,4.662468731256811e-13,4.2775991793120715e-13,4.3329071295944912e-13,4.6978647586373806e-13,5.3764055187714022e-13,6.4559863627625173e-13,8.1275138105582019e-13,1.0769813859851784e-12,1.5181507385529718e-12,2.329973971406346e-12,4.1172343806065421e-12,1.0121934252578718e-11,-1.5127341558919579e-10,-1.2757566960665314e-11,-8.1791935856361356e-12,-6.9418801847024816e-12,-6.7009564374203436e-12,-7.0091795160465744e-12,-7.7823664614455128e-12,-9.0865155357900026e-12,-1.1120532927919541e-11,-1.4287419212385646e-11,-1.9403122214888325e-11,-2.8293912072203778e-11,-4.5888077558862548e-11,-9.1139192424556324e-11,-3.6220019481754649e-10,3.2249905639557048e-10,1.4392526987441962e-10,1.0932969206363644e-10,9.9415979071905159e-11,9.9799982256341291e-11,1.072307898563611e-10,1.2160647426518542e-10,1.44695303453736e-10,1.8049201173453232e-10,2.3697432837761465e-10,3.3096846754900672e-10,5.0326801726160465e-10,8.8115230184503867e-10,2.1471603689878432e-09,-3.131401951296766e-08,-2.649727574599184e-09,-1.6833921949090425e-09,-1.4152811791257358e-09,-1.3531240362711053e-09,-1.4017462394467544e-09,-1.5413073346433116e-09,-1.7820764654350829e-09,-2.159655461329491e-09,-2.7473965028076731e-09,-3.6943009721446266e-09,-5.33377892283653e-09,-8.5650163128716892e-09,-1.684499709483568e-08,-6.6380938642910266e-08,5.8257338739430652e-08,2.5762516847788767e-08,1.9373797090690441e-08,1.7437075060675028e-08,1.7323887290097039e-08,1.8420394846995806e-08,2.0671519997068423e-08,2.4337695064017885e-08,3.0037875662715266e-08,3.9019064455664955e-08,5.3915084245756303e-08,8.1107161671274896e-08,1.4049526268925478e-07,3.3881723246908275e-07,-4.8163807628221806e-06,-4.0814799194556827e-07,-2.5654507587493737e-07,-2.1331897473623648e-07,-2.016838436945927e-07,-2.0658956528194464e-07,-2.2459428891891986e-07,-2.5672941482552322e-07,-3.075703478733846e-07,-3.8678194041038087e-07,-5.1408622534036133e-07,-7.3363139060319016e-07,-1.1643963281353612e-06,-2.2637067114344012e-06,-8.8297058901439019e-06,7.6244657954366033e-06,3.3350063698187856e-06,2.4783128741856878e-06,2.2037091090371624e-06,2.1627725847372172e-06,2.2714709699357434e-06,2.5175984317778483e-06,2.9272736918782989e-06,3.5677064160468978e-06,4.5761564955152186e-06,6.2432076215002181e-06,9.2728054342003144e-06,1.5858847672870071e-05,3.7772438596578703e-05,-0.00052226539873898633,-4.4227505084778013e-05,-2.744544100156021e-05,-2.2521414279425177e-05,-2.1009898850314527e-05,-2.1232202981821106e-05,-2.2770513221414203e-05,-2.5674002991356754e-05,-3.0336423795658067e-05,-3.7622374129318861e-05,-4.9310477656812561e-05,-6.9385880158777838e-05,-0.00010858426169331872,-0.00020815564983154934,-0.00080165852534630358,0.000679353880230817,0.00029315990154078525,0.00021471336479354824,0.00018812414852743727,0.00018189433339853766,0.00018818081842094389,0.00020542788189740948,0.00023522806583800912,0.00028230419924613086,0.00035651804705010194,0.00047884430564476397,0.00070010933086846238,0.0011786337038746011,0.0027640447712959861,-0.037067994506163153,-0.0031262658395481905,-0.0019091754476814723,-0.0015410763386202329,-0.0014138734693146494,-0.0014049621116933113,-0.0014813450564744358,-0.0016418165889394393,-0.0019066780227003238,-0.0023236814429132128,-0.002992437372767969,-0.0041366928103860594,-0.0063591101642202765,-0.011974948147215626,-0.045360022054971159,0.037577076855793368,0.015933923870771086,0.011455519521227555,0.0098491148413482402,0.0093426159368672074,0.0094804973685816574,0.010149268156237141,0.011394575560205058,0.013405235618862006,0.016592120032646842,0.021837104362064035,0.031280268648192097,0.051586264847606034,0.1185299881411533,-1.5342957327681079,-0.12819278854262259,-0.076640592861051834,-0.060531101310529335,-0.054320899809430633,-0.052783760619631866,-0.054406867512203375,-0.058934171864064216,-0.066872561082707255,-0.079608142382538008,-0.10011484241279538,-0.13511512651005089,-0.20273081606225063,-0.37257501637139678,-1.3788394816625802,1.1090160109596945,0.45888112052518942,0.32153358566769435,0.26929782103780758,0.24874462368023786,0.24569646122528366,0.2559283989281203,0.27946634376964835,0.31965517890075912,0.38451337195047014,0.4916227770890253,0.68384997400102276,1.0947788261847644,2.4417289297980864,-30.22267650950328,-2.4765675460250534,-1.434923300579205,-1.0974314338590909,-0.95307221503972928,-0.89570289415521287,-0.8924120587272153,-0.93382297767081501,-1.0229672507393368,-1.1749264353715103,-1.4246414931153606,-1.8525708639436573,-2.6764951486433599,-4.7335230617486754,-16.869186760094756,12.977372904586035,5.1590789759833831,3.4670645885367972,2.7820808231727905,2.4595304325318281,2.3227948790061257,2.310891799467603,2.4074386601243578,2.6240069423565915,3.0041482856532684,3.6510020977284969,4.8209494609606409,7.3164663583684826,15.451986342948087,-178.2195215239461,-13.937696716260875,-7.606272498089786,-5.4668951468160092,-4.4520789760224684,-3.9145485120586385,-3.6400176659417833,-3.5455394056782983,-3.6051747659849163,-3.8316303915534946,-4.2847798841060456,-5.1198105595752867,-6.7695027214749999,-10.9094406305788,-35.300024442143865,24.371320313103595,8.6859335612314652,5.1902957222057164,3.6714153572962664,2.8326777419914273,2.3070704975488745,1.9509300911054857,1.6965978680445783,1.5081022411033274,1.3646012897331694,1.2532174911517806,1.1655899038775093,1.0960718817966173,1.0407279972828243,0.99674427168474511,0.96206730349555825,0.9351743004958758,0.91492262693525361,0.90044853772197553,0.89109721230825978,0.88637397669566642,0.88590941071577811,0.88943420967992548,0.89676090188708302,0.9077705130619268,0.92240286502991553,0.9406494541968401,0.96254866381017801,0.98818235475920291,1.0176739348636954,1.0511871616191284,1.0889267549425661,1.1311384802830169,1.1781109950172979,1.2301786863321844,1.2877236784878969,1.3511799201903354,1.4210383446911485,1.4978504670432813,1.5822363441987362,1.6748896987624622,1.7765865022103686,1.8881951737996618,2.0106847159327175,2.1451372098288695,2.2927625290926605,2.4549098514176455,2.6330885984232646,2.8289836801847734,3.0444784422013851,3.2816815491720219,3.5429501089328137,3.8309227584243732,4.1485583922588223,4.4991690048389943,4.8864739556001426,5.3146432915507162,5.7883592125660774,6.3128860964289943,6.8941456481627066,7.538787560395618,8.2543110284445991,9.0491658170727245,9.9328598297059685,10.91613581812231,12.011121943739433,13.231492907809059,14.592728547522515,16.112339055739049,17.810107241776855,19.708469295882203,21.832853102849633,24.212043887211696,26.878748235934605,29.870082554673509,33.228236602317033,37.001094885155865,41.2431977162518,46.016630048496232,51.391991738833539,57.449840335669151,64.282045317506004,71.993272129871215,80.703160069182459,90.548394440304946,101.68498564988407,114.29157431124763,128.57261541967003,144.76189270260966,163.12756052983531,183.97690409335019,207.66254817578042,234.58865246446248,265.21983556442297,300.08999486436829,339.81211398239981,385.09203583185609,436.74220659138825,495.69700401072345,563.03409667833489,639.99594971444355,728.01387775552007,828.74132478266722,944.08765258284757,1076.2560344823937,1227.7955473205625,1401.6531861164963,1601.2402320861729,1830.5012907070461,2094.0096272958131,2397.0656580484697,2745.8080676898471,3147.3645883623835,3610.0088146988669,4143.3375476626816,4758.5102854995439,5468.4946042938127,6288.3705410181055,7235.6973674212222,8330.8724173610281,9597.6928685764706,11063.872055584477,12761.715875535325,14728.901741998452,17009.42639085375,19654.548230598295,22724.23497676929,26288.522106252913,30429.280798513239,35242.262047509998,40839.500847317795,47352.242102851676,54933.898208120067,63764.507476817955,74055.008329804143,86052.766960822337,100047.99620036839,116381.570247817,135453.02379784302,157732.44406663981,183772.05807441715,214221.15213790373,249843.45694195735,291537.70119943732,340362.65070226783,397563.07578553521,464607.81971307116,543227.52442962374,635463.00098003342,743721.8082404068,870847.2248733067,1020190.5037526768,1195715.7005526994,1402104.920473414,1644892.863224729,1930624.6843991738,2267048.5828458723,2663319.4178205472,3130291.4263204937,3680815.6122732204,4330118.9918126632,5096250.863618508,6000614.1354814824,7068614.1737125004,8330351.5469825976,9821608.626348244,11584864.596436767,13670586.841623364,16138755.493811633,19060726.89775569,22521238.436637141,26621243.740006976,31480858.310779862,37243101.185804114,44078323.86097198,52189506.975339159,61818741.802379116,73254260.960309178,86840309.393766716,102987508.00169384,122185998.20413017,145021046.84067392,172192160.9832865,204533957.78894421,243045304.96650994,288920169.94108379,343586707.31292242,408753774.95164305,486467971.85827661,579176291.97369373,689813178.83948231,821893396.70102561,979629608.88921118,1168072628.5413978,1393280175.7595522,1662524063.6096683,1984519288.0011075,2369740721.7567806,2830763791.7678947,3382695487.456943,4043689824.701611,4835581373.3701782,5784589465.8260536,6922287922.8437958,8286655160.6679029,9923402166.3653412,11887564117.179855,14245423009.504648,17076873666.418917,20478068920.563683,24565047458.448448,29477690860.614243,35384726061.171211,42489735520.113327,51038561547.433998,61327622824.598915,73715285215.269867,88634336452.860031,106607754076.33051,128267687822.75359,154378871120.52185,185865032674.22745,223844907245.32913,269671958807.44467,324984587608.16779,391766690359.8407,472421209450.13458,569860960282.40808,687611595425.49719,829951582165.80811,1002067539231.6243,1210250579708.0364,1462133663544.4219,1766980402052.585,2136036561239.6406,2582957989010.4438,3124331719740.9824,3780330652437.4907,4575411370394.9365,5539364479626.917,6708394823425.1738,8126538834063.2969,9847373131194.4395,11936098943305.248,14472085670327.215,17551975516874.939,21293473924693.727,25839978468686.883,31366233118784.285,38085441326584.234,46256935023012.07,56197600126168.031,68293793823573.922,83016947762873.922,100942450345359.86,122772752026288.59,149365645052236.44,181768884942545.94,221262586216571.03,269411150722281.41,328126887401255.62,399747974632881.81,487136686940061.25,593786483080430.62,723980042906664.62,882956376138417,1077129236632905.4,1314352480512584.5,1604245791405823,1958594600175031,2391841214741448.5,2921688103692450,3569839118025729,4362910401975275,5333550099872281,6521851338070880,7976908196847720,9759093425790832,11942496673175202,14618107320550400,17897695771103130,21918592051718180,26849570509545276,32898098263371604,40319265462074984,49426790034302064,60606581862366208,74333465361886400,91192316288318096,1.1190155024363832e+17,1.3734726792314509e+17,1.6862021482817395e+17,2.0706398672662355e+17,2.5433401993156554e+17,3.1247042952738893e+17,3.8398796589894586e+17,4.7198713675824774e+17,5.8029150427743053e+17,7.1361735950158374e+17,8.7778345426970086e+17,1.0799703031334287e+18,1.3290484715481288e+18,1.6359464331088607e+18,2.0141821216538148e+18,2.4804441395252403e+18,3.0553494019851105e+18,3.7643733739845939e+18,4.6390018731259832e+18,5.7181575104111667e+18,7.0499666224016701e+18,8.6939484253782774e+18,1.0723727847261538e+19,1.3230398003975006e+19,1.6326783750360324e+19,2.0152252992369967e+19,2.4879635525732737e+19,3.0722853232614449e+19,3.7946863907252576e+19,4.6879906055742808e+19,5.7928697706444128e+19,7.1597305688637956e+19,8.8510576509468672e+19,1.0944323743265148e+20,1.3535604717652848e+20,1.6744071295117741e+20,2.0717571074807303e+20,2.5639718155501257e+20,3.1737950476758378e+20,3.9295063719838089e+20,4.8662040257743762e+20,6.0274766703554553e+20,7.4674682256927805e+20,9.2534474709860837e+20,1.1469006429005437e+21,1.4218042172450823e+21,1.7629714907609579e+21,2.186462289762905e+21,2.712249435234261e+21,3.3651770794689529e+21,4.1761798803574998e+21,5.1836777185989047e+21,6.4355642655669622e+21,7.9914363529765742e+21,9.9254993598381252e+21,1.2330166139488244e+22,1.5320546920067701e+22,1.9040051808533666e+22,2.3667382916094322e+22,2.9425262415820534e+22,3.6591329547491041e+22,4.5511748094870849e+22,5.6618201684939763e+22,7.0449550323074158e+22,8.7676757018612905e+22,1.0913830432875351e+23,1.3588019105804713e+23,1.6920806970842968e+23,2.1075200877079686e+23,2.6254748295981661e+23,3.2713667618519772e+23,4.0769521480462926e+23,5.0819074369502285e+23,6.3358138177957047e+23,7.9006413085140386e+23,9.8538586735703272e+23,1.2292402738754057e+24,1.5337273223926029e+24,1.9140041369113918e+24,2.3890250461727726e+24,2.9825066217172276e+24,3.7241295871515842e+24,4.6510454067253029e+24,5.8097651210525714e+24,7.2585278288822634e+24,9.0702711358115303e+24,1.1336357215938771e+25,1.4171247512390545e+25,1.7718368616935958e+25,2.2157611194161019e+25,2.7714057237851002e+25,3.467030934785501e+25,4.3380598888893563e+25,5.4289191665997316e+25,6.795336999682946e+25,8.507230575591605e+25,1.0652334061085201e+26,1.3340758148198784e+26,1.6710721271569669e+26,2.0935754803876107e+26,2.6233762844938193e+26,3.2878621260979402e+26,4.1213739671993681e+26,5.1671179312301422e+26,6.4793650042499913e+26,8.1263222227829696e+26,1.0193725921789049e+27,1.2789365173382465e+27,1.6048777161417623e+27,2.0142419305115875e+27,2.5284702528521114e+27,3.1745370512649525e+27,3.9863836549679942e+27,5.0067249677580594e+27,6.2893660725543615e+27,7.901923830571115e+27,9.9296554624840293e+27,1.2479888530781357e+28,1.5687806742178071e+28,1.9723708046305313e+28,2.480216110966818e+28,3.1193558550228305e+28,3.9238696640837826e+28,4.9367177240468943e+28,6.2120637706663702e+28,7.8182080151324913e+28,9.8412907405079503e+28,1.2390048759633207e+29,1.5601428659277103e+29,1.9648468784181106e+29,2.4749467722430629e+29,3.1179966826776522e+29,3.9287816477555236e+29,4.9512222261581157e+29,6.2407826170637132e+29,7.8675158621500348e+29,9.9199152731926526e+29,1.2509786292545558e+30,1.5778410104860879e+30,1.9904342708193561e+30,2.5113446427921621e+30,3.1690779114927488e+30,3.9997261979004348e+30,5.0489165066682674e+30,6.3743591502608389e+30,8.049059145415547e+30,1.0165384089131051e+31,1.2840217720678865e+31,1.6221489921687291e+31,2.0496452032504556e+31,2.590216555118948e+31,3.2738798228087577e+31,4.1386481516098643e+31,5.2327026035525748e+31,6.6169763101062584e+31,8.368772196601096e+31,1.0586012319650495e+32,1.3392799589656353e+32,1.6946441462421908e+32,2.1446364225807583e+32,2.7145428453628115e+32,3.4364294528957858e+32,4.3509663065945007e+32,5.5097438833449676e+32,6.9782151458998789e+32,8.8394906559957274e+32,1.1198870948885396e+33,1.4190184476987246e+33,1.7983263037939546e+33,2.2793733049455597e+33,2.8895404417883337e+33,3.6636021777479868e+33,4.6457293545364938e+33,5.8920364253419139e+33,7.4738214125390217e+33,9.4817499857013634e+33,1.2030787430724465e+34,1.5267596503614933e+34,1.9377902748897993e+34,2.4598785201052084e+34,3.1230557466611901e+34,3.9656677773061215e+34,5.0363026573771176e+34,6.3970177809071411e+34,8.1264695109426271e+34,1.0325146851330325e+35,1.3120628972217236e+35,1.6675208194263061e+35,2.1196172723245779e+35,2.6946449416188013e+35,3.4262177332150116e+35,4.3569844075278107e+35,5.5414842392844216e+35,7.0489359125029386e+35,8.9678804905444722e+35,1.1410722742158574e+36,1.4521284268552517e+36,1.8482202431881835e+36,2.3527224497417078e+36,2.9953669016974887e+36,3.8140446883250341e+36,4.8572384938437644e+36,6.186560087048159e+36,7.8809159047117803e+36,1.004060877307505e+37,1.2794131221347212e+37,1.6304864355827651e+37,2.0782162555413577e+37,2.6492299796198822e+37,3.3776566428842159e+37,4.3069744703215542e+37,5.4926773566598824e+37,7.005875799076256e+37,8.9370773960014122e+37,1.1402364473223113e+38,1.4549524780998746e+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..df6ad8d015e8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/fixtures/r/runner.R @@ -0,0 +1,123 @@ +#!/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() ); + + # Convert doubles to IEEE-754 float32 and back: + to_float32 <- function( x ) { + return( readBin( writeBin( x, raw(), size = 4L ), 'numeric', n = length( x ), size = 4L ) ); + } + + # Generate integer test data: + x <- seq( 1L, 34L, 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( -34.099, 34.80, length.out = 1000L ); + x <- to_float32( x ); + 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..b3446a828124 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/test.js @@ -0,0 +1,150 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var incrspace = require( '@stdlib/array/base/incrspace' ); +var isAlmostSameValuef = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); +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 > 34.844...`, the function returns positive infinity', function test( t ) { + var values = incrspace( 34.9, 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 < -34.195...`, the function returns zero', function test( t ) { + var values = incrspace( -34.2, -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 v; + var i; + + for ( i = 0; i < data1.length; i++ ) { + v = gammaf( data1[ i ] ); + t.strictEqual( isAlmostSameValuef( v, expected1[ i ], 3 ), true, 'within tolerance. x: ' + data1[ i ] + '. Value: ' + v + '. Expected: ' + expected1[ i ] ); + } + t.end(); +}); + +tape( 'the function evaluates the gamma function (decimal values)', function test( t ) { + var v; + var i; + + for ( i = 0; i < data2.length; i++ ) { + v = gammaf( data2[ i ] ); + t.strictEqual( isAlmostSameValuef( v, expected2[ i ], 5 ), true, 'within tolerance. x: ' + data2[ i ] + '. Value: ' + v + '. Expected: ' + expected2[ i ] ); + } + 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 x; + var v; + + x = 0.000009999999747378752; // f32(1e-5) — triggers x < 1e-4 check + v = gammaf( x ); + + expected = 9.9999422e+4; + + t.strictEquals( isAlmostSameValuef( v, expected, 1 ), true, 'within tolerance. x: ' + x + '. Value: ' + v + + '. Expected: ' + expected ); + 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..0c3df1037521 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/gammaf/test/test.native.js @@ -0,0 +1,159 @@ +/** +* @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 PINF = require( '@stdlib/constants/float32/pinf' ); +var isAlmostSameValuef = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); +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 > 34.844...`, the function returns positive infinity', function test( t ) { + var values = incrspace( 34.9, 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 < -34.195...`, the function returns zero', function test( t ) { + var values = incrspace( -34.2, -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 v; + var i; + + for ( i = 0; i < data1.length; i++ ) { + v = gammaf( data1[ i ] ); + t.strictEqual( isAlmostSameValuef( v, expected1[ i ], 3 ), true, 'within tolerance. x: ' + data1[ i ] + '. Value: ' + v + '. Expected: ' + expected1[ i ] ); + } + t.end(); +}); + +tape( 'the function evaluates the gamma function (decimal values)', opts, function test( t ) { + var v; + var i; + + for ( i = 0; i < data2.length; i++ ) { + v = gammaf( data2[ i ] ); + t.strictEqual( isAlmostSameValuef( v, expected2[ i ], 5 ), true, 'within tolerance. x: ' + data2[ i ] + '. Value: ' + v + '. Expected: ' + expected2[ i ] ); + } + 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 x; + var v; + + x = 0.000009999999747378752; // f32(1e-5) — triggers x < 1e-4 check + v = gammaf( x ); + + expected = 9.9999422e+4; + + t.strictEquals( isAlmostSameValuef( v, expected, 1 ), true, 'within tolerance. x: ' + x + '. Value: ' + v + + '. Expected: ' + expected ); + t.end(); +});