From ba2910eee2d767acf8f37e08ac46e16dfb50a50f Mon Sep 17 00:00:00 2001 From: Marcus Cuda Date: Wed, 12 Aug 2009 03:08:51 +0800 Subject: [PATCH] Complex: added missing tests Signed-off-by: Marcus Cuda --- .../ComplexTests/ComplexTest.cs | 352 +++++++----------- src/Managed/Complex.cs | 136 +++---- 2 files changed, 200 insertions(+), 288 deletions(-) diff --git a/src/Managed.UnitTests/ComplexTests/ComplexTest.cs b/src/Managed.UnitTests/ComplexTests/ComplexTest.cs index 23d04de8..d6c1cd6e 100644 --- a/src/Managed.UnitTests/ComplexTests/ComplexTest.cs +++ b/src/Managed.UnitTests/ComplexTests/ComplexTest.cs @@ -5,16 +5,9 @@ using MbUnit.Framework; - /// - /// The complex test. - /// [TestFixture] public class ComplexTest { - - /// - /// The can add complex number and double using operartor. - /// [Test] [MultipleAsserts] public void CanAddComplexNumberAndDoubleUsingOperartor() @@ -29,9 +22,6 @@ AssertEx.That(() => -2.2 + new Complex(-1.1, 2.2) == new Complex(-3.3, 2.2)); } - /// - /// The can add subtract complex numbers using operartor. - /// [Test] [MultipleAsserts] public void CanAddSubtractComplexNumbersUsingOperartor() @@ -42,9 +32,6 @@ AssertEx.That(() => (new Complex(1.1, -2.2) - new Complex(1.1, -2.2)) == Complex.Zero); } - /// - /// The can add two complex numbers. - /// [Test] [MultipleAsserts] public void CanAddTwoComplexNumbers() @@ -55,9 +42,6 @@ AssertEx.That(() => new Complex(1.1, -2.2).Add(new Complex(-1.1, 2.2)) == Complex.Zero); } - /// - /// The can add two complex numbers using operartor. - /// [Test] [MultipleAsserts] public void CanAddTwoComplexNumbersUsingOperartor() @@ -68,9 +52,6 @@ AssertEx.That(() => (new Complex(1.1, -2.2) + new Complex(-1.1, 2.2)) == Complex.Zero); } - /// - /// The can calculate hash code. - /// [Test] [MultipleAsserts] public void CanCalculateHashCode() @@ -83,21 +64,6 @@ Assert.AreEqual(-2097152, complex.GetHashCode()); } - /// - /// The can compute exponential. - /// - /// - /// The real. - /// - /// - /// The imag. - /// - /// - /// The expected real. - /// - /// - /// The expected imag. - /// [Test] [Row(0.0, 0.0, 1.0, 0.0)] [Row(0.0, 1.0, 0.54030230586813977, 0.8414709848078965)] @@ -110,21 +76,6 @@ AssertHelpers.AlmostEqual(expected, value.Exponential(), 15); } - /// - /// The can compute natural logarithm. - /// - /// - /// The real. - /// - /// - /// The imag. - /// - /// - /// The expected real. - /// - /// - /// The expected imag. - /// [Test] [Row(0.0, 0.0, double.NegativeInfinity, 0.0)] [Row(0.0, 1.0, 0.0, 1.5707963267948966)] @@ -138,9 +89,6 @@ AssertHelpers.AlmostEqual(expected, value.NaturalLogarithm(), 15); } - /// - /// The can compute power. - /// [Test] [MultipleAsserts] public void CanComputePower() @@ -167,11 +115,24 @@ a = new Complex(0.0, -8.388608e6); b = new Complex(1.19209289550780998537e-7, 0.0); AssertHelpers.AlmostEqual(new Complex(1.00000190048219620166, -1.87253870018168043834e-7), a.Power(b), 15); + a = new Complex(0.0, 0.0); + b = new Complex(0.0, 0.0); + AssertHelpers.AlmostEqual(new Complex(1.0, 0.0), a.Power(b), 15); + a = new Complex(0.0, 0.0); + b = new Complex(1.0, 0.0); + AssertHelpers.AlmostEqual(new Complex(0.0, 0.0), a.Power(b), 15); + a = new Complex(0.0, 0.0); + b = new Complex(-1.0, 0.0); + AssertHelpers.AlmostEqual(new Complex(double.PositiveInfinity, 0.0), a.Power(b), 15); + a = new Complex(0.0, 0.0); + b = new Complex(-1.0, 1.0); + AssertHelpers.AlmostEqual(new Complex(double.PositiveInfinity, double.PositiveInfinity), a.Power(b), 15); + a = new Complex(0.0, 0.0); + b = new Complex(0.0, 1.0); + AssertEx.That(()=>a.Power(b).IsNaN); + } - /// - /// The can compute root. - /// [Test] [MultipleAsserts] public void CanComputeRoot() @@ -196,9 +157,6 @@ AssertHelpers.AlmostEqual(new Complex(double.PositiveInfinity, double.NegativeInfinity), a.Root(b), 15); } - /// - /// The can compute square. - /// [Test] [MultipleAsserts] public void CanComputeSquare() @@ -217,9 +175,6 @@ AssertHelpers.AlmostEqual(new Complex(-70368744177664.0, 0.0), complex.Square(), 15); } - /// - /// The can compute square root. - /// [Test] [MultipleAsserts] public void CanComputeSquareRoot() @@ -241,11 +196,22 @@ AssertHelpers.AlmostEqual(new Complex(2048.0, -2048.0), complex.SquareRoot(), 15); complex = new Complex(8.388608e6, 1.19209289550780998537e-7); AssertHelpers.AlmostEqual(new Complex(2896.3093757400989, 2.0579515874459933e-11), complex.SquareRoot(), 15); + complex = new Complex(0.0, 0.0); + AssertHelpers.AlmostEqual(Complex.Zero, complex.SquareRoot(), 15); + } + + [Test] + [Row(1, -2, "1 -2i")] + [Row(1, 2, "1 + 2i")] + [Row(1, 0, "1")] + [Row(0, -2, "-2i")] + [Row(0, 2, "2i")] + public void CanConvertComplexToString(double real, double imag, string expected) + { + var a = new Complex(real, imag); + Assert.AreEqual(expected, a.ToString()); } - /// - /// The can convert double to complex. - /// [Test] [MultipleAsserts] public void CanConvertDoubleToComplex() @@ -255,9 +221,68 @@ Assert.AreEqual(1.1, new Complex(1.1, 0)); } - /// - /// The can create complex number using the constructor. - /// + [Test] + [Row("-1", -1, 0)] + [Row("-i", 0, -1)] + [Row("i", 0, 1)] + [Row("2i", 0, 2)] + [Row("1 + 2i", 1, 2)] + [Row("1+2i", 1, 2)] + [Row("1 - 2i", 1, -2)] + [Row("1-2i", 1, -2)] + [Row("1,2", 1, 2)] + [Row("1 , 2", 1, 2)] + [Row("1,2i", 1, 2)] + [Row("-1, -2i", -1, -2)] + [Row("(+1,2i)", 1, 2)] + [Row("(-1 , -2)", -1, -2)] + [Row("(-1 , -2i)", -1, -2)] + [Row("(+1e1 , -2e-2i)", 10, -0.02)] + [Row("(-1E1 -2e2i)", -10, -200)] + [Row("(-1e+1 -2e2i)", -10, -200)] + [Row("(-1e1 -2e+2i)", -10, -200)] + [Row("(-1e-1 -2E2i)", -0.1, -200)] + [Row("(-1e1 -2e-2i)", -10, -0.02)] + [Row("(-1E+1 -2e+2i)", -10, -200)] + [Row("(-1e-1,-2e-2i)", -0.1, -0.02)] + [Row("(+1 +2i)", 1, 2)] + public void CanConvertStringToComplexUsingTryParse(string str, double expectedReal, double expectedImag) + { + Complex z; + var ret = Complex.TryParse(str, out z); + Assert.IsTrue(ret); + Assert.AreEqual(expectedReal, z.Real); + Assert.AreEqual(expectedImag, z.Imaginary); + + ret = Complex.TryParse("(-1E+1 -2e+2i)", out z); + Assert.IsTrue(ret); + Assert.AreEqual(-10, z.Real); + Assert.AreEqual(-200, z.Imaginary); + + ret = Complex.TryParse("(-1e-1,-2e-2i)", out z); + Assert.IsTrue(ret); + Assert.AreEqual(-.1, z.Real); + Assert.AreEqual(-.02, z.Imaginary); + + ret = Complex.TryParse("(+1 +2i)", out z); + Assert.IsTrue(ret); + Assert.AreEqual(1, z.Real); + Assert.AreEqual(2, z.Imaginary); + } + + [Test] + public void CanParseStringToComplex() + { + var actual = Complex.Parse("-1 -2i"); + Assert.AreEqual(new Complex(-1,-2), actual); + } + + [Test] + public void ParseThrowsFormatExceptionIfMissingClosingParen() + { + Assert.Throws(() => Complex.Parse("(1,2")); + } + [Test] [MultipleAsserts] public void CanCreateComplexNumberUsingTheConstructor() @@ -267,9 +292,6 @@ Assert.AreEqual(-2.2, complex.Imaginary, "Imaginary part is -2.2."); } - /// - /// The can create complex number with modulus argument. - /// [Test] [MultipleAsserts] public void CanCreateComplexNumberWithModulusArgument() @@ -279,9 +301,6 @@ Assert.AreApproximatelyEqual(-1, complex.Imaginary, 1e-15, "Imaginary part is -1."); } - /// - /// The can create complex number with real imaginary intializer. - /// [Test] [MultipleAsserts] public void CanCreateComplexNumberWithRealImaginaryIntializer() @@ -291,9 +310,6 @@ Assert.AreEqual(-2.2, complex.Imaginary, "Imaginary part is -2.2."); } - /// - /// The can create string from complex number. - /// [Test] [MultipleAsserts] public void CanCreateStringFromComplexNumber() @@ -306,9 +322,6 @@ Assert.AreEqual("1.1 + 1.1i", new Complex(1.1, 1.1).ToString()); } - /// - /// The can create string using format provider. - /// [Test] [MultipleAsserts] public void CanCreateStringUsingFormatProvider() @@ -322,9 +335,6 @@ Assert.AreEqual("1,1 + 1,1i", new Complex(1.1, 1.1).ToString(provider)); } - /// - /// The can create string using number format. - /// [Test] [MultipleAsserts] public void CanCreateStringUsingNumberFormat() @@ -337,9 +347,6 @@ Assert.AreEqual("1.100 + 1.100i", new Complex(1.1, 1.1).ToString("#.000")); } - /// - /// The can determine if imaginary unit. - /// [Test] public void CanDetermineIfImaginaryUnit() { @@ -347,9 +354,6 @@ Assert.IsTrue(complex.IsI, "Imaginary unit"); } - /// - /// The can determine if infinity. - /// [Test] [MultipleAsserts] public void CanDetermineIfInfinity() @@ -362,9 +366,6 @@ Assert.IsTrue(complex.IsInfinity, "Both parts are infinity."); } - /// - /// The can determine if na n. - /// [Test] [MultipleAsserts] public void CanDetermineIfNaN() @@ -377,9 +378,6 @@ Assert.IsTrue(complex.IsNaN, "Both parts are NaN."); } - /// - /// The can determine if one value complex number. - /// [Test] public void CanDetermineIfOneValueComplexNumber() { @@ -387,9 +385,6 @@ Assert.IsTrue(complex.IsOne, "Complex number with a value of one."); } - /// - /// The can determine if real non negative number. - /// [Test] public void CanDetermineIfRealNonNegativeNumber() { @@ -397,9 +392,6 @@ Assert.IsTrue(complex.IsReal, "Is a real non-negative number."); } - /// - /// The can determine if real number. - /// [Test] public void CanDetermineIfRealNumber() { @@ -407,9 +399,6 @@ Assert.IsTrue(complex.IsReal, "Is a real number."); } - /// - /// The can determine if zero value complex number. - /// [Test] public void CanDetermineIfZeroValueComplexNumber() { @@ -417,9 +406,6 @@ Assert.IsTrue(complex.IsZero, "Zero complex number."); } - /// - /// The can divide complex number and double using operators. - /// [Test] [MultipleAsserts] public void CanDivideComplexNumberAndDoubleUsingOperators() @@ -427,12 +413,10 @@ AssertEx.That(() => (Complex.NaN * 1.0).IsNaN); Assert.AreEqual(new Complex(-2, 2), new Complex(4, -4) / -2); Assert.AreEqual(new Complex(0.25, 0.25), 2 / new Complex(4, -4)); + Assert.AreEqual(Complex.Infinity, 2.0 / Complex.Zero); Assert.AreEqual(Complex.Infinity, Complex.One / 0); } - /// - /// The can divide two complex numbers. - /// [Test] [MultipleAsserts] public void CanDivideTwoComplexNumbers() @@ -442,9 +426,6 @@ Assert.AreEqual(Complex.Infinity, Complex.One.Divide(Complex.Zero)); } - /// - /// The can divide two complex numbers using operators. - /// [Test] [MultipleAsserts] public void CanDivideTwoComplexNumbersUsingOperators() @@ -454,9 +435,6 @@ Assert.AreEqual(Complex.Infinity, Complex.One / Complex.Zero); } - /// - /// The can multiple complex number and double using operators. - /// [Test] [MultipleAsserts] public void CanMultipleComplexNumberAndDoubleUsingOperators() @@ -466,9 +444,6 @@ Assert.AreEqual(new Complex(8, -8), 2 * new Complex(4, -4)); } - /// - /// The can multiple two complex numbers. - /// [Test] [MultipleAsserts] public void CanMultipleTwoComplexNumbers() @@ -477,9 +452,6 @@ Assert.AreEqual(new Complex(0, 16), new Complex(4, -4).Multiply(new Complex(-2, 2))); } - /// - /// The can multiple two complex numbers using operators. - /// [Test] [MultipleAsserts] public void CanMultipleTwoComplexNumbersUsingOperators() @@ -488,9 +460,6 @@ Assert.AreEqual(new Complex(0, 16), new Complex(4, -4) * new Complex(-2, 2)); } - /// - /// The can negate value. - /// [Test] public void CanNegateValue() { @@ -498,9 +467,6 @@ Assert.AreEqual(new Complex(-1.1, 2.2), complex.Negate()); } - /// - /// The can negate value using operator. - /// [Test] public void CanNegateValueUsingOperator() { @@ -508,9 +474,6 @@ Assert.AreEqual(new Complex(-1.1, 2.2), -complex); } - /// - /// The can subtract complex number and double using operartor. - /// [Test] [MultipleAsserts] public void CanSubtractComplexNumberAndDoubleUsingOperartor() @@ -525,9 +488,6 @@ AssertEx.That(() => -2.2 - new Complex(-1.1, 2.2) == new Complex(-1.1, -2.2)); } - /// - /// The can subtract two complex numbers. - /// [Test] [MultipleAsserts] public void CanSubtractTwoComplexNumbers() @@ -538,9 +498,6 @@ AssertEx.That(() => new Complex(1.1, -2.2).Subtract(new Complex(1.1, -2.2)) == Complex.Zero); } - /// - /// The can test for equality. - /// [Test] [MultipleAsserts] public void CanTestForEquality() @@ -551,9 +508,6 @@ Assert.AreNotEqual(new Complex(-1.1, 2.2), new Complex(1.1, -2.2)); } - /// - /// The can test for equality using operators. - /// [Test] [MultipleAsserts] public void CanTestForEqualityUsingOperators() @@ -564,9 +518,6 @@ AssertEx.That(() => new Complex(-1.1, 2.2) != new Complex(1.1, -2.2)); } - /// - /// The can use plus. - /// [Test] public void CanUsePlus() { @@ -574,9 +525,6 @@ Assert.AreEqual(complex, complex.Plus()); } - /// - /// The can use plus operator. - /// [Test] public void CanUsePlusOperator() { @@ -584,43 +532,6 @@ Assert.AreEqual(complex, +complex); } - /// - /// The with modulus argument throws argument out of range exception. - /// - [Test] - public void WithModulusArgumentThrowsArgumentOutOfRangeException() - { - Assert.Throws( - () => Complex.WithModulusArgument(-1, 1), "Throws exception because modulus is negative."); - } - - - [Test] - [Row(1,-2,"1 -2i")] - [Row(1, 2, "1 + 2i")] - [Row(1, 0, "1")] - [Row(0, -2, "-2i")] - [Row(0, 2, "2i")] - public void CanConvertComplexToString(double real, double imag, string expected) - { - var a = new Complex(real, imag); - Assert.AreEqual(expected, a.ToString()); - } - - [Test] - [Row("")] - [Row("+")] - [Row("1i+2")] - [Row(null)] - public void TryParseReturnsFalseWhenGiveBadValue(string str) - { - Complex z; - bool ret = Complex.TryParse(str, out z); - Assert.IsFalse(ret); - Assert.AreEqual(0, z.Real); - Assert.AreEqual(0, z.Imaginary); - } - [Test] public void TryParseCanHandleSymbols() { @@ -650,57 +561,50 @@ Assert.IsTrue(ret); Assert.AreEqual(double.MaxValue, z.Real); Assert.AreEqual(double.MinValue, z.Imaginary); - } [Test] - [Row("-1", -1, 0)] - [Row("-i", 0, -1)] - [Row("i", 0, 1)] - [Row("2i", 0, 2)] - [Row("1 + 2i", 1, 2)] - [Row("1+2i", 1, 2)] - [Row("1 - 2i", 1, -2)] - [Row("1-2i", 1, -2)] - [Row("1,2", 1, 2)] - [Row("1 , 2", 1, 2)] - [Row("1,2i", 1, 2)] - [Row("-1, -2i", -1, -2)] - [Row("(+1,2i)", 1, 2)] - [Row("(-1 , -2)", -1, -2)] - [Row("(-1 , -2i)", -1, -2)] - [Row("(+1e1 , -2e-2i)", 10, -0.02)] - [Row("(-1E1 -2e2i)", -10, -200)] - [Row("(-1e+1 -2e2i)", -10, -200)] - [Row("(-1e1 -2e+2i)", -10, -200)] - [Row("(-1e-1 -2E2i)", -0.1, -200)] - [Row("(-1e1 -2e-2i)", -10, -0.02)] - [Row("(-1E+1 -2e+2i)", -10, -200)] - [Row("(-1e-1,-2e-2i)", -0.1, -0.02)] - [Row("(+1 +2i)", 1, 2)] - public void CanConvertStringToComplexUsingTryParse(string str, double expectedReal, double expectedImag) + [Row("")] + [Row("+")] + [Row("1i+2")] + [Row(null)] + public void TryParseReturnsFalseWhenGiveBadValue(string str) { Complex z; var ret = Complex.TryParse(str, out z); - Assert.IsTrue(ret); - Assert.AreEqual(expectedReal, z.Real); - Assert.AreEqual(expectedImag, z.Imaginary); - - ret = Complex.TryParse("(-1E+1 -2e+2i)", out z); - Assert.IsTrue(ret); - Assert.AreEqual(-10, z.Real); - Assert.AreEqual(-200, z.Imaginary); + Assert.IsFalse(ret); + Assert.AreEqual(0, z.Real); + Assert.AreEqual(0, z.Imaginary); + } - ret = Complex.TryParse("(-1e-1,-2e-2i)", out z); - Assert.IsTrue(ret); - Assert.AreEqual(-.1, z.Real); - Assert.AreEqual(-.02, z.Imaginary); + [Test] + public void WithModulusArgumentThrowsArgumentOutOfRangeException() + { + Assert.Throws( + () => Complex.WithModulusArgument(-1, 1), "Throws exception because modulus is negative."); + } - ret = Complex.TryParse("(+1 +2i)", out z); - Assert.IsTrue(ret); - Assert.AreEqual(1, z.Real); - Assert.AreEqual(2, z.Imaginary); + [Test] + [Row(0.0, 0.0, 0.0)] + [Row(0.0, 1.0, 1.0)] + [Row(-1.0, 1.0, 1.4142135623730951)] + [Row(-111.1, 111.1, 157.11912677965086)] + public void CanComputeModulus(double real, double imag, double expected) + { + Assert.AreEqual(expected, new Complex(real, imag).Modulus); } + [Test] + [Row(double.PositiveInfinity, double.PositiveInfinity, Constants.Sqrt1Over2, Constants.Sqrt1Over2)] + [Row(double.PositiveInfinity, double.NegativeInfinity, Constants.Sqrt1Over2, -Constants.Sqrt1Over2)] + [Row(double.NegativeInfinity, double.PositiveInfinity, -Constants.Sqrt1Over2, -Constants.Sqrt1Over2)] + [Row(double.NegativeInfinity, double.NegativeInfinity, -Constants.Sqrt1Over2, Constants.Sqrt1Over2)] + [Row(0.0, 0.0, 0.0, 0.0)] + [Row(-1.0, 1.0, -0.70710678118654746, 0.70710678118654746)] + [Row(-111.1, 111.1, -0.70710678118654746, 0.70710678118654746)] + public void CanComputeSign(double real, double imag, double expectedReal, double expectedImag) + { + Assert.AreEqual(new Complex(expectedReal, expectedImag), new Complex(real, imag).Sign); + } } } \ No newline at end of file diff --git a/src/Managed/Complex.cs b/src/Managed/Complex.cs index 49b3e806..d1c55534 100644 --- a/src/Managed/Complex.cs +++ b/src/Managed/Complex.cs @@ -1,26 +1,11 @@ -// -// Math.NET Numerics, part of the Math.NET Project -// http://mathnet.opensourcedotnet.info -// Copyright (c) 2009 Math.NET -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. +// -------------------------------------------------------------------------------------------------------------------- +// +// // +// +// Complex numbers class. +// +// -------------------------------------------------------------------------------------------------------------------- namespace MathNet.Numerics { @@ -551,38 +536,31 @@ namespace MathNet.Numerics Complex result; - if (Real.AlmostZero() && Imaginary.AlmostZero()) + var absReal = Math.Abs(Real); + var absImag = Math.Abs(Imaginary); + double w; + if (absReal >= absImag) { - result = Zero; + var ratio = Imaginary / Real; + w = Math.Sqrt(absReal) * Math.Sqrt(0.5 * (1.0 + Math.Sqrt(1.0 + (ratio * ratio)))); } else { - var absReal = Math.Abs(Real); - var absImag = Math.Abs(Imaginary); - double w; - if (absReal >= absImag) - { - var ratio = Imaginary / Real; - w = Math.Sqrt(absReal) * Math.Sqrt(0.5 * (1.0 + Math.Sqrt(1.0 + (ratio * ratio)))); - } - else - { - var ratio = Real / Imaginary; - w = Math.Sqrt(absImag) * Math.Sqrt(0.5 * (Math.Abs(ratio) + Math.Sqrt(1.0 + (ratio * ratio)))); - } + var ratio = Real / Imaginary; + w = Math.Sqrt(absImag) * Math.Sqrt(0.5 * (Math.Abs(ratio) + Math.Sqrt(1.0 + (ratio * ratio)))); + } - if (Real >= 0.0) - { - result = new Complex(w, Imaginary / (2.0 * w)); - } - else if (Imaginary >= 0.0) - { - result = new Complex(absImag / (2.0 * w), w); - } - else - { - result = new Complex(absImag / (2.0 * w), -w); - } + if (Real >= 0.0) + { + result = new Complex(w, Imaginary / (2.0 * w)); + } + else if (Imaginary >= 0.0) + { + result = new Complex(absImag / (2.0 * w), w); + } + else + { + result = new Complex(absImag / (2.0 * w), -w); } return result; @@ -1068,7 +1046,9 @@ namespace MathNet.Numerics /// Returns a Norm of a value of this type, which is appropriate for measuring how /// close this value is to zero. /// - /// A norm of this value. + /// + /// A norm of this value. + /// double IPrecisionSupport.Norm() { return ModulusSquared; @@ -1078,8 +1058,12 @@ namespace MathNet.Numerics /// Returns a Norm of the difference of two values of this type, which is /// appropriate for measuring how close together these two values are. /// - /// The value to compare with. - /// A norm of the difference between this and the other value. + /// + /// The value to compare with. + /// + /// + /// A norm of the difference between this and the other value. + /// double IPrecisionSupport.NormOfDifference(Complex otherValue) { return (this - otherValue).ModulusSquared; @@ -1088,13 +1072,18 @@ namespace MathNet.Numerics #endregion #region Parse Functions + /// /// Creates a complex number based on a string. The string can be in the following /// formats(without the quotes): 'n', 'ni', 'n +/- ni', 'n,n', 'n,ni,' '(n,n)', or /// '(n,ni)', where n is a real number. /// - /// A complex number containing the value specified by the given string. - /// The string to parse. + /// + /// A complex number containing the value specified by the given string. + /// + /// + /// The string to parse. + /// public static Complex Parse(string value) { return Parse(value, null); @@ -1105,9 +1094,15 @@ namespace MathNet.Numerics /// formats(without the quotes): 'n', 'ni', 'n +/- ni', 'n,n', 'n,ni,' '(n,n)', or /// '(n,ni)', where n is a double. /// - /// A complex number containing the value specified by the given string. - /// the string to parse. - /// An IFormatProvider that supplies culture-specific formatting information. + /// + /// A complex number containing the value specified by the given string. + /// + /// + /// the string to parse. + /// + /// + /// An IFormatProvider that supplies culture-specific formatting information. + /// public static Complex Parse(string value, IFormatProvider formatProvider) { if (value == null) @@ -1208,10 +1203,16 @@ namespace MathNet.Numerics /// Converts the string representation of a complex number to a double-precision complex number equivalent. /// A return value indicates whether the conversion succeeded or failed. /// - /// A string containing a complex number to convert. - /// The parsed value. - /// If the conversion succeeds, the result will contain a complex number equivalent to value. - /// Otherwise the result will contain complex32.Zero. This parameter is passed uninitialized + /// + /// A string containing a complex number to convert. + /// + /// + /// The parsed value. + /// + /// + /// If the conversion succeeds, the result will contain a complex number equivalent to value. + /// Otherwise the result will contain complex32.Zero. This parameter is passed uninitialized + /// public static bool TryParse(string value, out Complex result) { return TryParse(value, null, out result); @@ -1221,9 +1222,15 @@ namespace MathNet.Numerics /// Converts the string representation of a complex number to double-precision complex number equivalent. /// A return value indicates whether the conversion succeeded or failed. /// - /// A string containing a complex number to convert. - /// An IFormatProvider that supplies culture-specific formatting information about value. - /// The parsed value. + /// + /// A string containing a complex number to convert. + /// + /// + /// An IFormatProvider that supplies culture-specific formatting information about value. + /// + /// + /// The parsed value. + /// /// /// If the conversion succeeds, the result will contain a complex number equivalent to value. /// Otherwise the result will contain complex32.Zero. This parameter is passed uninitialized @@ -1249,6 +1256,7 @@ namespace MathNet.Numerics return ret; } + #endregion } } \ No newline at end of file