Exemplo n.º 1
0
 public void IterateTest()
 {
     Fixed128 zx = 0, zy = 0;
       Fixed128 cx = new Fixed128(0, 0xa6aaaaaau, 0xaaaaaaaau, 0xaaaaaaabu);
       Fixed128 cy = new Fixed128(-1, 0xfd555555u, 0x55555555u, 0x55555555u);
       Assert.AreEqual("0.651041666666666666666666666670873924827845396295529219014841526558257100987248122692108154296875",
               (string)cx);
       Assert.AreEqual("-0.010416666666666666666666666670873924827845396295529219014841526558257100987248122692108154296875",
               (string)cy);
       double count = Fixed128.iterate(zx, zy, cx, cy, 255, Precision.Double);
       double expected = 1 + 5 - Math.Log(Math.Log(255.08471462316811, 2), 2);
       Assert.AreEqual(count, expected);
       count = Fixed128.iterate(zx, zy, cx, cy, 255, Precision.LongDouble);
       Assert.AreEqual(count, expected);
       count = Fixed128.iterate(zx, zy, cx, cy, 255, Precision.Fixed64);
       Assert.AreEqual(count, expected);
       count = Fixed128.iterate(zx, zy, cx, cy, 255, Precision.Fixed128);
       Assert.AreEqual(count, expected);
 }
Exemplo n.º 2
0
 private static extern double iterate_cs(ref Fixed128 zx, ref Fixed128 zy,
                                     ref Fixed128 cx, ref Fixed128 cy,
                                     int maxiters, int arith);
Exemplo n.º 3
0
 private static extern void Fixed128_sub(ref Fixed128 r,
                                     ref Fixed128 a,
                                     ref Fixed128 b);
Exemplo n.º 4
0
 private static extern int Fixed128_str2_cs(ref Fixed128 r, string s);
Exemplo n.º 5
0
 private static extern void Fixed128_sqrt(ref Fixed128 r,
                                      ref Fixed128 a);
Exemplo n.º 6
0
 private static extern void Fixed128_neg(ref Fixed128 r,
                                     ref Fixed128 a);
Exemplo n.º 7
0
 private static extern int Fixed128_lt(ref Fixed128 r,
                                   ref Fixed128 a);
Exemplo n.º 8
0
 private static extern void Fixed128_double2(ref Fixed128 r, double n);
Exemplo n.º 9
0
 private static unsafe extern IntPtr Fixed128_2str(byte* buffer, IntPtr bufsize,
                                               ref Fixed128 a, int radix);
Exemplo n.º 10
0
 private static extern double Fixed128_2double(ref Fixed128 a);
Exemplo n.º 11
0
 /// <summary>
 /// Calculate Mandelbrot set iteration
 /// </summary>
 /// <param name="zx">Starting real part</param>
 /// <param name="zy">Starting imaginary part</param>
 /// <param name="cx">Offset constant real part</param>
 /// <param name="cy">Offset constant imaginary part</param>
 /// <param name="maxiters">Maximum number of iterations</param>
 /// <param name="precision">Precision to use</param>
 /// <returns>Adjusted iteration count</returns>
 public static double iterate(Fixed128 zx, Fixed128 zy,
                          Fixed128 cx, Fixed128 cy,
                          int maxiters, Precision precision)
 {
     return iterate_cs(ref zx, ref zy, ref cx, ref cy, maxiters, (int)precision);
 }
Exemplo n.º 12
0
 public void ToDoubleTest()
 {
     Fixed128 a = new Fixed128(1, 0x80000000u, 0u, 0u);
       double n = a;
       Assert.AreEqual(1.5, n);
       a = new Fixed128(-101, 0xE0000000u, 0u, 0u);
       n = a;
       Assert.AreEqual(-100.125, n);
 }