public static MyDouble Sqrt(MyDouble v) { double[] arr = new double[v.length * 2]; for (int i = 0; i < v.length; i++) { double t = Math.Sqrt(v.arr[i]); arr[2 * i] = -t; arr[2 * i + 1] = t; } return(new MyDouble(arr, arr.Length)); }
private static MyDouble Iter(MyDouble a, MyDouble b, Func <double, double, double> f) { double[] arr = new double[a.length * b.length]; for (int ia = 0, i = 0; ia < a.length; ia++) { for (int ib = 0; ib < b.length; ib++, i++) { arr[i] = f(a.arr[ia], b.arr[ib]); } } return(new MyDouble(arr, arr.Length)); }