Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bitwise_impl.hpp
Go to the documentation of this file.
1// AUTOGENERATED FILE
2#pragma once
3
5
6namespace bb::avm2 {
7
8template <typename FF_>
9template <typename ContainerOverSubrelations, typename AllEntities>
10void bitwiseImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
11 const AllEntities& in,
12 [[maybe_unused]] const RelationParameters<FF_>&,
13 [[maybe_unused]] const FF_& scaling_factor)
14{
15 using C = ColumnAndShifts;
16
17 PROFILE_THIS_NAME("accumulate/bitwise");
18
19 const auto constants_MEM_TAG_FF = FF(0);
20 const auto bitwise_TAG_A_DIFF = (in.get(C::bitwise_tag_a) - constants_MEM_TAG_FF);
21 const auto bitwise_TAG_AB_DIFF = (in.get(C::bitwise_tag_a) - in.get(C::bitwise_tag_b));
22
23 {
24 using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>;
25 auto tmp = in.get(C::bitwise_sel) * (FF(1) - in.get(C::bitwise_sel));
26 tmp *= scaling_factor;
27 std::get<0>(evals) += typename Accumulator::View(tmp);
28 }
29 {
30 using Accumulator = typename std::tuple_element_t<1, ContainerOverSubrelations>;
31 auto tmp = in.get(C::bitwise_start) * (FF(1) - in.get(C::bitwise_start));
32 tmp *= scaling_factor;
33 std::get<1>(evals) += typename Accumulator::View(tmp);
34 }
35 {
36 using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>;
37 auto tmp = in.get(C::bitwise_sel_tag_ff_err) * (FF(1) - in.get(C::bitwise_sel_tag_ff_err));
38 tmp *= scaling_factor;
39 std::get<2>(evals) += typename Accumulator::View(tmp);
40 }
41 {
42 using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>;
43 auto tmp = in.get(C::bitwise_sel_tag_mismatch_err) * (FF(1) - in.get(C::bitwise_sel_tag_mismatch_err));
44 tmp *= scaling_factor;
45 std::get<3>(evals) += typename Accumulator::View(tmp);
46 }
47 {
48 using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>;
49 auto tmp = (in.get(C::bitwise_err) - (FF(1) - (FF(1) - in.get(C::bitwise_sel_tag_mismatch_err)) *
50 (FF(1) - in.get(C::bitwise_sel_tag_ff_err))));
51 tmp *= scaling_factor;
52 std::get<4>(evals) += typename Accumulator::View(tmp);
53 }
54 {
55 using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>;
56 auto tmp = in.get(C::bitwise_last) * (FF(1) - in.get(C::bitwise_last));
57 tmp *= scaling_factor;
58 std::get<5>(evals) += typename Accumulator::View(tmp);
59 }
60 { // LAST_ON_ERROR
61 using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>;
62 auto tmp = in.get(C::bitwise_err) * (in.get(C::bitwise_last) - FF(1));
63 tmp *= scaling_factor;
64 std::get<6>(evals) += typename Accumulator::View(tmp);
65 }
66 { // RES_TAG_SHOULD_MATCH_INPUT
67 using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>;
68 auto tmp = in.get(C::bitwise_start) * (in.get(C::bitwise_tag_c) - in.get(C::bitwise_tag_a));
69 tmp *= scaling_factor;
70 std::get<7>(evals) += typename Accumulator::View(tmp);
71 }
72 { // INPUT_TAG_CANNOT_BE_FF
73 using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>;
74 auto tmp = in.get(C::bitwise_start) *
75 ((bitwise_TAG_A_DIFF * (in.get(C::bitwise_sel_tag_ff_err) * (FF(1) - in.get(C::bitwise_tag_a_inv)) +
76 in.get(C::bitwise_tag_a_inv)) -
77 FF(1)) +
78 in.get(C::bitwise_sel_tag_ff_err));
79 tmp *= scaling_factor;
80 std::get<8>(evals) += typename Accumulator::View(tmp);
81 }
82 { // INPUT_TAGS_SHOULD_MATCH
83 using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>;
84 auto tmp =
85 in.get(C::bitwise_start) * (bitwise_TAG_AB_DIFF * ((FF(1) - in.get(C::bitwise_sel_tag_mismatch_err)) *
86 (FF(1) - in.get(C::bitwise_tag_ab_diff_inv)) +
87 in.get(C::bitwise_tag_ab_diff_inv)) -
88 in.get(C::bitwise_sel_tag_mismatch_err));
89 tmp *= scaling_factor;
90 std::get<9>(evals) += typename Accumulator::View(tmp);
91 }
92 { // BITW_OP_ID_REL
93 using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>;
94 auto tmp = (in.get(C::bitwise_op_id_shift) - in.get(C::bitwise_op_id)) * (FF(1) - in.get(C::bitwise_last));
95 tmp *= scaling_factor;
96 std::get<10>(evals) += typename Accumulator::View(tmp);
97 }
98 { // BITW_CTR_DECREMENT
99 using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>;
100 auto tmp = in.get(C::bitwise_sel) * ((in.get(C::bitwise_ctr_shift) - in.get(C::bitwise_ctr)) + FF(1)) *
101 (FF(1) - in.get(C::bitwise_last));
102 tmp *= scaling_factor;
103 std::get<11>(evals) += typename Accumulator::View(tmp);
104 }
105 { // BITW_SEL_CTR_NON_ZERO
106 using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>;
107 auto tmp = (in.get(C::bitwise_ctr) * ((FF(1) - in.get(C::bitwise_sel)) * (FF(1) - in.get(C::bitwise_ctr_inv)) +
108 in.get(C::bitwise_ctr_inv)) -
109 in.get(C::bitwise_sel));
110 tmp *= scaling_factor;
111 std::get<12>(evals) += typename Accumulator::View(tmp);
112 }
113 { // BITW_LAST_FOR_CTR_ONE
114 using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>;
115 auto tmp =
116 in.get(C::bitwise_sel) * (((in.get(C::bitwise_ctr) - FF(1)) *
117 (in.get(C::bitwise_last) * (FF(1) - in.get(C::bitwise_ctr_min_one_inv)) +
118 in.get(C::bitwise_ctr_min_one_inv)) +
119 in.get(C::bitwise_last)) -
120 FF(1));
121 tmp *= scaling_factor;
122 std::get<13>(evals) += typename Accumulator::View(tmp);
123 }
124 { // BITW_INIT_A
125 using Accumulator = typename std::tuple_element_t<14, ContainerOverSubrelations>;
126 auto tmp = in.get(C::bitwise_last) * (in.get(C::bitwise_acc_ia) - in.get(C::bitwise_ia_byte));
127 tmp *= scaling_factor;
128 std::get<14>(evals) += typename Accumulator::View(tmp);
129 }
130 { // BITW_INIT_B
131 using Accumulator = typename std::tuple_element_t<15, ContainerOverSubrelations>;
132 auto tmp = in.get(C::bitwise_last) * (in.get(C::bitwise_acc_ib) - in.get(C::bitwise_ib_byte));
133 tmp *= scaling_factor;
134 std::get<15>(evals) += typename Accumulator::View(tmp);
135 }
136 { // BITW_INIT_C
137 using Accumulator = typename std::tuple_element_t<16, ContainerOverSubrelations>;
138 auto tmp = in.get(C::bitwise_last) * (in.get(C::bitwise_acc_ic) - in.get(C::bitwise_ic_byte));
139 tmp *= scaling_factor;
140 std::get<16>(evals) += typename Accumulator::View(tmp);
141 }
142 { // BITW_ACC_REL_A
143 using Accumulator = typename std::tuple_element_t<17, ContainerOverSubrelations>;
144 auto tmp =
145 ((in.get(C::bitwise_acc_ia) - in.get(C::bitwise_ia_byte)) - FF(256) * in.get(C::bitwise_acc_ia_shift)) *
146 (FF(1) - in.get(C::bitwise_last));
147 tmp *= scaling_factor;
148 std::get<17>(evals) += typename Accumulator::View(tmp);
149 }
150 { // BITW_ACC_REL_B
151 using Accumulator = typename std::tuple_element_t<18, ContainerOverSubrelations>;
152 auto tmp =
153 ((in.get(C::bitwise_acc_ib) - in.get(C::bitwise_ib_byte)) - FF(256) * in.get(C::bitwise_acc_ib_shift)) *
154 (FF(1) - in.get(C::bitwise_last));
155 tmp *= scaling_factor;
156 std::get<18>(evals) += typename Accumulator::View(tmp);
157 }
158 { // BITW_ACC_REL_C
159 using Accumulator = typename std::tuple_element_t<19, ContainerOverSubrelations>;
160 auto tmp =
161 ((in.get(C::bitwise_acc_ic) - in.get(C::bitwise_ic_byte)) - FF(256) * in.get(C::bitwise_acc_ic_shift)) *
162 (FF(1) - in.get(C::bitwise_last));
163 tmp *= scaling_factor;
164 std::get<19>(evals) += typename Accumulator::View(tmp);
165 }
166 {
167 using Accumulator = typename std::tuple_element_t<20, ContainerOverSubrelations>;
168 auto tmp = (in.get(C::bitwise_sel_get_ctr) - in.get(C::bitwise_start) * (FF(1) - in.get(C::bitwise_err)));
169 tmp *= scaling_factor;
170 std::get<20>(evals) += typename Accumulator::View(tmp);
171 }
172}
173
174} // namespace bb::avm2
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
ColumnAndShifts
Definition columns.hpp:35
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define PROFILE_THIS_NAME(name)
Definition op_count.hpp:16
Container for parameters used by the grand product (permutation, lookup) Honk relations.