PARP Research Group | Universidad de Murcia |
src/qvmath/qvcomplex.hGo to the documentation of this file.00001 /* 00002 * Copyright (C) 2011, 2012. PARP Research Group. 00003 * <http://perception.inf.um.es> 00004 * University of Murcia, Spain. 00005 * 00006 * This file is part of the QVision library. 00007 * 00008 * QVision is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as 00010 * published by the Free Software Foundation, version 3 of the License. 00011 * 00012 * QVision is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with QVision. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00024 00025 #include <math.h> 00026 #include <iostream> 00027 #include <QPointF> 00028 #ifndef QVCOMPLEX_H 00029 #define QVCOMPLEX_H 00030 00037 class QVComplex 00038 { 00039 private: 00040 double _real, _imaginary; 00041 00042 public: 00043 00044 // ------------------ 00045 // Constructors 00046 00051 QVComplex(); 00052 00057 QVComplex(const QVComplex &complex); 00058 00065 QVComplex(const double real, const double imaginary = 0.0); 00066 00074 QVComplex(const QPointF &point); 00075 00079 QVComplex & operator=(const QVComplex &complex); 00080 00081 // ------------------------------------ 00082 // Complex-complex operators 00083 00088 bool operator==(const QVComplex &complex) const; 00089 00094 QVComplex & operator+=(const QVComplex &complex); 00095 00100 bool operator!=(const QVComplex &complex) const; 00101 00105 QVComplex operator*(const QVComplex &complex) const; 00106 00110 QVComplex operator/(const QVComplex &complex) const; 00111 00115 QVComplex operator+(const QVComplex &complex) const; 00116 00120 QVComplex operator-(const QVComplex &complex) const; 00121 00125 QVComplex operator-() const; 00126 00127 // Complex-scalar operators 00128 00132 QVComplex operator*(const double value) const; 00133 00137 QVComplex operator/(const double value) const; 00138 00142 QVComplex operator+(const double value) const; 00143 00147 QVComplex operator-(const double value) const; 00148 00152 double norm2() const; 00153 00155 inline double real() const { return _real; } 00156 00158 inline double imaginary() const { return _imaginary; } 00159 00161 inline double &real() { return _real; } 00162 00164 inline double &imaginary() { return _imaginary; } 00165 00169 static QVComplex i(); 00170 }; 00171 00174 std::ostream& operator << ( std::ostream &os, const QVComplex &complex ); 00175 00176 #endif 00177 |