Skip to content

Commit c24de14

Browse files
committed
chore: clean-up docs, benchmarks, and examples
1 parent e1a4f1c commit c24de14

File tree

5 files changed

+34
-25
lines changed

5 files changed

+34
-25
lines changed

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

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

21-
# Absolute Value
21+
# abs
2222

2323
> Compute the [absolute value][absolute-value] of a double-precision floating-point number.
2424
@@ -33,7 +33,7 @@ The [absolute value][absolute-value] is defined as
3333
```
3434

3535
<!-- <div class="equation" align="center" data-raw-text="|x| = \begin{cases} x &amp; \textrm{if}\ x \geq 0 \\ -x &amp; \textrm{if}\ x &lt; 0\end{cases}" data-equation="eq:absolute_value">
36-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/C:\Users\pb\Documents\GitHub\stdlib\lib\node_modules\@stdlib\math\base\special\abs\docs\img\equation_absolute_value.svg" alt="Absolute value">
36+
<img src="" alt="Absolute value">
3737
<br>
3838
</div> -->
3939

@@ -83,16 +83,16 @@ v = abs( NaN );
8383
<!-- eslint no-undef: "error" -->
8484

8585
```javascript
86-
var randu = require( '@stdlib/random/base/randu' );
87-
var round = require( '@stdlib/math/base/special/round' );
86+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
8887
var abs = require( '@stdlib/math/base/special/abs' );
8988

90-
var rand;
91-
var i;
89+
var x = discreteUniform( 100, -100, 100, {
90+
'dtype': 'float64'
91+
});
9292

93-
for ( i = 0; i < 100; i++ ) {
94-
rand = round( randu() * 100.0 ) - 50.0;
95-
console.log( 'abs(%d) = %d', rand, abs( rand ) );
93+
var i;
94+
for ( i = 0; i < x.length; i++ ) {
95+
console.log( 'abs(%d) = %d', x[ i ], abs( x[ i ] ) );
9696
}
9797
```
9898

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var pkg = require( './../package.json' ).name;
2727
var abs = require( './../lib' );
@@ -34,10 +34,13 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37+
x = uniform( 100, -100.0, 100.0, {
38+
'dtype': 'generic'
39+
});
40+
3741
b.tic();
3842
for ( i = 0; i < b.iterations; i++ ) {
39-
x = ( randu()*1000.0 ) - 500.0;
40-
y = abs( x );
43+
y = abs( x[ i%x.length ] );
4144
if ( isnan( y ) ) {
4245
b.fail( 'should not return NaN' );
4346
}
@@ -55,10 +58,13 @@ bench( pkg+'::built-in', function benchmark( b ) {
5558
var y;
5659
var i;
5760

61+
x = uniform( 100, -100.0, 100.0, {
62+
'dtype': 'generic'
63+
});
64+
5865
b.tic();
5966
for ( i = 0; i < b.iterations; i++ ) {
60-
x = ( randu()*1000.0 ) - 500.0;
61-
y = Math.abs( x ); // eslint-disable-line stdlib/no-builtin-math
67+
y = Math.abs( x[ i%x.length ] ); // eslint-disable-line stdlib/no-builtin-math
6268
if ( isnan( y ) ) {
6369
b.fail( 'should not return NaN' );
6470
}

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

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

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
@@ -43,10 +43,13 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4343
var y;
4444
var i;
4545

46+
x = uniform( 100, -100.0, 100.0, {
47+
'dtype': 'generic'
48+
});
49+
4650
b.tic();
4751
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu()*1000.0 ) - 500.0;
49-
y = abs( x );
52+
y = abs( x[ i%x.length ] );
5053
if ( isnan( y ) ) {
5154
b.fail( 'should not return NaN' );
5255
}

lib/node_modules/@stdlib/math/base/special/abs/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-
* Computes the absolute value of double-precision floating-point number `x`.
22+
* Computes the absolute value of a double-precision floating-point number `x`.
2323
*
2424
* @param x - input value
2525
* @returns absolute value

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

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

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
22-
var round = require( '@stdlib/math/base/special/round' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2322
var abs = require( './../lib' );
2423

25-
var rand;
26-
var i;
24+
var x = discreteUniform( 100, -100, 100, {
25+
'dtype': 'float64'
26+
});
2727

28-
for ( i = 0; i < 100; i++ ) {
29-
rand = round( randu() * 100.0 ) - 50.0;
30-
console.log( 'abs(%d) = %d', rand, abs( rand ) );
28+
var i;
29+
for ( i = 0; i < x.length; i++ ) {
30+
console.log( 'abs(%d) = %d', x[ i ], abs( x[ i ] ) );
3131
}

0 commit comments

Comments
 (0)