DEADSOFTWARE

Исправлены переводы строк в модуле Reals
[dsw-obn.git] / rtl / java / CPMath.java
1 import java.lang.Math;
3 public class CPMath
4 {
5 public static double ArcCos(double x)
6 {
7 return Math.acos(x);
8 }
10 public static double ArcCosh(double x)
11 {
12 return Ln(x + Sqrt(x * x - 1.0));
13 }
15 public static double ArcSin(double x)
16 {
17 return Math.asin(x);
18 }
20 public static double ArcSinh(double x)
21 {
22 if(x >= 0.0)
23 {
24 return Ln(x + Sqrt(x * x + 1.0));
25 }
26 else
27 {
28 return -Ln(-x + Sqrt(x * x + 1.0));
29 }
30 }
32 public static double ArcTan(double x)
33 {
34 return Math.atan(x);
35 }
37 public static double ArcTan2(double y, double x)
38 {
39 return Math.atan2(y, x);
40 }
42 public static double ArcTanh(double x)
43 {
44 return Ln((1.0 + x) / (1.0 - x)) / 2.0;
45 }
47 public static double Ceiling(double x)
48 {
49 return Math.ceil(x);
50 }
52 public static double Cos(double x)
53 {
54 return Math.cos(x);
55 }
57 public static double Cosh(double x)
58 {
59 return Math.cosh(x);
60 }
62 public static double Eps()
63 {
64 return Math.ulp(1.0);
65 }
67 public static double Exp(double x)
68 {
69 return Math.exp(x);
70 }
72 public static int Exponent(double x)
73 {
74 return Math.getExponent(x);
75 }
77 public static double Floor(double x)
78 {
79 return Math.floor(x);
80 }
82 public static double Frac(double x)
83 {
84 if(Math.abs(x) >= 1.0e16)
85 {
86 return 0;
87 }
88 else if(x >= 0)
89 {
90 return x - Floor(x);
91 }
92 else
93 {
94 return x + Floor(-x);
95 }
96 }
98 public static double IntPower(double x, int n)
99 {
100 double y = 1.0;
102 if(n < 0)
104 x = 1.0 / x;
105 n = -n;
108 while(n > 0)
110 if(n % 2 == 1)
112 y = y * x;
113 n -= 1;
115 else
117 x = x * x;
118 n = n / 2;
122 return y;
125 public static double Ln(double x)
127 return Math.log(x);
130 public static double Log(double x)
132 return Math.log10(x);
135 public static double Mantissa(double x)
137 int exponent = Math.getExponent(x);
138 return x / Math.pow(2, exponent);
141 public static double Pi()
143 return Math.PI;
146 public static double Power(double x, double y)
148 return Math.pow(x, y);
151 public static double Real(double m, int e)
153 return Math.scalb(m, e);
156 public static double Round(double x)
158 return Math.round(x);
161 public static double Sign(double x)
163 return Math.signum(x);
166 public static double Sin(double x)
168 return Math.sin(x);
171 public static double Sinh(double x)
173 return Math.sinh(x);
176 public static double Sqrt(double x)
178 return Math.sqrt(x);
181 public static double Tan(double x)
183 return Math.tan(x);
186 public static double Tanh(double x)
188 return Math.tanh(x);
191 public static double Trunc(double x)
193 if(Math.abs(x) >= 1.0e16)
195 return x;
197 else if(x >= 0)
199 return Floor(x);
201 else
203 return -Floor(-x);
207 public static void BEGIN()