From 55c6ebff4e702f255b5373e6cea747b320fe0b3a Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Thu, 19 Dec 2024 00:12:22 +0530 Subject: [PATCH 1/5] feat: add-betainc --- .../@stdlib/math/base/special/betainc/LICENSE | 215 ++++++++++++++++++ .../math/base/special/betainc/README.md | 96 ++++++++ .../betainc/benchmark/benchmark.native.js | 65 ++++++ .../math/base/special/betainc/binding.gyp | 170 ++++++++++++++ .../base/special/betainc/examples/c/Makefile | 146 ++++++++++++ .../base/special/betainc/examples/c/example.c | 35 +++ .../math/base/special/betainc/include.gypi | 170 ++++++++++++++ .../stdlib/math/base/special/betainc.h | 38 ++++ .../math/base/special/betainc/lib/native.js | 57 +++++ .../math/base/special/betainc/manifest.json | 79 +++++++ .../math/base/special/betainc/package.json | 3 + .../math/base/special/betainc/src/Makefile | 70 ++++++ .../math/base/special/betainc/src/addon.c | 22 ++ .../math/base/special/betainc/src/main.c | 57 +++++ .../base/special/betainc/test/test.native.js | 163 +++++++++++++ 15 files changed, 1386 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/LICENSE create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/include/stdlib/math/base/special/betainc.h create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/betainc/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/LICENSE b/lib/node_modules/@stdlib/math/base/special/betainc/LICENSE new file mode 100644 index 000000000000..135a9f487ab1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/betainc/LICENSE @@ -0,0 +1,215 @@ + file line number Original file line Diff line number Diff line change +@@ -0,0 +1,213 @@ + + 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: + +* Go + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/README.md b/lib/node_modules/@stdlib/math/base/special/betainc/README.md index 110e6e29453f..370346c8906a 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/README.md +++ b/lib/node_modules/@stdlib/math/base/special/betainc/README.md @@ -122,6 +122,102 @@ for ( i = 0; i < 100; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/bernoulli/cdf.h" +``` + +#### stdlib_base_betainc( x, a, b\[, regularized\[, upper]] ) + +Evaluates the incomplete beta function. + +```c +double y = stdlib_base_betainc( 0.5, 2.0, 2.0 ); +// returns ~0.5 + +y = stdlib_base_betainc( 0.5, 2.0, 2.0, false ); +// returns ~0.083 + +y = stdlib_base_betainc( 0.2, 1.0, 2.0 ); +// returns ~0.36 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **a**: `[in] double` + +```c +double stdlib_base_betainc( const double x, const double alpha, const double beta ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/betainc.h" +#include +#include + +int main( void ) { + double x; + double a; + double b; + int i; + + for ( i = 0; i < 100; i++ ) { + x = ( (double)rand() / (double)RAND_MAX ); + a = ( (double)rand() / (double)RAND_MAX ) * 10.0; + b = ( (double)rand() / (double)RAND_MAX ) * 10.0; + printf( "x: %1f, \t a: %1f, \t b: %1f, \t f(x,a,b): %1f\n", x, a , b ); + } +} +``` + +
+ + + +
+ + + @@ -193,19 +190,27 @@ double stdlib_base_betainc( const double x, const double alpha, const double bet #include #include +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v*(max-min) ); +} + int main( void ) { - double x; + double x; double a; - double b; - int i; - - for ( i = 0; i < 100; i++ ) { - x = ( (double)rand() / (double)RAND_MAX ); - a = ( (double)rand() / (double)RAND_MAX ) * 10.0; - b = ( (double)rand() / (double)RAND_MAX ) * 10.0; - printf( "x: %1f, \t a: %1f, \t b: %1f, \t f(x,a,b): %1f\n", x, a , b ); - } + double b; + double v; + int i; + + for ( i = 0; i < 100; i++ ) { + x = random_uniform( 0.0, 1.0 ); + a = random_uniform( 0.0, 10.0 ); + b = random_uniform( 0.0, 10.0 ); + v = stdlib_base_betainc( x, a, b, true, false ); + printf( "x: %lf, a: %lf, b: %lf, f(x,a,b): %lf\n", x, a, b, v ); + } } + ``` diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/betainc/benchmark/benchmark.native.js index cbb7943e52fb..52e1760328d7 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/betainc/benchmark/benchmark.native.js @@ -22,9 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); var EPS = require( '@stdlib/constants/float64/eps' ); var pkg = require( './../package.json' ).name; @@ -39,19 +40,20 @@ var opts = { // MAIN // -bench( pkg+'::native', opts, function benchmark( assert ) { +bench( format( '%s::native:regularized=true,upper=true', pkg ), opts, function benchmark( assert ) { var x; var y; var a; var b; var i; + x = uniform( 100, 0.0, 1.0 ); + a = uniform( 100, EPS, 1000.0 ); + b = uniform( 100, EPS, 1000.0 ); + assert.tic(); for ( i = 0; i < assert.iterations; i++ ) { - x = randu(); - a = ( randu()*1000.0 ) + EPS; - b = ( randu()*1000.0 ) + EPS; - y = betainc( x, a, b ); + y = betainc( x[ i % x.length ], a[ i % a.length ], b[ i % b.length ] ); if ( isnan( y ) ) { assert.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/betainc/benchmark/c/native/Makefile new file mode 100644 index 000000000000..979768abbcec --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/betainc/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 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 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/betainc/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/betainc/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..5a56db8ca1f4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/betainc/benchmark/c/native/benchmark.c @@ -0,0 +1,143 @@ +/** +* @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/betainc.h" +#include "stdlib/constants/float64/eps.h" +#include +#include +#include +#include +#include + +#define NAME "betainc" +#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 double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v*(max-min) ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double x[ 100 ]; + double a[ 100 ]; + double b[ 100 ]; + double elapsed; + double y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + x[ i ] = random_uniform( 0.0, 1.0 ); + a[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 1000.0 ); + b[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 1000.0 ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_betainc( x[ i % 100 ], a[ i % 100 ], b[ i % 100 ], false, true ); + 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::cephes::%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/betainc/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/betainc/examples/c/Makefile index d53ef397c77d..c8f8e9a1517b 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/examples/c/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/betainc/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# 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. @@ -143,4 +143,4 @@ run: $(c_targets) clean: $(QUIET) -rm -f *.o *.out -.PHONY: clean \ No newline at end of file +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/betainc/examples/c/example.c index cf9b8493ff23..a9a35d3f26f3 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/betainc/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. @@ -20,16 +20,23 @@ #include #include +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v*(max-min) ); +} + int main( void ) { double x; - double a; + double a; double b; + double v; int i; for ( i = 0; i < 100; i++ ) { - x = ( (double)rand() / (double)RAND_MAX ); - a = ( (double)rand() / (double)RAND_MAX ) * 10.0; - b = ( (double)rand() / (double)RAND_MAX ) * 10.0; - printf( "x: %1f, \t a: %1f, \t b: %1f, \t f(x,a,b): %1f\n", x, a , b ); + x = random_uniform( 0.0, 1.0 ); + a = random_uniform( 0.0, 10.0 ); + b = random_uniform( 0.0, 10.0 ); + v = stdlib_base_betainc( x, a, b, true, false ); + printf( "x: %lf, a: %lf, b: %lf, f(x,a,b): %lf\n", x, a, b, v ); } -} \ No newline at end of file +} diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/include/stdlib/math/base/special/betainc.h b/lib/node_modules/@stdlib/math/base/special/betainc/include/stdlib/math/base/special/betainc.h index d67988ab3017..b15c2bff014f 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/include/stdlib/math/base/special/betainc.h +++ b/lib/node_modules/@stdlib/math/base/special/betainc/include/stdlib/math/base/special/betainc.h @@ -18,6 +18,7 @@ #ifndef STDLIB_MATH_BASE_SPECIAL_BETAINC_H #define STDLIB_MATH_BASE_SPECIAL_BETAINC_H +#include /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. @@ -29,7 +30,7 @@ extern "C" { /** * Evaluates the incomplete beta function. */ -double stdlib_base_betainc( const double x, const double alpha, const double beta ); +double stdlib_base_betainc( const double x, const double a, const double b, const bool regularized, const bool upper ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/lib/native.js b/lib/node_modules/@stdlib/math/base/special/betainc/lib/native.js index cbc2ae007e19..604335350d93 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/betainc/lib/native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. @@ -28,6 +28,7 @@ var addon = require( './../src/addon.node' ); /** * Evaluates the incomplete beta function. * +* @private * @param {Probability} x - function parameter * @param {NonNegativeNumber} a - function parameter * @param {NonNegativeNumber} b - function parameter @@ -48,7 +49,7 @@ var addon = require( './../src/addon.node' ); * // returns 0.36 */ function betainc( x, a, b, regularized, upper ) { - return addon( x, a, b, regularized, upper ); + return addon( x, a, b, regularized, upper ); } diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/manifest.json b/lib/node_modules/@stdlib/math/base/special/betainc/manifest.json index 259fe5e97152..c0f445957d08 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/betainc/manifest.json @@ -38,9 +38,11 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/napi/binary", - "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/round" + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-bool", + "@stdlib/math/base/special/kernel-betainc" ] }, { @@ -55,8 +57,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/round" + "@stdlib/math/base/special/kernel-betainc", + "@stdlib/constants/float64/eps" ] }, { @@ -71,9 +73,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/round" + "@stdlib/math/base/special/kernel-betainc" ] } ] -} \ No newline at end of file +} diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/src/Makefile b/lib/node_modules/@stdlib/math/base/special/betainc/src/Makefile index 81bb164286c3..2caf905cedbe 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/src/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/betainc/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# 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. @@ -67,4 +67,4 @@ clean-addon: #/ clean: clean-addon -.PHONY: clean \ No newline at end of file +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/src/addon.c b/lib/node_modules/@stdlib/math/base/special/betainc/src/addon.c index 66941c60ba8b..04d2f4869c33 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/betainc/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. @@ -17,6 +17,28 @@ */ #include "stdlib/math/base/special/betainc.h" -#include "stdlib/math/base/napi/ternary.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_bool.h" +#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/export.h" +#include -STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( stdlib_base_betainc ) +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 5 ); + STDLIB_NAPI_ARGV_DOUBLE( env, x, argv, 0 ); + STDLIB_NAPI_ARGV_DOUBLE( env, a, argv, 1 ); + STDLIB_NAPI_ARGV_DOUBLE( env, b, argv, 2 ); + STDLIB_NAPI_ARGV_BOOL( env, regularized, argv, 3 ); + STDLIB_NAPI_ARGV_BOOL( env, upper, argv, 4 ); + stdlib_base_betainc( x, a, b, regularized, upper ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c b/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c index df11b7685fd0..fc9402e1cb3b 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. @@ -24,34 +24,26 @@ */ #include "stdlib/math/base/special/betainc.h" -#include "stdlib/math/base/special/kernelbetainc.h" +#include "stdlib/math/base/special/kernel_betainc.h" #include /** * Evaluates the incomplete beta function. * -* @param a first input value -* @param b second input value +* @param x function parameter +* @param a function parameter +* @param b function parameter * @param regularized boolean indicating if the function should evaluate the regularized or non-regularized incomplete beta function. -* @param upper boolean indicating if the function should return the upper tail of the incomplete beta function. -* @returns natural logarithm of beta function +* @param upper boolean indicating if the function should return the upper tail of the incomplete beta function. +* @return function value * * @example * double y = stdlib_base_betainc( 0.5, 2.0, 2.0 ); * // returns ~0.5 -* -* @example -* double y = stdlib_base_betainc( 0.5, 2.0, 2.0, false ); -* // returns ~0.083 -* -* @example -* double y = stdlib_base_betainc( 0.2, 1.0, 2.0 ); -* // returns ~0.36 */ double stdlib_base_betainc( const double x, const double a, const double b, const bool regularized, const bool upper ) { -double out = [ 0.0, 0.0 ]; - bool regularized = ( regularized == false ) ? false : true; // eslint-disable-line no-unneeded-ternary - bool upper = ( upper == true ) ? true : false; // eslint-disable-line no-unneeded-ternary - stdlib_base_kernelBetainc( x, a, b, regularized, upper, out, 1, 0 ); + double out[ 2 ]; + double derivative; + stdlib_base_kernel_betainc( x, a, b, regularized, upper, out, &derivative ); return out[ 0 ]; } diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/test/test.js b/lib/node_modules/@stdlib/math/base/special/betainc/test/test.js index b839f64be596..34edf92bba6d 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/betainc/test/test.js @@ -22,8 +22,7 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var EPS = require( '@stdlib/constants/float64/eps' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var betainc = require( './../lib' ); @@ -71,84 +70,52 @@ tape( 'the function returns `NaN` negative `a` or `b`', function test( t ) { tape( 'the function evaluates the lower regularized incomplete beta function', function test( t ) { var expected; - var delta; - var tol; var i; var y; expected = lowerRegularized; for ( i = 0; i < x.length; i++ ) { y = betainc( x[i], a[i], b[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+'. a: '+a[i]+'. b: '+b[i]+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 50.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 90 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the lower unregularized incomplete beta function', function test( t ) { var expected; - var delta; - var tol; var i; var y; expected = lowerUnregularized; for ( i = 0; i < x.length; i++ ) { y = betainc( x[i], a[i], b[i], false ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+'. a: '+a[i]+'. b: '+b[i]+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 80.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 100 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the upper regularized incomplete beta function', function test( t ) { var expected; - var delta; - var tol; var i; var y; expected = upperRegularized; for ( i = 0; i < x.length; i++ ) { y = betainc( x[i], a[i], b[i], true, true ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+'. a: '+a[i]+'. b: '+b[i]+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 50.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 100 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the upper unregularized incomplete beta function', function test( t ) { var expected; - var delta; - var tol; var i; var y; expected = upperUnregularized; for ( i = 0; i < x.length; i++ ) { y = betainc( x[i], a[i], b[i], false, true ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+'. a: '+a[i]+'. b: '+b[i]+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 80.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 120 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/betainc/test/test.native.js index 4954fe696931..c6ab2c678566 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/betainc/test/test.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. @@ -24,8 +24,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var EPS = require( '@stdlib/constants/float64/eps' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); // FIXTURES // @@ -80,84 +79,52 @@ tape( 'the function returns `NaN` negative `a` or `b`', opts, function test( t ) tape( 'the function evaluates the lower regularized incomplete beta function', opts, function test( t ) { var expected; - var delta; - var tol; var i; var y; expected = lowerRegularized; for ( i = 0; i < x.length; i++ ) { y = betainc( x[i], a[i], b[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+'. a: '+a[i]+'. b: '+b[i]+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 50.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 4 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the lower unregularized incomplete beta function', opts, function test( t ) { var expected; - var delta; - var tol; var i; var y; expected = lowerUnregularized; for ( i = 0; i < x.length; i++ ) { y = betainc( x[i], a[i], b[i], false ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+'. a: '+a[i]+'. b: '+b[i]+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 80.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 4 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the upper regularized incomplete beta function', opts, function test( t ) { var expected; - var delta; - var tol; var i; var y; expected = upperRegularized; for ( i = 0; i < x.length; i++ ) { y = betainc( x[i], a[i], b[i], true, true ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+'. a: '+a[i]+'. b: '+b[i]+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 50.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 4 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the upper unregularized incomplete beta function', opts, function test( t ) { var expected; - var delta; - var tol; var i; var y; expected = upperUnregularized; for ( i = 0; i < x.length; i++ ) { y = betainc( x[i], a[i], b[i], false, true ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+'. a: '+a[i]+'. b: '+b[i]+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 80.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 4 ), true, 'returns expected value' ); } t.end(); }); From b5244c10a62a4e031c52081b96f2630c20a12746 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Fri, 10 Jul 2026 19:57:21 +0530 Subject: [PATCH 3/5] chore: sync C implementation with JS implementation --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/betainc/src/main.c | 3 +++ .../@stdlib/math/base/special/betainc/test/test.native.js | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c b/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c index fc9402e1cb3b..9b15a1d6f249 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c @@ -44,6 +44,9 @@ double stdlib_base_betainc( const double x, const double a, const double b, const bool regularized, const bool upper ) { double out[ 2 ]; double derivative; + + regularized = ( regularized == false ) ? false : true; // eslint-disable-line no-unneeded-ternary + upper = ( upper == true ) ? true : false; // eslint-disable-line no-unneeded-ternary stdlib_base_kernel_betainc( x, a, b, regularized, upper, out, &derivative ); return out[ 0 ]; } diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/betainc/test/test.native.js index c6ab2c678566..870974e7148b 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/betainc/test/test.native.js @@ -85,7 +85,7 @@ tape( 'the function evaluates the lower regularized incomplete beta function', o expected = lowerRegularized; for ( i = 0; i < x.length; i++ ) { y = betainc( x[i], a[i], b[i] ); - t.strictEqual( isAlmostSameValue( y, expected[ i ], 4 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 90 ), true, 'returns expected value' ); } t.end(); }); @@ -98,7 +98,7 @@ tape( 'the function evaluates the lower unregularized incomplete beta function', expected = lowerUnregularized; for ( i = 0; i < x.length; i++ ) { y = betainc( x[i], a[i], b[i], false ); - t.strictEqual( isAlmostSameValue( y, expected[ i ], 4 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 100 ), true, 'returns expected value' ); } t.end(); }); @@ -111,7 +111,7 @@ tape( 'the function evaluates the upper regularized incomplete beta function', o expected = upperRegularized; for ( i = 0; i < x.length; i++ ) { y = betainc( x[i], a[i], b[i], true, true ); - t.strictEqual( isAlmostSameValue( y, expected[ i ], 4 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 100 ), true, 'returns expected value' ); } t.end(); }); @@ -124,7 +124,7 @@ tape( 'the function evaluates the upper unregularized incomplete beta function', expected = upperUnregularized; for ( i = 0; i < x.length; i++ ) { y = betainc( x[i], a[i], b[i], false, true ); - t.strictEqual( isAlmostSameValue( y, expected[ i ], 4 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 120 ), true, 'returns expected value' ); } t.end(); }); From e52e7d53102e603558919b8ac5bcab9790414224 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Fri, 10 Jul 2026 20:01:35 +0530 Subject: [PATCH 4/5] chore: update C addon to return double instead of NULL --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/betainc/manifest.json | 1 + .../@stdlib/math/base/special/betainc/src/addon.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/manifest.json b/lib/node_modules/@stdlib/math/base/special/betainc/manifest.json index c0f445957d08..8a28d4e5e818 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/betainc/manifest.json @@ -42,6 +42,7 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-double", "@stdlib/napi/argv-bool", + "@stdlib/napi/create-double", "@stdlib/math/base/special/kernel-betainc" ] }, diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/src/addon.c b/lib/node_modules/@stdlib/math/base/special/betainc/src/addon.c index 04d2f4869c33..b24abec1a217 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/betainc/src/addon.c @@ -20,6 +20,7 @@ #include "stdlib/napi/argv.h" #include "stdlib/napi/argv_bool.h" #include "stdlib/napi/argv_double.h" +#include "stdlib/napi/create_double.h" #include "stdlib/napi/export.h" #include @@ -37,8 +38,8 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_DOUBLE( env, b, argv, 2 ); STDLIB_NAPI_ARGV_BOOL( env, regularized, argv, 3 ); STDLIB_NAPI_ARGV_BOOL( env, upper, argv, 4 ); - stdlib_base_betainc( x, a, b, regularized, upper ); - return NULL; + STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_base_betainc( x, a, b, regularized, upper ), out ); + return out; } STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) From 3643d83ee86932549bc0088094f358d90cdb26eb Mon Sep 17 00:00:00 2001 From: Neeraj Date: Fri, 10 Jul 2026 20:10:17 +0530 Subject: [PATCH 5/5] chore: remove const var for upper and regularized --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../special/betainc/include/stdlib/math/base/special/betainc.h | 2 +- lib/node_modules/@stdlib/math/base/special/betainc/src/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/include/stdlib/math/base/special/betainc.h b/lib/node_modules/@stdlib/math/base/special/betainc/include/stdlib/math/base/special/betainc.h index b15c2bff014f..fb282fed7cb5 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/include/stdlib/math/base/special/betainc.h +++ b/lib/node_modules/@stdlib/math/base/special/betainc/include/stdlib/math/base/special/betainc.h @@ -30,7 +30,7 @@ extern "C" { /** * Evaluates the incomplete beta function. */ -double stdlib_base_betainc( const double x, const double a, const double b, const bool regularized, const bool upper ); +double stdlib_base_betainc( const double x, const double a, const double b, bool regularized, bool upper ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c b/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c index 9b15a1d6f249..479e6bb97d86 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c @@ -41,7 +41,7 @@ * double y = stdlib_base_betainc( 0.5, 2.0, 2.0 ); * // returns ~0.5 */ -double stdlib_base_betainc( const double x, const double a, const double b, const bool regularized, const bool upper ) { +double stdlib_base_betainc( const double x, const double a, const double b, bool regularized, bool upper ) { double out[ 2 ]; double derivative;