From 7edf42cd800971a676a96067514e7e26452dec87 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Tue, 28 Jan 2025 14:04:07 +0000 Subject: [PATCH 1/4] feat: add math/base/special/negafibonaccif --- 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: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../base/special/negafibonaccif/README.md | 273 ++++++++++++++++ .../negafibonaccif/benchmark/benchmark.js | 307 ++++++++++++++++++ .../benchmark/benchmark.native.js | 61 ++++ .../negafibonaccif/benchmark/c/Makefile | 127 ++++++++ .../negafibonaccif/benchmark/c/benchmark.c | 151 +++++++++ .../benchmark/c/native/Makefile | 146 +++++++++ .../benchmark/c/native/benchmark.c | 136 ++++++++ .../negafibonaccif/benchmark/julia/REQUIRE | 2 + .../benchmark/julia/benchmark.jl | 156 +++++++++ .../base/special/negafibonaccif/binding.gyp | 170 ++++++++++ .../img/equation_negafibonacci_fibonacci.svg | 36 ++ ...tion_negafibonacci_recurrence_relation.svg | 33 ++ .../img/equation_negafibonacci_sequence.svg | 70 ++++ .../base/special/negafibonaccif/docs/repl.txt | 51 +++ .../negafibonaccif/docs/types/index.d.ts | 74 +++++ .../special/negafibonaccif/docs/types/test.ts | 44 +++ .../negafibonaccif/examples/c/Makefile | 146 +++++++++ .../negafibonaccif/examples/c/example.c | 31 ++ .../special/negafibonaccif/examples/index.js | 29 ++ .../base/special/negafibonaccif/include.gypi | 53 +++ .../stdlib/math/base/special/negafibonaccif.h | 40 +++ .../base/special/negafibonaccif/lib/index.js | 58 ++++ .../base/special/negafibonaccif/lib/main.js | 93 ++++++ .../base/special/negafibonaccif/lib/native.js | 70 ++++ .../negafibonaccif/lib/negafibonaccif.json | 1 + .../base/special/negafibonaccif/manifest.json | 75 +++++ .../base/special/negafibonaccif/package.json | 68 ++++ .../base/special/negafibonaccif/src/Makefile | 70 ++++ .../base/special/negafibonaccif/src/addon.c | 24 ++ .../base/special/negafibonaccif/src/main.c | 83 +++++ .../base/special/negafibonaccif/test/test.js | 106 ++++++ .../negafibonaccif/test/test.native.js | 96 ++++++ 32 files changed, 2880 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/julia/REQUIRE create mode 100755 lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/julia/benchmark.jl create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_fibonacci.svg create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_recurrence_relation.svg create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_sequence.svg create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/include/stdlib/math/base/special/negafibonaccif.h create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/negafibonaccif.json create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/README.md b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/README.md new file mode 100644 index 000000000000..c6eb5ca10a26 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/README.md @@ -0,0 +1,273 @@ + + +# negaFibonaccif + +> Compute the nth [negaFibonacci number][fibonacci-number] as a single-precision floating-point number. + +
+ +The [negaFibonacci numbers][fibonacci-number] are the integer sequence + + + +```math +0, 1, -1, 2, -3, 5, -8, 13, -21, 34, -55, 89, -144, \ldots +``` + + + + + +The sequence is defined by the recurrence relation + + + +```math +F_{n-2} = F_{n} - F_{n-1} +``` + + + + + +which yields + + + +```math +F_{-n} = (-1)^{n+1} F_n +``` + + + + + +with seed values `F_0 = 0` and `F_{-1} = 1`. + +
+ + + +
+ +## Usage + +```javascript +var negafibonaccif = require( '@stdlib/math/base/special/negafibonaccif' ); +``` + +#### negafibonaccif( n ) + +Computes the nth [negaFibonacci number][fibonacci-number] as a single-precision floating-point number. + +```javascript +var v = negafibonaccif( 0 ); +// returns 0 + +v = negafibonaccif( -1 ); +// returns 1 + +v = negafibonaccif( -2 ); +// returns -1 + +v = negafibonaccif( -3 ); +// returns 2 + +v = negafibonaccif( -36 ); +// returns -14930352 +``` + +If `n < -36`, the function returns `NaN`, as larger [negaFibonacci numbers][fibonacci-number] cannot be safely represented in [single-precision floating-point format][ieee754]. + +```javascript +var v = negafibonaccif( -37 ); +// returns NaN +``` + +If not provided a nonpositive integer value, the function returns `NaN`. + +```javascript +var v = negafibonaccif( -3.14 ); +// returns NaN + +v = negafibonaccif( 1 ); +// returns NaN +``` + +If provided `NaN`, the function returns `NaN`. + +```javascript +var v = negafibonaccif( NaN ); +// returns NaN +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var negafibonaccif = require( '@stdlib/math/base/special/negafibonaccif' ); + +var v; +var i; + +for ( i = 0; i > -37; i-- ) { + v = negafibonaccif( i ); + console.log( v ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/negafibonaccif.h" +``` + +#### stdlib_base_negafibonaccif( n ) + +Computes the nth [negaFibonacci number][fibonacci-number] as a single-precision floating-point number. + +```c +float out = stdlib_base_negafibonaccif( 0 ); +// returns 0.0f + +out = stdlib_base_fibonaccif( -1 ); +// returns 1.0f +``` + +The function accepts the following arguments: + +- **n**: `[in] int32_t` input value. + +```c +float stdlib_base_negafibonaccif( const int32_t n ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/negafibonaccif.h" +#include +#include + +int main( void ) { + int32_t i; + float v; + + for ( i = 0; i > -37; i-- ) { + v = stdlib_base_negafibonaccif( i ); + printf( "negafibonaccif(%d) = %f\n", i, v ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js new file mode 100644 index 000000000000..9bed14fac94a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js @@ -0,0 +1,307 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var roundf = require( '@stdlib/math/base/special/roundf' ); +var sqrtf = require( '@stdlib/math/base/special/sqrtf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var PHI = require( '@stdlib/constants/float32/phi' ); +var pkg = require( './../package.json' ).name; +var NEGAFIBONACCIF = require( './../lib/negafibonaccif.json' ); +var negafibonaccif = require( './../lib' ); + + +// VARIABLES // + +var SQRT_5 = sqrtf( 5.0 ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var i; + + x = discreteUniform( 100, -36.0, 0.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = negafibonaccif( x[ i % 100 ] ); + 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(); +}); + +bench( pkg+'::analytic', function benchmark( b ) { + var x; + var y; + var i; + + function negafibonaccif( n ) { + var an = absf( n ); + return pow( -1.0, an+1 ) * roundf( pow( PHI, an ) / SQRT_5 ); + } + + x = discreteUniform( 100, -36.0, 0.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = negafibonaccif( x[ i % 100 ] ); + 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(); +}); + +bench( pkg+'::table', function benchmark( b ) { + var x; + var y; + var i; + + x = discreteUniform( 100, -36.0, 0.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = NEGAFIBONACCIF[ absf( x[ i % 100 ] ) ]; + 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(); +}); + +bench( pkg+'::naive_recursion', function benchmark( b ) { + var x; + var y; + var i; + + function negafibonaccif( n ) { + if ( n === 0 ) { + return n; + } + if ( n === -1 ) { + return 1; + } + return negafibonaccif( n+2 ) - negafibonaccif( n+1 ); + } + + x = discreteUniform( 100, -36.0, 0.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = negafibonaccif( x[ i % 100 ] ); + 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(); +}); + +bench( pkg+'::recursion_memoized', function benchmark( b ) { + var arr; + var N; + var x; + var y; + var i; + + arr = new Array( 37 ); + arr[ 0 ] = 0; + arr[ 1 ] = 1; + arr[ 2 ] = -1; + N = 2; + + function negafibonaccif( n ) { + var an = absf( n ); + if ( an <= N ) { + return arr[ an ]; + } + arr[ an ] = negafibonaccif( n+2 ) - negafibonaccif( n+1 ); + return arr[ an ]; + } + + x = discreteUniform( 100, -36.0, 0.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = negafibonaccif( x[ i % 100 ] ); + 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(); +}); + +bench( pkg+'::naive_iterative', function benchmark( b ) { + var x; + var y; + var i; + + function negafibonaccif( n ) { + var arr; + var an; + var i; + + an = absf( n ); + + arr = new Array( an+1 ); + arr[ 0 ] = 0; + arr[ 1 ] = 1; + arr[ 2 ] = -1; + for ( i = 3; i <= an; i++ ) { + arr[ i ] = arr[ i-2 ] - arr[ i-1 ]; + } + return arr[ an ]; + } + + x = discreteUniform( 100, -36.0, 0.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = negafibonaccif( x[ i % 100 ] ); + 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(); +}); + +bench( pkg+'::iterative', function benchmark( b ) { + var x; + var y; + var i; + + function negafibonaccif( n ) { + var an; + var a; + var b; + var c; + var i; + + an = absf( n ); + + a = 1; + b = -1; + for ( i = 3; i <= an; i++ ) { + c = a - b; + a = b; + b = c; + } + return b; + } + + x = discreteUniform( 100, -36.0, 0.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = negafibonaccif( x[ i % 100 ] ); + 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(); +}); + +bench( pkg+'::iterative_memoized', function benchmark( b ) { + var arr; + var N; + var x; + var y; + var i; + + arr = new Array( 37 ); + arr[ 0 ] = 0; + arr[ 1 ] = 1; + arr[ 2 ] = -1; + N = 2; + + function negafibonaccif( n ) { + var an; + var i; + + an = absf( n ); + if ( an > N ) { + for ( i = N; i <= an; i++ ) { + arr[ i ] = arr[ i-2 ] - arr[ i-1 ]; + } + N = an; + } + return arr[ an ]; + } + + x = discreteUniform( 100, -36.0, 0.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = negafibonaccif( x[ i % 100 ] ); + 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/negafibonaccif/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.native.js new file mode 100644 index 000000000000..212a779f501a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.native.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var negafibonaccif = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( negafibonaccif instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var x; + var y; + var i; + + x = discreteUniform( 100, -36.0, 0.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = negafibonaccif( x[ i % 100 ] ); + 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/negafibonaccif/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/Makefile new file mode 100644 index 000000000000..d564e8b2d6f9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/Makefile @@ -0,0 +1,127 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles C source files. +# +# @param {string} [C_COMPILER] - C compiler +# @param {string} [CFLAGS] - C compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler +# @param {string} CFLAGS - C compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $< -lm + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/benchmark.c new file mode 100644 index 000000000000..7077f1b6a3cb --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/benchmark.c @@ -0,0 +1,151 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include +#include +#include +#include + +#define NAME "negafibonaccif::naive_recursion" +#define ITERATIONS 100 +#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 ); +} + +/** +* Computes the nth negaFibonacci number. +* +* @param n negaFibonacci number to compute +* @return negaFibonacci number +*/ +int negafibonacci( int n ) { + if ( n == 0 ) { + return 0; + } + if ( n == -1 ) { + return 1; + } + return negafibonacci( n+2 ) - negafibonacci( n+1 ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + int x[ 100 ]; + double t; + int y; + int i; + + for ( i = 0; i < 100; i++ ) { + x[ i ] = (int)floor( 36.0f * rand_float() ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = negafibonacci( -x[ i % 100 ] ); + if ( y == 7 ) { + printf( "should not return 7\n" ); + break; + } + } + elapsed = tic() - t; + if ( y == 7 ) { + printf( "should not return 7\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/native/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/native/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 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/negafibonaccif/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..20633d6f34bb --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/native/benchmark.c @@ -0,0 +1,136 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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/negafibonaccif.h" +#include +#include +#include +#include +#include + +#define NAME "negafibonaccif" +#define ITERATIONS 100 +#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 ) { + int32_t x[ 100 ]; + double elapsed; + double t; + double y; + int i; + + for ( i = 0; i < 100; i++ ) { + x[ i ] = (int32_t)floor( 36.0f * rand_float()); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_negafibonaccif( -x[ i % 100 ] ); + if ( y != y ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y != y ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::native::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i + 1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/julia/REQUIRE b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/julia/REQUIRE new file mode 100644 index 000000000000..98645e192e41 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/julia/REQUIRE @@ -0,0 +1,2 @@ +julia 1.5 +BenchmarkTools 0.5.0 diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/julia/benchmark.jl new file mode 100755 index 000000000000..d66af4f571d0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/julia/benchmark.jl @@ -0,0 +1,156 @@ +#!/usr/bin/env julia +# +# @license Apache-2.0 +# +# Copyright (c) 2025 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 BenchmarkTools +using Printf + +# Benchmark variables: +name = "negafibonaccif::naive_recursion"; +repeats = 3; + +""" + print_version() + +Prints the TAP version. + +# Examples + +``` julia +julia> print_version() +``` +""" +function print_version() + @printf( "TAP version 13\n" ); +end + +""" + print_summary( total, passing ) + +Print the benchmark summary. + +# Arguments + +* `total`: total number of tests +* `passing`: number of passing tests + +# Examples + +``` julia +julia> print_summary( 3, 3 ) +``` +""" +function print_summary( total, 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" ); +end + +""" + print_results( iterations, elapsed ) + +Print benchmark results. + +# Arguments + +* `iterations`: number of iterations +* `elapsed`: elapsed time (in seconds) + +# Examples + +``` julia +julia> print_results( 1000000, 0.131009101868 ) +``` +""" +function print_results( iterations, elapsed ) + rate = iterations / elapsed + + @printf( " ---\n" ); + @printf( " iterations: %d\n", iterations ); + @printf( " elapsed: %0.9f\n", elapsed ); + @printf( " rate: %0.9f\n", rate ); + @printf( " ...\n" ); +end + +""" + benchmark() + +Run a benchmark. + +# Notes + +* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. +* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. +* The elapsed time is in seconds. + +# Examples + +``` julia +julia> out = benchmark(); +``` +""" +function benchmark() + # Define a NegaFibonacci recurrence relation: + function nfib( n ) + if n == 0 + return 0; + end + if n == -1 + return 1; + end + return nfib( n+2 ) - nfib( n+1 ); + end + + # Benchmark: + t = BenchmarkTools.@benchmark $nfib( -floor( 36.0*rand() ) ) samples=1e6 + + # Compute the total "elapsed" time and convert from nanoseconds to seconds: + s = sum( t.times ) / 1.0e9; + + # Determine the number of "iterations": + iter = length( t.times ); + + # Return the results: + [ iter, s ]; +end + +""" + main() + +Run benchmarks. + +# Examples + +``` julia +julia> main(); +``` +""" +function main() + print_version(); + for i in 1:repeats + @printf( "# julia::%s\n", name ); + results = benchmark(); + print_results( results[ 1 ], results[ 2 ] ); + @printf( "ok %d benchmark finished\n", i ); + end + print_summary( repeats, repeats ); +end + +main(); diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/binding.gyp b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/binding.gyp new file mode 100644 index 000000000000..68a1ca11d160 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_fibonacci.svg b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_fibonacci.svg new file mode 100644 index 000000000000..4c79febb4e15 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_fibonacci.svg @@ -0,0 +1,36 @@ + +upper F Subscript negative n Baseline equals left-parenthesis negative 1 right-parenthesis Superscript n plus 1 Baseline upper F Subscript n + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_recurrence_relation.svg b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_recurrence_relation.svg new file mode 100644 index 000000000000..7fa6352d483d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_recurrence_relation.svg @@ -0,0 +1,33 @@ + +upper F Subscript n minus 2 Baseline equals upper F Subscript n Baseline minus upper F Subscript n minus 1 + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_sequence.svg b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_sequence.svg new file mode 100644 index 000000000000..3fe150d2e720 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_sequence.svg @@ -0,0 +1,70 @@ + +0 comma 1 comma negative 1 comma 2 comma negative 3 comma 5 comma negative 8 comma 13 comma negative 21 comma 34 comma negative 55 comma 89 comma negative 144 comma ellipsis + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/repl.txt new file mode 100644 index 000000000000..4f9de6d10d9f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/repl.txt @@ -0,0 +1,51 @@ + +{{alias}}( n ) + Compute the nth negaFibonacci number as a single-precision floating-point + number. + + The negaFibonacci numbers follow the recurrence relation + + F_{n-2} = F_{n} - F_{n-1} + + with seed values F_0 = 0 and F_{-1} = 1. + + If `|n|` is greater than `36`, the function returns `NaN` as larger + negaFibonacci numbers cannot be accurately represented due to limitations of + single-precision floating-point format. + + If not provided a non-positive integer value, the function returns `NaN`. + + If provided `NaN`, the function returns `NaN`. + + Parameters + ---------- + n: integer + Input value. + + Returns + ------- + y: integer + NegaFibonacci number. + + Examples + -------- + > var y = {{alias}}( 0 ) + 0 + > y = {{alias}}( -1 ) + 1 + > y = {{alias}}( -2 ) + -1 + > y = {{alias}}( -3 ) + 2 + > y = {{alias}}( -4 ) + -3 + > y = {{alias}}( -37 ) + NaN + > y = {{alias}}( -38 ) + NaN + > y = {{alias}}( NaN ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/types/index.d.ts new file mode 100644 index 000000000000..0af2e28d3a0e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/types/index.d.ts @@ -0,0 +1,74 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 + +/** +* Compute the nth negaFibonacci number as a single-precision floating-point number. +* +* ## Notes +* +* - The negaFibonacci numbers follow the recurrence relation `F_{n-2} = F_{n} - F_{n-1}` with seed values `F_0 = 0` and `F_{-1} = 1`. +* - If `|n|` is greater than `36`, the function returns `NaN` as larger negaFibonacci numbers cannot be accurately represented due to limitations of single-precision floating-point format. +* - If not provided a non-positive integer value, the function returns `NaN`. +* +* @param n - the negaFibonacci number to compute +* @returns negaFibonacci number +* +* @example +* var y = negafibonaccif( 0 ); +* // returns 0 +* +* @example +* var y = negafibonaccif( -1 ); +* // returns 1 +* +* @example +* var y = negafibonaccif( -2 ); +* // returns -1 +* +* @example +* var y = negafibonaccif( -3 ); +* // returns 2 +* +* @example +* var y = negafibonaccif( -4 ); +* // returns -3 +* +* @example +* var y = negafibonaccif( -5 ); +* // returns 5 +* +* @example +* var y = negafibonaccif( -6 ); +* // returns -8 +* +* @example +* var y = negafibonaccif( NaN ); +* // returns NaN +* +* @example +* var y = negafibonaccif( -3.14 ); +* // returns NaN +*/ +declare function negafibonaccif( n: number ): number; + + +// EXPORTS // + +export = negafibonaccif; diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/types/test.ts new file mode 100644 index 000000000000..afa0d2e1a065 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/types/test.ts @@ -0,0 +1,44 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 negafibonaccif = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + negafibonaccif( -8 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a number... +{ + negafibonaccif( true ); // $ExpectError + negafibonaccif( false ); // $ExpectError + negafibonaccif( null ); // $ExpectError + negafibonaccif( undefined ); // $ExpectError + negafibonaccif( '5' ); // $ExpectError + negafibonaccif( [] ); // $ExpectError + negafibonaccif( {} ); // $ExpectError + negafibonaccif( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + negafibonaccif(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 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/negafibonaccif/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/c/example.c new file mode 100644 index 000000000000..1b0e5d3a3ffc --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/c/example.c @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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/negafibonaccif.h" +#include +#include + +int main( void ) { + int32_t i; + float v; + + for ( i = 0; i > -37; i-- ) { + v = stdlib_base_negafibonaccif( i ); + printf( "negafibonaccif(%d) = %f\n", i, v ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/index.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/index.js new file mode 100644 index 000000000000..288c2d0a9eed --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/index.js @@ -0,0 +1,29 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 negafibonaccif = require( '@stdlib/math/base/special/negafibonaccif' ); + +var v; +var i; + +for ( i = 0; i > -37; i-- ) { + v = negafibonaccif( i ); + console.log( v ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/include.gypi b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/include.gypi new file mode 100644 index 000000000000..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Compute the nth negaFibonacci number as a single-precision floating-point number. +*/ +float stdlib_base_negafibonaccif( const int32_t n ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_NEGAFIBONACCIF_H diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/index.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/index.js new file mode 100644 index 000000000000..f66af2ae9a4f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/index.js @@ -0,0 +1,58 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Compute the nth negaFibonacci number as a single-precision floating-point number. +* +* @module @stdlib/math/base/special/negafibonaccif +* +* @example +* var negafibonaccif = require( '@stdlib/math/base/special/negafibonaccif' ); +* +* var y = negafibonaccif( 0 ); +* // returns 0 +* +* y = negafibonaccif( -1 ); +* // returns 1 +* +* y = negafibonaccif( -2 ); +* // returns -1 +* +* y = negafibonaccif( -3 ); +* // returns 2 +* +* y = negafibonaccif( -4 ); +* // returns -3 +* +* y = negafibonaccif( -5 ); +* // returns 5 +* +* y = negafibonaccif( -6 ); +* // returns -8 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/main.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/main.js new file mode 100644 index 000000000000..467f285af1c2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/main.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var isInteger = require( '@stdlib/math/base/assert/is-integerf' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var MAX_FIBONACCI = require( '@stdlib/constants/float32/max-safe-nth-fibonacci' ); +var NEGAFIBONACCIF = require( './negafibonaccif.json' ); + + +// MAIN // + +/** +* Compute the nth negaFibonacci number as a single-precision floating-point number. +* +* @param {NonPositiveInteger} n - the negaFibonacci number to compute +* @returns {integer} negaFibonacci number +* +* @example +* var y = negafibonaccif( 0 ); +* // returns 0 +* +* @example +* var y = negafibonaccif( -1 ); +* // returns 1 +* +* @example +* var y = negafibonaccif( -2 ); +* // returns -1 +* +* @example +* var y = negafibonaccif( -3 ); +* // returns 2 +* +* @example +* var y = negafibonaccif( -4 ); +* // returns -3 +* +* @example +* var y = negafibonaccif( -5 ); +* // returns 5 +* +* @example +* var y = negafibonaccif( -6 ); +* // returns -8 +* +* @example +* var y = negafibonaccif( NaN ); +* // returns NaN +* +* @example +* var y = negafibonaccif( -3.14 ); +* // returns NaN +*/ +function negafibonaccif( n ) { + var an; + if ( + isnanf( n ) || + isInteger( n ) === false || + n > 0 + ) { + return NaN; + } + an = absf( n ); + if ( an > MAX_FIBONACCI ) { + return NaN; + } + return NEGAFIBONACCIF[ an ]; +} + + +// EXPORTS // + +module.exports = negafibonaccif; diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/native.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/native.js new file mode 100644 index 000000000000..40bdca9072cf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/native.js @@ -0,0 +1,70 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 // + +/** +* Compute the nth negaFibonacci number as a single-precision floating-point number. +* +* @private +* @param {NonPositiveInteger} n - the negaFibonacci number to compute +* @returns {integer} negaFibonacci number +* +* @example +* var y = negafibonaccif( 0 ); +* // returns 0 +* +* @example +* var y = negafibonaccif( -1 ); +* // returns 1 +* +* @example +* var y = negafibonaccif( -2 ); +* // returns -1 +* +* @example +* var y = negafibonaccif( -3 ); +* // returns 2 +* +* @example +* var y = negafibonaccif( -4 ); +* // returns -3 +* +* @example +* var y = negafibonaccif( -5 ); +* // returns 5 +* +* @example +* var y = negafibonaccif( -6 ); +* // returns -8 +*/ +function negafibonaccif( n ) { + return addon( n ); +} + + +// EXPORTS // + +module.exports = negafibonaccif; diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/negafibonaccif.json b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/negafibonaccif.json new file mode 100644 index 000000000000..cf2f4d77afbc --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/negafibonaccif.json @@ -0,0 +1 @@ +[0,1,-1,2,-3,5,-8,13,-21,34,-55,89,-144,233,-377,610,-987,1597,-2584,4181,-6765,10946,-17711,28657,-46368,75025,-121393,196418,-317811,514229,-832040,1346269,-2178309,3524578,-5702887,9227465,-14930352] diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/manifest.json b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/manifest.json new file mode 100644 index 000000000000..8a5106e3b52a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/manifest.json @@ -0,0 +1,75 @@ +{ + "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/constants/float32/max-safe-nth-fibonacci", + "@stdlib/math/base/special/absf" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/constants/float32/max-safe-nth-fibonacci", + "@stdlib/math/base/special/absf" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/constants/float32/max-safe-nth-fibonacci", + "@stdlib/math/base/special/absf" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/package.json b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/package.json new file mode 100644 index 000000000000..a079695c6e4d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/math/base/special/negafibonaccif", + "version": "0.0.0", + "description": "Compute the nth negaFibonacci number as a single-precision floating-point number.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "special functions", + "special", + "function", + "fibonacci", + "negafibonacci", + "fib", + "nfib", + "number" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/Makefile b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 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/negafibonaccif/src/addon.c b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/addon.c new file mode 100644 index 000000000000..3609bb251411 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/addon.c @@ -0,0 +1,24 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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/negafibonaccif.h" +#include "stdlib/math/base/napi/unary.h" +#include + +// cppcheck-suppress shadowFunction +STDLIB_MATH_BASE_NAPI_MODULE_I_F( stdlib_base_negafibonaccif ) diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/main.c b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/main.c new file mode 100644 index 000000000000..6b2baa5767a5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/main.c @@ -0,0 +1,83 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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/negafibonaccif.h" +#include "stdlib/math/base/special/absf.h" +#include "stdlib/constants/float32/max_safe_nth_fibonacci.h" + +static const float negafibonaccif_value[ 37 ] = { + 0.0f, + 1.0f, + -1.0f, + 2.0f, + -3.0f, + 5.0f, + -8.0f, + 13.0f, + -21.0f, + 34.0f, + -55.0f, + 89.0f, + -144.0f, + 233.0f, + -377.0f, + 610.0f, + -987.0f, + 1597.0f, + -2584.0f, + 4181.0f, + -6765.0f, + 10946.0f, + -17711.0f, + 28657.0f, + -46368.0f, + 75025.0f, + -121393.0f, + 196418.0f, + -317811.0f, + 514229.0f, + -832040.0f, + 1346269.0f, + -2178309.0f, + 3524578.0f, + -5702887.0f, + 9227465.0f, + -14930352.0f +}; + +/** +* Compute the nth negaFibonacci number as a single-precision floating-point number. +* +* @param n input value +* @return output value +* +* @example +* float out = stdlib_base_negafibonaccif( -1 ); +* // returns 1.0f +*/ +float stdlib_base_negafibonaccif( const int32_t n ) { + int32_t an; + if ( n > 0 ) { + return 0.0f / 0.0f; // NaN + } + an = stdlib_base_absf( n ); + if ( an > STDLIB_CONSTANT_FLOAT32_MAX_SAFE_NTH_FIBONACCI ) { + return 0.0f / 0.0f; // NaN + } + return negafibonaccif_value[ an ]; +} diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.js new file mode 100644 index 000000000000..064dd9789da0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 pow = require( '@stdlib/math/base/special/pow' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var fibonacci = require( '@stdlib/math/base/special/fibonacci' ); +var negafibonaccif = require( './../lib' ); + + +// FIXTURES // + +var NEGAFIBONACCIF = require( './../lib/negafibonaccif.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof negafibonaccif, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided a positive number, the function returns `NaN`', function test( t ) { + var v; + var i; + + t.strictEqual( isnanf( negafibonaccif( 3.14 ) ), true, 'returns expected value' ); + + for ( i = 1; i < 100; i++ ) { + v = negafibonaccif( i ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'if provided negative infinity, the function returns `NaN`', function test( t ) { + var v = negafibonaccif( NINF ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { + var v = negafibonaccif( NaN ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a non-integer, the function returns `NaN`', function test( t ) { + var v = negafibonaccif( -3.14 ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the nth negaFibonacci number', function test( t ) { + var v; + var i; + for ( i = 0; i > -37; i-- ) { + v = negafibonaccif( i ); + t.strictEqual( v, NEGAFIBONACCIF[ absf(i) ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns the nth negaFibonacci number (Fibonacci relationship)', function test( t ) { + var v; + var f; + var i; + for ( i = 0; i > -37; i-- ) { + v = negafibonaccif( i ); + f = pow( -1.0, absf(i)+1 ) * fibonacci( absf(i) ); + t.strictEqual( v, f, 'returns expected value' ); + } + t.end(); +}); + +tape( 'if provided nonpositive integers less than `-36`, the function returns `NaN`', function test( t ) { + var i; + var v; + for ( i = -37; i > -200; i-- ) { + v = negafibonaccif( i ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.native.js new file mode 100644 index 000000000000..4c86e9ca1ff3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.native.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 pow = require( '@stdlib/math/base/special/pow' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var fibonacci = require( '@stdlib/math/base/special/fibonacci' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var negafibonaccif = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( negafibonaccif instanceof Error ) +}; + + +// FIXTURES // + +var NEGAFIBONACCIF = require( './../lib/negafibonaccif.json' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof negafibonaccif, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided a positive number, the function returns `NaN`', opts, function test( t ) { + var v; + var i; + + t.strictEqual( isnanf( negafibonaccif( 3.14 ) ), true, 'returns NaN' ); + + for ( i = 1; i < 100; i++ ) { + v = negafibonaccif( i ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns the nth negaFibonacci number', opts, function test( t ) { + var v; + var i; + for ( i = 0; i > -37; i-- ) { + v = negafibonaccif( i ); + t.strictEqual( v, NEGAFIBONACCIF[ absf(i) ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns the nth negaFibonacci number (Fibonacci relationship)', opts, function test( t ) { + var v; + var f; + var i; + for ( i = 0; i > -37; i-- ) { + v = negafibonaccif( i ); + f = pow( -1.0, absf(i) + 1 ) * fibonacci( absf(i) ); + t.strictEqual( v, f, 'returns expected value' ); + } + t.end(); +}); + +tape( 'if provided nonpositive integers less than `-36`, the function returns `NaN`', opts, function test( t ) { + var i; + var v; + for ( i = -79; i > -200; i-- ) { + v = negafibonaccif( i ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + } + t.end(); +}); From dfed18e1e18c3c2570f9101548d87fe018a20287 Mon Sep 17 00:00:00 2001 From: Gururaj Gurram <143020143+gururaj1512@users.noreply.github.com> Date: Thu, 27 Mar 2025 02:50:33 +0530 Subject: [PATCH 2/4] Update index.js Signed-off-by: Gururaj Gurram <143020143+gururaj1512@users.noreply.github.com> --- .../@stdlib/math/base/special/negafibonaccif/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/index.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/index.js index 288c2d0a9eed..c6990833abfb 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/index.js @@ -18,7 +18,7 @@ 'use strict'; -var negafibonaccif = require( '@stdlib/math/base/special/negafibonaccif' ); +var negafibonaccif = require( './../lib' ); var v; var i; From 8403e543aeb4625e635246984c6fbbca87148c2f Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sun, 4 May 2025 17:38:34 +0000 Subject: [PATCH 3/4] fix: lint errors --- 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../base/special/negafibonaccif/benchmark/benchmark.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js index 9bed14fac94a..aa056372263e 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js @@ -27,6 +27,7 @@ var sqrtf = require( '@stdlib/math/base/special/sqrtf' ); var pow = require( '@stdlib/math/base/special/pow' ); var absf = require( '@stdlib/math/base/special/absf' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var Float32Array = require( '@stdlib/array/float32' ); var PHI = require( '@stdlib/constants/float32/phi' ); var pkg = require( './../package.json' ).name; var NEGAFIBONACCIF = require( './../lib/negafibonaccif.json' ); @@ -150,7 +151,7 @@ bench( pkg+'::recursion_memoized', function benchmark( b ) { var y; var i; - arr = new Array( 37 ); + arr = new Float32Array( 37 ); arr[ 0 ] = 0; arr[ 1 ] = 1; arr[ 2 ] = -1; @@ -194,7 +195,7 @@ bench( pkg+'::naive_iterative', function benchmark( b ) { an = absf( n ); - arr = new Array( an+1 ); + arr = new Float32Array( an+1 ); arr[ 0 ] = 0; arr[ 1 ] = 1; arr[ 2 ] = -1; @@ -269,7 +270,7 @@ bench( pkg+'::iterative_memoized', function benchmark( b ) { var y; var i; - arr = new Array( 37 ); + arr = new Float32Array( 37 ); arr[ 0 ] = 0; arr[ 1 ] = 1; arr[ 2 ] = -1; From c9db5e1796aacfb899c8a80a9dbeedf997f3dd9e Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Fri, 16 May 2025 14:25:28 -0700 Subject: [PATCH 4/4] fix: code review --- 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: na - 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: na - task: lint_license_headers status: passed --- --- .../base/special/negafibonaccif/README.md | 33 +++------ .../negafibonaccif/benchmark/benchmark.js | 34 ++++----- .../benchmark/benchmark.native.js | 4 +- .../negafibonaccif/benchmark/c/benchmark.c | 4 +- .../benchmark/c/native/benchmark.c | 7 +- .../img/equation_negafibonacci_fibonacci.svg | 36 ---------- ...tion_negafibonacci_recurrence_relation.svg | 33 --------- .../img/equation_negafibonacci_sequence.svg | 70 ------------------- .../base/special/negafibonaccif/docs/repl.txt | 2 +- .../negafibonaccif/docs/types/index.d.ts | 2 +- .../special/negafibonaccif/examples/index.js | 10 ++- .../stdlib/math/base/special/negafibonaccif.h | 2 +- .../base/special/negafibonaccif/lib/main.js | 6 +- .../base/special/negafibonaccif/lib/native.js | 2 +- .../base/special/negafibonaccif/package.json | 2 +- .../base/special/negafibonaccif/src/addon.c | 2 - .../base/special/negafibonaccif/src/main.c | 3 +- .../base/special/negafibonaccif/test/test.js | 8 ++- .../negafibonaccif/test/test.native.js | 10 +-- 19 files changed, 59 insertions(+), 211 deletions(-) delete mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_fibonacci.svg delete mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_recurrence_relation.svg delete mode 100644 lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_sequence.svg diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/README.md b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/README.md index c6eb5ca10a26..e6863918cb3f 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/README.md +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/README.md @@ -20,7 +20,7 @@ limitations under the License. # negaFibonaccif -> Compute the nth [negaFibonacci number][fibonacci-number] as a single-precision floating-point number. +> Compute the nth [negaFibonacci number][fibonacci-number] as a [single-precision floating-point number][ieee754].
@@ -32,11 +32,6 @@ The [negaFibonacci numbers][fibonacci-number] are the integer sequence 0, 1, -1, 2, -3, 5, -8, 13, -21, 34, -55, 89, -144, \ldots ``` - - The sequence is defined by the recurrence relation @@ -47,11 +42,6 @@ The sequence is defined by the recurrence relation F_{n-2} = F_{n} - F_{n-1} ``` - - which yields @@ -62,11 +52,6 @@ which yields F_{-n} = (-1)^{n+1} F_n ``` - - with seed values `F_0 = 0` and `F_{-1} = 1`. @@ -85,7 +70,7 @@ var negafibonaccif = require( '@stdlib/math/base/special/negafibonaccif' ); #### negafibonaccif( n ) -Computes the nth [negaFibonacci number][fibonacci-number] as a single-precision floating-point number. +Computes the nth [negaFibonacci number][fibonacci-number] as a [single-precision floating-point number][ieee754]. ```javascript var v = negafibonaccif( 0 ); @@ -145,15 +130,13 @@ var v = negafibonaccif( NaN ); ```javascript +var logEachMap = require( '@stdlib/console/log-each-map' ); +var linspace = require( '@stdlib/array/base/linspace' ); var negafibonaccif = require( '@stdlib/math/base/special/negafibonaccif' ); -var v; -var i; +var v = linspace( -36, 0, 37 ); -for ( i = 0; i > -37; i-- ) { - v = negafibonaccif( i ); - console.log( v ); -} +logEachMap( 'negafibonaccif(%d) = %0.4f', v, negafibonaccif ); ```
@@ -188,13 +171,13 @@ for ( i = 0; i > -37; i-- ) { #### stdlib_base_negafibonaccif( n ) -Computes the nth [negaFibonacci number][fibonacci-number] as a single-precision floating-point number. +Computes the nth [negaFibonacci number][fibonacci-number] as a [single-precision floating-point number][ieee754]. ```c float out = stdlib_base_negafibonaccif( 0 ); // returns 0.0f -out = stdlib_base_fibonaccif( -1 ); +out = stdlib_base_negafibonaccif( -1 ); // returns 1.0f ``` diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js index aa056372263e..17ca77d01fb4 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js @@ -46,11 +46,11 @@ bench( pkg, function benchmark( b ) { var y; var i; - x = discreteUniform( 100, -36.0, 0.0 ); + x = discreteUniform( 100, -36, 0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = negafibonaccif( x[ i % 100 ] ); + y = negafibonaccif( x[ i%x.length ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } @@ -70,14 +70,16 @@ bench( pkg+'::analytic', function benchmark( b ) { function negafibonaccif( n ) { var an = absf( n ); + + // TODO: replace with `powf` when available return pow( -1.0, an+1 ) * roundf( pow( PHI, an ) / SQRT_5 ); } - x = discreteUniform( 100, -36.0, 0.0 ); + x = discreteUniform( 100, -36, 0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = negafibonaccif( x[ i % 100 ] ); + y = negafibonaccif( x[ i%x.length ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } @@ -95,11 +97,11 @@ bench( pkg+'::table', function benchmark( b ) { var y; var i; - x = discreteUniform( 100, -36.0, 0.0 ); + x = discreteUniform( 100, -36, 0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = NEGAFIBONACCIF[ absf( x[ i % 100 ] ) ]; + y = NEGAFIBONACCIF[ absf( x[ i%x.length ] ) ]; if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } @@ -127,11 +129,11 @@ bench( pkg+'::naive_recursion', function benchmark( b ) { return negafibonaccif( n+2 ) - negafibonaccif( n+1 ); } - x = discreteUniform( 100, -36.0, 0.0 ); + x = discreteUniform( 100, -36, 0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = negafibonaccif( x[ i % 100 ] ); + y = negafibonaccif( x[ i%x.length ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } @@ -166,11 +168,11 @@ bench( pkg+'::recursion_memoized', function benchmark( b ) { return arr[ an ]; } - x = discreteUniform( 100, -36.0, 0.0 ); + x = discreteUniform( 100, -36, 0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = negafibonaccif( x[ i % 100 ] ); + y = negafibonaccif( x[ i%x.length ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } @@ -205,11 +207,11 @@ bench( pkg+'::naive_iterative', function benchmark( b ) { return arr[ an ]; } - x = discreteUniform( 100, -36.0, 0.0 ); + x = discreteUniform( 100, -36, 0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = negafibonaccif( x[ i % 100 ] ); + y = negafibonaccif( x[ i%x.length ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } @@ -246,11 +248,11 @@ bench( pkg+'::iterative', function benchmark( b ) { return b; } - x = discreteUniform( 100, -36.0, 0.0 ); + x = discreteUniform( 100, -36, 0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = negafibonaccif( x[ i % 100 ] ); + y = negafibonaccif( x[ i%x.length ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } @@ -290,11 +292,11 @@ bench( pkg+'::iterative_memoized', function benchmark( b ) { return arr[ an ]; } - x = discreteUniform( 100, -36.0, 0.0 ); + x = discreteUniform( 100, -36, 0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = negafibonaccif( x[ i % 100 ] ); + y = negafibonaccif( x[ i%x.length ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.native.js index 212a779f501a..96c855bf454b 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.native.js @@ -43,11 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; - x = discreteUniform( 100, -36.0, 0.0 ); + x = discreteUniform( 100, -36, 0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = negafibonaccif( x[ i % 100 ] ); + y = negafibonaccif( x[ i%x.length ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/benchmark.c index 7077f1b6a3cb..6c23f1987f7e 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/benchmark.c @@ -112,12 +112,12 @@ static double benchmark( void ) { int i; for ( i = 0; i < 100; i++ ) { - x[ i ] = (int)floor( 36.0f * rand_float() ); + x[ i ] = (int)floorf( 36.0f*rand_float() ); } t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - y = negafibonacci( -x[ i % 100 ] ); + y = negafibonacci( -x[ i%100 ] ); if ( y == 7 ) { printf( "should not return 7\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/native/benchmark.c index 20633d6f34bb..745bb0c18285 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/native/benchmark.c @@ -17,6 +17,7 @@ */ #include "stdlib/math/base/special/negafibonaccif.h" +#include #include #include #include @@ -93,16 +94,16 @@ static double benchmark( void ) { int32_t x[ 100 ]; double elapsed; double t; - double y; + float y; int i; for ( i = 0; i < 100; i++ ) { - x[ i ] = (int32_t)floor( 36.0f * rand_float()); + x[ i ] = (int32_t)floorf( 36.0f*rand_float()); } t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - y = stdlib_base_negafibonaccif( -x[ i % 100 ] ); + y = stdlib_base_negafibonaccif( -x[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_fibonacci.svg b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_fibonacci.svg deleted file mode 100644 index 4c79febb4e15..000000000000 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_fibonacci.svg +++ /dev/null @@ -1,36 +0,0 @@ - -upper F Subscript negative n Baseline equals left-parenthesis negative 1 right-parenthesis Superscript n plus 1 Baseline upper F Subscript n - - - \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_recurrence_relation.svg b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_recurrence_relation.svg deleted file mode 100644 index 7fa6352d483d..000000000000 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_recurrence_relation.svg +++ /dev/null @@ -1,33 +0,0 @@ - -upper F Subscript n minus 2 Baseline equals upper F Subscript n Baseline minus upper F Subscript n minus 1 - - - \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_sequence.svg b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_sequence.svg deleted file mode 100644 index 3fe150d2e720..000000000000 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_sequence.svg +++ /dev/null @@ -1,70 +0,0 @@ - -0 comma 1 comma negative 1 comma 2 comma negative 3 comma 5 comma negative 8 comma 13 comma negative 21 comma 34 comma negative 55 comma 89 comma negative 144 comma ellipsis - - - \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/repl.txt index 4f9de6d10d9f..9caf4bda74f7 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( n ) - Compute the nth negaFibonacci number as a single-precision floating-point + Computes the nth negaFibonacci number as a single-precision floating-point number. The negaFibonacci numbers follow the recurrence relation diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/types/index.d.ts index 0af2e28d3a0e..5a70d9468352 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/types/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /** -* Compute the nth negaFibonacci number as a single-precision floating-point number. +* Computes the nth negaFibonacci number as a single-precision floating-point number. * * ## Notes * diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/index.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/index.js index c6990833abfb..6984a73f89e6 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/examples/index.js @@ -18,12 +18,10 @@ 'use strict'; +var logEachMap = require( '@stdlib/console/log-each-map' ); +var linspace = require( '@stdlib/array/base/linspace' ); var negafibonaccif = require( './../lib' ); -var v; -var i; +var v = linspace( -36, 0, 37 ); -for ( i = 0; i > -37; i-- ) { - v = negafibonaccif( i ); - console.log( v ); -} +logEachMap( 'negafibonaccif(%d) = %0.4f', v, negafibonaccif ); diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/include/stdlib/math/base/special/negafibonaccif.h b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/include/stdlib/math/base/special/negafibonaccif.h index a512a5cc6ec9..fe0e896c179f 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/include/stdlib/math/base/special/negafibonaccif.h +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/include/stdlib/math/base/special/negafibonaccif.h @@ -29,7 +29,7 @@ extern "C" { #endif /** -* Compute the nth negaFibonacci number as a single-precision floating-point number. +* Computes the nth negaFibonacci number as a single-precision floating-point number. */ float stdlib_base_negafibonaccif( const int32_t n ); diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/main.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/main.js index 467f285af1c2..1064ec924bee 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var isInteger = require( '@stdlib/math/base/assert/is-integerf' ); +var isIntegerf = require( '@stdlib/math/base/assert/is-integerf' ); var absf = require( '@stdlib/math/base/special/absf' ); var MAX_FIBONACCI = require( '@stdlib/constants/float32/max-safe-nth-fibonacci' ); var NEGAFIBONACCIF = require( './negafibonaccif.json' ); @@ -30,7 +30,7 @@ var NEGAFIBONACCIF = require( './negafibonaccif.json' ); // MAIN // /** -* Compute the nth negaFibonacci number as a single-precision floating-point number. +* Computes the nth negaFibonacci number as a single-precision floating-point number. * * @param {NonPositiveInteger} n - the negaFibonacci number to compute * @returns {integer} negaFibonacci number @@ -75,7 +75,7 @@ function negafibonaccif( n ) { var an; if ( isnanf( n ) || - isInteger( n ) === false || + isIntegerf( n ) === false || n > 0 ) { return NaN; diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/native.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/native.js index 40bdca9072cf..8a992686526c 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/lib/native.js @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Compute the nth negaFibonacci number as a single-precision floating-point number. +* Computes the nth negaFibonacci number as a single-precision floating-point number. * * @private * @param {NonPositiveInteger} n - the negaFibonacci number to compute diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/package.json b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/package.json index a079695c6e4d..6ec310fd0df8 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/package.json +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/package.json @@ -56,11 +56,11 @@ "stdmath", "mathematics", "math", - "special functions", "special", "function", "fibonacci", "negafibonacci", + "negafibonaccif", "fib", "nfib", "number" diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/addon.c b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/addon.c index 3609bb251411..44a432addee4 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/addon.c @@ -18,7 +18,5 @@ #include "stdlib/math/base/special/negafibonaccif.h" #include "stdlib/math/base/napi/unary.h" -#include -// cppcheck-suppress shadowFunction STDLIB_MATH_BASE_NAPI_MODULE_I_F( stdlib_base_negafibonaccif ) diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/main.c b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/main.c index 6b2baa5767a5..e44f3b297ed2 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/src/main.c @@ -19,6 +19,7 @@ #include "stdlib/math/base/special/negafibonaccif.h" #include "stdlib/math/base/special/absf.h" #include "stdlib/constants/float32/max_safe_nth_fibonacci.h" +#include static const float negafibonaccif_value[ 37 ] = { 0.0f, @@ -61,7 +62,7 @@ static const float negafibonaccif_value[ 37 ] = { }; /** -* Compute the nth negaFibonacci number as a single-precision floating-point number. +* Computes the nth negaFibonacci number as a single-precision floating-point number. * * @param n input value * @return output value diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.js index 064dd9789da0..8c28fc19901d 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.js @@ -25,7 +25,7 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var absf = require( '@stdlib/math/base/special/absf' ); var NINF = require( '@stdlib/constants/float32/ninf' ); -var fibonacci = require( '@stdlib/math/base/special/fibonacci' ); +var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' ); var negafibonaccif = require( './../lib' ); @@ -89,7 +89,9 @@ tape( 'the function returns the nth negaFibonacci number (Fibonacci relationship var i; for ( i = 0; i > -37; i-- ) { v = negafibonaccif( i ); - f = pow( -1.0, absf(i)+1 ) * fibonacci( absf(i) ); + + // TODO: replace with `powf` when available + f = pow( -1.0, absf(i)+1 ) * fibonaccif( absf(i) ); t.strictEqual( v, f, 'returns expected value' ); } t.end(); @@ -98,7 +100,7 @@ tape( 'the function returns the nth negaFibonacci number (Fibonacci relationship tape( 'if provided nonpositive integers less than `-36`, the function returns `NaN`', function test( t ) { var i; var v; - for ( i = -37; i > -200; i-- ) { + for ( i = -37; i > -100; i-- ) { v = negafibonaccif( i ); t.strictEqual( isnanf( v ), true, 'returns expected value' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.native.js index 4c86e9ca1ff3..40c7e50cfb5a 100644 --- a/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/negafibonaccif/test/test.native.js @@ -25,7 +25,7 @@ var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var absf = require( '@stdlib/math/base/special/absf' ); -var fibonacci = require( '@stdlib/math/base/special/fibonacci' ); +var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -54,7 +54,7 @@ tape( 'if provided a positive number, the function returns `NaN`', opts, functio var v; var i; - t.strictEqual( isnanf( negafibonaccif( 3.14 ) ), true, 'returns NaN' ); + t.strictEqual( isnanf( negafibonaccif( 3.14 ) ), true, 'returns expected value' ); for ( i = 1; i < 100; i++ ) { v = negafibonaccif( i ); @@ -79,7 +79,9 @@ tape( 'the function returns the nth negaFibonacci number (Fibonacci relationship var i; for ( i = 0; i > -37; i-- ) { v = negafibonaccif( i ); - f = pow( -1.0, absf(i) + 1 ) * fibonacci( absf(i) ); + + // TODO: replace with `powf` when available + f = pow( -1.0, absf(i) + 1 ) * fibonaccif( absf(i) ); t.strictEqual( v, f, 'returns expected value' ); } t.end(); @@ -88,7 +90,7 @@ tape( 'the function returns the nth negaFibonacci number (Fibonacci relationship tape( 'if provided nonpositive integers less than `-36`, the function returns `NaN`', opts, function test( t ) { var i; var v; - for ( i = -79; i > -200; i-- ) { + for ( i = -37; i > -100; i-- ) { v = negafibonaccif( i ); t.strictEqual( isnanf( v ), true, 'returns expected value' ); }