EGlpNum


Detailed Description

Here we define a common interface to handle numbers in general, the idea is to be able to work with infinite precicion numbers, plain doubles, floats, integers, or fixed point numbers, without actually making different codes for each of those types, rather we preffer to fix that at compyle time.

History:
Revision 0.0.2 We start doing the migration to gmp and 'natural' types, this means that we drop support for EGrat, this allow us to drop the requirement to use pointers, and instead we can just call the functions with the original parameters, still we have to be VERY carefull regarding changing local/external copies.


Files

file  eg_lpnum.dbl.h
file  eg_lpnum.h

Number Types Definitions:

Define (as its name suggest) an internal identifier for the given type. this definitions are provided to select different types of data at compile time, thus allowing us to provide limited template support.

#define DBL_TYPE   0
#define FLOAT128_TYPE   13
#define FLT_TYPE   1
#define FP10_TYPE   3
#define FP20_TYPE   4
#define FP25_TYPE   6
#define FP28_TYPE   5
#define INT_TYPE   2
#define LDBL_TYPE   11
#define LLINT_TYPE   12
#define EGLPNUM_ISFP   1
#define EGLPNUM_MAXCONVORDER   2U
#define EGlpNum_t   double
#define EGlpNumAddInnProdTo(a, b, c)   dbl_EGlpNumAddInnProdTo(a,b,c)
#define EGlpNumAddTo(a, b)   dbl_EGlpNumAddTo(a,b)
#define EGlpNumAddUiTo(a, b)   dbl_EGlpNumAddUiTo(a,b)
#define EGlpNumAllocArray(size)   dbl_EGlpNumAllocArray(size)
#define EGlpNumCeil(a, b)   dbl_EGlpNumCeil(a,b)
#define EGlpNumClearVar(a)   dbl_EGlpNumClearVar(a)
#define EGlpNumCopy(dest, orig)   dbl_EGlpNumCopy(dest,orig)
#define EGlpNumCopyAbs(dest, orig)   dbl_EGlpNumCopyAbs(dest,orig)
#define EGlpNumCopyArray(dest, orig, size)   dbl_EGlpNumCopyArray(dest,orig,size)
#define EGlpNumCopyDiff(dest, a, b)   dbl_EGlpNumCopyDiff(dest,a,b)
#define EGlpNumCopyDiffRatio(a, b, c, d)   dbl_EGlpNumCopyDiffRatio(a,b,c,d)
#define EGlpNumCopyFrac(dest, op1, op2)   dbl_EGlpNumCopyFrac(dest,op1,op2)
#define EGlpNumCopyNeg(dest, orig)   dbl_EGlpNumCopyNeg(dest,orig)
#define EGlpNumCopySqrOver(dest, orig, den)   dbl_EGlpNumCopySqrOver(dest,orig,den)
#define EGlpNumCopySum(dest, a, b)   dbl_EGlpNumCopySum(dest,a,b)
#define EGlpNumDivTo(a, b)   dbl_EGlpNumDivTo(a,b)
#define EGlpNumDivUiTo(a, b)   dbl_EGlpNumDivUiTo(a,b)
#define EGlpNumFloor(a, b)   dbl_EGlpNumFloor(a,b)
#define EGlpNumFreeArray(ea)   dbl_EGlpNumFreeArray(ea)
#define EGlpNumGetStr(a)   dbl_EGlpNumGetStr(a)
#define EGlpNumInitVar(a)   dbl_EGlpNumInitVar(a)
#define EGlpNumInv(a)   dbl_EGlpNumInv(a)
#define EGlpNumIsDiffLess(a, b, c)   dbl_EGlpNumIsDiffLess(a,b,c)
#define EGlpNumIsEqqual(a, b)   dbl_EGlpNumIsEqqual(a,b)
#define EGlpNumIsEqual(a, b, error)   dbl_EGlpNumIsEqual(a,b,error)
#define EGlpNumIsGreaDbl(a, b)   dbl_EGlpNumIsGreaDbl(a,b)
#define EGlpNumIsLeq(a, b)   dbl_EGlpNumIsLeq(a,b)
#define EGlpNumIsLess(a, b)   dbl_EGlpNumIsLess(a,b)
#define EGlpNumIsLessDbl(a, b)   dbl_EGlpNumIsLessDbl(a,b)
#define EGlpNumIsNeq(a, b, error)   dbl_EGlpNumIsNeq(a,b,error)
#define EGlpNumIsNeqq(a, b)   dbl_EGlpNumIsNeqq(a,b)
#define EGlpNumIsNeqqZero(a)   dbl_EGlpNumIsNeqqZero(a)
#define EGlpNumIsNeqZero(a, error)   dbl_EGlpNumIsNeqZero(a,error)
#define EGlpNumIsSumLess(a, b, c)   dbl_EGlpNumIsSumLess(a,b,c)
#define EGlpNumMultTo(a, b)   dbl_EGlpNumMultTo(a,b)
#define EGlpNumMultUiTo(a, b)   dbl_EGlpNumMultUiTo(a,b)
#define EGlpNumOne(a)   dbl_EGlpNumOne(a)
#define EGlpNumReadStr(a, str)   dbl_EGlpNumReadStr(a,str)
#define EGlpNumReallocArray(lptr, size)   dbl_EGlpNumReallocArray(lptr,size)
#define EGlpNumSet(var, dbl)   dbl_EGlpNumSet(var,dbl)
#define EGlpNumSetToMaxAbs(dest, orig)   dbl_EGlpNumSetToMaxAbs(dest,orig)
#define EGlpNumSetToMinAbs(dest, orig)   dbl_EGlpNumSetToMinAbs(dest,orig)
#define EGlpNumSign(a)   dbl_EGlpNumSign(a)
#define EGlpNumSubInnProdTo(a, b, c)   dbl_EGlpNumSubInnProdTo(a,b,c)
#define EGlpNumSubTo(a, b)   dbl_EGlpNumSubTo(a,b)
#define EGlpNumSubUiTo(a, b)   dbl_EGlpNumSubUiTo(a,b)
#define EGlpNumToLf(a)   dbl_EGlpNumToLf(a)
#define EGlpNumZero(a)   dbl_EGlpNumZero(a)
#define epsLpNum   dbl_epsLpNum
#define oneLpNum   dbl_oneLpNum
#define zeroLpNum   dbl_zeroLpNum

