Skip to content

Commit 98ed32a

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents 3560ebc + dac7fbc commit 98ed32a

File tree

101 files changed

+704
-629
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+704
-629
lines changed

Diff for: lib/node_modules/@stdlib/math/base/special/fast/abs/README.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,16 @@ v = abs( NaN );
9797
<!-- eslint no-undef: "error" -->
9898

9999
```javascript
100-
var randu = require( '@stdlib/random/base/randu' );
101-
var round = require( '@stdlib/math/base/special/round' );
100+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
101+
var logEachMap = require( '@stdlib/console/log-each-map' );
102102
var abs = require( '@stdlib/math/base/special/fast/abs' );
103103
104-
var rand;
105-
var i;
104+
var opts = {
105+
'dtype': 'float64'
106+
};
107+
var x = discreteUniform( 100, -50, 50, opts );
106108
107-
for ( i = 0; i < 100; i++ ) {
108-
rand = round( randu() * 100.0 ) - 50.0;
109-
console.log( 'abs(%d) = %d', rand, abs( rand ) );
110-
}
109+
logEachMap( 'abs(%d) = %d', x, abs );
111110
```
112111

113112
</section>

Diff for: lib/node_modules/@stdlib/math/base/special/fast/abs/benchmark/benchmark.js

+6-3
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, -5000.0, 5000.0, {
38+
'dtype': 'float64'
39+
});
40+
3741
b.tic();
3842
for ( i = 0; i < b.iterations; i++ ) {
39-
x = ( randu()*10000.0 ) - 5000.0;
40-
y = abs( x );
43+
y = abs( x[ i%x.length ] );
4144
if ( isnan( y ) ) {
4245
b.fail( 'should not return NaN' );
4346
}

Diff for: lib/node_modules/@stdlib/math/base/special/fast/abs/benchmark/benchmark.native.js

+6-3
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, -5000.0, 5000.0, {
47+
'dtype': 'float64'
48+
});
49+
4650
b.tic();
4751
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu() * 10000.0 ) - 5000.0;
49-
y = abs( x );
52+
y = abs( x[ i%x.length ] );
5053
if ( isnan( y ) ) {
5154
b.fail( 'should not return NaN' );
5255
}

