Skip to content

Commit

Permalink
store num initial terms in map
Browse files Browse the repository at this point in the history
  • Loading branch information
ckrause committed Dec 17, 2023
1 parent 12c1f82 commit e880a44
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/form/formula_gen.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "form/formula_gen.hpp"

#include <map>
#include <set>
#include <stdexcept>

Expand Down Expand Up @@ -256,12 +257,12 @@ bool FormulaGenerator::generateSingle(const Program& p) {
simplifyFormulaUsingAlternatives(formula);

// determine number of initial terms needed
std::vector<int64_t> numTerms(numCells);
std::map<std::string, int64_t> 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
Expand All @@ -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;
Expand Down

0 comments on commit e880a44

Please sign in to comment.