Defines

#define __EGlpNumAllocArray(type, size)
 Allocate an array of a given type and store (sizeof(size_t) bytes before the actual array) the size of the allocated array.
#define __EGlpNumArraySize(array)
 Given an array allocated with __EGlpNumAllocArray, return the size of the given array, if the array is null, return zero.
#define __EGlpNumFreeArray(array)
 , given an array allocated by __EGlpNumAllocArray, free the allocated memory.
#define dbl_EGlpNumAddInnProdTo(a, b, c)   ((a) += (b)*(c))
 Add to a given number the product of two numbers.
#define dbl_EGlpNumAddTo(a, b)   ((a) += (b))
 Add to a given number the value of the second number.
#define dbl_EGlpNumAddUiTo(a, b)   ((a) += (b))
 Add to a given number the value of the second number.
#define dbl_EGlpNumAllocArray(size)   __EGlpNumAllocArray(double,size)
 Allocate and initialize (if needed) 'size' elements of type double and return it, if no more memory, exit(1).
#define dbl_EGlpNumCeil(a, b)   ((a) = ceil(b))
 Stores in the first number the ceil value of the second number, i.e. EGlpNumCeil(a,b) <==> a= ceil(b).
#define dbl_EGlpNumClearVar(a)
 free the internal memory of a given variable
#define dbl_EGlpNumCopy(dest, orig)   ((dest) = (orig))
 copy the value of the second number to the first.
#define dbl_EGlpNumCopyAbs(dest, orig)   ((dest) = fabs(orig))
 copy the value of the absolute value of the second parameter to the first parameter.
#define dbl_EGlpNumCopyArray(dest, orig, size)   memcpy(dest,orig,sizeof(double)*(size))
 copy the first 'size' values in the second array to the first array.
#define dbl_EGlpNumCopyDiff(dest, a, b)   ((dest) = (a) - (b))
 copy the value of the second number to the first.
#define dbl_EGlpNumCopyDiffRatio(dest, a, b, den)   ((dest) = ((a) - (b)) / (den))
 copy the value of the second number to the first.
#define dbl_EGlpNumCopyFrac(dest, op1, op2)   ((dest) = (op1)/(op2))
 Set des = op1/op2.
#define dbl_EGlpNumCopyNeg(dest, orig)   ((dest) = -(orig))
 copy minus the value of the second parameter to the first parameter.
#define dbl_EGlpNumCopySqrOver(dest, orig, den)   ((dest) = (orig)*(orig)/(den))
 copy the square of the second argument, divided by the third argument into the first argument.
#define dbl_EGlpNumCopySum(dest, a, b)   ((dest) = (a) + (b))
 copy the value of the sum of the second and third parameter
#define dbl_EGlpNumDivTo(a, b)   ((a) /= (b))
 Divide a given number by the value of the second number.
#define dbl_EGlpNumDivUiTo(a, b)   ((a) /= (b))
 Divide a given number by the value of the second number.
#define dbl_EGlpNumFloor(a, b)   ((a) = floor(b))
 Stores in the first number the floor value of the second number, i.e. EGlpNumFloor(a,b) <==> a= floor(b).
#define dbl_EGlpNumFreeArray(ea)   __EGlpNumFreeArray(ea)
 given an array of type double, free it, if the pointer is NULL nothing happen.
#define dbl_EGlpNumGetStr(a)
 given a double, write it to a string (to be allocated internally), and return it.
#define dbl_EGlpNumInitVar(a)   dbl_EGlpNumZero(a)
 initialize the internal memory of a given variable
#define dbl_EGlpNumInv(a)   ((a) = 1.0/(a))
 store the (multiplicative) inverse of a number to itself, i.e. implement a = 1/a.
#define dbl_EGlpNumIsDiffLess(a, b, c)   ((a) - (b) < (c))
 test if the diference of the first two numbers is less thatn the third number.
#define dbl_EGlpNumIsEqqual(a, b)   ((a) == (b))
 Compare if two numbers are equal within a maximum error.
#define dbl_EGlpNumIsEqual(a, b, error)   (fabs((a)-(b)) <= (error))
 Compare if two numbers are equal within a maximum error.
#define dbl_EGlpNumIsGreaDbl(a, b)   ((a) > (b))
 test if the first number is bigger to the second number
#define dbl_EGlpNumIsLeq(a, b)   ((a) <= (b))
 test if the first number is bigger to the second number
#define dbl_EGlpNumIsLess(a, b)   (a < b)
 test if the first number is bigger to the second number
