Files | |
| file | eg_lpnum.c |
| file | eg_lpnum.dbl.h |
| file | eg_lpnum.ex.c |
| file | eg_lpnum.fp20.h |
Here we provide an implementation of the common EGlpNum interface using EGlib fixed point numbers, on the case where we store 20 bits for fractional values, 11 bits for integers part and one sign bit. See eg_fp.h for more details. | |
| file | eg_lpnum.h |
| file | eg_lpnum.int.h |
| file | eg_lpnum.int32.h |
| file | eg_lpnum.llint.h |
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_EGlpNumIsGreatZero(a) (a > 0.0) |
| test if the first number is greater than zero | |
| #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_EGlpNumIsLessZero(a) (a < 0.0) |
| test if the first number is less than zero | |
| #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_MaxLpNum DBL_MAX |
| #define | dbl_MinLpNum DBL_MIN |
| #define | dbl_oneLpNum 1.0 |
| #define | dbl_zeroLpNum 0.0 |
| #define | EG_LPNUM_MEMSLAB 1 |
| if non-zero, use slab-pool allocator for GMP, otherwise, use malloc/ realloc / free, | |
| #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 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 | EGlpNumExit EGlpNumClear |
| provided for backwards compatibility | |
| #define | fp20_EGlpNumAddInnProdTo(a, b, c) ((a) += ((EGfp20_t)((((long long)(b))*(c))/fp20_oneLpNum))) |
| Add to a given number the product of two numbers. | |
| #define | fp20_EGlpNumAddTo(a, b) ((a) += (b)) |
| Add to a given number the value of the second number. | |
| #define | fp20_EGlpNumAddUiTo(a, b) ((a) += (b)*fp20_oneLpNum) |
| Add to a given number the value of the second number. | |
| #define | fp20_EGlpNumAllocArray(size) __EGlpNumAllocArray(EGfp20_t,size) |
| Allocate and initialize (if needed) 'size' elements of type int and return it, if no more memory, exit(1). | |
| #define | fp20_EGlpNumCeil(a, b) |
| Stores in the first number the ceil value of the second number, i.e. EGlpNumCeil(a,b) <==> a= ceil(b). | |
| #define | fp20_EGlpNumClearVar(a) |
| free the internal memory of a given variable | |
| #define | fp20_EGlpNumCopy(dest, orig) ((dest) = (orig)) |
| copy the value of the second number to the first. | |
| #define | fp20_EGlpNumCopyAbs(dest, orig) ((dest) = EGabs(orig)) |
| copy the value of the absolute value of the second parameter to the first parameter. | |
| #define | fp20_EGlpNumCopyArray(dest, orig, size) memcpy(dest,orig,sizeof(EGfp20_t)*(size)) |
| copy the first 'size' values in the second array to the first array. | |
| #define | fp20_EGlpNumCopyDiff(dest, a, b) ((dest) = (a) - (b)) |
| copy the value of the second number to the first. | |
| #define | fp20_EGlpNumCopyDiffRatio(dest, a, b, den) ((dest) = (EGfp20_t)((((long long)((a) - (b)))*fp20_oneLpNum) / (den))) |
| copy the value of the second number to the first. | |
| #define | fp20_EGlpNumCopyFrac(dest, op1, op2) ((dest) = ((EGfp20_t)((((long long)(op1))*fp20_oneLpNum)/(op2)))) |
| Set des = op1/op2. | |
| #define | fp20_EGlpNumCopyNeg(dest, orig) ((dest) = -(orig)) |
| copy minus the value of the second parameter to the first parameter. | |
| #define | fp20_EGlpNumCopySqrOver(dest, orig, den) ((dest) = ((EGfp20_t)((((long long)(orig))*(orig))/(den)))) |
| copy the square of the second argument, divided by the third argument into the first argument. | |
| #define | fp20_EGlpNumCopySum(dest, a, b) ((dest) = (a) + (b)) |
| copy the value of the sum of the second and third parameter | |
| #define | fp20_EGlpNumDivTo(a, b) ((a) = ((EGfp20_t)((((long long)(a))*fp20_oneLpNum)/(b)))) |
| Divide a given number by the value of the second number. | |
| #define | fp20_EGlpNumDivUiTo(a, b) ((a) /= (b)) |
| Divide a given number by the value of the second number. | |
| #define | fp20_EGlpNumFloor(a, b) ((a) = (((b)/fp20_oneLpNum)*fp20_oneLpNum)) |
| Stores in the first number the floor value of the second number, i.e. EGlpNumFloor(a,b) <==> a= floor(b). | |
| #define | fp20_EGlpNumFreeArray(ea) __EGlpNumFreeArray(ea) |
| given an array of type int, free it, if the pointer is NULL nothing happen. | |
| #define | fp20_EGlpNumGetStr(a) |
| given a int, write it to a string (to be allocated internally), and return it. | |
| #define | fp20_EGlpNumInitVar(a) fp20_EGlpNumZero(a) |
| initialize the internal memory of a given variable | |
| #define | fp20_EGlpNumInv(a) |
| store the (multiplicative) inverse of a number to itself, i.e. implement a = 1/a. | |
| #define | fp20_EGlpNumIsDiffLess(a, b, c) ((a) - (b) < (c)) |
| test if the diference of the first two numbers is less thatn the third number. | |
| #define | fp20_EGlpNumIsEqqual(a, b) ((a) == (b)) |
| Compare if two numbers are equal within a maximum error. | |
| #define | fp20_EGlpNumIsEqual(a, b, error) (EGabs((a)-(b)) <= (error)) |
| Compare if two numbers are equal within a maximum error. | |
| #define | fp20_EGlpNumIsGreaDbl(a, b) ((a) > ((b)*fp20_oneLpNum)) |
| test if the first number is bigger to the second number | |
| #define | fp20_EGlpNumIsGreatZero(a) (a > 0) |
| test if the first number is greater than zero | |
| #define | fp20_EGlpNumIsLeq(a, b) ((a) <= (b)) |
| test if the first number is bigger to the second number | |
| #define | fp20_EGlpNumIsLess(a, b) (a < b) |
| test if the first number is bigger to the second number | |
| #define | fp20_EGlpNumIsLessDbl(a, b) ((a) < ((b)*fp20_oneLpNum)) |
| test if the first number is bigger to the second number | |
| #define | fp20_EGlpNumIsLessZero(a) (a < 0) |
| test if the first number is less than zero | |
| #define | fp20_EGlpNumIsNeq(a, b, error) (((a)-(b) > (error)) || ((b)-(a) > (error))) |
| #define | fp20_EGlpNumIsNeqq(a, b) ((a) != (b)) |
| #define | fp20_EGlpNumIsNeqqZero(a) ((a) != 0) |
| #define | fp20_EGlpNumIsNeqZero(a, error) (((a) > (error)) || (-(a) > (error))) |
| #define | fp20_EGlpNumIsSumLess(a, b, c) ((a) + (b) < (c)) |
| test if the sum of the first two numbers is less thatn the third number. | |
| #define | fp20_EGlpNumMultTo(a, b) ((a) = ((EGfp20_t)((((long long)(a))*(b))/fp20_oneLpNum))) |
| Multiply a given number by the value of the second number. | |
| #define | fp20_EGlpNumMultUiTo(a, b) ((a) *= (b)) |
| Multiply a given number by the value of the second number. | |
| #define | fp20_EGlpNumOne(a) ((a) = fp20_oneLpNum) |
| Reset the value of the pointed number to one. | |
| #define | fp20_EGlpNumReadStr(a, str) |
| Read from a string a number and store it in the given int,. | |
| #define | fp20_EGlpNumReallocArray(lptr, lsize) |
| Reallocate and initialize (if needed) 'size' elements of type EGlpNum_t and return it, if no more memory, exit(1). | |
| #define | fp20_EGlpNumSet(var, dbl_var) ((var) = (EGfp20_t)((dbl_var)*fp20_oneLpNum)) |
| set the given number pointer, set its value to the given int. | |
| #define | fp20_EGlpNumSetToMaxAbs(dest, orig) |
| change the fist number to the maximum between itself and the absolute value of the second. | |
| #define | fp20_EGlpNumSetToMinAbs(dest, orig) |
| #define | fp20_EGlpNumSign(a) ((a) = -(a)) |
| Change the sign of the number. | |
| #define | fp20_EGlpNumSubInnProdTo(a, b, c) ((a) -= ((EGfp20_t)((((long long)(b))*(c))/fp20_oneLpNum))) |
| Sub to a given number the product of two numbers. | |
| #define | fp20_EGlpNumSubTo(a, b) ((a) -= (b)) |
| Substract to a given number the value of the second number. | |
| #define | fp20_EGlpNumSubUiTo(a, b) ((a) -= (b)*fp20_oneLpNum) |
| Substract to a given number the value of the second number. | |
| #define | fp20_EGlpNumToLf(a) (((double)(a))/fp20_oneLpNum) |
| return the closest int value of the given pointer number. | |
| #define | fp20_EGlpNumZero(a) ((a) = 0) |
| Reset the value of the pointed number to zero. | |
| #define | fp20_epsLpNum ((int long)1) |
| #define | fp20_MaxLpNum ((int long)0x7fffffff) |
| #define | fp20_MinLpNum ((int long)0xffffffff) |
| #define | fp20_oneLpNum ((int long)0x100000) |
| #define | fp20_zeroLpNum ((int long)0) |
| #define | int32_EGlpNumAddInnProdTo(__EGPa__, __EGPb__, __EGPc__) ((__EGPa__)+=(__EGPb__)*(__EGPc__)) |
| Add to (__EGPa__) given number the product of two numbers. | |
| #define | int32_EGlpNumAddTo(__EGPa__, __EGPb__) ((__EGPa__)+=(__EGPb__)) |
| Add to (__EGPa__) given number the value of the second number. | |
| #define | int32_EGlpNumAddUiTo(__EGPa__, __EGPb__) ((__EGPa__)+=((int32_t)(__EGPb__))) |
| Add to (__EGPa__) given number the value of the second number. | |
| #define | int32_EGlpNumAllocArray(__EGsz__) __EGlpNumAllocArray(int32_t,__EGsz__) |
| Allocate and initialize (if needed) '__EGsz__' elements of type int32_t and return it,if no more memory,exit(1). | |
| #define | int32_EGlpNumCeil(__EGPa__, __EGPb__) (__EGPa__=__EGPb__) |
| Stores in the first number the ceil value of the second number,i.e. EGlpNumCeil(__EGPa__,__EGPb__) <==> (__EGPa__)=ceil(__EGPb__). | |
| #define | int32_EGlpNumClearVar(__EGPa__) |
| free the internal memory of (__EGPa__) given variable | |
| #define | int32_EGlpNumCopy(__EGPd__, __EGPo__) ((__EGPd__)=(__EGPo__)) |
| copy the value of the second number to the first. | |
| #define | int32_EGlpNumCopyAbs(__EGPd__, __EGPo__) ((__EGPd__)=((__EGPo__)<0?-(__EGPo__):(__EGPo__))) |
| copy the value of the absolute value of the second parameter to the first parameter. | |
| #define | int32_EGlpNumCopyArray(__EGPd__, __EGPo__, __EGsz__) memcpy(__EGPd__,__EGPo__,sizeof(int32_t)*(__EGsz__)) |
| copy the first '(__EGsz__)' values in the second array to the first array. | |
| #define | int32_EGlpNumCopyDiff(__EGPd__, __EGPa__, __EGPb__) ((__EGPd__)=((__EGPa__)-(__EGPb__))) |
| copy the value of the second number to the first. | |
| #define | int32_EGlpNumCopyDiffRatio(__EGPd__, __EGPa__, __EGPb__, __EGPdn__) ((__EGPd__)=((__EGPa__)-(__EGPb__))/(__EGPdn__)) |
| copy the value of the second number to the first. | |
| #define | int32_EGlpNumCopyFrac(__EGPd__, __EGPone__, __EGPtwo__) ((__EGPd__)=(__EGPone__)/(__EGPtwo__)) |
| Set des=(__EGPone__)/(__EGPtwo__). | |
| #define | int32_EGlpNumCopyNeg(__EGPd__, __EGPo__) ((__EGPd__)=-(__EGPo__)) |
| copy minus the value of the second parameter to the first parameter. | |
| #define | int32_EGlpNumCopySqrOver(__EGPd__, __EGPo__, __EGPdn__) ((__EGPd__)=(__EGPo__)*(__EGPo__)/(__EGPdn__)) |
| copy the square of the second argument,divided by the third argument into the first argument. | |
| #define | int32_EGlpNumCopySum(__EGPd__, __EGPa__, __EGPb__) ((__EGPd__)=((__EGPa__)+(__EGPb__))) |
| copy the value of the sum of the second and third parameter | |
| #define | int32_EGlpNumDivTo(__EGPa__, __EGPb__) ((__EGPa__)/=(__EGPb__)) |
| Divide (__EGPa__) given number by the value of the second number. | |
| #define | int32_EGlpNumDivUiTo(__EGPa__, __EGPb__) ((__EGPa__)/=((int32_t)(__EGPb__))) |
| Divide (__EGPa__) given number by the value of the second number. | |
| #define | int32_EGlpNumFloor(__EGPa__, __EGPb__) (__EGPa__=__EGPb__) |
| Stores in the first number the floor value of the second number,i.e. EGlpNumFloor(__EGPa__,__EGPb__) <==> (__EGPa__)=floor(__EGPb__). | |
| #define | int32_EGlpNumFreeArray(__EGea__) __EGlpNumFreeArray(__EGea__) |
| given an array of type number,free it,if the pointer is NULL nothing happen. | |
| #define | int32_EGlpNumGetStr(__EGPa__) |
| given a number,write it to a string (to be allocated internally), and return it. | |
| #define | int32_EGlpNumInitVar(__EGPa__) int32_EGlpNumZero(__EGPa__) |
| initialize the internal memory of (__EGPa__) given variable | |
| #define | int32_EGlpNumInv(__EGPa__) ((__EGPa__)=0) |
| store the (multiplicative) inverse of (__EGPa__) number to itself,i.e. implement (__EGPa__)=1/(__EGPa__). | |
| #define | int32_EGlpNumIsDiffLess(__EGPa__, __EGPb__, __EGPc__) ((__EGPa__)-(__EGPb__)<(__EGPc__)) |
| test if the diference of the first two numbers is less thatn the third number. | |
| #define | int32_EGlpNumIsEqqual(__EGPa__, __EGPb__) ((__EGPa__)==(__EGPb__)) |
| Compare if two numbers are equal within (__EGPa__) maximum (__EGPerr__). | |
| #define | int32_EGlpNumIsEqual(__EGPa__, __EGPb__, __EGPerr__) (EGabs((__EGPa__)-(__EGPb__))<=(__EGPerr__)) |
| Compare if two numbers are equal within (__EGPa__) maximum (__EGPerr__). | |
| #define | int32_EGlpNumIsGreaDbl(__EGPa__, __EGPb__) (((double)(__EGPa__)) > (__EGPb__)) |
| test if the first number is bigger to the second number | |
| #define | int32_EGlpNumIsGreatZero(__EGPa__) ((__EGPa__)>0) |
| test if the first number is greater than zero | |
| #define | int32_EGlpNumIsLeq(__EGPa__, __EGPb__) ((__EGPa__)<=(__EGPb__)) |
| test if the first number is bigger to the second number | |
| #define | int32_EGlpNumIsLess(__EGPa__, __EGPb__) ((__EGPa__)<(__EGPb__)) |
| test if the first number is bigger to the second number | |
| #define | int32_EGlpNumIsLessDbl(__EGPa__, __EGPb__) (((double)(__EGPa__)) < (__EGPb__)) |
| test if the first number is bigger to the second number | |
| #define | int32_EGlpNumIsLessZero(__EGPa__) ((__EGPa__)<0) |
| test if the first number is less than zero | |
| #define | int32_EGlpNumIsNeq(__EGPa__, __EGPb__, __EGPerr__) (EGabs((__EGPa__)-(__EGPb__))>(__EGPerr__)) |
| #define | int32_EGlpNumIsNeqq(__EGPa__, __EGPb__) ((__EGPa__)!=(__EGPb__)) |
| #define | int32_EGlpNumIsNeqqZero(__EGPa__) (__EGPa__) |
| #define | int32_EGlpNumIsNeqZero(__EGPa__, __EGPerr__) (((__EGPa__)>(__EGPerr__))||(-(__EGPa__) > (__EGPerr__))) |
| #define | int32_EGlpNumIsSumLess(__EGPa__, __EGPb__, __EGPc__) ((__EGPa__)+(__EGPb__)<(__EGPc__)) |
| test if the sum of the first two numbers is less thatn the third number. | |
| #define | int32_EGlpNumMultTo(__EGPa__, __EGPb__) ((__EGPa__)*=(__EGPb__)) |
| Multiply (__EGPa__) given number by the value of the second number. | |
| #define | int32_EGlpNumMultUiTo(__EGPa__, __EGPb__) ((__EGPa__)*=((int32_t)(__EGPb__))) |
| Multiply (__EGPa__) given number by the value of the second number. | |
| #define | int32_EGlpNumOne(__EGPa__) ((__EGPa__)=1) |
| Reset the value of the pointed number to one. | |
| #define | int32_EGlpNumReadStr(__EGPa__, __EGstr__) |
| Read from a string a number and store it in the given number,. | |
| #define | int32_EGlpNumReallocArray(__EGpone__, __EGlsz__) |
| Reallocate and initialize (if needed) '__EGlsz__' elements of type int32_t and return it,if no more memory,exit(1). | |
| #define | int32_EGlpNumSet(__EGvone__, __EGdbl__) ((__EGvone__)=(int32_t)(__EGdbl__)) |
| set the given number pointer,set its value to the given double. | |
| #define | int32_EGlpNumSetToMaxAbs(__EGPd__, __EGPo__) |
| change the fist number to the maximum between itself and the absolute value of the second. | |
| #define | int32_EGlpNumSetToMinAbs(__EGPd__, __EGPo__) |
| #define | int32_EGlpNumSign(__EGPa__) ((__EGPa__)=-(__EGPa__)) |
| Change the sign of the number. | |
| #define | int32_EGlpNumSubInnProdTo(__EGPa__, __EGPb__, __EGPc__) ((__EGPa__)-=(__EGPb__)*(__EGPc__)) |
| Sub to (__EGPa__) given number the product of two numbers. | |
| #define | int32_EGlpNumSubTo(__EGPa__, __EGPb__) ((__EGPa__)-=(__EGPb__)) |
| Substract to (__EGPa__) given number the value of the second number. | |
| #define | int32_EGlpNumSubUiTo(__EGPa__, __EGPb__) ((__EGPa__)-=((int32_t)(__EGPb__))) |
| Substract to (__EGPa__) given number the value of the second number. | |
| #define | int32_EGlpNumToLf(__EGPa__) ((double)(__EGPa__)) |
| return the closest double value of the given pointer number. | |
| #define | int32_EGlpNumZero(__EGPa__) ((__EGPa__)=0) |
| Reset the value of the pointed number to zero. | |
| #define | int32_epsLpNum 0 |
| #define | int32_MaxLpNum INT32_MAX |
| #define | int32_MinLpNum INT32_MIN |
| #define | int32_oneLpNum 1 |
| #define | int32_zeroLpNum 0 |
| #define | int_EGlpNumAddInnProdTo(a, b, c) ((a) += (b)*(c)) |
| Add to a given number the product of two numbers. | |
| #define | int_EGlpNumAddTo(a, b) ((a) += (b)) |
| Add to a given number the value of the second number. | |
| #define | int_EGlpNumAddUiTo(a, b) ((a) += (b)) |
| Add to a given number the value of the second number. | |
| #define | int_EGlpNumAllocArray(size) __EGlpNumAllocArray(int,size) |
| Allocate and initialize (if needed) 'size' elements of type int and return it, if no more memory, exit(1). | |
| #define | int_EGlpNumCeil(a, b) int_EGlpNumSet(a,b) |
| Stores in the first number the ceil value of the second number, i.e. EGlpNumCeil(a,b) <==> a= ceil(b). | |
| #define | int_EGlpNumClearVar(a) |
| free the internal memory of a given variable | |
| #define | int_EGlpNumCopy(dest, orig) ((dest) = (orig)) |
| copy the value of the second number to the first. | |
| #define | int_EGlpNumCopyAbs(dest, orig) ((dest) = EGabs(orig)) |
| copy the value of the absolute value of the second parameter to the first parameter. | |
| #define | int_EGlpNumCopyArray(dest, orig, size) memcpy(dest,orig,sizeof(int)*(size)) |
| copy the first 'size' values in the second array to the first array. | |
| #define | int_EGlpNumCopyDiff(dest, a, b) ((dest) = (a) - (b)) |
| copy the value of the second number to the first. | |
| #define | int_EGlpNumCopyDiffRatio(dest, a, b, den) ((dest) = ((a) - (b)) / (den)) |
| copy the value of the second number to the first. | |
| #define | int_EGlpNumCopyFrac(dest, op1, op2) ((dest) = (op1)/(op2)) |
| Set des = op1/op2. | |
| #define | int_EGlpNumCopyNeg(dest, orig) ((dest) = -(orig)) |
| copy minus the value of the second parameter to the first parameter. | |
| #define | int_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 | int_EGlpNumCopySum(dest, a, b) ((dest) = (a) + (b)) |
| copy the value of the sum of the second and third parameter | |
| #define | int_EGlpNumDivTo(a, b) ((a) /= (b)) |
| Divide a given number by the value of the second number. | |
| #define | int_EGlpNumDivUiTo(a, b) ((a) /= (b)) |
| Divide a given number by the value of the second number. | |
| #define | int_EGlpNumFloor(a, b) int_EGlpNumSet(a,b) |
| Stores in the first number the floor value of the second number, i.e. EGlpNumFloor(a,b) <==> a= floor(b). | |
| #define | int_EGlpNumFreeArray(ea) __EGlpNumFreeArray(ea) |
| given an array of type int, free it, if the pointer is NULL nothing happen. | |
| #define | int_EGlpNumGetStr(a) |
| given a int, write it to a string (to be allocated internally), and return it. | |
| #define | int_EGlpNumInitVar(a) int_EGlpNumZero(a) |
| initialize the internal memory of a given variable | |
| #define | int_EGlpNumInv(a) ((a) = 1/(a)) |
| store the (multiplicative) inverse of a number to itself, i.e. implement a = 1/a. | |
| #define | int_EGlpNumIsDiffLess(a, b, c) ((a) - (b) < (c)) |
| test if the diference of the first two numbers is less thatn the third number. | |
| #define | int_EGlpNumIsEqqual(a, b) ((a) == (b)) |
| Compare if two numbers are equal within a maximum error. | |
| #define | int_EGlpNumIsEqual(a, b, error) (EGabs((a)-(b)) <= (error)) |
| Compare if two numbers are equal within a maximum error. | |
| #define | int_EGlpNumIsGreaDbl(a, b) ((a) > (b)) |
| test if the first number is bigger to the second number | |
| #define | int_EGlpNumIsGreatZero(a) (a > 0) |
| test if a numer is greater than zero | |
| #define | int_EGlpNumIsLeq(a, b) ((a) <= (b)) |
| test if the first number is bigger to the second number | |
| #define | int_EGlpNumIsLess(a, b) (a < b) |
| test if the first number is bigger to the second number | |
| #define | int_EGlpNumIsLessDbl(a, b) ((a) < (b)) |
| test if the first number is bigger to the second number | |
| #define | int_EGlpNumIsLessZero(a) (a < 0) |
| test if a numer is less than zero | |
| #define | int_EGlpNumIsNeq(a, b, error) (((a)-(b) > (error)) || ((b)-(a) > (error))) |
| #define | int_EGlpNumIsNeqq(a, b) ((a) != (b)) |
| #define | int_EGlpNumIsNeqqZero(a) ((a) != 0) |
| #define | int_EGlpNumIsNeqZero(a, error) (((a) > (error)) || (-(a) > (error))) |
| #define | int_EGlpNumIsSumLess(a, b, c) ((a) + (b) < (c)) |
| test if the sum of the first two numbers is less thatn the third number. | |
| #define | int_EGlpNumMultTo(a, b) ((a) *= (b)) |
| Multiply a given number by the value of the second number. | |
| #define | int_EGlpNumMultUiTo(a, b) ((a) *= (b)) |
| Multiply a given number by the value of the second number. | |
| #define | int_EGlpNumOne(a) ((a) = 1) |
| Reset the value of the pointed number to one. | |
| #define | int_EGlpNumReadStr(a, str) |
| Read from a string a number and store it in the given int,. | |
| #define | int_EGlpNumReallocArray(lptr, lsize) |
| Reallocate and initialize (if needed) 'size' elements of type EGlpNum_t and return it, if no more memory, exit(1). | |
| #define | int_EGlpNumSet(var, dbl_var) ((var) = (dbl_var)) |
| set the given number pointer, set its value to the given int. | |
| #define | int_EGlpNumSetToMaxAbs(dest, orig) |
| change the fist number to the maximum between itself and the absolute value of the second. | |
| #define | int_EGlpNumSetToMinAbs(dest, orig) |
| #define | int_EGlpNumSign(a) ((a) = -(a)) |
| Change the sign of the number. | |
| #define | int_EGlpNumSubInnProdTo(a, b, c) ((a) -= (b)*(c)) |
| Sub to a given number the product of two numbers. | |
| #define | int_EGlpNumSubTo(a, b) ((a) -= (b)) |
| Substract to a given number the value of the second number. | |
| #define | int_EGlpNumSubUiTo(a, b) ((a) -= (b)) |
| Substract to a given number the value of the second number. | |
| #define | int_EGlpNumToLf(a) ((double)a) |
| return the closest int value of the given pointer number. | |
| #define | int_EGlpNumZero(a) ((a) = 0) |
| Reset the value of the pointed number to zero. | |
| #define | int_epsLpNum 0 |
| #define | int_MaxLpNum INT_MAX |
| #define | int_MinLpNum INT_MIN |
| #define | int_oneLpNum 1 |
| #define | int_zeroLpNum 0 |
| #define | llint_EGlpNumAddInnProdTo(a, b, c) ((a) += (b)*(c)) |
| Add to a given number the product of two numbers. | |
| #define | llint_EGlpNumAddTo(a, b) ((a) += (b)) |
| Add to a given number the value of the second number. | |
| #define | llint_EGlpNumAddUiTo(a, b) ((a) += (b)) |
| Add to a given number the value of the second number. | |
| #define | llint_EGlpNumAllocArray(size) __EGlpNumAllocArray(long long int,size) |
| Allocate and initialize (if needed) 'size' elements of type long long int and return it, if no more memory, exit(1). | |
| #define | llint_EGlpNumCeil(a, b) llint_EGlpNumSet(a,b) |
| Stores in the first number the ceil value of the second number, i.e. EGlpNumCeil(a,b) <==> a= ceil(b). | |
| #define | llint_EGlpNumClearVar(a) |
| free the internal memory of a given variable | |
| #define | llint_EGlpNumCopy(dest, orig) ((dest) = (orig)) |
| copy the value of the second number to the first. | |
| #define | llint_EGlpNumCopyAbs(dest, orig) ((dest) = EGabs(orig)) |
| copy the value of the absolute value of the second parameter to the first parameter. | |
| #define | llint_EGlpNumCopyArray(dest, orig, size) memcpy(dest,orig,sizeof(long long int)*(size)) |
| copy the first 'size' values in the second array to the first array. | |
| #define | llint_EGlpNumCopyDiff(dest, a, b) ((dest) = (a) - (b)) |
| copy the value of the second number to the first. | |
| #define | llint_EGlpNumCopyDiffRatio(dest, a, b, den) ((dest) = ((a) - (b)) / (den)) |
| copy the value of the second number to the first. | |
| #define | llint_EGlpNumCopyFrac(dest, op1, op2) ((dest) = (op1)/(op2)) |
| Set des = op1/op2. | |
| #define | llint_EGlpNumCopyNeg(dest, orig) ((dest) = -(orig)) |
| copy minus the value of the second parameter to the first parameter. | |
| #define | llint_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 | llint_EGlpNumCopySum(dest, a, b) ((dest) = (a) + (b)) |
| copy the value of the sum of the second and third parameter | |
| #define | llint_EGlpNumDivTo(a, b) ((a) /= (b)) |
| Divide a given number by the value of the second number. | |
| #define | llint_EGlpNumDivUiTo(a, b) ((a) /= (b)) |
| Divide a given number by the value of the second number. | |
| #define | llint_EGlpNumFloor(a, b) llint_EGlpNumSet(a,b) |
| Stores in the first number the floor value of the second number, i.e. EGlpNumFloor(a,b) <==> a= floor(b). | |
| #define | llint_EGlpNumFreeArray(ea) __EGlpNumFreeArray(ea) |
| given an array of type long long int, free it, if the pointer is NULL nothing happen. | |
| #define | llint_EGlpNumGetStr(a) |
| given a long long int, write it to a string (to be allocated internally), and return it. | |
| #define | llint_EGlpNumInitVar(a) llint_EGlpNumZero(a) |
| initialize the internal memory of a given variable | |
| #define | llint_EGlpNumInv(a) ((a) = 1/(a)) |
| store the (multiplicative) inverse of a number to itself, i.e. implement a = 1/a. | |
| #define | llint_EGlpNumIsDiffLess(a, b, c) ((a) - (b) < (c)) |
| test if the diference of the first two numbers is less thatn the third number. | |
| #define | llint_EGlpNumIsEqqual(a, b) ((a) == (b)) |
| Compare if two numbers are equal within a maximum error. | |
| #define | llint_EGlpNumIsEqual(a, b, error) (EGabs((a)-(b)) <= (error)) |
| Compare if two numbers are equal within a maximum error. | |
| #define | llint_EGlpNumIsGreaDbl(a, b) ((a) > (b)) |
| test if the first number is bigger to the second number | |
| #define | llint_EGlpNumIsGreatZero(a) (a > 0) |
| test if a number is greater than zero | |
| #define | llint_EGlpNumIsLeq(a, b) ((a) <= (b)) |
| test if the first number is bigger to the second number | |
| #define | llint_EGlpNumIsLess(a, b) (a < b) |
| test if the first number is bigger to the second number | |
| #define | llint_EGlpNumIsLessDbl(a, b) ((a) < (b)) |
| test if the first number is bigger to the second number | |
| #define | llint_EGlpNumIsLessZero(a) (a < 0) |
| test if a number is bellow zero | |
| #define | llint_EGlpNumIsNeq(a, b, error) (((a)-(b) > (error)) || ((b)-(a) > (error))) |
| #define | llint_EGlpNumIsNeqq(a, b) ((a) != (b)) |
| #define | llint_EGlpNumIsNeqqZero(a) ((a) != 0) |
| #define | llint_EGlpNumIsNeqZero(a, error) (((a) > (error)) || (-(a) > (error))) |
| #define | llint_EGlpNumIsSumLess(a, b, c) ((a) + (b) < (c)) |
| test if the sum of the first two numbers is less thatn the third number. | |
| #define | llint_EGlpNumMultTo(a, b) ((a) *= (b)) |
| Multiply a given number by the value of the second number. | |
| #define | llint_EGlpNumMultUiTo(a, b) ((a) *= (b)) |
| Multiply a given number by the value of the second number. | |
| #define | llint_EGlpNumOne(a) ((a) = 1) |
| Reset the value of the pointed number to one. | |
| #define | llint_EGlpNumReadStr(a, str) |
| Read from a string a number and store it in the given long long int,. | |
| #define | llint_EGlpNumReallocArray(lptr, lsize) |
| Reallocate and initialize (if needed) 'size' elements of type EGlpNum_t and return it, if no more memory, exit(1). | |
| #define | llint_EGlpNumSet(var, dbl_var) ((var) = (dbl_var)) |
| set the given number pointer, set its value to the given long long int. | |
| #define | llint_EGlpNumSetToMaxAbs(dest, orig) |
| change the fist number to the maximum between itself and the absolute value of the second. | |
| #define | llint_EGlpNumSetToMinAbs(dest, orig) |
| #define | llint_EGlpNumSign(a) ((a) = -(a)) |
| Change the sign of the number. | |
| #define | llint_EGlpNumSubInnProdTo(a, b, c) ((a) -= (b)*(c)) |
| Sub to a given number the product of two numbers. | |
| #define | llint_EGlpNumSubTo(a, b) ((a) -= (b)) |
| Substract to a given number the value of the second number. | |
| #define | llint_EGlpNumSubUiTo(a, b) ((a) -= (b)) |
| Substract to a given number the value of the second number. | |
| #define | llint_EGlpNumToLf(a) (a) |
| return the closest long long int value of the given pointer number. | |
| #define | llint_EGlpNumZero(a) ((a) = 0) |
| Reset the value of the pointed number to zero. | |
| #define | llint_epsLpNum 0LL |
| #define | llint_MaxLpNum LLONG_MAX |
| #define | llint_MinLpNum LLONG_MIN |
| #define | llint_oneLpNum 1LL |
| #define | llint_zeroLpNum 0LL |
Functions | |
| void | EGlpNumClear (void) |
| This function must be called at the end of the program to free all internal data used in the EGlpNum_t structures, once this function is called any operation on EGlpNum_t types may fail. | |
| void | EGlpNumStart (void) |
| type-dependant constants and helper numbers | |
| int | main (int argc, char **argv) |
| Tester program for EGlpNum_t structure and functions. | |
Variables | |
| int | __EGlpNum_setup |
| indicate if the global data needed for EGlpNum has been initialized, if zero, initialization routine should be called. This is provided to allow syncronization between libraries | |
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 | FLT_TYPE 1 |
| #define | INT_TYPE 2 |
| #define | FP10_TYPE 3 |
| #define | FP20_TYPE 4 |
| #define | FP28_TYPE 5 |
| #define | FP25_TYPE 6 |
| #define | GNU_MP_Z 8 |
| #define | GNU_MP_Q 9 |
| #define | GNU_MP_F 10 |
| #define | LDBL_TYPE 11 |
| #define | LLINT_TYPE 12 |
| #define | FLOAT128_TYPE 13 |
| #define | INT32_TYPE 14 |
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.
| #define __EGlpNumAllocArray | ( | __type, | ||
| __size | ||||
| ) |
({\
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.
| __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 229 of file eg_lpnum.h.
| #define __EGlpNumArraySize | ( | __array | ) |
({\
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.
| __array | the array from where we need the size. |
Definition at line 240 of file eg_lpnum.h.
| #define __EGlpNumFreeArray | ( | __array | ) |
({\
size_t *__utmp = (size_t*)(__array);\
if(__utmp) free (__utmp-1);\
(__array) = 0;})
, given an array allocated by __EGlpNumAllocArray, free the allocated memory.
| __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 252 of file eg_lpnum.h.
| #define dbl_EGlpNumAddInnProdTo | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) += (b)*(c)) |
Add to a given number the product of two numbers.
| 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. |
Definition at line 352 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumAddTo | ( | a, | ||
| b | ||||
| ) | ((a) += (b)) |
Add to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to add to. | |
| b | EGlpNum_t value to be added to 'a'. |
Definition at line 382 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumAddUiTo | ( | a, | ||
| b | ||||
| ) | ((a) += (b)) |
Add to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to add to. | |
| b | unsigned int value to be added to 'a'. |
Definition at line 372 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 80 of file eg_lpnum.dbl.h.
| #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).
Definition at line 99 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumClearVar | ( | a | ) |
free the internal memory of a given variable
Definition at line 478 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumCopy | ( | dest, | ||
| orig | ||||
| ) | ((dest) = (orig)) |
copy the value of the second number to the first.
| orig | EGlpNum_t source number (it won't change value). | |
| dest | EGlpNum_t where to store the value stored in 'orig'. |
Definition at line 256 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.
| orig | EGlpNum_t source number (it won't change value). | |
| dest | EGlpNum_t where to store the absolute value stored in 'orig'. |
Definition at line 292 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.
| 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' |
Definition at line 330 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumCopyDiff | ( | dest, | ||
| a, | ||||
| b | ||||
| ) | ((dest) = (a) - (b)) |
copy the value of the second number to the first.
| 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'. |
Definition at line 238 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.
| 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 . |
Definition at line 229 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumCopyFrac | ( | dest, | ||
| op1, | ||||
| op2 | ||||
| ) | ((dest) = (op1)/(op2)) |
Set des = op1/op2.
| 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) |
Definition at line 314 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.
| orig | EGlpNum_t the source number (it won't change value). | |
| dest | EGlpNum_t where to store minus the value stored in 'orig'. |
Definition at line 304 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.
| dest | EGlpNum_t where to store the result | |
| orig | EGlpNum_t second parameter | |
| den | EGlpNum_t third parameter |
Definition at line 280 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumCopySum | ( | dest, | ||
| a, | ||||
| b | ||||
| ) | ((dest) = (a) + (b)) |
copy the value of the sum of the second and third parameter
| 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. |
Definition at line 247 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumDivTo | ( | a, | ||
| b | ||||
| ) | ((a) /= (b)) |
Divide a given number by the value of the second number.
| 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'. |
Definition at line 415 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumDivUiTo | ( | a, | ||
| b | ||||
| ) | ((a) /= (b)) |
Divide a given number by the value of the second number.
| 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'. |
Definition at line 426 of file eg_lpnum.dbl.h.
| #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).
Definition at line 104 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 57 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumGetStr | ( | a | ) |
({\
char *__str=0;\
int __i=snprintf(__str,(size_t)0,"%.7lg",a);\
__str = EGsMalloc(char,__i+1);\
snprintf(__str,(size_t)(__i+1),"%.7lg",a);\
__str;})
given a double, write it to a string (to be allocated internally), and return it.
Definition at line 47 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumInitVar | ( | a | ) | dbl_EGlpNumZero(a) |
initialize the internal memory of a given variable
Definition at line 474 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumInv | ( | a | ) | ((a) = 1.0/(a)) |
store the (multiplicative) inverse of a number to itself, i.e. implement a = 1/a.
| a | the number to be inverted. |
Definition at line 110 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsDiffLess | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) - (b) < (c)) |
test if the diference of the first two numbers is less thatn the third number.
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number | |
| c | EGlpNum_t the third number |
Definition at line 186 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsEqqual | ( | a, | ||
| b | ||||
| ) | ((a) == (b)) |
Compare if two numbers are equal within a maximum error.
| a | EGlpNum_t first number to compare. | |
| b | EGlpNum_t second number to compare. |
Definition at line 120 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.
| a | EGlpNum_t first number to compare. | |
| b | EGlpNum_t second number to compare. | |
| error | EGlpNum_t maximum difference allowed between both numbers. |
Definition at line 133 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsGreaDbl | ( | a, | ||
| b | ||||
| ) | ((a) > (b)) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | double the second number |
Definition at line 208 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsGreatZero | ( | a | ) | (a > 0.0) |
test if the first number is greater than zero
| a | EGlpNum_t number to test. |
Definition at line 144 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsLeq | ( | a, | ||
| b | ||||
| ) | ((a) <= (b)) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number |
Definition at line 219 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsLess | ( | a, | ||
| b | ||||
| ) | (a < b) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number |
Definition at line 162 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsLessDbl | ( | a, | ||
| b | ||||
| ) | ((a) < (b)) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | double the second number |
Definition at line 197 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsLessZero | ( | a | ) | (a < 0.0) |
test if the first number is less than zero
| a | EGlpNum_t number to test. |
Definition at line 151 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsNeq | ( | a, | ||
| b, | ||||
| error | ||||
| ) | (((a)-(b) > (error)) || ((b)-(a) > (error))) |
Definition at line 134 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsNeqq | ( | a, | ||
| b | ||||
| ) | ((a) != (b)) |
Definition at line 135 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsNeqqZero | ( | a | ) | ((a) != 0.0) |
Definition at line 137 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsNeqZero | ( | a, | ||
| error | ||||
| ) | (((a) > (error)) || (-(a) > (error))) |
Definition at line 136 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumIsSumLess | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) + (b) < (c)) |
test if the sum of the first two numbers is less thatn the third number.
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number | |
| c | EGlpNum_t the third number |
Definition at line 174 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumMultTo | ( | a, | ||
| b | ||||
| ) | ((a) *= (b)) |
Multiply a given number by the value of the second number.
| 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'. |
Definition at line 404 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumMultUiTo | ( | a, | ||
| b | ||||
| ) | ((a) *= (b)) |
Multiply a given number by the value of the second number.
| 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'. |
Definition at line 437 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumOne | ( | a | ) | ((a) = 1.0) |
Reset the value of the pointed number to one.
| a | EGlpNum_t value to be set to one. |
Definition at line 453 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumReadStr | ( | a, | ||
| str | ||||
| ) |
({\
int __i =0;\
sscanf(str,"%lf%n",&(a),&__i);\
__i;})
Read from a string a number and store it in the given double,.
Definition at line 39 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumReallocArray | ( | lptr, | ||
| lsize | ||||
| ) |
({\
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 62 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.
| var | double where we will store the double value. | |
| dbl | double value to be stored in 'var'. |
with
, then
. Definition at line 94 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumSetToMaxAbs | ( | dest, | ||
| orig | ||||
| ) |
if((dest) < fabs(orig)) \
(dest) = fabs(orig)
change the fist number to the maximum between itself and the absolute value of the second.
| orig | EGlpNum_t source number (it won't change value). | |
| dest | EGlpNum_t where to store the value stored in 'orig'. |
Definition at line 266 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumSetToMinAbs | ( | dest, | ||
| orig | ||||
| ) |
if((dest) > fabs(orig)) \
(dest) = fabs(orig)
Definition at line 268 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumSign | ( | a | ) | ((a) = -(a)) |
Change the sign of the number.
| a | EGlpNum_t number we will change sign. |
Definition at line 461 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumSubInnProdTo | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) -= (b)*(c)) |
Sub to a given number the product of two numbers.
| 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. |
Definition at line 341 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumSubTo | ( | a, | ||
| b | ||||
| ) | ((a) -= (b)) |
Substract to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to substract from. | |
| b | EGlpNum_t value to be substracted to 'a'. |
Definition at line 393 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumSubUiTo | ( | a, | ||
| b | ||||
| ) | ((a) -= (b)) |
Substract to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to substract to. | |
| b | unsigned int value to be substracted to 'a'. |
Definition at line 362 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumToLf | ( | a | ) | ((double)a) |
return the closest double value of the given pointer number.
| a | EGlpNum_t number that we will be transformed to double. |
Definition at line 470 of file eg_lpnum.dbl.h.
| #define dbl_EGlpNumZero | ( | a | ) | ((a) = 0.0) |
Reset the value of the pointed number to zero.
| a | EGlpNum_t the value to be set to zero. |
Definition at line 445 of file eg_lpnum.dbl.h.
| #define dbl_epsLpNum DBL_EPSILON |
Definition at line 32 of file eg_lpnum.dbl.h.
| #define dbl_MaxLpNum DBL_MAX |
Definition at line 33 of file eg_lpnum.dbl.h.
| #define dbl_MinLpNum DBL_MIN |
Definition at line 34 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 149 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 EG_LPNUM_MEMSLAB 1 |
if non-zero, use slab-pool allocator for GMP, otherwise, use malloc/ realloc / free,
Definition at line 46 of file eg_lpnum.c.
| #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 209 of file eg_lpnum.h.
| #define EGLPNUM_MINEPS 0x1ep-20 |
This constant define 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 33 of file eg_lpnum.c.
| #define EGlpNumExit EGlpNumClear |
provided for backwards compatibility
Definition at line 276 of file eg_lpnum.h.
| #define FLOAT128_TYPE 13 |
SoftFloat 128-bit floating point numbner
Definition at line 177 of file eg_lpnum.h.
| #define FLT_TYPE 1 |
C float type.
Definition at line 151 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 156 of file eg_lpnum.h.
| #define fp20_EGlpNumAddInnProdTo | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) += ((EGfp20_t)((((long long)(b))*(c))/fp20_oneLpNum))) |
Add to a given number the product of two numbers.
| 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. |
Definition at line 367 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumAddTo | ( | a, | ||
| b | ||||
| ) | ((a) += (b)) |
Add to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to add to. | |
| b | EGlpNum_t value to be added to 'a'. |
Definition at line 398 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumAddUiTo | ( | a, | ||
| b | ||||
| ) | ((a) += (b)*fp20_oneLpNum) |
Add to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to add to. | |
| b | unsigned int value to be added to 'a'. |
Definition at line 388 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumAllocArray | ( | size | ) | __EGlpNumAllocArray(EGfp20_t,size) |
Allocate and initialize (if needed) 'size' elements of type int and return it, if no more memory, exit(1).
Definition at line 85 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumCeil | ( | a, | ||
| b | ||||
| ) |
({\
fp20_EGlpNumFloor(a,b);\
if((a) < (b)) (a) += fp20_oneLpNum;\
(a);})
Stores in the first number the ceil value of the second number, i.e. EGlpNumCeil(a,b) <==> a= ceil(b).
Definition at line 104 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumClearVar | ( | a | ) |
free the internal memory of a given variable
Definition at line 496 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumCopy | ( | dest, | ||
| orig | ||||
| ) | ((dest) = (orig)) |
copy the value of the second number to the first.
| orig | EGlpNum_t source number (it won't change value). | |
| dest | EGlpNum_t where to store the value stored in 'orig'. |
Definition at line 267 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumCopyAbs | ( | dest, | ||
| orig | ||||
| ) | ((dest) = EGabs(orig)) |
copy the value of the absolute value of the second parameter to the first parameter.
| orig | EGlpNum_t source number (it won't change value). | |
| dest | EGlpNum_t where to store the absolute value stored in 'orig'. |
Definition at line 304 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumCopyArray | ( | dest, | ||
| orig, | ||||
| size | ||||
| ) | memcpy(dest,orig,sizeof(EGfp20_t)*(size)) |
copy the first 'size' values in the second array to the first array.
| 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' |
Definition at line 343 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumCopyDiff | ( | dest, | ||
| a, | ||||
| b | ||||
| ) | ((dest) = (a) - (b)) |
copy the value of the second number to the first.
| 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'. |
Definition at line 249 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumCopyDiffRatio | ( | dest, | ||
| a, | ||||
| b, | ||||
| den | ||||
| ) | ((dest) = (EGfp20_t)((((long long)((a) - (b)))*fp20_oneLpNum) / (den))) |
copy the value of the second number to the first.
| 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 . |
Definition at line 239 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumCopyFrac | ( | dest, | ||
| op1, | ||||
| op2 | ||||
| ) | ((dest) = ((EGfp20_t)((((long long)(op1))*fp20_oneLpNum)/(op2)))) |
Set des = op1/op2.
| 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) |
Definition at line 326 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumCopyNeg | ( | dest, | ||
| orig | ||||
| ) | ((dest) = -(orig)) |
copy minus the value of the second parameter to the first parameter.
| orig | EGlpNum_t the source number (it won't change value). | |
| dest | EGlpNum_t where to store minus the value stored in 'orig'. |
Definition at line 316 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumCopySqrOver | ( | dest, | ||
| orig, | ||||
| den | ||||
| ) | ((dest) = ((EGfp20_t)((((long long)(orig))*(orig))/(den)))) |
copy the square of the second argument, divided by the third argument into the first argument.
| dest | EGlpNum_t where to store the result | |
| orig | EGlpNum_t second parameter | |
| den | EGlpNum_t third parameter |
Definition at line 291 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumCopySum | ( | dest, | ||
| a, | ||||
| b | ||||
| ) | ((dest) = (a) + (b)) |
copy the value of the sum of the second and third parameter
| 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. |
Definition at line 258 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumDivTo | ( | a, | ||
| b | ||||
| ) | ((a) = ((EGfp20_t)((((long long)(a))*fp20_oneLpNum)/(b)))) |
Divide a given number by the value of the second number.
| 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'. |
Definition at line 432 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumDivUiTo | ( | a, | ||
| b | ||||
| ) | ((a) /= (b)) |
Divide a given number by the value of the second number.
| 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'. |
Definition at line 444 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumFloor | ( | a, | ||
| b | ||||
| ) | ((a) = (((b)/fp20_oneLpNum)*fp20_oneLpNum)) |
Stores in the first number the floor value of the second number, i.e. EGlpNumFloor(a,b) <==> a= floor(b).
Definition at line 112 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumFreeArray | ( | ea | ) | __EGlpNumFreeArray(ea) |
given an array of type int, free it, if the pointer is NULL nothing happen.
Definition at line 63 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumGetStr | ( | a | ) |
({\
char *__str=0;\
size_t __i=snprintf(__str,(size_t)0,"%.7lf",((double)(a))/fp20_oneLpNum);\
__str = EGsMalloc(char,__i+1);\
snprintf(__str,__i+1,"%.7lf",((double)(a))/fp20_oneLpNum);\
__str;})
given a int, write it to a string (to be allocated internally), and return it.
Definition at line 53 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumInitVar | ( | a | ) | fp20_EGlpNumZero(a) |
initialize the internal memory of a given variable
Definition at line 492 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumInv | ( | a | ) |
({\
long long __fp20_tmp = (0x10000000000LL);\
(a) = (EGfp20_t)(__fp20_tmp / (a));})
store the (multiplicative) inverse of a number to itself, i.e. implement a = 1/a.
| a | the number to be inverted. |
Definition at line 118 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsDiffLess | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) - (b) < (c)) |
test if the diference of the first two numbers is less thatn the third number.
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number | |
| c | EGlpNum_t the third number |
Definition at line 196 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsEqqual | ( | a, | ||
| b | ||||
| ) | ((a) == (b)) |
Compare if two numbers are equal within a maximum error.
| a | EGlpNum_t first number to compare. | |
| b | EGlpNum_t second number to compare. |
Definition at line 130 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsEqual | ( | a, | ||
| b, | ||||
| error | ||||
| ) | (EGabs((a)-(b)) <= (error)) |
Compare if two numbers are equal within a maximum error.
| a | EGlpNum_t first number to compare. | |
| b | EGlpNum_t second number to compare. | |
| error | EGlpNum_t maximum difference allowed between both numbers. |
Definition at line 143 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsGreaDbl | ( | a, | ||
| b | ||||
| ) | ((a) > ((b)*fp20_oneLpNum)) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | int the second number |
Definition at line 218 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsGreatZero | ( | a | ) | (a > 0) |
test if the first number is greater than zero
| a | number to compare. |
Definition at line 154 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsLeq | ( | a, | ||
| b | ||||
| ) | ((a) <= (b)) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number |
Definition at line 229 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsLess | ( | a, | ||
| b | ||||
| ) | (a < b) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number |
Definition at line 172 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsLessDbl | ( | a, | ||
| b | ||||
| ) | ((a) < ((b)*fp20_oneLpNum)) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | int the second number |
Definition at line 207 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsLessZero | ( | a | ) | (a < 0) |
test if the first number is less than zero
| a | number to compare. |
Definition at line 161 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsNeq | ( | a, | ||
| b, | ||||
| error | ||||
| ) | (((a)-(b) > (error)) || ((b)-(a) > (error))) |
Definition at line 144 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsNeqq | ( | a, | ||
| b | ||||
| ) | ((a) != (b)) |
Definition at line 145 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsNeqqZero | ( | a | ) | ((a) != 0) |
Definition at line 147 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsNeqZero | ( | a, | ||
| error | ||||
| ) | (((a) > (error)) || (-(a) > (error))) |
Definition at line 146 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumIsSumLess | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) + (b) < (c)) |
test if the sum of the first two numbers is less thatn the third number.
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number | |
| c | EGlpNum_t the third number |
Definition at line 184 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumMultTo | ( | a, | ||
| b | ||||
| ) | ((a) = ((EGfp20_t)((((long long)(a))*(b))/fp20_oneLpNum))) |
Multiply a given number by the value of the second number.
| 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'. |
Definition at line 420 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumMultUiTo | ( | a, | ||
| b | ||||
| ) | ((a) *= (b)) |
Multiply a given number by the value of the second number.
| 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'. |
Definition at line 455 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumOne | ( | a | ) | ((a) = fp20_oneLpNum) |
Reset the value of the pointed number to one.
| a | EGlpNum_t value to be set to one. |
Definition at line 471 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumReadStr | ( | a, | ||
| str | ||||
| ) |
({\
double __FP20_DBL;\
int __i =0;\
sscanf(str,"%lf%n",&__FP20_DBL,&__i);\
a = ((EGfp20_t)(__FP20_DBL * fp20_oneLpNum));\
__i;})
Read from a string a number and store it in the given int,.
Definition at line 43 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumReallocArray | ( | lptr, | ||
| lsize | ||||
| ) |
({\
size_t __csz = (lsize), *__usp = 0;\
size_t __psz = __EGlpNumArraySize(*lptr);\
EGfp20_t** __ptr__ = (lptr);\
if (!__psz) *__ptr__ = fp20_EGlpNumAllocArray (__csz); \
else if (__psz < __csz) {\
__usp = (size_t*)(*__ptr__);\
__usp--;\
__usp = EGrealloc(__usp, sizeof(EGfp20_t)*__csz+sizeof(size_t));\
__usp[0] = __csz;\
*__ptr__ = (EGfp20_t*)(__usp+1);\
}\
*__ptr__;})
Reallocate and initialize (if needed) 'size' elements of type EGlpNum_t and return it, if no more memory, exit(1).
Definition at line 68 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumSet | ( | var, | ||
| dbl_var | ||||
| ) | ((var) = (EGfp20_t)((dbl_var)*fp20_oneLpNum)) |
set the given number pointer, set its value to the given int.
| var | int where we will store the int value. | |
| dbl_var | int value to be stored in 'var'. |
Definition at line 98 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumSetToMaxAbs | ( | dest, | ||
| orig | ||||
| ) |
change the fist number to the maximum between itself and the absolute value of the second.
| orig | EGlpNum_t source number (it won't change value). | |
| dest | EGlpNum_t where to store the value stored in 'orig'. |
Definition at line 277 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumSetToMinAbs | ( | dest, | ||
| orig | ||||
| ) |
Definition at line 279 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumSign | ( | a | ) | ((a) = -(a)) |
Change the sign of the number.
| a | EGlpNum_t number we will change sign. |
Definition at line 479 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumSubInnProdTo | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) -= ((EGfp20_t)((((long long)(b))*(c))/fp20_oneLpNum))) |
Sub to a given number the product of two numbers.
| 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. |
Definition at line 355 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumSubTo | ( | a, | ||
| b | ||||
| ) | ((a) -= (b)) |
Substract to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to substract from. | |
| b | EGlpNum_t value to be substracted to 'a'. |
Definition at line 409 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumSubUiTo | ( | a, | ||
| b | ||||
| ) | ((a) -= (b)*fp20_oneLpNum) |
Substract to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to substract to. | |
| b | unsigned int value to be substracted to 'a'. |
Definition at line 378 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumToLf | ( | a | ) | (((double)(a))/fp20_oneLpNum) |
return the closest int value of the given pointer number.
| a | EGlpNum_t number that we will be transformed to int. |
Definition at line 488 of file eg_lpnum.fp20.h.
| #define fp20_EGlpNumZero | ( | a | ) | ((a) = 0) |
Reset the value of the pointed number to zero.
| a | EGlpNum_t the value to be set to zero. |
Definition at line 463 of file eg_lpnum.fp20.h.
| #define fp20_epsLpNum ((int long)1) |
Definition at line 36 of file eg_lpnum.fp20.h.
| #define fp20_MaxLpNum ((int long)0x7fffffff) |
Definition at line 37 of file eg_lpnum.fp20.h.
| #define fp20_MinLpNum ((int long)0xffffffff) |
Definition at line 38 of file eg_lpnum.fp20.h.
| #define fp20_oneLpNum ((int long)0x100000) |
2^20
Definition at line 35 of file eg_lpnum.fp20.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 159 of file eg_lpnum.h.
| #define fp20_zeroLpNum ((int long)0) |
extern definitions of constants for different set-ups
Definition at line 34 of file eg_lpnum.fp20.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 165 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 162 of file eg_lpnum.h.
| #define GNU_MP_F 10 |
GNU_MP library mpf_t type
Definition at line 171 of file eg_lpnum.h.
| #define GNU_MP_Q 9 |
GNU_MP library mpq_t type
Definition at line 169 of file eg_lpnum.h.
| #define GNU_MP_Z 8 |
GNU_MP library mpz_t type
Definition at line 167 of file eg_lpnum.h.
| #define int32_EGlpNumAddInnProdTo | ( | __EGPa__, | ||
| __EGPb__, | ||||
| __EGPc__ | ||||
| ) | ((__EGPa__)+=(__EGPb__)*(__EGPc__)) |
Add to (__EGPa__) given number the product of two numbers.
| (__EGPa__) | EGlpNum_t the number that we are going to add to. | |
| (__EGPb__) | EGlpNum_t value to be multiplyed. | |
| (__EGPc__) | EGlpNum_t value to be multiplyed. |
Definition at line 354 of file eg_lpnum.int32.h.
| #define int32_EGlpNumAddTo | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | ((__EGPa__)+=(__EGPb__)) |
Add to (__EGPa__) given number the value of the second number.
| (__EGPa__) | EGlpNum_t the number that we are going to add to. | |
| (__EGPb__) | EGlpNum_t value to be added to '(__EGPa__)'. |
Definition at line 384 of file eg_lpnum.int32.h.
| #define int32_EGlpNumAddUiTo | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | ((__EGPa__)+=((int32_t)(__EGPb__))) |
Add to (__EGPa__) given number the value of the second number.
| (__EGPa__) | EGlpNum_t the number that we are going to add to. | |
| (__EGPb__) | unsigned int value to be added to '(__EGPa__)'. |
Definition at line 374 of file eg_lpnum.int32.h.
| #define int32_EGlpNumAllocArray | ( | __EGsz__ | ) | __EGlpNumAllocArray(int32_t,__EGsz__) |
Allocate and initialize (if needed) '__EGsz__' elements of type int32_t and return it,if no more memory,exit(1).
Definition at line 80 of file eg_lpnum.int32.h.
| #define int32_EGlpNumCeil | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | (__EGPa__=__EGPb__) |
Stores in the first number the ceil value of the second number,i.e. EGlpNumCeil(__EGPa__,__EGPb__) <==> (__EGPa__)=ceil(__EGPb__).
Definition at line 99 of file eg_lpnum.int32.h.
| #define int32_EGlpNumClearVar | ( | __EGPa__ | ) |
free the internal memory of (__EGPa__) given variable
Definition at line 480 of file eg_lpnum.int32.h.
| #define int32_EGlpNumCopy | ( | __EGPd__, | ||
| __EGPo__ | ||||
| ) | ((__EGPd__)=(__EGPo__)) |
copy the value of the second number to the first.
| (__EGPo__) | EGlpNum_t source number (it won't change value). | |
| (__EGPd__) | EGlpNum_t where to store the value stored in '(__EGPo__)'. |
Definition at line 256 of file eg_lpnum.int32.h.
| #define int32_EGlpNumCopyAbs | ( | __EGPd__, | ||
| __EGPo__ | ||||
| ) | ((__EGPd__)=((__EGPo__)<0?-(__EGPo__):(__EGPo__))) |
copy the value of the absolute value of the second parameter to the first parameter.
| (__EGPo__) | EGlpNum_t source number (it won't change value). | |
| (__EGPd__) | EGlpNum_t where to store the absolute value stored in '(__EGPo__)'. |
Definition at line 294 of file eg_lpnum.int32.h.
| #define int32_EGlpNumCopyArray | ( | __EGPd__, | ||
| __EGPo__, | ||||
| __EGsz__ | ||||
| ) | memcpy(__EGPd__,__EGPo__,sizeof(int32_t)*(__EGsz__)) |
copy the first '(__EGsz__)' values in the second array to the first array.
| (__EGPo__) | EGlpNum_t* pointer to the array from where we will copy the values (it won't change value). | |
| (__EGPd__) | EGlpNum_t* pointer to where to store the first '(__EGsz__)' values stored in '(__EGPo__)'. | |
| (__EGsz__) | unsigned int specifying how many values of '(__EGPo__)' will be copied onto '(__EGPd__)' |
Definition at line 332 of file eg_lpnum.int32.h.
| #define int32_EGlpNumCopyDiff | ( | __EGPd__, | ||
| __EGPa__, | ||||
| __EGPb__ | ||||
| ) | ((__EGPd__)=((__EGPa__)-(__EGPb__))) |
copy the value of the second number to the first.
| (__EGPa__) | EGlpNum_t source number (it won't change value). | |
| (__EGPb__) | EGlpNum_t source number (it won't change value). | |
| (__EGPd__) | EGlpNum_t where to store the value stored in '(__EGPo__)'. |
Definition at line 238 of file eg_lpnum.int32.h.
| #define int32_EGlpNumCopyDiffRatio | ( | __EGPd__, | ||
| __EGPa__, | ||||
| __EGPb__, | ||||
| __EGPdn__ | ||||
| ) | ((__EGPd__)=((__EGPa__)-(__EGPb__))/(__EGPdn__)) |
copy the value of the second number to the first.
| (__EGPa__) | EGlpNum_t source number (it won't change value). | |
| (__EGPb__) | EGlpNum_t source number (it won't change value). | |
| (__EGPdn__) | EGlpNum_t denominator of the difference (it won't change value). | |
| (__EGPd__) | EGlpNum_t where to store the value . |
Definition at line 229 of file eg_lpnum.int32.h.
| #define int32_EGlpNumCopyFrac | ( | __EGPd__, | ||
| __EGPone__, | ||||
| __EGPtwo__ | ||||
| ) | ((__EGPd__)=(__EGPone__)/(__EGPtwo__)) |
Set des=(__EGPone__)/(__EGPtwo__).
| (__EGPd__) | EGlpNum_t where we will store the result. | |
| (__EGPone__) | EGlpNum_t numerator of the fraction (possibly non an integer) | |
| (__EGPtwo__) | EGlpNum_t denominator of the fraction (possibly non an integer) |
Definition at line 316 of file eg_lpnum.int32.h.
| #define int32_EGlpNumCopyNeg | ( | __EGPd__, | ||
| __EGPo__ | ||||
| ) | ((__EGPd__)=-(__EGPo__)) |
copy minus the value of the second parameter to the first parameter.
| (__EGPo__) | EGlpNum_t the source number (it won't change value). | |
| (__EGPd__) | EGlpNum_t where to store minus the value stored in '(__EGPo__)'. |
Definition at line 306 of file eg_lpnum.int32.h.
| #define int32_EGlpNumCopySqrOver | ( | __EGPd__, | ||
| __EGPo__, | ||||
| __EGPdn__ | ||||
| ) | ((__EGPd__)=(__EGPo__)*(__EGPo__)/(__EGPdn__)) |
copy the square of the second argument,divided by the third argument into the first argument.
| (__EGPd__) | EGlpNum_t where to store the result | |
| (__EGPo__) | EGlpNum_t second parameter | |
| (__EGPdn__) | EGlpNum_t third parameter |
Definition at line 282 of file eg_lpnum.int32.h.
| #define int32_EGlpNumCopySum | ( | __EGPd__, | ||
| __EGPa__, | ||||
| __EGPb__ | ||||
| ) | ((__EGPd__)=((__EGPa__)+(__EGPb__))) |
copy the value of the sum of the second and third parameter
| (__EGPa__) | EGlpNum_t source number (it won't change value). | |
| (__EGPb__) | EGlpNum_t source number (it won't change value). | |
| (__EGPd__) | EGlpNum_t where to store the sum. |
Definition at line 247 of file eg_lpnum.int32.h.
| #define int32_EGlpNumDivTo | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | ((__EGPa__)/=(__EGPb__)) |
Divide (__EGPa__) given number by the value of the second number.
| (__EGPa__) | EGlpNum_t the number that we are going to divide by the second number and store the result. | |
| (__EGPb__) | EGlpNum_t value to be divide to '(__EGPa__)'. |
Definition at line 417 of file eg_lpnum.int32.h.
| #define int32_EGlpNumDivUiTo | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | ((__EGPa__)/=((int32_t)(__EGPb__))) |
Divide (__EGPa__) given number by the value of the second number.
| (__EGPa__) | EGlpNum_t the number that we are going to divide by the second number and store the result. | |
| (__EGPb__) | unsigned int value to be divided to '(__EGPa__)'. |
Definition at line 428 of file eg_lpnum.int32.h.
| #define int32_EGlpNumFloor | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | (__EGPa__=__EGPb__) |
Stores in the first number the floor value of the second number,i.e. EGlpNumFloor(__EGPa__,__EGPb__) <==> (__EGPa__)=floor(__EGPb__).
Definition at line 104 of file eg_lpnum.int32.h.
| #define int32_EGlpNumFreeArray | ( | __EGea__ | ) | __EGlpNumFreeArray(__EGea__) |
given an array of type number,free it,if the pointer is NULL nothing happen.
Definition at line 57 of file eg_lpnum.int32.h.
| #define int32_EGlpNumGetStr | ( | __EGPa__ | ) |
({\
char *__str=0;\
size_t __i=snprintf(__str,(size_t)0,"%d",__EGPa__);\
__str=EGsMalloc(char,__i+1);\
snprintf(__str,__i+1,"%d",__EGPa__);\
__str;})
given a number,write it to a string (to be allocated internally), and return it.
Definition at line 47 of file eg_lpnum.int32.h.
| #define int32_EGlpNumInitVar | ( | __EGPa__ | ) | int32_EGlpNumZero(__EGPa__) |
initialize the internal memory of (__EGPa__) given variable
Definition at line 476 of file eg_lpnum.int32.h.
| #define int32_EGlpNumInv | ( | __EGPa__ | ) | ((__EGPa__)=0) |
store the (multiplicative) inverse of (__EGPa__) number to itself,i.e. implement (__EGPa__)=1/(__EGPa__).
| (__EGPa__) | the number to be inverted. |
Definition at line 110 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsDiffLess | ( | __EGPa__, | ||
| __EGPb__, | ||||
| __EGPc__ | ||||
| ) | ((__EGPa__)-(__EGPb__)<(__EGPc__)) |
test if the diference of the first two numbers is less thatn the third number.
| (__EGPa__) | EGlpNum_t the first number. | |
| (__EGPb__) | EGlpNum_t the second number | |
| (__EGPc__) | EGlpNum_t the third number |
Definition at line 186 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsEqqual | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | ((__EGPa__)==(__EGPb__)) |
Compare if two numbers are equal within (__EGPa__) maximum (__EGPerr__).
| (__EGPa__) | EGlpNum_t first number to compare. | |
| (__EGPb__) | EGlpNum_t second number to compare. |
Definition at line 120 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsEqual | ( | __EGPa__, | ||
| __EGPb__, | ||||
| __EGPerr__ | ||||
| ) | (EGabs((__EGPa__)-(__EGPb__))<=(__EGPerr__)) |
Compare if two numbers are equal within (__EGPa__) maximum (__EGPerr__).
| (__EGPa__) | EGlpNum_t first number to compare. | |
| (__EGPb__) | EGlpNum_t second number to compare. | |
| (__EGPerr__) | EGlpNum_t maximum difference allowed between both numbers. |
Definition at line 133 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsGreaDbl | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | (((double)(__EGPa__)) > (__EGPb__)) |
test if the first number is bigger to the second number
| (__EGPa__) | EGlpNum_t the first number. | |
| (__EGPb__) | double the second number |
Definition at line 208 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsGreatZero | ( | __EGPa__ | ) | ((__EGPa__)>0) |
test if the first number is greater than zero
| (__EGPa__) | EGlpNum_t number to test. |
Definition at line 144 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsLeq | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | ((__EGPa__)<=(__EGPb__)) |
test if the first number is bigger to the second number
| (__EGPa__) | EGlpNum_t the first number. | |
| (__EGPb__) | EGlpNum_t the second number |
Definition at line 219 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsLess | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | ((__EGPa__)<(__EGPb__)) |
test if the first number is bigger to the second number
| (__EGPa__) | EGlpNum_t the first number. | |
| (__EGPb__) | EGlpNum_t the second number |
Definition at line 162 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsLessDbl | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | (((double)(__EGPa__)) < (__EGPb__)) |
test if the first number is bigger to the second number
| (__EGPa__) | EGlpNum_t the first number. | |
| (__EGPb__) | double the second number |
Definition at line 197 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsLessZero | ( | __EGPa__ | ) | ((__EGPa__)<0) |
test if the first number is less than zero
| (__EGPa__) | EGlpNum_t number to test. |
Definition at line 151 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsNeq | ( | __EGPa__, | ||
| __EGPb__, | ||||
| __EGPerr__ | ||||
| ) | (EGabs((__EGPa__)-(__EGPb__))>(__EGPerr__)) |
Definition at line 134 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsNeqq | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | ((__EGPa__)!=(__EGPb__)) |
Definition at line 135 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsNeqqZero | ( | __EGPa__ | ) | (__EGPa__) |
Definition at line 137 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsNeqZero | ( | __EGPa__, | ||
| __EGPerr__ | ||||
| ) | (((__EGPa__)>(__EGPerr__))||(-(__EGPa__) > (__EGPerr__))) |
Definition at line 136 of file eg_lpnum.int32.h.
| #define int32_EGlpNumIsSumLess | ( | __EGPa__, | ||
| __EGPb__, | ||||
| __EGPc__ | ||||
| ) | ((__EGPa__)+(__EGPb__)<(__EGPc__)) |
test if the sum of the first two numbers is less thatn the third number.
| (__EGPa__) | EGlpNum_t the first number. | |
| (__EGPb__) | EGlpNum_t the second number | |
| (__EGPc__) | EGlpNum_t the third number |
Definition at line 174 of file eg_lpnum.int32.h.
| #define int32_EGlpNumMultTo | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | ((__EGPa__)*=(__EGPb__)) |
Multiply (__EGPa__) given number by the value of the second number.
| (__EGPa__) | EGlpNum_t the number that we are going to multiply by the second number and store the result. | |
| (__EGPb__) | EGlpNum_t value to be multyply to '(__EGPa__)'. |
Definition at line 406 of file eg_lpnum.int32.h.
| #define int32_EGlpNumMultUiTo | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | ((__EGPa__)*=((int32_t)(__EGPb__))) |
Multiply (__EGPa__) given number by the value of the second number.
| (__EGPa__) | EGlpNum_t the number that we are going to multiply by the second number and store the result. | |
| (__EGPb__) | unsigned int value to be multyply to '(__EGPa__)'. |
Definition at line 439 of file eg_lpnum.int32.h.
| #define int32_EGlpNumOne | ( | __EGPa__ | ) | ((__EGPa__)=1) |
Reset the value of the pointed number to one.
| (__EGPa__) | EGlpNum_t value to be set to one. |
Definition at line 455 of file eg_lpnum.int32.h.
| #define int32_EGlpNumReadStr | ( | __EGPa__, | ||
| __EGstr__ | ||||
| ) |
({\
int __i=0;\
sscanf(__EGstr__,"%d%n",&(__EGPa__),&__i);\
__i;})
Read from a string a number and store it in the given number,.
Definition at line 39 of file eg_lpnum.int32.h.
| #define int32_EGlpNumReallocArray | ( | __EGpone__, | ||
| __EGlsz__ | ||||
| ) |
({\
size_t __csz=(__EGlsz__),*__usp=0;\
size_t __psz=__EGlpNumArraySize(*(__EGpone__));\
int32_t** __ptr__=(__EGpone__);\
if (!__psz) *__ptr__=int32_EGlpNumAllocArray (__csz); \
else if (__psz < __csz) {\
__usp=(size_t*)(*__ptr__);\
__usp--;\
__usp=EGrealloc(__usp,sizeof(int32_t)*__csz+sizeof(size_t));\
__usp[0]=__csz;\
*__ptr__=(int32_t*)(__usp+1);\
memset((*__ptr__)+__psz,0,sizeof(int32_t)*(__csz-__psz));\
}\
*__ptr__;})
Reallocate and initialize (if needed) '__EGlsz__' elements of type int32_t and return it,if no more memory,exit(1).
Definition at line 62 of file eg_lpnum.int32.h.
| #define int32_EGlpNumSet | ( | __EGvone__, | ||
| __EGdbl__ | ||||
| ) | ((__EGvone__)=(int32_t)(__EGdbl__)) |
set the given number pointer,set its value to the given double.
| (__EGvone__) | double where we will store the double value. | |
| __EGdbl__ | double value to be stored in '(__EGvone__)'. |
with
, then
. Definition at line 94 of file eg_lpnum.int32.h.
| #define int32_EGlpNumSetToMaxAbs | ( | __EGPd__, | ||
| __EGPo__ | ||||
| ) |
({\
const int32_t __EGcv__=(__EGPo__)<0?(__EGPo__):-(__EGPo__);\
__EGPd__=(__EGcv__)>(__EGPd__)?(__EGcv__):(__EGPd__);})
change the fist number to the maximum between itself and the absolute value of the second.
| (__EGPo__) | EGlpNum_t source number (it won't change value). | |
| (__EGPd__) | EGlpNum_t where to store the value stored in '(__EGPo__)'. |
Definition at line 266 of file eg_lpnum.int32.h.
| #define int32_EGlpNumSetToMinAbs | ( | __EGPd__, | ||
| __EGPo__ | ||||
| ) |
({\
const int32_t __EGcv__=(__EGPo__)<0?(__EGPo__):-(__EGPo__);\
__EGPd__=(__EGcv__)<(__EGPd__)?(__EGcv__):(__EGPd__);})
Definition at line 269 of file eg_lpnum.int32.h.
| #define int32_EGlpNumSign | ( | __EGPa__ | ) | ((__EGPa__)=-(__EGPa__)) |
Change the sign of the number.
| (__EGPa__) | EGlpNum_t number we will change sign. |
Definition at line 463 of file eg_lpnum.int32.h.
| #define int32_EGlpNumSubInnProdTo | ( | __EGPa__, | ||
| __EGPb__, | ||||
| __EGPc__ | ||||
| ) | ((__EGPa__)-=(__EGPb__)*(__EGPc__)) |
Sub to (__EGPa__) given number the product of two numbers.
| (__EGPa__) | EGlpNum_t the number that we are going to Sub to. | |
| (__EGPb__) | EGlpNum_t value to be multiplyed. | |
| (__EGPc__) | EGlpNum_t value to be multiplyed. |
Definition at line 343 of file eg_lpnum.int32.h.
| #define int32_EGlpNumSubTo | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | ((__EGPa__)-=(__EGPb__)) |
Substract to (__EGPa__) given number the value of the second number.
| (__EGPa__) | EGlpNum_t the number that we are going to substract from. | |
| (__EGPb__) | EGlpNum_t value to be substracted to '(__EGPa__)'. |
Definition at line 395 of file eg_lpnum.int32.h.
| #define int32_EGlpNumSubUiTo | ( | __EGPa__, | ||
| __EGPb__ | ||||
| ) | ((__EGPa__)-=((int32_t)(__EGPb__))) |
Substract to (__EGPa__) given number the value of the second number.
| (__EGPa__) | EGlpNum_t the number that we are going to substract to. | |
| (__EGPb__) | unsigned int value to be substracted to '(__EGPa__)'. |
Definition at line 364 of file eg_lpnum.int32.h.
| #define int32_EGlpNumToLf | ( | __EGPa__ | ) | ((double)(__EGPa__)) |
return the closest double value of the given pointer number.
| (__EGPa__) | EGlpNum_t number that we will be transformed to double. |
Definition at line 472 of file eg_lpnum.int32.h.
| #define int32_EGlpNumZero | ( | __EGPa__ | ) | ((__EGPa__)=0) |
Reset the value of the pointed number to zero.
| (__EGPa__) | EGlpNum_t the value to be set to zero. |
Definition at line 447 of file eg_lpnum.int32.h.
| #define int32_epsLpNum 0 |
Definition at line 32 of file eg_lpnum.int32.h.
| #define int32_MaxLpNum INT32_MAX |
Definition at line 33 of file eg_lpnum.int32.h.
| #define int32_MinLpNum INT32_MIN |
Definition at line 34 of file eg_lpnum.int32.h.
| #define int32_oneLpNum 1 |
Definition at line 31 of file eg_lpnum.int32.h.
| #define INT32_TYPE 14 |
int32_t integers
Definition at line 179 of file eg_lpnum.h.
| #define int32_zeroLpNum 0 |
extern definitions of constaants for different set-ups
Definition at line 30 of file eg_lpnum.int32.h.
| #define int_EGlpNumAddInnProdTo | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) += (b)*(c)) |
Add to a given number the product of two numbers.
| 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. |
Definition at line 351 of file eg_lpnum.int.h.
| #define int_EGlpNumAddTo | ( | a, | ||
| b | ||||
| ) | ((a) += (b)) |
Add to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to add to. | |
| b | EGlpNum_t value to be added to 'a'. |
Definition at line 381 of file eg_lpnum.int.h.
| #define int_EGlpNumAddUiTo | ( | a, | ||
| b | ||||
| ) | ((a) += (b)) |
Add to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to add to. | |
| b | unsigned int value to be added to 'a'. |
Definition at line 371 of file eg_lpnum.int.h.
| #define int_EGlpNumAllocArray | ( | size | ) | __EGlpNumAllocArray(int,size) |
Allocate and initialize (if needed) 'size' elements of type int and return it, if no more memory, exit(1).
Definition at line 79 of file eg_lpnum.int.h.
| #define int_EGlpNumCeil | ( | a, | ||
| b | ||||
| ) | int_EGlpNumSet(a,b) |
Stores in the first number the ceil value of the second number, i.e. EGlpNumCeil(a,b) <==> a= ceil(b).
Definition at line 98 of file eg_lpnum.int.h.
| #define int_EGlpNumClearVar | ( | a | ) |
free the internal memory of a given variable
Definition at line 477 of file eg_lpnum.int.h.
| #define int_EGlpNumCopy | ( | dest, | ||
| orig | ||||
| ) | ((dest) = (orig)) |
copy the value of the second number to the first.
| orig | EGlpNum_t source number (it won't change value). | |
| dest | EGlpNum_t where to store the value stored in 'orig'. |
Definition at line 255 of file eg_lpnum.int.h.
| #define int_EGlpNumCopyAbs | ( | dest, | ||
| orig | ||||
| ) | ((dest) = EGabs(orig)) |
copy the value of the absolute value of the second parameter to the first parameter.
| orig | EGlpNum_t source number (it won't change value). | |
| dest | EGlpNum_t where to store the absolute value stored in 'orig'. |
Definition at line 291 of file eg_lpnum.int.h.
| #define int_EGlpNumCopyArray | ( | dest, | ||
| orig, | ||||
| size | ||||
| ) | memcpy(dest,orig,sizeof(int)*(size)) |
copy the first 'size' values in the second array to the first array.
| 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' |
Definition at line 329 of file eg_lpnum.int.h.
| #define int_EGlpNumCopyDiff | ( | dest, | ||
| a, | ||||
| b | ||||
| ) | ((dest) = (a) - (b)) |
copy the value of the second number to the first.
| 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'. |
Definition at line 237 of file eg_lpnum.int.h.
| #define int_EGlpNumCopyDiffRatio | ( | dest, | ||
| a, | ||||
| b, | ||||
| den | ||||
| ) | ((dest) = ((a) - (b)) / (den)) |
copy the value of the second number to the first.
| 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 . |
Definition at line 228 of file eg_lpnum.int.h.
| #define int_EGlpNumCopyFrac | ( | dest, | ||
| op1, | ||||
| op2 | ||||
| ) | ((dest) = (op1)/(op2)) |
Set des = op1/op2.
| 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) |
Definition at line 313 of file eg_lpnum.int.h.
| #define int_EGlpNumCopyNeg | ( | dest, | ||
| orig | ||||
| ) | ((dest) = -(orig)) |
copy minus the value of the second parameter to the first parameter.
| orig | EGlpNum_t the source number (it won't change value). | |
| dest | EGlpNum_t where to store minus the value stored in 'orig'. |
Definition at line 303 of file eg_lpnum.int.h.
| #define int_EGlpNumCopySqrOver | ( | dest, | ||
| orig, | ||||
| den | ||||
| ) | ((dest) = (orig)*(orig)/(den)) |
copy the square of the second argument, divided by the third argument into the first argument.
| dest | EGlpNum_t where to store the result | |
| orig | EGlpNum_t second parameter | |
| den | EGlpNum_t third parameter |
Definition at line 279 of file eg_lpnum.int.h.
| #define int_EGlpNumCopySum | ( | dest, | ||
| a, | ||||
| b | ||||
| ) | ((dest) = (a) + (b)) |
copy the value of the sum of the second and third parameter
| 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. |
Definition at line 246 of file eg_lpnum.int.h.
| #define int_EGlpNumDivTo | ( | a, | ||
| b | ||||
| ) | ((a) /= (b)) |
Divide a given number by the value of the second number.
| 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'. |
Definition at line 414 of file eg_lpnum.int.h.
| #define int_EGlpNumDivUiTo | ( | a, | ||
| b | ||||
| ) | ((a) /= (b)) |
Divide a given number by the value of the second number.
| 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'. |
Definition at line 425 of file eg_lpnum.int.h.
| #define int_EGlpNumFloor | ( | a, | ||
| b | ||||
| ) | int_EGlpNumSet(a,b) |
Stores in the first number the floor value of the second number, i.e. EGlpNumFloor(a,b) <==> a= floor(b).
Definition at line 103 of file eg_lpnum.int.h.
| #define int_EGlpNumFreeArray | ( | ea | ) | __EGlpNumFreeArray(ea) |
given an array of type int, free it, if the pointer is NULL nothing happen.
Definition at line 57 of file eg_lpnum.int.h.
| #define int_EGlpNumGetStr | ( | a | ) |
({\
char *__str=0;\
size_t __i=snprintf(__str,(size_t)0,"%d",a);\
__str = EGsMalloc(char,__i+1);\
snprintf(__str,__i+1,"%d",a);\
__str;})
given a int, write it to a string (to be allocated internally), and return it.
Definition at line 47 of file eg_lpnum.int.h.
| #define int_EGlpNumInitVar | ( | a | ) | int_EGlpNumZero(a) |
initialize the internal memory of a given variable
Definition at line 473 of file eg_lpnum.int.h.
| #define int_EGlpNumInv | ( | a | ) | ((a) = 1/(a)) |
store the (multiplicative) inverse of a number to itself, i.e. implement a = 1/a.
| a | the number to be inverted. |
Definition at line 109 of file eg_lpnum.int.h.
| #define int_EGlpNumIsDiffLess | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) - (b) < (c)) |
test if the diference of the first two numbers is less thatn the third number.
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number | |
| c | EGlpNum_t the third number |
Definition at line 185 of file eg_lpnum.int.h.
| #define int_EGlpNumIsEqqual | ( | a, | ||
| b | ||||
| ) | ((a) == (b)) |
Compare if two numbers are equal within a maximum error.
| a | EGlpNum_t first number to compare. | |
| b | EGlpNum_t second number to compare. |
Definition at line 119 of file eg_lpnum.int.h.
| #define int_EGlpNumIsEqual | ( | a, | ||
| b, | ||||
| error | ||||
| ) | (EGabs((a)-(b)) <= (error)) |
Compare if two numbers are equal within a maximum error.
| a | EGlpNum_t first number to compare. | |
| b | EGlpNum_t second number to compare. | |
| error | EGlpNum_t maximum difference allowed between both numbers. |
Definition at line 132 of file eg_lpnum.int.h.
| #define int_EGlpNumIsGreaDbl | ( | a, | ||
| b | ||||
| ) | ((a) > (b)) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | int the second number |
Definition at line 207 of file eg_lpnum.int.h.
| #define int_EGlpNumIsGreatZero | ( | a | ) | (a > 0) |
test if a numer is greater than zero
| a | number to test |
Definition at line 154 of file eg_lpnum.int.h.
| #define int_EGlpNumIsLeq | ( | a, | ||
| b | ||||
| ) | ((a) <= (b)) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number |
Definition at line 218 of file eg_lpnum.int.h.
| #define int_EGlpNumIsLess | ( | a, | ||
| b | ||||
| ) | (a < b) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number |
Definition at line 147 of file eg_lpnum.int.h.
| #define int_EGlpNumIsLessDbl | ( | a, | ||
| b | ||||
| ) | ((a) < (b)) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | int the second number |
Definition at line 196 of file eg_lpnum.int.h.
| #define int_EGlpNumIsLessZero | ( | a | ) | (a < 0) |
test if a numer is less than zero
| a | number to test |
Definition at line 161 of file eg_lpnum.int.h.
| #define int_EGlpNumIsNeq | ( | a, | ||
| b, | ||||
| error | ||||
| ) | (((a)-(b) > (error)) || ((b)-(a) > (error))) |
Definition at line 133 of file eg_lpnum.int.h.
| #define int_EGlpNumIsNeqq | ( | a, | ||
| b | ||||
| ) | ((a) != (b)) |
Definition at line 134 of file eg_lpnum.int.h.
| #define int_EGlpNumIsNeqqZero | ( | a | ) | ((a) != 0) |
Definition at line 136 of file eg_lpnum.int.h.
| #define int_EGlpNumIsNeqZero | ( | a, | ||
| error | ||||
| ) | (((a) > (error)) || (-(a) > (error))) |
Definition at line 135 of file eg_lpnum.int.h.
| #define int_EGlpNumIsSumLess | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) + (b) < (c)) |
test if the sum of the first two numbers is less thatn the third number.
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number | |
| c | EGlpNum_t the third number |
Definition at line 173 of file eg_lpnum.int.h.
| #define int_EGlpNumMultTo | ( | a, | ||
| b | ||||
| ) | ((a) *= (b)) |
Multiply a given number by the value of the second number.
| 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'. |
Definition at line 403 of file eg_lpnum.int.h.
| #define int_EGlpNumMultUiTo | ( | a, | ||
| b | ||||
| ) | ((a) *= (b)) |
Multiply a given number by the value of the second number.
| 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'. |
Definition at line 436 of file eg_lpnum.int.h.
| #define int_EGlpNumOne | ( | a | ) | ((a) = 1) |
Reset the value of the pointed number to one.
| a | EGlpNum_t value to be set to one. |
Definition at line 452 of file eg_lpnum.int.h.
| #define int_EGlpNumReadStr | ( | a, | ||
| str | ||||
| ) |
({\
int __i =0;\
sscanf(str,"%d%n",&(a),&__i);\
__i;})
Read from a string a number and store it in the given int,.
Definition at line 39 of file eg_lpnum.int.h.
| #define int_EGlpNumReallocArray | ( | lptr, | ||
| lsize | ||||
| ) |
({\
size_t __csz = (lsize), *__usp = 0;\
size_t __psz = __EGlpNumArraySize(*lptr);\
int** __ptr__ = (lptr);\
if (!__psz) *__ptr__ = int_EGlpNumAllocArray (__csz); \
else if (__psz < __csz) {\
__usp = (size_t*)(*__ptr__);\
__usp--;\
__usp = EGrealloc(__usp, sizeof(int)*__csz+sizeof(size_t));\
__usp[0] = __csz;\
*__ptr__ = (int*)(__usp+1);\
}\
*__ptr__;})
Reallocate and initialize (if needed) 'size' elements of type EGlpNum_t and return it, if no more memory, exit(1).
Definition at line 62 of file eg_lpnum.int.h.
| #define int_EGlpNumSet | ( | var, | ||
| dbl_var | ||||
| ) | ((var) = (dbl_var)) |
set the given number pointer, set its value to the given int.
| var | int where we will store the int value. | |
| dbl_var | int value to be stored in 'var'. |
with
, then
. Definition at line 93 of file eg_lpnum.int.h.
| #define int_EGlpNumSetToMaxAbs | ( | dest, | ||
| orig | ||||
| ) |
change the fist number to the maximum between itself and the absolute value of the second.
| orig | EGlpNum_t source number (it won't change value). | |
| dest | EGlpNum_t where to store the value stored in 'orig'. |
Definition at line 265 of file eg_lpnum.int.h.
| #define int_EGlpNumSetToMinAbs | ( | dest, | ||
| orig | ||||
| ) |
Definition at line 267 of file eg_lpnum.int.h.
| #define int_EGlpNumSign | ( | a | ) | ((a) = -(a)) |
Change the sign of the number.
| a | EGlpNum_t number we will change sign. |
Definition at line 460 of file eg_lpnum.int.h.
| #define int_EGlpNumSubInnProdTo | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) -= (b)*(c)) |
Sub to a given number the product of two numbers.
| 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. |
Definition at line 340 of file eg_lpnum.int.h.
| #define int_EGlpNumSubTo | ( | a, | ||
| b | ||||
| ) | ((a) -= (b)) |
Substract to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to substract from. | |
| b | EGlpNum_t value to be substracted to 'a'. |
Definition at line 392 of file eg_lpnum.int.h.
| #define int_EGlpNumSubUiTo | ( | a, | ||
| b | ||||
| ) | ((a) -= (b)) |
Substract to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to substract to. | |
| b | unsigned int value to be substracted to 'a'. |
Definition at line 361 of file eg_lpnum.int.h.
| #define int_EGlpNumToLf | ( | a | ) | ((double)a) |
return the closest int value of the given pointer number.
| a | EGlpNum_t number that we will be transformed to int. |
Definition at line 469 of file eg_lpnum.int.h.
| #define int_EGlpNumZero | ( | a | ) | ((a) = 0) |
Reset the value of the pointed number to zero.
| a | EGlpNum_t the value to be set to zero. |
Definition at line 444 of file eg_lpnum.int.h.
| #define int_epsLpNum 0 |
Definition at line 32 of file eg_lpnum.int.h.
| #define int_MaxLpNum INT_MAX |
Definition at line 33 of file eg_lpnum.int.h.
| #define int_MinLpNum INT_MIN |
Definition at line 34 of file eg_lpnum.int.h.
| #define int_oneLpNum 1 |
Definition at line 31 of file eg_lpnum.int.h.
| #define INT_TYPE 2 |
C int type.
Definition at line 153 of file eg_lpnum.h.
| #define int_zeroLpNum 0 |
extern definitions of constants for different set-ups
Definition at line 30 of file eg_lpnum.int.h.
| #define LDBL_TYPE 11 |
C long double type
Definition at line 173 of file eg_lpnum.h.
| #define llint_EGlpNumAddInnProdTo | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) += (b)*(c)) |
Add to a given number the product of two numbers.
| 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. |
Definition at line 351 of file eg_lpnum.llint.h.
| #define llint_EGlpNumAddTo | ( | a, | ||
| b | ||||
| ) | ((a) += (b)) |
Add to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to add to. | |
| b | EGlpNum_t value to be added to 'a'. |
Definition at line 381 of file eg_lpnum.llint.h.
| #define llint_EGlpNumAddUiTo | ( | a, | ||
| b | ||||
| ) | ((a) += (b)) |
Add to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to add to. | |
| b | unsigned long long int value to be added to 'a'. |
Definition at line 371 of file eg_lpnum.llint.h.
| #define llint_EGlpNumAllocArray | ( | size | ) | __EGlpNumAllocArray(long long int,size) |
Allocate and initialize (if needed) 'size' elements of type long long int and return it, if no more memory, exit(1).
Definition at line 79 of file eg_lpnum.llint.h.
| #define llint_EGlpNumCeil | ( | a, | ||
| b | ||||
| ) | llint_EGlpNumSet(a,b) |
Stores in the first number the ceil value of the second number, i.e. EGlpNumCeil(a,b) <==> a= ceil(b).
Definition at line 98 of file eg_lpnum.llint.h.
| #define llint_EGlpNumClearVar | ( | a | ) |
free the internal memory of a given variable
Definition at line 477 of file eg_lpnum.llint.h.
| #define llint_EGlpNumCopy | ( | dest, | ||
| orig | ||||
| ) | ((dest) = (orig)) |
copy the value of the second number to the first.
| orig | EGlpNum_t source number (it won't change value). | |
| dest | EGlpNum_t where to store the value stored in 'orig'. |
Definition at line 255 of file eg_lpnum.llint.h.
| #define llint_EGlpNumCopyAbs | ( | dest, | ||
| orig | ||||
| ) | ((dest) = EGabs(orig)) |
copy the value of the absolute value of the second parameter to the first parameter.
| orig | EGlpNum_t source number (it won't change value). | |
| dest | EGlpNum_t where to store the absolute value stored in 'orig'. |
Definition at line 291 of file eg_lpnum.llint.h.
| #define llint_EGlpNumCopyArray | ( | dest, | ||
| orig, | ||||
| size | ||||
| ) | memcpy(dest,orig,sizeof(long long int)*(size)) |
copy the first 'size' values in the second array to the first array.
| 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 long long int specifying how many values of 'orig' will be copied onto 'dest' |
Definition at line 329 of file eg_lpnum.llint.h.
| #define llint_EGlpNumCopyDiff | ( | dest, | ||
| a, | ||||
| b | ||||
| ) | ((dest) = (a) - (b)) |
copy the value of the second number to the first.
| 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'. |
Definition at line 237 of file eg_lpnum.llint.h.
| #define llint_EGlpNumCopyDiffRatio | ( | dest, | ||
| a, | ||||
| b, | ||||
| den | ||||
| ) | ((dest) = ((a) - (b)) / (den)) |
copy the value of the second number to the first.
| 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 . |
Definition at line 228 of file eg_lpnum.llint.h.
| #define llint_EGlpNumCopyFrac | ( | dest, | ||
| op1, | ||||
| op2 | ||||
| ) | ((dest) = (op1)/(op2)) |
Set des = op1/op2.
| 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) |
Definition at line 313 of file eg_lpnum.llint.h.
| #define llint_EGlpNumCopyNeg | ( | dest, | ||
| orig | ||||
| ) | ((dest) = -(orig)) |
copy minus the value of the second parameter to the first parameter.
| orig | EGlpNum_t the source number (it won't change value). | |
| dest | EGlpNum_t where to store minus the value stored in 'orig'. |
Definition at line 303 of file eg_lpnum.llint.h.
| #define llint_EGlpNumCopySqrOver | ( | dest, | ||
| orig, | ||||
| den | ||||
| ) | ((dest) = (orig)*(orig)/(den)) |
copy the square of the second argument, divided by the third argument into the first argument.
| dest | EGlpNum_t where to store the result | |
| orig | EGlpNum_t second parameter | |
| den | EGlpNum_t third parameter |
Definition at line 279 of file eg_lpnum.llint.h.
| #define llint_EGlpNumCopySum | ( | dest, | ||
| a, | ||||
| b | ||||
| ) | ((dest) = (a) + (b)) |
copy the value of the sum of the second and third parameter
| 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. |
Definition at line 246 of file eg_lpnum.llint.h.
| #define llint_EGlpNumDivTo | ( | a, | ||
| b | ||||
| ) | ((a) /= (b)) |
Divide a given number by the value of the second number.
| 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'. |
Definition at line 414 of file eg_lpnum.llint.h.
| #define llint_EGlpNumDivUiTo | ( | a, | ||
| b | ||||
| ) | ((a) /= (b)) |
Divide a given number by the value of the second number.
| a | EGlpNum_t the number that we are going to divide by the second number and store the result. | |
| b | unsigned long long int value to be divided to 'a'. |
Definition at line 425 of file eg_lpnum.llint.h.
| #define llint_EGlpNumFloor | ( | a, | ||
| b | ||||
| ) | llint_EGlpNumSet(a,b) |
Stores in the first number the floor value of the second number, i.e. EGlpNumFloor(a,b) <==> a= floor(b).
Definition at line 103 of file eg_lpnum.llint.h.
| #define llint_EGlpNumFreeArray | ( | ea | ) | __EGlpNumFreeArray(ea) |
given an array of type long long int, free it, if the pointer is NULL nothing happen.
Definition at line 57 of file eg_lpnum.llint.h.
| #define llint_EGlpNumGetStr | ( | a | ) |
({\
char *__str=0;\
size_t __i=snprintf(__str,(size_t)0,"%lld",a);\
__str = EGsMalloc(char,__i+1);\
snprintf(__str,__i+1,"%lld",a);\
__str;})
given a long long int, write it to a string (to be allocated internally), and return it.
Definition at line 47 of file eg_lpnum.llint.h.
| #define llint_EGlpNumInitVar | ( | a | ) | llint_EGlpNumZero(a) |
initialize the internal memory of a given variable
Definition at line 473 of file eg_lpnum.llint.h.
| #define llint_EGlpNumInv | ( | a | ) | ((a) = 1/(a)) |
store the (multiplicative) inverse of a number to itself, i.e. implement a = 1/a.
| a | the number to be inverted. |
Definition at line 109 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsDiffLess | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) - (b) < (c)) |
test if the diference of the first two numbers is less thatn the third number.
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number | |
| c | EGlpNum_t the third number |
Definition at line 185 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsEqqual | ( | a, | ||
| b | ||||
| ) | ((a) == (b)) |
Compare if two numbers are equal within a maximum error.
| a | EGlpNum_t first number to compare. | |
| b | EGlpNum_t second number to compare. |
Definition at line 119 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsEqual | ( | a, | ||
| b, | ||||
| error | ||||
| ) | (EGabs((a)-(b)) <= (error)) |
Compare if two numbers are equal within a maximum error.
| a | EGlpNum_t first number to compare. | |
| b | EGlpNum_t second number to compare. | |
| error | EGlpNum_t maximum difference allowed between both numbers. |
Definition at line 132 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsGreaDbl | ( | a, | ||
| b | ||||
| ) | ((a) > (b)) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | long long int the second number |
Definition at line 207 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsGreatZero | ( | a | ) | (a > 0) |
test if a number is greater than zero
| a | number to test |
Definition at line 154 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsLeq | ( | a, | ||
| b | ||||
| ) | ((a) <= (b)) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number |
Definition at line 218 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsLess | ( | a, | ||
| b | ||||
| ) | (a < b) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number |
Definition at line 147 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsLessDbl | ( | a, | ||
| b | ||||
| ) | ((a) < (b)) |
test if the first number is bigger to the second number
| a | EGlpNum_t the first number. | |
| b | long long int the second number |
Definition at line 196 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsLessZero | ( | a | ) | (a < 0) |
test if a number is bellow zero
| a | number to test |
Definition at line 161 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsNeq | ( | a, | ||
| b, | ||||
| error | ||||
| ) | (((a)-(b) > (error)) || ((b)-(a) > (error))) |
Definition at line 133 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsNeqq | ( | a, | ||
| b | ||||
| ) | ((a) != (b)) |
Definition at line 134 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsNeqqZero | ( | a | ) | ((a) != 0) |
Definition at line 136 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsNeqZero | ( | a, | ||
| error | ||||
| ) | (((a) > (error)) || (-(a) > (error))) |
Definition at line 135 of file eg_lpnum.llint.h.
| #define llint_EGlpNumIsSumLess | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) + (b) < (c)) |
test if the sum of the first two numbers is less thatn the third number.
| a | EGlpNum_t the first number. | |
| b | EGlpNum_t the second number | |
| c | EGlpNum_t the third number |
Definition at line 173 of file eg_lpnum.llint.h.
| #define llint_EGlpNumMultTo | ( | a, | ||
| b | ||||
| ) | ((a) *= (b)) |
Multiply a given number by the value of the second number.
| 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'. |
Definition at line 403 of file eg_lpnum.llint.h.
| #define llint_EGlpNumMultUiTo | ( | a, | ||
| b | ||||
| ) | ((a) *= (b)) |
Multiply a given number by the value of the second number.
| a | EGlpNum_t the number that we are going to multiply by the second number and store the result. | |
| b | unsigned long long int value to be multyply to 'a'. |
Definition at line 436 of file eg_lpnum.llint.h.
| #define llint_EGlpNumOne | ( | a | ) | ((a) = 1) |
Reset the value of the pointed number to one.
| a | EGlpNum_t value to be set to one. |
Definition at line 452 of file eg_lpnum.llint.h.
| #define llint_EGlpNumReadStr | ( | a, | ||
| str | ||||
| ) |
({\
long long int __i =0;\
sscanf(str,"%lld%n",&(a),&__i);\
__i;})
Read from a string a number and store it in the given long long int,.
Definition at line 39 of file eg_lpnum.llint.h.
| #define llint_EGlpNumReallocArray | ( | lptr, | ||
| lsize | ||||
| ) |
({\
size_t __csz = (lsize), *__usp = 0;\
size_t __psz = __EGlpNumArraySize(*lptr);\
long long int** __ptr__ = (lptr);\
if (!__psz) *__ptr__ = llint_EGlpNumAllocArray (__csz); \
else if (__psz < __csz) {\
__usp = (size_t*)(*__ptr__);\
__usp--;\
__usp = EGrealloc(__usp, sizeof(long long int)*__csz+sizeof(size_t));\
__usp[0] = __csz;\
*__ptr__ = (long long int*)(__usp+1);\
}\
*__ptr__;})
Reallocate and initialize (if needed) 'size' elements of type EGlpNum_t and return it, if no more memory, exit(1).
Definition at line 62 of file eg_lpnum.llint.h.
| #define llint_EGlpNumSet | ( | var, | ||
| dbl_var | ||||
| ) | ((var) = (dbl_var)) |
set the given number pointer, set its value to the given long long int.
| var | long long int where we will store the long long int value. | |
| dbl_var | long long int value to be stored in 'var'. |
with
, then
. Definition at line 93 of file eg_lpnum.llint.h.
| #define llint_EGlpNumSetToMaxAbs | ( | dest, | ||
| orig | ||||
| ) |
change the fist number to the maximum between itself and the absolute value of the second.
| orig | EGlpNum_t source number (it won't change value). | |
| dest | EGlpNum_t where to store the value stored in 'orig'. |
Definition at line 265 of file eg_lpnum.llint.h.
| #define llint_EGlpNumSetToMinAbs | ( | dest, | ||
| orig | ||||
| ) |
Definition at line 267 of file eg_lpnum.llint.h.
| #define llint_EGlpNumSign | ( | a | ) | ((a) = -(a)) |
Change the sign of the number.
| a | EGlpNum_t number we will change sign. |
Definition at line 460 of file eg_lpnum.llint.h.
| #define llint_EGlpNumSubInnProdTo | ( | a, | ||
| b, | ||||
| c | ||||
| ) | ((a) -= (b)*(c)) |
Sub to a given number the product of two numbers.
| 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. |
Definition at line 340 of file eg_lpnum.llint.h.
| #define llint_EGlpNumSubTo | ( | a, | ||
| b | ||||
| ) | ((a) -= (b)) |
Substract to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to substract from. | |
| b | EGlpNum_t value to be substracted to 'a'. |
Definition at line 392 of file eg_lpnum.llint.h.
| #define llint_EGlpNumSubUiTo | ( | a, | ||
| b | ||||
| ) | ((a) -= (b)) |
Substract to a given number the value of the second number.
| a | EGlpNum_t the number that we are going to substract to. | |
| b | unsigned long long int value to be substracted to 'a'. |
Definition at line 361 of file eg_lpnum.llint.h.
| #define llint_EGlpNumToLf | ( | a | ) | (a) |
return the closest long long int value of the given pointer number.
| a | EGlpNum_t number that we will be transformed to long long int. |
Definition at line 469 of file eg_lpnum.llint.h.
| #define llint_EGlpNumZero | ( | a | ) | ((a) = 0) |
Reset the value of the pointed number to zero.
| a | EGlpNum_t the value to be set to zero. |
Definition at line 444 of file eg_lpnum.llint.h.
| #define llint_epsLpNum 0LL |
Definition at line 32 of file eg_lpnum.llint.h.
| #define llint_MaxLpNum LLONG_MAX |
Definition at line 33 of file eg_lpnum.llint.h.
| #define llint_MinLpNum LLONG_MIN |
Definition at line 34 of file eg_lpnum.llint.h.
| #define llint_oneLpNum 1LL |
Definition at line 31 of file eg_lpnum.llint.h.
| #define LLINT_TYPE 12 |
C long long int type
Definition at line 175 of file eg_lpnum.h.
| #define llint_zeroLpNum 0LL |
extern definitions of constaants for different set-ups
Definition at line 30 of file eg_lpnum.llint.h.
| void EGlpNumClear | ( | void | ) |
This function must be called at the end of the program to free all internal data used in the EGlpNum_t structures, once this function is called any operation on EGlpNum_t types may fail.
Referenced by main().
| void EGlpNumStart | ( | void | ) |
type-dependant constants and helper numbers
initialization routine for global data. This function is called as a constructor, but calling it twice won't cause any problems, it is provided to ensure that all EGlpnum globals are initialized at the beggining and in case they where not (__EGlpNMum_setup==0), then call the initializator
Referenced by main().
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Tester program for EGlpNum_t structure and functions.
Definition at line 32 of file eg_lpnum.ex.c.
References EGfree, EGlib_info(), EGlib_version(), EGlpNumClear(), EGlpNumStart(), EGsetLimits(), and EGsigSet.

| int __EGlpNum_setup |
indicate if the global data needed for EGlpNum has been initialized, if zero, initialization routine should be called. This is provided to allow syncronization between libraries
1.7.1