Diff for: lib/node_modules/@stdlib/math/base/special/fast/abs/benchmark/c/native/benchmark.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,18 @@ static double rand_double( void ) {
9191
*/
9292
static double benchmark( void ) {
9393
double elapsed;
94-
double x;
94+
double x[ 100 ];
9595
double y;
9696
double t;
9797
int i;
9898

99+
for ( i = 0; i < 100; i++ ) {
100+
x[ i ] = ( 10000.0 * rand_double() ) - 5000.0;
101+
}
102+
99103
t = tic();
100104
for ( i = 0; i < ITERATIONS; i++ ) {
101-
x = ( 10000.0 * rand_double() ) - 5000.0;
102-
y = stdlib_base_fast_abs( x );
105+
y = stdlib_base_fast_abs( x[ i%100 ] );
103106
if ( y != y ) {
104107
printf( "should not return NaN\n" );
105108
break;

Diff for: lib/node_modules/@stdlib/math/base/special/fast/abs/examples/index.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
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' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2323
var abs = require( './../lib' );
2424

25-
var rand;
26-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = discreteUniform( 100, -50, 50, opts );
2729

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

Diff for: lib/node_modules/@stdlib/math/base/special/fast/abs/test/test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,26 @@ tape( 'main export is a function', function test( t ) {
3838
});
3939

4040
tape( 'the function computes the absolute value of a number', function test( t ) {
41-
t.strictEqual( abs( -2.0 ), 2.0, 'negative number' );
42-
t.strictEqual( abs( 3.0 ), 3.0, 'positive number' );
43-
t.strictEqual( abs( 0.0 ), 0.0, 'zero' );
44-
t.strictEqual( abs( -PI ), PI, 'pi' );
41+
t.strictEqual( abs( -2.0 ), 2.0, 'returns expected value' );
42+
t.strictEqual( abs( 3.0 ), 3.0, 'returns expected value' );
43+
t.strictEqual( abs( 0.0 ), 0.0, 'returns expected value' );
44+
t.strictEqual( abs( -PI ), PI, 'returns expected value' );
4545
t.end();
4646
});
4747

4848
tape( 'the function returns `-0` if provided `-0` (not IEEE 754 compliant)', function test( t ) {
49-
t.strictEqual( isNegativeZero( abs( -0.0 ) ), true, 'returns negative zero' );
49+
t.strictEqual( isNegativeZero( abs( -0.0 ) ), true, 'returns expected value' );
5050
t.end();
5151
});
5252

5353
tape( 'the function computes the absolute value of `infinity`', function test( t ) {
54-
t.strictEqual( abs( PINF ), PINF, 'returns +infinity' );
55-
t.strictEqual( abs( NINF ), PINF, 'returns +infinity' );
54+
t.strictEqual( abs( PINF ), PINF, 'returns expected value' );
55+
t.strictEqual( abs( NINF ), PINF, 'returns expected value' );
5656
t.end();
5757
});
5858

5959
tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) {
6060
var v = abs( NaN );
61-
t.strictEqual( isnan( v ), true, 'returns NaN' );
61+
t.strictEqual( isnan( v ), true, 'returns expected value' );
6262
t.end();
6363
});

Diff for: lib/node_modules/@stdlib/math/base/special/fast/abs/test/test.native.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,26 @@ tape( 'main export is a function', opts, function test( t ) {
4747
});
4848

4949
tape( 'the function computes the absolute value of a number', opts, function test( t ) {
50-
t.strictEqual( abs( -2.0 ), 2.0, 'negative number' );
51-
t.strictEqual( abs( 3.0 ), 3.0, 'positive number' );
52-
t.strictEqual( abs( 0.0 ), 0.0, 'zero' );
53-
t.strictEqual( abs( -PI ), PI, 'pi' );
50+
t.strictEqual( abs( -2.0 ), 2.0, 'returns expected value' );
51+
t.strictEqual( abs( 3.0 ), 3.0, 'returns expected value' );
52+
t.strictEqual( abs( 0.0 ), 0.0, 'returns expected value' );
53+
t.strictEqual( abs( -PI ), PI, 'returns expected value' );
5454
t.end();
5555
});
5656

5757
tape( 'the function returns `-0` if provided `-0` (not IEEE 754 compliant)', opts, function test( t ) {
58-
t.strictEqual( isNegativeZero( abs( -0.0 ) ), true, 'returns negative zero' );
58+
t.strictEqual( isNegativeZero( abs( -0.0 ) ), true, 'returns expected value' );
5959
t.end();
6060
});
6161

6262
tape( 'the function computes the absolute value of `infinity`', opts, function test( t ) {
63-
t.strictEqual( abs( PINF ), PINF, 'returns +infinity' );
64-
t.strictEqual( abs( NINF ), PINF, 'returns +infinity' );
63+
t.strictEqual( abs( PINF ), PINF, 'returns expected value' );
64+
t.strictEqual( abs( NINF ), PINF, 'returns expected value' );
6565
t.end();
6666
});
6767

6868
tape( 'if provided `NaN`, the function returns `NaN`', opts, function test( t ) {
6969
var v = abs( NaN );
70-
t.strictEqual( isnan( v ), true, 'returns NaN' );
70+
t.strictEqual( isnan( v ), true, 'returns expected value' );
7171
t.end();
7272
});

Diff for: lib/node_modules/@stdlib/math/base/special/fast/acosh/README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,16 @@ var v = acosh( 0.0 );
7979
<!-- eslint no-undef: "error" -->
8080

8181
```javascript
82-
var linspace = require( '@stdlib/array/base/linspace' );
82+
var uniform = require( '@stdlib/random/array/uniform' );
83+
var logEachMap = require( '@stdlib/console/log-each-map' );
8384
var acosh = require( '@stdlib/math/base/special/fast/acosh' );
8485
85-
var x = linspace( 1.0, 5.0, 103 );
86+
var opts = {
87+
'dtype': 'float64'
88+
};
89+
var x = uniform( 103, 1.0, 5.0, opts );
8690
87-
var i;
88-
for ( i = 0; i < x.length; i++ ) {
89-
console.log( acosh( x[ i ] ) );
90-
}
91+
logEachMap( 'acosh(%0.4f) = %0.4f', x, acosh );
9192
```
9293

9394
</section>

Diff for: lib/node_modules/@stdlib/math/base/special/fast/acosh/benchmark/benchmark.js

+6-3
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 acosh = require( './../lib' );
@@ -34,10 +34,13 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37+
x = uniform( 100, 1.0, 100.0, {
38+
'dtype': 'float64'
39+
});
40+
3741
b.tic();
3842
for ( i = 0; i < b.iterations; i++ ) {
39-
x = 1.0 + ( randu()*100.0 );
40-
y = acosh( x );
43+
y = acosh( x[ i%x.length ] );
4144
if ( isnan( y ) ) {
4245
b.fail( 'should not return NaN' );
4346
}

Diff for: lib/node_modules/@stdlib/math/base/special/fast/acosh/benchmark/benchmark.native.js

+6-3
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, 1.0, 100.0, {
47+
'dtype': 'float64'
48+
});
49+
4650
b.tic();
4751
for ( i = 0; i < b.iterations; i++ ) {
48-
x = 1.0 + ( randu()*100.0 );
49-
y = acosh( x );
52+
y = acosh( x[ i%x.length ] );
5053
if ( isnan( y ) ) {
5154
b.fail( 'should not return NaN' );
5255
}

Diff for: lib/node_modules/@stdlib/math/base/special/fast/acosh/benchmark/c/native/benchmark.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,18 @@ static double rand_double( void ) {
9191
*/
9292
static double benchmark( void ) {
9393
double elapsed;
94-
double x;
94+
double x[ 100 ];
9595
double y;
9696
double t;
9797
int i;
9898

99+
for ( i = 0; i < 100; i++ ) {
100+
x[ i ] = ( 100.0 * rand_double() ) + 1.0;
101+
}
102+
99103
t = tic();
100104
for ( i = 0; i < ITERATIONS; i++ ) {
101-
x = ( 100.0 * rand_double() ) + 1.0;
102-
y = stdlib_base_fast_acosh( x );
105+
y = stdlib_base_fast_acosh( x[ i%100 ] );
103106
if ( y != y ) {
104107
printf( "should not return NaN\n" );
105108
break;

Diff for: lib/node_modules/@stdlib/math/base/special/fast/acosh/examples/index.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818

1919
'use strict';
2020

21-
var linspace = require( '@stdlib/array/base/linspace' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var acosh = require( './../lib' );
2324

24-
var x = linspace( 1.0, 5.0, 103 );
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = uniform( 103, 1.0, 5.0, opts );
2529

26-
var i;
27-
for ( i = 0; i < x.length; i++ ) {
28-
console.log( 'acosh(%d) = %d', x[ i ], acosh( x[ i ] ) );
29-
}
30+
logEachMap( 'acosh(%0.4f) = %0.4f', x, acosh );

Diff for: lib/node_modules/@stdlib/math/base/special/fast/acosh/test/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ tape( 'the function computes the hyperbolic arccosine for huge values', function
142142

143143
tape( 'the function returns `NaN` if provided a `NaN`', function test( t ) {
144144
var v = acosh( NaN );
145-
t.strictEqual( isnan( v ), true, 'returns NaN' );
145+
t.strictEqual( isnan( v ), true, 'returns expected value' );
146146
t.end();
147147
});
148148

@@ -152,7 +152,7 @@ tape( 'the function returns `NaN` if provided value less than `1`', function tes
152152

153153
for ( i = 0; i < 1e3; i++ ) {
154154
v = -(randu()*1.0e6) + (1.0-EPS);
155-
t.strictEqual( isnan( acosh( v ) ), true, 'returns NaN when provided '+v );
155+
t.strictEqual( isnan( acosh( v ) ), true, 'returns expected value when provided '+v );
156156
}
157157
t.end();
158158
});

Diff for: lib/node_modules/@stdlib/math/base/special/fast/acosh/test/test.native.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ tape( 'the function computes the hyperbolic arccosine for huge values', opts, fu
151151

152152
tape( 'the function returns `NaN` if provided a `NaN`', opts, function test( t ) {
153153
var v = acosh( NaN );
154-
t.strictEqual( isnan( v ), true, 'returns NaN' );
154+
t.strictEqual( isnan( v ), true, 'returns expected value' );
155155
t.end();
156156
});
157157

@@ -161,7 +161,7 @@ tape( 'the function returns `NaN` if provided value less than `1`', opts, functi
161161

162162
for ( i = 0; i < 1e3; i++ ) {
163163
v = -(randu()*1.0e6) + (1.0-EPS);
164-
t.strictEqual( isnan( acosh( v ) ), true, 'returns NaN when provided '+v );
164+
t.strictEqual( isnan( acosh( v ) ), true, 'returns expected value when provided '+v );
165165
}
166166
t.end();
167167
});

Diff for: lib/node_modules/@stdlib/math/base/special/fast/alpha-max-plus-beta-min/README.md

+8-12
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,17 @@ var h = hypot( 5.0, 12.0 );
112112
<!-- eslint no-undef: "error" -->
113113

114114
```javascript
115-
var randu = require( '@stdlib/random/base/randu' );
116-
var round = require( '@stdlib/math/base/special/round' );
115+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
116+
var logEachMap = require( '@stdlib/console/log-each-map' );
117117
var ampbm = require( '@stdlib/math/base/special/fast/alpha-max-plus-beta-min' );
118118

119-
var x;
120-
var y;
121-
var h;
122-
var i;
119+
var opts = {
120+
'dtype': 'float64'
121+
};
122+
var x = discreteUniform( 100, -50, 50, opts );
123+
var y = discreteUniform( 100, -50, 50, opts );
123124

124-
for ( i = 0; i < 100; i++ ) {
125-
x = round( randu()*100.0 ) - 50.0;
126-
y = round( randu()*100.0 ) - 50.0;
127-
h = ampbm( x, y );
128-
console.log( 'hypot(%d,%d) = %d', x, y, h );
129-
}
125+
logEachMap( 'hypot(%d,%d) = %0.4f', x, y, ampbm );
130126
```
131127

132128
</section>

Diff for: lib/node_modules/@stdlib/math/base/special/fast/alpha-max-plus-beta-min/examples/index.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -18,18 +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' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2323
var ampbm = require( './../lib' );
2424

25-
var x;
26-
var y;
27-
var h;
28-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = discreteUniform( 100, -50, 50, opts );
29+
var y = discreteUniform( 100, -50, 50, opts );
2930

30-
for ( i = 0; i < 100; i++ ) {
31-
x = round( randu()*100.0 ) - 50.0;
32-
y = round( randu()*100.0 ) - 50.0;
33-
h = ampbm( x, y );
34-
console.log( 'hypot(%d,%d) = %d', x, y, h );
35-
}
31+
logEachMap( 'hypot(%d,%d) = %0.4f', x, y, ampbm );

0 commit comments

Comments
 (0)