public void CanFormatComplexToString(double real, double imag, string expected) { var numberFormat = NumberFormatInfo.CurrentInfo; var a = new Complex(real, imag); Assert.AreEqual( String.Format( expected, numberFormat.NumberDecimalSeparator, numberFormat.NaNSymbol, numberFormat.PositiveInfinitySymbol), a.ToString()); }
public static Complex Cyclotomic(Complex n, Complex z) { if (n != Truncate(n)) throw new MathException(n.ToString(), 0, "n doit être entier"); return Product( k => Pow(z - Pow(Constants.E, (2.0 * Constants.Pi * Constants.I * k) / n), KroneckerDelta(GCD(k, n), 1)), 1, n); }
public static Complex BetaLn(Complex z, Complex w) { if (z <= 0.0) { throw new MathException(z.ToString(), 0, "z doit être positif."); } if (w <= 0.0) { throw new MathException(w.ToString(), 0, "w doit être positif."); } return LogGamma(z) + LogGamma(w) - LogGamma(z + w); }
public void ToStringTest(double re, double im, string expected) { //arrange Complex c = new Complex(re, im); //action string actual = c.ToString(CultureInfo.InvariantCulture); //assert actual.Should().Be(expected); }
public void ConvertToString() { var c1 = new Complex(1, 2); var c2 = new Complex(0, 3); var c3 = new Complex(4, 0); var c4 = new Complex(4, -5); var c5 = new Complex(-6, -7); Assert.AreEqual("1+2i", c1.ToString()); Assert.AreEqual("3i", c2.ToString()); Assert.AreEqual("4", c3.ToString()); Assert.AreEqual("4-5i", c4.ToString()); Assert.AreEqual("-6-7i", c5.ToString()); }