Skip to content

Commit df0e6c7

Browse files
feat(math): add math/base/special/expf
1 parent 2ebc5a3 commit df0e6c7

File tree

12 files changed

+59
-63
lines changed

12 files changed

+59
-63
lines changed

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

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

2121
# expf
2222

23-
> Natural [exponential function][exponential-function] of a single-precision floating-point number
23+
> Natural [exponential function][exponential-function]
2424
2525
<section class="intro">
2626

@@ -55,14 +55,14 @@ var expf = require( '@stdlib/math/base/special/expf' );
5555

5656
#### expf( x )
5757

58-
Evaluates the natural [exponential function][exponential-function] of a single-precision floating-point number
58+
Evaluates the natural [exponential function][exponential-function] as a single-precision floating-point number
5959

6060
```javascript
6161
var v = expf( 4.0 );
62-
// returns ~54.5982
62+
// returns 54.598148345947266
6363

6464
v = expf( -9.0 );
65-
// returns ~1.234e-4
65+
// returns 0.00012340980174485594
6666

6767
v = expf( 0.0 );
6868
// returns 1.0
@@ -126,14 +126,14 @@ for ( i = 0; i < 100; i++ ) {
126126

127127
#### stdlib_base_expf( x )
128128

129-
Evaluates the natural [exponential function][exponential-function] single-precision floating-point number
129+
Evaluates the natural [exponential function][exponential-function] as a single-precision floating-point number
130130

131131
```c
132132
float out = stdlib_base_expf( 4.0 );
133-
// returns ~54.5982
133+
// returns 54.598148345947266
134134

