File tree Expand file tree Collapse file tree 7 files changed +35
-33
lines changed
lib/node_modules/@stdlib/math/base/special/negalucasf
include/stdlib/math/base/special Expand file tree Collapse file tree 7 files changed +35
-33
lines changed Original file line number Diff line number Diff line change @@ -191,19 +191,19 @@ for ( i = 0; i > -35; i-- ) {
191
191
Computes the nth [ negaLucas number] [ lucas-number ] in single-precision floating-point format.
192
192
193
193
``` c
194
- float out = stdlib_base_negalucasf( 0 );
194
+ float out = stdlib_base_negalucasf( 0 . 0f );
195
195
// returns 0.0f
196
196
197
- out = stdlib_base_negalucasf( -1 );
197
+ out = stdlib_base_negalucasf( -1 . 0f );
198
198
// returns -1.0f
199
199
```
200
200
201
201
The function accepts the following arguments:
202
202
203
- - ** n** : ` [in] int32_t ` input value.
203
+ - ** n** : ` [in] float ` input value.
204
204
205
205
``` c
206
- float stdlib_base_negalucasf ( const int32_t n );
206
+ float stdlib_base_negalucasf ( const float n );
207
207
```
208
208
209
209
</section>
@@ -227,15 +227,14 @@ float stdlib_base_negalucasf( const int32_t n );
227
227
```c
228
228
#include "stdlib/math/base/special/negalucasf.h"
229
229
#include <stdio.h>
230
- #include <stdint.h>
231
230
232
231
int main( void ) {
233
- int32_t i;
232
+ float i;
234
233
float v;
235
234
236
- for ( i = 0; i > -35; i-- ) {
235
+ for ( i = 0.0f ; i > -35.0f ; i-- ) {
237
236
v = stdlib_base_negalucasf( i );
238
- printf( "negalucasf(%d ) = %f\n", i, v );
237
+ printf( "negalucasf(%f ) = %f\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 float rand_float( void ) {
91
91
*/
92
92
static double benchmark ( void ) {
93
93
double elapsed ;
94
- int32_t x [ 100 ];
94
+ float x [ 100 ];
95
95
double t ;
96
96
float y ;
97
97
int i ;
98
98
99
99
for ( i = 0 ; i < 100 ; i ++ ) {
100
- x [ i ] = (int32_t )( 34.0f * rand_float () );
100
+ x [ i ] = ( 34.0f * rand_float () );
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/negalucasf.h"
20
20
#include <stdio.h>
21
- #include <stdint.h>
22
21
23
22
int main ( void ) {
24
- int32_t i ;
23
+ float i ;
25
24
float v ;
26
25
27
- for ( i = 0 ; i > -35 ; i -- ) {
26
+ for ( i = 0.0f ; i > -35.0f ; i -- ) {
28
27
v = stdlib_base_negalucasf ( i );
29
- printf ( "negalucasf(%d ) = %f\n" , i , v );
28
+ printf ( "negalucasf(%f ) = %f\n" , i , v );
30
29
}
31
30
}
Original file line number Diff line number Diff line change 19
19
#ifndef STDLIB_MATH_BASE_SPECIAL_NEGALUCASF_H
20
20
#define STDLIB_MATH_BASE_SPECIAL_NEGALUCASF_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 in single-precision floating-point format.
33
31
*/
34
- float stdlib_base_negalucasf ( const int32_t n );
32
+ float stdlib_base_negalucasf ( const float 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/float32/max-safe-nth-lucas"
40
+ " @stdlib/math/base/special/absf" ,
41
+ " @stdlib/constants/float32/max-safe-nth-lucas" ,
42
+ " @stdlib/math/base/assert/is-integerf"
42
43
]
43
44
},
44
45
{
52
53
"libraries" : [],
53
54
"libpath" : [],
54
55
"dependencies" : [
55
- " @stdlib/math/base/special/labs" ,
56
- " @stdlib/constants/float32/max-safe-nth-lucas"
56
+ " @stdlib/math/base/special/absf" ,
57
+ " @stdlib/constants/float32/max-safe-nth-lucas" ,
58
+ " @stdlib/math/base/assert/is-integerf"
57
59
]
58
60
},
59
61
{
67
69
"libraries" : [],
68
70
"libpath" : [],
69
71
"dependencies" : [
70
- " @stdlib/math/base/special/labs" ,
71
- " @stdlib/constants/float32/max-safe-nth-lucas"
72
+ " @stdlib/math/base/special/absf" ,
73
+ " @stdlib/constants/float32/max-safe-nth-lucas" ,
74
+ " @stdlib/math/base/assert/is-integerf"
72
75
]
73
76
}
74
77
]
Original file line number Diff line number Diff line change 19
19
#include "stdlib/math/base/special/negalucasf.h"
20
20
#include "stdlib/math/base/napi/unary.h"
21
21
22
- STDLIB_MATH_BASE_NAPI_MODULE_I_F ( stdlib_base_negalucasf )
22
+ STDLIB_MATH_BASE_NAPI_MODULE_F_F ( stdlib_base_negalucasf )
Original file line number Diff line number Diff line change 17
17
*/
18
18
19
19
#include "stdlib/math/base/special/negalucasf.h"
20
- #include "stdlib/math/base/special/labs.h"
20
+ #include "stdlib/math/base/assert/is_integerf.h"
21
+ #include "stdlib/math/base/special/absf.h"
21
22
#include "stdlib/constants/float32/max_safe_nth_lucas.h"
23
+ #include <stdint.h>
24
+ #include <stdlib.h>
22
25
23
26
static const int32_t negalucasf_value [ 35 ] = {
24
27
2 ,
@@ -65,17 +68,17 @@ static const int32_t negalucasf_value[ 35 ] = {
65
68
* @return output value
66
69
*
67
70
* @example
68
- * float out = stdlib_base_negalucasf( -1 );
69
- * // returns -1
71
+ * float out = stdlib_base_negalucasf( -1.0f );
72
+ * // returns -1.0f
70
73
*
71
74
* @example
72
- * float out = stdlib_base_negalucasf( 1 );
75
+ * float out = stdlib_base_negalucasf( 1.0f );
73
76
* // returns NaN
74
77
*/
75
- float stdlib_base_negalucasf ( const int32_t n ) {
76
- int32_t an = stdlib_base_labs ( n );
77
- if ( n > 0 || an > STDLIB_CONSTANT_FLOAT32_MAX_SAFE_NTH_LUCAS ) {
78
+ float stdlib_base_negalucasf ( const float n ) {
79
+ float an = stdlib_base_absf ( n );
80
+ if ( ! stdlib_base_is_integerf ( n ) || n > 0.0f || an > STDLIB_CONSTANT_FLOAT32_MAX_SAFE_NTH_LUCAS ) {
78
81
return 0.0f / 0.0f ; // NaN
79
82
}
80
- return negalucasf_value [ an ];
83
+ return negalucasf_value [ ( size_t ) an ];
81
84
}
You can’t perform that action at this time.
0 commit comments