#define dbl_EGlpNumIsLessDbl(a, b)   ((a) < (b))
 test if the first number is bigger to the second number
#define dbl_EGlpNumIsNeq(a, b, error)   (((a)-(b) > (error)) || ((b)-(a) > (error)))
#define dbl_EGlpNumIsNeqq(a, b)   ((a) != (b))
#define dbl_EGlpNumIsNeqqZero(a)   ((a) != 0.0)
#define dbl_EGlpNumIsNeqZero(a, error)   (((a) > (error)) || (-(a) > (error)))
#define dbl_EGlpNumIsSumLess(a, b, c)   ((a) + (b) < (c))
 test if the sum of the first two numbers is less thatn the third number.
#define dbl_EGlpNumMultTo(a, b)   ((a) *= (b))
 Multiply a given number by the value of the second number.
#define dbl_EGlpNumMultUiTo(a, b)   ((a) *= (b))
 Multiply a given number by the value of the second number.
#define dbl_EGlpNumOne(a)   ((a) = 1.0)
 Reset the value of the pointed number to one.
#define dbl_EGlpNumReadStr(a, str)
 Read from a string a number and store it in the given double,.
#define dbl_EGlpNumReallocArray(lptr, lsize)
 Reallocate and initialize (if needed) 'size' elements of type EGlpNum_t and return it, if no more memory, exit(1).
#define dbl_EGlpNumSet(var, dbl)   ((var) = (dbl))
 set the given number pointer, set its value to the given double.
#define dbl_EGlpNumSetToMaxAbs(dest, orig)
 change the fist number to the maximum between itself and the absolute value of the second.
#define dbl_EGlpNumSetToMinAbs(dest, orig)
#define dbl_EGlpNumSign(a)   ((a) = -(a))
 Change the sign of the number.
#define dbl_EGlpNumSubInnProdTo(a, b, c)   ((a) -= (b)*(c))
 Sub to a given number the product of two numbers.
#define dbl_EGlpNumSubTo(a, b)   ((a) -= (b))
 Substract to a given number the value of the second number.
#define dbl_EGlpNumSubUiTo(a, b)   ((a) -= (b))
 Substract to a given number the value of the second number.
#define dbl_EGlpNumToLf(a)   ((double)a)
 return the closest double value of the given pointer number.
#define dbl_EGlpNumZero(a)   ((a) = 0.0)
 Reset the value of the pointed number to zero.
#define dbl_epsLpNum   DBL_EPSILON
#define dbl_oneLpNum   1.0
#define dbl_zeroLpNum   0.0
#define EGLPNUM_DEBUGL   100
 Debugging verbosity messages deped on the value of DEBUG (defined in eg_configure.h) and on the value of EGLPNUM_DEBUGL macro defined here.
#define EGLPNUM_MINEPS   0x1ep-20
 This constant define the of the acuracy required while converting doubles to rationals, a good number is 1e-5. More exactly, we stop the continued fraction method whenever the next e_i-[e_i] computed is less than EGLPNUM_MINEPS. Note that this value can't be smaller than 1/ULONG_MAX, otherwise we will have problems in the confertion step.
#define EGLPNUM_TYPE   DBL_TYPE
 default type for EGLPNUM_TYPE

Functions

void EGlpNumSetPrecision (const unsigned prec)
 Change the default precision for mpf_t numbers.


Define Documentation

#define __EGlpNumAllocArray type,
size   ) 
 

Value:

({\
  size_t __sz = (size);\
  size_t *__utmp = __sz ? (size_t*) EGmalloc (sizeof(type) * __sz + sizeof(size_t)) : 0;\
  if(__sz) __utmp[0] = __sz;\
  (type*)(__sz ? (__utmp+1):0);})
Allocate an array of a given type and store (sizeof(size_t) bytes before the actual array) the size of the allocated array.

Parameters:
type the type of the array to be returned.
size the length of the array to be returned, note that it can be zero, in wich case no memory allocation is made and NULL is returned.

Definition at line 256 of file eg_lpnum.h.

#define __EGlpNumArraySize array   ) 
 

Value:

({\
  size_t *__utmp = (size_t*)(array);\
  if(__utmp) __utmp--;\
  __utmp ? __utmp[0]:0;})
Given an array allocated with __EGlpNumAllocArray, return the size of the given array, if the array is null, return zero.

Parameters:
array the array from where we need the size.

Definition at line 267 of file eg_lpnum.h.

#define __EGlpNumFreeArray array   ) 
 

Value:

({\
  size_t *__utmp = (size_t*)(array);\
  if(__utmp) free (__utmp-1);\
  (array) = 0;})
, given an array allocated by __EGlpNumAllocArray, free the allocated memory.

Parameters:
array the array to be freed, it can be null. The given array will always pooint to NULL when this function is done.

Definition at line 279 of file eg_lpnum.h.

#define dbl_EGlpNumAddInnProdTo a,
b,
 )     ((a) += (b)*(c))
 

Add to a given number the product of two numbers.

Parameters:
a EGlpNum_t the number that we are going to add to.
b EGlpNum_t value to be multiplyed.
c EGlpNum_t value to be multiplyed.
Description:
This function implements a = a + b*c, and clearly don't change the value stored in 'b' nor in 'c'.

Definition at line 336 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumAddTo a,
 )     ((a) += (b))
 

Add to a given number the value of the second number.

