private Node RealFunction() { var realFunc = new Real() { AnchorToken = Expect(TokenCategory.REAL) }; if (CurrentToken == TokenCategory.PARENTHESIS_OPEN) { realFunc.Add(new ParenthesisOpen() { AnchorToken = Expect(TokenCategory.PARENTHESIS_OPEN) }); if (CurrentToken != TokenCategory.PARENTHESIS_CLOSE) { var expr = Expression(); realFunc.Add(expr); while (CurrentToken == TokenCategory.COMMA) { Expect(TokenCategory.COMMA); expr = Expression(); realFunc.Add(expr); } } realFunc.Add(new ParenthesisClose() { AnchorToken = Expect(TokenCategory.PARENTHESIS_CLOSE) }); } return(realFunc); }
public void AddTestReal() { double a = 1.2, b = 2.3; double wynik = real.Add(a, b); Assert.AreEqual(wynik, 3.5); }
public void Simple() { double a = 5; double b = 7; var res = Real.Add(a, b); Assert.Equal(12, res[0]); Assert.Equal(0, res[1]); }
public BigComplex Multiply(BigComplex oth, MathContext mc) { BigDecimal a = Real.Add(Imaginary).Multiply(oth.Real); BigDecimal b = oth.Real.Add(oth.Imaginary).Multiply(Imaginary); BigDecimal c = oth.Imaginary.Subtract(oth.Real).Multiply(Real); BigDecimal x = a.Subtract(b, mc); BigDecimal y = a.Add(c, mc); return(new BigComplex(x, y)); }
public void HasEnhancedPrecision() { double a = 8; double b = 1e-16; // out of range Assert.Equal(a + b, a); var res = Real.Add(a, b) - a; // enhanced precision should give us b back Assert.Equal(b, res[0]); }
public void LargeAbsDiff() { double a = 8; double b = 1e-16; // out of range Assert.Equal(a + b, a); var res = Real.Add(a, b); Assert.Equal(a, res[0]); Assert.NotEqual(0, res[1]); Assert.NotEqual(res, new Real(a + b)); }
public static Real DotProduct(Vector <Real> a, Vector <Real> b) { if (a.Dimension != b.Dimension) { throw new ArgumentException("The dot product can only be applied to two vectors of the same dimension."); } Real sum = 0; for (int i = 0; i < a.Dimension; i++) { sum = sum.Add(a[i].Multiply(b[i])); } return(sum); }
internal override void AddChild(ConfigurationElement child) { ForceLoad(); if (Schema.CollectionSchema.ContainsAddElement(child.ElementTagName)) { child.AppendToParentElement(child.Entity, false); Real.Add(child); if (HasParent && Schema.Path == "system.webServer/defaultDocument/files") { var index = Real.Count == 0 ? 0 : Exposed.IndexOf(Real[Real.Count - 1]) + 1; Exposed.Insert(index, child); } else { Exposed.Add(child); } } else if (child.ElementTagName == Schema.CollectionSchema.ClearElementName) { child.AppendToParentElement(child.Entity, false); Real.Add(child); Exposed.Clear(); } else if (child.ElementTagName == Schema.CollectionSchema.RemoveElementName) { child.AppendToParentElement(child.Entity, false); Real.Add(child); foreach (var item in Exposed.ToList()) { if (Match(item, child, Schema.CollectionSchema.RemoveSchema)) { // IMPORTANT: can remove from location tag in the same file, but not from child web.config. if (item.IsLocked == "true" && item.CloneSource?.FileContext != FileContext) { throw new FileLoadException($"Filename: \\\\?\\{FileContext.FileName}\r\nLine number: {(child.Entity as IXmlLineInfo).LineNumber}\r\nError: Lock violation\r\n\r\n"); } Exposed.Remove(item); } } } else { base.AddChild(child); } }
internal override void AddChild(ConfigurationElement child) { ForceLoad(); if (Schema.CollectionSchema.ContainsAddElement(child.ElementTagName)) { child.AppendToParentElement(child.Entity, false); Real.Add(child); if (HasParent && Schema.Path == "system.webServer/defaultDocument/files") { var index = Real.Count == 0 ? 0 : Exposed.IndexOf(Real[Real.Count - 1]) + 1; Exposed.Insert(index, child); } else { Exposed.Add(child); } } else if (child.ElementTagName == Schema.CollectionSchema.ClearElementName) { child.AppendToParentElement(child.Entity, false); Real.Add(child); Exposed.Clear(); } else if (child.ElementTagName == Schema.CollectionSchema.RemoveElementName) { child.AppendToParentElement(child.Entity, false); Real.Add(child); foreach (var item in Exposed.ToList()) { if (Match(item, child, Schema.CollectionSchema.RemoveSchema)) { Exposed.Remove(item); } } } else { base.AddChild(child); } }
public BigComplex Add(BigDecimal oth) { BigDecimal x = Real.Add(oth); return(new BigComplex(x, Imaginary)); }
public void RealTest() { Real<double> test = new Real<double>(2); test.Add(new Real<double>(3)).Multiply(new Real<double>(4)); Assert.IsTrue(test.valuereal == 20); }
public void Add(R real, R complex) { Real.Add(real); Complex.Add(complex); }