X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Freal.h;h=20ec68101b70611a6b76a7172b4c9ffc932bf301;hp=13395fb75cac4457db0db17777c4c981ae8668d5;hb=6c0dfe752994312ee58d307b383948bfeb2d6e2e;hpb=667281b828c8515e995c0000706157cee180fa08 diff --git a/src/real.h b/src/real.h index 13395fb..20ec681 100644 --- a/src/real.h +++ b/src/real.h @@ -102,6 +102,7 @@ namespace IPDF inline std::string Str(const mpfr::mpreal & a) {std::stringstream s; s << a; return s.str();} inline size_t Size(mpfr::mpreal & a) {return a.get_prec();} inline mpfr::mpreal Log10(const mpfr::mpreal & a) {return mpfr::log10(a);} + inline mpfr::mpreal Exp(const mpfr::mpreal & a) {return mpfr::pow(2.817, a);} #elif REALTYPE == REAL_IRRAM typedef iRRAM::REAL Real; @@ -126,7 +127,7 @@ namespace IPDF inline Real Sqrt(const Real & r) {return Real(sqrt(r.ToDouble()));} inline Real RealFromStr(const char * str) {return Real(strtod(str, NULL));} inline Real Abs(const Real & a) {return (a > Real(0)) ? a : Real(0)-a;} - + inline std::string Str(const Real & r) {return r.Str();} #else #error "Type of Real unspecified." @@ -148,8 +149,9 @@ namespace IPDF // Don't cause an exception - inline float ClampFloat(double d) + inline float ClampFloat(const Real & a) { + double d = Double(a); float f = (fabs(d) < FLT_MAX) ? ((fabs(d) > FLT_MIN) ? (float)d : FLT_MIN) : FLT_MAX; return copysign(f, d); } @@ -212,8 +214,9 @@ namespace IPDF // things stolen from wikipedia and googling - inline const char * HumanScale(double f) + inline const char * HumanScale(const Real & r) { + double f = Double(r); if (f < 1e-36) return "RATHER SMALL"; if (f < 1e-35) @@ -258,15 +261,15 @@ namespace IPDF return "Ant"; if (f < 1e-2) return "Coin"; - if (f < 1e-1) + if (f < 0.5) return "iPhone"; - if (f < 1e0) + if (f < 5) return "Person"; - if (f < 1e1) - return "Building"; if (f < 1e2) - return "Football Field"; + return "Building"; if (f < 1e3) + return "Football Field"; + if (f < 2e3) return "Mountain"; if (f < 1e4) return "Clouds"; @@ -304,6 +307,13 @@ namespace IPDF Debug("Size limit of %d is being enforced", PARANOID_SIZE_LIMIT); #endif #endif + #if REALTYPE == REAL_MPFRCPP + Debug("Precision of MPFR is %d", mpfr_get_default_prec()); + #endif + + #ifdef TRANSFORM_BEZIERS_TO_PATH + Debug("PathReal = %d => \"%s\"", PATHREAL, g_real_name[PATHREAL]); + #endif } }