Skip to content

Commit b50cd39

Browse files
error-resolve
1 parent 8b53749 commit b50cd39

File tree

6 files changed

+45
-18
lines changed

6 files changed

+45
-18
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var expf = require( '@stdlib/math/base/special/expf' );
5555

5656
#### expf( x )
5757

58-
Evaluates the natural [exponential function][exponential-function] as 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 );
@@ -126,7 +126,7 @@ for ( i = 0; i < 100; i++ ) {
126126

127127
#### stdlib_base_expf( x )
128128

129-
Evaluates the natural [exponential function][exponential-function] as a 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 );

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var randu = require( '@stdlib/random/base/randu' );
25+
var Float32Array = require( '@stdlib/array/float32' );
2526
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2627
var pkg = require( './../package.json' ).name;
2728
var expf = require( './../lib' );
@@ -30,14 +31,20 @@ var expf = require( './../lib' );
3031
// MAIN //
3132

3233
bench( pkg, function benchmark( b ) {
34+
var len;
3335
var x;
3436
var y;
3537
var i;
3638

37-
x = randu( 100, -50.0, 50.0 );
39+
len = 100;
40+
x = new Float32Array( len );
41+
for ( i = 0; i < len; i++ ) {
42+
x[ i ] = ( randu() * 100.0 ) - 50.0;
43+
}
44+
3845
b.tic();
3946
for ( i = 0; i < b.iterations; i++ ) {
40-
y = expf( x[ i % x.length ] );
47+
y = expf( x[ i % len ] );
4148
if ( isnan( y ) ) {
4249
b.fail( 'should not return NaN' );
4350
}
@@ -51,14 +58,20 @@ bench( pkg, function benchmark( b ) {
5158
});
5259

5360
bench( pkg+'::built-in', function benchmark( b ) {
61+
var len;
5462
var x;
5563
var y;
5664
var i;
5765

58-
x = randu( 100, -50.0, 50.0 );
66+
len = 100;
67+
x = new Float32Array( len );
68+
for ( i = 0; i < len; i++ ) {
69+
x[ i ] = ( randu() * 100.0 ) - 50.0;
70+
}
71+
5972
b.tic();
6073
for ( i = 0; i < b.iterations; i++ ) {
61-
y = Math.exp( x[ i % x.length ] ); // eslint-disable-line stdlib/no-builtin-math
74+
y = Math.exp( x[ i % len ] ); // eslint-disable-line stdlib/no-builtin-math
6275
if ( isnan( y ) ) {
6376
b.fail( 'should not return NaN' );
6477
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25+
var Float32Array = require( '@stdlib/array/float32' );
2526
var randu = require( '@stdlib/random/base/randu' );
2627
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2728
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -39,14 +40,20 @@ var opts = {
3940
// MAIN //
4041

4142
bench( pkg+'::native', opts, function benchmark( b ) {
43+
var len;
4244
var x;
4345
var y;
4446
var i;
4547

48+
len = 100;
49+
x = new Float32Array( len );
50+
for ( i = 0; i < len; i++ ) {
51+
x[ i ] = ( randu() * 100.0 ) - 50.0;
52+
}
53+
4654
b.tic();
4755
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu()*100.0 ) - 50.0;
49-
y = expf( x );
56+
y = expf( x[ i % len ] );
5057
if ( isnan( y ) ) {
5158
b.fail( 'should not return NaN' );
5259
}

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

Lines changed: 10 additions & 8 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>
2019
#include "stdlib/math/base/special/expf.h"
2120
#include <math.h>
2221
#include <stdio.h>
2322
#include <stdlib.h>
2423
#include <time.h>
24+
#include <sys/time.h>
2525

2626
#define NAME "expf"
2727
#define ITERATIONS 1000000
@@ -75,13 +75,15 @@ static double tic( void ) {
7575
}
7676

7777
/**
78-
* Generates a random number on the interval [0,1).
78+
* Generates a random number on the interval [min,max).
7979
*
80-
* @return random number
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
8183
*/
82-
static float rand_float( void ) {
83-
int r = rand();
84-
return (float)r / ( (float)RAND_MAX + 1.0f );
84+
static float random_uniform( const float min, const float max ) {
85+
float v = (float)rand() / ( (float)RAND_MAX + 1.0 );
86+
return min + ( v*(max-min) );
8587
}
8688

8789
/**
@@ -92,12 +94,12 @@ static float rand_float( void ) {
9294
static double benchmark( void ) {
9395
double elapsed;
9496
float x[ 100 ];
95-
float y[ 100 ];
97+
float y;
9698
double t;
9799
int i;
98100

99101
for ( i = 0; i < 100; i++ ) {
100-
x[ i ] = ( 100.0f * rand_float() ) - 50.0f;
102+
x[ i ] = random_uniform( -50.0, 50.0 );
101103
}
102104
t = tic();
103105
for ( i = 0; i < ITERATIONS; i++ ) {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@
2020
#include <stdio.h>
2121
#include <stdlib.h>
2222

23+
static float random_uniform( const float min, const float max ) {
24+
float v = (float)rand() / ( (float)RAND_MAX + 1.0 );
25+
return min + ( v*(max-min) );
26+
}
27+
2328
int main( void ) {
2429
float x;
2530
float v;
2631
int i;
2732

2833
for ( i = 0; i < 100; i++ ) {
29-
x = ( rand() / RAND_MAX ) * 100.0;
34+
x = random_uniform( 0.0, 100.0 );
3035
v = stdlib_base_expf( x );
3136
printf( "e^%f = %f\n", x, v );
3237
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ var x;
2525
var i;
2626

2727
for ( i = 0; i < 100; i++ ) {
28-
x = (randu()*100.0) - 50.0;
28+
x = ( randu()*100.0 ) - 50.0;
2929
console.log( 'e^%f = %f', x, expf( x ) );
3030
}

0 commit comments

Comments
 (0)