00001 // @(#)root/mathcore:$Id: TComplex.cxx 25110 2008-08-11 06:09:50Z brun $ 00002 // Author: Federico Carminati 22/04/2004 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 ////////////////////////////////////////////////////////////////////////// 00013 // // 00014 // TComplex // 00015 // // 00016 ////////////////////////////////////////////////////////////////////////// 00017 00018 #include "TComplex.h" 00019 #include "Riostream.h" 00020 00021 00022 ClassImp(TComplex) 00023 00024 //______________________________________________________________________________ 00025 TComplex::TComplex(Double_t re, Double_t im, Bool_t polar) : fRe(re), fIm(im) 00026 { 00027 // Standard constructor 00028 00029 if (polar) { 00030 if(re<0) { 00031 ::Warning("TComplex::ctor","Modulo of a complex number should be >=0, taking the abs"); 00032 re=-re; 00033 } 00034 fRe=re*TMath::Cos(im); 00035 fIm=re*TMath::Sin(im); 00036 } 00037 } 00038 00039 //______________________________________________________________________________ 00040 ostream& operator<<(ostream& out, const TComplex& c) 00041 { 00042 out << "(" << c.fRe << "," << c.fIm << "i)"; 00043 return out; 00044 } 00045 00046 //______________________________________________________________________________ 00047 istream& operator>>(istream& in, TComplex& c) 00048 { 00049 in >> c.fRe >> c.fIm; 00050 return in; 00051 }