00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, 2009, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef O2SCL_CX_ARITH_H 00024 #define O2SCL_CX_ARITH_H 00025 /** \file cx_arith.h 00026 \brief Complex arithmetic 00027 00028 \note One should be careful about including this header file, 00029 especially in other header files as it overloads some of the 00030 standard mathematical functions, i.e. <tt>sqrt()</tt>. If you need 00031 access to both these functions and the standard functions for 00032 <tt>double</tt> objects, the easiest way is probably to include 00033 this file in a source (not header file) and use <tt>using 00034 namespace std</tt>. 00035 00036 \note This used to be in a separate namespace, called 00037 <tt>o2scl_arith</tt>, but this causes problems with Koenig 00038 lookup in template classes for operator*() when defined 00039 for vector addition (for example). 00040 00041 \todo Ensure all the functions are tested. 00042 \future Define operators with assignment for complex + double? 00043 */ 00044 #include <iostream> 00045 #include <complex> 00046 #include <cmath> 00047 00048 // For M_PI and M_PI_2 00049 #include <gsl/gsl_math.h> 00050 #include <gsl/gsl_complex.h> 00051 #include <gsl/gsl_complex_math.h> 00052 00053 #ifndef DOXYGENP 00054 namespace o2scl { 00055 #endif 00056 00057 /// Convert a complex number to GSL form 00058 gsl_complex complex_to_gsl(std::complex<double> &d); 00059 00060 /// Convert a complex number to STL form 00061 std::complex<double> gsl_to_complex(gsl_complex &g); 00062 00063 /// \name Binary operators for two complex numbers 00064 //@{ 00065 /// Add two complex numbers 00066 gsl_complex operator+(gsl_complex x, gsl_complex y); 00067 00068 /// Subtract two complex numbers 00069 gsl_complex operator-(gsl_complex x, gsl_complex y); 00070 00071 /// Multiply two complex numbers 00072 gsl_complex operator*(gsl_complex x, gsl_complex y); 00073 00074 /// Divide two complex numbers 00075 gsl_complex operator/(gsl_complex x, gsl_complex y); 00076 //@} 00077 00078 /// \name Binary operators with assignment for two complex numbers 00079 //@{ 00080 /// Add a complex number 00081 gsl_complex operator+=(gsl_complex &x, gsl_complex y); 00082 00083 /// Subtract a complex number 00084 gsl_complex operator-=(gsl_complex &x, gsl_complex y); 00085 00086 /// Multiply a complex number 00087 gsl_complex operator*=(gsl_complex &x, gsl_complex y); 00088 00089 /// Divide a complex number 00090 gsl_complex operator/=(gsl_complex &x, gsl_complex y); 00091 //@} 00092 00093 /// \name Binary operators with assignment for a complex and real 00094 //@{ 00095 /// Add a complex and real number 00096 gsl_complex operator+(gsl_complex x, double y); 00097 00098 /// Add a complex and real number 00099 gsl_complex operator+(double y, gsl_complex x); 00100 00101 /// Subtract a complex and real number 00102 gsl_complex operator-(gsl_complex x, double y); 00103 00104 /// Subtract a complex and real number 00105 gsl_complex operator-(double y, gsl_complex x); 00106 00107 /// Multiply a complex and real number 00108 gsl_complex operator*(gsl_complex x, double y); 00109 00110 /// Multiply a complex and real number 00111 gsl_complex operator*(double y, gsl_complex x); 00112 00113 /// Divide a complex and real number 00114 gsl_complex operator/(gsl_complex x, double y); 00115 //@} 00116 00117 /// \name Miscellaneous functions 00118 //@{ 00119 double arg(gsl_complex x); 00120 double abs(gsl_complex x); 00121 double abs2(gsl_complex z); 00122 gsl_complex conjugate(gsl_complex a); 00123 //@} 00124 00125 /// \name Square root and exponent functions 00126 //@{ 00127 gsl_complex sqrt(gsl_complex a); 00128 gsl_complex sqrt_real(double x); 00129 gsl_complex pow(gsl_complex a, gsl_complex b); 00130 gsl_complex pow_real(gsl_complex a, double b); 00131 //@} 00132 00133 /// \name Logarithmic and exponential functions 00134 //@{ 00135 double logabs(gsl_complex z); 00136 gsl_complex exp(gsl_complex a); 00137 gsl_complex log(gsl_complex a); 00138 gsl_complex log10(gsl_complex a); 00139 gsl_complex log_b(gsl_complex a, gsl_complex b); 00140 //@} 00141 00142 /// \name Trigonometric functions 00143 //@{ 00144 gsl_complex sin(gsl_complex a); 00145 gsl_complex cos(gsl_complex a); 00146 gsl_complex tan(gsl_complex a); 00147 gsl_complex sec(gsl_complex a); 00148 gsl_complex csc(gsl_complex a); 00149 gsl_complex cot(gsl_complex a); 00150 gsl_complex asin(gsl_complex a); 00151 gsl_complex asin_real(double a); 00152 gsl_complex acos(gsl_complex a); 00153 gsl_complex acos_real(double a); 00154 gsl_complex atan(gsl_complex a); 00155 gsl_complex asec(gsl_complex a); 00156 gsl_complex asec_real(double a); 00157 gsl_complex acsc(gsl_complex a); 00158 gsl_complex acsc_real(double a); 00159 gsl_complex acot(gsl_complex a); 00160 //@} 00161 00162 /// \name Hyperbolic trigonometric functions 00163 //@{ 00164 gsl_complex sinh(gsl_complex a); 00165 gsl_complex cosh(gsl_complex a); 00166 gsl_complex tanh(gsl_complex a); 00167 gsl_complex sech(gsl_complex a); 00168 gsl_complex csch(gsl_complex a); 00169 gsl_complex coth(gsl_complex a); 00170 gsl_complex asinh(gsl_complex a); 00171 gsl_complex acosh(gsl_complex a); 00172 gsl_complex acosh_real(double a); 00173 gsl_complex atanh(gsl_complex a); 00174 gsl_complex atanh_real(double a); 00175 gsl_complex asech(gsl_complex a); 00176 gsl_complex acsch(gsl_complex a); 00177 gsl_complex acoth(gsl_complex a); 00178 //@} 00179 00180 #ifndef DOXYGENP 00181 } 00182 #endif 00183 00184 #endif
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page