Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
libff::Double Class Reference

#include <double.hpp>

Collaboration diagram for libff::Double:

Public Member Functions

 Double ()
 
 Double (double real)
 
 Double (double real, double imag)
 
 Double (std::complex< double > num)
 
Double operator+ (const Double &other) const
 
Double operator- (const Double &other) const
 
Double operator* (const Double &other) const
 
Double operator- () const
 
Doubleoperator+= (const Double &other)
 
Doubleoperator-= (const Double &other)
 
Doubleoperator*= (const Double &other)
 
bool operator== (const Double &other) const
 
bool operator!= (const Double &other) const
 
bool operator< (const Double &other) const
 
bool operator> (const Double &other) const
 
Double operator^ (const libff::bigint< 1 > power) const
 
Double operator^ (const size_t power) const
 
libff::bigint< 1 > as_bigint () const
 
unsigned long as_ulong () const
 
Double inverse () const
 
Double squared () const
 

Static Public Member Functions

static Double one ()
 
static Double zero ()
 
static Double random_element ()
 
static Double geometric_generator ()
 
static Double arithmetic_generator ()
 

Public Attributes

std::complex< double > val
 

Static Public Attributes

static unsigned add_cnt = 0
 
static unsigned sub_cnt = 0
 
static unsigned mul_cnt = 0
 
static unsigned inv_cnt = 0
 
static Double multiplicative_generator = Double(2)
 
static Double root_of_unity
 
static size_t s
 

Detailed Description

Definition at line 21 of file double.hpp.

Constructor & Destructor Documentation

◆ Double() [1/4]

libff::Double::Double ( )

Definition at line 24 of file double.cpp.

25 {
26 val = std::complex<double>(0, 0);
27 }
std::complex< double > val
Definition double.hpp:24
Here is the caller graph for this function:

◆ Double() [2/4]

libff::Double::Double ( double real)

Definition at line 29 of file double.cpp.

30 {
31 val = std::complex<double>(real, 0);
32 }

◆ Double() [3/4]

libff::Double::Double ( double real,
double imag )

Definition at line 34 of file double.cpp.

35 {
36 val = std::complex<double>(real, imag);
37 }

◆ Double() [4/4]

libff::Double::Double ( std::complex< double > num)

Definition at line 39 of file double.cpp.

40 {
41 val = num;
42 }

Member Function Documentation

◆ arithmetic_generator()

Double libff::Double::arithmetic_generator ( )
static

Definition at line 188 of file double.cpp.

189 {
190 return Double(1);
191 }
Here is the call graph for this function:

◆ as_bigint()

libff::bigint< 1 > libff::Double::as_bigint ( ) const

Definition at line 153 of file double.cpp.

154 {
155 return libff::bigint<1>(val.real());
156 }

◆ as_ulong()

unsigned long libff::Double::as_ulong ( ) const

Definition at line 158 of file double.cpp.

159 {
160 return round(val.real());
161 }

◆ geometric_generator()

Double libff::Double::geometric_generator ( )
static

Definition at line 183 of file double.cpp.

184 {
185 return Double(2);
186 }
Here is the call graph for this function:

◆ inverse()

Double libff::Double::inverse ( ) const

Definition at line 144 of file double.cpp.

145 {
146#ifdef PROFILE_OP_COUNTS
147 ++inv_cnt;
148#endif
149
150 return Double(std::complex<double>(1) / val);
151 }
static unsigned inv_cnt
Definition double.hpp:37
Here is the call graph for this function:

◆ one()

Double libff::Double::one ( )
static

Definition at line 168 of file double.cpp.

169 {
170 return Double(1);
171 }
Here is the call graph for this function:

◆ operator!=()

bool libff::Double::operator!= ( const Double & other) const

Definition at line 119 of file double.cpp.

120 {
121 return Double(val) == other ? 0 : 1;
122 }
Here is the call graph for this function:

◆ operator*()

Double libff::Double::operator* ( const Double & other) const

Definition at line 67 of file double.cpp.

68 {
69#ifdef PROFILE_OP_COUNTS
70 ++mul_cnt;
71#endif
72
73 return Double(val * other.val);
74 }
static unsigned mul_cnt
Definition double.hpp:36
Here is the call graph for this function:

◆ operator*=()

Double & libff::Double::operator*= ( const Double & other)

Definition at line 103 of file double.cpp.

