00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "SawComplex.h"
00021
00026 SawComplex::SawComplex()
00027 :SawObject()
00028 {
00029 complex = gsl_complex_rect( 0.0, 0.0 ) ;
00030 }
00031
00037 SawComplex::SawComplex( double a, double b, int representation )
00038 {
00039 if( representation == CARTESIAN_REPRESENTATION )
00040 complex = gsl_complex_rect( a, b ) ;
00041 if( representation == POLAR_REPRESENTATION )
00042 complex = gsl_complex_polar( a, b ) ;
00043 }
00044
00049 SawComplex::SawComplex( const SawComplex& c )
00050 {
00051 this->complex = c.getGSLComplex() ;
00052 }
00053
00058 SawComplex::SawComplex( double d )
00059 {
00060 GSL_SET_REAL( &complex, d ) ;
00061 GSL_SET_IMAG( &complex, 0.0 ) ;
00062 }
00063
00069 SawComplex& SawComplex::operator = ( double d )
00070 {
00071
00072
00073 this->setReal( d ) ;
00074 this->setImg( 0.0 ) ;
00075 }
00076
00082 SawComplex& SawComplex::operator = ( const SawComplex& c )
00083 {
00084
00085
00086 this->setReal( c.getReal() ) ;
00087 this->setImg( c.getImg() ) ;
00088 }
00089
00093 SawComplex::~SawComplex()
00094 {
00095 }
00096
00101 double SawComplex::getReal() const
00102 {
00103 return GSL_REAL( complex ) ;
00104 }
00105
00110 double SawComplex::getImg() const
00111 {
00112 return GSL_IMAG( complex ) ;
00113 }
00114
00119 void SawComplex::setReal( double real )
00120 {
00121 GSL_SET_REAL( &complex, real ) ;
00122 }
00123
00128 void SawComplex::setImg( double img )
00129 {
00130 GSL_SET_IMAG( &complex, img ) ;
00131 }
00132
00133 gsl_complex SawComplex::getGSLComplex() const
00134 {
00135 return complex ;
00136 }
00137
00138 void SawComplex::setGSLComplex( gsl_complex complex )
00139 {
00140 this->complex = complex ;
00141 }
00142
00147 double SawComplex::getArg() const
00148 {
00149 return gsl_complex_arg( complex ) ;
00150 }
00151
00156 SawComplex SawComplex::getConjugate() const
00157 {
00158 }
00159
00164 SawComplex SawComplex::getInverse() const
00165 {
00166 }
00167
00174 SawComplex SawComplex::operator + ( SawComplex complex )
00175 {
00176 SawComplex output ;
00177 output.setGSLComplex( gsl_complex_add( this->getGSLComplex(), complex.getGSLComplex() ) ) ;
00178 return output ;
00179 }
00180
00187 SawComplex SawComplex::operator - ( SawComplex complex )
00188 {
00189 SawComplex output ;
00190 output.setGSLComplex( gsl_complex_sub( this->getGSLComplex(), complex.getGSLComplex() ) ) ;
00191 return output ;
00192 }
00193
00200 SawComplex SawComplex::operator * ( SawComplex complex )
00201 {
00202 SawComplex output ;
00203 output.setGSLComplex( gsl_complex_mul( this->getGSLComplex(), complex.getGSLComplex() ) ) ;
00204 return output ;
00205 }
00206
00213 SawComplex SawComplex::operator / ( SawComplex complex )
00214 {
00215 SawComplex output ;
00216 output.setGSLComplex( gsl_complex_div( this->getGSLComplex(), complex.getGSLComplex() ) ) ;
00217 return output ;
00218 }
00219
00226 ostream& operator << ( ostream& os, const SawComplex& e )
00227 {
00228 os.precision( e.precisionOutputStream ) ;
00229
00230 if( e.getImg() != 0.0 )
00231 os << e.getReal() << " + " << e.getImg() << "i" ;
00232 else
00233 os << e.getReal() ;
00234
00235 return os ;
00236 }
00237
00244 istream& operator >> ( istream& is, SawComplex& e )
00245 {
00246 double r, i ;
00247 is >> r ;
00248 is >> i ;
00249 e.setReal( r ) ;
00250 e.setImg( i ) ;
00251
00252 return is ;
00253 }
00254
00260 SawComplex SawComplex::sqrt( SawComplex complex )
00261 {
00262 SawComplex output ;
00263 output.setGSLComplex( gsl_complex_sqrt( complex.getGSLComplex() ) ) ;
00264 return output ;
00265 }
00266
00273 SawComplex SawComplex::pow( SawComplex complex, SawComplex a )
00274 {
00275 SawComplex output ;
00276 output.setGSLComplex( gsl_complex_pow( complex.getGSLComplex(), a.getGSLComplex() ) ) ;
00277 return output ;
00278 }
00279
00286 SawComplex SawComplex::pow( SawComplex complex, double a )
00287 {
00288 SawComplex output ;
00289 output.setGSLComplex( gsl_complex_pow_real( complex.getGSLComplex(), a ) ) ;
00290 return output ;
00291 }
00292
00298 SawComplex SawComplex::exp( SawComplex complex )
00299 {
00300 SawComplex output ;
00301 output.setGSLComplex( gsl_complex_exp( complex.getGSLComplex() ) ) ;
00302 return output ;
00303 }
00304
00310 SawComplex SawComplex::log( SawComplex complex )
00311 {
00312 SawComplex output ;
00313 output.setGSLComplex( gsl_complex_log( complex.getGSLComplex() ) ) ;
00314 return output ;
00315 }
00316
00322 SawComplex SawComplex::log10( SawComplex complex )
00323 {
00324 SawComplex output ;
00325 output.setGSLComplex( gsl_complex_log10( complex.getGSLComplex() ) ) ;
00326 return output ;
00327 }
00328
00334 SawComplex SawComplex::sin( SawComplex complex )
00335 {
00336 SawComplex output ;
00337 output.setGSLComplex( gsl_complex_sin( complex.getGSLComplex() ) ) ;
00338 return output ;
00339 }
00340
00346 SawComplex SawComplex::cos( SawComplex complex )
00347 {
00348 SawComplex output ;
00349 output.setGSLComplex( gsl_complex_cos( complex.getGSLComplex() ) ) ;
00350 return output ;
00351 }
00352
00358 SawComplex SawComplex::tan( SawComplex complex )
00359 {
00360 SawComplex output ;
00361 output.setGSLComplex( gsl_complex_tan( complex.getGSLComplex() ) ) ;
00362 return output ;
00363 }
00364
00370 SawComplex SawComplex::sec( SawComplex complex )
00371 {
00372 SawComplex output ;
00373 output.setGSLComplex( gsl_complex_sec( complex.getGSLComplex() ) ) ;
00374 return output ;
00375 }
00376
00382 SawComplex SawComplex::csc( SawComplex complex )
00383 {
00384 SawComplex output ;
00385 output.setGSLComplex( gsl_complex_csc( complex.getGSLComplex() ) ) ;
00386 return output ;
00387 }
00388
00394 SawComplex SawComplex::cot( SawComplex complex )
00395 {
00396 SawComplex output ;
00397 output.setGSLComplex( gsl_complex_cot( complex.getGSLComplex() ) ) ;
00398 return output ;
00399 }
00400
00406 SawComplex SawComplex::asin( SawComplex complex )
00407 {
00408 SawComplex output ;
00409 output.setGSLComplex( gsl_complex_arcsin( complex.getGSLComplex() ) ) ;
00410 return output ;
00411 }
00412
00418 SawComplex SawComplex::acos( SawComplex complex )
00419 {
00420 SawComplex output ;
00421 output.setGSLComplex( gsl_complex_arccos( complex.getGSLComplex() ) ) ;
00422 return output ;
00423 }
00424
00430 SawComplex SawComplex::atan( SawComplex complex )
00431 {
00432 SawComplex output ;
00433 output.setGSLComplex( gsl_complex_arctan( complex.getGSLComplex() ) ) ;
00434 return output ;
00435 }
00436
00442 SawComplex SawComplex::asec( SawComplex complex )
00443 {
00444 SawComplex output ;
00445 output.setGSLComplex( gsl_complex_arcsec( complex.getGSLComplex() ) ) ;
00446 return output ;
00447 }
00448
00454 SawComplex SawComplex::acsc( SawComplex complex )
00455 {
00456 SawComplex output ;
00457 output.setGSLComplex( gsl_complex_arccsc( complex.getGSLComplex() ) ) ;
00458 return output ;
00459 }
00460
00466 SawComplex SawComplex::acot( SawComplex complex )
00467 {
00468 SawComplex output ;
00469 output.setGSLComplex( gsl_complex_arccot( complex.getGSLComplex() ) ) ;
00470 return output ;
00471 }
00472
00478 SawComplex SawComplex::sinh( SawComplex complex )
00479 {
00480 SawComplex output ;
00481 output.setGSLComplex( gsl_complex_sinh( complex.getGSLComplex() ) ) ;
00482 return output ;
00483 }
00484
00490 SawComplex SawComplex::cosh( SawComplex complex )
00491 {
00492 SawComplex output ;
00493 output.setGSLComplex( gsl_complex_cosh( complex.getGSLComplex() ) ) ;
00494 return output ;
00495 }
00496
00502 SawComplex SawComplex::tanh( SawComplex complex )
00503 {
00504 SawComplex output ;
00505 output.setGSLComplex( gsl_complex_tanh( complex.getGSLComplex() ) ) ;
00506 return output ;
00507 }
00508
00514 SawComplex SawComplex::sech( SawComplex complex )
00515 {
00516 SawComplex output ;
00517 output.setGSLComplex( gsl_complex_sech( complex.getGSLComplex() ) ) ;
00518 return output ;
00519 }
00520
00526 SawComplex SawComplex::csch( SawComplex complex )
00527 {
00528 SawComplex output ;
00529 output.setGSLComplex( gsl_complex_csch( complex.getGSLComplex() ) ) ;
00530 return output ;
00531 }
00532
00538 SawComplex SawComplex::coth( SawComplex complex )
00539 {
00540 SawComplex output ;
00541 output.setGSLComplex( gsl_complex_coth( complex.getGSLComplex() ) ) ;
00542 return output ;
00543 }
00544
00550 SawComplex SawComplex::asinh( SawComplex complex )
00551 {
00552 SawComplex output ;
00553 output.setGSLComplex( gsl_complex_arcsinh( complex.getGSLComplex() ) ) ;
00554 return output ;
00555 }
00556
00562 SawComplex SawComplex::acosh( SawComplex complex )
00563 {
00564 SawComplex output ;
00565 output.setGSLComplex( gsl_complex_arccosh( complex.getGSLComplex() ) ) ;
00566 return output ;
00567 }
00568
00574 SawComplex SawComplex::atanh( SawComplex complex )
00575 {
00576 SawComplex output ;
00577 output.setGSLComplex( gsl_complex_arctanh( complex.getGSLComplex() ) ) ;
00578 return output ;
00579 }
00580
00586 SawComplex SawComplex::asech( SawComplex complex )
00587 {
00588 SawComplex output ;
00589 output.setGSLComplex( gsl_complex_arcsech( complex.getGSLComplex() ) ) ;
00590 return output ;
00591 }
00592
00598 SawComplex SawComplex::acsch( SawComplex complex )
00599 {
00600 SawComplex output ;
00601 output.setGSLComplex( gsl_complex_arccsch( complex.getGSLComplex() ) ) ;
00602 return output ;
00603 }
00604
00610 SawComplex SawComplex::acoth( SawComplex complex )
00611 {
00612 SawComplex output ;
00613 output.setGSLComplex( gsl_complex_arccoth( complex.getGSLComplex() ) ) ;
00614 return output ;
00615 }
00616