From 49bdcef648d5aa127e40b015217aa11ac0f53973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 28 Apr 2010 16:03:32 +0200 Subject: [PATCH] Preprocessor: replace non-standard operators 'and'/'or' by '&&'/'||' --- preprocessor/DynamicModel.cc | 14 +++++++------- preprocessor/ModelTree.cc | 14 ++++++++------ preprocessor/StaticModel.cc | 12 ++++++------ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc index 1e0a71dad..8d040ad4c 100644 --- a/preprocessor/DynamicModel.cc +++ b/preprocessor/DynamicModel.cc @@ -619,7 +619,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const ostringstream tmp_output; NodeID id = it->second.second; int lag = it->second.first; - if (eq >= block_recursive and var >= block_recursive) + if (eq >= block_recursive && var >= block_recursive) { if (lag == 0) Uf[eqr] << "+g1(" << eq+1-block_recursive @@ -1043,7 +1043,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin unsigned int eqr = getBlockEquationID(block, eq); unsigned int varr = getBlockVariableID(block, var); int lag = it->second.first; - if (eq >= block_recursive and var >= block_recursive) + if (eq >= block_recursive && var >= block_recursive) { if (!Uf[eqr].Ufl) { @@ -1279,7 +1279,7 @@ DynamicModel::Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const unsigned int eq = it->first.first; unsigned int var = it->first.second; 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; SaveCode.write(reinterpret_cast(&v), sizeof(v)); @@ -2208,7 +2208,7 @@ DynamicModel::get_Derivatives(int block) 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 Derivatives[make_pair(make_pair(lag, make_pair(eq, var)), make_pair(eqr, varr))] = 1; else @@ -2247,7 +2247,7 @@ DynamicModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives) int block_size = getBlockSize(block); int block_nb_mfs = getBlockMfs(block); 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)); for (int i = 0; i < block_nb_recursives; i++) @@ -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))]))); } } - else if (simulation_type == SOLVE_BACKWARD_SIMPLE or simulation_type == SOLVE_FORWARD_SIMPLE - or simulation_type == SOLVE_BACKWARD_COMPLETE or simulation_type == SOLVE_FORWARD_COMPLETE) + else if (simulation_type == SOLVE_BACKWARD_SIMPLE || simulation_type == SOLVE_FORWARD_SIMPLE + || simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_FORWARD_COMPLETE) { blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0)); for (int i = 0; i < block_nb_recursives; i++) diff --git a/preprocessor/ModelTree.cc b/preprocessor/ModelTree.cc index afd4f8c1c..2e2c403e6 100644 --- a/preprocessor/ModelTree.cc +++ b/preprocessor/ModelTree.cc @@ -582,9 +582,11 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(jacob_map & { for (int i = 0; i < n; i++) 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 - or equation_lag_lead[equation_reordered[i+prologue]].second > 0 or equation_lag_lead[equation_reordered[i+prologue]].first > 0 - or mfs == 0) + || variable_lag_lead[variable_reordered[i+prologue]].second > 0 + || variable_lag_lead[variable_reordered[i+prologue]].first > 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); } else @@ -737,7 +739,7 @@ ModelTree::reduceBlocksAndTypeDetermination(dynamic_jacob_map &dynamic_jacobian, } 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) Simulation_Type = EVALUATE_BACKWARD; @@ -746,8 +748,8 @@ ModelTree::reduceBlocksAndTypeDetermination(dynamic_jacob_map &dynamic_jacobian, } if (i > 0) { - if ((prev_Type == EVALUATE_FORWARD and Simulation_Type == EVALUATE_FORWARD) - or (prev_Type == EVALUATE_BACKWARD and Simulation_Type == EVALUATE_BACKWARD)) + if ((prev_Type == EVALUATE_FORWARD && Simulation_Type == EVALUATE_FORWARD) + || (prev_Type == EVALUATE_BACKWARD && Simulation_Type == EVALUATE_BACKWARD)) { //merge the current block with the previous one BlockSimulationType c_Type = (block_type_size_mfs[block_type_size_mfs.size()-1]).first.first; diff --git a/preprocessor/StaticModel.cc b/preprocessor/StaticModel.cc index a22a3ffc1..1d2f3596a 100644 --- a/preprocessor/StaticModel.cc +++ b/preprocessor/StaticModel.cc @@ -694,7 +694,7 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string unsigned int var = it->first.second; unsigned int eqr = getBlockEquationID(block, eq); 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) { @@ -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 var = it->first.second; int lag = 0; - if (eq >= block_recursive and var >= block_recursive) + if (eq >= block_recursive && var >= block_recursive) { int v = eq - block_recursive; SaveCode.write(reinterpret_cast(&v), sizeof(v)); @@ -1173,7 +1173,7 @@ StaticModel::get_Derivatives(int block) 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 Derivatives[make_pair(make_pair(lag, make_pair(eq, var)), make_pair(eqr, varr))] = 1; else @@ -1212,7 +1212,7 @@ StaticModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives) int block_size = getBlockSize(block); int block_nb_mfs = getBlockMfs(block); 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)); for (int i = 0; i < block_nb_recursives; i++) @@ -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))]))); } } - else if (simulation_type == SOLVE_BACKWARD_SIMPLE or simulation_type == SOLVE_FORWARD_SIMPLE - or simulation_type == SOLVE_BACKWARD_COMPLETE or simulation_type == SOLVE_FORWARD_COMPLETE) + else if (simulation_type == SOLVE_BACKWARD_SIMPLE || simulation_type == SOLVE_FORWARD_SIMPLE + || simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_FORWARD_COMPLETE) { blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0)); for (int i = 0; i < block_nb_recursives; i++)