diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md new file mode 100644 index 000000000000..622ce9e849c5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md @@ -0,0 +1,249 @@ + + +# Non-Fibonacci + +> Compute the nth [non-Fibonacci][fibonacci-number] single-precision floating-point number. + + + +
+ +The nth [non-Fibonacci number][fibonacci-number] is given by + + + +```math +f(n) = \left \lfloor{ n + 1 + \log_\varphi \biggl( \sqrt{5}( n + 1 + \log_\varphi(\sqrt{5}(n+1))) - 5 + \tfrac{3}{n+1} \biggr) - 2 } \right \rfloor +``` + + + + + +where `φ` is the [golden ratio][golden-ratio]. + +
+ + + + + +
+ +## Usage + +```javascript +var nonfibonaccif = require( '@stdlib/math/base/special/nonfibonaccif' ); +``` + +#### nonfibonaccif( n ) + +Computes the nth [non-Fibonacci][fibonacci-number] single-precision floating-point number. + +```javascript +var v = nonfibonaccif( 1 ); +// returns 4 + +v = nonfibonaccif( 2 ); +// returns 6 + +v = nonfibonaccif( 3 ); +// returns 7 +``` + +If provided either a non-integer or `n < 1`, the function returns `NaN`. + +```javascript +var v = nonfibonaccif( -1 ); +// returns NaN + +v = nonfibonaccif( 3.14 ); +// returns NaN +``` + +If provided `NaN`, the function returns `NaN`. + +```javascript +var v = nonfibonaccif( NaN ); +// returns NaN +``` + +
+ + + + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var nonfibonaccif = require( '@stdlib/math/base/special/nonfibonaccif' ); + +var i; +for ( i = 1; i < 100; i++ ) { + console.log( 'nonfibonaccif(%d) = %d', i, nonfibonaccif( i ) ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/nonfibonaccif.h" +``` + +#### stdlib_base_nonfibonaccif( x ) + +Computes the nth non-Fibonacci single-precision floating-point number. + +```c +float out = stdlib_base_nonfibonaccif( 1 ); +// returns 4.0f + +out = stdlib_base_nonfibonaccif( 2 ); +// returns 6.0f +``` + +The function accepts the following arguments: + +- **x**: `[in] int32_t` input value. + +```c +float stdlib_base_nonfibonaccif( const int32_t x ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/nonfibonaccif.h" +#include + +int main( void ) { + int i; + + for ( i = 1; i < 12; i++ ) { + printf( "x: %i => result: %f", i , stdlib_base_nonfibonaccif( i ) ); + } +} +``` + +
+ + + +
+ + + + + +* * * + +
+ +## References + +- Gould, H.W. 1965. "Non-Fibonacci Numbers." _Fibonacci Quarterly_, no. 3: 177–83. [<http://www.fq.math.ca/Scanned/3-3/gould.pdf>][@gould:1965a]. +- Farhi, Bakir. 2011. "An explicit formula generating the non-Fibonacci numbers." _arXiv_ abs/1105.1127 \[Math.NT] (May): 1–5. [<https://arxiv.org/abs/1105.1127>][@farhi:2011a]. + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.js new file mode 100644 index 000000000000..4ad7a4c031a0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/array/discrete-uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pkg = require( './../package.json' ).name; +var nonfibonaccif = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var i; + + x = randu( 100, 1, 100 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = nonfibonaccif( x[ i % 100 ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.native.js new file mode 100644 index 000000000000..d73228d5fd3c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.native.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var randu = require( '@stdlib/random/array/discrete-uniform' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var bench = require( '@stdlib/bench' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var nonfibonaccif = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( nonfibonaccif instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var x; + var y; + var i; + + x = randu( 100, 1, 100 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = nonfibonaccif( x[ i % 100 ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/c/native/Makefile new file mode 100644 index 000000000000..f69e9da2b4d3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/c/native/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/nonfibonaccif/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..91a9621eca07 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/c/native/benchmark.c @@ -0,0 +1,135 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/nonfibonaccif.h" +#include +#include +#include +#include +#include + +#define NAME "nonfibonaccif" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + int x[ 100 ]; + double t; + float y; + int i; + + for ( i = 0; i < 100; i++ ) { + x[ i ] = (int)floorf( ( 100.0f * rand_float() ) + 1.0f ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_nonfibonaccif( x[ i % 100 ] ); + 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/nonfibonaccif/benchmark/julia/REQUIRE b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/julia/REQUIRE new file mode 100644 index 000000000000..98645e192e41 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/julia/REQUIRE @@ -0,0 +1,2 @@ +julia 1.5 +BenchmarkTools 0.5.0 diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/julia/benchmark.jl new file mode 100755 index 000000000000..28e0bf53be8c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/julia/benchmark.jl @@ -0,0 +1,152 @@ +#!/usr/bin/env julia +# +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import BenchmarkTools +using Printf + +# Benchmark variables: +name = "nonfibonacci"; +repeats = 3; + +""" + print_version() + +Prints the TAP version. + +# Examples + +``` julia +julia> print_version() +``` +""" +function print_version() + @printf( "TAP version 13\n" ); +end + +""" + print_summary( total, passing ) + +Print the benchmark summary. + +# Arguments + +* `total`: total number of tests +* `passing`: number of passing tests + +# Examples + +``` julia +julia> print_summary( 3, 3 ) +``` +""" +function print_summary( total, passing ) + @printf( "#\n" ); + @printf( "1..%d\n", total ); # TAP plan + @printf( "# total %d\n", total ); + @printf( "# pass %d\n", passing ); + @printf( "#\n" ); + @printf( "# ok\n" ); +end + +""" + print_results( iterations, elapsed ) + +Print benchmark results. + +# Arguments + +* `iterations`: number of iterations +* `elapsed`: elapsed time (in seconds) + +# Examples + +``` julia +julia> print_results( 1000000, 0.131009101868 ) +``` +""" +function print_results( iterations, elapsed ) + rate = iterations / elapsed + + @printf( " ---\n" ); + @printf( " iterations: %d\n", iterations ); + @printf( " elapsed: %0.9f\n", elapsed ); + @printf( " rate: %0.9f\n", rate ); + @printf( " ...\n" ); +end + +""" + benchmark() + +Run a benchmark. + +# Notes + +* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. +* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. +* The elapsed time is in seconds. + +# Examples + +``` julia +julia> out = benchmark(); +``` +""" +function benchmark() + # Define a function for computing the nth non-Fibonacci number. + function nonfibonacci( n ) + n += 1; + a = (sqrt(5.0)*(n + log( 1.618033988749895, n*sqrt(5.0) ))) - 5.0 + (3.0/n) + floor( n + log( 1.618033988749895, a ) - 2.0 ); + end + + # Benchmark: + t = BenchmarkTools.@benchmark $nonfibonacci( floor( (100.0*rand()) + 1.0 ) ) samples=1e6 + + # Compute the total "elapsed" time and convert from nanoseconds to seconds: + s = sum( t.times ) / 1.0e9; + + # Determine the number of "iterations": + iter = length( t.times ); + + # Return the results: + [ iter, s ]; +end + +""" + main() + +Run benchmarks. + +# Examples + +``` julia +julia> main(); +``` +""" +function main() + print_version(); + for i in 1:repeats + @printf( "# julia::%s\n", name ); + results = benchmark(); + print_results( results[ 1 ], results[ 2 ] ); + @printf( "ok %d benchmark finished\n", i ); + end + print_summary( repeats, repeats ); +end + +main(); diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/binding.gyp b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/binding.gyp new file mode 100644 index 000000000000..ec3992233442 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/nonfibonaccif/docs/img/equation_nonfibonacci_number.svg b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/img/equation_nonfibonacci_number.svg new file mode 100644 index 000000000000..664b6040bf9d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/img/equation_nonfibonacci_number.svg @@ -0,0 +1,97 @@ + +f left-parenthesis n right-parenthesis equals left floor n plus 1 plus log Subscript phi Baseline left-parenthesis StartRoot 5 EndRoot left-parenthesis n plus 1 plus log Subscript phi Baseline left-parenthesis StartRoot 5 EndRoot left-parenthesis n plus 1 right-parenthesis right-parenthesis right-parenthesis minus 5 plus StartFraction 3 Over n plus 1 EndFraction right-parenthesis minus 2 right floor + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/repl.txt new file mode 100644 index 000000000000..042ce4ae82d0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( n ) + Computes the nth non-Fibonacci single-precision floating-point number. + + 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: number + Non-Fibonacci number. + + Examples + -------- + > var v = {{alias}}( 1 ) + 4 + > v = {{alias}}( 2 ) + 6 + > v = {{alias}}( 3 ) + 7 + > v = {{alias}}( NaN ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/types/index.d.ts new file mode 100644 index 000000000000..87c8c6263042 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/types/index.d.ts @@ -0,0 +1,60 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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 non-Fibonacci single-precision floating-point number. +* +* ## Notes +* +* - If not provided a nonnegative integer value, the function returns `NaN`. +* +* @param n - the non-Fibonacci number to compute +* @returns non-Fibonacci number +* +* @example +* var v = nonfibonaccif( 1 ); +* // returns 4 +* +* @example +* var v = nonfibonaccif( 2 ); +* // returns 6 +* +* @example +* var v = nonfibonaccif( 3 ); +* // returns 7 +* +* @example +* var v = nonfibonaccif( NaN ); +* // returns NaN +* +* @example +* var v = nonfibonaccif( 3.14 ); +* // returns NaN +* +* @example +* var v = nonfibonaccif( -1 ); +* // returns NaN +*/ +declare function nonfibonaccif( n: number ): number; + + +// EXPORTS // + +export = nonfibonaccif; diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/types/test.ts new file mode 100644 index 000000000000..45c2153b3d67 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/types/test.ts @@ -0,0 +1,44 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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 nonfibonaccif = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + nonfibonaccif( 8 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a number... +{ + nonfibonaccif( true ); // $ExpectError + nonfibonaccif( false ); // $ExpectError + nonfibonaccif( null ); // $ExpectError + nonfibonaccif( undefined ); // $ExpectError + nonfibonaccif( '5' ); // $ExpectError + nonfibonaccif( [] ); // $ExpectError + nonfibonaccif( {} ); // $ExpectError + nonfibonaccif( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + nonfibonaccif(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/nonfibonaccif/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/c/example.c new file mode 100644 index 000000000000..8a3e063460a4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/c/example.c @@ -0,0 +1,28 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/nonfibonaccif.h" +#include + +int main( void ) { + int i; + + for ( i = 1; i < 12; i++ ) { + printf( "x: %i => result: %f", i , stdlib_base_nonfibonaccif( i ) ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/index.js b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/index.js new file mode 100644 index 000000000000..48c1959a4c0e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/index.js @@ -0,0 +1,26 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 nonfibonaccif = require( './../lib' ); + +var i; +for ( i = 1; i < 100; i++ ) { + console.log( 'nonfibonaccif(%d) = %d', i, nonfibonaccif( i ) ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/include.gypi b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/include.gypi new file mode 100644 index 000000000000..575cb043c0bf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" +{ +#endif + +/** +* Computes the nth non-Fibonacci single-precision floating-point number. +*/ +float stdlib_base_nonfibonaccif( const int32_t n ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_NONFIBONACCIF_H diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/index.js b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/index.js new file mode 100644 index 000000000000..7f28fb621dac --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/index.js @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 non-Fibonacci single-precision floating-point number. +* +* @module @stdlib/math/base/special/nonfibonaccif +* +* @example +* var nonfibonaccif = require( '@stdlib/math/base/special/nonfibonaccif' ); +* +* var v = nonfibonaccif( 1 ); +* // returns 4 +* +* v = nonfibonaccif( 2 ); +* // returns 6 +* +* v = nonfibonaccif( 3 ); +* // returns 7 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/main.js b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/main.js new file mode 100644 index 000000000000..67a4ef97eb9a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/main.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 lnf = require( '@stdlib/math/base/special/lnf' ); +var floorf = require( '@stdlib/math/base/special/floorf' ); +var PHI = require( '@stdlib/constants/float32/phi' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); + + +// VARIABLES // + +var SQRT_5 = 2.23606797749979; +var LN_PHI = lnf( PHI ); + + +// MAIN // + +/** +* Computes the nth non-Fibonacci single-precision floating-point number. +* +* ## References +* +* - Gould, H.W. 1965. "Non-Fibonacci Numbers." _Fibonacci Quarterly_, no. 3: 177–83. . +* - Farhi, Bakir. 2011. "An explicit formula generating the non-Fibonacci numbers." _arXiv_ abs/1105.1127 \[Math.NT\] (May): 1–5. . +* +* @param {NonNegativeInteger} n - the non-Fibonacci number to compute +* @returns {NonNegativeInteger} non-Fibonacci number +* +* @example +* var v = nonfibonaccif( 1 ); +* // returns 4 +* +* @example +* var v = nonfibonaccif( 2 ); +* // returns 6 +* +* @example +* var v = nonfibonaccif( 3 ); +* // returns 7 +* +* @example +* var v = nonfibonaccif( NaN ); +* // returns NaN +* +* @example +* var v = nonfibonaccif( 3.14 ); +* // returns NaN +* +* @example +* var v = nonfibonaccif( -1 ); +* // returns NaN +*/ +function nonfibonaccif( n ) { + var a; + var b; + if ( + isnanf( n ) || + isIntegerf( n ) === false || + n < 1 || + n === PINF + ) { + return NaN; + } + n += 1; + a = lnf( n * SQRT_5 ) / LN_PHI; + b = lnf( ( SQRT_5 * ( n + a ) ) - 5.0 + ( 3.0 / n ) ) / LN_PHI; + return floorf( n + b - 2.0 ); +} + + +// EXPORTS // + +module.exports = nonfibonaccif; diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/native.js b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/native.js new file mode 100644 index 000000000000..2751a27b1644 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/native.js @@ -0,0 +1,70 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isIntegerf = require( '@stdlib/math/base/assert/is-integerf' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Computes the nth non-Fibonacci single-precision floating-point number. +* +* @private +* @param {NonNegativeInteger} n - the non-Fibonacci number to compute +* @returns {NonNegativeInteger} non-Fibonacci number +* +* @example +* var v = nonfibonaccif( 1 ); +* // returns 4 +* +* @example +* var v = nonfibonaccif( 2 ); +* // returns 6 +* +* @example +* var v = nonfibonaccif( 3 ); +* // returns 7 +* +* @example +* var v = nonfibonaccif( NaN ); +* // returns NaN +* +* @example +* var v = nonfibonaccif( 3.14 ); +* // returns NaN +* +* @example +* var v = nonfibonaccif( -1 ); +* // returns NaN +*/ +function nonfibonaccif( n ) { + if ( isIntegerf( n ) === false ) { + return NaN; + } + return addon( n ); +} + + +// EXPORTS // + +module.exports = nonfibonaccif; diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/manifest.json b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/manifest.json new file mode 100644 index 000000000000..755bad5c7427 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/manifest.json @@ -0,0 +1,90 @@ +{ + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/unary", + "@stdlib/constants/float32/nan", + "@stdlib/constants/float32/phi", + "@stdlib/constants/float32/pinf", + "@stdlib/math/base/assert/is-integerf", + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/floorf", + "@stdlib/math/base/special/lnf" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/constants/float32/nan", + "@stdlib/constants/float32/phi", + "@stdlib/constants/float32/pinf", + "@stdlib/math/base/assert/is-integerf", + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/floorf", + "@stdlib/math/base/special/lnf" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/constants/float32/nan", + "@stdlib/constants/float32/phi", + "@stdlib/constants/float32/pinf", + "@stdlib/math/base/assert/is-integerf", + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/floorf", + "@stdlib/math/base/special/lnf" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/package.json b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/package.json new file mode 100644 index 000000000000..430ea21280dc --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/math/base/special/nonfibonaccif", + "version": "0.0.0", + "description": "Compute the nth non-Fibonacci 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", + "sequence", + "seq", + "number", + "integer" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/Makefile b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/nonfibonaccif/src/addon.c b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/addon.c new file mode 100644 index 000000000000..bb0588f9b536 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/addon.c @@ -0,0 +1,23 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/nonfibonaccif.h" +#include "stdlib/math/base/napi/unary.h" + +// cppcheck-suppress shadowFunction +STDLIB_MATH_BASE_NAPI_MODULE_I_F( stdlib_base_nonfibonaccif ) diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c new file mode 100644 index 000000000000..692f54676008 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c @@ -0,0 +1,79 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/nonfibonaccif.h" +#include "stdlib/constants/float32/nan.h" +#include "stdlib/constants/float32/phi.h" +#include "stdlib/constants/float32/pinf.h" +#include "stdlib/math/base/assert/is_integerf.h" +#include "stdlib/math/base/assert/is_nanf.h" +#include "stdlib/math/base/special/floorf.h" +#include "stdlib/math/base/special/lnf.h" +#include + +static const float SQRT5 = 2.23606797749979f; +static const float LN_PHI = 0.48121182506f; + +/** +* Computes the nth non-Fibonacci single-precision floating-point number. +* +* @param x input value +* @return output value +* +* @example +* float y = stdlib_base_nonfibonaccif( 2 ); +* // returns 6.0f +* +* @example +* float y = stdlib_base_nonfibonaccif( 1 ); +* // returns 4.0f +* +* @example +* float y = stdlib_base_nonfibonaccif( 3 ); +* // returns 7.0f +* +* @example +* float y = stdlib_base_nonfibonaccif( NaN ); +* // returns NaN +* +* @example +* float y = stdlib_base_nonfibonaccif( 3.14f ); +* // returns NaN +* +* @example +* float y = stdlib_base_nonfibonaccif( -1 ); +* // returns NaN +*/ +float stdlib_base_nonfibonaccif( const int32_t n ) { + int32_t m; + float a; + float b; + + if ( + stdlib_base_is_nanf( n ) || + !stdlib_base_is_integerf( n ) || + n < 1.0f || + n == STDLIB_CONSTANT_FLOAT32_PINF + ) { + return STDLIB_CONSTANT_FLOAT32_NAN; + } + m = n + 1; + a = stdlib_base_lnf( m * SQRT5 ) / LN_PHI; + b = stdlib_base_lnf( ( SQRT5 * ( m + a ) ) - 5.0f + ( 3.0f / m ) ) / LN_PHI; + return stdlib_base_floorf( m + b - 2.0f ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/fixtures/expected.json b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/fixtures/expected.json new file mode 100644 index 000000000000..834e0d60a30a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/fixtures/expected.json @@ -0,0 +1 @@ +[4,6,7,9,10,11,12,14,15,16,17,18,19,20,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,721,722,723,724,725,726,727,728,729,730,731,732,733,734,735,736,737,738,739,740,741,742,743,744,745,746,747,748,749,750,751,752,753,754,755,756,757,758,759,760,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,886,887,888,889,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,930,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,988,989,990,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1014,1015] diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js new file mode 100644 index 000000000000..2bd70fdd20cb --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js @@ -0,0 +1,83 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 nonfibonaccif = require( './../lib' ); + + +// FIXTURES // + +// Expected values are from https://oeis.org/A001690: +var expected = require( './fixtures/expected.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nonfibonaccif, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { + var n = nonfibonaccif( NaN ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided `+infinity`, the function returns `NaN`', function test( t ) { + var n = nonfibonaccif( PINF ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a number less than 1, the function returns `NaN`', function test( t ) { + var n; + var i; + + t.strictEqual( isnanf( nonfibonaccif( -3.14 ) ), true, 'returns expected value' ); + + for ( i = 0; i > -100; i-- ) { + n = nonfibonaccif( i ); + t.strictEqual( isnanf( n ), true, 'returns expected value when provided ' + i ); + } + t.end(); +}); + +tape( 'if provided a non-integer, the function returns `NaN`', function test( t ) { + var n = nonfibonaccif( 3.14 ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the nth non-Fibonacci number', function test( t ) { + var v; + var i; + + for ( i = 1; i < expected.length; i++ ) { + v = nonfibonaccif( i ); + t.strictEqual( v, expected[ i - 1 ], 'returns the '+i+'th non-Fibonacci number' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.native.js new file mode 100644 index 000000000000..f8f9eb556146 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.native.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 PINF = require( '@stdlib/constants/float32/pinf' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var nonfibonaccif = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( nonfibonaccif instanceof Error ) +}; + + +// FIXTURES // + +// Expected values are from https://oeis.org/A001690: +var expected = require( './fixtures/expected.json' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nonfibonaccif, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN`, the function returns `NaN`', opts, function test( t ) { + var n = nonfibonaccif( NaN ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided `+infinity`, the function returns `NaN`', opts, function test( t ) { + var n = nonfibonaccif( PINF ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a number less than 1, the function returns `NaN`', opts, function test( t ) { + var n; + var i; + + t.strictEqual( isnanf( nonfibonaccif( -3.14 ) ), true, 'returns expected value' ); + + for ( i = 0; i > -100; i-- ) { + n = nonfibonaccif( i ); + t.strictEqual( isnanf( n ), true, 'returns expected value when provided ' + i ); + } + t.end(); +}); + +tape( 'if provided a non-integer, the function returns `NaN`', opts, function test( t ) { + var n = nonfibonaccif( 3.14 ); + + t.strictEqual( isnanf( n ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the nth non-Fibonacci number', opts, function test( t ) { + var v; + var i; + + for ( i = 1; i < expected.length; i++ ) { + v = nonfibonaccif( i ); + t.strictEqual( v, expected[ i - 1 ], 'returns the '+i+'th non-Fibonacci number' ); + } + t.end(); +});