Skip to content

Commit 9e31f06

Browse files
authored
Apply suggestions from code review
Signed-off-by: Gunj Joshi <[email protected]>
1 parent e96cdca commit 9e31f06

File tree

5 files changed

+26
-44
lines changed

5 files changed

+26
-44
lines changed

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

Lines changed: 7 additions & 24 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]
23+
> Evaluate the natural [exponential function][exponential-function] as a single-precision floating-point number.
2424
2525
<section class="intro">
2626

@@ -59,10 +59,10 @@ Evaluates the natural [exponential function][exponential-function] as a single-p
5959

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

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

6767
v = expf( 0.0 );
6868
// returns 1.0
@@ -129,11 +129,11 @@ for ( i = 0; i < 100; i++ ) {
129129
Evaluates the natural [exponential function][exponential-function] as a single-precision floating-point number.
130130

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

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

139139
The function accepts the following arguments:
@@ -192,15 +192,6 @@ int main( void ) {
192192

193193
<section class="related">
194194

195-
* * *
196-
197-
## See Also
198-
199-
- <span class="package-name">[`@stdlib/math/base/special/exp10`][@stdlib/math/base/special/exp10]</span><span class="delimiter">: </span><span class="description">base 10 exponential function.</span>
200-
- <span class="package-name">[`@stdlib/math/base/special/exp2`][@stdlib/math/base/special/exp2]</span><span class="delimiter">: </span><span class="description">base 2 exponential function.</span>
201-
- <span class="package-name">[`@stdlib/math/base/special/expm1`][@stdlib/math/base/special/expm1]</span><span class="delimiter">: </span><span class="description">compute expf(x) - 1.</span>
202-
- <span class="package-name">[`@stdlib/math/base/special/ln`][@stdlib/math/base/special/ln]</span><span class="delimiter">: </span><span class="description">evaluate the natural logarithm of a double-precision floating-point number.</span>
203-
204195
</section>
205196

206197
<!-- /.related -->
@@ -215,14 +206,6 @@ int main( void ) {
215206

216207
<!-- <related-links> -->
217208

218-
[@stdlib/math/base/special/exp10]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/exp10
219-
220-
[@stdlib/math/base/special/exp2]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/exp2
221-
222-
[@stdlib/math/base/special/expm1]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/expm1
223-
224-
[@stdlib/math/base/special/ln]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/ln
225-
226209
<!-- </related-links> -->
227210

228211
</section>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
var bench = require( '@stdlib/bench' );
2424
var randu = require( '@stdlib/random/base/randu' );
2525
var Float32Array = require( '@stdlib/array/float32' );
26-
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2727
var pkg = require( './../package.json' ).name;
2828
var expf = require( './../lib' );
2929

@@ -45,12 +45,12 @@ bench( pkg, function benchmark( b ) {
4545
b.tic();
4646
for ( i = 0; i < b.iterations; i++ ) {
4747
y = expf( x[ i % len ] );
48-
if ( isnan( y ) ) {
48+
if ( isnanf( y ) ) {
4949
b.fail( 'should not return NaN' );
5050
}
5151
}
5252
b.toc();
53-
if ( isnan( y ) ) {
53+
if ( isnanf( y ) ) {
5454
b.fail( 'should not return NaN' );
5555
}
5656
b.pass( 'benchmark finished' );
@@ -72,12 +72,12 @@ bench( pkg+'::built-in', function benchmark( b ) {
7272
b.tic();
7373
for ( i = 0; i < b.iterations; i++ ) {
7474
y = Math.exp( x[ i % len ] ); // eslint-disable-line stdlib/no-builtin-math
75-
if ( isnan( y ) ) {
75+
if ( isnanf( y ) ) {
7676
b.fail( 'should not return NaN' );
7777
}
7878
}
7979
b.toc();
80-
if ( isnan( y ) ) {
80+
if ( isnanf( y ) ) {
8181
b.fail( 'should not return NaN' );
8282
}
8383
b.pass( 'benchmark finished' );

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var Float32Array = require( '@stdlib/array/float32' );
2626
var randu = require( '@stdlib/random/base/randu' );
27-
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2828
var tryRequire = require( '@stdlib/utils/try-require' );
2929
var pkg = require( './../package.json' ).name;
3030

@@ -54,12 +54,12 @@ bench( pkg+'::native', opts, function benchmark( b ) {
5454
b.tic();
5555
for ( i = 0; i < b.iterations; i++ ) {
5656
y = expf( x[ i % len ] );
57-
if ( isnan( y ) ) {
57+
if ( isnanf( y ) ) {
5858
b.fail( 'should not return NaN' );
5959
}
6060
}
6161
b.toc();
62-
if ( isnan( y ) ) {
62+
if ( isnanf( y ) ) {
6363
b.fail( 'should not return NaN' );
6464
}
6565
b.pass( 'benchmark finished' );

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,13 @@ static double tic( void ) {
7575
}
7676

7777
/**
78-
* Generates a random number on the interval [min,max).
78+
* Generates a random number on the interval [0,1).
7979
*
80-
* @param min minimum value (inclusive)
81-
* @param max maximum value (exclusive)
82-
* @return random number
80+
* @return random number
8381
*/
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) );
82+
static float rand_float( void ) {
83+
int r = rand();
84+
return (float)r / ( (float)RAND_MAX + 1.0f );
8785
}
8886

8987
/**
@@ -94,13 +92,14 @@ static float random_uniform( const float min, const float max ) {
9492
static double benchmark( void ) {
9593
double elapsed;
9694
float x[ 100 ];
97-
float y;
9895
double t;
96+
float y;
9997
int i;
10098

101-
for ( i = 0; i < 100; i++ ) {
102-
x[ i ] = random_uniform( -50.0, 50.0 );
99+
for ( i = 0; i < 100; i++ ) {
100+
x[ i ] = ( 100.0f * rand_float() ) - 50.0f;
103101
}
102+
104103
t = tic();
105104
for ( i = 0; i < ITERATIONS; i++ ) {
106105
y = stdlib_base_expf( x[ i % 100 ] );

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
Examples
1616
--------
1717
> var y = {{alias}}( 4.0 )
18-
54.598148345947266
18+
~54.5982
1919
> y = {{alias}}( -9.0 )
20-
0.00012340980174485594
20+
~1.234e-4
2121
> y = {{alias}}( 0.0 )
2222
1.0
2323
> y = {{alias}}( NaN )

0 commit comments

Comments
 (0)