source: vis_dev/sharpSAT/src/shared/RealNumberTypes.cpp @ 64

Last change on this file since 64 was 29, checked in by cecile, 13 years ago

shared missing for sharpSAT

File size: 1.2 KB
Line 
1#include "RealNumberTypes.h"
2
3#include <math.h>
4
5#ifdef GMP_BIGNUM
6
7const mpf_class mpf_TWO = 2.0;
8
9bool pow(mpf_class &res, const mpf_class &base, unsigned long int iExp)
10{
11   mpf_pow_ui(res.get_mpf_t(),base.get_mpf_t(), iExp);       
12   return true;
13}
14
15bool pow2(mpf_class &res, unsigned long int iExp)
16{
17   mpf_class x(2.0,res.get_prec());
18  // x= 2.0;
19   mpf_pow_ui(res.get_mpf_t(),x.get_mpf_t(), iExp);       
20   return true;
21}
22
23bool to_div_2exp(mpf_class &res, const mpf_class &op1, unsigned long int iExp)
24{
25   mpf_div_2exp(res.get_mpf_t(),op1.get_mpf_t(),iExp); 
26   return true;
27}
28
29double to_doubleT(const mpf_class &num)
30{
31  return mpf_get_d(num.get_mpf_t());
32}
33
34#else
35
36bool pow(CRealNum &res, double &base, unsigned long int iExp)
37{
38   res = pow(base, iExp);   
39   return true;   
40}
41
42bool pow2(CRealNum &res, unsigned long int iExp)
43{
44   res = pow(2.00, iExp);       
45   return true;
46}
47
48
49bool to_div_2exp(CRealNum &res, const CRealNum &op1, unsigned long int iExp)
50{
51   res  = op1 / pow(2.00,iExp); 
52   return true;
53}
54
55
56long double to_doubleT(const CRealNum &num)
57{
58  return (long double) num;
59}
60#endif
Note: See TracBrowser for help on using the repository browser.