Clearmatics Libff  0.1
C++ library for Finite Fields and Elliptic Curves
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
libff::Double Class Reference

#include <double.hpp>

Collaboration diagram for libff::Double:
Collaboration graph
[legend]

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 21 of file double.cpp.

21 { val = std::complex<double>(0, 0); }
Here is the caller graph for this function:

◆ Double() [2/4]

libff::Double::Double ( double  real)

Definition at line 23 of file double.cpp.

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

◆ Double() [3/4]

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

Definition at line 25 of file double.cpp.

26 {
27  val = std::complex<double>(real, imag);
28 }

◆ Double() [4/4]

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

Definition at line 30 of file double.cpp.

30 { val = num; }

Member Function Documentation

◆ arithmetic_generator()

Double libff::Double::arithmetic_generator ( )
static

Definition at line 159 of file double.cpp.

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

◆ as_bigint()

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

Definition at line 142 of file double.cpp.

143 {
144  return libff::bigint<1>(val.real());
145 }

◆ as_ulong()

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

Definition at line 147 of file double.cpp.

147 { return round(val.real()); }

◆ geometric_generator()

Double libff::Double::geometric_generator ( )
static

Definition at line 157 of file double.cpp.

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

◆ inverse()

Double libff::Double::inverse ( ) const

Definition at line 133 of file double.cpp.

134 {
135 #ifdef PROFILE_OP_COUNTS
136  ++inv_cnt;
137 #endif
138 
139  return Double(std::complex<double>(1) / val);
140 }
Here is the call graph for this function:

◆ one()

Double libff::Double::one ( )
static

Definition at line 151 of file double.cpp.

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

◆ operator!=()

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

Definition at line 108 of file double.cpp.

109 {
110  return Double(val) == other ? 0 : 1;
111 }
Here is the call graph for this function:

◆ operator*()

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

Definition at line 55 of file double.cpp.

56 {
57 #ifdef PROFILE_OP_COUNTS
58  ++mul_cnt;
59 #endif
60 
61  return Double(val * other.val);
62 }
Here is the call graph for this function:

◆ operator*=()

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

Definition at line 92 of file double.cpp.

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

◆ operator+()

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

Definition at line 37 of file double.cpp.

38 {
39 #ifdef PROFILE_OP_COUNTS
40  ++add_cnt;
41 #endif
42 
43  return Double(val + other.val);
44 }
Here is the call graph for this function:

◆ operator+=()

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

Definition at line 72 of file double.cpp.

73 {
74 #ifdef PROFILE_OP_COUNTS
75  ++add_cnt;
76 #endif
77 
78  this->val = std::complex<double>(val + other.val);
79  return *this;
80 }

◆ operator-() [1/2]

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

Definition at line 64 of file double.cpp.

65 {
66  if (val.imag() == 0)
67  return Double(-val.real());
68 
69  return Double(-val.real(), -val.imag());
70 }
Here is the call graph for this function:

◆ operator-() [2/2]

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

Definition at line 46 of file double.cpp.

47 {
48 #ifdef PROFILE_OP_COUNTS
49  ++sub_cnt;
50 #endif
51 
52  return Double(val - other.val);
53 }
Here is the call graph for this function:

◆ operator-=()

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

Definition at line 82 of file double.cpp.

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

◆ operator<()

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

Definition at line 113 of file double.cpp.

114 {
115  return (val.real() < other.val.real());
116 }

◆ operator==()

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

Definition at line 102 of file double.cpp.

103 {
104  return (std::abs(val.real() - other.val.real()) < 0.000001) &&
105  (std::abs(val.imag() - other.val.imag()) < 0.000001);
106 }

◆ operator>()

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

Definition at line 118 of file double.cpp.

119 {
120  return (val.real() > other.val.real());
121 }

◆ operator^() [1/2]

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

Definition at line 123 of file double.cpp.

124 {
125  return Double(pow(val, power.as_ulong()));
126 }
Here is the call graph for this function:

◆ operator^() [2/2]

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

Definition at line 128 of file double.cpp.

129 {
130  return Double(pow(val, power));
131 }
Here is the call graph for this function:

◆ random_element()

Double libff::Double::random_element ( )
static

Definition at line 155 of file double.cpp.

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

◆ squared()

Double libff::Double::squared ( ) const

Definition at line 149 of file double.cpp.

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

◆ zero()

Double libff::Double::zero ( )
static

Definition at line 153 of file double.cpp.

153 { return Double(0); }
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:
libff::Double::val
std::complex< double > val
Definition: double.hpp:24
libff::Double::mul_cnt
static unsigned mul_cnt
Definition: double.hpp:36
libff::Double::add_cnt
static unsigned add_cnt
Definition: double.hpp:34
libff::bigint
Definition: bigint.hpp:20
libff::Double::inv_cnt
static unsigned inv_cnt
Definition: double.hpp:37
libff::power
FieldT power(const FieldT &base, const bigint< m > &exponent)
libff::Double::Double
Double()
Definition: double.cpp:21
libff::Double::sub_cnt
static unsigned sub_cnt
Definition: double.hpp:35