trunk preprocessor: cosmetic changes
git-svn-id: https://www.dynare.org/svn/dynare/trunk@2614 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
b775f1812c
commit
d55470ca88
|
@ -487,12 +487,6 @@ DataTree::getDerivID(int symb_id, int lag) const throw (UnknownDerivIDException)
|
|||
throw UnknownDerivIDException();
|
||||
}
|
||||
|
||||
int
|
||||
DataTree::getDerivIDNbr() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
DataTree::getDynJacobianCol(int deriv_id) const throw (UnknownDerivIDException)
|
||||
{
|
||||
|
|
|
@ -183,9 +183,6 @@ public:
|
|||
|
||||
//! Returns the derivation ID, or throws an exception if the derivation ID does not exist
|
||||
virtual int getDerivID(int symb_id, int lag) const throw (UnknownDerivIDException);
|
||||
//! Returns the total number of derivation IDs
|
||||
/*! Valid derivation IDs are between 0 and getDerivIDNbr()-1 */
|
||||
virtual int getDerivIDNbr() const;
|
||||
//! Returns the column of the dynamic Jacobian associated to a derivation ID
|
||||
virtual int getDynJacobianCol(int deriv_id) const throw (UnknownDerivIDException);
|
||||
};
|
||||
|
|
|
@ -2164,11 +2164,12 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
|
|||
|
||||
// Compute derivatives w.r. to all endogenous, and possibly exogenous and exogenous deterministic
|
||||
set<int> vars;
|
||||
for(int i = 0; i < getDerivIDNbr(); i++)
|
||||
for(deriv_id_table_t::const_iterator it = deriv_id_table.begin();
|
||||
it != deriv_id_table.end(); it++)
|
||||
{
|
||||
SymbolType type = getTypeByDerivID(i);
|
||||
SymbolType type = symbol_table.getType(it->first.first);
|
||||
if (type == eEndogenous || (jacobianExo && (type == eExogenous || type == eExogenousDet)))
|
||||
vars.insert(i);
|
||||
vars.insert(it->second);
|
||||
}
|
||||
|
||||
// Launch computations
|
||||
|
@ -2334,7 +2335,7 @@ DynamicModel::getTypeByDerivID(int deriv_id) const throw (UnknownDerivIDExceptio
|
|||
int
|
||||
DynamicModel::getLagByDerivID(int deriv_id) const throw (UnknownDerivIDException)
|
||||
{
|
||||
if (deriv_id < 0 || deriv_id >= getDerivIDNbr())
|
||||
if (deriv_id < 0 || deriv_id >= (int) inv_deriv_id_table.size())
|
||||
throw UnknownDerivIDException();
|
||||
|
||||
return inv_deriv_id_table[deriv_id].second;
|
||||
|
@ -2343,7 +2344,7 @@ DynamicModel::getLagByDerivID(int deriv_id) const throw (UnknownDerivIDException
|
|||
int
|
||||
DynamicModel::getSymbIDByDerivID(int deriv_id) const throw (UnknownDerivIDException)
|
||||
{
|
||||
if (deriv_id < 0 || deriv_id >= getDerivIDNbr())
|
||||
if (deriv_id < 0 || deriv_id >= (int) inv_deriv_id_table.size())
|
||||
throw UnknownDerivIDException();
|
||||
|
||||
return inv_deriv_id_table[deriv_id].first;
|
||||
|
@ -2359,12 +2360,6 @@ DynamicModel::getDerivID(int symb_id, int lag) const throw (UnknownDerivIDExcept
|
|||
return it->second;
|
||||
}
|
||||
|
||||
int
|
||||
DynamicModel::getDerivIDNbr() const
|
||||
{
|
||||
return deriv_id_table.size();
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::computeDynJacobianCols(bool jacobianExo)
|
||||
{
|
||||
|
@ -2430,17 +2425,20 @@ DynamicModel::getDynJacobianCol(int deriv_id) const throw (UnknownDerivIDExcepti
|
|||
void
|
||||
DynamicModel::computeParamsDerivatives()
|
||||
{
|
||||
for (int param = 0; param < getDerivIDNbr(); param++)
|
||||
for(deriv_id_table_t::const_iterator it = deriv_id_table.begin();
|
||||
it != deriv_id_table.end(); it++)
|
||||
{
|
||||
if (getTypeByDerivID(param) != eParameter)
|
||||
if (symbol_table.getType(it->first.first) != eParameter)
|
||||
continue;
|
||||
|
||||
for (first_derivatives_type::const_iterator it = first_derivatives.begin();
|
||||
it != first_derivatives.end(); it++)
|
||||
int param = it->second;
|
||||
|
||||
for (first_derivatives_type::const_iterator it2 = first_derivatives.begin();
|
||||
it2 != first_derivatives.end(); it2++)
|
||||
{
|
||||
int eq = it->first.first;
|
||||
int var = it->first.second;
|
||||
NodeID d1 = it->second;
|
||||
int eq = it2->first.first;
|
||||
int var = it2->first.second;
|
||||
NodeID d1 = it2->second;
|
||||
|
||||
NodeID d2 = d1->getDerivative(param);
|
||||
if (d2 == Zero)
|
||||
|
|
|
@ -147,7 +147,6 @@ public:
|
|||
/*! It assumes that the static model given in argument has just been allocated */
|
||||
void toStatic(StaticModel &static_model) const;
|
||||
virtual int getDerivID(int symb_id, int lag) const throw (UnknownDerivIDException);
|
||||
virtual int getDerivIDNbr() const;
|
||||
virtual int getDynJacobianCol(int deriv_id) const throw (UnknownDerivIDException);
|
||||
};
|
||||
|
||||
|
|
|
@ -204,7 +204,6 @@ private:
|
|||
const SymbolType type;
|
||||
const int lag;
|
||||
//! Derivation ID
|
||||
/*! It is comprised between 0 and datatree.getDerivIDNbr()-1, or can be -1 if we don't derive w.r. to this variable */
|
||||
const int deriv_id;
|
||||
virtual NodeID computeDerivative(int deriv_id_arg);
|
||||
public:
|
||||
|
|
|
@ -251,7 +251,7 @@ LoadParamsAndSteadyStateStatement::LoadParamsAndSteadyStateStatement(const strin
|
|||
const SymbolTable &symbol_table_arg) :
|
||||
symbol_table(symbol_table_arg)
|
||||
{
|
||||
cout << "Reading " << filename << " ...";
|
||||
cout << "Reading " << filename << "." << endl;
|
||||
|
||||
ifstream f;
|
||||
f.open(filename.c_str(), ios::in);
|
||||
|
|
|
@ -138,7 +138,7 @@ StaticModel::writeStaticModel(ostream &StaticOutput) const
|
|||
it != first_derivatives.end(); it++)
|
||||
{
|
||||
int eq = it->first.first;
|
||||
int symb_id = inv_deriv_id_table[it->first.second];
|
||||
int symb_id = it->first.second;
|
||||
NodeID d1 = it->second;
|
||||
|
||||
ostringstream g1;
|
||||
|
@ -155,8 +155,8 @@ StaticModel::writeStaticModel(ostream &StaticOutput) const
|
|||
it != second_derivatives.end(); it++)
|
||||
{
|
||||
int eq = it->first.first;
|
||||
int symb_id1 = inv_deriv_id_table[it->first.second.first];
|
||||
int symb_id2 = inv_deriv_id_table[it->first.second.second];
|
||||
int symb_id1 = it->first.second.first;
|
||||
int symb_id2 = it->first.second.second;
|
||||
NodeID d2 = it->second;
|
||||
|
||||
int tsid1 = symbol_table.getTypeSpecificID(symb_id1);
|
||||
|
@ -268,10 +268,10 @@ StaticModel::writeStaticFile(const string &basename) const
|
|||
void
|
||||
StaticModel::computingPass(bool hessian, bool no_tmp_terms)
|
||||
{
|
||||
// Compute derivatives w.r. to all derivation IDs (i.e. all endogenous)
|
||||
// Compute derivatives w.r. to all endogenous
|
||||
set<int> vars;
|
||||
for(int i = 0; i < getDerivIDNbr(); i++)
|
||||
vars.insert(i);
|
||||
for(int i = 0; i < symbol_table.endo_nbr(); i++)
|
||||
vars.insert(symbol_table.getID(eEndogenous, i));
|
||||
|
||||
// Launch computations
|
||||
cout << "Computing static model derivatives:" << endl
|
||||
|
@ -291,35 +291,17 @@ StaticModel::computingPass(bool hessian, bool no_tmp_terms)
|
|||
int
|
||||
StaticModel::computeDerivID(int symb_id, int lag)
|
||||
{
|
||||
// Only create derivation ID for endogenous
|
||||
if (symbol_table.getType(symb_id) != eEndogenous)
|
||||
if (symbol_table.getType(symb_id) == eEndogenous)
|
||||
return symb_id;
|
||||
else
|
||||
return -1;
|
||||
|
||||
deriv_id_table_t::const_iterator it = deriv_id_table.find(symb_id);
|
||||
if (it != deriv_id_table.end())
|
||||
return it->second;
|
||||
|
||||
// Create a new deriv_id
|
||||
int deriv_id = deriv_id_table.size();
|
||||
|
||||
deriv_id_table[symb_id] = deriv_id;
|
||||
inv_deriv_id_table.push_back(symb_id);
|
||||
|
||||
return deriv_id;
|
||||
}
|
||||
|
||||
int
|
||||
StaticModel::getDerivID(int symb_id, int lag) const throw (UnknownDerivIDException)
|
||||
{
|
||||
deriv_id_table_t::const_iterator it = deriv_id_table.find(symb_id);
|
||||
if (it == deriv_id_table.end())
|
||||
throw UnknownDerivIDException();
|
||||
if (symbol_table.getType(symb_id) == eEndogenous)
|
||||
return symb_id;
|
||||
else
|
||||
return it->second;
|
||||
}
|
||||
|
||||
int
|
||||
StaticModel::getDerivIDNbr() const
|
||||
{
|
||||
return deriv_id_table.size();
|
||||
throw UnknownDerivIDException();
|
||||
}
|
||||
|
|
|
@ -25,15 +25,10 @@ using namespace std;
|
|||
#include "ModelTree.hh"
|
||||
|
||||
//! Stores a static model
|
||||
/*! Derivation IDs are allocated only for endogenous, and are equal to symbol ID in that case */
|
||||
class StaticModel : public ModelTree
|
||||
{
|
||||
private:
|
||||
typedef map<int, int> deriv_id_table_t;
|
||||
//! Maps a symbol ID to a derivation ID
|
||||
deriv_id_table_t deriv_id_table;
|
||||
//! Maps a derivation ID to a symbol ID
|
||||
vector<int> inv_deriv_id_table;
|
||||
|
||||
//! Writes the static model equations and its derivatives
|
||||
/*! \todo handle hessian in C output */
|
||||
void writeStaticModel(ostream &StaticOutput) const;
|
||||
|
@ -55,7 +50,6 @@ public:
|
|||
void writeStaticFile(const string &basename) const;
|
||||
|
||||
virtual int getDerivID(int symb_id, int lag) const throw (UnknownDerivIDException);
|
||||
virtual int getDerivIDNbr() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue