From 45e5e6d3ce3c0a228c79ce8f8f92bf2cc0eef6e2 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 22 Mar 2025 22:00:38 -0700 Subject: [PATCH 01/10] feat: add complete implementation --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../base/special/fibonacci-indexf/README.md | 233 ++++++++++++++++++ .../fibonacci-indexf/benchmark/benchmark.js | 60 +++++ .../benchmark/benchmark.native.js | 69 ++++++ .../fibonacci-indexf/benchmark/c/Makefile | 127 ++++++++++ .../fibonacci-indexf/benchmark/c/benchmark.c | 147 +++++++++++ .../benchmark/c/native/Makefile | 146 +++++++++++ .../benchmark/c/native/benchmark.c | 136 ++++++++++ .../fibonacci-indexf/benchmark/julia/REQUIRE | 2 + .../benchmark/julia/benchmark.jl | 148 +++++++++++ .../base/special/fibonacci-indexf/binding.gyp | 170 +++++++++++++ .../special/fibonacci-indexf/docs/repl.txt | 35 +++ .../fibonacci-indexf/docs/types/index.d.ts | 73 ++++++ .../fibonacci-indexf/docs/types/test.ts | 44 ++++ .../fibonacci-indexf/examples/c/Makefile | 146 +++++++++++ .../fibonacci-indexf/examples/c/example.c | 31 +++ .../fibonacci-indexf/examples/index.js | 37 +++ .../special/fibonacci-indexf/include.gypi | 53 ++++ .../math/base/special/fibonacci_indexf.h | 38 +++ .../special/fibonacci-indexf/lib/index.js | 55 +++++ .../base/special/fibonacci-indexf/lib/main.js | 104 ++++++++ .../special/fibonacci-indexf/lib/native.js | 78 ++++++ .../special/fibonacci-indexf/manifest.json | 87 +++++++ .../special/fibonacci-indexf/package.json | 70 ++++++ .../special/fibonacci-indexf/src/Makefile | 70 ++++++ .../base/special/fibonacci-indexf/src/addon.c | 23 ++ .../base/special/fibonacci-indexf/src/main.c | 51 ++++ .../special/fibonacci-indexf/test/test.js | 79 ++++++ .../fibonacci-indexf/test/test.native.js | 88 +++++++ 28 files changed, 2400 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/julia/REQUIRE create mode 100755 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/julia/benchmark.jl create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/include/stdlib/math/base/special/fibonacci_indexf.h create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/README.md b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/README.md new file mode 100644 index 000000000000..ecf7060b8e26 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/README.md @@ -0,0 +1,233 @@ + + +# Fibonacci Number Index + +> Compute the [Fibonacci number][fibonacci-number] index of a single-precision floating-point number. + +
+ +The [Fibonacci number][fibonacci-number] index is given by + + + +```math +n = \left \lfloor{\log_\varphi \biggl(F \cdot \sqrt{5} + \tfrac{1}{2}\biggr)}\right \rfloor +``` + + + +where `φ` is the [golden ratio][golden-ratio] and `F > 1`. + +
+ + + +
+ +## Usage + +```javascript +var fibonacciIndexf = require( '@stdlib/math/base/special/fibonacci-indexf' ); +``` + +#### fibonacciIndexf( F ) + +Computes the [Fibonacci number][fibonacci-number] index of a single-precision floating-point number. + +```javascript +var n = fibonacciIndexf( 2 ); +// returns 3 + +n = fibonacciIndexf( 3 ); +// returns 4 + +n = fibonacciIndexf( 5 ); +// returns 5 +``` + +If provided either a non-integer or `F_n <= 1`, the function returns `NaN`. + +```javascript +var n = fibonacciIndexf( -1 ); +// returns NaN + +n = fibonacciIndexf( 3.14 ); +// returns NaN +``` + +If provided `NaN`, the function returns `NaN`. + +```javascript +var n = fibonacciIndexf( NaN ); +// returns NaN +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var fibonacciIndexf = require( '@stdlib/math/base/special/fibonacci-indexf' ); + +var F1; +var F2; +var FN; +var n; +var i; + +F1 = 1; +F2 = 1; +for ( i = 3; i < 37; i++ ) { + FN = F1 + F2; + F1 = F2; + F2 = FN; + n = fibonacciIndexf( FN ); + console.log( 'n(%d) = %d', FN, n ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/fibonacci_indexf.h" +``` + +#### stdlib_base_fibonacci_indexf( F ) + +Computes the [Fibonacci number][fibonacci-number] index of a single-precision floating-point number. + +```c +float out = stdlib_base_fibonacci_indexf( 2.0f ); +// returns 3.0f + +out = stdlib_base_fibonacci_indexf( 3.0f ); +// returns 4.0f +``` + +The function accepts the following arguments: + +- **F**: `[in] float` input value. + +```c +float stdlib_base_fibonacci_indexf( const float F ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/fibonacci_indexf.h" +#include + +int main( void ) { + const float x[] = { 2.0f, 3.0f, 5.0f, 8.0f }; + + float y; + int i; + for ( i = 0; i < 4; i++ ) { + y = stdlib_base_fibonacci_indexf( x[ i ] ); + printf( "fibonacci_indexf(%f) = %f\n", x[ i ], y ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/benchmark.js new file mode 100644 index 000000000000..5d626f1cdca8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/benchmark.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var zeros = require( '@stdlib/array/base/zeros' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var fibonacci = require( '@stdlib/math/base/special/fibonacci' ); +var pkg = require( './../package.json' ).name; +var fibonacciIndexf = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var FN; + var x; + var y; + var i; + + FN = zeros( 37 ); + for ( i = 3; i < 37; i++ ) { + FN[ i ] = fibonacci( i ); + } + + x = discreteUniform( 100, 3, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = fibonacciIndexf( FN[ x[ i%x.length ] ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/benchmark.native.js new file mode 100644 index 000000000000..63551519051e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/benchmark.native.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var zeros = require( '@stdlib/array/base/zeros' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var fibonacci = require( '@stdlib/math/base/special/fibonacci' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var fibonacciIndexf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( fibonacciIndexf instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var FN; + var x; + var y; + var i; + + FN = zeros( 37 ); + for ( i = 3; i < 37; i++ ) { + FN[ i ] = fibonacci( i ); + } + + x = discreteUniform( 100, 3, 36 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = fibonacciIndexf( FN[ x[ i%x.length ] ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/Makefile new file mode 100644 index 000000000000..d564e8b2d6f9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/Makefile @@ -0,0 +1,127 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles C source files. +# +# @param {string} [C_COMPILER] - C compiler +# @param {string} [CFLAGS] - C compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler +# @param {string} CFLAGS - C compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $< -lm + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/benchmark.c new file mode 100644 index 000000000000..dd2cc8159e78 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/benchmark.c @@ -0,0 +1,147 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include +#include +#include +#include + +#define NAME "fibonacci-indexf" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Computes the Fibonacci number index. +* +* @param F Fibonacci number +* @return function result +*/ +int fibonacci_indexf( int F ) { + float y = ((float)F * (float)sqrt( 5.0f )) + 0.5f; + return (int)floor( (float)log( y ) / (float)log( 1.618033988749895f ) ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + double t; + int x[ 100 ]; + int y; + int i; + + for ( i = 0; i < 100; i++ ) { + x[ i ] = (int)floor( (100000.0f*rand_float()) + 2.0f ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + // note: using actual Fibonacci numbers is not important + y = fibonacci_indexf( x[ i%100 ] ); + if ( y < 0 ) { + printf( "should return a nonnegative integer\n" ); + break; + } + } + elapsed = tic() - t; + if ( y < 0 ) { + printf( "should return a nonnegative integer\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/native/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/native/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..dbc1f2c31fbe --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/c/native/benchmark.c @@ -0,0 +1,136 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/fibonacci_indexf.h" +#include +#include +#include +#include +#include + +#define NAME "fibonacci_indexf" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec / 1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + double y; + double t; + float x[ 100 ]; + int i; + + for ( i = 0; i < 100; i++ ) { + x[ i ] = (int)floor( ( 75.0f * rand_float() ) + 3.0f ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_fibonacci_indexf( x[ i%100 ] ); + if ( y != y ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y != y ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::native::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/julia/REQUIRE b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/julia/REQUIRE new file mode 100644 index 000000000000..98645e192e41 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/julia/REQUIRE @@ -0,0 +1,2 @@ +julia 1.5 +BenchmarkTools 0.5.0 diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/julia/benchmark.jl new file mode 100755 index 000000000000..e6d27a5d1a4f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/benchmark/julia/benchmark.jl @@ -0,0 +1,148 @@ +#!/usr/bin/env julia +# +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import BenchmarkTools +using Printf + +# Benchmark variables: +name = "fibonacci-indexf"; +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 Fibonacci number index: + fibonacci_indexf( F::Float32 ) = Float32(log( Float32(1.618033988749895), (F*Float32(sqrt(5.0))) + 0.5f0 )); + + # Benchmark (note: using actual Fibonacci numbers is not important): + t = BenchmarkTools.@benchmark $fibonacci_indexf( Float32(floor( (100000.0f0*rand()) + 2.0f0 )) ) samples=1e6 + + # Compute the total "elapsed" time and convert from nanoseconds to seconds: + s = sum( t.times ) / 1.0e9; + + # Determine the number of "iterations": + iter = length( t.times ); + + # Return the results: + [ iter, s ]; +end + +""" + main() + +Run benchmarks. + +# Examples + +``` julia +julia> main(); +``` +""" +function main() + print_version(); + for i in 1:repeats + @printf( "# julia::%s\n", name ); + results = benchmark(); + print_results( results[ 1 ], results[ 2 ] ); + @printf( "ok %d benchmark finished\n", i ); + end + print_summary( repeats, repeats ); +end + +main(); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/binding.gyp new file mode 100644 index 000000000000..68a1ca11d160 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/docs/repl.txt new file mode 100644 index 000000000000..4605e4ba0f64 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/docs/repl.txt @@ -0,0 +1,35 @@ + +{{alias}}( F ) + Computes the Fibonacci number index of a single-precision floating-point + number. + + If not provided a nonnegative integer value, the function returns `NaN`. + + If provided `F <= 1` or `NaN`, the function returns `NaN`. + + Parameters + ---------- + F: integer + Fibonacci number. + + Returns + ------- + n: number + Fibonacci number index. + + Examples + -------- + > var n = {{alias}}( 2 ) + 3 + > n = {{alias}}( 3 ) + 4 + > n = {{alias}}( 5 ) + 5 + > n = {{alias}}( NaN ) + NaN + > n = {{alias}}( 1 ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/docs/types/index.d.ts new file mode 100644 index 000000000000..36e9caed13d8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/docs/types/index.d.ts @@ -0,0 +1,73 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Computes the Fibonacci number index of a single-precision floating-point number. +* +* ## Notes +* +* - If not provided a nonnegative integer value, the function returns `NaN`. +* - If provided `F <= 1` or `NaN`, the function returns `NaN`. +* +* @param F - Fibonacci number +* @returns Fibonacci number index +* +* @example +* var n = fibonacciIndexf( 0 ); +* // returns NaN +* +* @example +* var n = fibonacciIndexf( 1 ); +* // returns NaN +* +* @example +* var n = fibonacciIndexf( 2 ); +* // returns 3 +* +* @example +* var n = fibonacciIndexf( 3 ); +* // returns 4 +* +* @example +* var n = fibonacciIndexf( 5 ); +* // returns 5 +* +* @example +* var n = fibonacciIndexf( 8 ); +* // returns 6 +* +* @example +* var n = fibonacciIndexf( NaN ); +* // returns NaN +* +* @example +* var n = fibonacciIndexf( 3.14 ); +* // returns NaN +* +* @example +* var n = fibonacciIndexf( -1 ); +* // returns NaN +*/ +declare function fibonacciIndexf( F: number ): number; + + +// EXPORTS // + +export = fibonacciIndexf; diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/docs/types/test.ts new file mode 100644 index 000000000000..3acc5d7913cf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/docs/types/test.ts @@ -0,0 +1,44 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import fibonacciIndexf = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + fibonacciIndexf( 7 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a number... +{ + fibonacciIndexf( true ); // $ExpectError + fibonacciIndexf( false ); // $ExpectError + fibonacciIndexf( null ); // $ExpectError + fibonacciIndexf( undefined ); // $ExpectError + fibonacciIndexf( '5' ); // $ExpectError + fibonacciIndexf( [] ); // $ExpectError + fibonacciIndexf( {} ); // $ExpectError + fibonacciIndexf( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + fibonacciIndexf(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/examples/c/example.c new file mode 100644 index 000000000000..9dc2e44b31dc --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/examples/c/example.c @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/fibonacci_indexf.h" +#include + +int main( void ) { + const float x[] = { 2.0f, 3.0f, 5.0f, 8.0f }; + + float y; + int i; + for ( i = 0; i < 4; i++ ) { + y = stdlib_base_fibonacci_indexf( x[ i ] ); + printf( "fibonacci_indexf(%f) = %f\n", x[ i ], y ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/examples/index.js new file mode 100644 index 000000000000..a2dc8c2fad45 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/examples/index.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var fibonacciIndexf = require( './../lib' ); + +var F1; +var F2; +var FN; +var n; +var i; + +F1 = 1; +F2 = 1; +for ( i = 3; i < 37; i++ ) { + FN = F1 + F2; + F1 = F2; + F2 = FN; + n = fibonacciIndexf( FN ); + console.log( 'n(%d) = %d', FN, n ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/include.gypi b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/include.gypi new file mode 100644 index 000000000000..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '=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", + "fibonaccif", + "fib", + "sequence", + "seq", + "number", + "index" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/addon.c new file mode 100644 index 000000000000..4ddf455b4d22 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/addon.c @@ -0,0 +1,23 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/fibonacci_indexf.h" +#include "stdlib/math/base/napi/unary.h" + +// cppcheck-suppress shadowFunction +STDLIB_MATH_BASE_NAPI_MODULE_F_F( stdlib_base_fibonacci_indexf ) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c new file mode 100644 index 000000000000..796e05953fb3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/fibonacci_indexf.h" +#include "stdlib/math/base/assert/is_nanf.h" +#include "stdlib/math/base/assert/is_integerf.h" +#include "stdlib/math/base/special/lnf.h" +#include "stdlib/math/base/special/roundf.h" +#include "stdlib/constants/float32/phi.h" +#include "stdlib/constants/float32/pinf.h" + +static const float SQRT_5 = 2.23606797749979f; + +/** +* Computes the Fibonacci number index of a single-precision floating-point number. +* +* ## Notes +* +* - We use `roundf` instead of `floorf` due to errors introduced by floating-point precision. +* +* @param F Fibonacci number +* @return Fibonacci number index +* +* @example +* float out = stdlib_base_fibonacci_index( 2.0f ); +* // returns 3.0f +*/ +float stdlib_base_fibonacci_indexf( const float F ) { + float x; + + if ( stdlib_base_is_nanf( F ) || stdlib_base_is_integerf( F ) == false || F <= 1.0f || F == STDLIB_CONSTANT_FLOAT32_PINF ) { + return 0.0f / 0.0f; // NaN + } + x = ( F * SQRT_5 ) + 0.5f; + return stdlib_base_roundf( stdlib_base_lnf( x ) / stdlib_base_lnf( STDLIB_CONSTANT_FLOAT32_PHI ) ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.js b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.js new file mode 100644 index 000000000000..c202a4e6111e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.js @@ -0,0 +1,79 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nan' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var fibonacci = require( '@stdlib/math/base/special/fibonacci' ); +var fibonacciIndexf = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof fibonacciIndexf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) { + var n = fibonacciIndexf( NaN ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided `+infinity`, the function returns `NaN`', function test( t ) { + var n = fibonacciIndexf( PINF ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a number less than or equal to 1, the function returns `NaN`', function test( t ) { + var n; + var i; + + t.strictEqual( isnanf( fibonacciIndexf( -3.14 ) ), true, 'returns expected value' ); + + for ( i = 1; i > -100; i-- ) { + n = fibonacciIndexf( i ); + t.strictEqual( isnanf( n ), true, 'returns expected value ' ); + } + t.end(); +}); + +tape( 'if provided a non-integer, the function returns `NaN`', function test( t ) { + var n = fibonacciIndexf( 3.14 ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the Fibonacci number index', function test( t ) { + var v; + var n; + var i; + for ( i = 3; i < 37; i++ ) { + v = fibonacci( i ); + n = fibonacciIndexf( v ); + t.strictEqual( n, i, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.native.js new file mode 100644 index 000000000000..7ce006605434 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.native.js @@ -0,0 +1,88 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var fibonacci = require( '@stdlib/math/base/special/fibonacci' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var fibonacciIndexf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( fibonacciIndexf instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof fibonacciIndexf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN`, the function returns `NaN`', opts, function test( t ) { + var n = fibonacciIndexf( 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 = fibonacciIndexf( PINF ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a number less than or equal to 1, the function returns `NaN`', opts, function test( t ) { + var n; + var i; + + t.strictEqual( isnanf( fibonacciIndexf( -3.14 ) ), true, 'returns expected value' ); + + for ( i = 1; i > -100; i-- ) { + n = fibonacciIndexf( i ); + t.strictEqual( isnanf( n ), true, 'returns expected value ' ); + } + t.end(); +}); + +tape( 'if provided a non-integer, the function returns `NaN`', opts, function test( t ) { + var n = fibonacciIndexf( 3.14 ); + t.strictEqual( isnanf( n ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the Fibonacci number index', opts, function test( t ) { + var v; + var n; + var i; + for ( i = 3; i < 37; i++ ) { + v = fibonacci( i ); + n = fibonacciIndexf( v ); + t.strictEqual( n, i, 'returns expected value' ); + } + t.end(); +}); From 8879289a46bf2416f8df082660c0ab6116e8645a Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sun, 23 Mar 2025 06:00:45 +0000 Subject: [PATCH 02/10] chore: update copyright years --- .../@stdlib/math/base/special/fibonacci-indexf/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/Makefile index bcf18aa46655..7733b6180cb4 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From d6d3733a34b70bdfe0d0d5a560994c902794a25b Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Tue, 1 Apr 2025 22:52:21 -0700 Subject: [PATCH 03/10] chore: re-enable lint rule --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/fibonacci-indexf/src/addon.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/addon.c index 4ddf455b4d22..201033c58d41 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/addon.c @@ -19,5 +19,4 @@ #include "stdlib/math/base/special/fibonacci_indexf.h" #include "stdlib/math/base/napi/unary.h" -// cppcheck-suppress shadowFunction STDLIB_MATH_BASE_NAPI_MODULE_F_F( stdlib_base_fibonacci_indexf ) From fd3829078e5ec6e6d56f409aafb6e50b4608c7a9 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 10 Apr 2025 23:35:05 -0700 Subject: [PATCH 04/10] refactor: precompute constant Signed-off-by: Athan --- .../@stdlib/math/base/special/fibonacci-indexf/lib/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/lib/main.js index 084d6e4b7503..532a0ad2c816 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/lib/main.js @@ -31,6 +31,7 @@ var PINF = require( '@stdlib/constants/float32/pinf' ); // VARIABLES // +var ONE_HALF = float64ToFloat32( 0.5 ); var SQRT_5 = float64ToFloat32( 2.23606797749979 ); var LN_PHI = lnf( PHI ); @@ -94,7 +95,7 @@ function fibonacciIndexf( F ) { return NaN; } // eslint-disable-next-line max-len - x = float64ToFloat32( float64ToFloat32( F*SQRT_5 ) + float64ToFloat32( 0.5 ) ); + x = float64ToFloat32( float64ToFloat32( F*SQRT_5 ) + ONE_HALF ); return roundf( float64ToFloat32( lnf( x ) / LN_PHI ) ); } From bda666ce622e45ef70e3aa9215393185a30621de Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 10 Apr 2025 23:36:23 -0700 Subject: [PATCH 05/10] fix: add missing include Signed-off-by: Athan --- .../@stdlib/math/base/special/fibonacci-indexf/src/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c index 796e05953fb3..5779e279b075 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c @@ -23,6 +23,7 @@ #include "stdlib/math/base/special/roundf.h" #include "stdlib/constants/float32/phi.h" #include "stdlib/constants/float32/pinf.h" +#include static const float SQRT_5 = 2.23606797749979f; From ca711fa3ba3ddad73edab733e50f22f66fb02345 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 10 Apr 2025 23:38:40 -0700 Subject: [PATCH 06/10] test: use single-precision implementation Signed-off-by: Athan --- .../@stdlib/math/base/special/fibonacci-indexf/test/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.js b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.js index c202a4e6111e..6d81c2fb4be1 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.js @@ -23,7 +23,7 @@ var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nan' ); var PINF = require( '@stdlib/constants/float32/pinf' ); -var fibonacci = require( '@stdlib/math/base/special/fibonacci' ); +var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' ); var fibonacciIndexf = require( './../lib' ); @@ -71,7 +71,7 @@ tape( 'the function returns the Fibonacci number index', function test( t ) { var n; var i; for ( i = 3; i < 37; i++ ) { - v = fibonacci( i ); + v = fibonaccif( i ); n = fibonacciIndexf( v ); t.strictEqual( n, i, 'returns expected value' ); } From d68c4d0f5086f1e743083379cd644851fe980d05 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 10 Apr 2025 23:39:00 -0700 Subject: [PATCH 07/10] test: use singe-precision implementation Signed-off-by: Athan --- .../math/base/special/fibonacci-indexf/test/test.native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.native.js index 7ce006605434..e37fd1546e34 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/test/test.native.js @@ -24,7 +24,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var PINF = require( '@stdlib/constants/float32/pinf' ); -var fibonacci = require( '@stdlib/math/base/special/fibonacci' ); +var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -80,7 +80,7 @@ tape( 'the function returns the Fibonacci number index', opts, function test( t var n; var i; for ( i = 3; i < 37; i++ ) { - v = fibonacci( i ); + v = fibonaccif( i ); n = fibonacciIndexf( v ); t.strictEqual( n, i, 'returns expected value' ); } From c884ee32b8ac4166f9c92e5a7e7a70ff1cbd8aae Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 10 Apr 2025 23:39:47 -0700 Subject: [PATCH 08/10] refactor: precompute constant Signed-off-by: Athan --- .../@stdlib/math/base/special/fibonacci-indexf/src/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c index 5779e279b075..8b733f5c3ac3 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c @@ -26,6 +26,7 @@ #include static const float SQRT_5 = 2.23606797749979f; +static const float LN_PHI = stdlib_base_lnf( STDLIB_CONSTANT_FLOAT32_PHI ); /** * Computes the Fibonacci number index of a single-precision floating-point number. @@ -48,5 +49,5 @@ float stdlib_base_fibonacci_indexf( const float F ) { return 0.0f / 0.0f; // NaN } x = ( F * SQRT_5 ) + 0.5f; - return stdlib_base_roundf( stdlib_base_lnf( x ) / stdlib_base_lnf( STDLIB_CONSTANT_FLOAT32_PHI ) ); + return stdlib_base_roundf( stdlib_base_lnf( x ) / LN_PHI ); } From cc02a778c2c0acfd133900e429fbd2aa6428cb32 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 10 Apr 2025 23:43:25 -0700 Subject: [PATCH 09/10] fix: revert pre-computation Signed-off-by: Athan --- .../@stdlib/math/base/special/fibonacci-indexf/src/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c index 8b733f5c3ac3..5779e279b075 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/src/main.c @@ -26,7 +26,6 @@ #include static const float SQRT_5 = 2.23606797749979f; -static const float LN_PHI = stdlib_base_lnf( STDLIB_CONSTANT_FLOAT32_PHI ); /** * Computes the Fibonacci number index of a single-precision floating-point number. @@ -49,5 +48,5 @@ float stdlib_base_fibonacci_indexf( const float F ) { return 0.0f / 0.0f; // NaN } x = ( F * SQRT_5 ) + 0.5f; - return stdlib_base_roundf( stdlib_base_lnf( x ) / LN_PHI ); + return stdlib_base_roundf( stdlib_base_lnf( x ) / stdlib_base_lnf( STDLIB_CONSTANT_FLOAT32_PHI ) ); } From 98c4e1dea93fec26ceb473333270c71a42e067d1 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 10 Apr 2025 23:53:04 -0700 Subject: [PATCH 10/10] style: re-enable lint rule Signed-off-by: Athan --- .../@stdlib/math/base/special/fibonacci-indexf/lib/main.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/lib/main.js index 532a0ad2c816..89da7331b907 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci-indexf/lib/main.js @@ -94,7 +94,6 @@ function fibonacciIndexf( F ) { ) { return NaN; } - // eslint-disable-next-line max-len x = float64ToFloat32( float64ToFloat32( F*SQRT_5 ) + ONE_HALF ); return roundf( float64ToFloat32( lnf( x ) / LN_PHI ) ); }