mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
rename random(..) -> _random(..) to avoid conflict with similar function name <stdlib.h>
This commit is contained in:
parent
31c145b773
commit
bc950d502a
@ -27,7 +27,7 @@
|
|||||||
* \param[in] b upper limit
|
* \param[in] b upper limit
|
||||||
* \returns random number in the range \f$[a,b]\f$
|
* \returns random number in the range \f$[a,b]\f$
|
||||||
*/
|
*/
|
||||||
double random(double a, double b)
|
double _random(double a, double b)
|
||||||
{
|
{
|
||||||
return ((b - a) * (rand() % 100) / 100.f) + a;
|
return ((b - a) * (rand() % 100) / 100.f) + a;
|
||||||
}
|
}
|
||||||
@ -187,8 +187,8 @@ void test_circle(double *const *data, int N)
|
|||||||
#endif
|
#endif
|
||||||
for (i = 0; i < N; i++)
|
for (i = 0; i < N; i++)
|
||||||
{
|
{
|
||||||
double r = random(a_r, b_r); // random radius
|
double r = _random(a_r, b_r); // random radius
|
||||||
double theta = random(a_t, b_t); // random theta
|
double theta = _random(a_t, b_t); // random theta
|
||||||
data[i][0] = r * cos(theta); // convert from polar to cartesian
|
data[i][0] = r * cos(theta); // convert from polar to cartesian
|
||||||
data[i][1] = r * sin(theta);
|
data[i][1] = r * sin(theta);
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ void test1()
|
|||||||
#endif
|
#endif
|
||||||
// preallocate with random initial weights
|
// preallocate with random initial weights
|
||||||
for (j = 0; j < features; j++)
|
for (j = 0; j < features; j++)
|
||||||
W[i][j] = random(-1, 1);
|
W[i][j] = _random(-1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,9 +266,9 @@ void test_lamniscate(double *const *data, int N)
|
|||||||
#endif
|
#endif
|
||||||
for (i = 0; i < N; i++)
|
for (i = 0; i < N; i++)
|
||||||
{
|
{
|
||||||
double dx = random(-dr, dr); // random change in x
|
double dx = _random(-dr, dr); // random change in x
|
||||||
double dy = random(-dr, dr); // random change in y
|
double dy = _random(-dr, dr); // random change in y
|
||||||
double theta = random(0, M_PI); // random theta
|
double theta = _random(0, M_PI); // random theta
|
||||||
data[i][0] = dx + cos(theta); // convert from polar to cartesian
|
data[i][0] = dx + cos(theta); // convert from polar to cartesian
|
||||||
data[i][1] = dy + sin(2. * theta) / 2.f;
|
data[i][1] = dy + sin(2. * theta) / 2.f;
|
||||||
}
|
}
|
||||||
@ -313,7 +313,7 @@ void test2()
|
|||||||
#endif
|
#endif
|
||||||
// preallocate with random initial weights
|
// preallocate with random initial weights
|
||||||
for (j = 0; j < features; j++)
|
for (j = 0; j < features; j++)
|
||||||
W[i][j] = random(-1, 1);
|
W[i][j] = _random(-1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user