cx_arith.h

Go to the documentation of this file.
00001 /*
00002   -------------------------------------------------------------------
00003   
00004   Copyright (C) 2006, 2007, 2008, 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     \todo Define operators with assignment for complex + double
00029     \todo Ensure all the trig functions are tested
00030 */
00031 
00032 #include <iostream>
00033 #include <complex>
00034 #include <cmath>
00035 
00036 // For M_PI and M_PI_2
00037 #include <gsl/gsl_math.h>
00038 #include <gsl/gsl_complex.h>
00039 #include <gsl/gsl_complex_math.h>
00040 
00041 /** 
00042     \brief A namespace for arithmetic on complex numbers and vectors
00043 */
00044 namespace o2scl_arith {
00045 
00046   /// \name Binary operators for two complex numbers
00047   //@{
00048   /// Add two complex numbers
00049   gsl_complex operator+(gsl_complex x, gsl_complex y);
00050 
00051   /// Subtract two complex numbers
00052   gsl_complex operator-(gsl_complex x, gsl_complex y);
00053 
00054   /// Multiply two complex numbers
00055   gsl_complex operator*(gsl_complex x, gsl_complex y);
00056 
00057   /// Divide two complex numbers
00058   gsl_complex operator/(gsl_complex x, gsl_complex y);
00059   //@}
00060 
00061   /// \name Binary operators with assignment for two complex numbers
00062   //@{
00063   /// Add a complex number
00064   gsl_complex operator+=(gsl_complex &x, gsl_complex y);
00065 
00066   /// Subtract a complex number
00067   gsl_complex operator-=(gsl_complex &x, gsl_complex y);
00068 
00069   /// Multiply a complex number
00070   gsl_complex operator*=(gsl_complex &x, gsl_complex y);
00071 
00072   /// Divide a complex number
00073   gsl_complex operator/=(gsl_complex &x, gsl_complex y);
00074   //@}
00075 
00076   /// \name Binary operators with assignment for a complex and real
00077   //@{
00078   /// Add a complex and real number
00079   gsl_complex operator+(gsl_complex x, double y);
00080 
00081   /// Add a complex and real number
00082   gsl_complex operator+(double y, gsl_complex x);
00083 
00084   /// Subtract a complex and real number
00085   gsl_complex operator-(gsl_complex x, double y);
00086 
00087   /// Subtract a complex and real number
00088   gsl_complex operator-(double y, gsl_complex x);
00089 
00090   /// Multiply a complex and real number
00091   gsl_complex operator*(gsl_complex x, double y);
00092 
00093   /// Multiply a complex and real number
00094   gsl_complex operator*(double y, gsl_complex x);
00095 
00096   /// Divide a complex and real number
00097   gsl_complex operator/(gsl_complex x, double y);
00098   //@}
00099 
00100   /// \name Miscellaneous functions
00101   //@{
00102   double arg(gsl_complex x);
00103   double abs(gsl_complex x);
00104   double abs2(gsl_complex z);
00105   gsl_complex conjugate(gsl_complex a);
00106   //@}
00107 
00108   /// \name Square root and exponent functions
00109   //@{
00110   gsl_complex sqrt(gsl_complex a);
00111   gsl_complex sqrt_real(double x);
00112   gsl_complex pow(gsl_complex a, gsl_complex b);
00113   gsl_complex pow_real(gsl_complex a, double b);
00114   //@}
00115   
00116   /// \name Logarithmic and exponential functions
00117   //@{
00118   double logabs(gsl_complex z);
00119   gsl_complex exp(gsl_complex a);
00120   gsl_complex log(gsl_complex a);
00121   gsl_complex log10(gsl_complex a);
00122   gsl_complex log_b(gsl_complex a, gsl_complex b);
00123   //@}
00124 
00125   /// \name Trigonometric functions
00126   //@{
00127   gsl_complex sin(gsl_complex a);
00128   gsl_complex cos(gsl_complex a);
00129   gsl_complex tan(gsl_complex a);
00130   gsl_complex sec(gsl_complex a);
00131   gsl_complex csc(gsl_complex a);
00132   gsl_complex cot(gsl_complex a);
00133   gsl_complex asin(gsl_complex a);
00134   gsl_complex asin_real(double a);
00135   gsl_complex acos(gsl_complex a);
00136   gsl_complex acos_real(double a);
00137   gsl_complex atan(gsl_complex a);
00138   gsl_complex asec(gsl_complex a);
00139   gsl_complex asec_real(double a);
00140   gsl_complex acsc(gsl_complex a);
00141   gsl_complex acsc_real(double a);
00142   gsl_complex acot(gsl_complex a);
00143   //@}
00144 
00145   /// \name Hyperbolic trigonometric functions
00146   //@{
00147   gsl_complex sinh(gsl_complex a);
00148   gsl_complex cosh(gsl_complex a);
00149   gsl_complex tanh(gsl_complex a);
00150   gsl_complex sech(gsl_complex a);
00151   gsl_complex csch(gsl_complex a);
00152   gsl_complex coth(gsl_complex a);
00153   gsl_complex asinh(gsl_complex a);
00154   gsl_complex acosh(gsl_complex a);
00155   gsl_complex acosh_real(double a);
00156   gsl_complex atanh(gsl_complex a);
00157   gsl_complex atanh_real(double a);
00158   gsl_complex asech(gsl_complex a);
00159   gsl_complex acsch(gsl_complex a);
00160   gsl_complex acoth(gsl_complex a);
00161   //@}
00162 
00163 }
00164 
00165 #endif

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page