complex.h

来自「Gambit 是一个游戏库理论软件」· C头文件 代码 · 共 95 行

H
95
字号
//// $Source: /home/gambit/CVS/gambit/sources/math/complex.h,v $// $Date: 2002/08/26 05:50:01 $// $Revision: 1.3 $//// DESCRIPTION:// Declaration of a complex number class//// This file is part of Gambit// Copyright (c) 2002, The Gambit Project//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//#ifndef _Complex_h#ifdef __GNUG__#pragma interface#endif#define _Complex_h 1#include "base/gstream.h"#include <math.h>class gComplex{protected:  double re;  double im;public:// Constructors, and the destructor  gComplex();  gComplex(const double&, const double&);  gComplex(const gComplex&);  gComplex(const int& n);  gComplex(const long& n);    ~gComplex();// Operators  double      RealPart()                      const;  double      ImaginaryPart()                 const;  gComplex&   operator =  (const gComplex& y);  bool        operator == (const gComplex& y) const;  bool        operator != (const gComplex& y) const;  gComplex    operator +  (const gComplex& y) const;  gComplex    operator -  (const gComplex& y) const;  gComplex    operator *  (const gComplex& y) const;  gComplex    operator /  (const gComplex& y) const;  gComplex    operator -  ()                 const;  void       operator += (const gComplex& y);  void       operator -= (const gComplex& y);  void       operator *= (const gComplex& y);  void       operator /= (const gComplex& y);// error reporting  void    error(const char* msg) const;// printing  friend gInput&    operator >> (gInput& s, gComplex& y);  friend gOutput&   operator << (gOutput& s, const gComplex& y);// friends outside the class  friend double    fabs(const gComplex& x);                friend gComplex  sqr(const gComplex& x);                friend gComplex  pow(const gComplex& x, const long y);};// The following are facilities that are required of all arithmetic types.// For other types they are given in gmisc.hclass gString;gString         ToString(gComplex);gComplex        TOgComplex(const gString &);#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?