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

Preprocessor: replace non-standard operators 'and'/'or' by '&&'/'||'

parent 956b42fd
...@@ -619,7 +619,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const ...@@ -619,7 +619,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
ostringstream tmp_output; ostringstream tmp_output;
NodeID id = it->second.second; NodeID id = it->second.second;
int lag = it->second.first; int lag = it->second.first;
if (eq >= block_recursive and var >= block_recursive) if (eq >= block_recursive && var >= block_recursive)
{ {
if (lag == 0) if (lag == 0)
Uf[eqr] << "+g1(" << eq+1-block_recursive Uf[eqr] << "+g1(" << eq+1-block_recursive
...@@ -1043,7 +1043,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin ...@@ -1043,7 +1043,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin
unsigned int eqr = getBlockEquationID(block, eq); unsigned int eqr = getBlockEquationID(block, eq);
unsigned int varr = getBlockVariableID(block, var); unsigned int varr = getBlockVariableID(block, var);
int lag = it->second.first; int lag = it->second.first;
if (eq >= block_recursive and var >= block_recursive) if (eq >= block_recursive && var >= block_recursive)
{ {
if (!Uf[eqr].Ufl) if (!Uf[eqr].Ufl)
{ {
...@@ -1279,7 +1279,7 @@ DynamicModel::Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const ...@@ -1279,7 +1279,7 @@ DynamicModel::Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const
unsigned int eq = it->first.first; unsigned int eq = it->first.first;
unsigned int var = it->first.second; unsigned int var = it->first.second;
int lag = it->second.first; int lag = it->second.first;
if (eq >= block_recursive and var >= block_recursive) if (eq >= block_recursive && var >= block_recursive)
{ {
int v = eq - block_recursive; int v = eq - block_recursive;
SaveCode.write(reinterpret_cast<char *>(&v), sizeof(v)); SaveCode.write(reinterpret_cast<char *>(&v), sizeof(v));
...@@ -2208,7 +2208,7 @@ DynamicModel::get_Derivatives(int block) ...@@ -2208,7 +2208,7 @@ DynamicModel::get_Derivatives(int block)
if (OK) if (OK)
{ {
if (getBlockEquationType(block, eq) == E_EVALUATE_S and eq < block_nb_recursive) if (getBlockEquationType(block, eq) == E_EVALUATE_S && eq < block_nb_recursive)
//It's a normalized equation, we have to recompute the derivative using chain rule derivative function //It's a normalized equation, we have to recompute the derivative using chain rule derivative function
Derivatives[make_pair(make_pair(lag, make_pair(eq, var)), make_pair(eqr, varr))] = 1; Derivatives[make_pair(make_pair(lag, make_pair(eq, var)), make_pair(eqr, varr))] = 1;
else else
...@@ -2247,7 +2247,7 @@ DynamicModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives) ...@@ -2247,7 +2247,7 @@ DynamicModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives)
int block_size = getBlockSize(block); int block_size = getBlockSize(block);
int block_nb_mfs = getBlockMfs(block); int block_nb_mfs = getBlockMfs(block);
int block_nb_recursives = block_size - block_nb_mfs; int block_nb_recursives = block_size - block_nb_mfs;
if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE or simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE) if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
{ {
blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0)); blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0));
for (int i = 0; i < block_nb_recursives; i++) for (int i = 0; i < block_nb_recursives; i++)
...@@ -2283,8 +2283,8 @@ DynamicModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives) ...@@ -2283,8 +2283,8 @@ DynamicModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives)
tmp_derivatives.push_back(make_pair(make_pair(eq, var), make_pair(lag, first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))]))); tmp_derivatives.push_back(make_pair(make_pair(eq, var), make_pair(lag, first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))])));
} }
} }
else if (simulation_type == SOLVE_BACKWARD_SIMPLE or simulation_type == SOLVE_FORWARD_SIMPLE else if (simulation_type == SOLVE_BACKWARD_SIMPLE || simulation_type == SOLVE_FORWARD_SIMPLE
or simulation_type == SOLVE_BACKWARD_COMPLETE or simulation_type == SOLVE_FORWARD_COMPLETE) || simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_FORWARD_COMPLETE)
{ {
blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0)); blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0));
for (int i = 0; i < block_nb_recursives; i++) for (int i = 0; i < block_nb_recursives; i++)
......
...@@ -582,9 +582,11 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(jacob_map & ...@@ -582,9 +582,11 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(jacob_map &
{ {
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
if (Equation_Type[equation_reordered[i+prologue]].first == E_SOLVE if (Equation_Type[equation_reordered[i+prologue]].first == E_SOLVE
or variable_lag_lead[variable_reordered[i+prologue]].second > 0 or variable_lag_lead[variable_reordered[i+prologue]].first > 0 || variable_lag_lead[variable_reordered[i+prologue]].second > 0
or equation_lag_lead[equation_reordered[i+prologue]].second > 0 or equation_lag_lead[equation_reordered[i+prologue]].first > 0 || variable_lag_lead[variable_reordered[i+prologue]].first > 0
or mfs == 0) || equation_lag_lead[equation_reordered[i+prologue]].second > 0
|| equation_lag_lead[equation_reordered[i+prologue]].first > 0
|| mfs == 0)
add_edge(i, i, G2); add_edge(i, i, G2);
} }
else else
...@@ -737,7 +739,7 @@ ModelTree::reduceBlocksAndTypeDetermination(dynamic_jacob_map &dynamic_jacobian, ...@@ -737,7 +739,7 @@ ModelTree::reduceBlocksAndTypeDetermination(dynamic_jacob_map &dynamic_jacobian,
} }
if (Blck_Size == 1) if (Blck_Size == 1)
{ {
if (Equation_Type[equation_reordered[eq]].first == E_EVALUATE or Equation_Type[equation_reordered[eq]].first == E_EVALUATE_S) if (Equation_Type[equation_reordered[eq]].first == E_EVALUATE || Equation_Type[equation_reordered[eq]].first == E_EVALUATE_S)
{ {
if (Simulation_Type == SOLVE_BACKWARD_SIMPLE) if (Simulation_Type == SOLVE_BACKWARD_SIMPLE)
Simulation_Type = EVALUATE_BACKWARD; Simulation_Type = EVALUATE_BACKWARD;
...@@ -746,8 +748,8 @@ ModelTree::reduceBlocksAndTypeDetermination(dynamic_jacob_map &dynamic_jacobian, ...@@ -746,8 +748,8 @@ ModelTree::reduceBlocksAndTypeDetermination(dynamic_jacob_map &dynamic_jacobian,
} }
if (i > 0) if (i > 0)
{ {
if ((prev_Type == EVALUATE_FORWARD and Simulation_Type == EVALUATE_FORWARD) if ((prev_Type == EVALUATE_FORWARD && Simulation_Type == EVALUATE_FORWARD)
or (prev_Type == EVALUATE_BACKWARD and Simulation_Type == EVALUATE_BACKWARD)) || (prev_Type == EVALUATE_BACKWARD && Simulation_Type == EVALUATE_BACKWARD))
{ {
//merge the current block with the previous one //merge the current block with the previous one
BlockSimulationType c_Type = (block_type_size_mfs[block_type_size_mfs.size()-1]).first.first; BlockSimulationType c_Type = (block_type_size_mfs[block_type_size_mfs.size()-1]).first.first;
......
...@@ -694,7 +694,7 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string ...@@ -694,7 +694,7 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string
unsigned int var = it->first.second; unsigned int var = it->first.second;
unsigned int eqr = getBlockEquationID(block, eq); unsigned int eqr = getBlockEquationID(block, eq);
unsigned int varr = getBlockVariableID(block, var); unsigned int varr = getBlockVariableID(block, var);
if (eq >= block_recursive and var >= block_recursive) if (eq >= block_recursive && var >= block_recursive)
{ {
if (!Uf[eqr].Ufl) if (!Uf[eqr].Ufl)
{ {
...@@ -793,7 +793,7 @@ StaticModel::Write_Inf_To_Bin_File_Block(const string &static_basename, const st ...@@ -793,7 +793,7 @@ StaticModel::Write_Inf_To_Bin_File_Block(const string &static_basename, const st
unsigned int eq = it->first.first; unsigned int eq = it->first.first;
unsigned int var = it->first.second; unsigned int var = it->first.second;
int lag = 0; int lag = 0;
if (eq >= block_recursive and var >= block_recursive) if (eq >= block_recursive && var >= block_recursive)
{ {
int v = eq - block_recursive; int v = eq - block_recursive;
SaveCode.write(reinterpret_cast<char *>(&v), sizeof(v)); SaveCode.write(reinterpret_cast<char *>(&v), sizeof(v));
...@@ -1173,7 +1173,7 @@ StaticModel::get_Derivatives(int block) ...@@ -1173,7 +1173,7 @@ StaticModel::get_Derivatives(int block)
if (OK) if (OK)
{ {
if (getBlockEquationType(block, eq) == E_EVALUATE_S and eq < block_nb_recursive) if (getBlockEquationType(block, eq) == E_EVALUATE_S && eq < block_nb_recursive)
//It's a normalized equation, we have to recompute the derivative using chain rule derivative function //It's a normalized equation, we have to recompute the derivative using chain rule derivative function
Derivatives[make_pair(make_pair(lag, make_pair(eq, var)), make_pair(eqr, varr))] = 1; Derivatives[make_pair(make_pair(lag, make_pair(eq, var)), make_pair(eqr, varr))] = 1;
else else
...@@ -1212,7 +1212,7 @@ StaticModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives) ...@@ -1212,7 +1212,7 @@ StaticModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives)
int block_size = getBlockSize(block); int block_size = getBlockSize(block);
int block_nb_mfs = getBlockMfs(block); int block_nb_mfs = getBlockMfs(block);
int block_nb_recursives = block_size - block_nb_mfs; int block_nb_recursives = block_size - block_nb_mfs;
if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE or simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE) if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
{ {
blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0)); blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0));
for (int i = 0; i < block_nb_recursives; i++) for (int i = 0; i < block_nb_recursives; i++)
...@@ -1248,8 +1248,8 @@ StaticModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives) ...@@ -1248,8 +1248,8 @@ StaticModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives)
tmp_derivatives.push_back(make_pair(make_pair(eq, var), make_pair(lag, first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))]))); tmp_derivatives.push_back(make_pair(make_pair(eq, var), make_pair(lag, first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))])));
} }
} }
else if (simulation_type == SOLVE_BACKWARD_SIMPLE or simulation_type == SOLVE_FORWARD_SIMPLE else if (simulation_type == SOLVE_BACKWARD_SIMPLE || simulation_type == SOLVE_FORWARD_SIMPLE
or simulation_type == SOLVE_BACKWARD_COMPLETE or simulation_type == SOLVE_FORWARD_COMPLETE) || simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_FORWARD_COMPLETE)
{ {
blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0)); blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0));
for (int i = 0; i < block_nb_recursives; i++) for (int i = 0; i < block_nb_recursives; i++)
......
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