From 709fa52b6a3791aa84ceb1b89ec5163b4c01e5c3 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 <neerajrpathak710@gmail.com> Date: Sun, 23 Mar 2025 02:14:09 +0530 Subject: [PATCH 1/5] chore: adding essential files --- .../math/base/special/fibonaccif/README.md | 258 ++++++++++++ .../special/fibonaccif/benchmark/benchmark.js | 395 ++++++++++++++++++ .../fibonaccif/benchmark/benchmark.native.js | 61 +++ .../special/fibonaccif/benchmark/c/Makefile | 127 ++++++ .../fibonaccif/benchmark/c/benchmark.c | 145 +++++++ .../fibonaccif/benchmark/c/native/Makefile | 146 +++++++ .../fibonaccif/benchmark/c/native/benchmark.c | 133 ++++++ .../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 | 29 ++ .../math/base/special/fibonaccif/include.gypi | 53 +++ .../stdlib/math/base/special/fibonaccif.h | 40 ++ .../special/fibonaccif/lib/fibonaccif.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 ++++ 29 files changed, 2703 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/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/fibonaccif.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..ab20462ac5f8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md @@ -0,0 +1,258 @@ +<!-- + +@license Apache-2.0 + +Copyright (c) 2025 The Stdlib Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> + +# Fibonaccif + +> Compute the nth [Fibonacci number][fibonacci-number] as a [single-precision floating-point number][ieee754]. + +<section class="intro"> + +The [Fibonacci numbers][fibonacci-number] are the integer sequence + +<!-- <equation class="equation" label="eq:fibonacci_sequence" align="center" raw="0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, \ldots" alt="Fibonacci sequence"> --> + +```math +0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, \ldots +``` + +<!-- <div class="equation" align="center" data-raw-text="0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, \ldots" data-equation="eq:fibonacci_sequence"> + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_sequence.svg" alt="Fibonacci sequence"> + <br> +</div> --> + +<!-- </equation> --> + +The sequence is defined by the recurrence relation + +<!-- <equation class="equation" label="eq:fibonacci_recurrence_relation" align="center" raw="F_n = F_{n-1} + F_{n-2}" alt="Fibonacci sequence recurrence relation"> --> + +```math +F_n = F_{n-1} + F_{n-2} +``` + +<!-- <div class="equation" align="center" data-raw-text="F_n = F_{n-1} + F_{n-2}" data-equation="eq:fibonacci_recurrence_relation"> + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_recurrence_relation.svg" alt="Fibonacci sequence recurrence relation"> + <br> +</div> --> + +<!-- </equation> --> + +with seed values `F_0 = 0` and `F_1 = 1`. + +</section> + +<!-- /.intro --> + +<section class="usage"> + +## Usage + +```javascript +var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' ); +``` + +#### fibonaccif( n ) + +Computes the nth [Fibonacci number][fibonacci-number] as a [single-precision floating-point number][ieee754]. + +```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 +``` + +</section> + +<!-- /.usage --> + +<section class="notes"> + +</section> + +<!-- /.notes --> + +<section class="examples"> + +## Examples + +<!-- eslint no-undef: "error" --> + +```javascript +var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' ); + +var v; +var i; + +for ( i = 0; i < 37; i++ ) { + v = fibonaccif( i ); + console.log( v ); +} +``` + +</section> + +<!-- /.examples --> + +<!-- C interface documentation. --> + +* * * + +<section class="c"> + +## C APIs + +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> + +<section class="intro"> + +</section> + +<!-- /.intro --> + +<!-- C usage documentation. --> + +<section class="usage"> + +### Usage + +```c +#include "stdlib/math/base/special/fibonaccif.h" +``` + +#### stdlib_base_fibonaccif( n ) + +Computes the nth [Fibonacci number][fibonacci-number] as a [single-precision floating-point number][ieee754]. + +```c +float out = stdlib_base_fibonaccif( 0 ); +// returns 0 + +out = stdlib_base_fibonaccif( 1 ); +// returns 1 +``` + +The function accepts the following arguments: + +- **n**: `[in] int32_t` input value. + +```c +float stdlib_base_fibonaccif( const int32_t n ); +``` + +</section> + +<!-- /.usage --> + +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> + +<section class="notes"> + +</section> + +<!-- /.notes --> + +<!-- C API usage examples. --> + +<section class="examples"> + +### Examples + +```c +#include "stdlib/math/base/special/fibonaccif.h" +#include <stdio.h> +#include <stdint.h> + +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 ); + } +} +``` + +</section> + +<!-- /.examples --> + +</section> + +<!-- /.c --> + +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> + +<section class="related"> + +</section> + +<!-- /.related --> + +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> + +<section class="links"> + +[fibonacci-number]: https://en.wikipedia.org/wiki/Fibonacci_number + +[ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985 + +<!-- <related-links> --> + +<!-- </related-links> --> + +</section> + +<!-- /.links --> 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..4ae4d01be503 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.js @@ -0,0 +1,395 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var floorf = require( '@stdlib/math/base/special/floorf' ); +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 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; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( randu()*37.0 ); + y = fibonaccif( x ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::analytic', function benchmark( b ) { + var x; + var y; + var i; + + function fibonaccif( n ) { + return roundf( float64ToFloat32( pow( PHI, n ) ) / SQRT_5 ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( randu()*37.0 ); + y = fibonaccif( x ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( 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; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( randu()*37.0 ); + y = FIBONACCI[ x ]; + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( 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 fibonacci( n ) { + if ( n < 2 ) { + return n; + } + return fibonacci( n-1 ) + fibonacci( n-2 ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( randu()*19.0 ); // limit upper bound + y = fibonacci( x ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); +f +bench( pkg+'::recursion_memoized', function benchmark( b ) { + var arr; + var N; + var x; + var y; + var i; + + arr = new Array( 79 ); + 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 ]; + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( randu()*19.0 ); // limit upper bound + y = fibonaccif( x ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::naive_iterative', function benchmark( b ) { + var x; + var y; + var i; + + function fibonaccif( n ) { + var arr; + var i; + + arr = new Array( 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 ]; + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( randu()*37.0 ); + y = fibonaccif( x ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +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; + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( randu()*37.0 ); + y = fibonaccif( x ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::iterative_memoized', function benchmark( b ) { + var arr; + var N; + var x; + var y; + var i; + + arr = new Array( 79 ); + 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 ]; + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( randu()*37.0 ); + y = fibonaccif( x ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +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 floor( i/2 ) + } + return a + b; + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( randu()*37.0 ); + y = fibonaccif( x ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::iterative_doubling_memoized', function benchmark( b ) { + var arr; + var N; + var x; + var y; + var i; + + arr = new Array( 79 ); + 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 floor( i/2 ) + } + arr[ n ] = a + b; + return a + b; + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( randu()*37.0 ); + y = fibonaccif( x ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/benchmark.native.js new file mode 100644 index 000000000000..a35a0f994e81 --- /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) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var floorf = require( '@stdlib/math/base/special/floorf' ); +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; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( randu()*37.0 ); + y = fibonaccif( x ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/Makefile new file mode 100644 index 000000000000..d564e8b2d6f9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/Makefile @@ -0,0 +1,127 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles C source files. +# +# @param {string} [C_COMPILER] - C compiler +# @param {string} [CFLAGS] - C compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler +# @param {string} CFLAGS - C compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $< -lm + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/benchmark.c new file mode 100644 index 000000000000..5e8c2a34a2d7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/benchmark.c @@ -0,0 +1,145 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <math.h> +#include <time.h> +#include <sys/time.h> + +#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 = (int)floorf( 40.0f*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..a4bd7b38fd74 --- /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) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/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..411d85086e8f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/benchmark/c/native/benchmark.c @@ -0,0 +1,133 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/fibonaccif.h" +#include <stdlib.h> +#include <stdio.h> +#include <math.h> +#include <time.h> +#include <sys/time.h> + +#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; + float y; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + x = (int32_t)floorf( 40.0f*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/binding.gyp b/lib/node_modules/@stdlib/math/base/special/fibonaccif/binding.gyp new file mode 100644 index 000000000000..68a1ca11d160 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/math/base/special/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 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="18.279ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 7870.1 1080.4" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" aria-labelledby="MathJax-SVG-1-Title"> +<title id="MathJax-SVG-1-Title">upper F Subscript n Baseline equals upper F Subscript n minus 1 Baseline plus upper F Subscript n minus 2</title> +<defs aria-hidden="true"> +<path stroke-width="1" id="E1-MJMATHI-46" d="M48 1Q31 1 31 11Q31 13 34 25Q38 41 42 43T65 46Q92 46 125 49Q139 52 144 61Q146 66 215 342T285 622Q285 629 281 629Q273 632 228 634H197Q191 640 191 642T193 659Q197 676 203 680H742Q749 676 749 669Q749 664 736 557T722 447Q720 440 702 440H690Q683 445 683 453Q683 454 686 477T689 530Q689 560 682 579T663 610T626 626T575 633T503 634H480Q398 633 393 631Q388 629 386 623Q385 622 352 492L320 363H375Q378 363 398 363T426 364T448 367T472 374T489 386Q502 398 511 419T524 457T529 475Q532 480 548 480H560Q567 475 567 470Q567 467 536 339T502 207Q500 200 482 200H470Q463 206 463 212Q463 215 468 234T473 274Q473 303 453 310T364 317H309L277 190Q245 66 245 60Q245 46 334 46H359Q365 40 365 39T363 19Q359 6 353 0H336Q295 2 185 2Q120 2 86 2T48 1Z"></path> +<path stroke-width="1" id="E1-MJMATHI-6E" d="M21 287Q22 293 24 303T36 341T56 388T89 425T135 442Q171 442 195 424T225 390T231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336T465 179T427 52Q427 26 444 26Q450 26 453 27Q482 32 505 65T540 145Q542 153 560 153Q580 153 580 145Q580 144 576 130Q568 101 554 73T508 17T439 -10Q392 -10 371 17T350 73Q350 92 386 193T423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 180T152 343Q153 348 153 366Q153 405 129 405Q91 405 66 305Q60 285 60 284Q58 278 41 278H27Q21 284 21 287Z"></path> +<path stroke-width="1" id="E1-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"></path> +<path stroke-width="1" id="E1-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"></path> +<path stroke-width="1" id="E1-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path> +<path stroke-width="1" id="E1-MJMAIN-2B" d="M56 237T56 250T70 270H369V420L370 570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401 -82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z"></path> +<path stroke-width="1" id="E1-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"></path> +</defs> +<g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)" aria-hidden="true"> + <use xlink:href="#E1-MJMATHI-46" x="0" y="0"></use> + <use transform="scale(0.707)" xlink:href="#E1-MJMATHI-6E" x="910" y="-213"></use> + <use xlink:href="#E1-MJMAIN-3D" x="1445" y="0"></use> +<g transform="translate(2502,0)"> + <use xlink:href="#E1-MJMATHI-46" x="0" y="0"></use> +<g transform="translate(643,-150)"> + <use transform="scale(0.707)" xlink:href="#E1-MJMATHI-6E" x="0" y="0"></use> + <use transform="scale(0.707)" xlink:href="#E1-MJMAIN-2212" x="600" y="0"></use> + <use transform="scale(0.707)" xlink:href="#E1-MJMAIN-31" x="1379" y="0"></use> +</g> +</g> + <use xlink:href="#E1-MJMAIN-2B" x="4796" y="0"></use> +<g transform="translate(5797,0)"> + <use xlink:href="#E1-MJMATHI-46" x="0" y="0"></use> +<g transform="translate(643,-150)"> + <use transform="scale(0.707)" xlink:href="#E1-MJMATHI-6E" x="0" y="0"></use> + <use transform="scale(0.707)" xlink:href="#E1-MJMAIN-2212" x="600" y="0"></use> + <use transform="scale(0.707)" xlink:href="#E1-MJMAIN-32" x="1379" y="0"></use> +</g> +</g> +</g> +</svg> \ 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 @@ +<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="39.414ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 16969.7 1080.4" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" aria-labelledby="MathJax-SVG-1-Title"> +<title id="MathJax-SVG-1-Title">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</title> +<defs aria-hidden="true"> +<path stroke-width="1" id="E1-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"></path> +<path stroke-width="1" id="E1-MJMAIN-2C" d="M78 35T78 60T94 103T137 121Q165 121 187 96T210 8Q210 -27 201 -60T180 -117T154 -158T130 -185T117 -194Q113 -194 104 -185T95 -172Q95 -168 106 -156T131 -126T157 -76T173 -3V9L172 8Q170 7 167 6T161 3T152 1T140 0Q113 0 96 17Z"></path> +<path stroke-width="1" id="E1-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path> +<path stroke-width="1" id="E1-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"></path> +<path stroke-width="1" id="E1-MJMAIN-33" d="M127 463Q100 463 85 480T69 524Q69 579 117 622T233 665Q268 665 277 664Q351 652 390 611T430 522Q430 470 396 421T302 350L299 348Q299 347 308 345T337 336T375 315Q457 262 457 175Q457 96 395 37T238 -22Q158 -22 100 21T42 130Q42 158 60 175T105 193Q133 193 151 175T169 130Q169 119 166 110T159 94T148 82T136 74T126 70T118 67L114 66Q165 21 238 21Q293 21 321 74Q338 107 338 175V195Q338 290 274 322Q259 328 213 329L171 330L168 332Q166 335 166 348Q166 366 174 366Q202 366 232 371Q266 376 294 413T322 525V533Q322 590 287 612Q265 626 240 626Q208 626 181 615T143 592T132 580H135Q138 579 143 578T153 573T165 566T175 555T183 540T186 520Q186 498 172 481T127 463Z"></path> +<path stroke-width="1" id="E1-MJMAIN-35" d="M164 157Q164 133 148 117T109 101H102Q148 22 224 22Q294 22 326 82Q345 115 345 210Q345 313 318 349Q292 382 260 382H254Q176 382 136 314Q132 307 129 306T114 304Q97 304 95 310Q93 314 93 485V614Q93 664 98 664Q100 666 102 666Q103 666 123 658T178 642T253 634Q324 634 389 662Q397 666 402 666Q410 666 410 648V635Q328 538 205 538Q174 538 149 544L139 546V374Q158 388 169 396T205 412T256 420Q337 420 393 355T449 201Q449 109 385 44T229 -22Q148 -22 99 32T50 154Q50 178 61 192T84 210T107 214Q132 214 148 197T164 157Z"></path> +<path stroke-width="1" id="E1-MJMAIN-38" d="M70 417T70 494T124 618T248 666Q319 666 374 624T429 515Q429 485 418 459T392 417T361 389T335 371T324 363L338 354Q352 344 366 334T382 323Q457 264 457 174Q457 95 399 37T249 -22Q159 -22 101 29T43 155Q43 263 172 335L154 348Q133 361 127 368Q70 417 70 494ZM286 386L292 390Q298 394 301 396T311 403T323 413T334 425T345 438T355 454T364 471T369 491T371 513Q371 556 342 586T275 624Q268 625 242 625Q201 625 165 599T128 534Q128 511 141 492T167 463T217 431Q224 426 228 424L286 386ZM250 21Q308 21 350 55T392 137Q392 154 387 169T375 194T353 216T330 234T301 253T274 270Q260 279 244 289T218 306L210 311Q204 311 181 294T133 239T107 157Q107 98 150 60T250 21Z"></path> +<path stroke-width="1" id="E1-MJMAIN-34" d="M462 0Q444 3 333 3Q217 3 199 0H190V46H221Q241 46 248 46T265 48T279 53T286 61Q287 63 287 115V165H28V211L179 442Q332 674 334 675Q336 677 355 677H373L379 671V211H471V165H379V114Q379 73 379 66T385 54Q393 47 442 46H471V0H462ZM293 211V545L74 212L183 211H293Z"></path> +<path stroke-width="1" id="E1-MJMAIN-39" d="M352 287Q304 211 232 211Q154 211 104 270T44 396Q42 412 42 436V444Q42 537 111 606Q171 666 243 666Q245 666 249 666T257 665H261Q273 665 286 663T323 651T370 619T413 560Q456 472 456 334Q456 194 396 97Q361 41 312 10T208 -22Q147 -22 108 7T68 93T121 149Q143 149 158 135T173 96Q173 78 164 65T148 49T135 44L131 43Q131 41 138 37T164 27T206 22H212Q272 22 313 86Q352 142 352 280V287ZM244 248Q292 248 321 297T351 430Q351 508 343 542Q341 552 337 562T323 588T293 615T246 625Q208 625 181 598Q160 576 154 546T147 441Q147 358 152 329T172 282Q197 248 244 248Z"></path> +<path stroke-width="1" id="E1-MJMAIN-2026" d="M78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60ZM525 60Q525 84 542 102T585 120Q609 120 627 104T646 61Q646 36 629 18T586 0T543 17T525 60ZM972 60Q972 84 989 102T1032 120Q1056 120 1074 104T1093 61Q1093 36 1076 18T1033 0T990 17T972 60Z"></path> +</defs> +<g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)" aria-hidden="true"> + <use xlink:href="#E1-MJMAIN-30" x="0" y="0"></use> + <use xlink:href="#E1-MJMAIN-2C" x="500" y="0"></use> + <use xlink:href="#E1-MJMAIN-31" x="945" y="0"></use> + <use xlink:href="#E1-MJMAIN-2C" x="1446" y="0"></use> + <use xlink:href="#E1-MJMAIN-31" x="1891" y="0"></use> + <use xlink:href="#E1-MJMAIN-2C" x="2391" y="0"></use> + <use xlink:href="#E1-MJMAIN-32" x="2836" y="0"></use> + <use xlink:href="#E1-MJMAIN-2C" x="3337" y="0"></use> + <use xlink:href="#E1-MJMAIN-33" x="3782" y="0"></use> + <use xlink:href="#E1-MJMAIN-2C" x="4283" y="0"></use> + <use xlink:href="#E1-MJMAIN-35" x="4728" y="0"></use> + <use xlink:href="#E1-MJMAIN-2C" x="5228" y="0"></use> + <use xlink:href="#E1-MJMAIN-38" x="5674" y="0"></use> + <use xlink:href="#E1-MJMAIN-2C" x="6174" y="0"></use> +<g transform="translate(6619,0)"> + <use xlink:href="#E1-MJMAIN-31"></use> + <use xlink:href="#E1-MJMAIN-33" x="500" y="0"></use> +</g> + <use xlink:href="#E1-MJMAIN-2C" x="7620" y="0"></use> +<g transform="translate(8065,0)"> + <use xlink:href="#E1-MJMAIN-32"></use> + <use xlink:href="#E1-MJMAIN-31" x="500" y="0"></use> +</g> + <use xlink:href="#E1-MJMAIN-2C" x="9066" y="0"></use> +<g transform="translate(9512,0)"> + <use xlink:href="#E1-MJMAIN-33"></use> + <use xlink:href="#E1-MJMAIN-34" x="500" y="0"></use> +</g> + <use xlink:href="#E1-MJMAIN-2C" x="10513" y="0"></use> +<g transform="translate(10958,0)"> + <use xlink:href="#E1-MJMAIN-35"></use> + <use xlink:href="#E1-MJMAIN-35" x="500" y="0"></use> +</g> + <use xlink:href="#E1-MJMAIN-2C" x="11959" y="0"></use> +<g transform="translate(12404,0)"> + <use xlink:href="#E1-MJMAIN-38"></use> + <use xlink:href="#E1-MJMAIN-39" x="500" y="0"></use> +</g> + <use xlink:href="#E1-MJMAIN-2C" x="13405" y="0"></use> +<g transform="translate(13850,0)"> + <use xlink:href="#E1-MJMAIN-31"></use> + <use xlink:href="#E1-MJMAIN-34" x="500" y="0"></use> + <use xlink:href="#E1-MJMAIN-34" x="1001" y="0"></use> +</g> + <use xlink:href="#E1-MJMAIN-2C" x="15351" y="0"></use> + <use xlink:href="#E1-MJMAIN-2026" x="15797" y="0"></use> +</g> +</svg> \ 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..03a808e0c395 --- /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 as a single-precision floating-point number. + + 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..ae8af8c6a2d7 --- /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) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Computes the nth Fibonacci number as a single-precision floating-point number. +* +* ## 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..ea01795f88af --- /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) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import 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..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/c/example.c new file mode 100644 index 000000000000..cab99e248bac --- /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) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/fibonaccif.h" +#include <stdio.h> +#include <stdint.h> + +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..b4ab9fe28601 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/examples/index.js @@ -0,0 +1,29 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var fibonaccif = require( './../lib' ); + +var v; +var i; + +for ( i = 0; i < 37; i++ ) { + v = fibonaccif( i ); + console.log( v ); +} 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..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).include; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")', + ], + + # Add-on destination directory: + 'addon_output_dir': './src', + + # Source files: + 'src_files': [ + '<(src_dir)/addon.c', + '<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).src; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")', + ], + + # Library dependencies: + 'libraries': [ + '<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libraries; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")', + ], + + # Library directories: + 'library_dirs': [ + '<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libpath; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")', + ], + }, # end variables +} 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 new file mode 100644 index 000000000000..4b1c175fc166 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/include/stdlib/math/base/special/fibonaccif.h @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_MATH_BASE_SPECIAL_FIBONACCIF_H +#define STDLIB_MATH_BASE_SPECIAL_FIBONACCIF_H + +#include <stdint.h> + +/* +* 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 as a single-precision floating-point number. +*/ +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/fibonaccif.json b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/fibonaccif.json new file mode 100644 index 000000000000..66bb27dccf5d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/fibonaccif.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..422cf0a10f95 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/index.js @@ -0,0 +1,58 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Compute the nth Fibonacci number as a single-precision floating-point number. +* +* @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..b6af3c968e22 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/main.js @@ -0,0 +1,92 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var isIntegerf = require( '@stdlib/math/base/assert/is-integerf' ); +var FLOAT32_MAX_SAFE_NTH_FIBONACCI = require( '@stdlib/constants/float32/max-safe-nth-fibonacci' ); // eslint-disable-line id-length +var FIBONACCIF = require( './fibonaccif.json' ); + + +// MAIN // + +/** +* Computes the nth Fibonacci number as a single-precision floating-point number. +* +* @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 > FLOAT32_MAX_SAFE_NTH_FIBONACCI + ) { + return NaN; + } + return FIBONACCIF[ 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..6df1e9d5ea29 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/lib/native.js @@ -0,0 +1,74 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Computes the nth Fibonacci number as a single-precision floating-point number. +* +* @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..92be95e2ee61 --- /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 as a single-precision floating-point number.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "special functions", + "special", + "function", + "fibonacci", + "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..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c new file mode 100644 index 000000000000..89356973ba9d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/addon.c @@ -0,0 +1,23 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/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..09637926c034 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/src/main.c @@ -0,0 +1,77 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/fibonaccif.h" +#include "stdlib/constants/float32/max_safe_nth_fibonacci.h" + +static const int32_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 as a single-precision floating-point number. +* +* @param n input value +* @return output value +* +* @example +* float out = stdlib_base_fibonaccif( 1 ); +* // returns 1 +*/ +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..dfb2252d93e1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/test/test.js @@ -0,0 +1,91 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var fibonaccif = require( './../lib' ); + + +// FIXTURES // + +var FIBONACCIF = require( './../lib/fibonaccif.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, FIBONACCIF[ i ], 'returns the '+i+'th Fibonacci number' ); + } + t.end(); +}); + +tape( 'if provided nonnegative integers greater than `78`, 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..89f16f37e055 --- /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) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// FIXTURES // + +var FIBONACCIF = require( './../lib/fibonaccif.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, FIBONACCIF[ i ], 'returns the '+i+'th Fibonacci number' ); + } + t.end(); +}); + +tape( 'if provided nonnegative integers greater than `78`, 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 a830b82b530ec69a5fdf77772f44a02fc2fcaf91 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 <neerajrpathak710@gmail.com> Date: Sun, 23 Mar 2025 02:22:50 +0530 Subject: [PATCH 2/5] chore: refactoring benchmarks --- .../base/special/fibonaccif/benchmark/benchmark.js | 12 ++++++------ .../math/base/special/fibonaccif/docs/repl.txt | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) 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 4ae4d01be503..82097fda2dea 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 @@ -30,7 +30,7 @@ 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 pkg = require( './../package.json' ).name; -var FIBONACCI = require( './../lib/fibonacci.json' ); +var FIBONACCIF = require( './../lib/fibonaccif.json' ); var fibonaccif = require( './../lib' ); @@ -80,7 +80,7 @@ bench( pkg+'::analytic', function benchmark( b ) { } } b.toc(); - if ( isnan( y ) ) { + if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); @@ -95,13 +95,13 @@ bench( pkg+'::table', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { x = floorf( randu()*37.0 ); - y = FIBONACCI[ x ]; + y = FIBONACCIF[ x ]; if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( y ) ) { + if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); @@ -129,13 +129,13 @@ bench( pkg+'::naive_recursion', function benchmark( b ) { } } b.toc(); - if ( isnan( y ) ) { + if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); b.end(); }); -f + bench( pkg+'::recursion_memoized', function benchmark( b ) { var arr; var N; 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 03a808e0c395..9d88ac34b61b 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,10 +1,11 @@ {{alias}}( n ) - Computes the nth Fibonacci number as a single-precision floating-point number. + Computes the nth Fibonacci number as a single-precision + floating-point number. Fibonacci numbers follow the recurrence relation - F_n = F_{n-1} + F_{n-2} + F_n = F_{n-1} + F_{n-2} with seed values F_0 = 0 and F_1 = 1. From 48cc51bba0c23a38ec06d0cb47eda21e8fd1839e Mon Sep 17 00:00:00 2001 From: Neerajpathak07 <neerajrpathak710@gmail.com> Date: Sun, 23 Mar 2025 02:27:48 +0530 Subject: [PATCH 3/5] chore: minor clean up --- .../base/special/fibonaccif/benchmark/benchmark.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 82097fda2dea..8a546a14ab3f 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 @@ -28,7 +28,7 @@ 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 FLOAT32_PHI = require( '@stdlib/constants/float32/phi' ); var pkg = require( './../package.json' ).name; var FIBONACCIF = require( './../lib/fibonaccif.json' ); var fibonaccif = require( './../lib' ); @@ -68,7 +68,7 @@ bench( pkg+'::analytic', function benchmark( b ) { var i; function fibonaccif( n ) { - return roundf( float64ToFloat32( pow( PHI, n ) ) / SQRT_5 ); + return roundf( float64ToFloat32( pow( FLOAT32_PHI, n ) ) / SQRT_5 ); } b.tic(); @@ -143,7 +143,7 @@ bench( pkg+'::recursion_memoized', function benchmark( b ) { var y; var i; - arr = new Array( 79 ); + arr = new Array( 37 ); arr[ 0 ] = 0; arr[ 1 ] = 1; arr[ 2 ] = 1; @@ -252,7 +252,7 @@ bench( pkg+'::iterative_memoized', function benchmark( b ) { var y; var i; - arr = new Array( 79 ); + arr = new Array( 37 ); arr[ 0 ] = 0; arr[ 1 ] = 1; arr[ 2 ] = 1; @@ -338,7 +338,7 @@ bench( pkg+'::iterative_doubling_memoized', function benchmark( b ) { var y; var i; - arr = new Array( 79 ); + arr = new Array( 37 ); arr[ 0 ] = 0; arr[ 1 ] = 1; arr[ 2 ] = 1; From 1312fcf95952823e4735a18cecd0cb5f55e405b0 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 <neerajrpathak710@gmail.com> Date: Sun, 23 Mar 2025 02:36:39 +0530 Subject: [PATCH 4/5] chore: minor clean up --- .../math/base/special/fibonaccif/benchmark/benchmark.js | 9 +++++---- .../@stdlib/math/base/special/fibonaccif/test/test.js | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) 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 8a546a14ab3f..e80863c8e0e2 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 @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var randu = require( '@stdlib/random/base/randu' ); +var Int32Array = require( '@stdlib/array/int32' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var floorf = require( '@stdlib/math/base/special/floorf' ); var roundf = require( '@stdlib/math/base/special/roundf' ); @@ -143,7 +144,7 @@ bench( pkg+'::recursion_memoized', function benchmark( b ) { var y; var i; - arr = new Array( 37 ); + arr = new Int32Array( 37 ); arr[ 0 ] = 0; arr[ 1 ] = 1; arr[ 2 ] = 1; @@ -182,7 +183,7 @@ bench( pkg+'::naive_iterative', function benchmark( b ) { var arr; var i; - arr = new Array( n+1 ); + arr = new Int32Array( n+1 ); arr[ 0 ] = 0; arr[ 1 ] = 1; arr[ 2 ] = 1; @@ -252,7 +253,7 @@ bench( pkg+'::iterative_memoized', function benchmark( b ) { var y; var i; - arr = new Array( 37 ); + arr = new Int32Array( 37 ); arr[ 0 ] = 0; arr[ 1 ] = 1; arr[ 2 ] = 1; @@ -338,7 +339,7 @@ bench( pkg+'::iterative_doubling_memoized', function benchmark( b ) { var y; var i; - arr = new Array( 37 ); + arr = new Int32Array( 37 ); arr[ 0 ] = 0; arr[ 1 ] = 1; arr[ 2 ] = 1; 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 dfb2252d93e1..30d12b7d2fc2 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 @@ -80,7 +80,7 @@ tape( 'the function returns the nth Fibonacci number', function test( t ) { t.end(); }); -tape( 'if provided nonnegative integers greater than `78`, the function returns `NaN`', function test( t ) { +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++ ) { From eda6ba56cccf005a89b6fff3b2126901574d3d7f Mon Sep 17 00:00:00 2001 From: Neerajpathak07 <neerajrpathak710@gmail.com> Date: Sun, 23 Mar 2025 02:43:19 +0530 Subject: [PATCH 5/5] chore: referencing the svg to previous version --- .../@stdlib/math/base/special/fibonaccif/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 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 ab20462ac5f8..3407c9518748 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/README.md @@ -33,7 +33,7 @@ The [Fibonacci numbers][fibonacci-number] are the integer sequence ``` <!-- <div class="equation" align="center" data-raw-text="0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, \ldots" data-equation="eq:fibonacci_sequence"> - <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_sequence.svg" alt="Fibonacci sequence"> + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/fibonacci/docs/img/equation_fibonacci_sequence.svg" alt="Fibonacci sequence"> <br> </div> --> @@ -48,7 +48,7 @@ F_n = F_{n-1} + F_{n-2} ``` <!-- <div class="equation" align="center" data-raw-text="F_n = F_{n-1} + F_{n-2}" data-equation="eq:fibonacci_recurrence_relation"> - <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_recurrence_relation.svg" alt="Fibonacci sequence recurrence relation"> + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/fibonacci/docs/img/equation_fibonacci_recurrence_relation.svg" alt="Fibonacci sequence recurrence relation"> <br> </div> -->