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

LinearTerm. More...

#include <variable.hpp>

Public Member Functions

 LinearTerm (const Variable &v)
 
 LinearTerm (const Variable &v, const FElem &coeff)
 
 LinearTerm (const Variable &v, long n)
 
LinearTerm operator- () const
 
LinearTermoperator*= (const FElem &other)
 
FieldType fieldtype () const
 
::std::string asString () const
 
FElem eval (const VariableAssignment &assignment) const
 
Variable variable () const
 

Friends

class Monomial
 
class GadgetLibAdapter
 

Detailed Description

LinearTerm.

Definition at line 474 of file variable.hpp.

Constructor & Destructor Documentation

◆ LinearTerm() [1/3]

gadgetlib2::LinearTerm::LinearTerm ( const Variable v)
inline

Definition at line 481 of file variable.hpp.

481 : variable_(v), coeff_(1) {}
Here is the caller graph for this function:

◆ LinearTerm() [2/3]

gadgetlib2::LinearTerm::LinearTerm ( const Variable v,
const FElem coeff 
)
inline

Definition at line 482 of file variable.hpp.

483  : variable_(v), coeff_(coeff)
484  {
485  }

◆ LinearTerm() [3/3]

gadgetlib2::LinearTerm::LinearTerm ( const Variable v,
long  n 
)
inline

Definition at line 486 of file variable.hpp.

486 : variable_(v), coeff_(n) {}

Member Function Documentation

◆ asString()

std::string gadgetlib2::LinearTerm::asString ( ) const

Definition at line 512 of file variable.cpp.

513 {
514  if (coeff_ == 1) {
515  return variable_.name();
516  } else if (coeff_ == -1) {
517  return GADGETLIB2_FMT("-1 * %s", variable_.name().c_str());
518  } else if (coeff_ == 0) {
519  return GADGETLIB2_FMT("0 * %s", variable_.name().c_str());
520  } else {
521  return GADGETLIB2_FMT(
522  "%s * %s", coeff_.asString().c_str(), variable_.name().c_str());
523  }
524 }
Here is the call graph for this function:

◆ eval()

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

Definition at line 526 of file variable.cpp.

527 {
528  return FElem(coeff_) *= variable_.eval(assignment);
529 }
Here is the call graph for this function:

◆ fieldtype()

FieldType gadgetlib2::LinearTerm::fieldtype ( ) const
inline

Definition at line 493 of file variable.hpp.

493 { return coeff_.fieldType(); }
Here is the call graph for this function:

◆ operator*=()

LinearTerm& gadgetlib2::LinearTerm::operator*= ( const FElem other)
inline

Definition at line 488 of file variable.hpp.

489  {
490  coeff_ *= other;
491  return *this;
492  }

◆ operator-()

LinearTerm gadgetlib2::LinearTerm::operator- ( ) const
inline

Definition at line 487 of file variable.hpp.

487 { return LinearTerm(variable_, -coeff_); }
Here is the call graph for this function:

◆ variable()

Variable gadgetlib2::LinearTerm::variable ( ) const
inline

Definition at line 496 of file variable.hpp.

496 { return variable_; }

Friends And Related Function Documentation

◆ GadgetLibAdapter

friend class GadgetLibAdapter
friend

Definition at line 499 of file variable.hpp.

◆ Monomial

friend class Monomial
friend

Definition at line 498 of file variable.hpp.


The documentation for this class was generated from the following files:
gadgetlib2::LinearTerm::LinearTerm
LinearTerm(const Variable &v)
Definition: variable.hpp:481
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
gadgetlib2::FElem::fieldType
FieldType fieldType() const
Definition: variable.hpp:128
gadgetlib2::Variable::eval
FElem eval(const VariableAssignment &assignment) const
Definition: variable.cpp:306
gadgetlib2::FElem::asString
::std::string asString() const
Definition: variable.hpp:127