Mail Archives: djgpp/1996/12/18/04:05:50
>
> Can any one tell where to find an example of using the complex class in
> djgpp ?
#include <iostream.h>
#include <iomanip.h>
#ifdef MSDOS
#include <_Complex.h> // _ because MS-DOS is case-insensitive
#else
#include <Complex.h>
#endif
int main()
{
Complex dx(2,3), dy; // default is complex<double>
complex<long double> ldx(2,3), ldy;
dy = 1 / dx;
ldy = 1 / ldx;
cout << "Using double : ";
cout << "1/" << dx << " = " << dy;
cout << " Error = " << abs(dx * dy - 1) << endl;
cout << "Using long double: ";
cout << "1/" << ldx << " = " << ldy;
cout << " Error = " << abs(ldx * ldy - 1) << endl;
ldx = complex<long double>(0, PI);
ldy = exp(ldx);
ldy += 1;
cout << "e^(i*PI) + 1 = " << ldy << endl;
return 0;
}
> i want eventually to create a matrix of complex numbers.
>
I'm busy writing a matrix class. If you are interested, please E-mail me.
----
Koen Van Herck
Electronic Design Engineer
E-mail: Koen DOT VanHerck AT barco DOT com
BBBB AAA RRRR CCC OOO B A R C O V I S U A L S Y S T E M S
B B A A R R C O O A division of Barco Projection Systems
B BB A AAA R RR C OO O OO
B B A A R R C O O Noordlaan 5 Tel +32 (0)56 36 85 71
BBBB A A R R CCC OOO B-8520 Kuurne Fax +32 (0)56 36 83 55
- Raw text -