File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
lib/node_modules/@stdlib/math/base/special/sinpi/benchmark/c/native Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -75,13 +75,15 @@ static double tic( void ) {
75
75
}
76
76
77
77
/**
78
- * Generates a random number on the interval [0,1 ).
78
+ * Generates a random number on the interval [min,max ).
79
79
*
80
- * @return random number
80
+ * @param min minimum value (inclusive)
81
+ * @param max maximum value (exclusive)
82
+ * @return random number
81
83
*/
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 ) );
85
87
}
86
88
87
89
/**
@@ -97,7 +99,7 @@ static double benchmark( void ) {
97
99
int i ;
98
100
99
101
for ( i = 0 ; i < 100 ; i ++ ) {
100
- x [ i ] = ( 1.0e7 * rand_double () ) - 5.0e6 ;
102
+ x [ i ] = random_uniform ( -5.0e6 , 5.0e6 ) ;
101
103
}
102
104
103
105
t = tic ();
You can’t perform that action at this time.
0 commit comments