From 37f2cc8e284a5bc6903d9653735bab770d00330f Mon Sep 17 00:00:00 2001 From: aayush0325 Date: Tue, 10 Dec 2024 11:30:40 +0530 Subject: [PATCH 01/17] feat: basic setup done --- .../math/base/special/nonfibonaccif/README.md | 252 ++++++++++++++++++ .../base/special/nonfibonaccif/binding.gyp | 170 ++++++++++++ .../base/special/nonfibonaccif/include.gypi | 53 ++++ .../base/special/nonfibonaccif/manifest.json | 90 +++++++ .../base/special/nonfibonaccif/package.json | 69 +++++ 5 files changed, 634 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/package.json 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..8ca2a7316a8a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md @@ -0,0 +1,252 @@ + + +# Non-Fibonacci + +> Compute the nth [non-Fibonacci number][fibonacci-number] in single-precision floating-point format. + + + +
+ +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 number][fibonacci-number] in single-precision floating-point format. + +```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 v; +var i; + +for ( i = 1; i < 100; i++ ) { + v = nonfibonaccif( i ); + console.log( 'nonfibonaccif(%d) = %d', i, v ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/nonfibonaccif.h" +``` + +#### stdlib_base_nonfibonaccif( x ) + +Computes the nth non-Fibonacci number in single-precision floating-point format. + +```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 +#include +int main( void ) { + int i; + for ( i = 1; i < 12; i++ ) { + float result = stdlib_base_nonfibonaccif( i ); + printf( "x: %i => result: %lf", i , result ); + } +} +``` + +
+ + + +
+ + + + + +* * * + +
+ +## 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/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/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': [ + '=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" + ] +} From 3ddc39e80cbaf7530040183380a9fc220bedc8df Mon Sep 17 00:00:00 2001 From: aayush0325 Date: Tue, 10 Dec 2024 11:39:12 +0530 Subject: [PATCH 02/17] feat: c files added --- .../stdlib/math/base/special/nonfibonaccif.h | 41 ++++++++++ .../base/special/nonfibonaccif/src/Makefile | 70 ++++++++++++++++ .../base/special/nonfibonaccif/src/addon.c | 23 ++++++ .../base/special/nonfibonaccif/src/main.c | 82 +++++++++++++++++++ 4 files changed, 216 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/include/stdlib/math/base/special/nonfibonaccif.h create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/include/stdlib/math/base/special/nonfibonaccif.h b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/include/stdlib/math/base/special/nonfibonaccif.h new file mode 100644 index 000000000000..602df50da268 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/include/stdlib/math/base/special/nonfibonaccif.h @@ -0,0 +1,41 @@ +/** +* @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. +*/ + +#ifndef STDLIB_MATH_BASE_SPECIAL_NONFIBONACCIF_H +#define STDLIB_MATH_BASE_SPECIAL_NONFIBONACCIF_H + +#include + +/* +* 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 number in single-precision floating-point format. +*/ +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/src/Makefile b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/Makefile new file mode 100644 index 000000000000..81bb164286c3 --- /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 \ No newline at end of file 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..a8152ac02e2a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c @@ -0,0 +1,82 @@ +/** +* @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 + +#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" + +#define SQRT5 2.23606797749979 +#define LN_PHI 0.48121182506 + +/** +* Computes the nth non-Fibonacci number in single-precision floating-point format. +* +* @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.14 ); +* // returns NaN +* +* @example +* float y = stdlib_base_nonfibonaccif( -1 ); +* // returns NaN +*/ +float stdlib_base_nonfibonaccif( const int32_t n ) { + float a; + float b; + int32_t mut_n = n; + + if ( + stdlib_base_is_nanf( n ) || + !stdlib_base_is_integerf( n ) || + n < 1.0f || + n == STDLIB_CONSTANT_FLOAT32_PINF + ) { + return STDLIB_CONSTANT_FLOAT32_NAN; + } + + mut_n += 1; + a = stdlib_base_lnf( mut_n * SQRT5 ) / LN_PHI; + b = stdlib_base_lnf( (SQRT5 * ( mut_n + a ) ) - 5.0f + ( 3.0f / mut_n ) ) / LN_PHI; + + return stdlib_base_floorf( mut_n + b - 2.0f ); +} From 5422b20be53c71d874b3b6a7b3d7b2c1f4b4eeb7 Mon Sep 17 00:00:00 2001 From: aayush0325 Date: Tue, 10 Dec 2024 11:43:22 +0530 Subject: [PATCH 03/17] feat: c files added --- .../base/special/nonfibonaccif/lib/index.js | 46 +++++++++ .../base/special/nonfibonaccif/lib/main.js | 94 +++++++++++++++++++ .../base/special/nonfibonaccif/lib/native.js | 74 +++++++++++++++ 3 files changed, 214 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/native.js 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..0e8130279ab6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/index.js @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Compute the nth non-Fibonacci number in single-precision floating-point format. +* +* @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..87df8e38c5d7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/main.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var isIntegerf = require( '@stdlib/math/base/assert/is-integerf' ); +var 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 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..b4bd5a0055d7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/native.js @@ -0,0 +1,74 @@ +/** +* @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 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 ) { + if ( isIntegerf( n ) === false ) { + return NaN; + } + return addon( n ); +} + + +// EXPORTS // + +module.exports = nonfibonaccif; From 6a50b96babf4bd7d941545c94bc702e72740c297 Mon Sep 17 00:00:00 2001 From: aayush0325 Date: Tue, 10 Dec 2024 11:46:10 +0530 Subject: [PATCH 04/17] feat: tests added --- .../nonfibonaccif/test/fixtures/expected.json | 1 + .../base/special/nonfibonaccif/test/test.js | 83 +++++++++++++++++ .../special/nonfibonaccif/test/test.native.js | 93 +++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/fixtures/expected.json create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.native.js 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..cdd3725c2395 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js @@ -0,0 +1,83 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var 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 NaN when provided a NaN' ); + t.end(); +}); + +tape( 'if provided `+infinity`, the function returns `NaN`', function test( t ) { + var n = nonfibonaccif( PINF ); + t.strictEqual( isnanf( n ), true, 'returns NaN' ); + 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 NaN' ); + + for ( i = 0; i > -100; i-- ) { + n = nonfibonaccif( i ); + t.strictEqual( isnanf( n ), true, 'returns NaN 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 NaN' ); + 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..7a685dc47f99 --- /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/float64/pinf' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var nonfibonacci = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( nonfibonacci 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 nonfibonacci, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN`, the function returns `NaN`', opts, function test( t ) { + var n = nonfibonacci( NaN ); + t.strictEqual( isnan( n ), true, 'returns NaN when provided a NaN' ); + t.end(); +}); + +tape( 'if provided `+infinity`, the function returns `NaN`', opts, function test( t ) { + var n = nonfibonacci( PINF ); + t.strictEqual( isnan( n ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'if provided a number less than 1, the function returns `NaN`', opts, function test( t ) { + var n; + var i; + + t.strictEqual( isnan( nonfibonacci( -3.14 ) ), true, 'returns NaN' ); + + for ( i = 0; i > -100; i-- ) { + n = nonfibonacci( i ); + t.strictEqual( isnan( n ), true, 'returns NaN when provided ' + i ); + } + t.end(); +}); + +tape( 'if provided a non-integer, the function returns `NaN`', opts, function test( t ) { + var n = nonfibonacci( 3.14 ); + + t.strictEqual( isnan( n ), true, 'returns NaN' ); + 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 = nonfibonacci( i ); + t.strictEqual( v, expected[ i-1 ], 'returns the '+i+'th non-Fibonacci number' ); + } + t.end(); +}); From 068757bada41db6de67aa8e2d8850da19baf8c54 Mon Sep 17 00:00:00 2001 From: aayush0325 Date: Tue, 10 Dec 2024 11:56:51 +0530 Subject: [PATCH 05/17] docs: docs added --- .../math/base/special/nonfibonaccif/README.md | 2 +- .../docs/img/equation_nonfibonacci_number.svg | 97 +++++++++++++++++++ .../base/special/nonfibonaccif/docs/repl.txt | 33 +++++++ .../nonfibonaccif/docs/types/index.d.ts | 60 ++++++++++++ .../special/nonfibonaccif/docs/types/test.ts | 44 +++++++++ 5 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/img/equation_nonfibonacci_number.svg create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md index 8ca2a7316a8a..7c5a3a391a93 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md @@ -35,7 +35,7 @@ f(n) = \left \lfloor{ n + 1 + \log_\varphi \biggl( \sqrt{5}( n + 1 + \log_\varph ``` 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..62e592597b81 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/repl.txt @@ -0,0 +1,33 @@ + +{{alias}}( n ) + Computes the nth non-Fibonacci number in + 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: 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..02ba4dcd5d61 --- /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) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Computes the nth non-Fibonacci number in single-precision floating-point format. +* +* ## 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..85b4966c7d5e --- /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) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import 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 +} From 8479d8a10915eac6481dea908b6a4e3360466d24 Mon Sep 17 00:00:00 2001 From: aayush0325 Date: Tue, 10 Dec 2024 11:59:38 +0530 Subject: [PATCH 06/17] feat: benchmarks added --- .../nonfibonaccif/benchmark/benchmark.js | 52 ++++++ .../benchmark/benchmark.native.js | 61 +++++++ .../nonfibonaccif/benchmark/c/native/Makefile | 146 +++++++++++++++++ .../benchmark/c/native/benchmark.c | 132 +++++++++++++++ .../nonfibonaccif/benchmark/julia/REQUIRE | 2 + .../benchmark/julia/benchmark.jl | 152 ++++++++++++++++++ 6 files changed, 545 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/julia/REQUIRE create mode 100755 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/julia/benchmark.jl 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..c10457603c06 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var floorf = require( '@stdlib/math/base/special/floorf' ); +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; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( (randu()*100.0) + 1.0 ); + y = nonfibonaccif( 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/nonfibonaccif/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.native.js new file mode 100644 index 000000000000..7efc64f1e78c --- /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) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var floorf = require( '@stdlib/math/base/special/floorf' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var randu = require( '@stdlib/random/base/randu' ); +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; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = floorf( (randu()*100.0) + 1.0 ); + y = nonfibonaccif( 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/nonfibonaccif/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/c/native/Makefile new file mode 100644 index 000000000000..0ebf4545e1a9 --- /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 \ No newline at end of file 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..2c618fedb17e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/c/native/benchmark.c @@ -0,0 +1,132 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "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 double 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; + double t; + float y; + int x; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + x = (int)floorf( ( 100.0f * rand_float() ) + 1.0f ); + y = stdlib_base_nonfibonaccif( 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/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..ac3b0eb9e8d9 --- /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) 2018 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import BenchmarkTools +using Printf + +# Benchmark variables: +name = "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(); From f27a204efbf75ce6e5e707f7dc76b6d263e054b5 Mon Sep 17 00:00:00 2001 From: aayush0325 Date: Tue, 10 Dec 2024 12:00:56 +0530 Subject: [PATCH 07/17] feat: examples added --- .../special/nonfibonaccif/examples/c/Makefile | 146 ++++++++++++++++++ .../nonfibonaccif/examples/c/example.c | 28 ++++ .../special/nonfibonaccif/examples/index.js | 29 ++++ 3 files changed, 203 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/index.js 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..02a7a91ace48 --- /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++ ) { + double result = stdlib_base_nonfibonaccif( i ); + printf( "x: %i => result: %f", i , result ); + } +} 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..f5d59a52a3fe --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/index.js @@ -0,0 +1,29 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var nonfibonaccif = require( './../lib' ); + +var v; +var i; + +for ( i = 1; i < 100; i++ ) { + v = nonfibonaccif( i ); + console.log( 'nonfibonaccif(%d) = %d', i, v ); +} From 01f41d2a3ffd98f79462658800718a4e7fc377ec Mon Sep 17 00:00:00 2001 From: aayush0325 Date: Tue, 10 Dec 2024 12:03:42 +0530 Subject: [PATCH 08/17] feat: updated benchmarks with precomputation --- .../base/special/nonfibonaccif/benchmark/benchmark.js | 8 ++++---- .../special/nonfibonaccif/benchmark/benchmark.native.js | 8 ++++---- .../special/nonfibonaccif/benchmark/c/native/benchmark.c | 9 ++++++--- 3 files changed, 14 insertions(+), 11 deletions(-) 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 index c10457603c06..fb3b26027400 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.js @@ -21,8 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); -var floorf = require( '@stdlib/math/base/special/floorf' ); +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' ); @@ -35,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = randu( 100, 1, 100 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = floorf( (randu()*100.0) + 1.0 ); - y = nonfibonaccif( x ); + y = nonfibonaccif( x[ i % 100 ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } 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 index 7efc64f1e78c..5e6313a6fde6 100644 --- 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 @@ -21,9 +21,8 @@ // MODULES // var resolve = require( 'path' ).resolve; -var floorf = require( '@stdlib/math/base/special/floorf' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var randu = require( '@stdlib/random/base/randu' ); +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; @@ -44,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; + x = randu( 100, 1, 100 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = floorf( (randu()*100.0) + 1.0 ); - y = nonfibonaccif( x ); + y = nonfibonaccif( x[ i % 100 ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } 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 index 2c618fedb17e..6df63d49547c 100644 --- 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 @@ -92,13 +92,16 @@ static double benchmark( void ) { double elapsed; double t; float y; - int x; + int x[ 100 ]; 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++ ) { - x = (int)floorf( ( 100.0f * rand_float() ) + 1.0f ); - y = stdlib_base_nonfibonaccif( x ); + y = stdlib_base_nonfibonaccif( x[ i % 100 ] ); if ( y < 0 ) { printf( "should return a nonnegative integer\n" ); break; From 7cc58addd016d43e4b7b3c376f003e0a8c0c210f Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Tue, 10 Dec 2024 06:37:15 +0000 Subject: [PATCH 09/17] chore: update copyright years --- .../math/base/special/nonfibonaccif/benchmark/benchmark.js | 2 +- .../base/special/nonfibonaccif/benchmark/benchmark.native.js | 2 +- .../base/special/nonfibonaccif/benchmark/c/native/benchmark.c | 2 +- .../base/special/nonfibonaccif/benchmark/julia/benchmark.jl | 2 +- .../math/base/special/nonfibonaccif/docs/types/index.d.ts | 2 +- .../@stdlib/math/base/special/nonfibonaccif/docs/types/test.ts | 2 +- .../@stdlib/math/base/special/nonfibonaccif/examples/index.js | 2 +- .../@stdlib/math/base/special/nonfibonaccif/lib/index.js | 2 +- .../@stdlib/math/base/special/nonfibonaccif/lib/main.js | 2 +- .../@stdlib/math/base/special/nonfibonaccif/test/test.js | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) 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 index fb3b26027400..4ad7a4c031a0 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. 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 index 5e6313a6fde6..d73228d5fd3c 100644 --- 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 @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. 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 index 6df63d49547c..dc0011bae4d4 100644 --- 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 @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. 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 index ac3b0eb9e8d9..28e0bf53be8c 100755 --- 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 @@ -2,7 +2,7 @@ # # @license Apache-2.0 # -# Copyright (c) 2018 The Stdlib Authors. +# 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. 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 index 02ba4dcd5d61..948330a905a0 100644 --- 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 @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. 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 index 85b4966c7d5e..45c2153b3d67 100644 --- 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 @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. 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 index f5d59a52a3fe..dd111cb7f780 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. 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 index 0e8130279ab6..5c8d0a509bfb 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. 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 index 87df8e38c5d7..06eec71d0109 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. 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 index cdd3725c2395..35d4783fe380 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. From 6331f125c3fe0550123590f5820b6efad0ad0536 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Wed, 25 Dec 2024 00:53:43 +0530 Subject: [PATCH 10/17] Apply suggestions from code review Signed-off-by: Gunj Joshi --- .../@stdlib/math/base/special/nonfibonaccif/README.md | 2 +- .../base/special/nonfibonaccif/benchmark/c/native/Makefile | 2 +- .../base/special/nonfibonaccif/benchmark/c/native/benchmark.c | 4 ++-- .../@stdlib/math/base/special/nonfibonaccif/docs/repl.txt | 4 ++-- .../math/base/special/nonfibonaccif/examples/c/example.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md index 7c5a3a391a93..32fe42712935 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md @@ -195,7 +195,7 @@ int main( void ) { int i; for ( i = 1; i < 12; i++ ) { float result = stdlib_base_nonfibonaccif( i ); - printf( "x: %i => result: %lf", i , result ); + printf( "x: %i => result: %f", i , result ); } } ``` 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 index 0ebf4545e1a9..f69e9da2b4d3 100644 --- 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 @@ -143,4 +143,4 @@ run: $(c_targets) clean: $(QUIET) -rm -f *.o *.out -.PHONY: clean \ No newline at end of file +.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 index dc0011bae4d4..91a9621eca07 100644 --- 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 @@ -79,7 +79,7 @@ static double tic( void ) { * * @return random number */ -static double rand_float( void ) { +static float rand_float( void ) { int r = rand(); return (float)r / ( (float)RAND_MAX + 1.0f ); } @@ -90,9 +90,9 @@ static double rand_float( void ) { */ static double benchmark( void ) { double elapsed; + int x[ 100 ]; double t; float y; - int x[ 100 ]; int i; for ( i = 0; i < 100; i++ ) { 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 index 62e592597b81..66149c3051d4 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( n ) - Computes the nth non-Fibonacci number in - single-precision floating-point format. + Computes the nth non-Fibonacci number in single-precision floating-point + format. If not provided a nonnegative integer value, the function returns `NaN`. 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 index 02a7a91ace48..ce8030a370dd 100644 --- 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 @@ -22,7 +22,7 @@ int main( void ) { int i; for ( i = 1; i < 12; i++ ) { - double result = stdlib_base_nonfibonaccif( i ); + float result = stdlib_base_nonfibonaccif( i ); printf( "x: %i => result: %f", i , result ); } } From de7abd0c7813550b3f3f77b3feb59748c92d15b7 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Wed, 25 Dec 2024 01:11:36 +0530 Subject: [PATCH 11/17] Apply suggestions from code review Signed-off-by: Gunj Joshi --- .../@stdlib/math/base/special/nonfibonaccif/lib/main.js | 2 +- .../@stdlib/math/base/special/nonfibonaccif/lib/native.js | 2 +- .../@stdlib/math/base/special/nonfibonaccif/src/Makefile | 2 +- .../@stdlib/math/base/special/nonfibonaccif/src/main.c | 7 +++---- 4 files changed, 6 insertions(+), 7 deletions(-) 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 index 06eec71d0109..6a630072b29c 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/main.js @@ -37,7 +37,7 @@ var LN_PHI = lnf( PHI ); // MAIN // /** -* Computes the nth non-Fibonacci number. +* Computes the nth non-Fibonacci number in single-precision floating-point format. * * ## References * 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 index b4bd5a0055d7..f50d4820aea8 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/native.js @@ -27,7 +27,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Computes the nth non-Fibonacci number. +* Computes the nth non-Fibonacci number in single-precision floating-point format. * * ## References * diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/Makefile b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/Makefile index 81bb164286c3..bcf18aa46655 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/Makefile @@ -67,4 +67,4 @@ clean-addon: #/ clean: clean-addon -.PHONY: clean \ No newline at end of file +.PHONY: clean 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 index a8152ac02e2a..984786822803 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c @@ -16,8 +16,6 @@ * limitations under the License. */ -#include - #include "stdlib/math/base/special/nonfibonaccif.h" #include "stdlib/constants/float32/nan.h" #include "stdlib/constants/float32/phi.h" @@ -26,6 +24,7 @@ #include "stdlib/math/base/assert/is_nanf.h" #include "stdlib/math/base/special/floorf.h" #include "stdlib/math/base/special/lnf.h" +#include #define SQRT5 2.23606797749979 #define LN_PHI 0.48121182506 @@ -53,7 +52,7 @@ * // returns NaN * * @example -* float y = stdlib_base_nonfibonaccif( 3.14 ); +* float y = stdlib_base_nonfibonaccif( 3.14f ); * // returns NaN * * @example @@ -76,7 +75,7 @@ float stdlib_base_nonfibonaccif( const int32_t n ) { mut_n += 1; a = stdlib_base_lnf( mut_n * SQRT5 ) / LN_PHI; - b = stdlib_base_lnf( (SQRT5 * ( mut_n + a ) ) - 5.0f + ( 3.0f / mut_n ) ) / LN_PHI; + b = stdlib_base_lnf( ( SQRT5 * ( mut_n + a ) ) - 5.0f + ( 3.0f / mut_n ) ) / LN_PHI; return stdlib_base_floorf( mut_n + b - 2.0f ); } From 094e87afac48e29ce51879b2f5bf20029d0739ff Mon Sep 17 00:00:00 2001 From: aayush0325 Date: Tue, 24 Dec 2024 20:00:29 +0000 Subject: [PATCH 12/17] chore: stuff from code review --- .../@stdlib/math/base/special/nonfibonaccif/src/main.c | 6 +++--- .../math/base/special/nonfibonaccif/test/test.js | 10 +++++----- .../base/special/nonfibonaccif/test/test.native.js | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) 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 index 984786822803..99f7afa8ee14 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c @@ -26,14 +26,14 @@ #include "stdlib/math/base/special/lnf.h" #include -#define SQRT5 2.23606797749979 -#define LN_PHI 0.48121182506 +const float SQRT5 = 2.23606797749979; +const float LN_PHI = 0.48121182506; /** * Computes the nth non-Fibonacci number in single-precision floating-point format. * * @param x input value -* @return output value +* @return output value * * @example * float y = stdlib_base_nonfibonaccif( 2 ); 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 index 35d4783fe380..ef712b272d1f 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js @@ -42,13 +42,13 @@ tape( 'main export is a function', function test( t ) { tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { var n = nonfibonaccif( NaN ); - t.strictEqual( isnanf( n ), true, 'returns NaN when provided a NaN' ); + t.strictEqual( isnanf( n ), true, 'returns expected value when provided a NaN' ); t.end(); }); tape( 'if provided `+infinity`, the function returns `NaN`', function test( t ) { var n = nonfibonaccif( PINF ); - t.strictEqual( isnanf( n ), true, 'returns NaN' ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); t.end(); }); @@ -56,18 +56,18 @@ tape( 'if provided a number less than 1, the function returns `NaN`', function t var n; var i; - t.strictEqual( isnanf( nonfibonaccif( -3.14 ) ), true, 'returns NaN' ); + 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 NaN when provided ' + 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 NaN' ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); 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 index 7a685dc47f99..62af009386d0 100644 --- 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 @@ -51,13 +51,13 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'if provided `NaN`, the function returns `NaN`', opts, function test( t ) { var n = nonfibonacci( NaN ); - t.strictEqual( isnan( n ), true, 'returns NaN when provided a NaN' ); + t.strictEqual( isnan( n ), true, 'returns expected value when provided a NaN' ); t.end(); }); tape( 'if provided `+infinity`, the function returns `NaN`', opts, function test( t ) { var n = nonfibonacci( PINF ); - t.strictEqual( isnan( n ), true, 'returns NaN' ); + t.strictEqual( isnan( n ), true, 'returns expected value' ); t.end(); }); @@ -65,11 +65,11 @@ tape( 'if provided a number less than 1, the function returns `NaN`', opts, func var n; var i; - t.strictEqual( isnan( nonfibonacci( -3.14 ) ), true, 'returns NaN' ); + t.strictEqual( isnan( nonfibonacci( -3.14 ) ), true, 'returns expected value' ); for ( i = 0; i > -100; i-- ) { n = nonfibonacci( i ); - t.strictEqual( isnan( n ), true, 'returns NaN when provided ' + i ); + t.strictEqual( isnan( n ), true, 'returns expected value when provided ' + i ); } t.end(); }); @@ -77,7 +77,7 @@ tape( 'if provided a number less than 1, the function returns `NaN`', opts, func tape( 'if provided a non-integer, the function returns `NaN`', opts, function test( t ) { var n = nonfibonacci( 3.14 ); - t.strictEqual( isnan( n ), true, 'returns NaN' ); + t.strictEqual( isnan( n ), true, 'returns expected value' ); t.end(); }); From 49e47b9fc59120eb03ce7262488685e465eadfe5 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Wed, 25 Dec 2024 09:34:31 +0530 Subject: [PATCH 13/17] Update lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.native.js Signed-off-by: Gunj Joshi --- .../@stdlib/math/base/special/nonfibonaccif/test/test.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 62af009386d0..c9b4b2b2ad7a 100644 --- 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 @@ -87,7 +87,7 @@ tape( 'the function returns the nth non-Fibonacci number', opts, function test( for ( i = 1; i < expected.length; i++ ) { v = nonfibonacci( i ); - t.strictEqual( v, expected[ i-1 ], 'returns the '+i+'th non-Fibonacci number' ); + t.strictEqual( v, expected[ i - 1 ], 'returns the '+i+'th non-Fibonacci number' ); } t.end(); }); From 7d9824cfefa5a0457d4f8f35fdb7c75765571cce Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Wed, 25 Dec 2024 09:34:43 +0530 Subject: [PATCH 14/17] Update lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js Signed-off-by: Gunj Joshi --- .../@stdlib/math/base/special/nonfibonaccif/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index ef712b272d1f..38c5e76ea685 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js @@ -77,7 +77,7 @@ tape( 'the function returns the nth non-Fibonacci number', function test( t ) { for ( i = 1; i < expected.length; i++ ) { v = nonfibonaccif( i ); - t.strictEqual( v, expected[ i-1 ], 'returns the '+i+'th non-Fibonacci number' ); + t.strictEqual( v, expected[ i - 1 ], 'returns the '+i+'th non-Fibonacci number' ); } t.end(); }); From 2faef40ed4ca715afe9ba51c9c30046968bd306d Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Wed, 25 Dec 2024 09:34:55 +0530 Subject: [PATCH 15/17] Update lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c Signed-off-by: Gunj Joshi --- .../@stdlib/math/base/special/nonfibonaccif/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 99f7afa8ee14..346c5f7477eb 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c @@ -26,7 +26,7 @@ #include "stdlib/math/base/special/lnf.h" #include -const float SQRT5 = 2.23606797749979; +static const float SQRT5 = 2.23606797749979f; const float LN_PHI = 0.48121182506; /** From f75b8279b85aebaf37625a1dfbc64b51a551ca1e Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Wed, 25 Dec 2024 09:35:07 +0530 Subject: [PATCH 16/17] Update lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c Signed-off-by: Gunj Joshi --- .../@stdlib/math/base/special/nonfibonaccif/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 346c5f7477eb..062cb05ec2a8 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c @@ -27,7 +27,7 @@ #include static const float SQRT5 = 2.23606797749979f; -const float LN_PHI = 0.48121182506; +static const float LN_PHI = 0.48121182506f; /** * Computes the nth non-Fibonacci number in single-precision floating-point format. From 1b4166609ba614239be25d43b372cb5e3b5fd783 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 25 Dec 2024 01:55:31 -0800 Subject: [PATCH 17/17] chore: clean-up --- .../math/base/special/nonfibonaccif/README.md | 17 +++++------ .../base/special/nonfibonaccif/docs/repl.txt | 3 +- .../nonfibonaccif/docs/types/index.d.ts | 2 +- .../nonfibonaccif/examples/c/example.c | 4 +-- .../special/nonfibonaccif/examples/index.js | 5 +--- .../stdlib/math/base/special/nonfibonaccif.h | 2 +- .../base/special/nonfibonaccif/lib/index.js | 2 +- .../base/special/nonfibonaccif/lib/main.js | 2 +- .../base/special/nonfibonaccif/lib/native.js | 8 ++--- .../base/special/nonfibonaccif/package.json | 2 +- .../base/special/nonfibonaccif/src/main.c | 14 ++++----- .../base/special/nonfibonaccif/test/test.js | 2 +- .../special/nonfibonaccif/test/test.native.js | 30 +++++++++---------- 13 files changed, 40 insertions(+), 53 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md index 32fe42712935..622ce9e849c5 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/README.md @@ -20,7 +20,7 @@ limitations under the License. # Non-Fibonacci -> Compute the nth [non-Fibonacci number][fibonacci-number] in single-precision floating-point format. +> Compute the nth [non-Fibonacci][fibonacci-number] single-precision floating-point number. @@ -59,7 +59,7 @@ var nonfibonaccif = require( '@stdlib/math/base/special/nonfibonaccif' ); #### nonfibonaccif( n ) -Computes the nth [non-Fibonacci number][fibonacci-number] in single-precision floating-point format. +Computes the nth [non-Fibonacci][fibonacci-number] single-precision floating-point number. ```javascript var v = nonfibonaccif( 1 ); @@ -110,12 +110,9 @@ var v = nonfibonaccif( NaN ); ```javascript var nonfibonaccif = require( '@stdlib/math/base/special/nonfibonaccif' ); -var v; var i; - for ( i = 1; i < 100; i++ ) { - v = nonfibonaccif( i ); - console.log( 'nonfibonaccif(%d) = %d', i, v ); + console.log( 'nonfibonaccif(%d) = %d', i, nonfibonaccif( i ) ); } ``` @@ -151,7 +148,7 @@ for ( i = 1; i < 100; i++ ) { #### stdlib_base_nonfibonaccif( x ) -Computes the nth non-Fibonacci number in single-precision floating-point format. +Computes the nth non-Fibonacci single-precision floating-point number. ```c float out = stdlib_base_nonfibonaccif( 1 ); @@ -190,12 +187,12 @@ float stdlib_base_nonfibonaccif( const int32_t x ); ```c #include "stdlib/math/base/special/nonfibonaccif.h" #include -#include + int main( void ) { int i; + for ( i = 1; i < 12; i++ ) { - float result = stdlib_base_nonfibonaccif( i ); - printf( "x: %i => result: %f", i , result ); + printf( "x: %i => result: %f", i , stdlib_base_nonfibonaccif( i ) ); } } ``` 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 index 66149c3051d4..042ce4ae82d0 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/docs/repl.txt @@ -1,7 +1,6 @@ {{alias}}( n ) - Computes the nth non-Fibonacci number in single-precision floating-point - format. + Computes the nth non-Fibonacci single-precision floating-point number. If not provided a nonnegative integer value, the function returns `NaN`. 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 index 948330a905a0..87c8c6263042 100644 --- 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 @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /** -* Computes the nth non-Fibonacci number in single-precision floating-point format. +* Computes the nth non-Fibonacci single-precision floating-point number. * * ## Notes * 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 index ce8030a370dd..8a3e063460a4 100644 --- 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 @@ -21,8 +21,8 @@ int main( void ) { int i; + for ( i = 1; i < 12; i++ ) { - float result = stdlib_base_nonfibonaccif( i ); - printf( "x: %i => result: %f", i , result ); + 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 index dd111cb7f780..48c1959a4c0e 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/examples/index.js @@ -20,10 +20,7 @@ var nonfibonaccif = require( './../lib' ); -var v; var i; - for ( i = 1; i < 100; i++ ) { - v = nonfibonaccif( i ); - console.log( 'nonfibonaccif(%d) = %d', i, v ); + console.log( 'nonfibonaccif(%d) = %d', i, nonfibonaccif( i ) ); } diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/include/stdlib/math/base/special/nonfibonaccif.h b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/include/stdlib/math/base/special/nonfibonaccif.h index 602df50da268..7f37e6e56284 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/include/stdlib/math/base/special/nonfibonaccif.h +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/include/stdlib/math/base/special/nonfibonaccif.h @@ -30,7 +30,7 @@ extern "C" #endif /** -* Computes the nth non-Fibonacci number in single-precision floating-point format. +* Computes the nth non-Fibonacci single-precision floating-point number. */ float stdlib_base_nonfibonaccif( const int32_t n ); 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 index 5c8d0a509bfb..7f28fb621dac 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Compute the nth non-Fibonacci number in single-precision floating-point format. +* Compute the nth non-Fibonacci single-precision floating-point number. * * @module @stdlib/math/base/special/nonfibonaccif * 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 index 6a630072b29c..67a4ef97eb9a 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/main.js @@ -37,7 +37,7 @@ var LN_PHI = lnf( PHI ); // MAIN // /** -* Computes the nth non-Fibonacci number in single-precision floating-point format. +* Computes the nth non-Fibonacci single-precision floating-point number. * * ## References * 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 index f50d4820aea8..2751a27b1644 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/lib/native.js @@ -27,13 +27,9 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Computes the nth non-Fibonacci number in single-precision floating-point format. -* -* ## 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. . +* 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 * diff --git a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/package.json b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/package.json index e6b538f04d56..430ea21280dc 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/package.json +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/math/base/special/nonfibonaccif", "version": "0.0.0", - "description": "Compute the nth non-Fibonacci number in single-precision floating-point format.", + "description": "Compute the nth non-Fibonacci single-precision floating-point number.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", 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 index 062cb05ec2a8..692f54676008 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/src/main.c @@ -30,7 +30,7 @@ static const float SQRT5 = 2.23606797749979f; static const float LN_PHI = 0.48121182506f; /** -* Computes the nth non-Fibonacci number in single-precision floating-point format. +* Computes the nth non-Fibonacci single-precision floating-point number. * * @param x input value * @return output value @@ -60,9 +60,9 @@ static const float LN_PHI = 0.48121182506f; * // returns NaN */ float stdlib_base_nonfibonaccif( const int32_t n ) { + int32_t m; float a; float b; - int32_t mut_n = n; if ( stdlib_base_is_nanf( n ) || @@ -72,10 +72,8 @@ float stdlib_base_nonfibonaccif( const int32_t n ) { ) { return STDLIB_CONSTANT_FLOAT32_NAN; } - - mut_n += 1; - a = stdlib_base_lnf( mut_n * SQRT5 ) / LN_PHI; - b = stdlib_base_lnf( ( SQRT5 * ( mut_n + a ) ) - 5.0f + ( 3.0f / mut_n ) ) / LN_PHI; - - return stdlib_base_floorf( mut_n + b - 2.0f ); + 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/test.js b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js index 38c5e76ea685..2bd70fdd20cb 100644 --- a/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/nonfibonaccif/test/test.js @@ -42,7 +42,7 @@ tape( 'main export is a function', function test( t ) { tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { var n = nonfibonaccif( NaN ); - t.strictEqual( isnanf( n ), true, 'returns expected value when provided a NaN' ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); 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 index c9b4b2b2ad7a..f8f9eb556146 100644 --- 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 @@ -22,16 +22,16 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var PINF = require( '@stdlib/constants/float64/pinf' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +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 nonfibonacci = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var nonfibonaccif = tryRequire( resolve( __dirname, './../lib/native.js' ) ); var opts = { - 'skip': ( nonfibonacci instanceof Error ) + 'skip': ( nonfibonaccif instanceof Error ) }; @@ -45,19 +45,19 @@ var expected = require( './fixtures/expected.json' ); tape( 'main export is a function', opts, function test( t ) { t.ok( true, __filename ); - t.strictEqual( typeof nonfibonacci, 'function', 'main export is a function' ); + 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 = nonfibonacci( NaN ); - t.strictEqual( isnan( n ), true, 'returns expected value when provided a NaN' ); + 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 = nonfibonacci( PINF ); - t.strictEqual( isnan( n ), true, 'returns expected value' ); + var n = nonfibonaccif( PINF ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); t.end(); }); @@ -65,19 +65,19 @@ tape( 'if provided a number less than 1, the function returns `NaN`', opts, func var n; var i; - t.strictEqual( isnan( nonfibonacci( -3.14 ) ), true, 'returns expected value' ); + t.strictEqual( isnanf( nonfibonaccif( -3.14 ) ), true, 'returns expected value' ); for ( i = 0; i > -100; i-- ) { - n = nonfibonacci( i ); - t.strictEqual( isnan( n ), true, 'returns expected value when provided ' + 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 = nonfibonacci( 3.14 ); + var n = nonfibonaccif( 3.14 ); - t.strictEqual( isnan( n ), true, 'returns expected value' ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); t.end(); }); @@ -86,7 +86,7 @@ tape( 'the function returns the nth non-Fibonacci number', opts, function test( var i; for ( i = 1; i < expected.length; i++ ) { - v = nonfibonacci( i ); + v = nonfibonaccif( i ); t.strictEqual( v, expected[ i - 1 ], 'returns the '+i+'th non-Fibonacci number' ); } t.end();