Parameters:
a EGlpNum_t the number that we are going to add to.
b EGlpNum_t value to be added to 'a'.
Description:
This function implements a = a + b, and clearly don't change the value stored in 'b'.

Definition at line 366 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumAddUiTo a,
 )     ((a) += (b))
 

Add to a given number the value of the second number.

Parameters:
a EGlpNum_t the number that we are going to add to.
b unsigned int value to be added to 'a'.
Description:
This function implements a = a + b, and clearly don't change the value stored in 'b'.

Definition at line 356 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumAllocArray size   )     __EGlpNumAllocArray(double,size)
 

Allocate and initialize (if needed) 'size' elements of type double and return it, if no more memory, exit(1).

Definition at line 78 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumCeil a,
 )     ((a) = ceil(b))
 

Stores in the first number the ceil value of the second number, i.e. EGlpNumCeil(a,b) <==> a= ceil(b).

Definition at line 97 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumClearVar  ) 
 

free the internal memory of a given variable

Definition at line 462 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumCopy dest,
orig   )     ((dest) = (orig))
 

copy the value of the second number to the first.

Parameters:
orig EGlpNum_t source number (it won't change value).
dest EGlpNum_t where to store the value stored in 'orig'.
Description:
Given two numbers copy the values in 'orig', into 'dest'.

Definition at line 240 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumCopyAbs dest,
orig   )     ((dest) = fabs(orig))
 

copy the value of the absolute value of the second parameter to the first parameter.

Parameters:
orig EGlpNum_t source number (it won't change value).
dest EGlpNum_t where to store the absolute value stored in 'orig'.
Description:
Given a number 'orig', copy its absolute value to 'dest'. i.e. dest = |orig|

Definition at line 276 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumCopyArray dest,
orig,
size   )     memcpy(dest,orig,sizeof(double)*(size))
 

copy the first 'size' values in the second array to the first array.

Parameters:
orig EGlpNum_t* pointer to the array from where we will copy the values (it won't change value).
dest EGlpNum_t* pointer to where to store the first 'size' values stored in 'orig'.
size unsigned int specifying how many values of 'orig' will be copied onto 'dest'
Description:
This function is provided to (possible) make fast copies of arrays of numbers, the arrays should be of length at least 'size', and the resulting copy is absolutely independent froom the original, any change in one vale of one array won't change values on the other array.

Definition at line 314 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumCopyDiff dest,
a,
 )     ((dest) = (a) - (b))
 

copy the value of the second number to the first.

Parameters:
a EGlpNum_t source number (it won't change value).
b EGlpNum_t source number (it won't change value).
dest EGlpNum_t where to store the value stored in 'orig'.
Description:
Set dest = a - b

Definition at line 222 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumCopyDiffRatio dest,
a,
b,
den   )     ((dest) = ((a) - (b)) / (den))
 

copy the value of the second number to the first.

Parameters:
a EGlpNum_t source number (it won't change value).
b EGlpNum_t source number (it won't change value).
den EGlpNum_t denominator of the difference (it won't change value).
dest EGlpNum_t where to store the value .
Description:
Set dest = (a - b) / den

Definition at line 213 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumCopyFrac dest,
op1,
op2   )     ((dest) = (op1)/(op2))
 

Set des = op1/op2.

Parameters:
dest EGlpNum_t where we will store the result.
op1 EGlpNum_t numerator of the fraction (possibly non an integer)
op2 EGlpNum_t denominator of the fraction (possibly non an integer)
Description:
Set des = op1/op2

Definition at line 298 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumCopyNeg dest,
orig   )     ((dest) = -(orig))
 

copy minus the value of the second parameter to the first parameter.

Parameters:
orig EGlpNum_t the source number (it won't change value).
dest EGlpNum_t where to store minus the value stored in 'orig'.
Description:
Given a number 'orig', copy minus the value to 'dest'. i.e. dest = -orig

Definition at line 288 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumCopySqrOver dest,
orig,
den   )     ((dest) = (orig)*(orig)/(den))
 

copy the square of the second argument, divided by the third argument into the first argument.

Parameters:
dest EGlpNum_t where to store the result
orig EGlpNum_t second parameter
den EGlpNum_t third parameter
Description:
compute dest = (orig*orig)/den

Definition at line 264 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumCopySum dest,
a,
 )     ((dest) = (a) + (b))
 

copy the value of the sum of the second and third parameter

Parameters:
a EGlpNum_t source number (it won't change value).
b EGlpNum_t source number (it won't change value).
dest EGlpNum_t where to store the sum.
Description:
Set dest = a + b

Definition at line 231 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumDivTo a,
 )     ((a) /= (b))
 

Divide a given number by the value of the second number.

Parameters:
a EGlpNum_t the number that we are going to divide by the second number and store the result.
b EGlpNum_t value to be divide to 'a'.
Description:
This function implements a = a / b, and clearly don't change the value stored in 'b'.

Definition at line 399 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumDivUiTo a,
 )     ((a) /= (b))
 

Divide a given number by the value of the second number.

Parameters:
a EGlpNum_t the number that we are going to divide by the second number and store the result.
b unsigned int value to be divided to 'a'.
Description:
This function implements a = a / b, and don't change the value stored in 'b'.

Definition at line 410 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumFloor a,
 )     ((a) = floor(b))
 

Stores in the first number the floor value of the second number, i.e. EGlpNumFloor(a,b) <==> a= floor(b).

