File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
lib/node_modules/@stdlib/math/base/special/fast/minf/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 ) {
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 float rand_float ( void ) {
83
- int r = rand ();
84
- return ( float ) r / ( ( float ) RAND_MAX + 1.0f );
84
+ static float random_uniform ( const float min , const float max ) {
85
+ float v = ( float ) rand () / ( ( float ) RAND_MAX + 1.0f );
86
+ return min + ( v * ( max - min ) );
85
87
}
86
88
87
89
/**
@@ -98,8 +100,8 @@ static double benchmark( void ) {
98
100
int i ;
99
101
100
102
for ( i = 0 ; i < 100 ; i ++ ) {
101
- x [ i ] = ( 200 .0f * rand_float () ) - 100 .0f ;
102
- y [ i ] = ( 200 .0f * rand_float () ) - 100 .0f ;
103
+ x [ i ] = random_uniform ( -10 .0f, 10 .0f ) ;
104
+ y [ i ] = random_uniform ( -10 .0f, 10 .0f ) ;
103
105
}
104
106
105
107
t = tic ();
You can’t perform that action at this time.
0 commit comments