forked from github/server
use correct type for PI (double).
promote defines to platform-header.
This commit is contained in:
parent
7ad5c4b3f2
commit
db07cbed6b
2 changed files with 8 additions and 4 deletions
|
@ -48,4 +48,10 @@ char * strdup(const char *s);
|
||||||
int mkdir(const char *pathname, int mode);
|
int mkdir(const char *pathname, int mode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* do not use M_PI, use one of these instead: */
|
||||||
|
#define PI_F 3.1415926535897932384626433832795F
|
||||||
|
#define PI_D 3.1415926535897932384626433832795
|
||||||
|
#define PI_L 3.1415926535897932384626433832795L
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,8 +28,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#define PI_L 3.1415926535897932384626433832795L
|
|
||||||
|
|
||||||
int lovar(double xpct_x2)
|
int lovar(double xpct_x2)
|
||||||
{
|
{
|
||||||
int n = (int)(xpct_x2 * 500) + 1;
|
int n = (int)(xpct_x2 * 500) + 1;
|
||||||
|
@ -51,10 +49,10 @@ double normalvariate(double mu, double sigma)
|
||||||
if (phase == 0) {
|
if (phase == 0) {
|
||||||
U = (rng_int() + 1.) / (RNG_RAND_MAX + 2.);
|
U = (rng_int() + 1.) / (RNG_RAND_MAX + 2.);
|
||||||
V = rng_int() / (RNG_RAND_MAX + 1.);
|
V = rng_int() / (RNG_RAND_MAX + 1.);
|
||||||
Z = sqrt(-2 * log(U)) * sin(2 * PI_L * V);
|
Z = sqrt(-2 * log(U)) * sin(2 * PI_D * V);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Z = sqrt(-2 * log(U)) * cos(2 * PI_L * V);
|
Z = sqrt(-2 * log(U)) * cos(2 * PI_D * V);
|
||||||
}
|
}
|
||||||
phase = 1 - phase;
|
phase = 1 - phase;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue