Logo ROOT  
Reference Guide
 
Loading...
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/*************************************************************************
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 <iostream>
20#include <sstream>
21
22
23////////////////////////////////////////////////////////////////////////////////
24/// Standard constructor
25
27{
28 if (polar) {
29 if(re<0) {
30 ::Warning("TComplex::ctor","Modulo of a complex number should be >=0, taking the abs");
31 re=-re;
32 }
33 fRe=re*TMath::Cos(im);
34 fIm=re*TMath::Sin(im);
35 }
36}
37
38////////////////////////////////////////////////////////////////////////////////
39
40std::ostream& operator<<(std::ostream& out, const TComplex& c)
41{
42 out << "(" << c.fRe << "," << c.fIm << "i)";
43 return out;
44}
45
46////////////////////////////////////////////////////////////////////////////////
47
48std::istream& operator>>(std::istream& in, TComplex& c)
49{
50 in >> c.fRe >> c.fIm;
51 return in;
52}
53
54namespace cling {
55std::string printValue(TComplex *c)
56{
57 std::stringstream s;
58 s << *c;
59 return s.str();
60}
61}
#define c(i)
Definition RSha256.hxx:101
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
std::istream & operator>>(std::istream &in, TComplex &c)
Definition TComplex.cxx:48
std::ostream & operator<<(std::ostream &out, const TComplex &c)
Definition TComplex.cxx:40
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
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:605
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:599