NMath User's Guide

TOC |  Previous |  Next |  Index

3.2 Value Operations on Complex Numbers (.NET, C#, CSharp, Visual Basic, VB.NET)

Both FloatComplex and DoubleComplex have public instance variables Real and Imag that you can use to access and modify the real and imaginary parts of a complex number. For instance:

DoubleComplex c1 = new DoubleComplex( 1.0 );
DoubleComplex c2 = new DoubleComplex( 2.13, 5.6 );
c1.Imag = c2.Imag;
c1.Real = -7.77;

You can also use the static functions Real() and Imag() on class NMathFunctions to return the real and imaginary parts of a complex number:

DoubleComplex c = new DoubleComplex( 2.13, 5.6 );
double d1 = c.Real();
double d2 = NMathFunctions.Real( c );   // d2 == d1

TOC |  Previous |  Next |  Index