Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var max = require( './../lib' );
Expand All @@ -35,11 +35,12 @@ bench( pkg, function benchmark( b ) {
var z;
var i;

x = uniform( 100, -500.0, 500.0 );
y = uniform( 100, -500.0, 500.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1000.0 ) - 500.0;
y = ( randu()*1000.0 ) - 500.0;
z = max( x, y );
z = max( x[ i%x.length ], y[ i%y.length ] );
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -58,11 +59,12 @@ bench( pkg+'::built-in', function benchmark( b ) {
var z;
var i;

x = uniform( 100, -500.0, 500.0 );
y = uniform( 100, -500.0, 500.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1000.0 ) - 500.0;
y = ( randu()*1000.0 ) - 500.0;
z = Math.max( x, y ); // eslint-disable-line stdlib/no-builtin-math
z = Math.max( x[ i%x.length ], y[ i%y.length ] ); // eslint-disable-line stdlib/no-builtin-math
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
Expand All @@ -44,11 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var z;
var i;

x = uniform( 100, -100.0, 100.0 );
y = uniform( 100, -100.0, 100.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*200.0 ) - 100.0;
y = ( randu()*200.0 ) - 100.0;
z = max( x, y );
z = max( x[ i%x.length ], y[ i%y.length ] );
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,20 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x;
double y;
double x[ 100 ];
double y[ 100 ];
double z;
double t;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( 1000.0*rand_double() ) - 500.0;
y[ i ] = ( 1000.0*rand_double() ) - 500.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 1000.0*rand_double() ) - 500.0;
y = ( 1000.0*rand_double() ) - 500.0;
z = fmax( x, y );
z = fmax( x[ i % 100 ], y[ i % 100 ] );
if ( z != z ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,20 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x[ 100 ];
double y[ 100 ];
double t;
double x;
double y;
double z;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( 200.0*rand_double() ) - 100.0;
y[ i ] = ( 200.0*rand_double() ) - 100.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 200.0*rand_double() ) - 100.0;
y = ( 200.0*rand_double() ) - 100.0;
z = stdlib_base_max( x, y );
z = stdlib_base_max( x[ i % 100 ], y[ i % 100 ] );
if ( z != z ) {
printf( "should not return NaN\n" );
break;
Expand Down
20 changes: 10 additions & 10 deletions lib/node_modules/@stdlib/math/base/special/max/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ tape( 'the function returns `NaN` if provided a `NaN`', function test( t ) {
var v;

v = max( NaN, 3.14 );
t.strictEqual( isnan( v ), true, 'returns NaN' );
t.strictEqual( isnan( v ), true, 'returns expected value' );

v = max( 3.14, NaN );
t.strictEqual( isnan( v ), true, 'returns NaN' );
t.strictEqual( isnan( v ), true, 'returns expected value' );

t.end();
});
Expand All @@ -52,10 +52,10 @@ tape( 'the function returns `+Infinity` if provided `+Infinity`', function test(
var v;

v = max( PINF, 3.14 );
t.strictEqual( v, PINF, 'returns +infinity' );
t.strictEqual( v, PINF, 'returns expected value' );

v = max( 3.14, PINF );
t.strictEqual( v, PINF, 'returns +infinity' );
t.strictEqual( v, PINF, 'returns expected value' );

t.end();
});
Expand All @@ -64,16 +64,16 @@ tape( 'the function returns a correctly signed zero', function test( t ) {
var v;

v = max( +0.0, -0.0 );
t.strictEqual( isPositiveZero( v ), true, 'returns +0' );
t.strictEqual( isPositiveZero( v ), true, 'returns expected value' );

v = max( -0.0, +0.0 );
t.strictEqual( isPositiveZero( v ), true, 'returns +0' );
t.strictEqual( isPositiveZero( v ), true, 'returns expected value' );

v = max( -0.0, -0.0 );
t.strictEqual( isNegativeZero( v ), true, 'returns -0' );
t.strictEqual( isNegativeZero( v ), true, 'returns expected value' );

v = max( +0.0, +0.0 );
t.strictEqual( isPositiveZero( v ), true, 'returns +0' );
t.strictEqual( isPositiveZero( v ), true, 'returns expected value' );

t.end();
});
Expand All @@ -82,10 +82,10 @@ tape( 'the function returns the maximum value', function test( t ) {
var v;

v = max( 4.2, 3.14 );
t.strictEqual( v, 4.2, 'returns max value' );
t.strictEqual( v, 4.2, 'returns expected value' );

v = max( -4.2, 3.14 );
t.strictEqual( v, 3.14, 'returns max value' );
t.strictEqual( v, 3.14, 'returns expected value' );

t.end();
});
20 changes: 10 additions & 10 deletions lib/node_modules/@stdlib/math/base/special/max/test/test.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ tape( 'the function returns `NaN` if provided a `NaN`', opts, function test( t )
var v;

v = max( NaN, 3.14 );
t.strictEqual( isnan( v ), true, 'returns NaN' );
t.strictEqual( isnan( v ), true, 'returns expected value' );

v = max( 3.14, NaN );
t.strictEqual( isnan( v ), true, 'returns NaN' );
t.strictEqual( isnan( v ), true, 'returns expected value' );

t.end();
});
Expand All @@ -61,10 +61,10 @@ tape( 'the function returns `Infinity` if provided `Infinity`', opts, function t
var v;

v = max( PINF, 3.14 );
t.strictEqual( v, PINF, 'returns infinity' );
t.strictEqual( v, PINF, 'returns expected value' );

v = max( 3.14, PINF );
t.strictEqual( v, PINF, 'returns infinity' );
t.strictEqual( v, PINF, 'returns expected value' );

t.end();
});
Expand All @@ -73,16 +73,16 @@ tape( 'the function returns a correctly signed zero', opts, function test( t ) {
var v;

v = max( +0.0, -0.0 );
t.strictEqual( isPositiveZero( v ), true, 'returns +0' );
t.strictEqual( isPositiveZero( v ), true, 'returns expected value' );

v = max( -0.0, +0.0 );
t.strictEqual( isPositiveZero( v ), true, 'returns +0' );
t.strictEqual( isPositiveZero( v ), true, 'returns expected value' );

v = max( -0.0, -0.0 );
t.strictEqual( isNegativeZero( v ), true, 'returns -0' );
t.strictEqual( isNegativeZero( v ), true, 'returns expected value' );

v = max( +0.0, +0.0 );
t.strictEqual( isPositiveZero( v ), true, 'returns +0' );
t.strictEqual( isPositiveZero( v ), true, 'returns expected value' );

t.end();
});
Expand All @@ -91,10 +91,10 @@ tape( 'the function returns the maximum value', opts, function test( t ) {
var v;

v = max( 4.2, 3.14 );
t.strictEqual( v, 4.2, 'returns max value' );
t.strictEqual( v, 4.2, 'returns expected value' );

v = max( -4.2, 3.14 );
t.strictEqual( v, 3.14, 'returns max value' );
t.strictEqual( v, 3.14, 'returns expected value' );

t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/array/uniform' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var pkg = require( './../package.json' ).name;
var maxf = require( './../lib' );
Expand All @@ -35,8 +35,12 @@ bench( pkg, function benchmark( b ) {
var z;
var i;

x = randu( 100, -100.0, 100.0 );
y = randu( 100, -100.0, 100.0 );
x = uniform( 100, -100.0, 100.0, {
'dtype': 'float32'
});
y = uniform( 100, -100.0, 100.0, {
'dtype': 'float32'
});

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/array/uniform' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
Expand All @@ -44,8 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var z;
var i;

x = randu( 100, -100.0, 100.0 );
y = randu( 100, -100.0, 100.0 );
x = uniform( 100, -100.0, 100.0, {
'dtype': 'float32'
});
y = uniform( 100, -100.0, 100.0, {
'dtype': 'float32'
});

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var maxn = require( './../lib' );
Expand All @@ -35,11 +35,12 @@ bench( pkg, function benchmark( b ) {
var z;
var i;

x = uniform( 100, -500.0, 500.0 );
y = uniform( 100, -500.0, 500.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1000.0 ) - 500.0;
y = ( randu()*1000.0 ) - 500.0;
z = maxn( x, y );
z = maxn( x[ i % x.length ], y[ i % y.length ] );
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -58,11 +59,12 @@ bench( pkg+'::built-in', function benchmark( b ) {
var z;
var i;

x = uniform( 100, -500.0, 500.0 );
y = uniform( 100, -500.0, 500.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1000.0 ) - 500.0;
y = ( randu()*1000.0 ) - 500.0;
z = Math.max( x, y ); // eslint-disable-line stdlib/no-builtin-math
z = Math.max( x[ i % x.length ], y[ i % y.length ] ); // eslint-disable-line stdlib/no-builtin-math
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,20 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x;
double y;
double x[ 100 ];
double y[ 100 ];
double z;
double t;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( 1000.0*rand_double() ) - 500.0;
y[ i ] = ( 1000.0*rand_double() ) - 500.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 1000.0*rand_double() ) - 500.0;
y = ( 1000.0*rand_double() ) - 500.0;
z = fmax( x, y );
z = fmax( x[ i % 100 ], y[ i % 100 ] );
if ( z != z ) {
printf( "should not return NaN\n" );
break;
Expand Down
Loading