Definition at line 102 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumFreeArray ea   )     __EGlpNumFreeArray(ea)
 

given an array of type double, free it, if the pointer is NULL nothing happen.

Definition at line 55 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumGetStr  ) 
 

Value:

({\
  char *__str=0;\
  size_t __i=snprintf(__str,(size_t)0,"%.7lg",a);\
  __str = EGsMalloc(char,__i+1);\
  snprintf(__str,__i+1,"%.7lg",a);\
  __str;})
given a double, write it to a string (to be allocated internally), and return it.

Definition at line 45 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumInitVar  )     dbl_EGlpNumZero(a)
 

initialize the internal memory of a given variable

Definition at line 458 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumInv  )     ((a) = 1.0/(a))
 

store the (multiplicative) inverse of a number to itself, i.e. implement a = 1/a.

Parameters:
a the number to be inverted.

Definition at line 108 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumIsDiffLess a,
b,
 )     ((a) - (b) < (c))
 

test if the diference of the first two numbers is less thatn the third number.

Parameters:
a EGlpNum_t the first number.
b EGlpNum_t the second number
c EGlpNum_t the third number
Returns:
int one if success, zero otherwise.
Description:
Given a,b, and c, return nonzero if (a - b < c), zero toherwise.

Definition at line 170 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumIsEqqual a,
 )     ((a) == (b))
 

Compare if two numbers are equal within a maximum error.

Parameters:
a EGlpNum_t first number to compare.
b EGlpNum_t second number to compare.
Returns:
int one in success, zero oterwise.
Description:
Given two numbers 'a','b' return 1 if a == b, otherwise it return 0

Definition at line 118 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumIsEqual a,
b,
error   )     (fabs((a)-(b)) <= (error))
 

Compare if two numbers are equal within a maximum error.

Parameters:
a EGlpNum_t first number to compare.
b EGlpNum_t second number to compare.
error EGlpNum_t maximum difference allowed between both numbers.
Returns:
int one in success, zero oterwise.
Description:
Given two numbers 'a','b' and a tolerance 'error', return 1 if |a-b|<= error, otherwise it return 0.

Definition at line 131 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumIsGreaDbl a,
 )     ((a) > (b))
 

test if the first number is bigger to the second number

Parameters:
a EGlpNum_t the first number.
b double the second number
Returns:
int one if success, zero otherwise.
Description:
Given two numbers 'a' and 'b', return one if a > b, zero otherwise.

Definition at line 192 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumIsLeq a,
 )     ((a) <= (b))
 

test if the first number is bigger to the second number

Parameters:
a EGlpNum_t the first number.
b EGlpNum_t the second number
Returns:
int one if success, zero otherwise.
Description:
Given two numbers 'a' and 'b', return one if a <= b, zero otherwise.

Definition at line 203 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumIsLess a,
 )     (a < b)
 

test if the first number is bigger to the second number

Parameters:
a EGlpNum_t the first number.
b EGlpNum_t the second number
Returns:
int one if success, zero otherwise.
Description:
Given two numbers 'a' and 'b', return one if a < b, zero otherwise.

Definition at line 146 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumIsLessDbl a,
 )     ((a) < (b))
 

test if the first number is bigger to the second number

Parameters:
a EGlpNum_t the first number.
b double the second number
Returns:
int one if success, zero otherwise.
Description:
Given two numbers 'a' and 'b', return one if a < b, zero otherwise.

Definition at line 181 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumIsNeq a,
b,
error   )     (((a)-(b) > (error)) || ((b)-(a) > (error)))
 

Definition at line 132 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumIsNeqq a,
 )     ((a) != (b))
 

Definition at line 133 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumIsNeqqZero  )     ((a) != 0.0)
 

Definition at line 135 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumIsNeqZero a,
error   )     (((a) > (error)) || (-(a) > (error)))
 

Definition at line 134 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumIsSumLess a,
b,
 )     ((a) + (b) < (c))
 

test if the sum of the first two numbers is less thatn the third number.

Parameters:
a EGlpNum_t the first number.
b EGlpNum_t the second number
c EGlpNum_t the third number
Returns:
int one if success, zero otherwise.
Description:
Given a,b, and c, return nonzero if (a + b < c), zero toherwise.

Definition at line 158 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumMultTo a,
 )     ((a) *= (b))
 

Multiply a given number by the value of the second number.

Parameters:
a EGlpNum_t the number that we are going to multiply by the second number and store the result.
b EGlpNum_t value to be multyply to 'a'.
Description:
This function implements a = a * b, and clearly don't change the value stored in 'b'.

Definition at line 388 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumMultUiTo a,
 )     ((a) *= (b))
 

Multiply a given number by the value of the second number.

Parameters:
a EGlpNum_t the number that we are going to multiply by the second number and store the result.
b unsigned int value to be multyply to 'a'.
Description:
This function implements a = a * b, and clearly don't change the value stored in 'b'.

Definition at line 421 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumOne  )     ((a) = 1.0)
 

Reset the value of the pointed number to one.

Parameters:
a EGlpNum_t value to be set to one.
Descrpition:
Reset a to zero, i.e. implements a = 1;

Definition at line 437 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumReadStr a,
str   ) 
 

Value:

({\
  int __i =0;\
  sscanf(str,"%lf%n",&(a),&__i);\
  __i;})
Read from a string a number and store it in the given double,.

Returns:
the number of chars readed from the input string

