Package: MATH

MATH

nameinstructionbranchcomplexitylinemethod
MATH()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
acos(Number)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
acot(Number)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
asin(Number)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
atan(Number)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
cos(Number)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
cot(Number)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
exp(Number)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
fac(Number)
M: 19 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
ln(Number)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
log(Number)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
pi_f()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
rand(Number)
M: 24 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
sin(Number)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
sqrt(Number)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
srand(Number)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
srand2(Number)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
tan(Number)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * VDM Code Generator Runtime
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.codegen.runtime;
23:
24: import java.util.Random;
25:
26: public class MATH
27: {
28:
29:         public static final Number pi = 3.141592653589793;
30:         private static Random random = new Random();
31:         private static long seed = 0;
32:
33:         public static Number sin(Number v)
34:         {
35:                 return Math.sin(v.doubleValue());
36:         }
37:
38:         public static Number cos(Number v)
39:         {
40:                 return Math.cos(v.doubleValue());
41:         }
42:
43:         public static Number tan(Number a)
44:         {
45:                 return Math.tan(a.doubleValue());
46:         }
47:
48:         public static Number cot(Number a)
49:         {
50:                 return 1 / Math.tan(a.doubleValue());
51:         }
52:
53:         public static Number asin(Number a)
54:         {
55:                 return Math.asin(a.doubleValue());
56:         }
57:
58:         public static Number acos(Number a)
59:         {
60:                 return Math.acos(a.doubleValue());
61:         }
62:
63:         public static Number atan(Number v)
64:         {
65:                 return Math.atan(v.doubleValue());
66:         }
67:
68:         public static Number acot(Number a)
69:         {
70:                 return atan(1 / a.doubleValue());
71:         }
72:
73:         public static Number sqrt(Number a)
74:         {
75:                 return Math.sqrt(a.doubleValue());
76:         }
77:
78:         public static Number pi_f()
79:         {
80:                 return Math.PI;
81:         }
82:
83:         public static void srand(Number a)
84:         {
85:                 MATH.srand2(a);
86:         }
87:
88:         public static Number rand(Number a)
89:         {
90:                 long lv = a.longValue();
91:
92:•                if (seed == -1)
93:                 {
94:                         return lv;
95:•                } else if (lv == 0)
96:                 {
97:                         return 0;
98:                 } else
99:                 {
100:                         return Math.abs(random.nextLong() % lv);
101:                 }
102:         }
103:
104:         public static Number srand2(Number a)
105:         {
106:                 seed = a.longValue();
107:                 random.setSeed(seed);
108:                 return seed;
109:         }
110:
111:         public static Number exp(Number a)
112:         {
113:
114:                 return Math.exp(a.doubleValue());
115:         }
116:
117:         public static Number ln(Number a)
118:         {
119:
120:                 return Math.log(a.doubleValue());
121:         }
122:
123:         public static Number log(Number a)
124:         {
125:
126:                 return Math.log10(a.doubleValue());
127:         }
128:
129:         public static Number fac(Number a)
130:         {
131:•                return a.longValue() < 1 ? 1
132:                                 : a.longValue() * fac(a.longValue() - 1).longValue();
133:         }
134:
135: }