67#include "TRestComplex.h"
77TRestComplex::TRestComplex(mpfr::mpreal re, mpfr::mpreal im, Bool_t polar) : fRe(re), fIm(im) {
82 fRe = re * mpfr::cos(im);
83 fIm = re * mpfr::sin(im);
89std::ostream& operator<<(std::ostream& out,
const TRestComplex& c) {
90 int pr = out.precision();
92 int realExponent = (int)mpfr::abs(mpfr::log(mpfr::abs(c.
fRe)) / mpfr::log(10));
93 int complexExponent = (int)mpfr::abs(mpfr::log(mpfr::abs(c.
fIm)) / mpfr::log(10));
95 out.precision(mpfr::bits2digits(mpfr::mpreal::get_default_prec()) - realExponent);
97 out.precision(mpfr::bits2digits(mpfr::mpreal::get_default_prec()) - complexExponent);
98 out <<
"," << c.
fIm <<
"i)";
105std::istream& operator>>(std::istream& in,
TRestComplex& c) {
A generic class to handle complex numbers with real precision.
mpfr::mpreal fIm
The imaginary part of the complex number using MPFR precision.
mpfr::mpreal fRe
The real part of the complex number using MPFR precision.