Definition at line 37 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumReallocArray lptr,
lsize   ) 
 

Value:

({\
  size_t __csz = (lsize), *__usp = 0;\
  size_t __psz = __EGlpNumArraySize(*lptr);\
  double** __ptr__ = (lptr);\
  if (!__psz) *__ptr__ = dbl_EGlpNumAllocArray (__csz); \
  else if (__psz < __csz) {\
    __usp = (size_t*)(*__ptr__);\
    __usp--;\
    __usp = EGrealloc(__usp, sizeof(double)*__csz+sizeof(size_t));\
    __usp[0] = __csz;\
    *__ptr__ = (double*)(__usp+1);\
    memset((*__ptr__)+__psz,0,sizeof(double)*(__csz-__psz));\
  }\
  *__ptr__;})
Reallocate and initialize (if needed) 'size' elements of type EGlpNum_t and return it, if no more memory, exit(1).

Definition at line 60 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumSet var,
dbl   )     ((var) = (dbl))
 

set the given number pointer, set its value to the given double.

Parameters:
var double where we will store the double value.
dbl double value to be stored in 'var'.
Description:
This function is intended to set initial values to variables; note that the double is a number and not a pointer to that value, be carefull with this detail. Also, due to implementation details this function can't deal with numbers above 1e158 or smaller than 1e-158. Note also that if the number is writen in the form $x=\bar{x}\cdot 2^e$ with $0.5<|\bar{x}|<1$, then $\left|x-\frac{p}{q}\right|<2^{e-64}$.

Definition at line 92 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumSetToMaxAbs dest,
orig   ) 
 

Value:

if((dest) < fabs(orig)) \
                                              (dest) = fabs(orig)
change the fist number to the maximum between itself and the absolute value of the second.

Parameters:
orig EGlpNum_t source number (it won't change value).
dest EGlpNum_t where to store the value stored in 'orig'.
Description:
implement dest = max(dest,abs(orig))

Definition at line 250 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumSetToMinAbs dest,
orig   ) 
 

Value:

if((dest) > fabs(orig)) \
                                              (dest) = fabs(orig)

Definition at line 252 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumSign  )     ((a) = -(a))
 

Change the sign of the number.

Parameters:
a EGlpNum_t number we will change sign.
Descrpition:
Change the sign of the given number, i.e. implements a = -a

Definition at line 445 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumSubInnProdTo a,
b,
 )     ((a) -= (b)*(c))
 

Sub to a given number the product of two numbers.

Parameters:
a EGlpNum_t the number that we are going to Sub to.
b EGlpNum_t value to be multiplyed.
c EGlpNum_t value to be multiplyed.
Description:
This function implements a = a - b*c, and clearly don't change the value stored in 'b' nor in 'c'.

Definition at line 325 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumSubTo a,
 )     ((a) -= (b))
 

Substract to a given number the value of the second number.

Parameters:
a EGlpNum_t the number that we are going to substract from.
b EGlpNum_t value to be substracted to 'a'.
Description:
This function implements a = a - b, and clearly don't change the value stored in 'b'.

Definition at line 377 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumSubUiTo a,
 )     ((a) -= (b))
 

Substract to a given number the value of the second number.

Parameters:
a EGlpNum_t the number that we are going to substract to.
b unsigned int value to be substracted to 'a'.
Description:
This function implements a = a - b, and clearly don't change the value stored in 'b'.

Definition at line 346 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumToLf  )     ((double)a)
 

return the closest double value of the given pointer number.

Parameters:
a EGlpNum_t number that we will be transformed to double.
Returns:
double the closest double representation of the given number. par Description: return the double number closest in value to the value stored in a.

Definition at line 454 of file eg_lpnum.dbl.h.

#define dbl_EGlpNumZero  )     ((a) = 0.0)
 

Reset the value of the pointed number to zero.

Parameters:
a EGlpNum_t the value to be set to zero.
Descrpition:
Reset a to zero, i.e. implements a = 0;

Definition at line 429 of file eg_lpnum.dbl.h.

#define dbl_epsLpNum   DBL_EPSILON
 

Definition at line 32 of file eg_lpnum.dbl.h.

#define dbl_oneLpNum   1.0
 

Definition at line 31 of file eg_lpnum.dbl.h.

#define DBL_TYPE   0
 

C double type.

Definition at line 150 of file eg_lpnum.h.

#define dbl_zeroLpNum   0.0
 

extern definitions of constaants for different set-ups

Definition at line 30 of file eg_lpnum.dbl.h.

#define EGLPNUM_DEBUGL   100
 

Debugging verbosity messages deped on the value of DEBUG (defined in eg_configure.h) and on the value of EGLPNUM_DEBUGL macro defined here.

Definition at line 221 of file eg_lpnum.h.

#define EGLPNUM_ISFP   1
 

Definition at line 471 of file eg_lpnum.dbl.h.

#define EGLPNUM_MAXCONVORDER   2U
 

This are the definitions needed to use double numbers within our general framework

Definition at line 469 of file eg_lpnum.dbl.h.

#define EGLPNUM_MINEPS   0x1ep-20
 

This constant define the of the acuracy required while converting doubles to rationals, a good number is 1e-5. More exactly, we stop the continued fraction method whenever the next e_i-[e_i] computed is less than EGLPNUM_MINEPS. Note that this value can't be smaller than 1/ULONG_MAX, otherwise we will have problems in the confertion step.

