From 38b90c71924cbba2004283614754023599f2b593 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 15 Mar 2025 12:36:53 -0700 Subject: [PATCH 1/7] feat: add complete implementation --- .../math/base/special/fibonaccif/README.md | 246 +++++++++++ .../special/fibonaccif/benchmark/benchmark.js | 406 ++++++++++++++++++ .../fibonaccif/benchmark/benchmark.native.js | 61 +++ .../special/fibonaccif/benchmark/c/Makefile | 127 ++++++ .../fibonaccif/benchmark/c/benchmark.c | 146 +++++++ .../fibonaccif/benchmark/c/native/Makefile | 146 +++++++ .../fibonaccif/benchmark/c/native/benchmark.c | 134 ++++++ .../fibonaccif/benchmark/julia/REQUIRE | 2 + .../fibonaccif/benchmark/julia/benchmark.jl | 148 +++++++ .../math/base/special/fibonaccif/binding.gyp | 170 ++++++++ ...equation_fibonacci_recurrence_relation.svg | 34 ++ .../docs/img/equation_fibonacci_sequence.svg | 63 +++ .../base/special/fibonaccif/docs/repl.txt | 48 +++ .../special/fibonaccif/docs/types/index.d.ts | 77 ++++ .../special/fibonaccif/docs/types/test.ts | 44 ++ .../special/fibonaccif/examples/c/Makefile | 146 +++++++ .../special/fibonaccif/examples/c/example.c | 31 ++ .../base/special/fibonaccif/examples/index.js | 27 ++ .../math/base/special/fibonaccif/include.gypi | 53 +++ .../stdlib/math/base/special/fibonaccif.h | 40 ++ .../special/fibonaccif/lib/fibonacci.json | 1 + .../math/base/special/fibonaccif/lib/index.js | 58 +++ .../math/base/special/fibonaccif/lib/main.js | 92 ++++ .../base/special/fibonaccif/lib/native.js | 74 ++++ .../base/special/fibonaccif/manifest.json | 72 ++++ .../math/base/special/fibonaccif/package.json | 66 +++ .../math/base/special/fibonaccif/src/Makefile | 70 +++ .../math/base/special/fibonaccif/src/addon.c | 23 + .../math/base/special/fibonaccif/src/main.c | 77 ++++ .../math/base/special/fibonaccif/test/test.js | 91 ++++ .../special/fibonaccif/test/test.native.js | 79 ++++ 31 files changed, 2852 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/julia/REQUIRE create mode 100755 lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/julia/benchmark.jl create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_recurrence_relation.svg create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_sequence.svg create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/include/stdlib/math/base/special/fibonaccif.h create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/fibonacci.json create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md b/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md new file mode 100644 index 000000000000..f821f7996c2c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md @@ -0,0 +1,246 @@ + + +# Fibonaccif + +> Compute the nth [Fibonacci number][fibonacci-number] (single-precision). + +
+ +The [Fibonacci 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 = F_{n-1} + F_{n-2} +``` + + + +with seed values `F_0 = 0` and `F_1 = 1`. + +
+ + + +
+ +## Usage + +```javascript +var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' ); +``` + +#### fibonaccif( n ) + +Computes the nth [Fibonacci number][fibonacci-number] (single-precision). + +```javascript +var v = fibonaccif( 0 ); +// returns 0 + +v = fibonaccif( 1 ); +// returns 1 + +v = fibonaccif( 2 ); +// returns 1 + +v = fibonaccif( 3 ); +// returns 2 + +v = fibonaccif( 36 ); +// returns 14930352 +``` + +If `n > 36`, the function returns `NaN`, as larger [Fibonacci numbers][fibonacci-number] cannot be safely represented in [single-precision floating-point format][ieee754]. + +```javascript +var v = fibonaccif( 37 ); +// returns NaN +``` + +If not provided a nonnegative integer value, the function returns `NaN`. + +```javascript +var v = fibonaccif( 3.14 ); +// returns NaN + +v = fibonaccif( -1 ); +// returns NaN +``` + +If provided `NaN`, the function returns `NaN`. + +```javascript +var v = fibonaccif( NaN ); +// returns NaN +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' ); + +var x = discreteUniform( 10, 0, 36 ); + +logEachMap( 'fibonaccif(%d) = %f', x, fibonaccif ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/fibonaccif.h" +``` + +#### stdlib_base_fibonaccif( n ) + +Computes the nth [Fibonacci number][fibonacci-number] (single-precision). + +```c +float out = stdlib_base_fibonaccif( 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_fibonacci( const int32_t n ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/fibonaccif.h" +#include +#include + +int main( void ) { + int32_t i; + float v; + + for ( i = 0; i < 37; i++ ) { + v = stdlib_base_fibonaccif( i ); + printf( "fibonaccif(%d) = %f\n", i, v ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.js new file mode 100644 index 000000000000..b93753e848ae --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.js @@ -0,0 +1,406 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 Int32Array = require( '@stdlib/array/int32' ); +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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var PHI = require( '@stdlib/constants/float32/phi' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var pkg = require( './../package.json' ).name; +var FIBONACCI = require( './../lib/fibonacci.json' ); +var fibonaccif = require( './../lib' ); + + +// VARIABLES // + +var SQRT_5 = sqrtf( 5.0 ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var i; + + x = discreteUniform( 100, 0, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = fibonaccif( x[ i%x.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::analytic', function benchmark( b ) { + var x; + var y; + var i; + + function fibonaccif( n ) { + // TODO: replace with powf once implemented + return roundf( float64ToFloat32( pow( PHI, n ) ) / SQRT_5 ); + } + + x = discreteUniform( 100, 0, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = fibonaccif( x[ i%x.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::table', function benchmark( b ) { + var x; + var y; + var i; + + x = discreteUniform( 100, 0, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = FIBONACCI[ x[ i%x.length ] ]; + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::naive_recursion', function benchmark( b ) { + var x; + var y; + var i; + + function fibonaccif( n ) { + if ( n < 2 ) { + return n; + } + return fibonaccif( n-1 ) + fibonaccif( n-2 ); + } + + x = discreteUniform( 100, 0, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = fibonaccif( x[ i%x.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::recursion_memoized', function benchmark( b ) { + var arr; + var N; + var x; + var y; + var i; + + arr = new Int32Array( 37 ); + arr[ 0 ] = 0; + arr[ 1 ] = 1; + arr[ 2 ] = 1; + N = 2; + + function fibonaccif( n ) { + if ( n <= N ) { + return arr[ n ]; + } + arr[ n ] = fibonaccif( n-1 ) + fibonaccif( n-2 ); + return arr[ n ]; + } + + x = discreteUniform( 100, 0, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = fibonaccif( x[ i%x.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::naive_iterative', function benchmark( b ) { + var x; + var y; + var i; + + function fibonaccif( n ) { + var arr; + var i; + + arr = new Int32Array( n+1 ); + arr[ 0 ] = 0; + arr[ 1 ] = 1; + arr[ 2 ] = 1; + for ( i = 3; i <= n; i++ ) { + arr[ i ] = arr[ i-1 ] + arr[ i-2 ]; + } + return arr[ n ]; + } + + x = discreteUniform( 100, 0, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = fibonaccif( x[ i%x.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::iterative', function benchmark( b ) { + var x; + var y; + var i; + + function fibonaccif( n ) { + var a; + var b; + var c; + var i; + + a = 1; + b = 1; + for ( i = 3; i <= n; i++ ) { + c = a + b; + a = b; + b = c; + } + return b; + } + + x = discreteUniform( 100, 0, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = fibonaccif( x[ i%x.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::iterative_memoized', function benchmark( b ) { + var arr; + var N; + var x; + var y; + var i; + + arr = new Int32Array( 37 ); + arr[ 0 ] = 0; + arr[ 1 ] = 1; + arr[ 2 ] = 1; + N = 2; + + function fibonaccif( n ) { + var i; + if ( n > N ) { + for ( i = N+1; i <= n; i++ ) { + arr[ i ] = arr[ i-1 ] + arr[ i-2 ]; + } + N = n; + } + return arr[ n ]; + } + + x = discreteUniform( 100, 0, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = fibonaccif( x[ i%x.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::iterative_doubling', function benchmark( b ) { + var x; + var y; + var i; + + function fibonaccif( n ) { + var i = n - 1; + var a = 1; + var b = 0; + var c = 0; + var d = 1; + var t; + + if ( n < 1 ) { + return n; + } + while ( i > 0 ) { + if ( (i&1) === 1 ) { // is odd + t = (d*(b+a)) + (c*b); + a = (d*b) + (c*a); + b = t; + } + t = d * ((2*c) + d); + c = (c*c) + (d*d); + d = t; + i >>= 1; // i >> 1 is equal to floorf( i/2 ) + } + return a + b; + } + + x = discreteUniform( 100, 0, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = fibonaccif( x[ i%x.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::iterative_doubling_memoized', function benchmark( b ) { + var arr; + var N; + var x; + var y; + var i; + + arr = new Int32Array( 37 ); + arr[ 0 ] = 0; + arr[ 1 ] = 1; + arr[ 2 ] = 1; + N = 2; + + function fibonaccif( n ) { + var i; + var a; + var b; + var c; + var d; + var t; + + if ( n <= N ) { + return arr[ n ]; + } + if ( n < 1 ) { + return n; + } + i = n - 1; + a = 1; + b = 0; + c = 0; + d = 1; + while ( i > 0 ) { + if ( (i&1) === 1 ) { // is odd + t = (d*(b+a)) + (c*b); + a = (d*b) + (c*a); + b = t; + } + t = d * ((2*c) + d); + c = (c*c) + (d*d); + d = t; + i >>= 1; // i >> 1 is equal to floorf( i/2 ) + } + arr[ n ] = a + b; + return a + b; + } + + x = discreteUniform( 100, 0, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = fibonaccif( x[ i%x.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.native.js new file mode 100644 index 000000000000..16c9648a65b3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.native.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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 fibonaccif = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( fibonaccif instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var x; + var y; + var i; + + x = discreteUniform( 100, 0, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = fibonaccif( x[ i%x.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/Makefile new file mode 100644 index 000000000000..e64c0050f3da --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/Makefile @@ -0,0 +1,127 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2018 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/fibonaccif/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/benchmark.c new file mode 100644 index 000000000000..77da6954e4fd --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/benchmark.c @@ -0,0 +1,146 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 +#include + +#define NAME "fibonaccif::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 Fibonacci number. +* +* @param n Fibonacci number to compute +* @return Fibonacci number +*/ +int fibonaccif( int n ) { + if ( n < 2 ) { + return n; + } + return fibonaccif( n-1 ) + fibonaccif( n-2 ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + double t; + int x; + int y; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + x = (int32_t)floor( 36.0*rand_float() ); + y = fibonaccif( x ); + if ( y < 0 ) { + printf( "should return a nonnegative integer\n" ); + break; + } + } + elapsed = tic() - t; + if ( y < 0 ) { + printf( "should return a nonnegative integer\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/fibonaccif/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/Makefile new file mode 100644 index 000000000000..d6b58c7f5d3e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2022 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/fibonaccif/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..e9d33ad1b270 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/benchmark.c @@ -0,0 +1,134 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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/fibonaccif.h" +#include +#include +#include +#include +#include +#include + +#define NAME "fibonaccif" +#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 ) { + double elapsed; + int32_t x; + double t; + double y; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + x = (int32_t)floor( 36.0*rand_float() ); + y = stdlib_base_fibonaccif( x ); + if ( y < 0 ) { + printf( "should return a nonnegative integer\n" ); + break; + } + } + elapsed = tic() - t; + if ( y < 0 ) { + printf( "should return a nonnegative integer\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/fibonaccif/benchmark/julia/REQUIRE b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/julia/REQUIRE new file mode 100644 index 000000000000..98645e192e41 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/julia/REQUIRE @@ -0,0 +1,2 @@ +julia 1.5 +BenchmarkTools 0.5.0 diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/julia/benchmark.jl new file mode 100755 index 000000000000..978ac400279f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/julia/benchmark.jl @@ -0,0 +1,148 @@ +#!/usr/bin/env julia +# +# @license Apache-2.0 +# +# Copyright (c) 2018 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 = "fibonacci::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 Fibonacci recurrence relation: + fib( n ) = ( n < 2 ) ? n : fib( n-1 ) + fib( n-2 ); + + # Benchmark: + t = BenchmarkTools.@benchmark $fib( 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/fibonaccif/binding.gyp b/lib/node_modules/@stdlib/math/base/special/fibonaccif/binding.gyp new file mode 100644 index 000000000000..1058b57bab16 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2022 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/fibonaccif/docs/img/equation_fibonacci_recurrence_relation.svg b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_recurrence_relation.svg new file mode 100644 index 000000000000..4c635bc9d903 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_recurrence_relation.svg @@ -0,0 +1,34 @@ + +upper F Subscript n Baseline equals upper F Subscript n minus 1 Baseline plus upper F Subscript n minus 2 + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_sequence.svg b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_sequence.svg new file mode 100644 index 000000000000..805bc80aea27 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_sequence.svg @@ -0,0 +1,63 @@ + +0 comma 1 comma 1 comma 2 comma 3 comma 5 comma 8 comma 13 comma 21 comma 34 comma 55 comma 89 comma 144 comma ellipsis + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/repl.txt new file mode 100644 index 000000000000..c172e39d2cf3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/repl.txt @@ -0,0 +1,48 @@ + +{{alias}}( n ) + Computes the nth Fibonacci number (single-precision). + + Fibonacci numbers follow the recurrence relation + + F_n = F_{n-1} + F_{n-2} + + with seed values F_0 = 0 and F_1 = 1. + + If `n` is greater than `36`, the function returns `NaN`, as larger Fibonacci + numbers cannot be accurately represented due to limitations of single- + precision floating-point format. + + If not provided a nonnegative integer value, the function returns `NaN`. + + If provided `NaN`, the function returns `NaN`. + + Parameters + ---------- + n: integer + Input value. + + Returns + ------- + y: integer + Fibonacci 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}}( NaN ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts new file mode 100644 index 000000000000..41bbb7949498 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts @@ -0,0 +1,77 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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 + +/** +* Computes the nth Fibonacci number (single-precision). +* +* ## Notes +* +* - If `n` is greater than `36`, the function returns `NaN`, as larger Fibonacci numbers cannot be accurately represented due to limitations of single-precision floating-point format. +* - If not provided a nonnegative integer value, the function returns `NaN`. +* +* @param n - the Fibonacci number to compute +* @returns Fibonacci number +* +* @example +* var y = fibonaccif( 0 ); +* // returns 0 +* +* @example +* var y = fibonaccif( 1 ); +* // returns 1 +* +* @example +* var y = fibonaccif( 2 ); +* // returns 1 +* +* @example +* var y = fibonaccif( 3 ); +* // returns 2 +* +* @example +* var y = fibonaccif( 4 ); +* // returns 3 +* +* @example +* var y = fibonaccif( 5 ); +* // returns 5 +* +* @example +* var y = fibonaccif( 6 ); +* // returns 8 +* +* @example +* var y = fibonaccif( NaN ); +* // returns NaN +* +* @example +* var y = fibonaccif( 3.14 ); +* // returns NaN +* +* @example +* var y = fibonaccif( -1.0 ); +* // returns NaN +*/ +declare function fibonaccif( n: number ): number; + + +// EXPORTS // + +export = fibonaccif; diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/test.ts new file mode 100644 index 000000000000..45ff0483397a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/test.ts @@ -0,0 +1,44 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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 fibonaccif = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + fibonaccif( 7 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a number... +{ + fibonaccif( true ); // $ExpectError + fibonaccif( false ); // $ExpectError + fibonaccif( null ); // $ExpectError + fibonaccif( undefined ); // $ExpectError + fibonaccif( '5' ); // $ExpectError + fibonaccif( [] ); // $ExpectError + fibonaccif( {} ); // $ExpectError + fibonaccif( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + fibonaccif(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/Makefile new file mode 100644 index 000000000000..91d364d19fc3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2022 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/fibonaccif/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/example.c new file mode 100644 index 000000000000..306386d04576 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/example.c @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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/fibonaccif.h" +#include +#include + +int main( void ) { + int32_t i; + float v; + + for ( i = 0; i < 37; i++ ) { + v = stdlib_base_fibonaccif( i ); + printf( "fibonaccif(%d) = %f\n", i, v ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js new file mode 100644 index 000000000000..2a9ee500a03b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js @@ -0,0 +1,27 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var fibonaccif = require( './../lib' ); + +var x = discreteUniform( 10, 0, 36 ); + +logEachMap( 'fibonaccif(%d) = %f', x, fibonaccif ); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/include.gypi b/lib/node_modules/@stdlib/math/base/special/fibonaccif/include.gypi new file mode 100644 index 000000000000..3b437d524797 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2022 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 + +/** +* Computes the nth Fibonacci number (single-precision). +*/ +float stdlib_base_fibonaccif( const int32_t n ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_FIBONACCIF_H diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/fibonacci.json b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/fibonacci.json new file mode 100644 index 000000000000..66bb27dccf5d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/fibonacci.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/fibonaccif/lib/index.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/index.js new file mode 100644 index 000000000000..8c2d6d0896d5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/index.js @@ -0,0 +1,58 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 Fibonacci number (single-precision). +* +* @module @stdlib/math/base/special/fibonaccif +* +* @example +* var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' ); +* +* var y = fibonaccif( 0 ); +* // returns 0 +* +* y = fibonaccif( 1 ); +* // returns 1 +* +* y = fibonaccif( 2 ); +* // returns 1 +* +* y = fibonaccif( 3 ); +* // returns 2 +* +* y = fibonaccif( 4 ); +* // returns 3 +* +* y = fibonaccif( 5 ); +* // returns 5 +* +* y = fibonaccif( 6 ); +* // returns 8 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js new file mode 100644 index 000000000000..9dc45ddee114 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js @@ -0,0 +1,92 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 isIntegerf = require( '@stdlib/math/base/assert/is-integerf' ); +var MAX_FIBONACCI = require( '@stdlib/constants/float32/max-safe-nth-fibonacci' ); +var FIBONACCI = require( './fibonacci.json' ); + + +// MAIN // + +/** +* Computes the nth Fibonacci number (single-precision). +* +* @param {NonNegativeInteger} n - the Fibonacci number to compute +* @returns {NonNegativeInteger} Fibonacci number +* +* @example +* var y = fibonaccif( 0 ); +* // returns 0 +* +* @example +* var y = fibonaccif( 1 ); +* // returns 1 +* +* @example +* var y = fibonaccif( 2 ); +* // returns 1 +* +* @example +* var y = fibonaccif( 3 ); +* // returns 2 +* +* @example +* var y = fibonaccif( 4 ); +* // returns 3 +* +* @example +* var y = fibonaccif( 5 ); +* // returns 5 +* +* @example +* var y = fibonaccif( 6 ); +* // returns 8 +* +* @example +* var y = fibonaccif( NaN ); +* // returns NaN +* +* @example +* var y = fibonaccif( 3.14 ); +* // returns NaN +* +* @example +* var y = fibonaccif( -1.0 ); +* // returns NaN +*/ +function fibonaccif( n ) { + if ( + isnanf( n ) || + isIntegerf( n ) === false || + n < 0 || + n > MAX_FIBONACCI + ) { + return NaN; + } + return FIBONACCI[ n ]; +} + + +// EXPORTS // + +module.exports = fibonaccif; diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js new file mode 100644 index 000000000000..c4713f615663 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js @@ -0,0 +1,74 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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 // + +/** +* Computes the nth Fibonacci number (single-precision). +* +* @private +* @param {NonNegativeInteger} n - the Fibonacci number to compute +* @returns {NonNegativeInteger} Fibonacci number +* +* @example +* var y = fibonaccif( 0 ); +* // returns 0 +* +* @example +* var y = fibonaccif( 1 ); +* // returns 1 +* +* @example +* var y = fibonaccif( 2 ); +* // returns 1 +* +* @example +* var y = fibonaccif( 3 ); +* // returns 2 +* +* @example +* var y = fibonaccif( 4 ); +* // returns 3 +* +* @example +* var y = fibonaccif( 5 ); +* // returns 5 +* +* @example +* var y = fibonaccif( 6 ); +* // returns 8 +* +* @example +* var y = fibonaccif( -1 ); +* // returns NaN +*/ +function fibonaccif( n ) { + return addon( n ); +} + + +// EXPORTS // + +module.exports = fibonaccif; diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/manifest.json b/lib/node_modules/@stdlib/math/base/special/fibonaccif/manifest.json new file mode 100644 index 000000000000..26a079a0b09f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/manifest.json @@ -0,0 +1,72 @@ +{ + "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" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/constants/float32/max-safe-nth-fibonacci" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/constants/float32/max-safe-nth-fibonacci" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/package.json b/lib/node_modules/@stdlib/math/base/special/fibonaccif/package.json new file mode 100644 index 000000000000..8b77ee8c8aa9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/math/base/special/fibonaccif", + "version": "0.0.0", + "description": "Compute the nth Fibonacci number (single-precision).", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "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", + "fibonaccif", + "fib", + "number" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/Makefile new file mode 100644 index 000000000000..f79b87238713 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2022 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/fibonaccif/src/addon.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c new file mode 100644 index 000000000000..c0bf5aae3477 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c @@ -0,0 +1,23 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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/fibonaccif.h" +#include "stdlib/math/base/napi/unary.h" + +// cppcheck-suppress shadowFunction +STDLIB_MATH_BASE_NAPI_MODULE_I_F( stdlib_base_fibonaccif ) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c new file mode 100644 index 000000000000..e96b51b421e6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c @@ -0,0 +1,77 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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/fibonaccif.h" +#include "stdlib/constants/float32/max_safe_nth_fibonacci.h" + +static const int64_t fibonacci_value[ 37 ] = { + 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 +}; + +/** +* Computes the nth Fibonacci number (single-precision). +* +* @param n input value +* @return output value +* +* @example +* float out = stdlib_base_fibonaccif( 1 ); +* // returns 1.0f +*/ +float stdlib_base_fibonaccif( const int32_t n ) { + if ( n < 0 || n > STDLIB_CONSTANT_FLOAT32_MAX_SAFE_NTH_FIBONACCI ) { + return 0.0 / 0.0; // NaN + } + return fibonacci_value[ n ]; +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js new file mode 100644 index 000000000000..36767a4fc5a8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js @@ -0,0 +1,91 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 PINF = require( '@stdlib/constants/float32/pinf' ); +var fibonaccif = require( './../lib' ); + + +// FIXTURES // + +var FIBONACCI = require( './../lib/fibonacci.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof fibonaccif, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided a negative number, the function returns `NaN`', function test( t ) { + var v; + var i; + + t.strictEqual( isnanf( fibonaccif( -3.14 ) ), true, 'returns NaN' ); + + for ( i = -1; i > -100; i-- ) { + v = fibonaccif( i ); + t.strictEqual( isnanf( v ), true, 'returns NaN when provided ' + i ); + } + t.end(); +}); + +tape( 'if provided positive infinity, the function returns `NaN`', function test( t ) { + var v = fibonaccif( PINF ); + t.strictEqual( isnanf( v ), true, 'returns NaN when provided +infinity' ); + t.end(); +}); + +tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { + var v = fibonaccif( NaN ); + t.strictEqual( isnanf( v ), true, 'returns NaN when provided a NaN' ); + t.end(); +}); + +tape( 'if provided a non-integer, the function returns `NaN`', function test( t ) { + var v = fibonaccif( 3.14 ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'the function returns the nth Fibonacci number', function test( t ) { + var v; + var i; + for ( i = 0; i < 37; i++ ) { + v = fibonaccif( i ); + t.strictEqual( v, FIBONACCI[ i ], 'returns the '+i+'th Fibonacci number' ); + } + t.end(); +}); + +tape( 'if provided nonnegative integers greater than `36`, the function returns `NaN`', function test( t ) { + var i; + var v; + for ( i = 37; i < 500; i++ ) { + v = fibonaccif( i ); + t.strictEqual( isnanf( v ), true, 'returns NaN when provided ' + i ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.native.js new file mode 100644 index 000000000000..31f10a0cdb75 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.native.js @@ -0,0 +1,79 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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 tryRequire = require( '@stdlib/utils/try-require' ); + + +// FIXTURES // + +var FIBONACCI = require( './../lib/fibonacci.json' ); + + +// VARIABLES // + +var fibonaccif = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( fibonaccif instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof fibonaccif, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided a negative number, the function returns `NaN`', opts, function test( t ) { + var v; + var i; + + for ( i = -1; i > -100; i-- ) { + v = fibonaccif( i ); + t.strictEqual( isnanf( v ), true, 'returns NaN when provided ' + i ); + } + t.end(); +}); + +tape( 'the function returns the nth Fibonacci number', opts, function test( t ) { + var v; + var i; + for ( i = 0; i < 37; i++ ) { + v = fibonaccif( i ); + t.strictEqual( v, FIBONACCI[ i ], 'returns the '+i+'th Fibonacci number' ); + } + t.end(); +}); + +tape( 'if provided nonnegative integers greater than `36`, the function returns `NaN`', opts, function test( t ) { + var i; + var v; + for ( i = 37; i < 500; i++ ) { + v = fibonaccif( i ); + t.strictEqual( isnanf( v ), true, 'returns NaN when provided ' + i ); + } + t.end(); +}); From fb2fa3801d6f998c2190c71f25fec9ca87199a71 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Fri, 21 Mar 2025 09:33:08 +0000 Subject: [PATCH 2/7] chore: update copyright years --- lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md | 2 +- .../@stdlib/math/base/special/fibonaccif/benchmark/benchmark.js | 2 +- .../math/base/special/fibonaccif/benchmark/benchmark.native.js | 2 +- .../@stdlib/math/base/special/fibonaccif/benchmark/c/Makefile | 2 +- .../math/base/special/fibonaccif/benchmark/c/benchmark.c | 2 +- .../math/base/special/fibonaccif/benchmark/c/native/Makefile | 2 +- .../math/base/special/fibonaccif/benchmark/c/native/benchmark.c | 2 +- .../math/base/special/fibonaccif/benchmark/julia/benchmark.jl | 2 +- .../@stdlib/math/base/special/fibonaccif/binding.gyp | 2 +- .../@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts | 2 +- .../@stdlib/math/base/special/fibonaccif/docs/types/test.ts | 2 +- .../@stdlib/math/base/special/fibonaccif/examples/c/Makefile | 2 +- .../@stdlib/math/base/special/fibonaccif/examples/c/example.c | 2 +- .../@stdlib/math/base/special/fibonaccif/examples/index.js | 2 +- .../@stdlib/math/base/special/fibonaccif/include.gypi | 2 +- .../fibonaccif/include/stdlib/math/base/special/fibonaccif.h | 2 +- .../@stdlib/math/base/special/fibonaccif/lib/index.js | 2 +- .../@stdlib/math/base/special/fibonaccif/lib/main.js | 2 +- .../@stdlib/math/base/special/fibonaccif/lib/native.js | 2 +- .../@stdlib/math/base/special/fibonaccif/src/Makefile | 2 +- .../@stdlib/math/base/special/fibonaccif/src/addon.c | 2 +- .../@stdlib/math/base/special/fibonaccif/src/main.c | 2 +- .../@stdlib/math/base/special/fibonaccif/test/test.js | 2 +- .../@stdlib/math/base/special/fibonaccif/test/test.native.js | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md b/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md index f821f7996c2c..b805309aae06 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2022 The Stdlib Authors. +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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.js index b93753e848ae..b7b21060660c 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.native.js index 16c9648a65b3..9cb9a046106c 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/Makefile index e64c0050f3da..d564e8b2d6f9 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2018 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/benchmark.c index 77da6954e4fd..53d59b260dd5 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/benchmark.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/Makefile index d6b58c7f5d3e..a4bd7b38fd74 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2022 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/benchmark.c index e9d33ad1b270..a85da61142e4 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/benchmark.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/julia/benchmark.jl index 978ac400279f..f80a00b4fc3b 100755 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/julia/benchmark.jl +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/julia/benchmark.jl @@ -2,7 +2,7 @@ # # @license Apache-2.0 # -# Copyright (c) 2018 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/binding.gyp b/lib/node_modules/@stdlib/math/base/special/fibonaccif/binding.gyp index 1058b57bab16..68a1ca11d160 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/binding.gyp +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2022 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts index 41bbb7949498..46532bb70217 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/test.ts index 45ff0483397a..ea01795f88af 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/Makefile index 91d364d19fc3..25ced822f96a 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2022 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/example.c index 306386d04576..cab99e248bac 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js index 2a9ee500a03b..dfe4d1076542 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/include.gypi b/lib/node_modules/@stdlib/math/base/special/fibonaccif/include.gypi index 3b437d524797..ecfaf82a3279 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/include.gypi +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2022 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/include/stdlib/math/base/special/fibonaccif.h b/lib/node_modules/@stdlib/math/base/special/fibonaccif/include/stdlib/math/base/special/fibonaccif.h index 0ae260e70cbd..3186cd767331 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/include/stdlib/math/base/special/fibonaccif.h +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/include/stdlib/math/base/special/fibonaccif.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/index.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/index.js index 8c2d6d0896d5..1e226b723572 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js index 9dc45ddee114..1afbad2aa905 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js index c4713f615663..ea71c1ef1b53 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/Makefile index f79b87238713..7733b6180cb4 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2022 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c index c0bf5aae3477..89356973ba9d 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c index e96b51b421e6..79d35015a84e 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js index 36767a4fc5a8..49d0f8a621a5 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.native.js index 31f10a0cdb75..3f105059882e 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* 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. From 42144246b9572a24737587fe3d9eab9d77b46084 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Fri, 21 Mar 2025 02:55:53 -0700 Subject: [PATCH 3/7] chore: fix examples --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: 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 --- --- .../@stdlib/math/base/special/fibonaccif/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js index dfe4d1076542..e18298ff455a 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js @@ -24,4 +24,4 @@ var fibonaccif = require( './../lib' ); var x = discreteUniform( 10, 0, 36 ); -logEachMap( 'fibonaccif(%d) = %f', x, fibonaccif ); +logEachMap( 'fibonaccif(%d) = %0.4f', x, fibonaccif ); From ade3596013d3d503d0b559bf352ee4b303f5a0c1 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 22 Mar 2025 12:44:24 -0700 Subject: [PATCH 4/7] chore: use correct data types --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/fibonaccif/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c index 79d35015a84e..0cd45e8e7d2d 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c @@ -19,7 +19,7 @@ #include "stdlib/math/base/special/fibonaccif.h" #include "stdlib/constants/float32/max_safe_nth_fibonacci.h" -static const int64_t fibonacci_value[ 37 ] = { +static const int32_t fibonacci_value[ 37 ] = { 0, 1, 1, From 14c56ba0e2e4845a0b7cd8d8401609460ab1e2f8 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 22 Mar 2025 21:49:27 -0700 Subject: [PATCH 5/7] docs: fix the function description --- 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: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/fibonaccif/README.md | 8 ++++---- .../@stdlib/math/base/special/fibonaccif/docs/repl.txt | 3 ++- .../math/base/special/fibonaccif/docs/types/index.d.ts | 2 +- .../math/base/special/fibonaccif/examples/index.js | 2 +- .../include/stdlib/math/base/special/fibonaccif.h | 2 +- .../@stdlib/math/base/special/fibonaccif/lib/index.js | 2 +- .../@stdlib/math/base/special/fibonaccif/lib/main.js | 2 +- .../@stdlib/math/base/special/fibonaccif/lib/native.js | 2 +- .../@stdlib/math/base/special/fibonaccif/package.json | 2 +- .../@stdlib/math/base/special/fibonaccif/src/main.c | 2 +- 10 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md b/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md index b805309aae06..623fd6b04c86 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md @@ -20,7 +20,7 @@ limitations under the License. # Fibonaccif -> Compute the nth [Fibonacci number][fibonacci-number] (single-precision). +> Compute the nth [Fibonacci number][fibonacci-number] as a single-precision floating-point number.
@@ -60,7 +60,7 @@ var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' ); #### fibonaccif( n ) -Computes the nth [Fibonacci number][fibonacci-number] (single-precision). +Computes the nth [Fibonacci number][fibonacci-number] as a single-precision floating-point number. ```javascript var v = fibonaccif( 0 ); @@ -126,7 +126,7 @@ var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' ); var x = discreteUniform( 10, 0, 36 ); -logEachMap( 'fibonaccif(%d) = %f', x, fibonaccif ); +logEachMap( 'fibonaccif(%d) = %0.1f', x, fibonaccif ); ```
@@ -161,7 +161,7 @@ logEachMap( 'fibonaccif(%d) = %f', x, fibonaccif ); #### stdlib_base_fibonaccif( n ) -Computes the nth [Fibonacci number][fibonacci-number] (single-precision). +Computes the nth [Fibonacci number][fibonacci-number] as a single-precision floating-point number. ```c float out = stdlib_base_fibonaccif( 0 ); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/repl.txt index c172e39d2cf3..bf821fd94a43 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/repl.txt @@ -1,6 +1,7 @@ {{alias}}( n ) - Computes the nth Fibonacci number (single-precision). + Computes the nth Fibonacci number as a single-precision floating-point + number. Fibonacci numbers follow the recurrence relation diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts index 46532bb70217..ae8af8c6a2d7 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/types/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /** -* Computes the nth Fibonacci number (single-precision). +* Computes the nth Fibonacci number as a single-precision floating-point number. * * ## Notes * diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js index e18298ff455a..c56414f4caf6 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js @@ -24,4 +24,4 @@ var fibonaccif = require( './../lib' ); var x = discreteUniform( 10, 0, 36 ); -logEachMap( 'fibonaccif(%d) = %0.4f', x, fibonaccif ); +logEachMap( 'fibonaccif(%d) = %0.1f', x, fibonaccif ); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/include/stdlib/math/base/special/fibonaccif.h b/lib/node_modules/@stdlib/math/base/special/fibonaccif/include/stdlib/math/base/special/fibonaccif.h index 3186cd767331..4b1c175fc166 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/include/stdlib/math/base/special/fibonaccif.h +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/include/stdlib/math/base/special/fibonaccif.h @@ -29,7 +29,7 @@ extern "C" { #endif /** -* Computes the nth Fibonacci number (single-precision). +* Computes the nth Fibonacci number as a single-precision floating-point number. */ float stdlib_base_fibonaccif( const int32_t n ); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/index.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/index.js index 1e226b723572..422cf0a10f95 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Compute the nth Fibonacci number (single-precision). +* Compute the nth Fibonacci number as a single-precision floating-point number. * * @module @stdlib/math/base/special/fibonaccif * diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js index 1afbad2aa905..9380dd553aee 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js @@ -29,7 +29,7 @@ var FIBONACCI = require( './fibonacci.json' ); // MAIN // /** -* Computes the nth Fibonacci number (single-precision). +* Computes the nth Fibonacci number as a single-precision floating-point number. * * @param {NonNegativeInteger} n - the Fibonacci number to compute * @returns {NonNegativeInteger} Fibonacci number diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js index ea71c1ef1b53..6df1e9d5ea29 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Computes the nth Fibonacci number (single-precision). +* Computes the nth Fibonacci number as a single-precision floating-point number. * * @private * @param {NonNegativeInteger} n - the Fibonacci number to compute diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/package.json b/lib/node_modules/@stdlib/math/base/special/fibonaccif/package.json index 8b77ee8c8aa9..0b60201bb397 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/package.json +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/math/base/special/fibonaccif", "version": "0.0.0", - "description": "Compute the nth Fibonacci number (single-precision).", + "description": "Compute the nth Fibonacci number as a single-precision floating-point number.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c index 0cd45e8e7d2d..44aefe9f3c41 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c @@ -60,7 +60,7 @@ static const int32_t fibonacci_value[ 37 ] = { }; /** -* Computes the nth Fibonacci number (single-precision). +* Computes the nth Fibonacci number as a single-precision floating-point number. * * @param n input value * @return output value From 58eaa82b521bb35f4ba333fcb83ecf484de3d9a5 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 22 Mar 2025 22:01:56 -0700 Subject: [PATCH 6/7] test: fix test messages --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/fibonaccif/test/test.js | 12 ++++++------ .../math/base/special/fibonaccif/test/test.native.js | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js index 49d0f8a621a5..3d86709ed6e5 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js @@ -43,7 +43,7 @@ tape( 'if provided a negative number, the function returns `NaN`', function test var v; var i; - t.strictEqual( isnanf( fibonaccif( -3.14 ) ), true, 'returns NaN' ); + t.strictEqual( isnanf( fibonaccif( -3.14 ) ), true, 'returns expected value' ); for ( i = -1; i > -100; i-- ) { v = fibonaccif( i ); @@ -54,19 +54,19 @@ tape( 'if provided a negative number, the function returns `NaN`', function test tape( 'if provided positive infinity, the function returns `NaN`', function test( t ) { var v = fibonaccif( PINF ); - t.strictEqual( isnanf( v ), true, 'returns NaN when provided +infinity' ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); t.end(); }); tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { var v = fibonaccif( NaN ); - t.strictEqual( isnanf( v ), true, 'returns NaN when provided a 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 = fibonaccif( 3.14 ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); t.end(); }); @@ -75,7 +75,7 @@ tape( 'the function returns the nth Fibonacci number', function test( t ) { var i; for ( i = 0; i < 37; i++ ) { v = fibonaccif( i ); - t.strictEqual( v, FIBONACCI[ i ], 'returns the '+i+'th Fibonacci number' ); + t.strictEqual( v, FIBONACCI[ i ], 'returns expected value' ); } t.end(); }); @@ -85,7 +85,7 @@ tape( 'if provided nonnegative integers greater than `36`, the function returns var v; for ( i = 37; i < 500; i++ ) { v = fibonaccif( i ); - t.strictEqual( isnanf( v ), true, 'returns NaN when provided ' + i ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.native.js index 3f105059882e..bd7b8bf98537 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.native.js @@ -53,7 +53,7 @@ tape( 'if provided a negative number, the function returns `NaN`', opts, functio for ( i = -1; i > -100; i-- ) { v = fibonaccif( i ); - t.strictEqual( isnanf( v ), true, 'returns NaN when provided ' + i ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); } t.end(); }); @@ -63,7 +63,7 @@ tape( 'the function returns the nth Fibonacci number', opts, function test( t ) var i; for ( i = 0; i < 37; i++ ) { v = fibonaccif( i ); - t.strictEqual( v, FIBONACCI[ i ], 'returns the '+i+'th Fibonacci number' ); + t.strictEqual( v, FIBONACCI[ i ], 'returns expected value' ); } t.end(); }); @@ -73,7 +73,7 @@ tape( 'if provided nonnegative integers greater than `36`, the function returns var v; for ( i = 37; i < 500; i++ ) { v = fibonaccif( i ); - t.strictEqual( isnanf( v ), true, 'returns NaN when provided ' + i ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); } t.end(); }); From 6818de54d7464bf042cdd4f0b1474c27fed74d96 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Tue, 1 Apr 2025 23:06:35 -0700 Subject: [PATCH 7/7] chore: re-enable lint rule --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/fibonaccif/src/addon.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c index 89356973ba9d..0c93d2701413 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c @@ -19,5 +19,4 @@ #include "stdlib/math/base/special/fibonaccif.h" #include "stdlib/math/base/napi/unary.h" -// cppcheck-suppress shadowFunction STDLIB_MATH_BASE_NAPI_MODULE_I_F( stdlib_base_fibonaccif )