/// <summary> /// Computes an intersection point between two lines /// using DD arithmetic. /// Currently does not handle case of parallel lines. /// </summary> /// <param name="p1">A point of 1st segment</param> /// <param name="p2">Another point of 1st segment</param> /// <param name="q1">A point of 2nd segment</param> /// <param name="q2">Another point of 2nd segment</param> /// <returns></returns> public static Coordinate Intersection( Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2) { var denom1 = (DD.ValueOf(q2.Y) - DD.ValueOf(q1.Y)) * (DD.ValueOf(p2.X) - DD.ValueOf(p1.X)); var denom2 = (DD.ValueOf(q2.X) - DD.ValueOf(q1.X)) * (DD.ValueOf(p2.Y) - DD.ValueOf(p1.Y)); var denom = denom1 - denom2; /** * Cases: * - denom is 0 if lines are parallel * - intersection point lies within line segment p if fracP is between 0 and 1 * - intersection point lies within line segment q if fracQ is between 0 and 1 */ var numx1 = (DD.ValueOf(q2.X) - DD.ValueOf(q1.X)) * (DD.ValueOf(p1.Y) - DD.ValueOf(q1.Y)); var numx2 = (DD.ValueOf(q2.Y) - DD.ValueOf(q1.Y)) * (DD.ValueOf(p1.X) - DD.ValueOf(q1.X)); var numx = numx1 - numx2; var fracP = (numx / denom) /*.ToDoubleValue()*/; var x = (DD.ValueOf(p1.X) + (DD.ValueOf(p2.X) - DD.ValueOf(p1.X)) * fracP).ToDoubleValue(); var numy1 = (DD.ValueOf(p2.X) - DD.ValueOf(p1.X)) * (DD.ValueOf(p1.Y) - DD.ValueOf(q1.Y)); var numy2 = (DD.ValueOf(p2.Y) - DD.ValueOf(p1.Y)) * (DD.ValueOf(p1.X) - DD.ValueOf(q1.X)); var numy = numy1 - numy2; var fracQ = numy / denom; var y = (DD.ValueOf(p1.Y) + (DD.ValueOf(p2.Y) - DD.ValueOf(p1.Y)) * fracQ).ToDoubleValue(); return(new Coordinate(x, y)); }
public static bool IsInCircleDD( Coordinate a, Coordinate b, Coordinate c, Coordinate p) { DD px = new DD(p.X); DD py = new DD(p.Y); DD ax = new DD(a.X); DD ay = new DD(a.Y); DD bx = new DD(b.X); DD by = new DD(b.Y); DD cx = new DD(c.X); DD cy = new DD(c.Y); DD aTerm = (ax.Multiply(ax).Add(ay.Multiply(ay))) .Multiply(TriAreaDD(bx, by, cx, cy, px, py)); DD bTerm = (bx.Multiply(bx).Add(by.Multiply(by))) .Multiply(TriAreaDD(ax, ay, cx, cy, px, py)); DD cTerm = (cx.Multiply(cx).Add(cy.Multiply(cy))) .Multiply(TriAreaDD(ax, ay, bx, by, px, py)); DD pTerm = (px.Multiply(px).Add(py.Multiply(py))) .Multiply(TriAreaDD(ax, ay, bx, by, cx, cy)); DD sum = aTerm.Subtract(bTerm).Add(cTerm).Subtract(pTerm); var isInCircle = sum.ToDoubleValue() > 0; return isInCircle; }
public void TestParseStandardNotation() { CheckParse("1.0000000", 1, 1e-32); CheckParse("1.0", 1, 1e-32); CheckParse("1.", 1, 1e-32); CheckParse("01.", 1, 1e-32); CheckParse("-1.0", -1, 1e-32); CheckParse("-1.", -1, 1e-32); CheckParse("-01.0", -1, 1e-32); CheckParse("-123.0", -123, 1e-32); /* * The Java double-precision constant 1.4 gives rise to a value which * differs from the exact binary representation down around the 17th decimal * place. Thus it will not compare exactly to the DoubleDouble * representation of the same number. To avoid this, compute the expected * value using full DD precision. */ CheckParse("1.4", DD.ValueOf(14) / DD.ValueOf(10), 1e-30); // 39.5D can be converted to an exact FP representation CheckParse("39.5", 39.5, 1e-30); CheckParse("-39.5", -39.5, 1e-30); }
private static void CheckSciNotation(DD x, string expectedStr) { string xStr = x.ToSciNotation(); // System.Console.WriteLine("Sci Notation: " + xStr); Assert.AreEqual(xStr, expectedStr); }
public void TestParse() { CheckParse("0", 0, 1e-32); CheckParse("1", 1, 1e-32); CheckParse("100", 100, 1e-32); CheckParse("-1", -1, 1e-32); CheckParse("-100", -100, 1e-32); CheckParse("-123", -123, 1e-32); CheckParse(".1", 0.1, 1e-32); CheckParse("0", 0, 1e-32); CheckParse("1", 1, 1e-32); CheckParse("1.05e10", 1.05E10, 1e-32); CheckParse("-1.05e10", -1.05E10, 1e-32); CheckParse("1.05e-10", DD.ValueOf(105d).Divide( DD.ValueOf(100d)).Divide(DD.ValueOf(1.0E10)), 1e-32); CheckParse("-1.05e-10", DD.ValueOf(105d).Divide( DD.ValueOf(100d)).Divide(DD.ValueOf(1.0E10)) .Negate(), 1e-32); /** * The Java double-precision constant 1.4 gives rise to a value which * differs from the exact binary representation down around the 17th decimal * place. Thus it will not compare exactly to the DoubleDouble * representation of the same number. To avoid this, compute the expected * value using full DD precision. */ CheckParse("1.4", DD.ValueOf(14).Divide(DD.ValueOf(10)), 1e-30); // 39.5D can be converted to an exact FP representation CheckParse("39.5", 39.5, 1e-30); CheckParse("-39.5", -39.5, 1e-30); }
public void TestStandardNotation() { // standard cases CheckStandardNotation(1.0, "1.0"); CheckStandardNotation(0.0, "0.0"); // cases where hi is a power of 10 and lo is negative CheckStandardNotation(DD.ValueOf(1e12).Subtract(DD.ValueOf(1)), "999999999999.0"); CheckStandardNotation(DD.ValueOf(1e14).Subtract(DD.ValueOf(1)), "99999999999999.0"); CheckStandardNotation(DD.ValueOf(1e16).Subtract(DD.ValueOf(1)), "9999999999999999.0"); var num8Dec = DD.ValueOf(-379363639).Divide( DD.ValueOf(100000000)); CheckStandardNotation(num8Dec, "-3.79363639"); CheckStandardNotation(new DD(-3.79363639, 8.039137357367426E-17), "-3.7936363900000000000000000"); CheckStandardNotation(DD.ValueOf(34).Divide( DD.ValueOf(1000)), "0.034"); CheckStandardNotation(1.05e3, "1050.0"); CheckStandardNotation(0.34, "0.34000000000000002442490654175344"); CheckStandardNotation(DD.ValueOf(34).Divide( DD.ValueOf(100)), "0.34"); CheckStandardNotation(14, "14.0"); }
/// <summary> /// This routine simply tests for robustness of the ToString function. /// </summary> private static void WriteRepeatedSqrt(DD xdd) { int count = 0; while (xdd.ToDoubleValue() > 1e-300) { count++; // if (count == 100) // count = count; double x = xdd.ToDoubleValue(); var xSqrt = xdd.Sqrt(); string s = xSqrt.ToString(); // System.Console.WriteLine((count + ": " + s); var xSqrt2 = DD.Parse(s); var xx = xSqrt2.Multiply(xSqrt2); double err = Math.Abs(xx.ToDoubleValue() - x); // assertTrue(err < 1e-10); xdd = xSqrt; // square roots converge on 1 - stop when very close var distFrom1DD = xSqrt.Subtract(DD.ValueOf(1.0)); double distFrom1 = distFrom1DD.ToDoubleValue(); if (Math.Abs(distFrom1) < 1.0e-40) { break; } } }
private static void CheckBinomial2(double a, double b) { // binomial product var add = new DD(a); var bdd = new DD(b); var aPlusb = add.Add(bdd); var aSubb = add.Subtract(bdd); var abProd = aPlusb.Multiply(aSubb); // System.out.println("(a+b)^2 = " + abSq); // expansion var a2DD = add.Multiply(add); var b2DD = bdd.Multiply(bdd); // System.out.println("2ab+b^2 = " + sum); // this should equal b^2 var diff = abProd.Subtract(a2DD).Negate(); // System.out.println("(a+b)^2 - a^2 = " + diff); var delta = diff.Subtract(b2DD); Console.WriteLine("\nA = " + a + ", B = " + b); Console.WriteLine("[DD] (a+b)(a-b) = " + abProd + " -((a^2 - b^2) - a^2) = " + diff + " delta = " + delta); // printBinomialSquareDouble(a,b); var isSame = diff.Equals(b2DD); Assert.IsTrue(isSame); var isDeltaZero = delta.IsZero; Assert.IsTrue(isDeltaZero); }
/// <summary> /// Computes (a+b)^2 in two different ways and compares the result. /// For correct results, a and b should be integers. /// </summary> private static void CheckBinomialSquare(double a, double b) { // binomial square var add = new DD(a); var bdd = new DD(b); var aPlusb = add + bdd; var abSq = aPlusb * aPlusb; // System.out.println("(a+b)^2 = " + abSq); // expansion var a2DD = add * add; var b2DD = bdd * bdd; var ab = add * bdd; var sum = b2DD + ab + ab; // System.out.println("2ab+b^2 = " + sum); var diff = abSq - a2DD; // System.out.println("(a+b)^2 - a^2 = " + diff); var delta = diff - sum; // TestContext.WriteLine("\nA = " + a + ", B = " + b); // TestContext.WriteLine("[DD] 2ab+b^2 = " + sum // + " (a+b)^2 - a^2 = " + diff // + " delta = " + delta); PrintBinomialSquareDouble(a, b); bool isSame = diff.Equals(sum); Assert.IsTrue(isSame); bool isDeltaZero = delta.IsZero; Assert.IsTrue(isDeltaZero); }
private static void CheckAddMult2(DD dd) { var sum = dd + dd; var prod = dd * new DD(2.0); CheckErrorBound("AddMult2", sum, prod, 0.0); }
static DD DD_DEC(double x) { var res = DD.ValueOf(x.ToString("R", NumberFormatInfo.InvariantInfo)); //Console.WriteLine($"DEC: {x} -> {res} ({res.Dump()})"); return(res); }
private static void CheckBinomial2(double a, double b) { // binomial product var add = new DD(a); var bdd = new DD(b); var aPlusb = add + bdd; var aSubb = add - bdd; var abProd = aPlusb * aSubb; // System.out.println("(a+b)^2 = " + abSq); // expansion var a2DD = add * add; var b2DD = bdd * bdd; // System.out.println("2ab+b^2 = " + sum); // this should equal b^2 var diff = -(abProd - a2DD); // System.out.println("(a+b)^2 - a^2 = " + diff); var delta = diff - b2DD; // TestContext.WriteLine("\nA = " + a + ", B = " + b); // TestContext.WriteLine("[DD] (a+b)(a-b) = " + abProd // + " -((a^2 - b^2) - a^2) = " + diff // + " delta = " + delta); // printBinomialSquareDouble(a,b); bool isSame = diff.Equals(b2DD); Assert.IsTrue(isSame); bool isDeltaZero = delta.IsZero; Assert.IsTrue(isDeltaZero); }
protected override void ProcessRecord() { if (!(this.MyInvocation.BoundParameters.ContainsKey("BlockSize"))) { blockSize = 512; } Regex lettersOnly = new Regex("^[a-zA-Z]{1}$"); if (lettersOnly.IsMatch(inFile)) { inFile = @"\\.\" + inFile + ":"; } WriteDebug("VolumeName: " + inFile); if (this.MyInvocation.BoundParameters.ContainsKey("OutFile")) { DD.Get(inFile, outFile, offset, blockSize, count); } else { for (int i = 0; i <= count; i++) { WriteObject(DD.Get(inFile, offset, blockSize)); offset += blockSize; } } } // ProcessRecord
private void CheckSqrt(DD x, double errBound) { DD sqrt = x.Sqrt(); DD x2 = sqrt.Multiply(sqrt); CheckErrorBound("Sqrt", x, x2, errBound); }
protected void rdbMultiple_CheckedChanged(object sender, EventArgs e) { if (ViewState["MS"].ToString() == "N") { TxtAMTCOLL.Text = FDR.GetCurrentBalance("X_" + Session["MID"].ToString(), "Y").ToString(); TxtDiff.Text = TxtAMTCOLL.Text; TxtDepoAmt.Enabled = true; ClearFD(); string DD; DD = FDR.GetDUEDATE(ViewState["FDTP"].ToString(), Session["BRCD"].ToString(), "DUED", ViewState["ACC"].ToString(), ViewState["CT"].ToString()); if (DD != null) { dtDeposDate.Text = DD.ToString(); } TxtDepoAmt.Text = "0"; ViewState["CTYPE"] = "M"; } else { TxtAMTCOLL.Text = FDR.GetCurrentBalance("X_" + Session["MID"].ToString(), "Y").ToString(); TxtDiff.Text = TxtAMTCOLL.Text; TxtDepoAmt.Enabled = true; ClearFD(); string DD; TxtDepoAmt.Text = "0"; ViewState["CTYPE"] = "M"; TxtProcode.Focus(); } }
private static void CheckStandardNotation(DD x, String expectedStr) { String xStr = x.ToStandardNotation(); Console.WriteLine("Standard Notation: " + xStr); Assert.AreEqual(expectedStr, xStr); }
private void CibleSup(monBouton b, Cavalier p) { for (int i = 0; i < p.GetDepi().GetLength(0); ++i) { DD.UnSetButtonCible(b, piece.GetDepi()[i], piece.GetDepj()[i]); } }
/** * Computes (a+b)^2 in two different ways and compares the result. * For correct results, a and b should be integers. * * @param a * @param b */ private static void CheckBinomialSquare(double a, double b) { // binomial square var add = new DD(a); var bdd = new DD(b); var aPlusb = add.Add(bdd); var abSq = aPlusb.Multiply(aPlusb); // System.out.println("(a+b)^2 = " + abSq); // expansion var a2DD = add.Multiply(add); var b2DD = bdd.Multiply(bdd); var ab = add.Multiply(bdd); var sum = b2DD.Add(ab).Add(ab); // System.out.println("2ab+b^2 = " + sum); var diff = abSq.Subtract(a2DD); // System.out.println("(a+b)^2 - a^2 = " + diff); var delta = diff.Subtract(sum); Console.WriteLine("\nA = " + a + ", B = " + b); Console.WriteLine("[DD] 2ab+b^2 = " + sum + " (a+b)^2 - a^2 = " + diff + " delta = " + delta); PrintBinomialSquareDouble(a, b); var isSame = diff.Equals(sum); Assert.IsTrue(isSame); var isDeltaZero = delta.IsZero; Assert.IsTrue(isDeltaZero); }
// ******************** MOUVEMENT ********************** // ******************** MOUVEMENT RETOUR ********************** public void RetourDpl(int retourNbr) { if (rtClic < cpClic) { monBouton btmp; //effacement for (int i = cpClic - 1; i >= (cpClic - retourNbr); --i) { btmp = dpl[i]; btmp.Reinitialiser(); CibleSup(btmp, piece); DD.OuvrirDispo(btmp.getNumLigne(), btmp.getNumCol()); dpl[i] = null; } //ajouter detail initiaux cpClic -= retourNbr; btmp = dpl[cpClic - 1]; btmp.Colorer(); btmp.ImageAj(piece.GetImg()); CibleAj(btmp, this.piece); piece.DeplacerF(btmp.getNumLigne(), btmp.getNumCol()); jouLig = btmp.getNumLigne(); jouCol = btmp.getNumCol(); DD.FermerDispo(btmp.getNumLigne(), btmp.getNumCol()); } }
// Initializes the DetectDisplays library. public static void Initialize() { displayInfo = new DisplayInfo(); IntPtr pointer = IntPtr.Zero; try { pointer = Marshal.AllocHGlobal(Marshal.SizeOf(displayInfo)); int returnValue = DD.Initialize(pointer); displayInfo = (DisplayInfo)Marshal.PtrToStructure(pointer, typeof(DisplayInfo)); // Detection failed if (returnValue == 0) { InitializeNoDetectDisplays(); } } catch { //// (Exception e) //// MessageBox.Show(string.Format("Exception: {0}\n\nStack Trace:\n{1}", e.Message, e.StackTrace)); InitializeNoDetectDisplays(); throw; } finally { Marshal.FreeHGlobal(pointer); } }
//Calls CaseInsensitiveComparer.Compare with the parameters reversed. int IComparer.Compare(Object _x, Object _y) { DD x = (DD)_x; DD y = (DD)_y; return(x.key.CompareTo(y.key)); }
public override DL GetDL() { DD x = E.GetDD(); ulong p10 = Util.PowerTen(DTI.Scale(Type)); return((ee) => (long)(x(ee) * p10)); }
public static bool IsInCircleDDSlow( Coordinate a, Coordinate b, Coordinate c, Coordinate p) { var px = DD.ValueOf(p.X); var py = DD.ValueOf(p.Y); var ax = DD.ValueOf(a.X); var ay = DD.ValueOf(a.Y); var bx = DD.ValueOf(b.X); var by = DD.ValueOf(b.Y); var cx = DD.ValueOf(c.X); var cy = DD.ValueOf(c.Y); var aTerm = (ax.Multiply(ax).Add(ay.Multiply(ay))) .Multiply(TriAreaDDSlow(bx, by, cx, cy, px, py)); var bTerm = (bx.Multiply(bx).Add(by.Multiply(by))) .Multiply(TriAreaDDSlow(ax, ay, cx, cy, px, py)); var cTerm = (cx.Multiply(cx).Add(cy.Multiply(cy))) .Multiply(TriAreaDDSlow(ax, ay, bx, by, px, py)); var pTerm = (px.Multiply(px).Add(py.Multiply(py))) .Multiply(TriAreaDDSlow(ax, ay, bx, by, cx, cy)); var sum = aTerm.Subtract(bTerm).Add(cTerm).Subtract(pTerm); bool isInCircle = sum.ToDoubleValue() > 0; return(isInCircle); }
private static void CheckSciNotation(DD x, String expectedStr) { var xStr = x.ToSciNotation(); Console.WriteLine("Sci Notation: " + xStr); Assert.AreEqual(xStr, expectedStr); }
private static void CheckAddMult2(DD dd) { DD sum = dd.Add(dd); DD prod = dd.Multiply(new DD(2.0)); CheckErrorBound("AddMult2", sum, prod, 0.0); }
// public double XrunDoubleDoubleSelf(int nIter) // { // Stopwatch sw = new Stopwatch(); // for (int i = 0; i < nIter; i++) { // // DD a = new DD(9.0); // DD factor = new DD(10.0); // DD aMul = factor.multiply(a); // DD aDiv = a.divide(factor); // // DD det = a.multiply(a) // .subtract(aMul.multiply(aDiv)); /// Console.WriteLine(aDiv); /// Console.WriteLine(det); // } // sw.Stop(); // Console.WriteLine("DD: nIter = " + nIter // + " time = " + sw.ElapsedMilliseconds); // return sw.ElapsedMilliseconds / (double) nIter; // } //* public double RunDoubleDoubleSelf(int nIter) { var sw = new Stopwatch(); sw.Start(); for (int i = 0; i < nIter; i++) { double a = 9.0; double factor = 10.0; var c = new DD(9.0); c *= factor; var b = new DD(9.0); b /= factor; var a2 = new DD(a); a2 *= a; var b2 = new DD(b); b2 *= c; a2 /= b2; var det = a2; // Console.WriteLine(aDiv); // Console.WriteLine(det); } sw.Stop(); Console.WriteLine("DD-Self: nIter = " + nIter + " time = " + sw.ElapsedMilliseconds); return(sw.ElapsedMilliseconds / (double)nIter); }
void PrintGraph(SemanticWebUsersLevel web) { DD.ClearAll(); Dictionary <int, DiagramNode> nodeMap = new Dictionary <int, DiagramNode>(); foreach (var node in web.Nodes) { var diagramNode = DD.Factory.CreateShapeNode(bounds); //diagramNode.Brush = new LinearGradientBrush(new GradientStopCollection nodeMap[node.ID] = diagramNode; diagramNode.Text = node.Name; diagramNode.Tag = node; } foreach (var arc in web.Arcs) { if (!arc.Name.Contains("_#")) { var diagramArc = DD.Factory.CreateDiagramLink(nodeMap[arc.From.ID], nodeMap[arc.To.ID]); diagramArc.Text = arc.Name; } } load = false; // arrange the graph(расстановка) var layout = new LayeredLayout(); layout.Arrange(DD); //sbState.Style = (Style)FindResource("ReadySBStyle"); }
private static void CheckStandardNotation(DD x, string expectedStr) { string xStr = x.ToStandardNotation(); // TestContext.WriteLine("Standard Notation: " + xStr); Assert.AreEqual(expectedStr, xStr); }
private void CheckSqrt(DD x, double errBound) { var sqrt = x.Sqrt(); var x2 = sqrt * sqrt; CheckErrorBound("Sqrt", x, x2, errBound); }
/// <summary> /// The ProcessRecord Reads bytes from the InFile /// and outputs them to the OutFile. /// </summary> protected override void ProcessRecord() { if (!(this.MyInvocation.BoundParameters.ContainsKey("Offset"))) { offset = 0; } if (!(this.MyInvocation.BoundParameters.ContainsKey("BlockSize"))) { blockSize = 512; } Util.getVolumeName(ref inFile); if (this.MyInvocation.BoundParameters.ContainsKey("OutFile")) { DD.Get(inFile, outFile, offset, blockSize, count); } else { for (int i = 0; i < count; i++) { WriteObject(DD.Get(inFile, offset, blockSize)); offset += blockSize; } } }
/* * private const bool UseAccurateConversion = false; * * private static DD convertToDD(double x) * { * if (UseAccurateConversion) * { * // convert more accurately to DD from decimal representation * // very slow though - should be a better way * return DD.ValueOf(x + ""); * } * * // current built-in conversion - introduces jitter * return DD.ValueOf(x); * } */ static DD DD_STD(double x) { var res = DD.ValueOf(x); //Console.WriteLine($"STD: {x.ToString(NumberFormatInfo.InvariantInfo)} -> {res.} ({res.Dump()})"); return(res); }
private static void CheckTrunc(DD x, DD expected) { DD trunc = x.Truncate(); var isEqual = trunc.Equals(expected); Assert.True(isEqual); isEqual = trunc == expected; Assert.True(isEqual); }
/// <summary> /// Computes the sign of the determinant of the 2x2 matrix /// with the given entries. /// </summary> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <returns> /// <list type="Bullet"> /// <item>-1 if the determinant is negative,</item> /// <item>1 if the determinant is positive,</item> /// <item>0 if the determinant is 0.</item> /// </list> /// </returns> public static int SignOfDet2x2(DD x1, DD y1, DD x2, DD y2) { DD det = x1.Multiply(y2).Subtract(y1.Multiply(x2)); if (det.IsZero) return 0; if (det.IsNegative) return -1; return 1; }
/// <summary> /// Computes the arctangent based on the Taylor series expansion /// <para/> /// arctan(x) = x - x^3 / 3 + x^5 / 5 - x^7 / 7 + ... /// </summary> /// <param name="x">The argument</param> /// <returns>An approximation to the arctangent of the input</returns> private static DD ArcTan(DD x) { var t = x; var t2 = t.Sqr(); var at = new DD(0.0); var two = new DD(2.0); var k = 0; var d = new DD(1.0); var sign = 1; while (t.ToDoubleValue() > DD.Epsilon) { k++; at = sign < 0 ? at.Subtract(t.Divide(d)) : at.Add(t.Divide(d)); d = d.Add(two); t = t.Multiply(t2); sign = -sign; } Console.WriteLine("Computed DD.atan(): " + at + " Math.atan = " + Math.Atan(x.ToDoubleValue())); return at; }
public static bool IsInstDDToCC() { object o = new DD(); return (o is CC); }
public static bool IsInstDDToBB() { object o = new DD(); return (o is BB); }
public static bool IsInstDDToAA() { object o = new DD(); return (o is AA); }
private static void menu() { DD[] ddArray = new DD[12]; DD dd = new DD { Name = "Sipariş" }; DD[] ddArray2 = new DD[2]; DD dd2 = new DD { Name = "Gelen Siparişler", SubMenu = new string[] { "Bekleyen Siparişler", "Onaylanan Siparişler", "Onaylanmayan Siparişler", "Siparişleri Listele" } }; ddArray2[0] = dd2; DD dd3 = new DD { Name = "Verilen Siparişler", SubMenu = new string[] { "Sipariş Ver", "Siparişleri Listele" } }; ddArray2[1] = dd3; dd.SubMenu = ddArray2; ddArray[0] = dd; DD dd4 = new DD { Name = "Fatura / İrsaliye" }; ddArray2 = new DD[4]; DD dd5 = new DD { Name = "Satış İrsaliye", SubMenu = new string[] { "Satış İrsaliye", "Satış Fason İrsaliye", "Gelen Fason İrsaliye", "İrsaliye Listele" } }; ddArray2[0] = dd5; DD dd6 = new DD { Name = "Satış Faturası", SubMenu = new string[] { "Satış Faturası", "İrsaliyeli Satış Faturası", "Fason Satış Faturası", "Satış İade Faturası (Alıştan)" } }; ddArray2[1] = dd6; DD dd7 = new DD { Name = "Alış İrsaliye", SubMenu = new string[] { "Alış İrsaliye", "Giden Fason İrsaliye", "İrsaliye Listele" } }; ddArray2[2] = dd7; DD dd8 = new DD { Name = "Alış Faturası", SubMenu = new string[] { "Alış Faturası", "İrsaliyeli Alış Faturası", "Gider Alış Faturası", "Alış Fason Faturası", "Alış İade Faturası" } }; ddArray2[3] = dd8; dd4.SubMenu = ddArray2; ddArray[1] = dd4; DD dd9 = new DD { Name = "Stok / \x00dcretim" }; ddArray2 = new DD[2]; DD dd10 = new DD { Name = "Stok", SubMenu = new string[] { "Stok Kartı", "Stok Listesi", "Stok Ekstresi", "Depo, Şube Transfer" } }; ddArray2[0] = dd10; DD dd11 = new DD { Name = "\x00dcretim", SubMenu = new string[] { "Re\x00e7ete Kartı", "Re\x00e7ete Listesi", "Tahmini \x00dcretim", "Reel \x00dcretim", "\x00dcretim Listesi" } }; ddArray2[1] = dd11; dd9.SubMenu = ddArray2; ddArray[2] = dd9; DD dd12 = new DD { Name = "Personel", SubMenu = new string[] { "Personel Kartı", "Prim, İkramiye Giriş", "Puantaj Kayıt", "Bordro", "\x00dccret Pusulası", "Banka \x00d6deme Formu", "Yasal Kesintiler" } }; ddArray[3] = dd12; DD dd13 = new DD { Name = "Banka", SubMenu = new string[] { "Banka Kartı", "Banka Listesi", "Bankalar Arası Virman", "Bankalar Gider \x00c7ıkış", "Bankadan Kasaya Giriş", "Banka Cari \x00d6deme", "Banka Kasa \x00c7ıkış", "Bankadan Personele \x00d6deme", "Kredi Kullanım Girişi", "Talimatlar" } }; ddArray[4] = dd13; DD dd14 = new DD { Name = "Kasa", SubMenu = new string[] { "Kasa Kartı", "Kasa Listesi", "Kasalar Arası Virman", "Kasadan Personele \x00d6deme" } }; ddArray[5] = dd14; DD dd15 = new DD { Name = "Cari", SubMenu = new string[] { "Cari Kart", "Cari Listele", "Cari Ekstre", "Cariler Arası Virman", "Kasa Cari \x00d6deme", "Kasa Cari Tahsilat", "Cari Risk Raporu", "Cari Hesap Vade Farkları" } }; ddArray[6] = dd15; DD dd16 = new DD { Name = "\x00c7ek" }; ddArray2 = new DD[2]; DD dd17 = new DD { Name = "Alınan \x00c7ekler", SubMenu = new string[] { "\x00c7ek Giriş", "\x00c7ek \x00c7ıkış", "\x00c7ek Tahsilat", "Portf\x00f6ydeki \x00c7ekler", "\x00c7ek \x00c7ıkıştan İade", "Portf\x00f6yden İade", "Bankaya \x00c7ek \x00c7ıkış", "Bankadan İade \x00c7ekler", "Bankadan Portf\x00f6ye Alınan \x00c7ekler", "\x00c7ek Listesi" } }; ddArray2[0] = dd17; DD dd18 = new DD { Name = "Verilen \x00c7ekler", SubMenu = new string[] { "\x00c7ek \x00c7ıkış", "\x00c7ek Listesi", "İade Gelen \x00c7ekler", "\x00c7ek \x00d6deme Bankadan", "\x00c7ek \x00d6deme Kasadan" } }; ddArray2[1] = dd18; dd16.SubMenu = ddArray2; ddArray[7] = dd16; DD dd19 = new DD { Name = "Senet" }; ddArray2 = new DD[2]; DD dd20 = new DD { Name = "Alınan Senetler", SubMenu = new string[] { "Senet Giriş", "Senet \x00c7ıkış", "Senet Tahsilat", "Portf\x00f6ydeki Senetler", "Senet \x00c7ıkışdan İade", "Portf\x00f6yden İade", "Bankaya İade Senetler", "Bankadan Portf\x00f6ye Alınan Senetler", "Senet Listesi" } }; ddArray2[0] = dd20; DD dd21 = new DD { Name = "Verilen Senetler", SubMenu = new string[] { "Senet \x00c7ıkış", "Senet Listesi", "İade Gelen Senetler", "Senet \x00d6deme Bankadan", "Senet \x00d6deme Kasadan" } }; ddArray2[1] = dd21; dd19.SubMenu = ddArray2; ddArray[8] = dd19; DD dd22 = new DD { Name = "Hatırlatıcı", SubMenu = new string[] { "Hatırlatıcı", "Rehber" } }; ddArray[9] = dd22; DD dd23 = new DD { Name = "Y\x00f6netim Paneli", SubMenu = new string[] { "Tek D\x00fczen Hesap Planı", "Kullanıcı Yetkilendirme", "Evrak Numaralarndırma", "Evrak Parametreleri", "Şifre Değiştirme", "Mail Tanımlaması", "D\x00f6nem A\x00e7ma", "Firma A\x00e7ma", "Kullanıcı Raporu" } }; ddArray[10] = dd23; DD dd24 = new DD { Name = "Mali Veriler", SubMenu = new string[] { "Mizan", "Nakit Akışı", "Bilan\x00e7o", "Kdv Bilgisi", "Form BA BS", "Karşılaştıma Raporu" } }; ddArray[11] = dd24; var xmlMenu = new Menu { Categories = new List<Menu.Category>() }; for (int i = 0; i < ddArray.Length; i++) { var cat = ddArray[i]; xmlMenu.Categories.Add(new Menu.Category { Name = cat.Name, SubCategories = new List<Menu.Category.SubCategory>() }); var xmlCat = xmlMenu.Categories[i]; if (cat.SubMenu.GetType() == typeof(string[])) { xmlCat.SubCategories.Add(new Menu.Category.SubCategory { Name = "-", Pages = new List<Menu.Category.SubCategory.Page>() }); var xmlSubCat = xmlCat.SubCategories[0]; for (int k = 0; k < cat.SubMenu.Length; k++) { var page = cat.SubMenu[k]; xmlSubCat.Pages.Add(new Menu.Category.SubCategory.Page { Name = page.ToString(), Url = "" }); } } else { for (int j = 0; j < cat.SubMenu.Length; j++) { var subMenu = (DD)cat.SubMenu[j]; xmlCat.SubCategories.Add(new Menu.Category.SubCategory { Pages = new List<Menu.Category.SubCategory.Page>(), Name = subMenu.Name }); var xmlSubCat = xmlCat.SubCategories[j]; for (int k = 0; k < subMenu.SubMenu.Length; k++) { var page = subMenu.SubMenu[k]; xmlSubCat.Pages.Add(new Menu.Category.SubCategory.Page { Name = page.ToString(), Url = "" }); } } } } var xmlParser = new XmlSerializer(xmlMenu.GetType()); var strBuilder = new StringBuilder(); var stream = new MemoryStream(); var xmlWrite = System.Xml.XmlWriter.Create(strBuilder); xmlParser.Serialize(xmlWrite,xmlMenu); var xml = strBuilder.ToString(); Console.WriteLine(xml); Console.ReadLine(); }
public static UTM DD2UTM(DD dd) { var Convert = new ConversionDD2UTM(); return Convert.Convert(dd); }
/// <summary> /// Computes twice the area of the oriented triangle (a, b, c), i.e., the area /// is positive if the triangle is oriented counterclockwise. /// </summary> /// <remarks> /// The computation uses {@link DD} arithmetic for robustness. /// </remarks> /// <param name="ax">x ordinate of a vertex of the triangle</param> /// <param name="ay">y ordinate of a vertex of the triangle</param> /// <param name="bx">x ordinate of a vertex of the triangle</param> /// <param name="by">y ordinate of a vertex of the triangle</param> /// <param name="cx">x ordinate of a vertex of the triangle</param> /// <param name="cy">y ordinate of a vertex of the triangle</param> /// <returns>The area of a triangle defined by the points a, b and c</returns> private static DD TriAreaDDSlow(DD ax, DD ay, DD bx, DD by, DD cx, DD cy) { return (bx.Subtract(ax).Multiply(cy.Subtract(ay)).Subtract(by.Subtract(ay) .Multiply(cx.Subtract(ax)))); }
private static int SignOfDet2x2DD(DD x1, DD y1, DD x2, DD y2) { DD det = x1 * y2 - y1 * x2; if (det.IsZero) return 0; if (det.IsNegative) return -1; return 1; }
private static void CheckSciNotation(DD x, String expectedStr) { var xStr = x.ToSciNotation(); Console.WriteLine("Sci Notation: " + xStr); Assert.AreEqual(xStr, expectedStr); }
private static void CheckParse(String str, DD expectedVal, double relErrBound) { DD xdd = DD.Parse(str); double err = xdd.Subtract(expectedVal).ToDoubleValue(); double relErr = err / xdd.ToDoubleValue(); Console.WriteLine("Parsed= " + xdd + " rel err= " + relErr); Assert.IsTrue(err <= relErrBound); }
/** * This routine simply tests for robustness of the toString function. * * @param xdd */ private static void WriteRepeatedSqrt(DD xdd) { int count = 0; while (xdd.ToDoubleValue() > 1e-300) { count++; //if (count == 100) // count = count; double x = xdd.ToDoubleValue(); DD xSqrt = xdd.Sqrt(); String s = xSqrt.ToString(); // System.out.println(count + ": " + s); DD xSqrt2 = DD.Parse(s); DD xx = xSqrt2.Multiply(xSqrt2); double err = Math.Abs(xx.ToDoubleValue() - x); //assertTrue(err < 1e-10); xdd = xSqrt; // square roots converge on 1 - stop when very close DD distFrom1DD = xSqrt.Subtract(DD.ValueOf(1.0)); double distFrom1 = distFrom1DD.ToDoubleValue(); if (Math.Abs(distFrom1) < 1.0e-40) break; } }
/** * This routine simply tests for robustness of the toString function. * * @param xdd */ static void WriteRepeatedSqr(DD xdd) { if (xdd.GreaterOrEqualThan(DD.ValueOf(1))) throw new ArgumentException("Argument must be < 1"); int count = 0; while (xdd.ToDoubleValue() > 1e-300) { count++; double x = xdd.ToDoubleValue(); DD xSqr = xdd.Sqr(); String s = xSqr.ToString(); Console.WriteLine(count + ": " + s); DD xSqr2 = DD.Parse(s); xdd = xSqr; } }
public double RunDoubleDouble(int nIter) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < nIter; i++) { DD a = new DD(9.0); DD factor = new DD(10.0); DD aMul = factor.Multiply(a); DD aDiv = a.Divide(factor); DD det = a.Multiply(a) .Subtract(aMul.Multiply(aDiv)); // Console.WriteLine(aDiv); // Console.WriteLine(det); } sw.Stop(); Console.WriteLine("DD: nIter = " + nIter + " time = " + sw.ElapsedMilliseconds); return sw.ElapsedMilliseconds/(double) nIter; }
// public double XrunDoubleDoubleSelf(int nIter) // { // Stopwatch sw = new Stopwatch(); // for (int i = 0; i < nIter; i++) { // DD a = new DD(9.0); // DD factor = new DD(10.0); // DD aMul = factor.multiply(a); // DD aDiv = a.divide(factor); // DD det = a.multiply(a) // .subtract(aMul.multiply(aDiv)); //// Console.WriteLine(aDiv); //// Console.WriteLine(det); // } // sw.Stop(); // Console.WriteLine("DD: nIter = " + nIter // + " time = " + sw.ElapsedMilliseconds); // return sw.ElapsedMilliseconds / (double) nIter; // } //* public double RunDoubleDoubleSelf(int nIter) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < nIter; i++) { double a = 9.0; double factor = 10.0; DD c = new DD(9.0); c*=factor; DD b = new DD(9.0); b/=factor; DD a2 = new DD(a); a2*=a; DD b2 = new DD(b); b2*=c; a2/=b2; DD det = a2; // Console.WriteLine(aDiv); // Console.WriteLine(det); } sw.Stop(); Console.WriteLine("DD-Self: nIter = " + nIter + " time = " + sw.ElapsedMilliseconds); return sw.ElapsedMilliseconds/(double) nIter; }
public static MGRS DD2MGRS(DD dd) { var Convert = new ConversionDD2MGRS(); return Convert.Convert(dd); }
public static DMS DD2DMS(DD dd) { var Convert = new ConversionDD2DMS(); return Convert.Convert(dd); }
private static void CheckStandardNotation(DD x, String expectedStr) { String xStr = x.ToStandardNotation(); Console.WriteLine("Standard Notation: " + xStr); Assert.AreEqual(expectedStr, xStr); }
private void CheckSqrt(DD x, double errBound) { DD sqrt = x.Sqrt(); DD x2 = sqrt.Multiply(sqrt); CheckErrorBound("Sqrt", x, x2, errBound); }
private static void CheckBinomial2(double a, double b) { // binomial product var add = new DD(a); var bdd = new DD(b); var aPlusb = add.Add(bdd); var aSubb = add.Subtract(bdd); var abProd = aPlusb.Multiply(aSubb); // System.out.println("(a+b)^2 = " + abSq); // expansion var a2DD = add.Multiply(add); var b2DD = bdd.Multiply(bdd); // System.out.println("2ab+b^2 = " + sum); // this should equal b^2 var diff = abProd.Subtract(a2DD).Negate(); // System.out.println("(a+b)^2 - a^2 = " + diff); var delta = diff.Subtract(b2DD); Console.WriteLine("\nA = " + a + ", B = " + b); Console.WriteLine("[DD] (a+b)(a-b) = " + abProd + " -((a^2 - b^2) - a^2) = " + diff + " delta = " + delta); // printBinomialSquareDouble(a,b); var isSame = diff.Equals(b2DD); Assert.IsTrue(isSame); var isDeltaZero = delta.IsZero; Assert.IsTrue(isDeltaZero); }
private static void CheckPow(double x, int exp, double errBound) { var xdd = new DD(x); var pow = xdd.Pow(exp); Console.WriteLine("Pow(" + x + ", " + exp + ") = " + pow); var pow2 = SlowPow(xdd, exp); double err = pow.Subtract(pow2).ToDoubleValue(); var isOK = err < errBound; if (!isOK) Console.WriteLine("Test slowPow value " + pow2); Assert.IsTrue(err <= errBound); }
private static DD SlowPow(DD x, int exp) { if (exp == 0) return DD.ValueOf(1.0); var n = Math.Abs(exp); // MD - could use binary exponentiation for better precision & speed var pow = new DD(x); for (int i = 1; i < n; i++) { pow = pow.Multiply(x); } if (exp < 0) { return pow.Reciprocal(); } return pow; }
public static bool IsInstTest6() { object o = new DD(); return (o is BB); }
private static void CheckReciprocal(double x, double errBound) { var xdd = new DD(x); var rr = xdd.Reciprocal().Reciprocal(); var err = xdd.Subtract(rr).ToDoubleValue(); Console.WriteLine("DD Recip = " + xdd + " DD delta= " + err + " double recip delta= " + (x - 1.0/(1.0/x))); Assert.IsTrue(err <= errBound); }
public static bool IsInstTest5() { object o = new DD(); return (o is AA); }
private static void CheckErrorBound(String tag, DD x, DD y, double errBound) { DD err = x.Subtract(y).Abs(); Console.WriteLine(tag + " err=" + err); var isWithinEps = err.ToDoubleValue() <= errBound; Assert.True(isWithinEps); }
public static bool IsInstTest7() { object o = new DD(); return !(o is CC); }
/** * Computes (a+b)^2 in two different ways and compares the result. * For correct results, a and b should be integers. * * @param a * @param b */ private static void CheckBinomialSquare(double a, double b) { // binomial square var add = new DD(a); var bdd = new DD(b); var aPlusb = add.Add(bdd); var abSq = aPlusb.Multiply(aPlusb); // System.out.println("(a+b)^2 = " + abSq); // expansion var a2DD = add.Multiply(add); var b2DD = bdd.Multiply(bdd); var ab = add.Multiply(bdd); var sum = b2DD.Add(ab).Add(ab); // System.out.println("2ab+b^2 = " + sum); var diff = abSq.Subtract(a2DD); // System.out.println("(a+b)^2 - a^2 = " + diff); var delta = diff.Subtract(sum); Console.WriteLine("\nA = " + a + ", B = " + b); Console.WriteLine("[DD] 2ab+b^2 = " + sum + " (a+b)^2 - a^2 = " + diff + " delta = " + delta); PrintBinomialSquareDouble(a, b); var isSame = diff.Equals(sum); Assert.IsTrue(isSame); var isDeltaZero = delta.IsZero; Assert.IsTrue(isDeltaZero); }