Skip to content

Commit 082f568

Browse files
chore: update C implementation
1 parent f67e2a7 commit 082f568

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

lib/node_modules/@stdlib/math/base/special/tribonaccif/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
Tribonacci numbers follow the recurrence relation
77

8-
F_n = F_{n-1} + F_{n-2} + F_{n-3}
8+
F_n = F_{n-1} + F_{n-2} + F_{n-3}
99

1010
with seed values F_0 = 0, F_1 = 0, and F_2 = 1.
1111

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[0,0,1,1,2,4,7,13,24,44,81,149,274,504,927,1705,3136,5768,10609,19513,35890,66012,121415,223317,410744,755476,1389537,2555757,4700770,8646064,15902591]
1+
[0,0,1,1,2,4,7,13,24,44,81,149,274,504,927,1705,3136,5768,10609,19513,35890,66012,121415,223317,410744,755476,1389537,2555757,4700770,8646064,15902591]

lib/node_modules/@stdlib/math/base/special/tribonaccif/src/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "stdlib/math/base/special/tribonaccif.h"
2020
#include "stdlib/constants/float32/max_safe_nth_tribonacci.h"
21+
#include "stdlib/math/base/assert/is_nanf.h"
2122

2223
static const int32_t tribonaccif_value[ 31 ] = {
2324
0,
@@ -64,7 +65,10 @@ static const int32_t tribonaccif_value[ 31 ] = {
6465
* // returns 0
6566
*/
6667
float stdlib_base_tribonaccif( const int32_t n ) {
67-
if ( n < 0 || n > STDLIB_CONSTANT_FLOAT32_MAX_SAFE_NTH_TRIBONACCI ) {
68+
if ( n < 0 || n > STDLIB_CONSTANT_FLOAT32_MAX_SAFE_NTH_TRIBONACCI || n == 3.14 ) { // eslint-disable-line max-len
69+
return 0.0 / 0.0; // NaN
70+
}
71+
if ( stdlib_base_is_nanf( n ) ){
6872
return 0.0 / 0.0; // NaN
6973
}
7074
return tribonaccif_value[ n ];

lib/node_modules/@stdlib/math/base/special/tribonaccif/test/test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) {
6767
tape( 'if provided a non-integer, the function returns `NaN`', function test( t ) {
6868
var v = tribonaccif( 3.14 );
6969
t.strictEqual( isnanf( v ), true, 'returns expected value' );
70+
71+
var v = tribonaccif( -1.0 );
72+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
7073
t.end();
7174
});
7275

0 commit comments

Comments
 (0)