135135
out = stdlib_base_expf( -9.0 );
136-
// returns ~1.234e-4
136+
// returns 0.00012340980174485594
137137
```
138138

139139
The function accepts the following arguments:
@@ -173,7 +173,7 @@ int main( void ) {
173173
int i;
174174
175175
for ( i = 0; i < 100; i++ ) {
176-
x = ( (float)rand() / (float)RAND_MAX ) * 100.0;
176+
x = ( (float)rand() / (float)RAND_MAX ) * 100.0f;
177177
v = stdlib_base_expf( x );
178178
printf( "e^%f = %f\n", x, v );
179179
}
@@ -211,7 +211,7 @@ int main( void ) {
211211

212212
[exponential-function]: https://en.wikipedia.org/wiki/Exponential_function
213213

214-
[@stdlib/constants/float64/e]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/constants/float64/e
214+
[@stdlib/constants/float32/e]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/constants/float32/e
215215

216216
<!-- <related-links> -->
217217

lib/node_modules/@stdlib/math/base/special/expf/benchmark/c/cephes/benchmark.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include <stdlib.h>
20-
#include <stdio.h>
19+
#include <sys/time.h>
2120
#include <math.h>
21+
#include <stdio.h>
22+
#include <stdlib.h>
2223
#include <time.h>
23-
#include <sys/time.h>
2424

2525
#define NAME "expf"
2626
#define ITERATIONS 1000000
@@ -75,7 +75,7 @@ static void print_results( double elapsed ) {
7575
static double tic( void ) {
7676
struct timeval now;
7777
gettimeofday( &now, NULL );
78-
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
78+
return (double)now.tv_sec + (double)now.tv_usec / 1.0e6;
7979
}
8080

8181
/**
@@ -102,7 +102,7 @@ static double benchmark( void ) {
102102

103103
t = tic();
104104
for ( i = 0; i < ITERATIONS; i++ ) {
105-
x = ( 100.0f *rand_float() ) - 50.0f;
105+
x = ( 100.0f * rand_float() ) - 50.0f;
106106
y = expf( x );
107107
if ( y != y ) {
108108
printf( "should not return NaN\n" );
@@ -123,15 +123,15 @@ int main( void ) {
123123
double elapsed;
124124
int i;
125125

126-
// Use the current time to seed the random number generator:
126+
// Use the current time to seed the random number generator:
127127
srand( time( NULL ) );
128128

129129
print_version();
130130
for ( i = 0; i < REPEATS; i++ ) {
131131
printf( "# c::cephes::%s\n", NAME );
132132
elapsed = benchmark();
133133
print_results( elapsed );
134-
printf( "ok %d benchmark finished\n", i+1 );
134+
printf( "ok %d benchmark finished\n", i + 1 );
135135
}
136136
print_summary( REPEATS, REPEATS );
137137
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
* limitations under the License.
1717
*/
1818

19+
#include <sys/time.h>
1920
#include "stdlib/math/base/special/expf.h"
20-
#include <stdlib.h>
21-
#include <stdio.h>
2221
#include <math.h>
22+
#include <stdio.h>
23+
#include <stdlib.h>
2324
#include <time.h>
24-
#include <sys/time.h>
2525

2626
#define NAME "expf"
2727
#define ITERATIONS 1000000
@@ -71,7 +71,7 @@ static void print_results( double elapsed ) {
7171
static double tic( void ) {
7272
struct timeval now;
7373
gettimeofday( &now, NULL );
74-
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
74+
return (double)now.tv_sec + (double)now.tv_usec / 1.0e6;
7575
}
7676

7777
/**
@@ -119,15 +119,15 @@ int main( void ) {
119119
double elapsed;
120120
int i;
121121

122-
// Use the current time to seed the random number generator:
122+
// Use the current time to seed the random number generator:
123123
srand( time( NULL ) );
124124

125125
print_version();
126126
for ( i = 0; i < REPEATS; i++ ) {
127127
printf( "# c::native::%s\n", NAME );
128128
elapsed = benchmark();
129129
print_results( elapsed );
130-
printf( "ok %d benchmark finished\n", i+1 );
130+
printf( "ok %d benchmark finished\n", i + 1 );
131131
}
132132
print_summary( REPEATS, REPEATS );
133133
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
{{alias}}( x )
3-
Evaluates the natural exponential function.
3+
Evaluates the natural exponential function (single-precision).
44

55
Parameters
66
----------
@@ -15,9 +15,9 @@
1515
Examples
1616
--------
1717
> var y = {{alias}}( 4.0 )
18-
~54.5982
18+
54.598148345947266
1919
> y = {{alias}}( -9.0 )
20-
~1.234e-4
20+
0.00012340980174485594
2121
> y = {{alias}}( 0.0 )
2222
1.0
2323
> y = {{alias}}( NaN )

lib/node_modules/@stdlib/math/base/special/expf/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// TypeScript Version: 4.1
2020

2121
/**
22-
* Evaluates the natural exponential function.
22+
* Evaluates the natural exponential function as a single-precision floating-point number.
2323
*
2424
* @param x - input value
2525
* @returns function value

lib/node_modules/@stdlib/math/base/special/expf/examples/c/example.c

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

1919
#include "stdlib/math/base/special/expf.h"
20-
#include <stdlib.h>
2120
#include <stdio.h>
21+
#include <stdlib.h>
2222

2323
int main( void ) {
24-
float x;
25-
float v;
26-
int i;
24+
float x;
25+
float v;
26+
int i;
2727

28-
for ( i = 0; i < 100; i++ ) {
29-
x = ( (float)rand() / (float)RAND_MAX ) * 100.0f;
30-
v = stdlib_base_expf( x );
31-
printf( "e^%f = %f\n", x, v );
32-
}
28+
for ( i = 0; i < 100; i++ ) {
29+
x = ( (float)rand() / (float)RAND_MAX ) * 100.0f;
30+
v = stdlib_base_expf( x );
31+
printf( "e^%f = %f\n", x, v );
32+
}
3333
}

lib/node_modules/@stdlib/math/base/special/expf/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Evaluate the natural exponential function.
22+
* Evaluate the natural exponential function as a single-precision floating-point number.
2323
*
2424
* @module @stdlib/math/base/special/expf
2525
*

lib/node_modules/@stdlib/math/base/special/expf/lib/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var NEG_NEARZERO = -NEARZERO;
5757
// MAIN //
5858

5959
/**
60-
* Evaluates the natural exponential function for single-precision.
60+
* Evaluates the natural exponential function as a single-precision floating-point number.
6161
*
6262
* ## Method
6363
*
@@ -144,11 +144,11 @@ var NEG_NEARZERO = -NEARZERO;
144144
*
145145
* @example
146146
* var v = expf( 4.0 );
147-
* // returns ~54.598
147+
* // returns 54.598148345947266
148148
*
149149
* @example
150150
* var v = expf( -9.0 );
151-
* // returns ~1.234e-4
151+
* // returns 0.00012340980174485594
152152
*
153153
* @example
154154
* var v = expf( 0.0 );

lib/node_modules/@stdlib/math/base/special/expf/lib/native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' );
2626
// MAIN //
2727

2828
/**
29-
* Evaluates the natural exponential function for single-precision.
29+
* Evaluates the natural exponential function as a single-precision floating-point number.
3030
*
3131
* @private
3232
* @param {number} x - input value

lib/node_modules/@stdlib/math/base/special/expf/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,21 @@
6060
"special",
6161
"function",
6262
"math.exp",
63-
"exp",
63+
"expf",
6464
"natural",
6565
"exponential",
6666
"euler",
6767
"power",
68+
"float",
6869
"number"
6970
],
7071
"__stdlib__": {
7172
"scaffold": {
7273
"$schema": "math/[email protected]",
7374
"base_alias": "expf",
7475
"alias": "expf",
75-
"pkg_desc": "evaluate the natural exponential function (single-precision)",
76-
"desc": "evaluates the natural exponential function using single-precision floating-point numbers",
76+
"pkg_desc": "evaluate the natural exponential function as a single-precision floating-point number",
77+
"desc": "evaluates the natural exponential function as a single-precision floating-point number",
7778
"short_desc": "natural exponential function (single-precision)",
7879
"parameters": [
7980
{
@@ -134,7 +135,7 @@
134135
"keywords": [
135136
"natural",
136137
"exponential",
137-
"exp",
138+
"expf",
138139
"power"
139140
],
140141
"extra_keywords": [

0 commit comments

Comments
 (0)