104 {
105#ifdef PROFILE_OP_COUNTS
106 ++mul_cnt;
107#endif
108
109 this->val *= std::complex<double>(other.val);
110 return *this;
111 }

◆ operator+()

Double libff::Double::operator+ ( const Double & other) const

Definition at line 49 of file double.cpp.

50 {
51#ifdef PROFILE_OP_COUNTS
52 ++add_cnt;
53#endif
54
55 return Double(val + other.val);
56 }
static unsigned add_cnt
Definition double.hpp:34
Here is the call graph for this function:

◆ operator+=()

Double & libff::Double::operator+= ( const Double & other)

Definition at line 83 of file double.cpp.

84 {
85#ifdef PROFILE_OP_COUNTS
86 ++add_cnt;
87#endif
88
89 this->val = std::complex<double>(val + other.val);
90 return *this;
91 }

◆ operator-() [1/2]

Double libff::Double::operator- ( ) const

Definition at line 76 of file double.cpp.

77 {
78 if (val.imag() == 0) return Double(-val.real());
79
80 return Double(-val.real(), -val.imag());
81 }
Here is the call graph for this function:

◆ operator-() [2/2]

Double libff::Double::operator- ( const Double & other) const

Definition at line 58 of file double.cpp.

59 {
60#ifdef PROFILE_OP_COUNTS
61 ++sub_cnt;
62#endif
63
64 return Double(val - other.val);
65 }
static unsigned sub_cnt
Definition double.hpp:35
Here is the call graph for this function:

◆ operator-=()

Double & libff::Double::operator-= ( const Double & other)

Definition at line 93 of file double.cpp.

94 {
95#ifdef PROFILE_OP_COUNTS
96 ++sub_cnt;
97#endif
98
99 this->val = std::complex<double>(val - other.val);
100 return *this;
101 }

◆ operator<()

bool libff::Double::operator< ( const Double & other) const

Definition at line 124 of file double.cpp.

125 {
126 return (val.real() < other.val.real());
127 }

◆ operator==()

bool libff::Double::operator== ( const Double & other) const

Definition at line 113 of file double.cpp.

114 {
115 return (std::abs(val.real() - other.val.real()) < 0.000001)
116 && (std::abs(val.imag() - other.val.imag()) < 0.000001);
117 }

◆ operator>()

bool libff::Double::operator> ( const Double & other) const

Definition at line 129 of file double.cpp.

130 {
131 return (val.real() > other.val.real());
132 }

◆ operator^() [1/2]

Double libff::Double::operator^ ( const libff::bigint< 1 > power) const

Definition at line 134 of file double.cpp.

135 {
136 return Double(pow(val, power.as_ulong()));
137 }
FieldT power(const FieldT &base, const bigint< m > &exponent)
Here is the call graph for this function:

◆ operator^() [2/2]

Double libff::Double::operator^ ( const size_t power) const

Definition at line 139 of file double.cpp.

140 {
141 return Double(pow(val, power));
142 }
Here is the call graph for this function:

◆ random_element()

Double libff::Double::random_element ( )
static

Definition at line 178 of file double.cpp.

179 {
180 return Double(std::rand() % 1001);
181 }
Here is the call graph for this function:

◆ squared()

Double libff::Double::squared ( ) const

Definition at line 163 of file double.cpp.

164 {
165 return Double(val * val);
166 }
Here is the call graph for this function:

◆ zero()

Double libff::Double::zero ( )
static

Definition at line 173 of file double.cpp.

174 {
175 return Double(0);
176 }
Here is the call graph for this function:

Member Data Documentation

◆ add_cnt

unsigned libff::Double::add_cnt = 0
static

Definition at line 34 of file double.hpp.

◆ inv_cnt

unsigned libff::Double::inv_cnt = 0
static

Definition at line 37 of file double.hpp.

◆ mul_cnt

unsigned libff::Double::mul_cnt = 0
static

Definition at line 36 of file double.hpp.

◆ multiplicative_generator

Double libff::Double::multiplicative_generator = Double(2)
static

Definition at line 68 of file double.hpp.

◆ root_of_unity

Double libff::Double::root_of_unity
static

Definition at line 69 of file double.hpp.

◆ s

size_t libff::Double::s
static

Definition at line 70 of file double.hpp.

◆ sub_cnt

unsigned libff::Double::sub_cnt = 0
static

Definition at line 35 of file double.hpp.

◆ val

std::complex<double> libff::Double::val

Definition at line 24 of file double.hpp.


The documentation for this class was generated from the following files: