File tree Expand file tree Collapse file tree 3 files changed +15
-10
lines changed
lib/node_modules/@stdlib/math/base/special/croundf Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -91,19 +91,22 @@ static float rand_float( void ) {
9191static double benchmark ( void ) {
9292 double elapsed ;
9393 double t ;
94- float re ;
95- float im ;
94+ float re [ 100 ] ;
95+ float im [ 100 ] ;
9696 int i ;
9797
9898 float complex z ;
9999 float complex y ;
100100
101+ for ( i = 0 ; i < 100 ; i ++ ) {
102+ re [ i ] = ( 1000.0f * rand_float () ) - 500.0f ;
103+ im [ i ] = ( 1000.0f * rand_float () ) - 500.0f ;
104+ }
105+
101106 t = tic ();
102107 for ( i = 0 ; i < ITERATIONS ; i ++ ) {
103- re = ( 1000.0 * rand_float () ) - 500.0 ;
104- im = ( 1000.0 * rand_float () ) - 500.0 ;
105- z = re + im * I ;
106- y = roundf ( crealf (z ) ) + roundf ( cimagf (z ) )* I ;
108+ z = re [ i % 100 ] + im [ i % 100 ]* I ;
109+ y = roundf ( crealf ( z ) ) + roundf ( cimagf ( z ) )* I ;
107110 if ( y != y ) {
108111 printf ( "should not return NaN\n" );
109112 break ;
Original file line number Diff line number Diff line change @@ -93,19 +93,22 @@ static float rand_float( void ) {
9393*/
9494static double benchmark ( void ) {
9595 double elapsed ;
96+ float v [ 100 ];
9697 double t ;
9798 float re ;
9899 float im ;
99- float v ;
100100 int i ;
101101
102102 stdlib_complex64_t x ;
103103 stdlib_complex64_t y ;
104104
105+ for ( i = 0 ; i < 100 ; i ++ ) {
106+ v [ i ] = ( 1000.0f * rand_float () ) - 500.0f ;
107+ }
108+
105109 t = tic ();
106110 for ( i = 0 ; i < ITERATIONS ; i ++ ) {
107- v = ( 1000.0 * rand_float () ) - 500.0 ;
108- x = stdlib_complex64 ( v , v );
111+ x = stdlib_complex64 ( v [ i % 100 ], v [ i % 100 ] );
109112 y = stdlib_base_croundf ( x );
110113 stdlib_complex64_reim ( y , & re , & im );
111114 if ( re != re ) {
Original file line number Diff line number Diff line change 2020#include "stdlib/math/base/special/roundf.h"
2121#include "stdlib/complex/float32/ctor.h"
2222#include "stdlib/complex/float32/reim.h"
23- #include <math.h>
2423
2524/**
2625* Rounds each component of a single-precision complex floating-point number to the nearest integer.
You can’t perform that action at this time.
0 commit comments