Output of file : COMPLEX.H contained in archive : ZPP10.ZIP
/* -------------------------------------------------------------------- */
/* complex.h */
/* */
/* Z++ Version 1.0 Last revised 04/03/92 */
/* */
/* Complex number class for Turbo C++/Borland C++. */
/* Copyright 1992 by Carl W. Moreland */
/* This source code may be freely distributed as long as the copyright */
/* notice remains intact. */
/* -------------------------------------------------------------------- */

#ifndef COMPLEXdotH
#define COMPLEXdotH

#include
#include

#define Z_DEGREES 1
#define Z_COMMA 0 // (x, y)
#define Z_LETTER 1 // x + iy

class complex
{
public:
double re, im;

//private:
static unsigned char zArgMode;
static unsigned char zPrintMode;
static unsigned char zLetter;

public:
complex(void);
complex(const double re, const double im=0);
complex(const complex& z);

friend double re(const complex& z); // real part
friend double im(const complex& z); // imaginary part
friend double real(const complex& z); // real part
friend double imag(const complex& z); // imaginary part
friend double mag(const complex& z); // magnitude
friend double arg(const complex& z); // argument
friend double ang(const complex& z) { return arg(z);}
friend double ph(const complex& z) { return arg(z);}
friend complex conj(const complex& z); // complex conjugate
friend double norm(const complex& z); // the square of the magnitude

friend complex rtop(double x, double y=0);
friend complex ptor(double mag, double angle=0);
complex& topolar(void);
complex& torect(void);

void operator = (const complex&); // z1 = z2
complex& operator += (const complex&); // z1 += z2
complex& operator -= (const complex&); // z1 -= z2
complex& operator *= (const complex&); // z1 *= z2
complex& operator /= (const complex&); // z1 /= z2
complex operator + (void) const; // +z1
complex operator - (void) const; // -z1

friend complex operator + (const complex&, const complex&);
friend complex operator + (const complex&, const double);
friend complex operator + (const double, const complex&);
friend complex operator - (const complex&, const complex&);
friend complex operator - (const complex&, const double);
friend complex operator - (const double, const complex&);
friend complex operator * (const complex&, const complex&);
friend complex operator * (const complex&, const double);
friend complex operator * (const double, const complex&);
friend complex operator / (const complex&, const complex&);
friend complex operator / (const complex&, const double);
friend complex operator / (const double, const complex&);
friend complex operator ^ (const complex&, const complex&);
friend int operator == (const complex&, const complex&);
friend int operator != (const complex&, const complex&);

friend double abs(const complex& z);
friend complex sqrt(const complex& z);
friend complex pow(const complex& base, const complex& exp);
friend complex pow(const complex& base, const double exp);
friend complex pow(const double base, const complex& exp);

friend complex exp(const complex& z);
friend complex log(const complex& z);
friend complex ln(const complex& z) { return log(z); }
friend complex log10(const complex& z);

friend complex cos(const complex& z);
friend complex sin(const complex& z);
friend complex tan(const complex& z);

friend complex acos(const complex& z);
friend complex asin(const complex& z);
friend complex atan(const complex& z);

friend complex cosh(const complex& z);
friend complex sinh(const complex& z);
friend complex tanh(const complex& z);

void SetArgMode(unsigned char mode) const;
void SetPrintMode(unsigned char mode) const;
void SetLetter(unsigned char letter) const;
};

ostream& operator<<(ostream&, const complex&);
istream& operator>>(istream&, const complex&);

static const complex Z0(0, 0); // complex number 0
static const complex Z1(1, 0); // complex number 1
static const complex Zi(0, 1); // complex number i
static const complex Zinf(HUGE_VAL, HUGE_VAL); // complex number infinity
static const complex Complex;

#endif

### 3 Responses to “Category : C++ Source CodeArchive   : ZPP10.ZIPFilename : COMPLEX.H”

1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/