Definition at line 230 of file eg_lpnum.h.

#define EGlpNum_t   double
 

Definition at line 475 of file eg_lpnum.dbl.h.

#define EGLPNUM_TYPE   DBL_TYPE
 

default type for EGLPNUM_TYPE

Description:
If the type of number for EGlpNum is not defined beforehand (eg. eg_config.h or through make.conf) we default to GNU_MP_Q. available options:
  • GNU_MP_Q
  • GNU_MP_F
  • DBL_TYPE
  • LDBL_TYPE

Definition at line 197 of file eg_lpnum.h.

#define EGlpNumAddInnProdTo a,
b,
 )     dbl_EGlpNumAddInnProdTo(a,b,c)
 

Definition at line 478 of file eg_lpnum.dbl.h.

#define EGlpNumAddTo a,
 )     dbl_EGlpNumAddTo(a,b)
 

Definition at line 476 of file eg_lpnum.dbl.h.

#define EGlpNumAddUiTo a,
 )     dbl_EGlpNumAddUiTo(a,b)
 

Definition at line 477 of file eg_lpnum.dbl.h.

#define EGlpNumAllocArray size   )     dbl_EGlpNumAllocArray(size)
 

Definition at line 479 of file eg_lpnum.dbl.h.

#define EGlpNumCeil a,
 )     dbl_EGlpNumCeil(a,b)
 

Definition at line 480 of file eg_lpnum.dbl.h.

#define EGlpNumClearVar  )     dbl_EGlpNumClearVar(a)
 

Definition at line 481 of file eg_lpnum.dbl.h.

#define EGlpNumCopy dest,
orig   )     dbl_EGlpNumCopy(dest,orig)
 

Definition at line 482 of file eg_lpnum.dbl.h.

#define EGlpNumCopyAbs dest,
orig   )     dbl_EGlpNumCopyAbs(dest,orig)
 

Definition at line 488 of file eg_lpnum.dbl.h.

#define EGlpNumCopyArray dest,
orig,
size   )     dbl_EGlpNumCopyArray(dest,orig,size)
 

Definition at line 483 of file eg_lpnum.dbl.h.

#define EGlpNumCopyDiff dest,
a,
 )     dbl_EGlpNumCopyDiff(dest,a,b)
 

Definition at line 484 of file eg_lpnum.dbl.h.

#define EGlpNumCopyDiffRatio a,
b,
c,
 )     dbl_EGlpNumCopyDiffRatio(a,b,c,d)
 

Definition at line 485 of file eg_lpnum.dbl.h.

#define EGlpNumCopyFrac dest,
op1,
op2   )     dbl_EGlpNumCopyFrac(dest,op1,op2)
 

Definition at line 490 of file eg_lpnum.dbl.h.

#define EGlpNumCopyNeg dest,
orig   )     dbl_EGlpNumCopyNeg(dest,orig)
 

Definition at line 489 of file eg_lpnum.dbl.h.

#define EGlpNumCopySqrOver dest,
orig,
den   )     dbl_EGlpNumCopySqrOver(dest,orig,den)
 

Definition at line 487 of file eg_lpnum.dbl.h.

#define EGlpNumCopySum dest,
a,
 )     dbl_EGlpNumCopySum(dest,a,b)
 

Definition at line 486 of file eg_lpnum.dbl.h.

#define EGlpNumDivTo a,
 )     dbl_EGlpNumDivTo(a,b)
 

Definition at line 491 of file eg_lpnum.dbl.h.

#define EGlpNumDivUiTo a,
 )     dbl_EGlpNumDivUiTo(a,b)
 

Definition at line 492 of file eg_lpnum.dbl.h.

#define EGlpNumFloor a,
 )     dbl_EGlpNumFloor(a,b)
 

Definition at line 493 of file eg_lpnum.dbl.h.

#define EGlpNumFreeArray ea   )     dbl_EGlpNumFreeArray(ea)
 

Definition at line 494 of file eg_lpnum.dbl.h.

#define EGlpNumGetStr  )     dbl_EGlpNumGetStr(a)
 

Definition at line 495 of file eg_lpnum.dbl.h.

#define EGlpNumInitVar  )     dbl_EGlpNumInitVar(a)
 

Definition at line 496 of file eg_lpnum.dbl.h.

#define EGlpNumInv  )     dbl_EGlpNumInv(a)
 

Definition at line 497 of file eg_lpnum.dbl.h.

#define EGlpNumIsDiffLess a,
b,
 )     dbl_EGlpNumIsDiffLess(a,b,c)
 

Definition at line 498 of file eg_lpnum.dbl.h.

#define EGlpNumIsEqqual a,
 )     dbl_EGlpNumIsEqqual(a,b)
 

Definition at line 499 of file eg_lpnum.dbl.h.

#define EGlpNumIsEqual a,
b,
error   )     dbl_EGlpNumIsEqual(a,b,error)
 

Definition at line 500 of file eg_lpnum.dbl.h.

#define EGlpNumIsGreaDbl a,
 )     dbl_EGlpNumIsGreaDbl(a,b)
 

Definition at line 501 of file eg_lpnum.dbl.h.

#define EGlpNumIsLeq a,
 )     dbl_EGlpNumIsLeq(a,b)
 

Definition at line 504 of file eg_lpnum.dbl.h.

#define EGlpNumIsLess a,
 )     dbl_EGlpNumIsLess(a,b)
 

