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 @@ -91,19 +91,22 @@ static float rand_float( void ) {
static double benchmark( void ) {
double elapsed;
double t;
float re;
float im;
float re[ 100 ];
float im[ 100 ];
int i;

float complex z;
float complex y;

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

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
re = ( 1000.0*rand_float() ) - 500.0;
im = ( 1000.0*rand_float() ) - 500.0;
z = re + im*I;
y = roundf( crealf(z) ) + roundf( cimagf(z) )*I;
z = re[ i % 100 ] + im[ i % 100 ]*I;
y = roundf( crealf( z ) ) + roundf( cimagf( z ) )*I;
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,22 @@ static float rand_float( void ) {
*/
static double benchmark( void ) {
double elapsed;
float v[ 100 ];
double t;
float re;
float im;
float v;
int i;

stdlib_complex64_t x;
stdlib_complex64_t y;

for ( i = 0; i < 100; i++ ) {
v[ i ] = ( 1000.0f * rand_float() ) - 500.0f;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
v = ( 1000.0*rand_float() ) - 500.0;
x = stdlib_complex64( v, v );
x = stdlib_complex64( v[ i % 100 ], v[ i % 100 ] );
y = stdlib_base_croundf( x );
stdlib_complex64_reim( y, &re, &im );
if ( re != re ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "stdlib/math/base/special/roundf.h"
#include "stdlib/complex/float32/ctor.h"
#include "stdlib/complex/float32/reim.h"
#include <math.h>

/**
* Rounds each component of a single-precision complex floating-point number to the nearest integer.
Expand Down