Clearmatics Libsnark  0.1
C++ library for zkSNARK proofs
Classes | Public Types | Public Member Functions | Friends | List of all members
gadgetlib2::Variable Class Reference

A formal variable, field agnostic. More...

#include <variable.hpp>

Classes

struct  VariableStrictOrder
 

Public Types

typedef ::std::map< Variable, FElem, Variable::VariableStrictOrderVariableAssignment
 
typedef ::std::set< Variable, VariableStrictOrderset
 A set of Variables should be declared as follows: Variable::set s1;. More...
 
typedef ::std::multiset< Variable, VariableStrictOrdermultiset
 

Public Member Functions

 Variable (const ::std::string &name="")
 allocates the variable More...
 
virtual ~Variable ()
 
::std::string name () const
 
FElem eval (const VariableAssignment &assignment) const
 

Friends

class GadgetLibAdapter
 

Detailed Description

A formal variable, field agnostic.

Each variable is specified by an index. This can be imagined as the index in x_1, x_2,..., x_i These are formal variables and do not hold an assignment, later the class VariableAssignment will give each formal variable its own assignment. Variables have no comparison and assignment operators as evaluating (x_1 == x_2) has no sense without specific assignments. Variables are field agnostic, this means they can be used regardless of the context field, which will also be determined by the assignment.

Definition at line 306 of file variable.hpp.

Member Typedef Documentation

◆ multiset

Definition at line 342 of file variable.hpp.

◆ set

A set of Variables should be declared as follows: Variable::set s1;.

Definition at line 341 of file variable.hpp.

◆ VariableAssignment

Definition at line 337 of file variable.hpp.

Constructor & Destructor Documentation

◆ Variable()

gadgetlib2::Variable::Variable ( const ::std::string &  name = "")
explicit

allocates the variable

Definition at line 283 of file variable.cpp.

283  : index_(nextFreeIndex_++)
284 {
285  libff::UNUSED(name);
287  nextFreeIndex_ > 0,
289  "Variable index overflow has occured, maximum number of "
290  "Variables is %lu",
291  ULONG_MAX));
292 }
Here is the call graph for this function:

◆ ~Variable()

gadgetlib2::Variable::~Variable ( )
virtual

Definition at line 295 of file variable.cpp.

295 {};

Member Function Documentation

◆ eval()

FElem gadgetlib2::Variable::eval ( const VariableAssignment assignment) const

Definition at line 306 of file variable.cpp.

307 {
308  try {
309  return assignment.at(*this);
310  } catch (::std::out_of_range &) {
312  "Attempted to evaluate unassigned Variable \"%s\", idx:%lu",
313  name().c_str(),
314  index_));
315  }
316 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ name()

string gadgetlib2::Variable::name ( ) const

Definition at line 297 of file variable.cpp.

298 {
299 #ifdef DEBUG
300  return name_;
301 #else
302  return "";
303 #endif
304 }
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ GadgetLibAdapter

friend class GadgetLibAdapter
friend

Definition at line 344 of file variable.hpp.


The documentation for this class was generated from the following files:
gadgetlib2::GADGETLIB2_FMT
::std::string GADGETLIB2_FMT(const char *format,...)
Definition: infrastructure.cpp:49
gadgetlib2::Variable::name
::std::string name() const
Definition: variable.cpp:297
GADGETLIB_FATAL
#define GADGETLIB_FATAL(msg)
Definition: infrastructure.hpp:85
GADGETLIB_ASSERT
#define GADGETLIB_ASSERT(predicate, msg)
Definition: infrastructure.hpp:94