23class EvaluationBackend {
27 explicit EvaluationBackend(
const Field& F,
28 bool panic_on_assertion_failure =
true)
30 panic_on_assertion_failure_(panic_on_assertion_failure),
31 assertion_failed_(
false) {}
33 ~EvaluationBackend() {
36 check(!assertion_failed_,
"assertion_failed_ true in ~EvaluationBackend()");
41 bool assertion_failed()
const {
42 bool b = assertion_failed_;
43 assertion_failed_ =
false;
50 explicit V(
const Elt& x) : e(x) {}
51 Elt elt()
const {
return e; }
53 bool operator==(
const V& y)
const {
return e == y.e; }
54 bool operator!=(
const V& y)
const {
return e != y.e; }
57 V assert0(
const V& a)
const {
58 if (a.e == f_.zero()) {
61 if (panic_on_assertion_failure_) {
62 check(
false,
"a != F.zero()");
64 assertion_failed_ =
true;
69 V add(
const V& a,
const V& b)
const {
return V{f_.addf(a.e, b.e)}; }
70 V sub(
const V& a,
const V& b)
const {
return V{f_.subf(a.e, b.e)}; }
71 V mul(
const V& a,
const V& b)
const {
return V{f_.mulf(a.e, b.e)}; }
72 V mul(
const Elt& a,
const V& b)
const {
return V{f_.mulf(a, b.e)}; }
73 V mul(
const Elt& a,
const V& b,
const V& c)
const {
74 return mul(a, mul(b, c));
76 V konst(
const Elt& a)
const {
return V{a}; }
78 V ax(
const Elt& a,
const V& x)
const {
return V{f_.mulf(a, x.e)}; }
79 V axy(
const Elt& a,
const V& x,
const V& y)
const {
80 return V{f_.mulf(a, f_.mulf(x.e, y.e))};
82 V axpy(
const V& y,
const Elt& a,
const V& x)
const {
83 return V{f_.addf(y.e, f_.mulf(a, x.e))};
85 V apy(
const V& y,
const Elt& a)
const {
return V{f_.addf(y.e, a)}; }
89 bool panic_on_assertion_failure_;
90 mutable bool assertion_failed_;