Definition at line 503 of file eg_lpnum.dbl.h.

#define EGlpNumIsLessDbl a,
 )     dbl_EGlpNumIsLessDbl(a,b)
 

Definition at line 502 of file eg_lpnum.dbl.h.

#define EGlpNumIsNeq a,
b,
error   )     dbl_EGlpNumIsNeq(a,b,error)
 

Definition at line 505 of file eg_lpnum.dbl.h.

#define EGlpNumIsNeqq a,
 )     dbl_EGlpNumIsNeqq(a,b)
 

Definition at line 506 of file eg_lpnum.dbl.h.

#define EGlpNumIsNeqqZero  )     dbl_EGlpNumIsNeqqZero(a)
 

Definition at line 508 of file eg_lpnum.dbl.h.

#define EGlpNumIsNeqZero a,
error   )     dbl_EGlpNumIsNeqZero(a,error)
 

Definition at line 507 of file eg_lpnum.dbl.h.

#define EGlpNumIsSumLess a,
b,
 )     dbl_EGlpNumIsSumLess(a,b,c)
 

Definition at line 509 of file eg_lpnum.dbl.h.

#define EGlpNumMultTo a,
 )     dbl_EGlpNumMultTo(a,b)
 

Definition at line 510 of file eg_lpnum.dbl.h.

#define EGlpNumMultUiTo a,
 )     dbl_EGlpNumMultUiTo(a,b)
 

Definition at line 511 of file eg_lpnum.dbl.h.

#define EGlpNumOne  )     dbl_EGlpNumOne(a)
 

Definition at line 512 of file eg_lpnum.dbl.h.

#define EGlpNumReadStr a,
str   )     dbl_EGlpNumReadStr(a,str)
 

Definition at line 513 of file eg_lpnum.dbl.h.

#define EGlpNumReallocArray lptr,
size   )     dbl_EGlpNumReallocArray(lptr,size)
 

Definition at line 514 of file eg_lpnum.dbl.h.

#define EGlpNumSet var,
dbl   )     dbl_EGlpNumSet(var,dbl)
 

Definition at line 515 of file eg_lpnum.dbl.h.

#define EGlpNumSetToMaxAbs dest,
orig   )     dbl_EGlpNumSetToMaxAbs(dest,orig)
 

Definition at line 516 of file eg_lpnum.dbl.h.

#define EGlpNumSetToMinAbs dest,
orig   )     dbl_EGlpNumSetToMinAbs(dest,orig)
 

Definition at line 517 of file eg_lpnum.dbl.h.

#define EGlpNumSign  )     dbl_EGlpNumSign(a)
 

Definition at line 518 of file eg_lpnum.dbl.h.

#define EGlpNumSubInnProdTo a,
b,
 )     dbl_EGlpNumSubInnProdTo(a,b,c)
 

Definition at line 521 of file eg_lpnum.dbl.h.

#define EGlpNumSubTo a,
 )     dbl_EGlpNumSubTo(a,b)
 

Definition at line 519 of file eg_lpnum.dbl.h.

#define EGlpNumSubUiTo a,
 )     dbl_EGlpNumSubUiTo(a,b)
 

Definition at line 520 of file eg_lpnum.dbl.h.

#define EGlpNumToLf  )     dbl_EGlpNumToLf(a)
 

Definition at line 522 of file eg_lpnum.dbl.h.

#define EGlpNumZero  )     dbl_EGlpNumZero(a)
 

Definition at line 523 of file eg_lpnum.dbl.h.

#define epsLpNum   dbl_epsLpNum
 

Definition at line 472 of file eg_lpnum.dbl.h.

#define FLOAT128_TYPE   13
 

SoftFloat 128-bit floating point numbner

Definition at line 180 of file eg_lpnum.h.

#define FLT_TYPE   1
 

C float type.

Definition at line 152 of file eg_lpnum.h.

#define FP10_TYPE   3
 

EGlib EGfp10_t type, this is an implementation of fixed precision arithmetic with 10 bits for fractional representation.

Definition at line 157 of file eg_lpnum.h.

#define FP20_TYPE   4
 

EGlib EGfp20_t type, this is an implementation of fixed precision arithmetic with 20 bits for fractional representation.

Definition at line 160 of file eg_lpnum.h.

#define FP25_TYPE   6
 

EGlib EGfp25_t type, this is an implementation of fixed precision arithmetic with 25 bits for fractional representation.

Definition at line 166 of file eg_lpnum.h.

#define FP28_TYPE   5
 

EGlib EGfp28_t type, this is an implementation of fixed precision arithmetic with 28 bits for fractional representation.

Definition at line 163 of file eg_lpnum.h.

#define INT_TYPE   2
 

C int type.

Definition at line 154 of file eg_lpnum.h.

#define LDBL_TYPE   11
 

C long double type

Definition at line 176 of file eg_lpnum.h.

#define LLINT_TYPE   12
 

C long long int type

Definition at line 178 of file eg_lpnum.h.

#define oneLpNum   dbl_oneLpNum
 

Definition at line 473 of file eg_lpnum.dbl.h.

#define zeroLpNum   dbl_zeroLpNum
 

Definition at line 474 of file eg_lpnum.dbl.h.


Function Documentation

void EGlpNumSetPrecision const unsigned  prec  ) 
 

Change the default precision for mpf_t numbers.


Generated on Wed Nov 21 09:38:35 2007 for MTgomory by  doxygen 1.4.6