Changeset View
Changeset View
Standalone View
Standalone View
src/EvtGenBase/EvtComplex.cpp
Show All 22 Lines | |||||
#include "EvtGenBase/EvtPatches.hh" | #include "EvtGenBase/EvtPatches.hh" | ||||
#include <iostream> | #include <iostream> | ||||
#include <math.h> | #include <math.h> | ||||
using std::ostream; | using std::ostream; | ||||
ostream& operator<<( ostream& s, const EvtComplex& c ) | ostream& operator<<( ostream& s, const EvtComplex& c ) | ||||
{ | { | ||||
s << "(" << c._rpart << "," << c._ipart << ")"; | s << "(" << c.m_rpart << "," << c.m_ipart << ")"; | ||||
return s; | return s; | ||||
} | } | ||||
EvtComplex& EvtComplex::operator*=( EvtComplex c ) | EvtComplex& EvtComplex::operator*=( EvtComplex c ) | ||||
{ | { | ||||
double r = _rpart * c._rpart - _ipart * c._ipart; | double r = m_rpart * c.m_rpart - m_ipart * c.m_ipart; | ||||
double i = _rpart * c._ipart + _ipart * c._rpart; | double i = m_rpart * c.m_ipart + m_ipart * c.m_rpart; | ||||
_rpart = r; | m_rpart = r; | ||||
_ipart = i; | m_ipart = i; | ||||
return *this; | return *this; | ||||
} | } | ||||
EvtComplex& EvtComplex::operator/=( EvtComplex c ) | EvtComplex& EvtComplex::operator/=( EvtComplex c ) | ||||
{ | { | ||||
double inv = 1.0 / ( c._rpart * c._rpart + c._ipart * c._ipart ); | double inv = 1.0 / ( c.m_rpart * c.m_rpart + c.m_ipart * c.m_ipart ); | ||||
double r = inv * ( _rpart * c._rpart + _ipart * c._ipart ); | double r = inv * ( m_rpart * c.m_rpart + m_ipart * c.m_ipart ); | ||||
double i = inv * ( _ipart * c._rpart - _rpart * c._ipart ); | double i = inv * ( m_ipart * c.m_rpart - m_rpart * c.m_ipart ); | ||||
_rpart = r; | m_rpart = r; | ||||
_ipart = i; | m_ipart = i; | ||||
return *this; | return *this; | ||||
} | } |