Qucs-core
0.0.19
|
00001 /* 00002 * complex.h - complex number class definitions 00003 * 00004 * Copyright (C) 2008 Stefan Jahn <stefan@lkcc.org> 00005 * 00006 * This is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2, or (at your option) 00009 * any later version. 00010 * 00011 * This software is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this package; see the file COPYING. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 * $Id$ 00022 * 00023 */ 00024 00025 #ifndef __COMPLEX_H__ 00026 #define __COMPLEX_H__ 00027 00028 #include <complex> 00029 #include "real.h" 00030 00031 typedef std::complex<nr_double_t> nr_complex_t; 00032 00033 // undefine this macro if it is defined already 00034 #ifdef log2 00035 #undef log2 00036 #endif 00037 00038 namespace qucs { 00039 00040 // see http://www.cplusplus.com/reference/complex/ 00041 00042 // 00043 // trigonometric complex 00044 // 00045 nr_complex_t cos (const nr_complex_t); 00046 nr_complex_t sin (const nr_complex_t); 00047 nr_complex_t tan (const nr_complex_t); 00048 nr_complex_t acos (const nr_complex_t); //c++11 00049 nr_complex_t asin (const nr_complex_t); //c++11 00050 nr_complex_t atan (const nr_complex_t); //c++11 00051 00052 // 00053 // hyperbolic complex 00054 // 00055 nr_complex_t cosh (const nr_complex_t); 00056 nr_complex_t sinh (const nr_complex_t); 00057 nr_complex_t tanh (const nr_complex_t); 00058 nr_complex_t acosh (const nr_complex_t); //c++11 00059 nr_complex_t asinh (const nr_complex_t); //c++11 00060 nr_complex_t atanh (const nr_complex_t); //c++11 00061 00062 // 00063 // transcendentals overloads 00064 // 00065 nr_complex_t exp (const nr_complex_t); 00066 nr_complex_t log (const nr_complex_t); 00067 nr_complex_t log10 (const nr_complex_t); 00068 nr_complex_t pow (const nr_complex_t, const nr_double_t); 00069 nr_complex_t pow (const nr_double_t, const nr_complex_t); 00070 nr_complex_t pow (const nr_complex_t, const nr_complex_t); 00071 nr_complex_t sqrt (const nr_complex_t); 00072 00073 nr_double_t norm (const nr_complex_t); 00074 00075 00076 // 00077 // Qucs extra trancendental functions 00078 // 00079 nr_complex_t cot (const nr_complex_t); 00080 nr_complex_t acot (const nr_complex_t); 00081 nr_complex_t coth (const nr_complex_t); 00082 nr_complex_t acoth (const nr_complex_t); 00083 nr_complex_t sech (const nr_complex_t); 00084 nr_complex_t asech (const nr_complex_t); 00085 nr_complex_t cosech (const nr_complex_t); 00086 nr_complex_t atan2 (const nr_complex_t, const nr_complex_t); 00087 00088 00089 // 00090 // extra math 00091 // 00092 nr_complex_t log2 (const nr_complex_t); 00093 nr_complex_t signum (const nr_complex_t); 00094 nr_complex_t sign (const nr_complex_t); 00095 nr_complex_t sinc (const nr_complex_t); 00096 nr_double_t xhypot (const nr_complex_t, const nr_complex_t); 00097 nr_double_t xhypot (const nr_double_t, const nr_complex_t); 00098 nr_double_t xhypot (const nr_complex_t, const nr_double_t); 00099 00100 nr_complex_t round (const nr_complex_t); 00101 nr_complex_t trunc (const nr_complex_t); 00102 00103 00104 nr_double_t dB (const nr_complex_t); 00105 00106 nr_complex_t limexp (const nr_complex_t); 00107 00108 nr_complex_t polar (const nr_double_t mag, const nr_double_t theta = 0.0); 00110 //nr_complex_t polar (const nr_double_t a, const nr_complex_t p); 00111 //nr_complex_t polar (const nr_complex_t a, const nr_double_t p = 0.0); 00112 nr_complex_t polar (const nr_complex_t a, const nr_complex_t p = 0.0); 00113 00114 00115 nr_complex_t ztor (const nr_complex_t, const nr_complex_t zref = 50.0); 00116 nr_complex_t rtoz (const nr_complex_t, const nr_complex_t zref = 50.0); 00117 nr_complex_t ytor (const nr_complex_t, const nr_complex_t zref = 50.0); 00118 nr_complex_t rtoy (const nr_complex_t, const nr_complex_t zref = 50.0); 00119 00120 00121 nr_complex_t floor (const nr_complex_t ); 00122 nr_complex_t ceil (const nr_complex_t ); 00123 nr_complex_t fix (const nr_complex_t ); 00124 00126 nr_complex_t fmod (const nr_complex_t x, const nr_complex_t y); 00127 nr_complex_t sqr (const nr_complex_t z); 00128 00129 nr_complex_t step (const nr_complex_t); 00130 00131 00132 // bessel functions 00133 nr_complex_t jn (const int, const nr_complex_t); 00134 nr_complex_t yn (const int, const nr_complex_t); 00135 nr_complex_t i0 (const nr_complex_t); 00136 00137 00138 // error functions 00139 nr_complex_t erf (const nr_complex_t); 00140 nr_complex_t erfc (const nr_complex_t); 00141 nr_complex_t erfinv (const nr_complex_t); //see fspecial 00142 nr_complex_t erfcinv (const nr_complex_t); //see fspecial 00143 00144 00145 nr_double_t rad2deg (const nr_complex_t ); 00146 nr_double_t deg2rad (const nr_complex_t ); 00147 00148 // modulo operators 00149 nr_complex_t operator % (const nr_complex_t, const nr_complex_t); 00150 nr_complex_t operator % (const nr_complex_t, const nr_double_t); 00151 nr_complex_t operator % (const nr_double_t, const nr_complex_t); 00152 00153 // comparisons 00154 bool operator == (const nr_complex_t, const nr_complex_t); 00155 bool operator != (const nr_complex_t, const nr_complex_t); 00156 bool operator >= (const nr_complex_t, const nr_complex_t); 00157 bool operator <= (const nr_complex_t, const nr_complex_t); 00158 bool operator > (const nr_complex_t, const nr_complex_t); 00159 bool operator < (const nr_complex_t, const nr_complex_t); 00160 00161 } // namespace qucs 00162 00163 #endif /* __COMPLEX_H__ */