From e880a440b1583014f267a9b7a9410a273cc69fe4 Mon Sep 17 00:00:00 2001 From: Christian Krause Date: Sun, 17 Dec 2023 13:11:34 +0100 Subject: [PATCH] store num initial terms in map --- src/form/formula_gen.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/form/formula_gen.cpp b/src/form/formula_gen.cpp index 9f68742b..ebcc5dac 100644 --- a/src/form/formula_gen.cpp +++ b/src/form/formula_gen.cpp @@ -1,5 +1,6 @@ #include "form/formula_gen.hpp" +#include #include #include @@ -256,12 +257,12 @@ bool FormulaGenerator::generateSingle(const Program& p) { simplifyFormulaUsingAlternatives(formula); // determine number of initial terms needed - std::vector numTerms(numCells); + std::map numTerms; int64_t maxNumTerms = 0; for (int64_t cell = 0; cell < numCells; cell++) { - numTerms[cell] = - getNumInitialTermsNeeded(cell, getCellName(cell), formula, ie); - maxNumTerms = std::max(maxNumTerms, numTerms[cell]); + auto name = getCellName(cell); + numTerms[name] = getNumInitialTermsNeeded(cell, name, formula, ie); + maxNumTerms = std::max(maxNumTerms, numTerms[name]); } // evaluate program and add initial terms to formula @@ -274,8 +275,9 @@ bool FormulaGenerator::generateSingle(const Program& p) { } const auto state = ie.getLoopStates().at(ie.getPreviousSlice()); for (int64_t cell = 0; cell < numCells; cell++) { - if (offset < numTerms[cell]) { - Expression func(Expression::Type::FUNCTION, getCellName(cell), + auto name = getCellName(cell); + if (offset < numTerms[name]) { + Expression func(Expression::Type::FUNCTION, name, {ExpressionUtil::newConstant(offset)}); Expression val(Expression::Type::CONSTANT, "", state.get(cell)); formula.entries[func] = val;