116 static constexpr std::array<bool, 3>
121 template <
typename AllEntities>
inline static bool skip(
const AllEntities& in)
124 return in.q_lookup.is_zero() && in.lookup_read_counts.is_zero();
141 return (row.q_lookup == 1) || (row.lookup_read_tags == 1);
162 template <
typename Accumulator,
typename AllEntities>
165 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
167 const auto row_has_write = CoefficientAccumulator(in.lookup_read_tags);
168 const auto row_has_read = CoefficientAccumulator(in.q_lookup);
176 return Accumulator(-(row_has_write * row_has_read) + row_has_write + row_has_read);
196 template <
typename Accumulator,
typename AllEntities,
typename Parameters>
199 using ParameterCoefficientAccumulator =
typename Parameters::DataType::CoefficientAccumulator;
200 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
202 const auto gamma = ParameterCoefficientAccumulator(params.gamma);
203 const auto beta = ParameterCoefficientAccumulator(params.beta);
204 const auto beta_sqr = ParameterCoefficientAccumulator(params.beta_sqr);
205 const auto beta_cube = ParameterCoefficientAccumulator(params.beta_cube);
207 auto table_1 = CoefficientAccumulator(in.table_1);
208 auto table_2 = CoefficientAccumulator(in.table_2);
209 auto table_3 = CoefficientAccumulator(in.table_3);
210 auto table_4 = CoefficientAccumulator(in.table_4);
213 auto result = (table_2 * beta) + (table_3 * beta_sqr) + (table_4 * beta_cube);
216 return Accumulator(result);
219 template <
typename Accumulator,
typename AllEntities,
typename Parameters>
222 using ParameterCoefficientAccumulator =
typename Parameters::DataType::CoefficientAccumulator;
223 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
225 const auto gamma = ParameterCoefficientAccumulator(params.gamma);
226 const auto beta = ParameterCoefficientAccumulator(params.beta);
227 const auto beta_sqr = ParameterCoefficientAccumulator(params.beta_sqr);
228 const auto beta_cube = ParameterCoefficientAccumulator(params.beta_cube);
230 auto w_1 = CoefficientAccumulator(in.w_l);
231 auto w_2 = CoefficientAccumulator(in.w_r);
232 auto w_3 = CoefficientAccumulator(in.w_o);
234 auto w_1_shift = CoefficientAccumulator(in.w_l_shift);
235 auto w_2_shift = CoefficientAccumulator(in.w_r_shift);
236 auto w_3_shift = CoefficientAccumulator(in.w_o_shift);
238 auto table_index = CoefficientAccumulator(in.q_o);
239 auto negative_column_1_step_size = CoefficientAccumulator(in.q_r);
240 auto negative_column_2_step_size = CoefficientAccumulator(in.q_m);
241 auto negative_column_3_step_size = CoefficientAccumulator(in.q_c);
247 auto derived_table_entry_1 = (negative_column_1_step_size * w_1_shift) + (w_1 + gamma);
249 auto derived_table_entry_2 = (negative_column_2_step_size * w_2_shift) + w_2;
251 auto derived_table_entry_3 = (negative_column_3_step_size * w_3_shift) + w_3;
253 auto table_index_entry = table_index * beta_cube;
258 auto result = Accumulator(derived_table_entry_2) * beta + Accumulator(derived_table_entry_3) * beta_sqr;
259 result += Accumulator(derived_table_entry_1 + table_index_entry);
274 template <
typename Polynomials>
276 auto& relation_parameters,
277 const size_t circuit_size,
278 const size_t start_index = 0)
283 const size_t num_rows = circuit_size - start_index;
284 size_t min_iterations_per_thread = 1 << 6;
289 for (
size_t j : chunk.
range(num_rows)) {
290 size_t i = j + start_index;
292 if (polynomials.q_lookup.get(i) == 1 || polynomials.lookup_read_tags.get(i) == 1) {
294 auto row = polynomials.get_row(i);
295 auto value = compute_lookup_term<FF>(row, relation_parameters) *
296 compute_table_term<FF>(row, relation_parameters);
297 inverse_polynomial.at(i) =
value;
315 template <
typename ContainerOverSubrelations,
typename AllEntities,
typename Parameters>
316 static void accumulate(ContainerOverSubrelations& accumulator,
317 const AllEntities& in,
318 const Parameters& params,
319 const FF& scaling_factor)
326 using ShortView =
typename ShortAccumulator::View;
329 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
334 const auto inverses_m = CoefficientAccumulator(in.lookup_inverses);
335 const Accumulator inverses(inverses_m);
336 const auto read_counts_m = CoefficientAccumulator(in.lookup_read_counts);
337 const auto read_selector_m = CoefficientAccumulator(in.q_lookup);
339 const auto inverse_exists = compute_inverse_exists<Accumulator>(in);
340 const auto lookup_term = compute_lookup_term<Accumulator>(in, params);
341 const auto table_term = compute_table_term<Accumulator>(in, params);
346 const Accumulator logderiv_first_term = (lookup_term * table_term * inverses - inverse_exists) * scaling_factor;
347 std::get<0>(accumulator) += ShortView(logderiv_first_term);
352 Accumulator tmp = Accumulator(read_selector_m) * table_term;
353 tmp -= (Accumulator(read_counts_m) * lookup_term);
358 const auto read_tag_m = CoefficientAccumulator(in.lookup_read_tags);
359 const auto read_tag = BooleanCheckerAccumulator(read_tag_m);
361 std::get<2>(accumulator) += (read_tag * read_tag - read_tag) * scaling_factor;
#define BB_BENCH_NAME(name)
#define BB_BENCH_TRACY_NAME(name)
Log-derivative lookup argument relation for establishing lookup reads from tables with 3 or fewer col...
static constexpr std::array< size_t, 3 > SUBRELATION_PARTIAL_LENGTHS
static bool operation_exists_at_row(const AllValues &row)
Does the provided row contain data relevant to table lookups.
static constexpr size_t TABLE_TERMS
static constexpr size_t LOOKUP_SUBRELATION_LENGTH
static void accumulate(ContainerOverSubrelations &accumulator, const AllEntities &in, const Parameters ¶ms, const FF &scaling_factor)
Accumulate the subrelation contributions for reads from a lookup table.
static Accumulator compute_inverse_exists(const AllEntities &in)
Compute the Accumulator whose values indicate whether the inverse is computed or not.
static constexpr size_t INVERSE_SUBRELATION_LENGTH
static Accumulator compute_table_term(const AllEntities &in, const Parameters ¶ms)
Compute the table term.
static void compute_logderivative_inverse(Polynomials &polynomials, auto &relation_parameters, const size_t circuit_size, const size_t start_index=0)
Construct the polynomial whose components are the inverse of the product of the read and write terms...
static constexpr std::array< bool, 3 > SUBRELATION_LINEARLY_INDEPENDENT
static bool skip(const AllEntities &in)
static Accumulator compute_lookup_term(const AllEntities &in, const Parameters ¶ms)
static auto & get_inverse_polynomial(AllEntities &in)
static constexpr size_t BOOLEAN_CHECK_SUBRELATION_LENGTH
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
Entry point for Barretenberg command-line interface.
size_t calculate_num_threads(size_t num_iterations, size_t min_iterations_per_thread)
calculates number of threads to create based on minimum iterations per thread
void parallel_for(size_t num_iterations, const std::function< void(size_t)> &func)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
auto range(size_t size, size_t offset=0) const
static void batch_invert(C &coeffs) noexcept
Batch invert a collection of field elements using Montgomery's trick.