File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
lib/node_modules/@stdlib/math/base/special/kernel-tanf/benchmark/c/native Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -75,13 +75,15 @@ static double tic( void ) {
7575}
7676
7777/**
78- * Generates a random number on the interval [0,1 ).
78+ * Generates a random number on the interval [min,max ).
7979*
80- * @return random number
80+ * @param min minimum value (inclusive)
81+ * @param max maximum value (exclusive)
82+ * @return random number
8183*/
82- static double rand_double ( void ) {
83- int r = rand ();
84- return ( double ) r / ( ( double ) RAND_MAX + 1.0 );
84+ static double random_uniform ( const double min , const double max ) {
85+ double v = ( double ) rand () / ( ( double ) RAND_MAX + 1.0 );
86+ return min + ( v * ( max - min ) );
8587}
8688
8789/**
@@ -90,14 +92,14 @@ static double rand_double( void ) {
9092* @return elapsed time in seconds
9193*/
9294static double benchmark ( void ) {
93- double elapsed ;
9495 double x [ 100 ];
96+ double elapsed ;
9597 double t ;
9698 float z ;
9799 int i ;
98100
99101 for ( i = 0 ; i < 100 ; i ++ ) {
100- x [ i ] = ( ( rand_double () * 2.0 ) - 1.0 ) * 0.7853981633974483 ;
102+ x [ i ] = random_uniform ( -0.7853981633974483 , 0.7853981633974483 ) ;
101103 }
102104
103105 t = tic ();
You can’t perform that action at this time.
0 commit comments