Skip to content

Commit c9db5e1

Browse files
committed
fix: code review
--- 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: na - 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: na - task: lint_license_headers status: passed ---
1 parent 2423d30 commit c9db5e1

File tree

19 files changed

+59
-211
lines changed

19 files changed

+59
-211
lines changed

lib/node_modules/@stdlib/math/base/special/negafibonaccif/README.md

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# negaFibonaccif
2222

23-
> Compute the nth [negaFibonacci number][fibonacci-number] as a single-precision floating-point number.
23+
> Compute the nth [negaFibonacci number][fibonacci-number] as a [single-precision floating-point number][ieee754].
2424
2525
<section class="intro">
2626

@@ -32,11 +32,6 @@ The [negaFibonacci numbers][fibonacci-number] are the integer sequence
3232
0, 1, -1, 2, -3, 5, -8, 13, -21, 34, -55, 89, -144, \ldots
3333
```
3434

35-
<!-- <div class="equation" align="center" data-raw-text="0, 1, -1, 2, -3, 5, -8, 13, -21, 34, -55, 89, -144, \ldots" data-equation="eq:negafibonacci_sequence">
36-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/negafibonacci/docs/img/equation_negafibonacci_sequence.svg" alt="NegaFibonacci sequence">
37-
<br>
38-
</div> -->
39-
4035
<!-- </equation> -->
4136

4237
The sequence is defined by the recurrence relation
@@ -47,11 +42,6 @@ The sequence is defined by the recurrence relation
4742
F_{n-2} = F_{n} - F_{n-1}
4843
```
4944

50-
<!-- <div class="equation" align="center" data-raw-text="F_{n-2} = F_{n} - F_{n-1}" data-equation="eq:negafibonacci_recurrence_relation">
51-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/negafibonacci/docs/img/equation_negafibonacci_recurrence_relation.svg" alt="NegaFibonacci sequence recurrence relation">
52-
<br>
53-
</div> -->
54-
5545
<!-- </equation> -->
5646

5747
which yields
@@ -62,11 +52,6 @@ which yields
6252
F_{-n} = (-1)^{n+1} F_n
6353
```
6454

65-
<!-- <div class="equation" align="center" data-raw-text="F_{-n} = (-1)^{n+1} F_n" data-equation="eq:negafibonacci_fibonacci">
66-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/negafibonacci/docs/img/equation_negafibonacci_fibonacci.svg" alt="NegaFibonacci relationship to Fibonacci numbers">
67-
<br>
68-
</div> -->
69-
7055
<!-- </equation> -->
7156

7257
with seed values `F_0 = 0` and `F_{-1} = 1`.
@@ -85,7 +70,7 @@ var negafibonaccif = require( '@stdlib/math/base/special/negafibonaccif' );
8570

8671
#### negafibonaccif( n )
8772

88-
Computes the nth [negaFibonacci number][fibonacci-number] as a single-precision floating-point number.
73+
Computes the nth [negaFibonacci number][fibonacci-number] as a [single-precision floating-point number][ieee754].
8974

9075
```javascript
9176
var v = negafibonaccif( 0 );
@@ -145,15 +130,13 @@ var v = negafibonaccif( NaN );
145130
<!-- eslint no-undef: "error" -->
146131

147132
```javascript
133+
var logEachMap = require( '@stdlib/console/log-each-map' );
134+
var linspace = require( '@stdlib/array/base/linspace' );
148135
var negafibonaccif = require( '@stdlib/math/base/special/negafibonaccif' );
149136

150-
var v;
151-
var i;
137+
var v = linspace( -36, 0, 37 );
152138

153-
for ( i = 0; i > -37; i-- ) {
154-
v = negafibonaccif( i );
155-
console.log( v );
156-
}
139+
logEachMap( 'negafibonaccif(%d) = %0.4f', v, negafibonaccif );
157140
```
158141

