*** empty log message ***
git-svn-id: svn://10.65.10.50/trunk@22 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
65e62eda30
commit
a041c09044
305
include/real.cpp
305
include/real.cpp
@ -14,17 +14,17 @@ HIDDEN real __tmp_real;
|
|||||||
HIDDEN char __string[80];
|
HIDDEN char __string[80];
|
||||||
const real ZERO (0.0);
|
const real ZERO (0.0);
|
||||||
|
|
||||||
real ::real ()
|
real::real ()
|
||||||
{
|
{
|
||||||
dzero (ptr ());
|
dzero (ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
real ::real (const real & b)
|
real::real (const real& b)
|
||||||
{
|
{
|
||||||
dcpy (ptr (), b.ptr ());
|
dcpy (ptr (), b.ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
real ::real (double a)
|
real::real (double a)
|
||||||
{
|
{
|
||||||
dftodr (ptr (), a, 9); // Round the number (1.0 is NOT 0.999999999)
|
dftodr (ptr (), a, 9); // Round the number (1.0 is NOT 0.999999999)
|
||||||
|
|
||||||
@ -32,8 +32,7 @@ real ::real (double a)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *real ::
|
char *real::eng2ita (char *s)
|
||||||
eng2ita (char *s)
|
|
||||||
{
|
{
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
@ -44,8 +43,7 @@ eng2ita (char *s)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *real ::
|
char *real::ita2eng (const char *s)
|
||||||
ita2eng (const char *s)
|
|
||||||
{
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
if (s)
|
if (s)
|
||||||
@ -68,15 +66,13 @@ ita2eng (const char *s)
|
|||||||
return __string;
|
return __string;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool real ::
|
bool real::is_real (const char *s)
|
||||||
is_real (const char *s)
|
|
||||||
{
|
{
|
||||||
bool ok = FALSE;
|
bool ok = FALSE;
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
while (*s == ' ')
|
while (*s == ' ')
|
||||||
s++; // Remove leading spaces before atod
|
s++; // Remove leading spaces before atod
|
||||||
|
|
||||||
ok = atod (__tmp_real.ptr (), (char *) s) != GM_NULL;
|
ok = atod (__tmp_real.ptr (), (char *) s) != GM_NULL;
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
@ -94,46 +90,46 @@ real ::real (const char *s)
|
|||||||
dzero (ptr ());
|
dzero (ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
real & real ::operator = (const real & b)
|
real& real::operator = (const real& b)
|
||||||
{
|
{
|
||||||
dcpy (ptr (), b.ptr ());
|
dcpy (ptr (), b.ptr ());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
real & real ::operator = (double a)
|
real& real::operator = (double a)
|
||||||
{
|
{
|
||||||
const real n (a);
|
const real n (a);
|
||||||
operator = (n);
|
operator = (n);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
real & real ::operator += (const real & b)
|
real& real::operator += (const real& b)
|
||||||
{
|
{
|
||||||
dadd (ptr (), ptr (), b.ptr ());
|
dadd (ptr (), ptr (), b.ptr ());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
real & real ::operator += (double a)
|
real& real ::operator += (double a)
|
||||||
{
|
{
|
||||||
__tmp_real = *this;
|
__tmp_real = *this;
|
||||||
adddfd (ptr (), __tmp_real.ptr (), a);
|
adddfd (ptr (), __tmp_real.ptr (), a);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
real & real ::operator -= (const real & b)
|
real& real::operator -= (const real& b)
|
||||||
{
|
{
|
||||||
__tmp_real = *this;
|
__tmp_real = *this;
|
||||||
dsub (ptr (), __tmp_real.ptr (), b.ptr ());
|
dsub (ptr (), __tmp_real.ptr (), b.ptr ());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
real & real ::operator *= (const real & b)
|
real& real::operator *= (const real& b)
|
||||||
{
|
{
|
||||||
dmul (ptr (), ptr (), b.ptr ());
|
dmul (ptr (), ptr (), b.ptr ());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
real & real ::operator /= (const real & b)
|
real& real::operator /= (const real& b)
|
||||||
{
|
{
|
||||||
const DEC *dst = ddiv (ptr (), ptr (), b.ptr ());
|
const DEC *dst = ddiv (ptr (), ptr (), b.ptr ());
|
||||||
|
|
||||||
@ -148,52 +144,47 @@ real & real ::operator /= (const real & b)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
TObject *real ::
|
|
||||||
dup ()
|
|
||||||
const
|
TObject *real::dup () const
|
||||||
{
|
{
|
||||||
return new real (*this);
|
return new real (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool real ::is_zero ()
|
bool real::is_zero () const
|
||||||
const
|
{
|
||||||
{
|
|
||||||
return diszero (ptr ());
|
return diszero (ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
int real ::sign ()
|
int real::sign () const
|
||||||
const
|
{
|
||||||
{
|
|
||||||
return dsign (ptr ());
|
return dsign (ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
real real ::operator - ()
|
real real::operator- () const
|
||||||
const
|
{
|
||||||
{
|
|
||||||
real n;
|
real n;
|
||||||
dchgs (n.ptr (), ptr ());
|
dchgs (n.ptr (), ptr ());
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int real ::integer ()
|
int real::integer () const
|
||||||
const
|
{
|
||||||
{
|
|
||||||
return dtoi (ptr ());
|
return dtoi (ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Certified 91%
|
// Certified 91%
|
||||||
char *real ::string (int len, int dec, char pad)
|
char *real::string (int len, int dec, char pad) const
|
||||||
const
|
{
|
||||||
{
|
|
||||||
__tmp_real = *this;
|
__tmp_real = *this;
|
||||||
if (dec != UNDEFINED)
|
if (dec != UNDEFINED)
|
||||||
__tmp_real.round (dec);
|
__tmp_real.round (dec);
|
||||||
else
|
else
|
||||||
deltrz (__tmp_real.ptr (), __tmp_real.ptr ());
|
deltrz (__tmp_real.ptr (), __tmp_real.ptr ());
|
||||||
|
|
||||||
// if (len == 0)
|
// if (len == 0)
|
||||||
dtoa (__string, __tmp_real.ptr ());
|
dtoa (__string, __tmp_real.ptr ());
|
||||||
/*
|
/*
|
||||||
* else
|
* else
|
||||||
* {
|
* {
|
||||||
* char f[16];
|
* char f[16];
|
||||||
@ -215,7 +206,7 @@ dup ()
|
|||||||
*/
|
*/
|
||||||
int lun = strlen (__string);
|
int lun = strlen (__string);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* char* dot = strchr(__string, '.');
|
* char* dot = strchr(__string, '.');
|
||||||
*
|
*
|
||||||
* int d = dot ? strlen(dot+1) : 0; // Decimals already there
|
* int d = dot ? strlen(dot+1) : 0; // Decimals already there
|
||||||
@ -242,24 +233,21 @@ dup ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
return __string;
|
return __string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Certified 99%
|
// Certified 99%
|
||||||
char *real ::
|
char* real::stringa (int len, int dec, char pad) const
|
||||||
stringa (int len, int dec, char pad)
|
|
||||||
const
|
|
||||||
|
|
||||||
{
|
{
|
||||||
string (len, dec, pad);
|
string (len, dec, pad);
|
||||||
if (dec > 0 || dec == UNDEFINED)
|
if (dec > 0 || dec == UNDEFINED)
|
||||||
eng2ita (__string);
|
eng2ita (__string);
|
||||||
return __string;
|
return __string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Certified 75%
|
// Certified 75%
|
||||||
char *real ::literals ()
|
char *real::literals () const
|
||||||
const
|
{
|
||||||
{
|
|
||||||
const char *primi20[] =
|
const char *primi20[] =
|
||||||
{"", "uno", "due", "tre", "quattro",
|
{"", "uno", "due", "tre", "quattro",
|
||||||
"cinque", "sei", "sette", "otto",
|
"cinque", "sei", "sette", "otto",
|
||||||
@ -335,13 +323,11 @@ stringa (int len, int dec, char pad)
|
|||||||
if (negativo)
|
if (negativo)
|
||||||
risultato.insert ("meno", 0);
|
risultato.insert ("meno", 0);
|
||||||
return __string;
|
return __string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Certified 75%
|
// Certified 75%
|
||||||
char *real ::
|
char *real::points (int dec) const
|
||||||
points (int dec)
|
{
|
||||||
const
|
|
||||||
{
|
|
||||||
const char *str = stringa ();
|
const char *str = stringa ();
|
||||||
const int neg = (*str == '-') ? 1 : 0;
|
const int neg = (*str == '-') ? 1 : 0;
|
||||||
TFixed_string n ((char *) str, 24);
|
TFixed_string n ((char *) str, 24);
|
||||||
@ -369,10 +355,9 @@ points (int dec)
|
|||||||
n.insert (".", i);
|
n.insert (".", i);
|
||||||
|
|
||||||
return __string;
|
return __string;
|
||||||
}
|
}
|
||||||
|
|
||||||
HIDDEN int
|
HIDDEN int get_picture_decimals (const TString & picture)
|
||||||
get_picture_decimals (const TString & picture)
|
|
||||||
{
|
{
|
||||||
int decimali = 0;
|
int decimali = 0;
|
||||||
const int virgola = picture.find (',');
|
const int virgola = picture.find (',');
|
||||||
@ -386,10 +371,8 @@ get_picture_decimals (const TString & picture)
|
|||||||
return decimali;
|
return decimali;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *real ::
|
char *real::string (const char *picture) const
|
||||||
string (const char *picture)
|
{
|
||||||
const
|
|
||||||
{
|
|
||||||
if (*picture == '\0')
|
if (*picture == '\0')
|
||||||
return string ();
|
return string ();
|
||||||
if (*picture == '.')
|
if (*picture == '.')
|
||||||
@ -440,29 +423,27 @@ string (const char *picture)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return strcpy (__string, f);
|
return strcpy (__string, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream & operator << (ostream & out, const real & a)
|
ostream& operator<< (ostream& out, const real& a)
|
||||||
|
|
||||||
{
|
{
|
||||||
return out << a.string ();
|
return out << a.string ();
|
||||||
}
|
}
|
||||||
|
|
||||||
istream & operator >> (istream & in, real & a)
|
istream& operator>> (istream& in, real& a)
|
||||||
|
|
||||||
{
|
{
|
||||||
in >> __string;
|
in >> __string;
|
||||||
atod (a.ptr (), __string);
|
atod (a.ptr (), __string);
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
int real ::
|
int real::precision ()
|
||||||
precision ()
|
|
||||||
{
|
{
|
||||||
return dprec (ptr ());
|
return dprec (ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
real & real ::round (int prec)
|
real& real::round (int prec)
|
||||||
{
|
{
|
||||||
if (prec < 0)
|
if (prec < 0)
|
||||||
{
|
{
|
||||||
@ -476,7 +457,7 @@ real & real ::round (int prec)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
real & real ::ceil (int prec)
|
real& real::ceil (int prec)
|
||||||
{
|
{
|
||||||
double p = 1.0;
|
double p = 1.0;
|
||||||
if (prec)
|
if (prec)
|
||||||
@ -498,41 +479,41 @@ real & real ::ceil (int prec)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
real & real ::trunc (int prec)
|
real& real::trunc (int prec)
|
||||||
{
|
{
|
||||||
dtrunc (ptr (), ptr (), prec);
|
dtrunc (ptr (), ptr (), prec);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator + (const real & a, const real & b)
|
real operator+ (const real& a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
dadd (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
dadd (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator + (double a, const real & b)
|
real operator+ (double a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
__tmp_real = a;
|
__tmp_real = a;
|
||||||
return __tmp_real += b;
|
return __tmp_real += b;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator + (const real & a, double b)
|
real operator+ (const real& a, double b)
|
||||||
|
|
||||||
{
|
{
|
||||||
__tmp_real = a;
|
__tmp_real = a;
|
||||||
return __tmp_real += b;
|
return __tmp_real += b;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator - (const real & a, const real & b)
|
real operator - (const real& a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
dsub (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
dsub (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator - (double a, const real & b)
|
real operator - (double a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
__tmp_real = a;
|
__tmp_real = a;
|
||||||
@ -540,42 +521,42 @@ real operator - (double a, const real & b)
|
|||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator - (const real & a, double b)
|
real operator - (const real& a, double b)
|
||||||
|
|
||||||
{
|
{
|
||||||
__tmp_real = b;
|
__tmp_real = b;
|
||||||
return __tmp_real -= a;
|
return __tmp_real -= a;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator *(const real & a, const real & b)
|
real operator *(const real& a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
dmul (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
dmul (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator *(double a, const real & b)
|
real operator *(double a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
muldfd (__tmp_real.ptr (), b.ptr (), a);
|
muldfd (__tmp_real.ptr (), b.ptr (), a);
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator *(const real & a, double b)
|
real operator *(const real& a, double b)
|
||||||
|
|
||||||
{
|
{
|
||||||
muldfd (__tmp_real.ptr (), a.ptr (), b);
|
muldfd (__tmp_real.ptr (), a.ptr (), b);
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator / (const real & a, const real & b)
|
real operator / (const real& a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
ddiv (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
ddiv (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator / (double a, const real & b)
|
real operator / (double a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
__tmp_real = a;
|
__tmp_real = a;
|
||||||
@ -583,7 +564,7 @@ real operator / (double a, const real & b)
|
|||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator / (const real & a, double b)
|
real operator / (const real& a, double b)
|
||||||
|
|
||||||
{
|
{
|
||||||
__tmp_real = b;
|
__tmp_real = b;
|
||||||
@ -591,191 +572,193 @@ real operator / (const real & a, double b)
|
|||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator > (const real & a, const real & b)
|
bool operator > (const real& a, const real& b)
|
||||||
{
|
{
|
||||||
return disgt (a.ptr (), b.ptr ());
|
return disgt (a.ptr (), b.ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator > (double a, const real & b)
|
bool operator > (double a, const real& b)
|
||||||
{
|
{
|
||||||
// dftod(__tmp_real.ptr(), a);
|
// dftod(__tmp_real.ptr(), a);
|
||||||
// return disgt(__tmp_real.ptr(), b.ptr());
|
// return disgt(__tmp_real.ptr(), b.ptr());
|
||||||
const double n = dtodf (b.ptr ());
|
const double n = dtodf (b.ptr ());
|
||||||
return a > n;
|
return a > n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator < (const real & a, const real & b)
|
bool operator < (const real& a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
return dislt (a.ptr (), b.ptr ());
|
return dislt (a.ptr (), b.ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator < (double a, const real & b)
|
bool operator < (double a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
// dftod(__tmp_real.ptr(), a);
|
// dftod(__tmp_real.ptr(), a);
|
||||||
// return dislt(__tmp_real.ptr(), b.ptr());
|
// return dislt(__tmp_real.ptr(), b.ptr());
|
||||||
const double n = dtodf (b.ptr ());
|
const double n = dtodf (b.ptr ());
|
||||||
return a < n;
|
return a < n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator >= (const real & a, const real & b)
|
bool operator >= (const real& a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
return disge (a.ptr (), b.ptr ());
|
return disge (a.ptr (), b.ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator >= (double a, const real & b)
|
bool operator >= (double a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
// dftod(__tmp_real.ptr(), a);
|
// dftod(__tmp_real.ptr(), a);
|
||||||
// return disge(__tmp_real.ptr(), b.ptr());
|
// return disge(__tmp_real.ptr(), b.ptr());
|
||||||
const double n = dtodf (b.ptr ());
|
const double n = dtodf (b.ptr ());
|
||||||
return a >= n;
|
return a >= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator <= (const real & a, const real & b)
|
bool operator <= (const real& a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
return disle (a.ptr (), b.ptr ());
|
return disle (a.ptr (), b.ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator <= (double a, const real & b)
|
bool operator <= (double a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
// dftod(__tmp_real.ptr(), a);
|
// dftod(__tmp_real.ptr(), a);
|
||||||
// return disle(__tmp_real.ptr(), b.ptr());
|
// return disle(__tmp_real.ptr(), b.ptr());
|
||||||
const double n = dtodf (b.ptr ());
|
const double n = dtodf (b.ptr ());
|
||||||
return a <= n;
|
return a <= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator == (const real & a, const real & b)
|
bool operator == (const real& a, const real& b)
|
||||||
{
|
{
|
||||||
return diseq (a.ptr (), b.ptr ());
|
return diseq (a.ptr (), b.ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator == (double a, const real & b)
|
bool operator == (double a, const real& b)
|
||||||
{
|
{
|
||||||
const double n = dtodf (b.ptr ());
|
const double n = dtodf (b.ptr ());
|
||||||
return a == n;
|
return a == n;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator != (const real & a, const real & b)
|
bool operator != (const real& a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
return !diseq (a.ptr (), b.ptr ());
|
return !diseq (a.ptr (), b.ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator != (double a, const real & b)
|
bool operator != (double a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
const double n = dtodf (b.ptr ());
|
const double n = dtodf (b.ptr ());
|
||||||
return a != n;
|
return a != n;
|
||||||
}
|
}
|
||||||
|
|
||||||
real operator % (const real & a, const long b)
|
real operator % (const real& a, const long b)
|
||||||
|
|
||||||
{
|
{
|
||||||
dmodl (__tmp_real.ptr (), a.ptr (), b);
|
dmodl (__tmp_real.ptr (), a.ptr (), b);
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap (real & a, real & b)
|
void swap (real& a, real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
SwapDecimal (a.ptr (), b.ptr ());
|
SwapDecimal (a.ptr (), b.ptr ());
|
||||||
}
|
}
|
||||||
|
|
||||||
real fnc_min (const real & a, const real & b)
|
real fnc_min (const real& a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
dmin (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
dmin (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real fnc_max (const real & a, const real & b)
|
real fnc_max (const real& a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
dmax (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
dmax (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real sqrt (const real & a)
|
real sqrt (const real& a)
|
||||||
|
|
||||||
{
|
{
|
||||||
dsqrt (__tmp_real.ptr (), a.ptr ());
|
dsqrt (__tmp_real.ptr (), a.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real sqr (const real & a)
|
real sqr (const real& a)
|
||||||
|
|
||||||
{
|
{
|
||||||
dmul (__tmp_real.ptr (), a.ptr (), a.ptr ());
|
dmul (__tmp_real.ptr (), a.ptr (), a.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real exp10 (const real & a)
|
real exp10 (const real& a)
|
||||||
|
|
||||||
{
|
{
|
||||||
dalog (__tmp_real.ptr (), a.ptr ());
|
dalog (__tmp_real.ptr (), a.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real pow (const real & a, const real & b)
|
real pow (const real& a, const real& b)
|
||||||
|
|
||||||
{
|
{
|
||||||
dpow (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
dpow (__tmp_real.ptr (), a.ptr (), b.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real exp (const real & a)
|
real exp (const real& a)
|
||||||
|
|
||||||
{
|
{
|
||||||
dexp (__tmp_real.ptr (), a.ptr ());
|
dexp (__tmp_real.ptr (), a.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real log10 (const real & a)
|
|
||||||
|
|
||||||
{
|
|
||||||
|
real log10 (const real& a)
|
||||||
|
|
||||||
|
{
|
||||||
dlog (__tmp_real.ptr (), a.ptr ());
|
dlog (__tmp_real.ptr (), a.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real log (const real & a)
|
real log (const real& a)
|
||||||
|
|
||||||
{
|
{
|
||||||
dln (__tmp_real.ptr (), a.ptr ());
|
dln (__tmp_real.ptr (), a.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real sin (const real & a)
|
real sin (const real& a)
|
||||||
|
|
||||||
{
|
{
|
||||||
dsin (__tmp_real.ptr (), a.ptr ());
|
dsin (__tmp_real.ptr (), a.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real cos (const real & a)
|
real cos (const real& a)
|
||||||
|
|
||||||
{
|
{
|
||||||
dcos (__tmp_real.ptr (), a.ptr ());
|
dcos (__tmp_real.ptr (), a.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real tan (const real & a)
|
real tan (const real& a)
|
||||||
|
|
||||||
{
|
{
|
||||||
dtan (__tmp_real.ptr (), a.ptr ());
|
dtan (__tmp_real.ptr (), a.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
real abs (const real & a)
|
real abs (const real& a)
|
||||||
|
|
||||||
{
|
{
|
||||||
dabs (__tmp_real.ptr (), a.ptr ());
|
dabs (__tmp_real.ptr (), a.ptr ());
|
||||||
return __tmp_real;
|
return __tmp_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// Distrib
|
// Distrib
|
||||||
@ -784,15 +767,15 @@ bool operator == (const real & a, const real & b)
|
|||||||
// /////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void TDistrib ::add (real slice)
|
void TDistrib ::add (real slice)
|
||||||
{
|
{
|
||||||
if (slice > real (1.0))
|
if (slice > real (1.0))
|
||||||
slice /= 100.0;
|
slice /= 100.0;
|
||||||
CHECK (!_ready, "TDistrib: les jeux sont faits");
|
CHECK (!_ready, "TDistrib: les jeux sont faits");
|
||||||
_slices.add (slice);
|
_slices.add (slice);
|
||||||
}
|
}
|
||||||
|
|
||||||
real TDistrib ::get ()
|
real TDistrib ::get ()
|
||||||
{
|
{
|
||||||
_ready = TRUE;
|
_ready = TRUE;
|
||||||
CHECK (_current < _slices.items (), "TDistrib: too many gets");
|
CHECK (_current < _slices.items (), "TDistrib: too many gets");
|
||||||
real r = _tot * ((real &) _slices[_current++]);
|
real r = _tot * ((real &) _slices[_current++]);
|
||||||
@ -804,10 +787,10 @@ real TDistrib ::get ()
|
|||||||
else
|
else
|
||||||
_prog += r;
|
_prog += r;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDistrib ::init (const real & r)
|
void TDistrib ::init (const real& r)
|
||||||
{
|
{
|
||||||
_current = 0; _prog = 0;
|
_current = 0; _prog = 0;
|
||||||
_tot = r; _ready = FALSE;
|
_tot = r; _ready = FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user