Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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,19 +89,22 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double re[ 100 ];
double im[ 100 ];
double complex z;
double elapsed;
double re;
double im;
double y;
double t;
int i;

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;
z = re + im*I;
z = re[ i%100 ] + im[ i%100 ]*I;
y = cabs( z );
if ( y != y ) {
printf( "should not return NaN\n" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,23 @@ 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 y;
double t;
int i;

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

stdlib_complex128_t z;

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
re = ( 1000.0*rand_double() ) - 500.0;
im = ( 1000.0*rand_double() ) - 500.0;
z = stdlib_complex128( re, im );
z = stdlib_complex128( re[ i % 100 ], im[ i % 100 ] );
y = stdlib_base_cabs( z );
if ( y != y ) {
printf( "should not return NaN\n" );
Expand Down
6 changes: 3 additions & 3 deletions lib/node_modules/@stdlib/math/base/special/cabs/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ tape( 'if either the real or imaginary component is `NaN`, the function returns
var v;

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

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

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

t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ tape( 'if either the real or imaginary component is `NaN`, the function returns
var v;

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

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

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

t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,22 @@ double cabs2( double complex z ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double re[ 100 ];
double im[ 100 ];
double complex z;
double elapsed;
double re;
double im;
double y;
double t;
int i;

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;
z = re + im*I;
z = re[ i%100] + im[ i%100 ]*I;
y = cabs2( z );
if ( y != y ) {
printf( "should not return NaN\n" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,23 @@ 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 y;
double t;
int i;

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

stdlib_complex128_t z;

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
re = ( 1000.0*rand_double() ) - 500.0;
im = ( 1000.0*rand_double() ) - 500.0;
z = stdlib_complex128( re, im );
z = stdlib_complex128( re[ i % 100 ], im[ i % 100 ] );
y = stdlib_base_cabs2( z );
if ( y != y ) {
printf( "should not return NaN\n" );
Expand Down
6 changes: 3 additions & 3 deletions lib/node_modules/@stdlib/math/base/special/cabs2/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ tape( 'if either the real or imaginary component is `NaN`, the function returns
var v;

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

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

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

t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ tape( 'if either the real or imaginary component is `NaN`, the function returns
var v;

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

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

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

t.end();
});