File tree Expand file tree Collapse file tree 2 files changed +20
-13
lines changed
lib/node_modules/@stdlib/math/base/special/cinvf/benchmark/c Expand file tree Collapse file tree 2 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -90,20 +90,22 @@ static float rand_float( void ) {
9090*/
9191static double benchmark ( void ) {
9292 double elapsed ;
93- float re ;
94- float im ;
93+ float x [ 100 ] ;
94+ float y [ 100 ] ;
9595 double t ;
9696 int i ;
9797
9898 float complex z1 ;
9999 float complex z2 ;
100100
101+ for ( i = 0 ; i < 100 ; i ++ ) {
102+ x [ i ] = ( 20.0f * rand_float () ) - 10.0f ;
103+ y [ i ] = ( 2048.0f * rand_float () ) - 1024.0f ;
104+ }
105+
101106 t = tic ();
102107 for ( i = 0 ; i < ITERATIONS ; i ++ ) {
103- re = ( 1000.0f * rand_float () ) - 500.0f ;
104- im = ( 1000.0f * rand_float () ) - 500.0f ;
105- z1 = re + im * I ;
106-
108+ z1 = x [ i % 100 ] + y [ i % 100 ]* I ;
107109 z2 = 1.0f / z1 ;
108110 if ( z2 != z2 ) {
109111 printf ( "should not return NaN\n" );
Original file line number Diff line number Diff line change @@ -96,18 +96,23 @@ static double benchmark( void ) {
9696 float re ;
9797 float im ;
9898 double t ;
99- float v ;
99+ float x [ 100 ];
100+ float y [ 100 ];
100101 int i ;
101102
102- stdlib_complex64_t x ;
103- stdlib_complex64_t y ;
103+ stdlib_complex64_t a ;
104+ stdlib_complex64_t b ;
105+
106+ for ( i = 0 ; i < 100 ; i ++ ) {
107+ x [ i ] = ( 20.0f * rand_float () ) - 10.0f ;
108+ y [ i ] = ( 2048.0f * rand_float () ) - 1024.0f ;
109+ }
104110
105111 t = tic ();
106112 for ( i = 0 ; i < ITERATIONS ; i ++ ) {
107- v = ( 1000.0f * rand_float () ) - 500.0f ;
108- x = stdlib_complex64 ( v , v );
109- y = stdlib_base_cinvf ( x );
110- stdlib_complex64_reim ( y , & re , & im );
113+ a = stdlib_complex64 ( x [ i % 100 ], y [ i % 100 ] );
114+ b = stdlib_base_cinvf ( a );
115+ stdlib_complex64_reim ( b , & re , & im );
111116 if ( re != re ) {
112117 printf ( "unexpected result\n" );
113118 break ;
You can’t perform that action at this time.
0 commit comments