ROOT
6.12/07
Reference Guide
math
mathcore
src
TComplex.cxx
Go to the documentation of this file.
1
// @(#)root/mathcore:$Id$
2
// Author: Federico Carminati 22/04/2004
3
4
/*************************************************************************
5
* Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6
* All rights reserved. *
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 "
Riostream.h
"
20
21
22
ClassImp
(
TComplex
);
23
24
////////////////////////////////////////////////////////////////////////////////
25
/// Standard constructor
26
27
TComplex::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
41
std::ostream&
operator<<
(std::ostream& out,
const
TComplex
& c)
42
{
43
out <<
"("
<< c.
fRe
<<
","
<< c.
fIm
<<
"i)"
;
44
return
out;
45
}
46
47
////////////////////////////////////////////////////////////////////////////////
48
49
std::istream&
operator>>
(std::istream& in,
TComplex
& c)
50
{
51
in >> c.
fRe
>> c.
fIm
;
52
return
in;
53
}
TComplex::operator<<
friend std::ostream & operator<<(std::ostream &out, const TComplex &c)
Definition:
TComplex.cxx:41
TComplex::TComplex
TComplex()
Definition:
TComplex.h:34
TComplex::fIm
Double_t fIm
Definition:
TComplex.h:30
Bool_t
bool Bool_t
Definition:
RtypesCore.h:59
TComplex::operator>>
friend std::istream & operator>>(std::istream &in, TComplex &c)
Definition:
TComplex.cxx:49
TComplex
Definition:
TComplex.h:26
Warning
void Warning(const char *location, const char *msgfmt,...)
TMath::Cos
Double_t Cos(Double_t)
Definition:
TMath.h:550
Riostream.h
ClassImp
#define ClassImp(name)
Definition:
Rtypes.h:359
Double_t
double Double_t
Definition:
RtypesCore.h:55
TComplex::fRe
Double_t fRe
Definition:
TComplex.h:29
TComplex.h
TMath::Sin
Double_t Sin(Double_t)
Definition:
TMath.h:547