159142
</section>
@@ -188,13 +171,13 @@ for ( i = 0; i > -37; i-- ) {
188171

189172
#### stdlib_base_negafibonaccif( n )
190173

191-
Computes the nth [negaFibonacci number][fibonacci-number] as a single-precision floating-point number.
174+
Computes the nth [negaFibonacci number][fibonacci-number] as a [single-precision floating-point number][ieee754].
192175

193176
```c
194177
float out = stdlib_base_negafibonaccif( 0 );
195178
// returns 0.0f
196179

197-
out = stdlib_base_fibonaccif( -1 );
180+
out = stdlib_base_negafibonaccif( -1 );
198181
// returns 1.0f
199182
```
200183

lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ bench( pkg, function benchmark( b ) {
4646
var y;
4747
var i;
4848

49-
x = discreteUniform( 100, -36.0, 0.0 );
49+
x = discreteUniform( 100, -36, 0 );
5050

5151
b.tic();
5252
for ( i = 0; i < b.iterations; i++ ) {
53-
y = negafibonaccif( x[ i % 100 ] );
53+
y = negafibonaccif( x[ i%x.length ] );
5454
if ( isnanf( y ) ) {
5555
b.fail( 'should not return NaN' );
5656
}
@@ -70,14 +70,16 @@ bench( pkg+'::analytic', function benchmark( b ) {
7070

7171
function negafibonaccif( n ) {
7272
var an = absf( n );
73+
74+
// TODO: replace with `powf` when available
7375
return pow( -1.0, an+1 ) * roundf( pow( PHI, an ) / SQRT_5 );
7476
}
7577

76-
x = discreteUniform( 100, -36.0, 0.0 );
78+
x = discreteUniform( 100, -36, 0 );
7779

7880
b.tic();
7981
for ( i = 0; i < b.iterations; i++ ) {
80-
y = negafibonaccif( x[ i % 100 ] );
82+
y = negafibonaccif( x[ i%x.length ] );
8183
if ( isnanf( y ) ) {
8284
b.fail( 'should not return NaN' );
8385
}
@@ -95,11 +97,11 @@ bench( pkg+'::table', function benchmark( b ) {
9597
var y;
9698
var i;
9799

98-
x = discreteUniform( 100, -36.0, 0.0 );
100+
x = discreteUniform( 100, -36, 0 );
99101

100102
b.tic();
101103
for ( i = 0; i < b.iterations; i++ ) {
102-
y = NEGAFIBONACCIF[ absf( x[ i % 100 ] ) ];
104+
y = NEGAFIBONACCIF[ absf( x[ i%x.length ] ) ];
103105
if ( isnanf( y ) ) {
104106
b.fail( 'should not return NaN' );
105107
}
@@ -127,11 +129,11 @@ bench( pkg+'::naive_recursion', function benchmark( b ) {
127129
return negafibonaccif( n+2 ) - negafibonaccif( n+1 );
128130
}
129131

130-
x = discreteUniform( 100, -36.0, 0.0 );
132+
x = discreteUniform( 100, -36, 0 );
131133

132134
b.tic();
133135
for ( i = 0; i < b.iterations; i++ ) {
134-
y = negafibonaccif( x[ i % 100 ] );
136+
y = negafibonaccif( x[ i%x.length ] );
135137
if ( isnanf( y ) ) {
136138
b.fail( 'should not return NaN' );
137139
}
@@ -166,11 +168,11 @@ bench( pkg+'::recursion_memoized', function benchmark( b ) {
166168
return arr[ an ];
167169
}
168170

169-
x = discreteUniform( 100, -36.0, 0.0 );
171+
x = discreteUniform( 100, -36, 0 );
170172

171173
b.tic();
172174
for ( i = 0; i < b.iterations; i++ ) {
173-
y = negafibonaccif( x[ i % 100 ] );
175+
y = negafibonaccif( x[ i%x.length ] );
174176
if ( isnanf( y ) ) {
175177
b.fail( 'should not return NaN' );
176178
}
@@ -205,11 +207,11 @@ bench( pkg+'::naive_iterative', function benchmark( b ) {
205207
return arr[ an ];
206208
}
207209

208-
x = discreteUniform( 100, -36.0, 0.0 );
210+
x = discreteUniform( 100, -36, 0 );
209211

210212
b.tic();
211213
for ( i = 0; i < b.iterations; i++ ) {
212-
y = negafibonaccif( x[ i % 100 ] );
214+
y = negafibonaccif( x[ i%x.length ] );
213215
if ( isnanf( y ) ) {
214216
b.fail( 'should not return NaN' );
215217
}
@@ -246,11 +248,11 @@ bench( pkg+'::iterative', function benchmark( b ) {
246248
return b;
247249
}
248250

249-
x = discreteUniform( 100, -36.0, 0.0 );
251+
x = discreteUniform( 100, -36, 0 );
250252

251253
b.tic();
252254
for ( i = 0; i < b.iterations; i++ ) {
253-
y = negafibonaccif( x[ i % 100 ] );
255+
y = negafibonaccif( x[ i%x.length ] );
254256
if ( isnanf( y ) ) {
255257
b.fail( 'should not return NaN' );
256258
}
@@ -290,11 +292,11 @@ bench( pkg+'::iterative_memoized', function benchmark( b ) {
290292
return arr[ an ];
291293
}
292294

293-
x = discreteUniform( 100, -36.0, 0.0 );
295+
x = discreteUniform( 100, -36, 0 );
294296

295297
b.tic();
296298
for ( i = 0; i < b.iterations; i++ ) {
297-
y = negafibonaccif( x[ i % 100 ] );
299+
y = negafibonaccif( x[ i%x.length ] );
298300
if ( isnanf( y ) ) {
299301
b.fail( 'should not return NaN' );
300302
}

lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/benchmark.native.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4343
var y;
4444
var i;
4545

46-
x = discreteUniform( 100, -36.0, 0.0 );
46+
x = discreteUniform( 100, -36, 0 );
4747

4848
b.tic();
4949
for ( i = 0; i < b.iterations; i++ ) {
50-
y = negafibonaccif( x[ i % 100 ] );
50+
y = negafibonaccif( x[ i%x.length ] );
5151
if ( isnanf( y ) ) {
5252
b.fail( 'should not return NaN' );
5353
}

lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/benchmark.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ static double benchmark( void ) {
112112
int i;
113113

114114
for ( i = 0; i < 100; i++ ) {
115-
x[ i ] = (int)floor( 36.0f * rand_float() );
115+
x[ i ] = (int)floorf( 36.0f*rand_float() );
116116
}
117117

118118
t = tic();
119119
for ( i = 0; i < ITERATIONS; i++ ) {
120-
y = negafibonacci( -x[ i % 100 ] );
120+
y = negafibonacci( -x[ i%100 ] );
121121
if ( y == 7 ) {
122122
printf( "should not return 7\n" );
123123
break;

lib/node_modules/@stdlib/math/base/special/negafibonaccif/benchmark/c/native/benchmark.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "stdlib/math/base/special/negafibonaccif.h"
20+
#include <stdint.h>
2021
#include <stdlib.h>
2122
#include <stdio.h>
2223
#include <math.h>
@@ -93,16 +94,16 @@ static double benchmark( void ) {
9394
int32_t x[ 100 ];
9495
double elapsed;
9596
double t;
96-
double y;
97+
float y;
9798
int i;
9899

99100
for ( i = 0; i < 100; i++ ) {
100-
x[ i ] = (int32_t)floor( 36.0f * rand_float());
101+
x[ i ] = (int32_t)floorf( 36.0f*rand_float());
101102
}
102103

103104
t = tic();
104105
for ( i = 0; i < ITERATIONS; i++ ) {
105-
y = stdlib_base_negafibonaccif( -x[ i % 100 ] );
106+
y = stdlib_base_negafibonaccif( -x[ i%100 ] );
106107
if ( y != y ) {
107108
printf( "should not return NaN\n" );
108109
break;

lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_fibonacci.svg

Lines changed: 0 additions & 36 deletions
This file was deleted.

lib/node_modules/@stdlib/math/base/special/negafibonaccif/docs/img/equation_negafibonacci_recurrence_relation.svg

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)