Commit 723b260f authored by sebastien's avatar sebastien
Browse files

trunk preprocessor: automatic reindentation of all code with emacs

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2372 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 867daedd
......@@ -418,7 +418,7 @@ BlockTriangular::Allocate_Block(int size, int *count_Equ, int count_Block, Block
void
BlockTriangular::Free_Block(Model_Block* ModelBlock) const
{
{
int blk, i;
for (blk = 0;blk < ModelBlock->Size;blk++)
{
......@@ -463,7 +463,7 @@ BlockTriangular::Free_Block(Model_Block* ModelBlock) const
free(ModelBlock);
free(Index_Equ_IM);
free(Index_Var_IM);
}
}
t_type
......
......@@ -18,10 +18,10 @@
*/
/*
Useful documentation: Matlab 7 Mat-File Format
-----------------------------------------------
revision: October 2008 PDF only Rereleased for Version 7.7 (Release 2008b)
available at: http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf
Useful documentation: Matlab 7 Mat-File Format
-----------------------------------------------
revision: October 2008 PDF only Rereleased for Version 7.7 (Release 2008b)
available at: http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf
*/
#include "MatlabFile.hh"
......@@ -1048,9 +1048,9 @@ MatlabFile::Delete()
}
/*
int
main(int argc, char** argv)
{
int
main(int argc, char** argv)
{
CollectStruct collect_struct;
MatlabFile matlab_file;
matlab_file.MatFileRead("gimf_steady.mat");
......@@ -1071,7 +1071,7 @@ main(int argc, char** argv)
cout << "\n";
}
}
}
}
*/
......@@ -55,32 +55,32 @@ ModelTree::ModelTree(SymbolTable &symbol_table_arg,
int
ModelTree::equation_number() const
{
{
return(equations.size());
}
}
void
ModelTree::writeDerivative(ostream &output, int eq, int symb_id, int lag,
ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms,
SymbolType type) const
{
{
first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, variable_table.getID(type, symb_id, lag)));
if (it != first_derivatives.end())
(it->second)->writeOutput(output, output_type, temporary_terms);
else
output << 0;
}
}
void
ModelTree::compileDerivative(ofstream &code_file, int eq, int symb_id, int lag, ExprNodeOutputType output_type, map_idx_type &map_idx) const
{
{
first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, variable_table.getID(eEndogenous, symb_id, lag)));
if (it != first_derivatives.end())
(it->second)->compile(code_file,false, output_type, temporary_terms, map_idx);
else
code_file.write(&FLDZ, sizeof(FLDZ));
}
}
void
......@@ -177,7 +177,7 @@ ModelTree::computeTemporaryTerms(int order)
void
ModelTree::writeTemporaryTerms(ostream &output, ExprNodeOutputType output_type) const
{
{
// A copy of temporary terms
temporary_terms_type tt2;
......@@ -203,11 +203,11 @@ ModelTree::writeTemporaryTerms(ostream &output, ExprNodeOutputType output_type)
}
if (!OFFSET(output_type))
output << ";" << endl;
}
}
void
ModelTree::writeModelLocalVariables(ostream &output, ExprNodeOutputType output_type) const
{
{
for (map<int, NodeID>::const_iterator it = local_variables_table.begin();
it != local_variables_table.end(); it++)
{
......@@ -222,7 +222,7 @@ ModelTree::writeModelLocalVariables(ostream &output, ExprNodeOutputType output_t
value->writeOutput(output, output_type, temporary_terms_type());
output << ";" << endl;
}
}
}
void
......@@ -255,7 +255,7 @@ ModelTree::BuildIncidenceMatrix()
void
ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type) const
{
{
for (int eq = 0; eq < (int) equations.size(); eq++)
{
BinaryOpNode *eq_node = equations[eq];
......@@ -272,7 +272,7 @@ ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type)
output << "residual" << LPAR(output_type) << eq + OFFSET(output_type) << RPAR(output_type) << "= lhs-rhs;" << endl;
}
}
}
void
ModelTree::computeTemporaryTermsOrdered(int order, Model_Block *ModelBlock)
......@@ -389,7 +389,7 @@ ModelTree::computeTemporaryTermsOrdered(int order, Model_Block *ModelBlock)
void
ModelTree::writeModelEquationsOrdered_M( Model_Block *ModelBlock, const string &dynamic_basename) const
{
{
int i,j,k,m;
string tmp_s, sps;
ostringstream tmp_output, tmp1_output, global_output;
......@@ -564,7 +564,7 @@ ModelTree::writeModelEquationsOrdered_M( Model_Block *ModelBlock, const string &
output << " residual(" << i+1 << ", it_) = (";
goto end;
default:
end:
end:
output << tmp_output.str();
output << ") - (";
rhs->writeOutput(output, oMatlabDynamicModelSparse, temporary_terms);
......@@ -860,11 +860,11 @@ end:
prev_Simulation_Type=ModelBlock->Block_List[j].Simulation_Type;
output.close();
}
}
}
void
ModelTree::writeModelStaticEquationsOrdered_M(Model_Block *ModelBlock, const string &static_basename) const
{
{
int i,j,k,m, var, eq, g1_index = 1;
string tmp_s, sps;
ostringstream tmp_output, tmp1_output, global_output;
......@@ -996,7 +996,7 @@ ModelTree::writeModelStaticEquationsOrdered_M(Model_Block *ModelBlock, const str
case SOLVE_TWO_BOUNDARIES_SIMPLE:
goto end;
default:
end:
end:
output << sps << "residual(" << i+1 << ") = (";
output << tmp_output.str();
output << ") - (";
......@@ -1078,12 +1078,12 @@ end:
output.close();
}
//output << "return;\n\n\n";
}
}
void
ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Block *ModelBlock, const string bin_basename, ExprNodeOutputType output_type, map_idx_type map_idx) const
{
{
struct Uff_l
{
int u, var, lag;
......@@ -1269,7 +1269,7 @@ ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Bl
Uf[v].Ufl=NULL;
goto end;
default:
end:
end:
lhs->compile(code_file,false, output_type, temporary_terms, map_idx);
rhs->compile(code_file,false, output_type, temporary_terms, map_idx);
code_file.write(&FBINARY, sizeof(FBINARY));
......@@ -1464,12 +1464,12 @@ end:
code_file.write(&FENDBLOCK, sizeof(FENDBLOCK));
code_file.write(&FEND, sizeof(FEND));
code_file.close();
}
}
void
ModelTree::writeStaticMFile(const string &static_basename) const
{
{
string filename = static_basename + ".m";
ofstream mStaticModelFile;
......@@ -1490,12 +1490,12 @@ ModelTree::writeStaticMFile(const string &static_basename) const
writeStaticModel(mStaticModelFile);
mStaticModelFile.close();
}
}
void
ModelTree::writeDynamicMFile(const string &dynamic_basename) const
{
{
string filename = dynamic_basename + ".m";
ofstream mDynamicModelFile;
......@@ -1515,11 +1515,11 @@ ModelTree::writeDynamicMFile(const string &dynamic_basename) const
writeDynamicModel(mDynamicModelFile);
mDynamicModelFile.close();
}
}
void
ModelTree::writeStaticCFile(const string &static_basename) const
{
{
string filename = static_basename + ".c";
ofstream mStaticModelFile;
......@@ -1580,11 +1580,11 @@ ModelTree::writeStaticCFile(const string &static_basename) const
<< "}" << endl;
mStaticModelFile.close();
}
}
void
ModelTree::writeDynamicCFile(const string &dynamic_basename) const
{
{
string filename = dynamic_basename + ".c";
ofstream mDynamicModelFile;
......@@ -1662,11 +1662,11 @@ ModelTree::writeDynamicCFile(const string &dynamic_basename) const
<< " Dynamic(y, x, nb_row_x, params, it_, residual, g1, g2);" << endl
<< "}" << endl;
mDynamicModelFile.close();
}
}
void
ModelTree::writeStaticModel(ostream &StaticOutput) const
{
{
ostringstream model_output; // Used for storing model equations
ostringstream jacobian_output; // Used for storing jacobian equations
ostringstream hessian_output;
......@@ -1801,11 +1801,11 @@ ModelTree::writeStaticModel(ostream &StaticOutput) const
<< " }" << endl
<< "}" << endl << endl;
}
}
}
string
ModelTree::reform(const string name1) const
{
{
string name=name1;
int pos = name.find("\\", 0);
while (pos >= 0)
......@@ -1819,12 +1819,12 @@ ModelTree::reform(const string name1) const
pos = name.find("\\", pos);
}
return (name);
}
}
void
ModelTree::Write_Inf_To_Bin_File(const string &dynamic_basename, const string &bin_basename, const int &num,
int &u_count_int, bool &file_open, bool is_two_boundaries) const
{
{
int j;
std::ofstream SaveCode;
if (file_open)
......@@ -1879,11 +1879,11 @@ ModelTree::Write_Inf_To_Bin_File(const string &dynamic_basename, const string &b
SaveCode.write(reinterpret_cast<char *>(&eqr1), sizeof(eqr1));
}
SaveCode.close();
}
}
void
ModelTree::writeSparseStaticMFile(const string &static_basename, const string &basename, const int mode) const
{
{
string filename;
ofstream mStaticModelFile;
ostringstream tmp, tmp1, tmp_eq;
......@@ -2099,11 +2099,11 @@ ModelTree::writeSparseStaticMFile(const string &static_basename, const string &b
writeModelStaticEquationsOrdered_M(block_triangular.ModelBlock, static_basename);
mStaticModelFile.close();
chdir("..");
}
}
void
ModelTree::writeSparseDynamicMFile(const string &dynamic_basename, const string &basename, const int mode) const
{
{
string sp;
ofstream mDynamicModelFile;
ostringstream tmp, tmp1, tmp_eq;
......@@ -2454,11 +2454,11 @@ ModelTree::writeSparseDynamicMFile(const string &dynamic_basename, const string
writeModelEquationsOrdered_M( block_triangular.ModelBlock, dynamic_basename);
chdir("..");
}
}
void
ModelTree::writeDynamicModel(ostream &DynamicOutput) const
{
{
ostringstream lsymetric; // Used when writing symetric elements in Hessian
ostringstream model_output; // Used for storing model equations
ostringstream jacobian_output; // Used for storing jacobian equations
......@@ -2657,11 +2657,11 @@ ModelTree::writeDynamicModel(ostream &DynamicOutput) const
}
DynamicOutput << "}" << endl << endl;
}
}
}
void
ModelTree::writeOutput(ostream &output) const
{
{
/* Writing initialisation for M_.lead_lag_incidence matrix
M_.lead_lag_incidence is a matrix with as many columns as there are
endogenous variables and as many rows as there are periods in the
......@@ -2885,7 +2885,7 @@ ModelTree::writeOutput(ostream &output) const
}
if (symbol_table.parameter_nbr)
output << "M_.params = repmat(NaN," << symbol_table.parameter_nbr << ", 1);\n";
}
}
void
ModelTree::addEquation(NodeID eq)
......@@ -3019,7 +3019,7 @@ ModelTree::BlockLinear(Model_Block *ModelBlock)
}
}
}
follow:
follow:
i=0;
}
}
......@@ -3069,7 +3069,7 @@ ModelTree::computingPass(const eval_context_type &eval_context, bool no_tmp_term
void
ModelTree::writeStaticFile(const string &basename) const
{
{
switch (mode)
{
case eStandardMode:
......@@ -3091,11 +3091,11 @@ ModelTree::writeStaticFile(const string &basename) const
writeStaticCFile(basename + "_static");
break;
}
}
}
void
ModelTree::writeDynamicFile(const string &basename) const
{
{
switch (mode)
{
case eStandardMode:
......@@ -3123,15 +3123,15 @@ ModelTree::writeDynamicFile(const string &basename) const
//block_triangular.Free_IM_X(block_triangular.First_IM_X);
break;
}
}
}
void
ModelTree::matrixHelper(ostream &output, int eq_nb, int col_nb, ExprNodeOutputType output_type) const
{
{
output << LPAR(output_type);
if (OFFSET(output_type))
output << eq_nb + 1 << ", " << col_nb + 1;
else
output << eq_nb + col_nb * equations.size();
output << RPAR(output_type);
}
}
......@@ -17,10 +17,10 @@
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Usefull documentation: Matlab 7 Mat-File Format
-----------------------------------------------
revision: October 2008 PDF only Rereleased for Version 7.7 (Release 2008b)
available at: http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf
Usefull documentation: Matlab 7 Mat-File Format
-----------------------------------------------
revision: October 2008 PDF only Rereleased for Version 7.7 (Release 2008b)
available at: http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf
*/
#ifndef _MAT_FILE_HH
......@@ -42,7 +42,7 @@ using namespace std;
enum Data_Type
{
{
miINT8 = 1, //8 bit, signed
miUINT8 = 2, //8 bit, unsigned
miINT16 = 3, //16-bit, signed
......@@ -58,10 +58,10 @@ enum Data_Type
miUTF8 = 16, //Unicode UTF-8 Encoded Character Data
miUTF16 = 17, //Unicode UTF-16 Encoded Character Data
miUTF32 = 18 //Unicode UTF-32 Encoded Character Data
};
};
enum Array_Type
{
{
Cell_array = 1,
Structure_ = 2,
Object_ = 3,
......@@ -75,17 +75,17 @@ enum Array_Type
Unsigned_integer_16_bit = 11,
Signed_integer_32_bit = 12,
Unsigned_integer_32_bit = 13
};
};
enum Function_Returned_Type
{
{
Numerical =1,
AlphaNumeric =2,
Matrix =3,
Compressed =4,
Unknown =5
};
};
class ArrayElem;
class SimpleElem;
......@@ -106,7 +106,7 @@ typedef struct Header
short int Version;
char Edian_Indicator[2];
}
Header_t;
Header_t;
typedef struct Data_Header
{
......@@ -114,7 +114,7 @@ typedef struct Data_Header
ShortInt DataType;
uLongInt Number_of_Bytes;
}
Data_Header_t;
Data_Header_t;
typedef struct Array_Flag
{
......@@ -124,7 +124,7 @@ typedef struct Array_Flag
char undef1[2];
uLongInt nzmax;
}
Array_Flag_t;
Array_Flag_t;
typedef struct returned_ReadData
......@@ -149,7 +149,7 @@ typedef struct CollectStruct
map<string,vector<string> > variable_string_name;
map<string,vector<double> > variable_double_name;
}
CollectStruct;
CollectStruct;
typedef vector<int> Array_Dimensions_t;
......@@ -294,7 +294,7 @@ public:
class CellArray : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -303,7 +303,7 @@ class CellArray : public ArrayElem
class Structure : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -312,7 +312,7 @@ class Structure : public ArrayElem
class Object : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -321,7 +321,7 @@ class Object : public ArrayElem
class CharacterArray : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -330,7 +330,7 @@ class CharacterArray : public ArrayElem
class SparseArray : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -339,7 +339,7 @@ class SparseArray : public ArrayElem
class DoublePrecisionArray : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -348,7 +348,7 @@ class DoublePrecisionArray : public ArrayElem
class SinglePrecisionArray : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -357,7 +357,7 @@ class SinglePrecisionArray : public ArrayElem
class Bit8SignedInteger : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -366,7 +366,7 @@ class Bit8SignedInteger : public ArrayElem
class Bit8UnsignedInteger : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -375,7 +375,7 @@ class Bit8UnsignedInteger : public ArrayElem
class Bit16SignedInteger : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -384,7 +384,7 @@ class Bit16SignedInteger : public ArrayElem
class Bit16UnsignedInteger : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -393,7 +393,7 @@ class Bit16UnsignedInteger : public ArrayElem
class Bit32SignedInteger : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -402,7 +402,7 @@ class Bit32SignedInteger : public ArrayElem
class Bit32UnsignedInteger : public ArrayElem
{
public:
public:
virtual void Collect(const string &name, bool found, CollectStruct &collect_struct) const;
virtual void Print() const;
virtual void Delete() const;
......@@ -412,7 +412,7 @@ class Bit32UnsignedInteger : public ArrayElem