Logo ROOT   6.18/05
Reference Guide
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#include <sstream>
22
24
25////////////////////////////////////////////////////////////////////////////////
26/// Standard constructor
27
28TComplex::TComplex(Double_t re, Double_t im, Bool_t polar) : fRe(re), fIm(im)
29{
30 if (polar) {
31 if(re<0) {
32 ::Warning("TComplex::ctor","Modulo of a complex number should be >=0, taking the abs");
33 re=-re;
34 }
35 fRe=re*TMath::Cos(im);
36 fIm=re*TMath::Sin(im);
37 }
38}
39
40////////////////////////////////////////////////////////////////////////////////
41
42std::ostream& operator<<(std::ostream& out, const TComplex& c)
43{
44 out << "(" << c.fRe << "," << c.fIm << "i)";
45 return out;
46}
47
48////////////////////////////////////////////////////////////////////////////////
49
50std::istream& operator>>(std::istream& in, TComplex& c)
51{
52 in >> c.fRe >> c.fIm;
53 return in;
54}
55
56namespace cling {
57std::string printValue(TComplex *c)
58{
59 std::stringstream s;
60 s << *c;
61 return s.str();
62}
63}
#define c(i)
Definition: RSha256.hxx:101
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
#define ClassImp(name)
Definition: Rtypes.h:365
std::istream & operator>>(std::istream &in, TComplex &c)
Definition: TComplex.cxx:50
std::ostream & operator<<(std::ostream &out, const TComplex &c)
Definition: TComplex.cxx:42
void Warning(const char *location, const char *msgfmt,...)
Double_t fRe
Definition: TComplex.h:29
Double_t fIm
Definition: TComplex.h:30
TComplex()
Definition: TComplex.h:34
static constexpr double s
Double_t Cos(Double_t)
Definition: TMath.h:629
Double_t Sin(Double_t)
Definition: TMath.h:625