Re: Complex Number Support

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Victor Bazarov" wrote:

> Jon Evans wrote:

> > If someone could post the min num lines of code to
> > 1) Initialise a complex number
> > 2) Take it's square root
> > 3) AND list all the header files / .lib files needed

> In C++ you should do

> #include <complex>
> using std::complex;
>
> int main() {
> complex<double> cd(1,1); // initialise
> complex<double> sq = sqrt(cd); // take a square root
> }
>
> Everything should be the default.

Many thanks ! I now see my fundamental mistake was trying to include a
(non-existant) complex.h.

I had to mod the sqrt line by adding "std::" in front of the 'sqrt' - I only
mention this as having never used this kind of thing I thought I'd check that
this wasn't indicative of me having failed to do something else.

> MFC is a C++ library. If you need to confine yourself to the C language,
> then MFC is not an option.

The majority of the project is C++ (MFC) but contains core analysis
algorithms that are straight C (for portability reasons).

Thanks for pointing me in the right direction,

TTFN,
Jon
.