Skip to content

Commit

Permalink
Count properly the prime variables by order
Browse files Browse the repository at this point in the history
  • Loading branch information
iomaganaris committed Oct 18, 2023
1 parent 420fb2d commit 551f366
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/codegen/codegen_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2598,7 +2598,15 @@ void CodegenCppVisitor::print_mechanism_global_var_structure(bool print_initiali
}

if (info.primes_size != 0) {
if (info.primes_size != info.prime_variables_by_order.size()) {
const auto count_prime_variables = [](auto size, const SymbolType& symbol) {
return size += symbol->get_length();
};
const auto prime_variables_by_order_size =
std::accumulate(info.prime_variables_by_order.begin(),
info.prime_variables_by_order.end(),
0,
count_prime_variables);
if (info.primes_size != prime_variables_by_order_size) {
throw std::runtime_error{
fmt::format("primes_size = {} differs from prime_variables_by_order.size() = {}, "
"this should not happen.",
Expand Down

0 comments on commit 551f366

Please sign in to comment.