File tree Expand file tree Collapse file tree 7 files changed +37
-35
lines changed
lib/node_modules/@stdlib/math/base/special/negalucas
include/stdlib/math/base/special Expand file tree Collapse file tree 7 files changed +37
-35
lines changed Original file line number Diff line number Diff line change @@ -191,19 +191,19 @@ for ( i = 0; i > -77; i-- ) {
191
191
Computes the nth [ negaLucas number] [ lucas-number ] .
192
192
193
193
``` c
194
- double out = stdlib_base_negalucas( 0 );
195
- // returns 0
194
+ double out = stdlib_base_negalucas( 0.0 );
195
+ // returns 0.0
196
196
197
- out = stdlib_base_negalucas( -1 );
198
- // returns -1
197
+ out = stdlib_base_negalucas( -1.0 );
198
+ // returns -1.0
199
199
```
200
200
201
201
The function accepts the following arguments:
202
202
203
- - ** n** : ` [in] int32_t ` input value.
203
+ - ** n** : ` [in] double ` input value.
204
204
205
205
``` c
206
- double stdlib_base_negalucas ( const int32_t n );
206
+ double stdlib_base_negalucas ( const double n );
207
207
```
208
208
209
209
</section>
@@ -227,15 +227,14 @@ double stdlib_base_negalucas( const int32_t n );
227
227
```c
228
228
#include "stdlib/math/base/special/negalucas.h"
229
229
#include <stdio.h>
230
- #include <stdint.h>
231
230
232
231
int main( void ) {
233
- int32_t i;
232
+ double i;
234
233
double v;
235
234
236
- for ( i = 0; i > -77; i-- ) {
235
+ for ( i = 0.0 ; i > -77.0 ; i-- ) {
237
236
v = stdlib_base_negalucas( i );
238
- printf( "negalucas(%d ) = %lf\n", i, v );
237
+ printf( "negalucas(%lf ) = %lf\n", i, v );
239
238
}
240
239
}
241
240
```
Original file line number Diff line number Diff line change 30
30
/**
31
31
* Prints the TAP version.
32
32
*/
33
- void print_version () {
33
+ static void print_version ( void ) {
34
34
printf ( "TAP version 13\n" );
35
35
}
36
36
@@ -91,13 +91,13 @@ static double rand_double( void ) {
91
91
*/
92
92
static double benchmark ( void ) {
93
93
double elapsed ;
94
- int32_t x [ 100 ];
94
+ double x [ 100 ];
95
95
double t ;
96
96
double y ;
97
97
int i ;
98
98
99
99
for ( i = 0 ; i < 100 ; i ++ ) {
100
- x [ i ] = (int32_t )( 77.0 * rand_double () );
100
+ x [ i ] = ( 77.0 * rand_double () );
101
101
}
102
102
103
103
t = tic ();
Original file line number Diff line number Diff line change 18
18
19
19
#include "stdlib/math/base/special/negalucas.h"
20
20
#include <stdio.h>
21
- #include <stdint.h>
22
21
23
22
int main ( void ) {
24
- int32_t i ;
23
+ double i ;
25
24
double v ;
26
25
27
- for ( i = 0 ; i > -77 ; i -- ) {
26
+ for ( i = 0.0 ; i > -77.0 ; i -- ) {
28
27
v = stdlib_base_negalucas ( i );
29
- printf ( "negalucas(%d ) = %lf\n" , i , v );
28
+ printf ( "negalucas(%lf ) = %lf\n" , i , v );
30
29
}
31
30
}
Original file line number Diff line number Diff line change 19
19
#ifndef STDLIB_MATH_BASE_SPECIAL_NEGALUCAS_H
20
20
#define STDLIB_MATH_BASE_SPECIAL_NEGALUCAS_H
21
21
22
- #include <stdint.h>
23
-
24
22
/*
25
23
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
26
24
*/
@@ -31,7 +29,7 @@ extern "C" {
31
29
/**
32
30
* Computes the nth negaLucas number.
33
31
*/
34
- double stdlib_base_negalucas ( const int32_t n );
32
+ double stdlib_base_negalucas ( const double n );
35
33
36
34
#ifdef __cplusplus
37
35
}
Original file line number Diff line number Diff line change 37
37
"libpath" : [],
38
38
"dependencies" : [
39
39
" @stdlib/math/base/napi/unary" ,
40
- " @stdlib/math/base/special/labs" ,
41
- " @stdlib/constants/float64/max-safe-nth-lucas"
40
+ " @stdlib/math/base/special/abs" ,
41
+ " @stdlib/constants/float64/max-safe-nth-lucas" ,
42
+ " @stdlib/math/base/assert/is-integer"
42
43
]
43
44
},
44
45
{
52
53
"libraries" : [],
53
54
"libpath" : [],
54
55
"dependencies" : [
55
- " @stdlib/math/base/special/labs" ,
56
- " @stdlib/constants/float64/max-safe-nth-lucas"
56
+ " @stdlib/math/base/special/abs" ,
57
+ " @stdlib/constants/float64/max-safe-nth-lucas" ,
58
+ " @stdlib/math/base/assert/is-integer"
57
59
]
58
60
},
59
61
{
67
69
"libraries" : [],
68
70
"libpath" : [],
69
71
"dependencies" : [
70
- " @stdlib/math/base/special/labs" ,
71
- " @stdlib/constants/float64/max-safe-nth-lucas"
72
+ " @stdlib/math/base/special/abs" ,
73
+ " @stdlib/constants/float64/max-safe-nth-lucas" ,
74
+ " @stdlib/math/base/assert/is-integer"
72
75
]
73
76
}
74
77
]
Original file line number Diff line number Diff line change 19
19
#include "stdlib/math/base/special/negalucas.h"
20
20
#include "stdlib/math/base/napi/unary.h"
21
21
22
- STDLIB_MATH_BASE_NAPI_MODULE_I_D ( stdlib_base_negalucas )
22
+ STDLIB_MATH_BASE_NAPI_MODULE_D_D ( stdlib_base_negalucas )
Original file line number Diff line number Diff line change 17
17
*/
18
18
19
19
#include "stdlib/math/base/special/negalucas.h"
20
- #include "stdlib/math/base/special/labs.h"
20
+ #include "stdlib/math/base/assert/is_integer.h"
21
+ #include "stdlib/math/base/special/abs.h"
21
22
#include "stdlib/constants/float64/max_safe_nth_lucas.h"
23
+ #include <stdint.h>
24
+ #include <stdlib.h>
22
25
23
26
static const int64_t negalucas_value [ 77 ] = {
24
27
2 ,
@@ -107,17 +110,17 @@ static const int64_t negalucas_value[ 77 ] = {
107
110
* @return output value
108
111
*
109
112
* @example
110
- * double out = stdlib_base_negalucas( -1 );
111
- * // returns -1
113
+ * double out = stdlib_base_negalucas( -1.0 );
114
+ * // returns -1.0
112
115
*
113
116
* @example
114
- * double out = stdlib_base_negalucas( 1 );
117
+ * double out = stdlib_base_negalucas( 1.0 );
115
118
* // returns NaN
116
119
*/
117
- double stdlib_base_negalucas ( const int32_t n ) {
118
- int32_t an = stdlib_base_labs ( n );
119
- if ( n > 0 || an > STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_LUCAS ) {
120
+ double stdlib_base_negalucas ( const double n ) {
121
+ double an = stdlib_base_abs ( n );
122
+ if ( ! stdlib_base_is_integer ( n ) || n > 0. 0 || an > STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_LUCAS ) {
120
123
return 0.0 / 0.0 ; // NaN
121
124
}
122
- return negalucas_value [ an ];
125
+ return negalucas_value [ ( size_t ) an ];
123
126
}
You can’t perform that action at this time.
0 commit comments