Skip to content

Commit ecb48f6

Browse files
refactored examples and readme
1 parent 5f4546d commit ecb48f6

File tree

4 files changed

+30
-23
lines changed

4 files changed

+30
-23
lines changed

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@ v = expf( NaN );
8282
<!-- eslint no-undef: "error" -->
8383

8484
```javascript
85-
var randu = require( '@stdlib/random/base/randu' );
86-
var expf = require( '@stdlib/math/base/special/expf' );
85+
var uniform = require( '@stdlib/random/array/uniform' );
86+
var expf = require( './../lib' );
87+
88+
var opts = {
89+
'dtype': 'float32'
90+
};
8791

88-
var x;
92+
var x = uniform( 100, -50.0, 50.0, opts );
8993
var i;
9094

9195
for ( i = 0; i < 100; i++ ) {
92-
x = (randu()*100.0) - 50.0;
93-
console.log( 'e^%d = %d', x, expf( x ) );
96+
console.log( 'e^%f = %f', x, expf( x[ i ] ) );
9497
}
9598
```
9699

@@ -168,14 +171,17 @@ float stdlib_base_expf( const float x );
168171
#include <stdio.h>
169172
170173
int main( void ) {
171-
float x;
174+
float x[ 100 ];
172175
float v;
173176
int i;
177+
178+
for ( i = 0; i < 100; i++ ) {
179+
x[ i ] = ( ( (float)rand() / (float)RAND_MAX ) * 100.0f );
180+
}
174181
175182
for ( i = 0; i < 100; i++ ) {
176-
x = ( (float)rand() / (float)RAND_MAX ) * 100.0f;
177-
v = stdlib_base_expf( x );
178-
printf( "e^%f = %f\n", x, v );
183+
v = stdlib_base_expf( x[ i ] );
184+
printf( "e^%f = %f\n", x[ i ], v );
179185
}
180186
}
181187
```

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
{{alias}}( x )
3-
Evaluates the natural exponential function (single-precision).
3+
Evaluates the natural exponential function as a single-precision floating-point number.
44

55
Parameters
66
----------

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,17 @@
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-
2823
int main( void ) {
29-
float x;
24+
float x[ 100 ];
3025
float v;
3126
int i;
3227

3328
for ( i = 0; i < 100; i++ ) {
34-
x = random_uniform( 0.0, 100.0 );
35-
v = stdlib_base_expf( x );
36-
printf( "e^%f = %f\n", x, v );
29+
x[ i ] = ( ( (float)rand() / (float)RAND_MAX ) * 100.0f );
30+
}
31+
32+
for ( i = 0; i < 100; i++ ) {
33+
v = stdlib_base_expf( x[ i ] );
34+
printf( "e^%f = %f\n", x[ i ], v );
3735
}
3836
}

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
2222
var expf = require( './../lib' );
2323

24-
var x;
24+
var opts = {
25+
'dtype': 'float32'
26+
};
27+
28+
var x = uniform( 100, -50.0, 50.0, opts );
2529
var i;
2630

2731
for ( i = 0; i < 100; i++ ) {
28-
x = ( randu()*100.0 ) - 50.0;
29-
console.log( 'e^%f = %f', x, expf( x ) );
32+
console.log( 'e^%f = %f', x, expf( x[ i ] ) );
3033
}

0 commit comments

Comments
 (0)