First NIT release and new clean mercurial repository
[nit.git] / lib / standard / math_nit.h
1 #ifndef __MATH_NIT_H
2 #define __MATH_NIT_H
3 /* This file is part of NIT ( http://www.nitlanguage.org ).
4 *
5 * Copyright 2004-2008 Jean Privat <jean@pryen.org>
6 *
7 * This file is free software, which comes along with NIT. This software is
8 * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
10 * PARTICULAR PURPOSE. You can modify it is you want, provided this header
11 * is kept unaltered, and a notification of the changes is added.
12 * You are allowed to redistribute it and sell it, alone or is a part of
13 * another product.
14 */
15
16 #include <stdlib.h>
17 #include <math.h>
18 #include <time.h>
19
20 #define kernel_Int_Int_rand_0(self) ((int)(((double)(self))*rand()/(RAND_MAX+1.0)))
21 #define kernel_Float_Float_sqrt_0(self) sqrt(self)
22 #define kernel_Float_Float_cos_0(self) cos(self)
23 #define kernel_Float_Float_sin_0(self) sin(self)
24 #define kernel_Float_Float_tan_0(self) tan(self)
25 #define kernel_Float_Float_acos_0(self) acos(self)
26 #define kernel_Float_Float_asin_0(self) asin(self)
27 #define kernel_Float_Float_atan_0(self) atan(self)
28 #define kernel_Float_Float_pow_1(self, p0) pow(self, p0)
29 #define kernel_Float_Float_log_0(self) log(self)
30 #define kernel_Float_Float_exp_0(self) exp(self)
31 #define kernel_Float_Float_rand_0(self) (((self)*rand())/(RAND_MAX+1.0))
32 #define kernel_Any_Any_atan2_2(self, p0, p1) (atan2((p0),(p1)))
33 #define kernel_Any_Any_pi_0(self) (3.14159265)
34 #define kernel_Any_Any_srand_from_1(self, p0) (srand((p0)))
35 #define kernel_Any_Any_srand_0(self) (srand(time(NULL)))
36
37 #endif