?? complex.h
字號(hào):
/*
* complex.h - complex number class definitions
*
* Copyright (C) lartely <luda@hitwh.edu.cn>
*
*/
#include <math.h>
#include <iostream.h>
#ifndef _COMPLEX_DOT_H_
#define _COMPLEX_DOT_H_
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795029
#endif
class complex;
// create a complex object given polar coordinates
complex polar (const double mag, const double ang = 0.0);
// complex manipulations
double re (const double);
double im (const double);
double norm (const double);
double conj (const double);
// overloaded math functions
double xhypot (const double, const double);
double abs (const double);
class complex
{
public:
double real,imag;
public:
complex (double real,double imag=0.0);
complex ();
complex (const complex&);
friend double arg (const complex);
friend double re(const complex);
friend double im(const complex);
friend double norm (const complex);
friend complex conj(const complex);
double re (void); // the real part
double im (void); // the imaginary part
complex conj (void); // the complex conjugate
double abs (void); // the magnitude
//overroad basic math function
friend complex exp (const complex);
friend complex sin (const complex);
friend complex cos (const complex);
friend complex pow (const complex, const double);
// operator functions
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 double);
// comparisons
friend bool operator == (const complex, const complex);
friend bool operator != (const complex, const complex);
// assignment operations
complex& operator = (const complex);
complex& operator = (const double);
complex& operator += (const complex);
complex& operator += (const double);
complex& operator -= (const complex);
complex& operator -= (const double);
complex& operator *= (const complex);
complex& operator *= (const double);
complex operator + ();
complex operator - ();
// debugging
void print (void);
};
#endif /* _COMPLEX_DOT_H_ */
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -