Commit c47b6e6e authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Fix bug with notmpterms option

Commit c6cb9aa1 was not the right fix.
parent 9043efab
Pipeline #198 passed with stage
in 1 minute and 35 seconds
...@@ -1256,36 +1256,34 @@ ModelTree::computeTemporaryTerms(bool is_matlab, bool no_tmp_terms) ...@@ -1256,36 +1256,34 @@ ModelTree::computeTemporaryTerms(bool is_matlab, bool no_tmp_terms)
reference_count[v] = { ExprNode::min_cost(is_matlab)+1, NodeTreeReference::residuals }; reference_count[v] = { ExprNode::min_cost(is_matlab)+1, NodeTreeReference::residuals };
} }
/* When option notmpterms is set, we only need to process model local
variables (and turn them into temporary terms); no need to go further */
if (no_tmp_terms)
return;
map<NodeTreeReference, temporary_terms_t> temp_terms_map; map<NodeTreeReference, temporary_terms_t> temp_terms_map;
temp_terms_map[NodeTreeReference::residuals] = temporary_terms_res; temp_terms_map[NodeTreeReference::residuals] = temporary_terms_res;
temp_terms_map[NodeTreeReference::firstDeriv] = temporary_terms_g1; temp_terms_map[NodeTreeReference::firstDeriv] = temporary_terms_g1;
temp_terms_map[NodeTreeReference::secondDeriv] = temporary_terms_g2; temp_terms_map[NodeTreeReference::secondDeriv] = temporary_terms_g2;
temp_terms_map[NodeTreeReference::thirdDeriv] = temporary_terms_g3; temp_terms_map[NodeTreeReference::thirdDeriv] = temporary_terms_g3;
for (auto & equation : equations) if (!no_tmp_terms)
equation->computeTemporaryTerms(reference_count, {
temp_terms_map, for (auto & equation : equations)
is_matlab, NodeTreeReference::residuals); equation->computeTemporaryTerms(reference_count,
temp_terms_map,
for (auto & first_derivative : first_derivatives) is_matlab, NodeTreeReference::residuals);
first_derivative.second->computeTemporaryTerms(reference_count,
temp_terms_map, for (auto & first_derivative : first_derivatives)
is_matlab, NodeTreeReference::firstDeriv); first_derivative.second->computeTemporaryTerms(reference_count,
temp_terms_map,
for (auto & second_derivative : second_derivatives) is_matlab, NodeTreeReference::firstDeriv);
second_derivative.second->computeTemporaryTerms(reference_count,
temp_terms_map, for (auto & second_derivative : second_derivatives)
is_matlab, NodeTreeReference::secondDeriv); second_derivative.second->computeTemporaryTerms(reference_count,
temp_terms_map,
for (auto & third_derivative : third_derivatives) is_matlab, NodeTreeReference::secondDeriv);
third_derivative.second->computeTemporaryTerms(reference_count,
temp_terms_map, for (auto & third_derivative : third_derivatives)
is_matlab, NodeTreeReference::thirdDeriv); third_derivative.second->computeTemporaryTerms(reference_count,
temp_terms_map,
is_matlab, NodeTreeReference::thirdDeriv);
}
for (map<NodeTreeReference, temporary_terms_t>::const_iterator it = temp_terms_map.begin(); for (map<NodeTreeReference, temporary_terms_t>::const_iterator it = temp_terms_map.begin();
it != temp_terms_map.end(); it++) it != temp_terms_map.end(); it++)
...@@ -1301,8 +1299,8 @@ ModelTree::computeTemporaryTerms(bool is_matlab, bool no_tmp_terms) ...@@ -1301,8 +1299,8 @@ ModelTree::computeTemporaryTerms(bool is_matlab, bool no_tmp_terms)
it != temporary_terms_mlv.end(); it++) it != temporary_terms_mlv.end(); it++)
temporary_terms_idxs[it->first] = idx++; temporary_terms_idxs[it->first] = idx++;
for (auto temporary_terms_re : temporary_terms_res) for (auto it : temporary_terms_res)
temporary_terms_idxs[temporary_terms_re] = idx++; temporary_terms_idxs[it] = idx++;
for (auto it : temporary_terms_g1) for (auto it : temporary_terms_g1)
temporary_terms_idxs[it] = idx++; temporary_terms_idxs[it] = idx++;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment