git.ucc.asn.au
/
ipdf
/
code.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
About to break everything with a merge
[ipdf/code.git]
/
src
/
real.h
diff --git
a/src/real.h
b/src/real.h
index
e72709b
..
20ec681
100644
(file)
--- a/
src/real.h
+++ b/
src/real.h
@@
-41,6
+41,7
@@
#if REALTYPE == REAL_MPFRCPP
#include <mpreal.h>
#if REALTYPE == REAL_MPFRCPP
#include <mpreal.h>
+
#endif //REALTYPE
#if REALTYPE == REAL_IRRAM
#endif //REALTYPE
#if REALTYPE == REAL_IRRAM
@@
-98,6
+99,11
@@
namespace IPDF
inline Real Sqrt(const Real & r) {return mpfr::sqrt(r, mpfr::mpreal::get_default_rnd());}
inline Real Abs(const Real & r) {return mpfr::abs(r, mpfr::mpreal::get_default_rnd());}
inline Real RealFromStr(const char * str) {return Real(strtod(str, NULL));}
inline Real Sqrt(const Real & r) {return mpfr::sqrt(r, mpfr::mpreal::get_default_rnd());}
inline Real Abs(const Real & r) {return mpfr::abs(r, mpfr::mpreal::get_default_rnd());}
inline Real RealFromStr(const char * str) {return Real(strtod(str, NULL));}
+ 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;
inline double Double(const Real & r) {return r.as_double(53);}
#elif REALTYPE == REAL_IRRAM
typedef iRRAM::REAL Real;
inline double Double(const Real & r) {return r.as_double(53);}
@@
-121,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 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."
#else
#error "Type of Real unspecified."
@@
-138,12
+144,14
@@
namespace IPDF
inline double Sqrt(double f) {return sqrt(f);}
inline double Abs(double a) {return fabs(a);}
inline double Log10(double a) {return log(a)/log(10.0);}
inline double Sqrt(double f) {return sqrt(f);}
inline double Abs(double a) {return fabs(a);}
inline double Log10(double a) {return log(a)/log(10.0);}
- inline size_t Size(double a) {return sizeof(a);}
inline size_t Size(float a) {return sizeof(a);}
inline size_t Size(float a) {return sizeof(a);}
+ inline size_t Size(double a) {return sizeof(a);}
+
// Don't cause an exception
// 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);
}
float f = (fabs(d) < FLT_MAX) ? ((fabs(d) > FLT_MIN) ? (float)d : FLT_MIN) : FLT_MAX;
return copysign(f, d);
}
@@
-206,8
+214,9
@@
namespace IPDF
// things stolen from wikipedia and googling
// 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)
if (f < 1e-36)
return "RATHER SMALL";
if (f < 1e-35)
@@
-252,15
+261,15
@@
namespace IPDF
return "Ant";
if (f < 1e-2)
return "Coin";
return "Ant";
if (f < 1e-2)
return "Coin";
- if (f <
1e-1
)
+ if (f <
0.5
)
return "iPhone";
return "iPhone";
- if (f <
1e0
)
+ if (f <
5
)
return "Person";
return "Person";
- if (f < 1e1)
- return "Building";
if (f < 1e2)
if (f < 1e2)
- return "
Football Field
";
+ return "
Building
";
if (f < 1e3)
if (f < 1e3)
+ return "Football Field";
+ if (f < 2e3)
return "Mountain";
if (f < 1e4)
return "Clouds";
return "Mountain";
if (f < 1e4)
return "Clouds";
@@
-298,6
+307,13
@@
namespace IPDF
Debug("Size limit of %d is being enforced", PARANOID_SIZE_LIMIT);
#endif
#endif
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
}
}
}
}
UCC
git Repository :: git.ucc.asn.au