www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/18/04:05:50

Date: Wed, 18 Dec 1996 09:58:34 GMT
From: kvhk AT ivs4 DOT barco DOT com (Koen Van Herck)
Message-Id: <9612180958.AA19823@ivs4.>
To: tbakir AT mnw DOT net
Cc: djgpp AT delorie DOT com
In-Reply-To: <32B5BC14.6188@mnw.net> (message from tariq bakir on Mon, 16 Dec 1996 13:16:04 -0700)
Subject: Re: complex numbers and arrays of complex
Reply-To: Koen DOT VanHerck AT barco DOT com

> 
> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019