From 75a21c0683f39e54d1a56db45315e523123554a8 Mon Sep 17 00:00:00 2001 From: officiallyanee Date: Sat, 14 Feb 2026 06:04:05 +0530 Subject: [PATCH 1/8] feat: add C & JS implementation of math/base/special/digammaf --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../math/base/special/digammaf/README.md | 241 ++++++++++++++++++ .../special/digammaf/benchmark/benchmark.js | 52 ++++ .../digammaf/benchmark/benchmark.native.js | 61 +++++ .../digammaf/benchmark/c/native/Makefile | 146 +++++++++++ .../digammaf/benchmark/c/native/benchmark.c | 133 ++++++++++ .../math/base/special/digammaf/binding.gyp | 167 ++++++++++++ .../docs/img/equation_digamma_function.svg | 63 +++++ .../math/base/special/digammaf/docs/repl.txt | 35 +++ .../special/digammaf/docs/types/index.d.ts | 60 +++++ .../base/special/digammaf/docs/types/test.ts | 44 ++++ .../base/special/digammaf/examples/c/Makefile | 146 +++++++++++ .../special/digammaf/examples/c/example.c | 31 +++ .../base/special/digammaf/examples/index.js | 30 +++ .../math/base/special/digammaf/include.gypi | 48 ++++ .../stdlib/math/base/special/digammaf.h | 38 +++ .../math/base/special/digammaf/lib/index.js | 57 +++++ .../math/base/special/digammaf/lib/main.js | 148 +++++++++++ .../math/base/special/digammaf/lib/native.js | 50 ++++ .../base/special/digammaf/lib/polyval_p.js | 52 ++++ .../math/base/special/digammaf/manifest.json | 90 +++++++ .../math/base/special/digammaf/package.json | 149 +++++++++++ .../base/special/digammaf/scripts/evalpoly.js | 126 +++++++++ .../math/base/special/digammaf/src/addon.c | 22 ++ .../math/base/special/digammaf/src/main.c | 185 ++++++++++++++ .../test/fixtures/julia/half_integers.json | 1 + .../test/fixtures/julia/large_positive.json | 1 + .../test/fixtures/julia/near_integers.json | 1 + .../test/fixtures/julia/negative.json | 1 + .../test/fixtures/julia/positive.json | 1 + .../digammaf/test/fixtures/julia/runner.jl | 92 +++++++ .../test/fixtures/julia/small_positive.json | 1 + .../math/base/special/digammaf/test/test.js | 226 ++++++++++++++++ .../base/special/digammaf/test/test.native.js | 234 +++++++++++++++++ 33 files changed, 2732 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/docs/img/equation_digamma_function.svg create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/include/stdlib/math/base/special/digammaf.h create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/lib/polyval_p.js create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/scripts/evalpoly.js create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/half_integers.json create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/large_positive.json create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/near_integers.json create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/negative.json create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/positive.json create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/runner.jl create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/small_positive.json create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/test/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/README.md b/lib/node_modules/@stdlib/math/base/special/digammaf/README.md new file mode 100644 index 000000000000..d7cc40e2281b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/README.md @@ -0,0 +1,241 @@ + + +# digammaf + +> [Digamma][digamma-function] function (single-precision). + +
+ +The [digamma function][digamma-function] `ψ` is the logarithmic derivative of the [gamma function][gamma-function], i.e. + + + +```math +\psi(x) =\frac{d}{dx} \ln{\Gamma(x)}= \frac{\Gamma\,'(x)}{\Gamma(x)} +``` + + + + + +
+ + + +
+ +## Usage + +```javascript +var digammaf = require( '@stdlib/math/base/special/digammaf' ); +``` + +#### digammaf( x ) + +Evaluates the [digamma function][digamma-function] for a single-precision floating-point number. + +```javascript +var v = digammaf( -2.5 ); +// returns ~1.103 + +v = digammaf( 1.0 ); +// returns ~-0.577 + +v = digammaf( 10.0 ); +// returns ~2.252 +``` + +If `x` is `0` or a negative `integer`, the function returns `NaN`. + +```javascript +var v = digammaf( 0.0 ); +// returns NaN + +v = digammaf( -1.0 ); +// returns NaN + +v = digammaf( -2.0 ); +// returns NaN +``` + +If provided `NaN`, the function returns `NaN`. + +```javascript +var v = digammaf( NaN ); +// returns NaN +``` + +
+ + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var digammaf = require( '@stdlib/math/base/special/digammaf' ); + +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, -5.0, 5.0, opts ); + +logEachMap( 'x: %0.4f, f(x): %0.4f', x, digammaf ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/digammaf.h" +``` + +#### stdlib_base_digammaf( x ) + +Evaluates the [digamma function][digamma-function] for a single-precision floating-point number. + +```c +float out = stdlib_base_digammaf( 1.0f ); +// returns ~-0.577 + +out = stdlib_base_digammaf( 2.0f ); +// returns ~0.423 +``` + +The function accepts the following arguments: + +- **x**: `[in] float` input value. + +```c +float stdlib_base_digammaf( const float x ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/digammaf.h" +#include +#include + +int main( void ) { + const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; + + float y; + int i; + for ( i = 0; i < 5; i++ ) { + y = stdlib_base_digammaf( x[ i ] ); + printf( "digamma(%f) = %f\n", x[ i ], y ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.js new file mode 100644 index 000000000000..97065f312163 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var pkg = require( './../package.json' ).name; +var digammaf = require( './../lib' ); + + +// MAIN // + +bench(pkg, function benchmark(b) { + var x; + var y; + var i; + + b.tic(); + for (i = 0; i < b.iterations; i++) { + x = (randu() * 1000.0) + EPS; + y = digammaf(x); + 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/digammaf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.native.js new file mode 100644 index 000000000000..fb489abcd586 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.native.js @@ -0,0 +1,61 @@ +/** +* @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 randu = require( '@stdlib/random/base/randu' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var digammaf = tryRequire(resolve(__dirname, './../lib/native.js')); +var opts = { + 'skip': (digammaf instanceof Error) +}; + + +// MAIN // + +bench(pkg + '::native', opts, function benchmark(b) { + var x; + var y; + var i; + + b.tic(); + for (i = 0; i < b.iterations; i++) { + x = (randu() * 1000.0) + EPS; + y = digammaf(x); + 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/digammaf/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/c/native/Makefile new file mode 100644 index 000000000000..979768abbcec --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/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/digammaf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..ec5b9f078350 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/c/native/benchmark.c @@ -0,0 +1,133 @@ +/** +* @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/digammaf.h" +#include +#include +#include +#include +#include + +#define NAME "digammaf" +#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 [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + float x; + float y; + double t; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + x = ( 1000.0f * rand_float() ) + 0.1f; + y = stdlib_base_digammaf( x ); + if ( y != y ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y != y ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::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/digammaf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/digammaf/binding.gyp new file mode 100644 index 000000000000..328943ad008d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/binding.gyp @@ -0,0 +1,167 @@ +# @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. +{ + # 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/digammaf/docs/img/equation_digamma_function.svg b/lib/node_modules/@stdlib/math/base/special/digammaf/docs/img/equation_digamma_function.svg new file mode 100644 index 000000000000..f50f0f882f93 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/docs/img/equation_digamma_function.svg @@ -0,0 +1,63 @@ + +psi left-parenthesis x right-parenthesis equals StartFraction d Over d x EndFraction ln normal upper Gamma left-parenthesis x right-parenthesis equals StartFraction normal upper Gamma prime left-parenthesis x right-parenthesis Over normal upper Gamma left-parenthesis x right-parenthesis EndFraction + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/digammaf/docs/repl.txt new file mode 100644 index 000000000000..e3a29ebe1d25 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/docs/repl.txt @@ -0,0 +1,35 @@ +{{alias}}( x ) + Evaluates the digamma function for a single-precision floating-point + number. + + If `x` is zero or a negative integer, the function returns `NaN`. + + If provided `NaN`, the function returns `NaN`. + + Parameters + ---------- + x: number + Input value. + + Returns + ------- + y: number + Function value. + + Examples + -------- + > var y = {{alias}}( 1.0 ) + ~-0.577 + > y = {{alias}}( -2.0 ) + NaN + > y = {{alias}}( 3.0 ) + ~0.923 + > y = {{alias}}( -2.5 ) + ~1.103 + > y = {{alias}}( 0.0 ) + NaN + > y = {{alias}}( NaN ) + NaN + + See Also + -------- diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/digammaf/docs/types/index.d.ts new file mode 100644 index 000000000000..99bcf63026b5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/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 digamma function for a single-precision floating-point number. +* +* ## Notes +* +* - If `x` is zero or a negative integer, the function returns `NaN`. +* +* @param x - input value +* @returns function value +* +* @example +* var v = digammaf( 1.0 ); +* // returns ~-0.577 +* +* @example +* var v = digammaf( 2.0 ); +* // returns ~0.423 +* +* @example +* var v = digammaf( -1.0 ); +* // returns NaN +* +* @example +* var v = digammaf( -2.5 ); +* // returns ~1.103 +* +* @example +* var v = digammaf( 0.0 ); +* // returns NaN +* +* @example +* var v = digammaf( NaN ); +* // returns NaN +*/ +declare function digammaf( x: number ): number; + + +// EXPORTS // + +export = digammaf; diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/digammaf/docs/types/test.ts new file mode 100644 index 000000000000..88b2505ea26b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/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 digammaf = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + digammaf( 2.0 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a number... +{ + digammaf( true ); // $ExpectError + digammaf( false ); // $ExpectError + digammaf( null ); // $ExpectError + digammaf( undefined ); // $ExpectError + digammaf( '5' ); // $ExpectError + digammaf( [] ); // $ExpectError + digammaf( {} ); // $ExpectError + digammaf( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + digammaf(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/digammaf/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/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/digammaf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/digammaf/examples/c/example.c new file mode 100644 index 000000000000..3914fc7c86d3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/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/digammaf.h" +#include + +int main( void ) { + const float x[] = { 0.0f, 1.0f, -1.5f, -3.0f, 0.5f }; + + float y; + int i; + for ( i = 0; i < 5; i++ ) { + y = stdlib_base_digammaf( x[ i ] ); + printf( "digamma(%f) = %f\n", x[ i ], y ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/digammaf/examples/index.js new file mode 100644 index 000000000000..6695687ddb91 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/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 digammaf = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; +var x = uniform(100, -5.0, 5.0, opts); + +logEachMap('x: %0.4f, f(x): %0.4f', x, digammaf); diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/include.gypi b/lib/node_modules/@stdlib/math/base/special/digammaf/include.gypi new file mode 100644 index 000000000000..0fd0d2000337 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/include.gypi @@ -0,0 +1,48 @@ +# @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. +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' 0.5) { + p += 1.0; + nz = float64ToFloat32(q - p); + } + nz = float64ToFloat32(FLOAT32_PI * cotf(float64ToFloat32(FLOAT32_PI * nz))); // eslint-disable-line max-len + } + xx = float64ToFloat32(1.0 - xx); + } + + // Use direct formula for small positive integers... + if (xx <= 10.0 && xx === floorf(xx)) { + y = 0.0; + n = xx; + for (i = 1; i < n; i++) { + w = i; + y = float64ToFloat32(y + float64ToFloat32(1.0 / w)); + } + y = float64ToFloat32(y - EULERGAMMA); + } else { + // Use recurrence to make x large enough for asymptotic expansion... + s = xx; + w = 0.0; + while (s < 10.0) { + w = float64ToFloat32(w + float64ToFloat32(1.0 / s)); + s = float64ToFloat32(s + 1.0); + } + + // Asymptotic expansion... + if (s < 1.0e8) { + z = float64ToFloat32(1.0 / float64ToFloat32(s * s)); + y = float64ToFloat32(z * polyvalP(z)); + } else { + y = 0.0; + } + y = float64ToFloat32(lnf(s) - float64ToFloat32(0.5 / s) - y - w); + } + + if (negative) { + y = float64ToFloat32(y - nz); + } + return y; +} + + +// EXPORTS // + +module.exports = digammaf; diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/digammaf/lib/native.js new file mode 100644 index 000000000000..0c4010555cd9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/lib/native.js @@ -0,0 +1,50 @@ +/** +* @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 digamma function for a single-precision floating-point number. +* +* @private +* @param {number} x - input value +* @returns {number} function value +* +* @example +* var v = digammaf( 1.0 ); +* // returns ~-0.577 +* +* @example +* var v = digammaf( 2.0 ); +* // returns ~0.423 +*/ +function digammaf(x) { + return addon(x); +} + + +// EXPORTS // + +module.exports = digammaf; diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/lib/polyval_p.js b/lib/node_modules/@stdlib/math/base/special/digammaf/lib/polyval_p.js new file mode 100644 index 000000000000..ed3b14abf5a4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/lib/polyval_p.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* This is a generated file. Do not edit directly. */ +'use strict'; + +// MODULES // + +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// MAIN // + +/** +* Evaluates a polynomial. +* +* ## Notes +* +* - The implementation uses [Horner's rule][horners-method] for efficient computation. +* +* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method +* +* @private +* @param {number} x - value at which to evaluate the polynomial +* @returns {number} evaluated polynomial +*/ +function evalpoly( x ) { + if ( x === 0.0 ) { + return 0.0833333358168602; + } + return float64ToFloat32(0.0833333358168602 + float64ToFloat32(x * float64ToFloat32(-0.008333333767950535 + float64ToFloat32(x * float64ToFloat32(0.003968254197388887 + float64ToFloat32(x * -0.004166666883975267)))))); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/manifest.json b/lib/node_modules/@stdlib/math/base/special/digammaf/manifest.json new file mode 100644 index 000000000000..60ef5c6a4dc4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/manifest.json @@ -0,0 +1,90 @@ +{ + "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/special/floorf", + "@stdlib/math/base/special/lnf", + "@stdlib/math/base/special/cotf", + "@stdlib/constants/float32/pi", + "@stdlib/constants/float32/max", + "@stdlib/constants/float32/eulergamma" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/floorf", + "@stdlib/math/base/special/lnf", + "@stdlib/math/base/special/cotf", + "@stdlib/constants/float32/pi", + "@stdlib/constants/float32/max", + "@stdlib/constants/float32/eulergamma" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/floorf", + "@stdlib/math/base/special/lnf", + "@stdlib/math/base/special/cotf", + "@stdlib/constants/float32/pi", + "@stdlib/constants/float32/max", + "@stdlib/constants/float32/eulergamma" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/package.json b/lib/node_modules/@stdlib/math/base/special/digammaf/package.json new file mode 100644 index 000000000000..a098c6ef7d8a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/package.json @@ -0,0 +1,149 @@ +{ + "name": "@stdlib/math/base/special/digammaf", + "version": "0.0.0", + "description": "Digamma function (single-precision).", + "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", + "digamma", + "psi", + "polygamma", + "gamma", + "derivative", + "logarithmic", + "single", + "precision", + "float", + "float32" + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "digamma", + "alias": "digammaf", + "pkg_desc": "evaluate the digamma function for a single-precision floating-point number", + "desc": "evaluates the digamma function for a single-precision floating-point number", + "short_desc": "digamma", + "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": [ + 0.5, + 20 + ] + }, + "example_values": [ + 0.51, + 1.37, + 2.93, + 4.18, + 7.64, + -2.47, + -1.23, + -3.79, + -0.61, + 5.42, + 9.08, + 12.57, + 15.33, + -4.62, + -6.14, + 18.91, + 10.26, + -5.37, + 3.41, + 0.89 + ] + } + ], + "output_policy": "real_floating_point_and_generic", + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + } + }, + "keywords": [ + "derivative", + "gamma", + "digamma", + "scalar", + "number", + "psi" + ], + "extra_keywords": [] + } + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/scripts/evalpoly.js b/lib/node_modules/@stdlib/math/base/special/digammaf/scripts/evalpoly.js new file mode 100644 index 000000000000..493ec7a57700 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/scripts/evalpoly.js @@ -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. +*/ + +/* +* 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 substringBefore = require( '@stdlib/string/substring-before' ); +var substringAfter = require( '@stdlib/string/substring-after' ); +var format = require( '@stdlib/string/format' ); +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' ); + + +// VARIABLES // + +// Polynomial coefficients ordered in ascending degree... +var P = [ + 8.33333333333333333333e-2, + -8.33333333333333333333e-3, + 3.96825396825396825397e-3, + -4.16666666666666666667e-3 +]; + +// 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 jopts; + var opts; + var file; + var str; + + opts = { + 'encoding': 'utf8' + }; + + jopts = { + 'dtype': 'float32', + 'name': '' + }; + + fpath = resolve(__dirname, '..', 'lib', 'polyval_p.js'); + str = header + compile(P, jopts); + writeFileSync(fpath, str, opts); + + copts = { + 'dtype': 'float', + 'name': '' + }; + + fpath = resolve(__dirname, '..', 'src', 'main.c'); + file = readFileSync(fpath, opts); + + copts.name = 'polyval_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/digammaf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/digammaf/src/addon.c new file mode 100644 index 000000000000..777dc65bc1a9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/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/digammaf.h" +#include "stdlib/math/base/napi/unary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_F_F( stdlib_base_digammaf ) diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c b/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c new file mode 100644 index 000000000000..779afb443a5c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c @@ -0,0 +1,185 @@ +/** +* @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 JavaScript. +* +* ```text +* Cephes Math Library Release 2.2: June, 1992 +* Copyright 1984, 1987, 1992 by Stephen L. Moshier +* Direct inquiries to 30 Frost Street, Cambridge, MA 02140 +* ``` +*/ + +#include "stdlib/math/base/special/digammaf.h" +#include "stdlib/math/base/special/floorf.h" +#include "stdlib/math/base/special/lnf.h" +#include "stdlib/math/base/special/cotf.h" +#include "stdlib/math/base/assert/is_nanf.h" +#include "stdlib/constants/float32/pi.h" +#include "stdlib/constants/float32/max.h" +#include "stdlib/constants/float32/eulergamma.h" +#include + +/* Begin auto-generated functions. The following functions are auto-generated. Do not edit directly. */ + +// BEGIN: polyval_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 polyval_p( const float x ) { + return 0.08333333333333333f + (x * (-0.008333333333333333f + (x * (0.003968253968253968f + (x * -0.004166666666666667f))))); +} + +// END: polyval_p + +/** +* Evaluates the digamma function for a single-precision floating-point number. +* +* ## Method +* +* The digamma function ψ(x) is the logarithmic derivative of the gamma function: +* +* ```tex +* \psi(x) = \frac{d}{dx} \ln \Gamma(x) = \frac{\Gamma'(x)}{\Gamma(x)} +* ``` +* +* For integer x: +* +* ```tex +* \psi(n) = -\gamma + \sum_{k=1}^{n-1} \frac{1}{k} +* ``` +* +* where γ is the Euler-Mascheroni constant. +* +* For negative x, the reflection formula is used: +* +* ```tex +* \psi(1-x) = \psi(x) + \pi \cot(\pi x) +* ``` +* +* For general positive x, the recurrence relation is applied: +* +* ```tex +* \psi(x+1) = \psi(x) + \frac{1}{x} +* ``` +* +* Then the asymptotic expansion is used: +* +* ```tex +* \psi(x) = \ln(x) - \frac{1}{2x} - \sum_{k=1}^{\infty} \frac{B_{2k}}{2k x^{2k}} +* ``` +* +* where B_{2k} are Bernoulli numbers. +* +* ## Notes +* +* - For `x` equal to a negative integer or zero, the function returns `NaN`. +* +* @param x input value +* @return function value +* +* @example +* float y = stdlib_base_digammaf( 1.0f ); +* // returns ~-0.577 +*/ +float stdlib_base_digammaf( const float x ) { + float p, q, nz, s, w, y, z; + int32_t i, n, negative; + float xx; + + xx = x; + nz = 0.0f; + negative = 0; + + if ( stdlib_base_is_nanf( x ) ) { + return x; + } + + // Handle negative arguments using reflection formula + if ( xx <= 0.0f ) { + negative = 1; + q = xx; + p = stdlib_base_floorf( q ); + + // Check for singularity (negative integer or zero) + if ( p == q ) { + return 0.0f / 0.0f; // NaN + } + + // Compute fractional part + nz = q - p; + if ( nz != 0.5f ) { + if ( nz > 0.5f ) { + p += 1.0f; + nz = q - p; + } + nz = STDLIB_CONSTANT_FLOAT32_PI * stdlib_base_cotf( STDLIB_CONSTANT_FLOAT32_PI * nz ); + } else { + nz = 0.0f; + } + xx = 1.0f - xx; + } + + // Use direct formula for small positive integers + if ( ( xx <= 10.0f ) && ( xx == stdlib_base_floorf( xx ) ) ) { + y = 0.0f; + n = (int32_t)xx; + for ( i = 1; i < n; i++ ) { + w = (float)i; + y += 1.0f / w; + } + y -= STDLIB_CONSTANT_FLOAT32_EULERGAMMA; + goto done; + } + + // Use recurrence to make x large enough for asymptotic expansion + s = xx; + w = 0.0f; + while ( s < 10.0f ) { + w += 1.0f / s; + s += 1.0f; + } + + // Asymptotic expansion + if ( s < 1.0e8f ) { + z = 1.0f / ( s * s ); + y = z * polyval_p( z ); + } else { + y = 0.0f; + } + + y = stdlib_base_lnf( s ) - ( 0.5f / s ) - y - w; + +done: + if ( negative ) { + y -= nz; + } + return y; +} diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/half_integers.json b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/half_integers.json new file mode 100644 index 000000000000..5f85466bed84 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/half_integers.json @@ -0,0 +1 @@ +{"expected":[0.036489975,0.70315665,1.1031567,1.388871,1.6110932,1.7929113,1.9467574,2.0800908,2.197738,2.303001,2.3982391,2.4851956,2.5651956,2.6392698,2.7082353,2.7727513,2.8333573,2.8905003,2.9445543,2.9958365,3.044617,3.0911286,3.135573,3.178126,3.2189424,3.2581582,3.295894,3.3322577,3.3673453,3.4012437,3.4340305,3.4657767,3.4965458,3.5263965,3.555382,3.5835512,3.6109483,3.637615,3.663589,3.6889055,3.7135968,3.7376933,3.7612226,3.7842112,3.806683,3.8286612,3.8501666,3.8712192,3.8918376,3.9120398,3.9318416,3.9512591,3.9703066,3.9889984,4.007347,4.025365,4.043064,4.0604553,4.0775495,4.094356,4.110885,4.1271453,4.143145,4.158893,4.174397,4.1896644,4.204702,4.2195168,4.234115,4.2485037,4.262688,4.2766743,4.2904673,4.304073,4.3174953,4.3307405,4.3438125,4.3567157,4.3694544,4.3820333,4.3944554,4.4067254,4.4188466,4.430823,4.442657,4.454353,4.465914,4.477342,4.4886417,4.499815,4.5108647,4.5217934,4.532604,4.5432997,4.5538816,4.5643525,4.5747156,4.584972,4.5951242,4.6051745],"x":[-0.5,-1.5,-2.5,-3.5,-4.5,-5.5,-6.5,-7.5,-8.5,-9.5,-10.5,-11.5,-12.5,-13.5,-14.5,-15.5,-16.5,-17.5,-18.5,-19.5,-20.5,-21.5,-22.5,-23.5,-24.5,-25.5,-26.5,-27.5,-28.5,-29.5,-30.5,-31.5,-32.5,-33.5,-34.5,-35.5,-36.5,-37.5,-38.5,-39.5,-40.5,-41.5,-42.5,-43.5,-44.5,-45.5,-46.5,-47.5,-48.5,-49.5,-50.5,-51.5,-52.5,-53.5,-54.5,-55.5,-56.5,-57.5,-58.5,-59.5,-60.5,-61.5,-62.5,-63.5,-64.5,-65.5,-66.5,-67.5,-68.5,-69.5,-70.5,-71.5,-72.5,-73.5,-74.5,-75.5,-76.5,-77.5,-78.5,-79.5,-80.5,-81.5,-82.5,-83.5,-84.5,-85.5,-86.5,-87.5,-88.5,-89.5,-90.5,-91.5,-92.5,-93.5,-94.5,-95.5,-96.5,-97.5,-98.5,-99.5]} diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/large_positive.json b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/large_positive.json new file mode 100644 index 000000000000..b50453eab17d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/large_positive.json @@ -0,0 +1 @@ +{"expected":[2.2517526,2.2982197,2.342625,2.385143,2.425928,2.4651158,2.5028265,2.5391672,2.574234,2.6081135,2.640883,2.6726131,2.7033675,2.7332048,2.7621777,2.7903352,2.8177216,2.8443782,2.8703427,2.8956504,2.9203336,2.9444222,2.9679441,2.9909258,3.0133913,3.0353632,3.0568628,3.07791,3.0985234,3.1187203,3.1385176,3.1579306,3.176974,3.1956615,3.2140064,3.2320206,3.2497163,3.2671041,3.284195,3.3009984,3.3175244,3.3337817,3.3497791,3.3655245,3.3810258,3.3962905,3.4113257,3.4261382,3.4407346,3.455121,3.4693034,3.4832873,3.4970787,3.510682,3.5241032,3.5373466,3.5504167,3.5633185,3.5760555,3.5886328,3.6010537,3.6133223,3.6254418,3.6374166,3.6492498,3.6609442,3.6725037,3.683931,3.6952293,3.7064013,3.71745,3.7283778,3.7391875,3.7498817,3.7604628,3.770933,3.7812948,3.7915502,3.8017015,3.811751,3.8217003,3.8315518,3.841307,3.8509681,3.8605366,3.8700144,3.8794034,3.888705,3.8979208,3.9070525,3.9161017,3.9250696,3.9339578,3.9427676,3.9515007,3.960158,3.9687412,3.9772513,3.9856894,3.994057,4.002355,4.0105853,4.018748,4.0268445,4.034876,4.042844,4.0507483,4.058591,4.0663724,4.0740943,4.0817566,4.0893607,4.096907,4.1043973,4.111832,4.1192117,4.1265373,4.1338096,4.1410294,4.148197,4.1553144,4.162381,4.1693983,4.176367,4.1832867,4.190159,4.196985,4.203764,4.210498,4.217186,4.22383,4.2304306,4.2369876,4.243502,4.2499743,4.256405,4.2627945,4.269143,4.275452,4.281721,4.2879515,4.294143,4.300297,4.3064127,4.3124914,4.3185334,4.324539,4.330509,4.3364434,4.342343,4.348208,4.3540387,4.3598356,4.3655987,4.3713293,4.377027,4.3826923,4.388326,4.393928,4.399499,4.405039,4.410548,4.4160275,4.421477,4.4268966,4.432287,4.4376493,4.442982,4.448287,4.4535637,4.4588127,4.4640346,4.469229,4.474397,4.4795384,4.484653,4.4897423,4.4948053,4.4998426,4.504855,4.5098424,4.514805,4.519743,4.524657,4.5295467,4.534413,4.539255,4.5440745,4.54887,4.553643,4.558394,4.563122,4.5678277,4.572511,4.577173,4.5818133,4.586432,4.5910296,4.5956063,4.600162],"x":[10.0,10.452261,10.904523,11.356784,11.809045,12.261307,12.713568,13.165829,13.618091,14.070352,14.522614,14.9748745,15.427135,15.879397,16.331657,16.78392,17.236181,17.688442,18.140703,18.592964,19.045227,19.497488,19.949749,20.40201,20.85427,21.306532,21.758795,22.211056,22.663317,23.115578,23.567839,24.0201,24.472363,24.924623,25.376884,25.829145,26.281406,26.73367,27.18593,27.638191,28.090452,28.542713,28.994974,29.447237,29.899498,30.351759,30.80402,31.25628,31.708542,32.160805,32.613064,33.065327,33.51759,33.96985,34.42211,34.87437,35.326633,35.778896,36.231155,36.68342,37.135677,37.58794,38.0402,38.492462,38.944725,39.396984,39.849247,40.301506,40.75377,41.20603,41.65829,42.110554,42.562813,43.015076,43.46734,43.919598,44.37186,44.82412,45.276382,45.72864,46.180904,46.633167,47.085426,47.53769,47.98995,48.44221,48.894474,49.346733,49.798996,50.251255,50.703518,51.15578,51.60804,52.060303,52.51256,52.964825,53.417084,53.869347,54.32161,54.77387,55.22613,55.67839,56.130653,56.582916,57.035175,57.48744,57.939697,58.39196,58.84422,59.296482,59.748745,60.201004,60.653267,61.105526,61.55779,62.01005,62.46231,62.914574,63.366833,63.819096,64.271355,64.72362,65.17588,65.62814,66.0804,66.53266,66.984924,67.43719,67.88945,68.341705,68.79397,69.24623,69.698494,70.15076,70.60301,71.055275,71.50754,71.9598,72.41206,72.86432,73.31658,73.768845,74.22111,74.67337,75.125626,75.57789,76.03015,76.482414,76.93468,77.38693,77.839195,78.29146,78.74372,79.19598,79.64824,80.1005,80.552765,81.00503,81.45728,81.909546,82.36181,82.81407,83.266335,83.71859,84.17085,84.623116,85.07538,85.52764,85.9799,86.43216,86.88442,87.336685,87.78895,88.2412,88.69347,89.14573,89.59799,90.050255,90.50251,90.95477,91.407036,91.8593,92.31156,92.76382,93.21608,93.66834,94.120605,94.57286,95.02512,95.47739,95.92965,96.38191,96.83417,97.28643,97.73869,98.190956,98.64322,99.095474,99.54774,100.0]} diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/near_integers.json b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/near_integers.json new file mode 100644 index 000000000000..5835dde486d2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/near_integers.json @@ -0,0 +1 @@ +{"expected":[-0.754927,-0.7471064,-0.7393386,-0.7316227,-0.7239583,-0.71634465,-0.70878124,-0.7012674,-0.6938024,-0.686386,-0.6790172,-0.6716958,-0.664421,-0.65719247,-0.6500096,-0.6428717,-0.6357785,-0.6287292,-0.62172365,-0.614761,-0.6078411,-0.6009633,-0.594127,-0.587332,-0.5805777,-0.57386357,-0.5671894,-0.5605547,-0.55395883,-0.5474016,-0.5408823,-0.53440094,-0.52795684,-0.5215497,-0.5151789,-0.5088445,-0.5025458,-0.4962825,-0.49005425,-0.48386046,-0.4777012,-0.47157586,-0.46548417,-0.45942554,-0.45340005,-0.44740716,-0.4414465,-0.43551785,-0.42962062,-0.4237549,0.35618415,0.35898837,0.36178508,0.36457413,0.3673557,0.37012976,0.3728964,0.37565574,0.37840763,0.38115218,0.38388947,0.38661957,0.3893424,0.39205804,0.39476654,0.39746797,0.4001624,0.40284973,0.40553007,0.40820342,0.41086996,0.41352955,0.41618225,0.41882816,0.42146727,0.4240997,0.4267253,0.42934433,0.43195674,0.43456236,0.43716156,0.43975407,0.4423402,0.44491982,0.44749287,0.45005962,0.45261982,0.45517385,0.4577215,0.46026275,0.46279785,0.4653267,0.4678492,0.47036567,0.47287583,0.47538003,0.47787815,0.48037004,0.48285607,0.48533592,0.8825,0.88417596,0.88584924,0.88751966,0.88918746,0.89085245,0.89251465,0.8941743,0.895831,0.8974852,0.8991366,0.9007853,0.90243137,0.9040748,0.90571547,0.9073536,0.9089889,0.91062176,0.91225195,0.9138794,0.91550434,0.9171266,0.91874635,0.92036355,0.921978,0.92359,0.9251994,0.9268063,0.9284106,0.93001235,0.9316116,0.9332083,0.9348025,0.9363942,0.9379834,0.9395701,0.94115424,0.942736,0.9443153,0.9458921,0.9474665,0.94903845,0.95060784,0.9521749,0.95373946,0.9553017,0.9568615,0.95841885,0.9599739,0.9615264,1.4837378,1.4846611,1.4855835,1.4865052,1.4874259,1.4883459,1.489265,1.4901831,1.4911004,1.492017,1.4929328,1.4938477,1.4947617,1.4956748,1.4965873,1.4974989,1.4984096,1.4993194,1.5002285,1.5011369,1.5020443,1.5029509,1.5038567,1.5047617,1.5056659,1.5065693,1.5074718,1.5083736,1.5092745,1.5101745,1.511074,1.5119724,1.5128702,1.513767,1.5146631,1.5155584,1.5164529,1.5173466,1.5182395,1.5191317,1.520023,1.5209136,1.5218033,1.5226922,1.5235804,1.5244678,1.5253544,1.5262402,1.5271252,1.5280095],"x":[0.9,0.90408164,0.90816325,0.9122449,0.9163265,0.9204082,0.9244898,0.9285714,0.93265307,0.9367347,0.94081634,0.94489795,0.9489796,0.9530612,0.95714283,0.9612245,0.9653061,0.96938777,0.9734694,0.97755104,0.98163265,0.98571426,0.9897959,0.99387753,0.9979592,1.0020409,1.0061225,1.0102041,1.0142857,1.0183673,1.022449,1.0265306,1.0306122,1.0346938,1.0387756,1.0428572,1.0469388,1.0510204,1.055102,1.0591837,1.0632653,1.0673469,1.0714285,1.0755103,1.0795919,1.0836735,1.0877551,1.0918367,1.0959184,1.1,1.9,1.9040816,1.9081633,1.9122449,1.9163265,1.9204081,1.9244897,1.9285715,1.9326531,1.9367347,1.9408163,1.944898,1.9489796,1.9530612,1.9571428,1.9612244,1.9653062,1.9693878,1.9734694,1.977551,1.9816327,1.9857143,1.9897959,1.9938775,1.9979591,2.0020409,2.0061224,2.010204,2.0142858,2.0183673,2.022449,2.0265305,2.0306122,2.034694,2.0387754,2.0428572,2.0469387,2.0510204,2.055102,2.0591836,2.0632653,2.067347,2.0714285,2.0755103,2.0795918,2.0836735,2.0877552,2.0918367,2.0959184,2.1,2.9,2.9040816,2.9081633,2.9122448,2.9163265,2.9204082,2.9244897,2.9285715,2.932653,2.9367347,2.9408164,2.944898,2.9489796,2.9530613,2.9571428,2.9612246,2.965306,2.9693878,2.9734695,2.977551,2.9816327,2.9857142,2.989796,2.9938776,2.9979591,3.0020409,3.0061224,3.010204,3.0142858,3.0183673,3.022449,3.0265305,3.0306122,3.034694,3.0387754,3.0428572,3.0469387,3.0510204,3.055102,3.0591836,3.0632653,3.067347,3.0714285,3.0755103,3.0795918,3.0836735,3.0877552,3.0918367,3.0959184,3.1,4.9,4.904082,4.908163,4.912245,4.9163265,4.9204082,4.92449,4.928571,4.932653,4.9367347,4.9408164,4.944898,4.9489794,4.953061,4.957143,4.9612246,4.9653063,4.9693875,4.9734693,4.977551,4.9816327,4.9857144,4.9897957,4.9938774,4.997959,5.002041,5.0061226,5.0102043,5.0142856,5.0183673,5.022449,5.0265307,5.0306125,5.0346937,5.0387754,5.042857,5.046939,5.0510206,5.055102,5.0591836,5.0632653,5.067347,5.071429,5.07551,5.0795918,5.0836735,5.087755,5.091837,5.095918,5.1]} diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/negative.json b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/negative.json new file mode 100644 index 000000000000..8e0662069516 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/negative.json @@ -0,0 +1 @@ +{"expected":[2.303001,2.6111472,2.9254663,3.2526126,3.600356,3.9783378,4.399277,4.880833,5.44899,6.144149,7.0335145,8.238392,10.003838,12.911597,18.764597,37.337654,-329.9871,-26.667192,-12.715438,-7.711256,-5.099828,-3.4712336,-2.3405056,-1.4956423,-0.8290948,-0.2802572,0.18778467,0.59907514,0.9701448,1.3130038,1.6368363,1.9491522,2.2564876,2.5649874,2.8808618,3.2109516,3.563318,3.9480603,4.378669,4.8740983,5.462502,6.1881323,7.125704,8.412702,10.334135,13.594185,20.540821,46.695477,-108.57433,-22.441597,-11.537408,-7.205553,-4.8458586,-3.3381329,-2.2744505,-1.4705331,-0.83067894,-0.3000976,0.15509406,0.55715454,0.92157936,1.2597135,1.5803753,1.8908194,2.1974747,2.5064526,2.8240511,3.1572921,3.5145366,3.9064405,4.3473225,4.8575525,5.467658,6.226325,7.2168603,8.595727,10.696323,14.380328,22.77341,62.984383,-64.38232,-19.348204,-10.569972,-6.7801013,-4.6360307,-3.2353563,-2.2324224,-1.4661787,-0.85118437,-0.3377416,0.105279006,0.49855176,0.85661894,1.1902381,1.5078663,1.8165488,2.122617,2.4321806,2.7516305,3.0881922,3.4505804,3.8500266,4.301782,4.8277674,5.461194,6.2557044,7.3045406,8.786537,11.09453,15.295128,25.661373,98.29208,-45.521954,-17.00684,-9.775046,-6.428793,-4.470921,-3.1656313,-2.2179732,-1.4865419,-0.8947989,-0.3975471,0.03387601,0.41871166,0.7706341,1.0998652,1.4145339,1.7214999,2.0270164,2.3372085,2.6585793,2.9985836,3.366324,3.7736638,4.2368793,4.779607,5.4380603,6.271502,7.3846645,8.982959,11.532742,16.37205,29.538525,231.69392,-35.12353,-15.197281,-9.127977,-6.149725,-4.353912,-3.1341116,-2.2370222,-1.5379465,-0.96810156,-0.48627913,-0.06603131,0.31058463,0.65645206,0.98130393,1.2929726,1.5981542,1.9030421,2.2137947,2.5370476,2.8805106,3.2537131,3.6692104,4.1444073,4.70484,5.3900914,6.2658176,7.450095,9.180112,12.014103,17.656534,35.009983,-596.47906,-28.594238,-13.7875595,-8.615761,-5.9465003,-4.292884,-3.1502342,-2.2997649,-1.631036,-1.0820673,-0.615175,-0.20592509,0.16246328,0.5021408,0.8224053,1.1308109,1.4339215,1.7378788,2.048897,2.3737695,2.7204792,3.099035,3.5227382,4.010249,4.5892015,5.302978,6.224523,7.4875035,9.36733,12.538427,19.210978,43.29744,-128.72026,-24.181732,-12.701804,-8.23863,-5.831977,-4.304312,-3.2320364,-2.425111,-1.7853719,-1.2567883,-0.8048405,-0.40688044,-0.047208223,0.28567165,0.6006502,0.90504014,1.2052828,1.5074952,1.8179599,2.1436448,2.4928446,2.8760815,3.3074875,3.8070934,4.404881,5.1484957,6.119241,7.4690766,9.519795,13.094467,21.120178,57.286674,-71.96419,-21.094606,-11.911748,-8.019618,-5.8393126,-4.42498,-3.4182794,-2.6533024,-2.0424888,-1.5350453,-1.0992779,-0.7141652,-0.36497873,-0.040829506,0.26680046,0.5650057,0.86011934,1.1582488,1.4657602,1.7898151,2.1390483,2.5245402,2.9613304,3.4709606,4.086023,4.8589764,5.880745,7.324815,9.569757,13.631591,23.486393,85.82072,-50.20312,-18.984598,-11.464183,-8.043405,-6.063729,-4.7559075,-3.8146498,-3.094448,-2.5169382,-2.0359747,-1.6224141,-1.256723,-0.9250838,-0.6171811,-0.32486245,-0.041256584,0.23985511,0.5245526,0.81926966,1.1313456,1.469748,1.8461212,2.2764516,2.7838893,3.40389,4.194294,5.25706,6.7911406,9.245073],"x":[-9.5,-9.468562,-9.437123,-9.405685,-9.374248,-9.34281,-9.311371,-9.279933,-9.248495,-9.217057,-9.185618,-9.154181,-9.122743,-9.091305,-9.059866,-9.028428,-8.99699,-8.965551,-8.9341135,-8.902676,-8.871238,-8.839799,-8.808361,-8.776923,-8.745485,-8.7140465,-8.682609,-8.651171,-8.619733,-8.588294,-8.556856,-8.525418,-8.49398,-8.462542,-8.431104,-8.399666,-8.368227,-8.336789,-8.305351,-8.273913,-8.242475,-8.211037,-8.179599,-8.148161,-8.116722,-8.085284,-8.053846,-8.0224085,-7.99097,-7.959532,-7.9280934,-7.8966556,-7.865217,-7.8337793,-7.802341,-7.770903,-7.7394648,-7.708027,-7.6765885,-7.6451507,-7.6137123,-7.5822744,-7.550836,-7.519398,-7.48796,-7.4565215,-7.4250836,-7.3936453,-7.3622074,-7.330769,-7.299331,-7.267893,-7.236455,-7.2050166,-7.1735787,-7.1421404,-7.1107025,-7.079264,-7.0478263,-7.016388,-6.98495,-6.9535117,-6.9220734,-6.8906355,-6.859197,-6.8277593,-6.796321,-6.764883,-6.7334447,-6.702007,-6.6705685,-6.6391306,-6.6076922,-6.5762544,-6.544816,-6.513378,-6.48194,-6.4505014,-6.4190636,-6.387625,-6.3561873,-6.324749,-6.293311,-6.261873,-6.230435,-6.1989965,-6.1675587,-6.1361203,-6.1046824,-6.073244,-6.041806,-6.010368,-5.97893,-5.9474916,-5.9160533,-5.8846154,-5.853177,-5.821739,-5.790301,-5.758863,-5.7274246,-5.6959867,-5.6645484,-5.6331105,-5.601672,-5.5702343,-5.538796,-5.507358,-5.4759197,-5.4444814,-5.4130435,-5.381605,-5.3501673,-5.318729,-5.287291,-5.2558527,-5.224415,-5.1929765,-5.1615386,-5.1301003,-5.0986624,-5.067224,-5.035786,-5.004348,-4.97291,-4.9414716,-4.910033,-4.8785954,-4.847157,-4.815719,-4.784281,-4.752843,-4.7214046,-4.6899667,-4.6585283,-4.6270905,-4.595652,-4.564214,-4.532776,-4.501338,-4.4698997,-4.4384613,-4.4070234,-4.375585,-4.344147,-4.312709,-4.281271,-4.2498326,-4.2183948,-4.1869564,-4.1555185,-4.12408,-4.0926423,-4.061204,-4.029766,-3.9983277,-3.9668896,-3.9354515,-3.9040134,-3.8725753,-3.8411372,-3.809699,-3.778261,-3.7468228,-3.7153847,-3.6839464,-3.6525083,-3.6210701,-3.589632,-3.558194,-3.5267558,-3.4953177,-3.4638796,-3.4324415,-3.4010034,-3.3695652,-3.3381271,-3.306689,-3.275251,-3.2438128,-3.2123747,-3.1809363,-3.1494982,-3.11806,-3.086622,-3.055184,-3.0237458,-2.9923077,-2.9608696,-2.9294314,-2.8979933,-2.8665552,-2.835117,-2.803679,-2.7722409,-2.7408028,-2.7093647,-2.6779265,-2.6464882,-2.61505,-2.583612,-2.5521739,-2.5207357,-2.4892976,-2.4578595,-2.4264214,-2.3949833,-2.3635452,-2.332107,-2.300669,-2.2692308,-2.2377927,-2.2063546,-2.1749165,-2.1434782,-2.11204,-2.080602,-2.0491638,-2.0177257,-1.9862876,-1.9548495,-1.9234114,-1.8919733,-1.8605351,-1.829097,-1.7976589,-1.7662207,-1.7347826,-1.7033445,-1.6719064,-1.6404682,-1.6090301,-1.577592,-1.5461539,-1.5147157,-1.4832776,-1.4518394,-1.4204013,-1.3889632,-1.3575251,-1.326087,-1.2946489,-1.2632107,-1.2317725,-1.2003344,-1.1688963,-1.1374582,-1.1060201,-1.074582,-1.0431439,-1.0117056,-0.9802676,-0.9488294,-0.9173913,-0.8859532,-0.8545151,-0.8230769,-0.7916388,-0.7602007,-0.72876257,-0.6973244,-0.6658863,-0.6344482,-0.60301006,-0.5715719,-0.5401338,-0.50869566,-0.47725752,-0.4458194,-0.41438127,-0.38294315,-0.351505,-0.3200669,-0.28862876,-0.25719064,-0.2257525,-0.19431438,-0.16287625,-0.13143812,-0.1]} diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/positive.json b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/positive.json new file mode 100644 index 000000000000..1e7a33fa2398 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/positive.json @@ -0,0 +1 @@ +{"expected":[-1.96351,-1.8725027,-1.7869774,-1.706393,-1.6302788,-1.5582241,-1.4898679,-1.4248921,-1.3630154,-1.303988,-1.2475866,-1.193612,-1.1418852,-1.092245,-1.0445459,-0.99865633,-0.95445657,-0.9118379,-0.8707012,-0.83095556,-0.7925181,-0.7553123,-0.71926826,-0.68432117,-0.6504114,-0.61748374,-0.5854871,-0.55437404,-0.52410036,-0.4946252,-0.46591026,-0.43791983,-0.4106206,-0.3839814,-0.35797298,-0.3325679,-0.30774063,-0.28346664,-0.25972334,-0.23648924,-0.21374415,-0.19146895,-0.16964562,-0.1482571,-0.12728724,-0.106720746,-0.086543106,-0.06674056,-0.047300033,-0.02820911,-0.009455972,0.008970625,0.027081396,0.044886548,0.062395826,0.07961852,0.0965635,0.113239266,0.12965392,0.14581522,0.1617305,0.17740709,0.19285168,0.20807084,0.22307083,0.23785768,0.25243717,0.26681486,0.28099608,0.294986,0.30878958,0.3224115,0.33585644,0.34912875,0.3622327,0.37517244,0.38795185,0.40057483,0.41304502,0.425366,0.4375412,0.44957405,0.46146753,0.4732251,0.48484936,0.4963436,0.50771034,0.5189526,0.53007275,0.54107356,0.55195737,0.56272674,0.5733838,0.583931,0.5943705,0.60470444,0.6149348,0.62506366,0.6350931,0.6450248,0.6548608,0.66460276,0.67425257,0.6838117,0.6932821,0.70266515,0.7119626,0.72117573,0.7303063,0.73935556,0.7483251,0.7572161,0.7660301,0.7747682,0.7834318,0.79202205,0.8005404,0.8089877,0.81736535,0.8256743,0.83391577,0.8420909,0.85020053,0.85824597,0.86622787,0.87414753,0.88200563,0.8898034,0.89754146,0.9052209,0.9128425,0.92040724,0.9279157,0.935369,0.9427677,0.95011276,0.9574048,0.9646447,0.97183305,0.97897077,0.9860583,0.9930966,1.0000861,1.0070276,1.0139219,1.0207692,1.0275706,1.0343264,1.0410374,1.047704,1.054327,1.0609066,1.0674438,1.0739388,1.0803924,1.0868049,1.0931768,1.0995088,1.1058013,1.1120548,1.1182698,1.1244466,1.1305859,1.136688,1.1427534,1.1487825,1.1547757,1.1607336,1.1666564,1.1725446,1.1783985,1.1842188,1.1900054,1.1957592,1.2014802,1.2071688,1.2128255,1.2184507,1.2240446,1.2296076,1.23514,1.2406422,1.2461144,1.2515571,1.2569705,1.262355,1.2677108,1.2730381,1.2783375,1.2836092,1.2888533,1.2940701,1.2992601,1.3044236,1.3095605,1.3146715,1.3197565,1.3248161,1.3298502,1.3348593,1.3398435,1.3448032,1.3497385,1.3546497,1.3595371,1.3644009,1.369241,1.3740581,1.3788522,1.3836236,1.3883723,1.3930988,1.3978032,1.4024856,1.4071462,1.4117855,1.4164034,1.421,1.4255759,1.430131,1.4346654,1.4391795,1.4436735,1.4481474,1.4526014,1.4570358,1.4614507,1.4658463,1.4702228,1.4745802,1.4789188,1.4832388,1.4875402,1.4918233,1.4960883,1.5003351,1.5045642,1.5087754,1.512969,1.5171453,1.521304,1.5254458,1.5295706,1.5336785,1.5377696,1.541844,1.5459021,1.5499438,1.5539691,1.5579786,1.5619721,1.5659497,1.5699116,1.5738579,1.5777888,1.5817044,1.5856045,1.5894898,1.5933601,1.5972154,1.601056,1.604882,1.6086934,1.6124903,1.616273,1.6200415,1.6237959,1.6275362,1.6312627,1.6349754,1.6386744,1.6423597,1.6460316,1.6496902,1.6533355,1.6569674,1.6605862,1.6641922,1.6677852,1.6713653,1.6749327,1.6784875,1.6820297,1.6855595,1.6890769,1.692582,1.6960747,1.6995555,1.7030243,1.706481,1.7099258,1.7133589,1.7167803,1.72019,1.7235881,1.7269748,1.7303501,1.7337141,1.7370667,1.7404083,1.7437388,1.7470582,1.7503666,1.7536641,1.756951,1.760227,1.7634922,1.766747,1.7699913,1.773225,1.7764482,1.7796613,1.7828641,1.7860566,1.789239,1.7924113,1.7955737,1.798726,1.8018686,1.8050013,1.8081242,1.8112373,1.814341,1.8174349,1.8205193,1.8235943,1.8266599,1.8297162,1.8327632,1.8358008,1.8388294,1.8418489,1.8448591,1.8478605,1.8508528,1.8538363,1.8568108,1.8597766,1.8627336,1.865682,1.8686216,1.8715527,1.8744752,1.8773893,1.8802949,1.8831921,1.886081,1.8889614,1.8918337,1.8946978,1.8975537,1.9004015,1.903241,1.9060727,1.9088964,1.9117123,1.91452,1.9173201,1.9201124,1.9228967,1.9256735,1.9284426,1.931204,1.9339578,1.936704,1.9394429,1.9421742,1.944898,1.9476146,1.9503237,1.9530256,1.9557201,1.9584074,1.9610876,1.9637606,1.9664264,1.9690852,1.971737,1.9743818,1.9770195,1.9796504,1.9822744,1.9848915,1.9875019,1.9901054,1.9927021,1.9952921,1.9978755,2.0004523,2.0030224,2.005586,2.008143,2.0106933,2.0132372,2.015775,2.018306,2.0208306,2.023349,2.0258613,2.028367,2.0308666,2.03336,2.0358472,2.0383282,2.0408027,2.0432715,2.0457342,2.0481908,2.0506415,2.053086,2.0555248,2.0579574,2.0603843,2.0628054,2.0652206,2.0676298,2.0700336,2.0724313,2.0748234,2.0772097,2.0795903,2.0819654,2.0843349,2.0866988,2.089057,2.0914097,2.093757,2.0960984,2.0984347,2.1007657,2.103091,2.105411,2.1077256,2.110035,2.112339,2.1146376,2.1169312,2.1192193,2.1215024,2.1237803,2.1260529,2.1283202,2.1305826,2.1328397,2.135092,2.137339,2.1395812,2.1418183,2.1440504,2.1462774,2.1484995,2.1507168,2.1529293,2.1551368,2.1573393,2.159537,2.16173,2.1639183,2.1661017,2.1682804,2.1704543,2.1726234,2.174788,2.1769478,2.1791031,2.1812534,2.1833994,2.185541,2.1876776,2.18981,2.1919377,2.1940608,2.1961796,2.1982937,2.2004035,2.202509,2.2046099,2.2067063,2.2087986,2.2108862,2.2129698,2.2150488,2.2171235,2.2191942,2.2212603,2.2233224,2.2253802,2.2274337,2.229483,2.231528,2.233569,2.2356057,2.2376385,2.239667,2.2416914,2.2437117,2.245728,2.2477403,2.2497485,2.2517526],"x":[0.5,0.5190381,0.53807616,0.55711424,0.5761523,0.5951904,0.6142284,0.6332665,0.6523046,0.6713427,0.69038075,0.70941883,0.7284569,0.747495,0.7665331,0.78557116,0.80460924,0.8236473,0.84268534,0.8617234,0.8807615,0.8997996,0.91883767,0.93787575,0.9569138,0.9759519,0.99499,1.0140281,1.0330662,1.0521042,1.0711423,1.0901804,1.1092185,1.1282566,1.1472946,1.1663327,1.1853707,1.2044088,1.2234468,1.2424849,1.261523,1.2805611,1.2995992,1.3186373,1.3376753,1.3567134,1.3757515,1.3947896,1.4138277,1.4328657,1.4519038,1.4709419,1.48998,1.5090181,1.5280561,1.5470942,1.5661323,1.5851704,1.6042085,1.6232466,1.6422845,1.6613226,1.6803607,1.6993988,1.7184368,1.7374749,1.756513,1.7755511,1.7945892,1.8136272,1.8326653,1.8517034,1.8707415,1.8897796,1.9088176,1.9278557,1.9468938,1.9659319,1.98497,2.004008,2.023046,2.0420842,2.0611222,2.0801604,2.0991983,2.1182365,2.1372745,2.1563127,2.1753507,2.1943889,2.2134268,2.232465,2.251503,2.2705412,2.2895792,2.3086174,2.3276553,2.3466933,2.3657315,2.3847694,2.4038076,2.4228456,2.4418838,2.4609218,2.47996,2.498998,2.5180361,2.537074,2.5561123,2.5751503,2.5941885,2.6132264,2.6322646,2.6513026,2.6703408,2.6893787,2.708417,2.727455,2.746493,2.765531,2.784569,2.8036072,2.8226452,2.8416834,2.8607213,2.8797596,2.8987975,2.9178357,2.9368737,2.9559119,2.9749498,2.993988,3.013026,3.0320642,3.0511022,3.0701404,3.0891783,3.1082165,3.1272545,3.1462927,3.1653306,3.1843688,3.2034068,3.2224448,3.241483,3.260521,3.2795591,3.298597,3.3176353,3.3366733,3.3557115,3.3747494,3.3937876,3.4128256,3.4318638,3.4509017,3.46994,3.488978,3.508016,3.527054,3.5460923,3.5651302,3.5841684,3.6032064,3.6222446,3.6412826,3.6603208,3.6793587,3.6983967,3.717435,3.7364728,3.755511,3.774549,3.7935872,3.8126252,3.8316634,3.8507013,3.8697395,3.8887775,3.9078157,3.9268537,3.9458919,3.9649298,3.983968,4.003006,4.022044,4.0410824,4.06012,4.0791583,4.0981965,4.1172347,4.1362724,4.1553106,4.174349,4.1933866,4.2124248,4.231463,4.250501,4.269539,4.288577,4.3076153,4.3266535,4.345691,4.3647294,4.3837676,4.402806,4.4218435,4.4408817,4.45992,4.478958,4.497996,4.517034,4.5360723,4.5551105,4.574148,4.5931864,4.6122246,4.6312623,4.6503005,4.6693387,4.688377,4.7074146,4.726453,4.745491,4.764529,4.783567,4.802605,4.8216434,4.8406816,4.8597193,4.8787575,4.8977957,4.916834,4.9358716,4.95491,4.973948,4.992986,5.012024,5.031062,5.0501003,5.069138,5.0881763,5.1072145,5.1262527,5.1452904,5.1643286,5.183367,5.202405,5.2214427,5.240481,5.259519,5.2785573,5.297595,5.316633,5.3356714,5.3547096,5.3737473,5.3927855,5.4118237,5.430862,5.4498997,5.468938,5.487976,5.507014,5.526052,5.54509,5.5641284,5.583166,5.6022043,5.6212425,5.6402807,5.6593184,5.6783566,5.697395,5.716433,5.735471,5.754509,5.773547,5.7925854,5.811623,5.8306613,5.8496995,5.8687377,5.8877754,5.9068136,5.925852,5.9448895,5.9639277,5.982966,6.002004,6.021042,6.04008,6.0591183,6.0781565,6.097194,6.1162324,6.1352706,6.154309,6.1733465,6.1923847,6.211423,6.230461,6.249499,6.268537,6.2875752,6.3066134,6.325651,6.3446894,6.3637276,6.3827653,6.4018035,6.4208417,6.43988,6.4589176,6.477956,6.496994,6.516032,6.53507,6.554108,6.5731463,6.5921845,6.6112223,6.6302605,6.6492987,6.668337,6.6873746,6.706413,6.725451,6.744489,6.763527,6.782565,6.8016033,6.8206415,6.8396792,6.8587174,6.8777556,6.8967934,6.9158316,6.93487,6.953908,6.9729457,6.991984,7.011022,7.0300603,7.049098,7.068136,7.0871744,7.1062126,7.1252503,7.1442885,7.1633267,7.182365,7.2014027,7.220441,7.239479,7.2585173,7.277555,7.296593,7.3156314,7.334669,7.3537073,7.3727455,7.3917837,7.4108214,7.4298596,7.448898,7.467936,7.486974,7.506012,7.52505,7.5440884,7.563126,7.5821643,7.6012025,7.6202407,7.6392784,7.6583166,7.677355,7.696393,7.7154307,7.734469,7.753507,7.772545,7.791583,7.8106213,7.8296595,7.848697,7.8677354,7.8867736,7.905812,7.9248495,7.9438877,7.962926,7.981964,8.001002,8.0200405,8.039078,8.058116,8.077154,8.096192,8.115231,8.134269,8.153307,8.172345,8.191382,8.210421,8.229459,8.248497,8.267535,8.286573,8.305612,8.324649,8.343687,8.362725,8.381763,8.400802,8.41984,8.438878,8.457916,8.4769535,8.495992,8.51503,8.534068,8.553106,8.5721445,8.591183,8.610221,8.629258,8.648296,8.667335,8.686373,8.705411,8.724449,8.743487,8.762525,8.781563,8.800601,8.819639,8.838677,8.857716,8.876754,8.895792,8.914829,8.933867,8.952906,8.971944,8.990982,9.01002,9.029058,9.048097,9.067134,9.086172,9.10521,9.1242485,9.143287,9.162325,9.181363,9.2004,9.219439,9.238477,9.257515,9.276553,9.295591,9.31463,9.333668,9.352705,9.371743,9.390781,9.40982,9.428858,9.447896,9.466934,9.485972,9.50501,9.524048,9.543086,9.562124,9.581162,9.600201,9.619239,9.638276,9.657314,9.6763525,9.695391,9.714429,9.733467,9.752505,9.7715435,9.790581,9.809619,9.828657,9.847695,9.866734,9.885772,9.90481,9.923848,9.942885,9.961924,9.980962,10.0]} diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/runner.jl b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/runner.jl new file mode 100644 index 000000000000..90430ca9e6c2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/runner.jl @@ -0,0 +1,92 @@ +#!/usr/bin/env julia +# +# @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 JSON +using SpecialFunctions + +""" + gen( domain, name ) + +Generate fixture data and write to file. + +# Arguments + +* `domain`: domain +* `name::AbstractString`: output filename + +# Examples + +``` julia +julia> x = range( 0.5, stop = 10.0, length = 100 ); +julia> gen( x, "data.json" ); +``` +""" +function gen( domain, name ) + x = Float32.( collect( domain ) ); + y = digamma.( x ); + + # Store data to be written to file as a collection: + data = Dict([ + ("x", x), + ("expected", y) + ]); + + # Based on the script directory, create an output filepath: + filepath = joinpath( dir, name ); + + # Write the data to the output filepath as JSON: + outfile = open( filepath, "w" ); + write( outfile, JSON.json(data) ); + write( outfile, "\n" ); + close( outfile ); +end + +# Get the filename: +file = @__FILE__; + +# Extract the directory in which this file resides: +dir = dirname( file ); + +# Generate fixture data for positive values (main range): +x = range( 0.5f0, stop = 10.0f0, length = 500 ); +gen( x, "positive.json" ); + +# Generate fixture data for small positive values: +x = range( 0.01f0, stop = 0.5f0, length = 200 ); +gen( x, "small_positive.json" ); + +# Generate fixture data for large positive values: +x = range( 10.0f0, stop = 100.0f0, length = 200 ); +gen( x, "large_positive.json" ); + +# Generate fixture data for negative values (non-integers): +x = range( -9.5f0, stop = -0.1f0, length = 300 ); +gen( x, "negative.json" ); + +# Generate fixture data for values near positive integers: +x = vcat( + range( 0.9f0, stop = 1.1f0, length = 50 ), + range( 1.9f0, stop = 2.1f0, length = 50 ), + range( 2.9f0, stop = 3.1f0, length = 50 ), + range( 4.9f0, stop = 5.1f0, length = 50 ) +); +gen( x, "near_integers.json" ); + +# Generate fixture data for half-integer values (exact): +x = range( -0.5f0, step = -1.0f0, length = 100 ); +gen( x, "half_integers.json" ); diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/small_positive.json b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/small_positive.json new file mode 100644 index 000000000000..f38e32359add --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/small_positive.json @@ -0,0 +1 @@ +{"expected":[-100.56089,-80.798836,-67.5563,-58.063427,-50.924778,-45.360924,-40.902298,-37.249153,-34.201138,-31.619272,-29.404099,-27.48258,-25.799873,-24.313984,-22.992224,-21.808764,-20.74292,-19.777945,-18.900122,-18.098118,-17.362476,-16.685259,-16.059738,-15.480186,-14.9416895,-14.440011,-13.9714775,-13.532888,-13.121445,-12.734682,-12.370428,-12.026758,-11.701961,-11.394508,-11.103036,-10.826317,-10.563246,-10.312828,-10.07416,-9.846425,-9.62888,-9.420845,-9.221704,-9.030889,-8.84788,-8.672203,-8.503417,-8.341119,-8.184935,-8.034519,-7.8895535,-7.7497406,-7.614805,-7.484492,-7.3585615,-7.2367926,-7.1189775,-7.004923,-6.8944464,-6.7873793,-6.6835613,-6.5828443,-6.4850864,-6.3901567,-6.2979302,-6.20829,-6.121126,-6.036334,-5.9538155,-5.873477,-5.7952313,-5.7189946,-5.644688,-5.5722375,-5.5015707,-5.4326215,-5.365325,-5.29962,-5.23545,-5.172758,-5.111493,-5.0516043,-4.9930444,-4.9357677,-4.8797307,-4.824892,-4.7712116,-4.718652,-4.6671767,-4.6167507,-4.567342,-4.518917,-4.471446,-4.4248996,-4.37925,-4.3344703,-4.290534,-4.2474165,-4.2050943,-4.1635447,-4.1227446,-4.0826735,-4.0433106,-4.004637,-3.9666321,-3.9292796,-3.8925607,-3.8564591,-3.8209577,-3.7860415,-3.7516947,-3.7179031,-3.6846526,-3.6519284,-3.6197186,-3.5880094,-3.5567892,-3.5260453,-3.495767,-3.4659421,-3.4365609,-3.4076118,-3.3790855,-3.3509715,-3.3232608,-3.2959435,-3.2690115,-3.2424557,-3.2162673,-3.190439,-3.1649618,-3.1398292,-3.1150327,-3.0905654,-3.0664206,-3.042591,-3.0190701,-2.9958518,-2.972929,-2.9502966,-2.927948,-2.9058776,-2.88408,-2.8625493,-2.8412805,-2.8202682,-2.7995079,-2.7789938,-2.7587223,-2.7386875,-2.718886,-2.6993124,-2.6799634,-2.6608338,-2.6419203,-2.6232183,-2.6047246,-2.5864348,-2.5683455,-2.5504532,-2.532754,-2.515245,-2.4979222,-2.480783,-2.4638236,-2.4470413,-2.4304328,-2.4139955,-2.3977258,-2.3816218,-2.3656802,-2.3498979,-2.334273,-2.3188024,-2.303484,-2.2883148,-2.2732928,-2.2584155,-2.2436805,-2.2290854,-2.2146287,-2.2003071,-2.1861196,-2.1720634,-2.1581366,-2.1443374,-2.1306636,-2.1171136,-2.1036851,-2.0903766,-2.0771863,-2.0641124,-2.051153,-2.0383067,-2.0255716,-2.0129461,-2.000429,-1.9880182,-1.9757122,-1.96351],"x":[0.01,0.012462311,0.014924623,0.017386934,0.019849246,0.022311557,0.02477387,0.02723618,0.029698493,0.032160804,0.034623116,0.03708543,0.039547738,0.04201005,0.044472363,0.04693467,0.049396984,0.051859297,0.05432161,0.05678392,0.05924623,0.061708543,0.06417085,0.066633165,0.06909548,0.07155779,0.0740201,0.076482415,0.07894472,0.08140703,0.083869345,0.08633166,0.08879397,0.09125628,0.093718596,0.0961809,0.09864321,0.101105526,0.10356784,0.10603015,0.108492464,0.11095478,0.11341709,0.115879394,0.11834171,0.12080402,0.12326633,0.12572864,0.12819095,0.13065326,0.13311557,0.13557789,0.1380402,0.14050251,0.14296483,0.14542714,0.14788945,0.15035176,0.15281408,0.15527639,0.1577387,0.160201,0.16266331,0.16512562,0.16758794,0.17005025,0.17251256,0.17497487,0.17743719,0.1798995,0.18236181,0.18482412,0.18728644,0.18974875,0.19221106,0.19467336,0.19713567,0.19959798,0.2020603,0.20452261,0.20698492,0.20944723,0.21190955,0.21437186,0.21683417,0.21929649,0.2217588,0.22422111,0.22668342,0.22914574,0.23160803,0.23407035,0.23653266,0.23899497,0.24145728,0.2439196,0.24638191,0.24884422,0.25130653,0.25376883,0.25623116,0.25869346,0.26115578,0.26361808,0.2660804,0.2685427,0.27100503,0.27346733,0.27592966,0.27839196,0.28085428,0.28331658,0.28577888,0.2882412,0.2907035,0.29316583,0.29562813,0.29809046,0.30055276,0.30301508,0.30547738,0.3079397,0.310402,0.31286433,0.31532663,0.31778896,0.32025126,0.32271355,0.32517588,0.32763818,0.3301005,0.3325628,0.33502513,0.33748743,0.33994976,0.34241205,0.34487438,0.34733668,0.349799,0.3522613,0.35472363,0.35718593,0.35964823,0.36211056,0.36457285,0.36703518,0.36949748,0.3719598,0.3744221,0.37688443,0.37934673,0.38180906,0.38427135,0.38673368,0.38919598,0.3916583,0.3941206,0.3965829,0.39904523,0.40150753,0.40396985,0.40643215,0.40889448,0.41135678,0.4138191,0.4162814,0.41874373,0.42120603,0.42366835,0.42613065,0.42859295,0.43105528,0.43351758,0.4359799,0.4384422,0.44090453,0.44336683,0.44582915,0.44829145,0.45075378,0.45321608,0.4556784,0.4581407,0.46060303,0.46306533,0.46552762,0.46798995,0.47045225,0.47291458,0.47537687,0.4778392,0.4803015,0.48276383,0.48522612,0.48768845,0.49015075,0.49261308,0.49507537,0.4975377,0.5]} diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.js b/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.js new file mode 100644 index 000000000000..39432db8fce4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.js @@ -0,0 +1,226 @@ +/** +* @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 abs = require( '@stdlib/math/base/special/abs' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var digammaf = require( './../lib' ); + + +// FIXTURES // + +var positive = require( './fixtures/julia/positive.json' ); +var smallPositive = require( './fixtures/julia/small_positive.json' ); +var largePositive = require( './fixtures/julia/large_positive.json' ); +var negative = require( './fixtures/julia/negative.json' ); +var nearIntegers = require( './fixtures/julia/near_integers.json' ); +var halfIntegers = require( './fixtures/julia/half_integers.json' ); + + +// TESTS // + +tape('main export is a function', function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof digammaf, 'function', 'main export is a function'); + t.end(); +}); + +tape('the function returns `NaN` if provided `NaN`', function test(t) { + var v = digammaf(NaN); + t.strictEqual(isnanf(v), true, 'returns NaN'); + t.end(); +}); + +tape('the function returns `NaN` if provided `0`', function test(t) { + var v = digammaf(0.0); + t.strictEqual(isnanf(v), true, 'returns NaN'); + t.end(); +}); + +tape('the function returns `NaN` if provided a negative integer', function test(t) { + var v; + var i; + + for (i = -1; i > -100; i--) { + v = digammaf(i); + t.strictEqual(isnanf(v), true, 'returns NaN when provided ' + i); + } + t.end(); +}); + +tape('the function evaluates the digamma function (half-integers)', function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = halfIntegers.x; + expected = halfIntegers.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = float64ToFloat32(expected[i]); + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = abs(y - e); + tol = 150.0 * EPS * abs(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); + +tape('the function computes the digamma function (positive values)', function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = positive.x; + expected = positive.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = float64ToFloat32(expected[i]); + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = abs(y - e); + tol = 350.0 * EPS * abs(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); + +tape('the function computes the digamma function (small positive values)', function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = smallPositive.x; + expected = smallPositive.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = float64ToFloat32(expected[i]); + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = abs(y - e); + tol = 500.0 * EPS * abs(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); + +tape('the function computes the digamma function (large positive values)', function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = largePositive.x; + expected = largePositive.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = float64ToFloat32(expected[i]); + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = abs(y - e); + tol = 100.0 * EPS * abs(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); + +tape('the function computes the digamma function (negative values)', function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = negative.x; + expected = negative.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = float64ToFloat32(expected[i]); + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = abs(y - e); + tol = 500.0 * EPS * abs(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); + +tape('the function computes the digamma function (near integers)', function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = nearIntegers.x; + expected = nearIntegers.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = float64ToFloat32(expected[i]); + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = abs(y - e); + tol = 300.0 * EPS * abs(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.native.js new file mode 100644 index 000000000000..07b7201584c8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.native.js @@ -0,0 +1,234 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var digammaf = tryRequire(resolve(__dirname, './../lib/native.js')); +var opts = { + 'skip': (digammaf instanceof Error) +}; + + +// FIXTURES // + +var positive = require( './fixtures/julia/positive.json' ); +var smallPositive = require( './fixtures/julia/small_positive.json' ); +var largePositive = require( './fixtures/julia/large_positive.json' ); +var negative = require( './fixtures/julia/negative.json' ); +var nearIntegers = require( './fixtures/julia/near_integers.json' ); +var halfIntegers = require( './fixtures/julia/half_integers.json' ); + + +// TESTS // + +tape('main export is a function', opts, function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof digammaf, 'function', 'main export is a function'); + t.end(); +}); + +tape('the function returns `NaN` if provided `NaN`', opts, function test(t) { + var v = digammaf(NaN); + t.strictEqual(isnanf(v), true, 'returns NaN'); + t.end(); +}); + +tape('the function returns `NaN` if provided `0`', opts, function test(t) { + var v = digammaf(0.0); + t.strictEqual(isnanf(v), true, 'returns NaN'); + t.end(); +}); + +tape('the function returns `NaN` if provided a negative integer', opts, function test(t) { + var v; + var i; + + for (i = -1; i > -100; i--) { + v = digammaf(i); + t.strictEqual(isnanf(v), true, 'returns NaN when provided ' + i); + } + t.end(); +}); + +tape('the function computes the digamma function (positive values)', opts, function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = positive.x; + expected = positive.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = expected[i]; + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = absf(y - e); + tol = 500.0 * EPS * absf(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); + +tape('the function computes the digamma function (small positive values)', opts, function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = smallPositive.x; + expected = smallPositive.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = expected[i]; + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = absf(y - e); + tol = 500.0 * EPS * absf(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); + +tape('the function computes the digamma function (large positive values)', opts, function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = largePositive.x; + expected = largePositive.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = expected[i]; + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = absf(y - e); + tol = 100.0 * EPS * absf(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); + +tape('the function computes the digamma function (negative values)', opts, function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = negative.x; + expected = negative.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = expected[i]; + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = absf(y - e); + tol = 500.0 * EPS * absf(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); + +tape('the function evaluates the digamma function (half-integers)', opts, function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = halfIntegers.x; + expected = halfIntegers.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = expected[i]; + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = absf(y - e); + tol = 150.0 * EPS * absf(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); + +tape('the function computes the digamma function (near integers)', opts, function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = nearIntegers.x; + expected = nearIntegers.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = expected[i]; + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = absf(y - e); + tol = 300.0 * EPS * absf(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); From 50316844b4aca49627ffaa44e34f39f9ed5cfaa1 Mon Sep 17 00:00:00 2001 From: officiallyanee Date: Sat, 14 Feb 2026 07:36:08 +0530 Subject: [PATCH 2/8] chore: use absf inplace of abs & add a test --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: 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: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../digammaf/test/fixtures/julia/runner.jl | 4 ++ .../fixtures/julia/very_large_positive.json | 1 + .../math/base/special/digammaf/test/test.js | 53 ++++++++++++++----- .../base/special/digammaf/test/test.native.js | 27 ++++++++++ 4 files changed, 72 insertions(+), 13 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/very_large_positive.json diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/runner.jl b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/runner.jl index 90430ca9e6c2..ae5cb095315b 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/runner.jl +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/runner.jl @@ -90,3 +90,7 @@ gen( x, "near_integers.json" ); # Generate fixture data for half-integer values (exact): x = range( -0.5f0, step = -1.0f0, length = 100 ); gen( x, "half_integers.json" ); + +# Generate fixture for very large positie values: +x = Float32[ 1.0e8, 5.0e8, 1.0e9, 1.0e10, 1.0e20 ]; +gen( x, "very_large_positive.json" ); diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/very_large_positive.json b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/very_large_positive.json new file mode 100644 index 000000000000..9b05e69cbb31 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/fixtures/julia/very_large_positive.json @@ -0,0 +1 @@ +{"expected":[18.420681,20.030119,20.723267,23.02585,46.0517],"x":[1.0e8,5.0e8,1.0e9,1.0e10,1.0e20]} diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.js b/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.js index 39432db8fce4..b5cf6af7e98c 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.js @@ -22,7 +22,7 @@ var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var absf = require( '@stdlib/math/base/special/absf' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var EPS = require( '@stdlib/constants/float32/eps' ); var digammaf = require( './../lib' ); @@ -36,6 +36,7 @@ var largePositive = require( './fixtures/julia/large_positive.json' ); var negative = require( './fixtures/julia/negative.json' ); var nearIntegers = require( './fixtures/julia/near_integers.json' ); var halfIntegers = require( './fixtures/julia/half_integers.json' ); +var veryLargePositive = require( './fixtures/julia/very_large_positive.json' ); // TESTS // @@ -87,8 +88,8 @@ tape('the function evaluates the digamma function (half-integers)', function tes if (y === e) { t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); } else { - delta = abs(y - e); - tol = 150.0 * EPS * abs(e); + delta = absf(y - e); + tol = 150.0 * EPS * absf(e); t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); } } @@ -113,8 +114,8 @@ tape('the function computes the digamma function (positive values)', function te if (y === e) { t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); } else { - delta = abs(y - e); - tol = 350.0 * EPS * abs(e); + delta = absf(y - e); + tol = 350.0 * EPS * absf(e); t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); } } @@ -139,8 +140,8 @@ tape('the function computes the digamma function (small positive values)', funct if (y === e) { t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); } else { - delta = abs(y - e); - tol = 500.0 * EPS * abs(e); + delta = absf(y - e); + tol = 500.0 * EPS * absf(e); t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); } } @@ -165,8 +166,8 @@ tape('the function computes the digamma function (large positive values)', funct if (y === e) { t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); } else { - delta = abs(y - e); - tol = 100.0 * EPS * abs(e); + delta = absf(y - e); + tol = 100.0 * EPS * absf(e); t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); } } @@ -191,8 +192,8 @@ tape('the function computes the digamma function (negative values)', function te if (y === e) { t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); } else { - delta = abs(y - e); - tol = 500.0 * EPS * abs(e); + delta = absf(y - e); + tol = 500.0 * EPS * absf(e); t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); } } @@ -217,8 +218,34 @@ tape('the function computes the digamma function (near integers)', function test if (y === e) { t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); } else { - delta = abs(y - e); - tol = 300.0 * EPS * abs(e); + delta = absf(y - e); + tol = 300.0 * EPS * absf(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); + +tape('the function evaluates the digamma function (very large values)', function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = veryLargePositive.x; + expected = veryLargePositive.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = float64ToFloat32(expected[i]); + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = absf(y - e); + tol = 10.0 * EPS * absf(e); t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); } } diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.native.js index 07b7201584c8..41aeedf61237 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.native.js @@ -44,6 +44,7 @@ var largePositive = require( './fixtures/julia/large_positive.json' ); var negative = require( './fixtures/julia/negative.json' ); var nearIntegers = require( './fixtures/julia/near_integers.json' ); var halfIntegers = require( './fixtures/julia/half_integers.json' ); +var veryLargePositive = require( './fixtures/julia/very_large_positive.json' ); // TESTS // @@ -232,3 +233,29 @@ tape('the function computes the digamma function (near integers)', opts, functio } t.end(); }); + +tape('the function evaluates the digamma function (very large values)', opts, function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = veryLargePositive.x; + expected = veryLargePositive.expected; + + for (i = 0; i < x.length; i++) { + y = digammaf(x[i]); + e = expected[i]; + if (y === e) { + t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + } else { + delta = absf(y - e); + tol = 10.0 * EPS * absf(e); + t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + } + } + t.end(); +}); From 7da6f59f0cfcfeec79e5f2bcacd7839ab7367369 Mon Sep 17 00:00:00 2001 From: officiallyanee Date: Sat, 28 Feb 2026 16:42:38 +0530 Subject: [PATCH 3/8] chore: fix comments & follow stdlib's conventions --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - 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 --- --- .../math/base/special/digammaf/lib/main.js | 133 ++++++++++++------ .../math/base/special/digammaf/src/Makefile | 70 +++++++++ .../math/base/special/digammaf/src/main.c | 71 +++++----- 3 files changed, 198 insertions(+), 76 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/base/special/digammaf/src/Makefile diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/digammaf/lib/main.js index 5e49d1d5ec76..86f9a74bd326 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/lib/main.js @@ -14,27 +14,79 @@ * 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 JavaScript. +* +* ```text +* Cephes Math Library Release 2.2: June, 1992 +* Copyright 1984, 1987, 1992 by Stephen L. Moshier +* Direct inquiries to 30 Frost Street, Cambridge, MA 02140 +* ``` */ 'use strict'; // MODULES // -var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); var floorf = require( '@stdlib/math/base/special/floorf' ); var lnf = require( '@stdlib/math/base/special/lnf' ); -var cotf = require( '@stdlib/math/base/special/cotf' ); +var tanf = require( '@stdlib/math/base/special/tanf' ); var FLOAT32_PI = require( '@stdlib/constants/float32/pi' ); var EULERGAMMA = require( '@stdlib/constants/float32/eulergamma' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var polyvalP = require( './polyval_p.js' ); +// VARIABLES // + +// Threshold above which the asymptotic expansion's correction term is below float32 epsilon: +var ASYMPTOTIC_THRESHOLD = 1.0e8; + +// Minimum value of x for which we use the asymptotic expansion directly: +var MIN_SAFE_ASYMPTOTIC = 10.0; + + // MAIN // /** * Evaluates the digamma function for a single-precision floating-point number. * +* ## Method +* +* 1. For \\\\(x \u003c= 0\\\\), we use the reflection formula +* +* ```tex +* \\psi(1-x) = \\psi(x) + \\frac{\\pi}{\\tan(\\pi \\cdot x)} +* ``` +* +* to make \\\\(x\\\\) positive. +* +* 2. For positive integer \\\\(x \u003c= 10\\\\), we use the recurrence +* +* ```tex +* \\psi(n) = -\\gamma + \\sum_{k=1}^{n-1} \\frac{1}{k} +* ``` +* +* where \\\\(\\gamma\\\\) is the Euler-Mascheroni constant. +* +* 3. For general \\\\(x\\\\), we apply the recurrence relation +* +* ```tex +* \\psi(x+1) = \\psi(x) + \\frac{1}{x} +* ``` +* +* until \\\\(x \u003e= 10\\\\), then use the asymptotic expansion +* +* ```tex +* \\psi(x) = \\ln(x) - \\frac{1}{2x} - \\sum_{k=1}^{\\infty} \\frac{B_{2k}}{2k x^{2k}} +* ``` +* +* where \\\\(B_{2k}\\\\) are Bernoulli numbers. +* * @param {number} x - input value * @returns {number} function value * @@ -64,10 +116,9 @@ var polyvalP = require( './polyval_p.js' ); */ function digammaf(x) { var negative; - var nz; + var tmp; + var rem; var xx; - var p; - var q; var s; var w; var y; @@ -75,8 +126,7 @@ function digammaf(x) { var i; var n; - xx = float64ToFloat32(x); - nz = 0.0; + xx = f32(x); negative = false; if (isnanf(xx)) { @@ -86,58 +136,57 @@ function digammaf(x) { // Handle negative arguments using reflection formula... if (xx <= 0.0) { negative = true; - q = xx; - p = floorf(q); + + // Argument reduction for tan: + rem = f32(xx - floorf(xx)); + + // Reflect: + xx = f32(1.0 - xx); // Check for singularity (negative integer or zero)... - if (p === q) { + if (rem === 0.0) { return NaN; } - - // Compute fractional part... - nz = float64ToFloat32(q - p); - if (nz === 0.5) { - nz = 0.0; - } else { - if (nz > 0.5) { - p += 1.0; - nz = float64ToFloat32(q - p); - } - nz = float64ToFloat32(FLOAT32_PI * cotf(float64ToFloat32(FLOAT32_PI * nz))); // eslint-disable-line max-len + if (rem > 0.5) { + rem = f32(rem - 1.0); } - xx = float64ToFloat32(1.0 - xx); + tmp = f32(FLOAT32_PI / tanf(f32(FLOAT32_PI * rem))); + } else { + tmp = 0.0; } // Use direct formula for small positive integers... - if (xx <= 10.0 && xx === floorf(xx)) { + if (xx <= MIN_SAFE_ASYMPTOTIC && xx === floorf(xx)) { y = 0.0; n = xx; for (i = 1; i < n; i++) { - w = i; - y = float64ToFloat32(y + float64ToFloat32(1.0 / w)); + y = f32(y + f32(1.0 / i)); } - y = float64ToFloat32(y - EULERGAMMA); - } else { - // Use recurrence to make x large enough for asymptotic expansion... - s = xx; - w = 0.0; - while (s < 10.0) { - w = float64ToFloat32(w + float64ToFloat32(1.0 / s)); - s = float64ToFloat32(s + 1.0); + y = f32(y - EULERGAMMA); + if (negative) { + y = f32(y - tmp); } + return y; + } - // Asymptotic expansion... - if (s < 1.0e8) { - z = float64ToFloat32(1.0 / float64ToFloat32(s * s)); - y = float64ToFloat32(z * polyvalP(z)); - } else { - y = 0.0; - } - y = float64ToFloat32(lnf(s) - float64ToFloat32(0.5 / s) - y - w); + // Use recurrence to make x large enough for asymptotic expansion... + s = xx; + w = 0.0; + while (s < MIN_SAFE_ASYMPTOTIC) { + w = f32(w + f32(1.0 / s)); + s = f32(s + 1.0); } + // Asymptotic expansion... + if (s < ASYMPTOTIC_THRESHOLD) { + z = f32(1.0 / f32(s * s)); + y = f32(z * polyvalP(z)); + } else { + y = 0.0; + } + y = f32(lnf(s) - f32(0.5 / s) - y - w); if (negative) { - y = float64ToFloat32(y - nz); + y = f32(y - tmp); } return y; } diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/digammaf/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/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/digammaf/src/main.c b/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c index 779afb443a5c..bc43e505298c 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c @@ -27,14 +27,13 @@ * ``` */ +#include "stdlib/constants/float32/eulergamma.h" +#include "stdlib/constants/float32/pi.h" +#include "stdlib/math/base/assert/is_nanf.h" #include "stdlib/math/base/special/digammaf.h" #include "stdlib/math/base/special/floorf.h" #include "stdlib/math/base/special/lnf.h" -#include "stdlib/math/base/special/cotf.h" -#include "stdlib/math/base/assert/is_nanf.h" -#include "stdlib/constants/float32/pi.h" -#include "stdlib/constants/float32/max.h" -#include "stdlib/constants/float32/eulergamma.h" +#include "stdlib/math/base/special/tanf.h" #include /* Begin auto-generated functions. The following functions are auto-generated. Do not edit directly. */ @@ -54,7 +53,7 @@ * @return evaluated polynomial */ static float polyval_p( const float x ) { - return 0.08333333333333333f + (x * (-0.008333333333333333f + (x * (0.003968253968253968f + (x * -0.004166666666666667f))))); + return 0.08333333333333333f + ( x * ( -0.008333333333333333f + ( x * ( 0.003968253968253968f + ( x * -0.004166666666666667f ) ) ) ) ); } // END: polyval_p @@ -81,8 +80,7 @@ static float polyval_p( const float x ) { * For negative x, the reflection formula is used: * * ```tex -* \psi(1-x) = \psi(x) + \pi \cot(\pi x) -* ``` +* \psi(1-x) = \psi(x) + \frac{\pi}{\tan(\pi \cdot x)}* ``` * * For general positive x, the recurrence relation is applied: * @@ -110,44 +108,48 @@ static float polyval_p( const float x ) { * // returns ~-0.577 */ float stdlib_base_digammaf( const float x ) { - float p, q, nz, s, w, y, z; - int32_t i, n, negative; + float rem; + float tmp; float xx; + float s; + float w; + float y; + float z; + int32_t i; + int32_t n; + int32_t negative; xx = x; - nz = 0.0f; negative = 0; if ( stdlib_base_is_nanf( x ) ) { return x; } - // Handle negative arguments using reflection formula + // If `x` is negative, use reflection... if ( xx <= 0.0f ) { negative = 1; - q = xx; - p = stdlib_base_floorf( q ); - // Check for singularity (negative integer or zero) - if ( p == q ) { + // Argument reduction for tan: + rem = xx - stdlib_base_floorf( xx ); + + // Reflect: + xx = 1.0f - xx; + + // Check for evaluation at a negative pole: + if ( rem == 0.0f ) { return 0.0f / 0.0f; // NaN } - // Compute fractional part - nz = q - p; - if ( nz != 0.5f ) { - if ( nz > 0.5f ) { - p += 1.0f; - nz = q - p; - } - nz = STDLIB_CONSTANT_FLOAT32_PI * stdlib_base_cotf( STDLIB_CONSTANT_FLOAT32_PI * nz ); - } else { - nz = 0.0f; + if ( rem > 0.5f ) { + rem -= 1.0f; } - xx = 1.0f - xx; + tmp = STDLIB_CONSTANT_FLOAT32_PI / stdlib_base_tanf( STDLIB_CONSTANT_FLOAT32_PI * rem ); + } else { + tmp = 0.0f; } - // Use direct formula for small positive integers + // Use direct formula for small positive integers... if ( ( xx <= 10.0f ) && ( xx == stdlib_base_floorf( xx ) ) ) { y = 0.0f; n = (int32_t)xx; @@ -156,10 +158,13 @@ float stdlib_base_digammaf( const float x ) { y += 1.0f / w; } y -= STDLIB_CONSTANT_FLOAT32_EULERGAMMA; - goto done; + if ( negative ) { + y -= tmp; + } + return y; } - // Use recurrence to make x large enough for asymptotic expansion + // Use recurrence to make x large enough for asymptotic expansion... s = xx; w = 0.0f; while ( s < 10.0f ) { @@ -167,7 +172,7 @@ float stdlib_base_digammaf( const float x ) { s += 1.0f; } - // Asymptotic expansion + // Asymptotic expansion... if ( s < 1.0e8f ) { z = 1.0f / ( s * s ); y = z * polyval_p( z ); @@ -176,10 +181,8 @@ float stdlib_base_digammaf( const float x ) { } y = stdlib_base_lnf( s ) - ( 0.5f / s ) - y - w; - -done: if ( negative ) { - y -= nz; + y -= tmp; } return y; } From ce19383d879cb9b1ec469ae577d9bd062ff9a37b Mon Sep 17 00:00:00 2001 From: officiallyanee Date: Wed, 4 Mar 2026 20:17:59 +0530 Subject: [PATCH 4/8] fix: spacing in js files & remove max from dependencies --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../special/digammaf/benchmark/benchmark.js | 18 +- .../digammaf/benchmark/benchmark.native.js | 22 +-- .../math/base/special/digammaf/lib/index.js | 2 - .../math/base/special/digammaf/lib/main.js | 48 +++--- .../math/base/special/digammaf/lib/native.js | 4 +- .../math/base/special/digammaf/manifest.json | 9 +- .../base/special/digammaf/scripts/evalpoly.js | 26 +-- .../math/base/special/digammaf/test/test.js | 154 ++++++++--------- .../base/special/digammaf/test/test.native.js | 157 +++++++++--------- 9 files changed, 218 insertions(+), 222 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.js index 97065f312163..f361c852f03f 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.js @@ -30,23 +30,23 @@ var digammaf = require( './../lib' ); // MAIN // -bench(pkg, function benchmark(b) { +bench( pkg, function benchmark( b ) { var x; var y; var i; b.tic(); - for (i = 0; i < b.iterations; i++) { - x = (randu() * 1000.0) + EPS; - y = digammaf(x); - if (isnanf(y)) { - b.fail('should not return NaN'); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu() * 1000.0 ) + EPS; + y = digammaf( x ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); } } b.toc(); - if (isnanf(y)) { - b.fail('should not return NaN'); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); } - b.pass('benchmark finished'); + b.pass( 'benchmark finished' ); b.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.native.js index fb489abcd586..c44726485453 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.native.js @@ -31,31 +31,31 @@ var pkg = require( './../package.json' ).name; // VARIABLES // -var digammaf = tryRequire(resolve(__dirname, './../lib/native.js')); +var digammaf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); var opts = { - 'skip': (digammaf instanceof Error) + 'skip': ( digammaf instanceof Error ) }; // MAIN // -bench(pkg + '::native', opts, function benchmark(b) { +bench( pkg + '::native', opts, function benchmark( b ) { var x; var y; var i; b.tic(); - for (i = 0; i < b.iterations; i++) { - x = (randu() * 1000.0) + EPS; - y = digammaf(x); - if (isnanf(y)) { - b.fail('should not return NaN'); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu() * 1000.0 ) + EPS; + y = digammaf( x ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); } } b.toc(); - if (isnanf(y)) { - b.fail('should not return NaN'); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); } - b.pass('benchmark finished'); + b.pass( 'benchmark finished' ); b.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/digammaf/lib/index.js index 475d9eda5939..94ec4ae72e1e 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/lib/index.js @@ -53,5 +53,3 @@ var main = require( './main.js' ); // EXPORTS // module.exports = main; - -// exports: { "digammaf": "main" } diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/digammaf/lib/main.js index 86f9a74bd326..ee25f305bd70 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/lib/main.js @@ -114,7 +114,7 @@ var MIN_SAFE_ASYMPTOTIC = 10.0; * var v = digammaf( NaN ); * // returns NaN */ -function digammaf(x) { +function digammaf( x ) { var negative; var tmp; var rem; @@ -126,45 +126,45 @@ function digammaf(x) { var i; var n; - xx = f32(x); + xx = f32( x ); negative = false; - if (isnanf(xx)) { + if ( isnanf( xx ) ) { return xx; } // Handle negative arguments using reflection formula... - if (xx <= 0.0) { + if ( xx <= 0.0 ) { negative = true; // Argument reduction for tan: - rem = f32(xx - floorf(xx)); + rem = f32( xx - floorf( xx ) ); // Reflect: - xx = f32(1.0 - xx); + xx = f32( 1.0 - xx ); // Check for singularity (negative integer or zero)... - if (rem === 0.0) { + if ( rem === 0.0 ) { return NaN; } - if (rem > 0.5) { + if ( rem > 0.5 ) { rem = f32(rem - 1.0); } - tmp = f32(FLOAT32_PI / tanf(f32(FLOAT32_PI * rem))); + tmp = f32( FLOAT32_PI / tanf( f32( FLOAT32_PI * rem ) ) ); } else { tmp = 0.0; } // Use direct formula for small positive integers... - if (xx <= MIN_SAFE_ASYMPTOTIC && xx === floorf(xx)) { + if ( xx <= MIN_SAFE_ASYMPTOTIC && xx === floorf( xx ) ) { y = 0.0; n = xx; - for (i = 1; i < n; i++) { - y = f32(y + f32(1.0 / i)); + for ( i = 1; i < n; i++ ) { + y = f32( y + f32( 1.0 / i ) ); } - y = f32(y - EULERGAMMA); - if (negative) { - y = f32(y - tmp); + y = f32( y - EULERGAMMA ); + if ( negative ) { + y = f32( y - tmp ); } return y; } @@ -172,21 +172,21 @@ function digammaf(x) { // Use recurrence to make x large enough for asymptotic expansion... s = xx; w = 0.0; - while (s < MIN_SAFE_ASYMPTOTIC) { - w = f32(w + f32(1.0 / s)); - s = f32(s + 1.0); + while ( s < MIN_SAFE_ASYMPTOTIC ) { + w = f32( w + f32( 1.0 / s ) ); + s = f32( s + 1.0 ); } // Asymptotic expansion... - if (s < ASYMPTOTIC_THRESHOLD) { - z = f32(1.0 / f32(s * s)); - y = f32(z * polyvalP(z)); + if ( s < ASYMPTOTIC_THRESHOLD ) { + z = f32( 1.0 / f32( s * s ) ); + y = f32( z * polyvalP( z ) ); } else { y = 0.0; } - y = f32(lnf(s) - f32(0.5 / s) - y - w); - if (negative) { - y = f32(y - tmp); + y = f32( lnf( s ) - f32( 0.5 / s ) - y - w ); + if ( negative ) { + y = f32( y - tmp ); } return y; } diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/digammaf/lib/native.js index 0c4010555cd9..bff7372ae600 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/lib/native.js @@ -40,8 +40,8 @@ var addon = require( './../src/addon.node' ); * var v = digammaf( 2.0 ); * // returns ~0.423 */ -function digammaf(x) { - return addon(x); +function digammaf( x ) { + return addon( x ); } diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/manifest.json b/lib/node_modules/@stdlib/math/base/special/digammaf/manifest.json index 60ef5c6a4dc4..56d807319d3d 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/manifest.json @@ -40,9 +40,8 @@ "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/special/floorf", "@stdlib/math/base/special/lnf", - "@stdlib/math/base/special/cotf", + "@stdlib/math/base/special/tanf", "@stdlib/constants/float32/pi", - "@stdlib/constants/float32/max", "@stdlib/constants/float32/eulergamma" ] }, @@ -60,9 +59,8 @@ "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/special/floorf", "@stdlib/math/base/special/lnf", - "@stdlib/math/base/special/cotf", + "@stdlib/math/base/special/tanf", "@stdlib/constants/float32/pi", - "@stdlib/constants/float32/max", "@stdlib/constants/float32/eulergamma" ] }, @@ -80,9 +78,8 @@ "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/special/floorf", "@stdlib/math/base/special/lnf", - "@stdlib/math/base/special/cotf", + "@stdlib/math/base/special/tanf", "@stdlib/constants/float32/pi", - "@stdlib/constants/float32/max", "@stdlib/constants/float32/eulergamma" ] } diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/scripts/evalpoly.js b/lib/node_modules/@stdlib/math/base/special/digammaf/scripts/evalpoly.js index 493ec7a57700..e9b291709bb7 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/scripts/evalpoly.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/scripts/evalpoly.js @@ -46,7 +46,7 @@ var P = [ ]; // Header to add to output files: -var header = licenseHeader('Apache-2.0', 'js', { +var header = licenseHeader( 'Apache-2.0', 'js', { 'year': currentYear(), 'copyright': 'The Stdlib Authors' }); @@ -64,7 +64,7 @@ header += '\n/* This is a generated file. Do not edit directly. */\n'; * @param {string} str - function string * @returns {string} updated content */ -function insert(text, id, str) { +function insert( text, id, str ) { var before; var after; var begin; @@ -73,10 +73,10 @@ function insert(text, id, str) { begin = '// BEGIN: ' + id; end = '// END: ' + id; - before = substringBefore(text, begin); - after = substringAfter(text, end); + before = substringBefore( text, begin ); + after = substringAfter( text, end ); - return format('%s// BEGIN: %s\n\n%s\n%s%s', before, id, str, end, after); + return format( '%s// BEGIN: %s\n\n%s\n%s%s', before, id, str, end, after ); } @@ -104,23 +104,23 @@ function main() { 'name': '' }; - fpath = resolve(__dirname, '..', 'lib', 'polyval_p.js'); - str = header + compile(P, jopts); - writeFileSync(fpath, str, opts); + fpath = resolve( __dirname, '..', 'lib', 'polyval_p.js' ); + str = header + compile( P, jopts ); + writeFileSync( fpath, str, opts ); copts = { 'dtype': 'float', 'name': '' }; - fpath = resolve(__dirname, '..', 'src', 'main.c'); - file = readFileSync(fpath, opts); + fpath = resolve( __dirname, '..', 'src', 'main.c' ); + file = readFileSync( fpath, opts ); copts.name = 'polyval_p'; - str = compileC(P, copts); - file = insert(file, copts.name, str); + str = compileC( P, copts ); + file = insert( file, copts.name, str ); - writeFileSync(fpath, file, opts); + writeFileSync( fpath, file, opts ); } main(); diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.js b/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.js index b5cf6af7e98c..165c0d40fc58 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.js @@ -23,7 +23,7 @@ var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var absf = require( '@stdlib/math/base/special/absf' ); -var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); var EPS = require( '@stdlib/constants/float32/eps' ); var digammaf = require( './../lib' ); @@ -41,36 +41,36 @@ var veryLargePositive = require( './fixtures/julia/very_large_positive.json' ); // TESTS // -tape('main export is a function', function test(t) { - t.ok(true, __filename); - t.strictEqual(typeof digammaf, 'function', 'main export is a function'); +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof digammaf, 'function', 'main export is a function' ); t.end(); }); -tape('the function returns `NaN` if provided `NaN`', function test(t) { - var v = digammaf(NaN); - t.strictEqual(isnanf(v), true, 'returns NaN'); +tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { + var v = digammaf( NaN ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); -tape('the function returns `NaN` if provided `0`', function test(t) { - var v = digammaf(0.0); - t.strictEqual(isnanf(v), true, 'returns NaN'); +tape( 'the function returns `NaN` if provided `0`', function test( t ) { + var v = digammaf( 0.0 ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); -tape('the function returns `NaN` if provided a negative integer', function test(t) { +tape( 'the function returns `NaN` if provided a negative integer', function test( t ) { var v; var i; - for (i = -1; i > -100; i--) { - v = digammaf(i); - t.strictEqual(isnanf(v), true, 'returns NaN when provided ' + i); + for ( i = -1; i > -100; i-- ) { + v = digammaf( i ); + t.strictEqual( isnanf( v ), true, 'returns NaN when provided ' + i ); } t.end(); }); -tape('the function evaluates the digamma function (half-integers)', function test(t) { +tape( 'the function evaluates the digamma function (half-integers)', function test( t ) { var expected; var delta; var tol; @@ -82,21 +82,21 @@ tape('the function evaluates the digamma function (half-integers)', function tes x = halfIntegers.x; expected = halfIntegers.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = float64ToFloat32(expected[i]); - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 150.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 150.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); }); -tape('the function computes the digamma function (positive values)', function test(t) { +tape( 'the function computes the digamma function (positive values)', function test( t ) { var expected; var delta; var tol; @@ -108,21 +108,21 @@ tape('the function computes the digamma function (positive values)', function te x = positive.x; expected = positive.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = float64ToFloat32(expected[i]); - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 350.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 350.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); }); -tape('the function computes the digamma function (small positive values)', function test(t) { +tape( 'the function computes the digamma function (small positive values)', function test( t ) { var expected; var delta; var tol; @@ -134,21 +134,21 @@ tape('the function computes the digamma function (small positive values)', funct x = smallPositive.x; expected = smallPositive.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = float64ToFloat32(expected[i]); - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 500.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 500.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); }); -tape('the function computes the digamma function (large positive values)', function test(t) { +tape( 'the function computes the digamma function (large positive values)', function test( t ) { var expected; var delta; var tol; @@ -160,21 +160,21 @@ tape('the function computes the digamma function (large positive values)', funct x = largePositive.x; expected = largePositive.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = float64ToFloat32(expected[i]); - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 100.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 100.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); }); -tape('the function computes the digamma function (negative values)', function test(t) { +tape( 'the function computes the digamma function (negative values)', function test( t ) { var expected; var delta; var tol; @@ -186,21 +186,21 @@ tape('the function computes the digamma function (negative values)', function te x = negative.x; expected = negative.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = float64ToFloat32(expected[i]); - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 500.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 500.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); }); -tape('the function computes the digamma function (near integers)', function test(t) { +tape( 'the function computes the digamma function (near integers)', function test( t ) { var expected; var delta; var tol; @@ -212,21 +212,21 @@ tape('the function computes the digamma function (near integers)', function test x = nearIntegers.x; expected = nearIntegers.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = float64ToFloat32(expected[i]); - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 300.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 300.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); }); -tape('the function evaluates the digamma function (very large values)', function test(t) { +tape( 'the function evaluates the digamma function (very large values)', function test( t ) { var expected; var delta; var tol; @@ -238,15 +238,15 @@ tape('the function evaluates the digamma function (very large values)', function x = veryLargePositive.x; expected = veryLargePositive.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = float64ToFloat32(expected[i]); - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 10.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 10.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.native.js index 41aeedf61237..31677ad7ebba 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/test/test.native.js @@ -24,15 +24,16 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var absf = require( '@stdlib/math/base/special/absf' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); var EPS = require( '@stdlib/constants/float32/eps' ); var tryRequire = require( '@stdlib/utils/try-require' ); // VARIABLES // -var digammaf = tryRequire(resolve(__dirname, './../lib/native.js')); +var digammaf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); var opts = { - 'skip': (digammaf instanceof Error) + 'skip': ( digammaf instanceof Error ) }; @@ -49,36 +50,36 @@ var veryLargePositive = require( './fixtures/julia/very_large_positive.json' ); // TESTS // -tape('main export is a function', opts, function test(t) { - t.ok(true, __filename); - t.strictEqual(typeof digammaf, 'function', 'main export is a function'); +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof digammaf, 'function', 'main export is a function' ); t.end(); }); -tape('the function returns `NaN` if provided `NaN`', opts, function test(t) { - var v = digammaf(NaN); - t.strictEqual(isnanf(v), true, 'returns NaN'); +tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { + var v = digammaf( NaN ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); -tape('the function returns `NaN` if provided `0`', opts, function test(t) { - var v = digammaf(0.0); - t.strictEqual(isnanf(v), true, 'returns NaN'); +tape( 'the function returns `NaN` if provided `0`', opts, function test( t ) { + var v = digammaf( 0.0 ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); -tape('the function returns `NaN` if provided a negative integer', opts, function test(t) { +tape( 'the function returns `NaN` if provided a negative integer', opts, function test( t ) { var v; var i; - for (i = -1; i > -100; i--) { - v = digammaf(i); - t.strictEqual(isnanf(v), true, 'returns NaN when provided ' + i); + for ( i = -1; i > -100; i-- ) { + v = digammaf( i ); + t.strictEqual( isnanf( v ), true, 'returns NaN when provided ' + i ); } t.end(); }); -tape('the function computes the digamma function (positive values)', opts, function test(t) { +tape( 'the function computes the digamma function (positive values)', opts, function test( t ) { var expected; var delta; var tol; @@ -90,21 +91,21 @@ tape('the function computes the digamma function (positive values)', opts, funct x = positive.x; expected = positive.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = expected[i]; - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 500.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 500.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); }); -tape('the function computes the digamma function (small positive values)', opts, function test(t) { +tape( 'the function computes the digamma function (small positive values)', opts, function test( t ) { var expected; var delta; var tol; @@ -116,21 +117,21 @@ tape('the function computes the digamma function (small positive values)', opts, x = smallPositive.x; expected = smallPositive.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = expected[i]; - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 500.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 500.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); }); -tape('the function computes the digamma function (large positive values)', opts, function test(t) { +tape( 'the function computes the digamma function (large positive values)', opts, function test( t ) { var expected; var delta; var tol; @@ -142,21 +143,21 @@ tape('the function computes the digamma function (large positive values)', opts, x = largePositive.x; expected = largePositive.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = expected[i]; - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 100.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 100.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); }); -tape('the function computes the digamma function (negative values)', opts, function test(t) { +tape( 'the function computes the digamma function (negative values)', opts, function test( t ) { var expected; var delta; var tol; @@ -168,21 +169,21 @@ tape('the function computes the digamma function (negative values)', opts, funct x = negative.x; expected = negative.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = expected[i]; - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 500.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 500.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); }); -tape('the function evaluates the digamma function (half-integers)', opts, function test(t) { +tape( 'the function evaluates the digamma function (half-integers)', opts, function test( t ) { var expected; var delta; var tol; @@ -194,21 +195,21 @@ tape('the function evaluates the digamma function (half-integers)', opts, functi x = halfIntegers.x; expected = halfIntegers.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = expected[i]; - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 150.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 150.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); }); -tape('the function computes the digamma function (near integers)', opts, function test(t) { +tape( 'the function computes the digamma function (near integers)', opts, function test( t ) { var expected; var delta; var tol; @@ -220,21 +221,21 @@ tape('the function computes the digamma function (near integers)', opts, functio x = nearIntegers.x; expected = nearIntegers.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = expected[i]; - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 300.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 300.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); }); -tape('the function evaluates the digamma function (very large values)', opts, function test(t) { +tape( 'the function evaluates the digamma function (very large values)', opts, function test( t ) { var expected; var delta; var tol; @@ -246,15 +247,15 @@ tape('the function evaluates the digamma function (very large values)', opts, fu x = veryLargePositive.x; expected = veryLargePositive.expected; - for (i = 0; i < x.length; i++) { - y = digammaf(x[i]); - e = expected[i]; - if (y === e) { - t.strictEqual(y, e, 'x: ' + x[i] + '. E: ' + e); + for ( i = 0; i < x.length; i++ ) { + y = digammaf( x[ i ] ); + e = f32( expected[ i ] ); + if ( y === e ) { + t.strictEqual( y, e, 'x: ' + x[ i ] + '. E: ' + e ); } else { - delta = absf(y - e); - tol = 10.0 * EPS * absf(e); - t.ok(delta <= tol, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.'); + delta = absf( y - e ); + tol = 10.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. y: ' + y + '. E: ' + e + '. tol: ' + tol + '. Δ: ' + delta + '.' ); } } t.end(); From 5e5dcd63ccc21be2c139701266c6da536c0dd30f Mon Sep 17 00:00:00 2001 From: officiallyanee Date: Wed, 4 Mar 2026 20:26:50 +0530 Subject: [PATCH 5/8] bench: refactor to use string interpolation in math/base/special/digammaf --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: 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: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/digammaf/benchmark/benchmark.js | 3 ++- .../math/base/special/digammaf/benchmark/benchmark.native.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.js index f361c852f03f..f4bbd697c65b 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.js @@ -24,13 +24,14 @@ var bench = require( '@stdlib/bench' ); var randu = require( '@stdlib/random/base/randu' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var EPS = require( '@stdlib/constants/float32/eps' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var digammaf = require( './../lib' ); // MAIN // -bench( pkg, function benchmark( b ) { +bench( format( '%s', pkg ), function benchmark( b ) { var x; var y; var i; diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.native.js index c44726485453..c8addb1dcc35 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/benchmark/benchmark.native.js @@ -26,6 +26,7 @@ var randu = require( '@stdlib/random/base/randu' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var EPS = require( '@stdlib/constants/float32/eps' ); var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -39,7 +40,7 @@ var opts = { // MAIN // -bench( pkg + '::native', opts, function benchmark( b ) { +bench( format( '%s::native', pkg ), opts, function benchmark( b ) { var x; var y; var i; From e8b7b599f56784fe6e7e0886cd62b79ad355cfea Mon Sep 17 00:00:00 2001 From: officiallyanee Date: Wed, 4 Mar 2026 20:28:17 +0530 Subject: [PATCH 6/8] fix: spacing in main.c --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: 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: passed - 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 --- --- lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c b/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c index bc43e505298c..def6d72f04a8 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c @@ -53,7 +53,7 @@ * @return evaluated polynomial */ static float polyval_p( const float x ) { - return 0.08333333333333333f + ( x * ( -0.008333333333333333f + ( x * ( 0.003968253968253968f + ( x * -0.004166666666666667f ) ) ) ) ); + return 0.08333333333333333f + (x * (-0.008333333333333333f + (x * (0.003968253968253968f + (x * -0.004166666666666667f))))); } // END: polyval_p From 51d474d2fa7c3387452a7548ffc523206e951659 Mon Sep 17 00:00:00 2001 From: officiallyanee Date: Thu, 5 Mar 2026 19:54:34 +0530 Subject: [PATCH 7/8] fix: spacomg in index.js & update notice header in main.c --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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: passed - 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/digammaf/examples/index.js | 4 ++-- .../@stdlib/math/base/special/digammaf/src/main.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/digammaf/examples/index.js index 6695687ddb91..1855eddfaf45 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/examples/index.js @@ -25,6 +25,6 @@ var digammaf = require( './../lib' ); var opts = { 'dtype': 'float32' }; -var x = uniform(100, -5.0, 5.0, opts); +var x = uniform( 100, -5.0, 5.0, opts ); -logEachMap('x: %0.4f, f(x): %0.4f', x, digammaf); +logEachMap( 'x: %0.4f, f(x): %0.4f', x, digammaf ); diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c b/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c index def6d72f04a8..e3ca51451717 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/src/main.c @@ -18,7 +18,7 @@ * * ## 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 JavaScript. +* 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 * Cephes Math Library Release 2.2: June, 1992 From 050b403372e71c2ccfa67a28b90010a19e8870f9 Mon Sep 17 00:00:00 2001 From: officiallyanee Date: Thu, 5 Mar 2026 20:18:41 +0530 Subject: [PATCH 8/8] chore: update return to add f suffix --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - 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: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/math/base/special/digammaf/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/digammaf/README.md b/lib/node_modules/@stdlib/math/base/special/digammaf/README.md index d7cc40e2281b..12f9d0d3d15e 100644 --- a/lib/node_modules/@stdlib/math/base/special/digammaf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/digammaf/README.md @@ -145,10 +145,10 @@ Evaluates the [digamma function][digamma-function] for a single-precision floati ```c float out = stdlib_base_digammaf( 1.0f ); -// returns ~-0.577 +// returns ~-0.577f out = stdlib_base_digammaf( 2.0f ); -// returns ~0.423 +// returns ~0.423f ``` The function accepts the following arguments: