ROOT   Reference Guide
Searching...
No Matches
TComplex.cxx
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Author: Federico Carminati 22/04/2004
3
4/*************************************************************************
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. * 9 * For the list of contributors see$ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12//////////////////////////////////////////////////////////////////////////
13// //
14// TComplex //
15// //
16//////////////////////////////////////////////////////////////////////////
17
18#include "TComplex.h"
19#include <iostream>
20#include <sstream>
21
23
24////////////////////////////////////////////////////////////////////////////////
25/// Standard constructor
26
27TComplex::TComplex(Double_t re, Double_t im, Bool_t polar) : fRe(re), fIm(im)
28{
29 if (polar) {
30 if(re<0) {
31 ::Warning("TComplex::ctor","Modulo of a complex number should be >=0, taking the abs");
32 re=-re;
33 }
34 fRe=re*TMath::Cos(im);
35 fIm=re*TMath::Sin(im);
36 }
37}
38
39////////////////////////////////////////////////////////////////////////////////
40
41std::ostream& operator<<(std::ostream& out, const TComplex& c)
42{
43 out << "(" << c.fRe << "," << c.fIm << "i)";
44 return out;
45}
46
47////////////////////////////////////////////////////////////////////////////////
48
49std::istream& operator>>(std::istream& in, TComplex& c)
50{
51 in >> c.fRe >> c.fIm;
52 return in;
53}
54
55namespace cling {
56std::string printValue(TComplex *c)
57{
58 std::stringstream s;
59 s << *c;
60 return s.str();
61}
62}
#define c(i)
Definition RSha256.hxx:101
#define ClassImp(name)
Definition Rtypes.h:377
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Definition TBuffer.h:397
std::istream & operator>>(std::istream &in, TComplex &c)
Definition TComplex.cxx:49
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
Double_t fRe
Definition TComplex.h:32
Double_t fIm
Definition TComplex.h:33
TComplex()
Definition TComplex.h:37
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:594
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:588