From 47c22072f01ace50484e130b3fa47086593b3015 Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Mon, 31 Mar 2008 16:19:16 +0000
Subject: [PATCH] v4 matlab+preprocessor: the three homotopy modes should now
 work

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1769 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 NumericalInitialization.cc         | 30 +++++++++---------------------
 ParsingDriver.cc                   |  3 +--
 include/CodeInterpreter.hh         |  2 +-
 include/NumericalInitialization.hh |  2 +-
 4 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/NumericalInitialization.cc b/NumericalInitialization.cc
index c1e36a51..b7783141 100644
--- a/NumericalInitialization.cc
+++ b/NumericalInitialization.cc
@@ -154,7 +154,7 @@ HistValStatement::writeOutput(ostream &output, const string &basename) const
 }
 
 HomotopyStatement::HomotopyStatement(const homotopy_values_type &homotopy_values_arg,
-                                   const SymbolTable &symbol_table_arg) :
+                                     const SymbolTable &symbol_table_arg) :
   homotopy_values(homotopy_values_arg),
   symbol_table(symbol_table_arg)
 {
@@ -163,11 +163,10 @@ HomotopyStatement::HomotopyStatement(const homotopy_values_type &homotopy_values
 void
 HomotopyStatement::writeOutput(ostream &output, const string &basename) const
 {
-  output << interfaces::comment() << "\n" << interfaces::comment() << "HOMOTOPY_SETUP instructions\n"
-         << interfaces::comment() << "\n";
-  output << "homotopy_param = {};" << endl; 
-  output << "homotopy_exo = {};" << endl; 
-  output << "homotopy_exodet = {};" << endl; 
+  output << interfaces::comment() << endl
+         << interfaces::comment() << "HOMOTOPY_SETUP instructions" << endl
+         << interfaces::comment() << endl
+         << "options_.homotopy_values = [];" << endl;
 
   for(homotopy_values_type::const_iterator it = homotopy_values.begin();
       it != homotopy_values.end(); it++)
@@ -176,24 +175,13 @@ HomotopyStatement::writeOutput(ostream &output, const string &basename) const
       const NodeID expression1 = it->second.first;
       const NodeID expression2 = it->second.second;
 
-      Type type = symbol_table.getType(name);
+      const Type type = symbol_table.getType(name);
+      const int id = symbol_table.getID(name) + 1;
 
-      if (type == eParameter)
-        output << "homotopy_param = vertcat(homotopy_param,{ '" << name << "', ";
-      else if (type == eExogenous)
-        output << "homotopy_exo = vertcat(homotopy_exo,{ '" << name << "', ";
-      else if (type != eExogenousDet)
-        output << "homotopy_exodet = vertcat(homotopy_exodet,{ '" << name << "', ";
-
-        
+      output << "options_.homotopy_values = vertcat(options_.homotopy_values, [ " << type << ", " << id << ", ";
       expression1->writeOutput(output);
       output << ", ";
       expression2->writeOutput(output);
-      output << "});" << endl;
+      output << "]);" << endl;
     }
-  
-  output << "options_.homotopy_param = homotopy_param;" << endl;
-  output << "options_.homotopy_exo = homotopy_exo;" << endl;
-  output << "options_.homotopy_exodet = homotopy_exodet;" << endl;
 }
-
diff --git a/ParsingDriver.cc b/ParsingDriver.cc
index 272ebab7..eec83386 100644
--- a/ParsingDriver.cc
+++ b/ParsingDriver.cc
@@ -350,8 +350,7 @@ ParsingDriver::homotopy_val(string *name, NodeID val1, NodeID val2)
   if (homotopy_values.find(*name) != homotopy_values.end())
     error("homotopy_val: " + *name +" declared twice");
 
-  pair<NodeID, NodeID> expressions(val1, val2);
-  homotopy_values[*name] = expressions;
+  homotopy_values[*name] = make_pair(val1, val2);
 
   delete name;
 }
diff --git a/include/CodeInterpreter.hh b/include/CodeInterpreter.hh
index 237d577f..4c3df347 100644
--- a/include/CodeInterpreter.hh
+++ b/include/CodeInterpreter.hh
@@ -58,7 +58,7 @@ const int EVALUATE_FOREWARD_R=8;
 const int EVALUATE_BACKWARD_R=9;
 
 //! Enumeration of possible symbol types
-/*! Warning: do not to change the order of the enumeration, it matters for VariableTable (at least ensure that eEndogenous is the first one) */
+/*! Warning: do not to change existing values: the order matters for VariableTable (at least ensure that eEndogenous is the first one), and the values matter for homotopy_setup command */
 enum Type
   {
     eEndogenous = 0,               //!< Endogenous
diff --git a/include/NumericalInitialization.hh b/include/NumericalInitialization.hh
index 1dfcdab5..f920c967 100644
--- a/include/NumericalInitialization.hh
+++ b/include/NumericalInitialization.hh
@@ -105,7 +105,7 @@ private:
   const SymbolTable &symbol_table;
 public:
   HomotopyStatement(const homotopy_values_type &homotopy_values_arg,
-		    const SymbolTable &symbol_table_arg);
+                    const SymbolTable &symbol_table_arg);
   virtual void writeOutput(ostream &output, const string &basename) const;
 };
 #endif
-- 
GitLab