Like BigInteger, the Complex struct is another specialized numeric type new to Framework 4.0 and is for representing complex numbers with real and imaginary components of type double. It also lives in the System.Numerics.dll assembly. To use Complex, instantiate the struct, specifying the real and imvar aginary values: var c1 = new Complex(2, 3.5);
var c2 = new Complex(3, 0);There are also implicit conversions from the standard numeric types.The complex struct exposes properties for the real and imaginary values, as well as the phase and magnitudeL Console. WriteLine(c1.Real); // 2
Console.WriteLine(c1.Imaginary); // 3.5
Console.WriteLine(c1.Phase); // 1.05165021254837
Console.WriteLine(c1.Magnitude); // 4.03112887414927 You can also construct aq Complex number by specifying the magnitude and phase: Complex c3 = Complex.FromPolarCoordinates(1.3, 5);The standard arithmetic operators are overloaded to work on Complex numbers: Console.WriteLine(c1 + c2); // (5, 3.5);
Console.WriteLine(c1 * c2); // (6, 10.5)Read more: Sam Gentile's Blog
var c2 = new Complex(3, 0);There are also implicit conversions from the standard numeric types.The complex struct exposes properties for the real and imaginary values, as well as the phase and magnitudeL Console. WriteLine(c1.Real); // 2
Console.WriteLine(c1.Imaginary); // 3.5
Console.WriteLine(c1.Phase); // 1.05165021254837
Console.WriteLine(c1.Magnitude); // 4.03112887414927 You can also construct aq Complex number by specifying the magnitude and phase: Complex c3 = Complex.FromPolarCoordinates(1.3, 5);The standard arithmetic operators are overloaded to work on Complex numbers: Console.WriteLine(c1 + c2); // (5, 3.5);
Console.WriteLine(c1 * c2); // (6, 10.5)Read more: Sam Gentile's Blog
0 comments:
Post a Comment