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 @@ -89,20 +89,22 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double re[ 100 ];
double im[ 100 ];
double elapsed;
double re;
double im;
double t;
int i;

double complex z;

for ( i = 0; i < 100; i++ ) {
re[ i ] = ( 100.0*rand_double() ) - 50.0;
im[ i ] = ( 100.0*rand_double() ) - 50.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
re = ( 100.0*rand_double() ) - 50.0;
im = ( 100.0*rand_double() ) - 50.0;

z = ( cos( re ) + I * sin( re ) ) / exp( im );
z = ( cos( re[ i%100 ] ) + I * sin( re[ i%100 ] ) ) / exp( im[ 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 @@ -92,23 +92,26 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double re[ 100 ];
double im[ 100 ];
double elapsed;
double re;
double im;
double t;
int i;

stdlib_complex128_t z1;
stdlib_complex128_t z2;

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

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
re = ( 1000.0*rand_double() ) - 500.0;
im = ( 1000.0*rand_double() ) - 500.0;
z1 = stdlib_complex128( re, im );
z1 = stdlib_complex128( re[ i%100 ], im[ i%100 ] );

z2 = stdlib_base_ccis( z1 );
stdlib_complex128_reim( z2, &re, &im );
stdlib_complex128_reim( z2, &re[ i%100 ], &im[ i%100 ] );
if ( re != re ) {
printf( "should not return NaN\n" );
break;
Expand Down
22 changes: 11 additions & 11 deletions lib/node_modules/@stdlib/math/base/special/ccis/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ tape( 'if real component is `+Infinity`, all components are `NaN`', function tes
var v;

v = ccis( new Complex128( PINF, 0.0 ) );
t.strictEqual( isnan( real( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( imag( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( real( v ) ), true, 'returns expected value' );
t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' );
t.end();
});

tape( 'if real component is `-Infinity`, all components are `NaN`', function test( t ) {
var v;

v = ccis( new Complex128( NINF, 0.0 ) );
t.strictEqual( isnan( real( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( imag( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( real( v ) ), true, 'returns expected value' );
t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' );
t.end();
});

Expand All @@ -171,24 +171,24 @@ tape( 'if imaginary component is `-Infinity`, the function computes the correct
t.strictEqual( real( v ), PINF, 'returns +Infinity' );

// The imaginary component is computed as Infinity * 0.0 = NaN:
t.strictEqual( isnan( imag( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' );
t.end();
});

tape( 'if a real or imaginary component is `NaN`, all components are `NaN`', function test( t ) {
var v;

v = ccis( new Complex128( NaN, 3.0 ) );
t.strictEqual( isnan( real( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( imag( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( real( v ) ), true, 'returns expected value' );
t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' );

v = ccis( new Complex128( 5.0, NaN ) );
t.strictEqual( isnan( real( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( imag( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( real( v ) ), true, 'returns expected value' );
t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' );

v = ccis( new Complex128( NaN, NaN ) );
t.strictEqual( isnan( real( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( imag( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( real( v ) ), true, 'returns expected value' );
t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' );

t.end();
});
22 changes: 11 additions & 11 deletions lib/node_modules/@stdlib/math/base/special/ccis/test/test.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,17 @@ tape( 'if real component is `+Infinity`, all components are `NaN`', opts, functi
var v;

v = ccis( new Complex128( PINF, 0.0 ) );
t.strictEqual( isnan( real( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( imag( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( real( v ) ), true, 'returns expected value' );
t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' );
t.end();
});

tape( 'if real component is `-Infinity`, all components are `NaN`', opts, function test( t ) {
var v;

v = ccis( new Complex128( NINF, 0.0 ) );
t.strictEqual( isnan( real( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( imag( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( real( v ) ), true, 'returns expected value' );
t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' );
t.end();
});

Expand All @@ -181,24 +181,24 @@ tape( 'if imaginary component is `-Infinity`, the function computes the correct
t.strictEqual( real( v ), PINF, 'returns +Infinity' );

// The imaginary component is computed as Infinity * 0.0 = NaN:
t.strictEqual( isnan( imag( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' );
t.end();
});

tape( 'if a real or imaginary component is `NaN`, all components are `NaN`', opts, function test( t ) {
var v;

v = ccis( new Complex128( NaN, 3.0 ) );
t.strictEqual( isnan( real( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( imag( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( real( v ) ), true, 'returns expected value' );
t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' );

v = ccis( new Complex128( 5.0, NaN ) );
t.strictEqual( isnan( real( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( imag( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( real( v ) ), true, 'returns expected value' );
t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' );

v = ccis( new Complex128( NaN, NaN ) );
t.strictEqual( isnan( real( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( imag( v ) ), true, 'returns NaN' );
t.strictEqual( isnan( real( v ) ), true, 'returns expected value' );
t.strictEqual( isnan( imag( v ) ), true, '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/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 ceil = require( './../lib' );
Expand All @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

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

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

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1000.0 ) - 500.0;
y = Math.ceil( x ); // eslint-disable-line stdlib/no-builtin-math
y = Math.ceil( x[ i%x.length ] ); // eslint-disable-line stdlib/no-builtin-math
if ( isnan( y ) ) {
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 @@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var i;

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1000.0 ) - 500.0;
y = ceil( x );
y = ceil( x[ i%x.length ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,19 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double x[ 100 ];
double elapsed;
double x;
double y;
double t;
int i;

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

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

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

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

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

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 1000.0*rand_double() ) - 500.0;
y = stdlib_base_ceil( x );
y = stdlib_base_ceil( x[ i%100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ tape( 'the function returns the largest integer greater than or equal to a given

tape( 'the function returns `NaN` if provided a `NaN`', function test( t ) {
var val = ceil( NaN );
t.strictEqual( isnan( val ), true, 'returns NaN' );
t.strictEqual( isnan( val ), true, 'returns expected value' );
t.end();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ tape( 'the function returns the largest integer greater than or equal to a given

tape( 'the function returns `NaN` if provided a `NaN`', opts, function test( t ) {
var val = ceil( NaN );
t.strictEqual( isnan( val ), true, 'returns NaN' );
t.strictEqual( isnan( val ), true, 'returns expected value' );
t.end();
});

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 ceil10 = require( './../lib' );
Expand All @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

x = uniform( 100, -5.0e6, 5.0e6 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1.0e7 ) - 5.0e6;
y = ceil10( x );
y = ceil10( x[ i%x.length ] );
if ( isnan( y ) ) {
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 @@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var i;

x = uniform( 100, -5.0e6, 5.0e6 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 1.0e7 ) - 5.0e6;
y = ceil10( x );
y = ceil10( x[ i%x.length ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,19 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double x[ 100 ];
double elapsed;
double x;
double y;
double t;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( 1.0e7 * rand_double() ) - 5.0e6;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 1.0e7 * rand_double() ) - 5.0e6;
y = stdlib_base_ceil10( x );
y = stdlib_base_ceil10( x[ i%100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ tape( 'the function returns `-0` if provided `-0`', function test( t ) {

tape( 'the function returns `NaN` if provided a `NaN`', function test( t ) {
var v = ceil10( NaN );
t.strictEqual( isnan( v ), true, 'returns NaN' );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
});

Expand Down
Loading