Commit 1740884d 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 9d0d9f0f
......@@ -31,9 +31,9 @@ using namespace std;
//------------------------------------------------------------------------------
BlockTriangular::BlockTriangular(const SymbolTable &symbol_table_arg) :
symbol_table(symbol_table_arg),
normalization(symbol_table_arg),
incidencematrix(symbol_table_arg)
symbol_table(symbol_table_arg),
normalization(symbol_table_arg),
incidencematrix(symbol_table_arg)
{
bt_verbose = 0;
ModelBlock = NULL;
......@@ -418,52 +418,52 @@ 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++)
{
{
int blk, i;
for (blk = 0;blk < ModelBlock->Size;blk++)
{
free(ModelBlock->Block_List[blk].Equation);
free(ModelBlock->Block_List[blk].Variable);
free(ModelBlock->Block_List[blk].Exogenous);
free(ModelBlock->Block_List[blk].Own_Derivative);
free(ModelBlock->Block_List[blk].Other_Endogenous);
for (i = 0;i < ModelBlock->Block_List[blk].Max_Lag + ModelBlock->Block_List[blk].Max_Lead + 1;i++)
{
if (incidencematrix.Model_Max_Lag_Endo-ModelBlock->Block_List[blk].Max_Lag+i>=0 /*&& ModelBlock->Block_List[blk].IM_lead_lag[i].size*/)
{
free(ModelBlock->Block_List[blk].IM_lead_lag[i].u);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].us);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Var);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ_Index);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Var_Index);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].u_other_endo);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Var_other_endo);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ_other_endo);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Var_Index_other_endo);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ_Index_other_endo);
}
if (incidencematrix.Model_Max_Lag_Exo-ModelBlock->Block_List[blk].Max_Lag+i>=0 /*&& ModelBlock->Block_List[blk].IM_lead_lag[i].size_exo*/)
{
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Exogenous);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Exogenous_Index);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ_X_Index);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ_X);
}
}
free(ModelBlock->Block_List[blk].IM_lead_lag);
for(i=0; i<ModelBlock->Block_List[blk].Size; i++)
delete ModelBlock->Block_List[blk].Temporary_Terms_in_Equation[i];
free(ModelBlock->Block_List[blk].Temporary_Terms_in_Equation);
delete(ModelBlock->Block_List[blk].Temporary_InUse);
}
free(ModelBlock->Block_List);
free(ModelBlock);
free(Index_Equ_IM);
free(Index_Var_IM);
}
free(ModelBlock->Block_List[blk].Equation);
free(ModelBlock->Block_List[blk].Variable);
free(ModelBlock->Block_List[blk].Exogenous);
free(ModelBlock->Block_List[blk].Own_Derivative);
free(ModelBlock->Block_List[blk].Other_Endogenous);
for (i = 0;i < ModelBlock->Block_List[blk].Max_Lag + ModelBlock->Block_List[blk].Max_Lead + 1;i++)
{
if (incidencematrix.Model_Max_Lag_Endo-ModelBlock->Block_List[blk].Max_Lag+i>=0 /*&& ModelBlock->Block_List[blk].IM_lead_lag[i].size*/)
{
free(ModelBlock->Block_List[blk].IM_lead_lag[i].u);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].us);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Var);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ_Index);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Var_Index);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].u_other_endo);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Var_other_endo);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ_other_endo);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Var_Index_other_endo);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ_Index_other_endo);
}
if (incidencematrix.Model_Max_Lag_Exo-ModelBlock->Block_List[blk].Max_Lag+i>=0 /*&& ModelBlock->Block_List[blk].IM_lead_lag[i].size_exo*/)
{
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Exogenous);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Exogenous_Index);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ_X_Index);
free(ModelBlock->Block_List[blk].IM_lead_lag[i].Equ_X);
}
}
free(ModelBlock->Block_List[blk].IM_lead_lag);
for(i=0; i<ModelBlock->Block_List[blk].Size; i++)
delete ModelBlock->Block_List[blk].Temporary_Terms_in_Equation[i];
free(ModelBlock->Block_List[blk].Temporary_Terms_in_Equation);
delete(ModelBlock->Block_List[blk].Temporary_InUse);
}
free(ModelBlock->Block_List);
free(ModelBlock);
free(Index_Equ_IM);
free(Index_Var_IM);
}
t_type
......@@ -571,7 +571,7 @@ BlockTriangular::Reduce_Blocks_and_type_determination(int prologue, int epilogue
{
if ( ((prev_Type == EVALUATE_FORWARD_R || prev_Type == EVALUATE_FORWARD) && (Simulation_Type == EVALUATE_FORWARD_R || Simulation_Type == EVALUATE_FORWARD))
|| ((prev_Type == EVALUATE_BACKWARD_R || prev_Type == EVALUATE_BACKWARD) && (Simulation_Type == EVALUATE_BACKWARD_R || Simulation_Type == EVALUATE_BACKWARD))
)
)
{
BlockSimulationType c_Type = (Type[Type.size()-1]).first;
int c_Size = (Type[Type.size()-1]).second;
......
......@@ -177,7 +177,7 @@ StochSimulStatement::writeOutput(ostream &output, const string &basename) const
}
ForecastStatement::ForecastStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg) :
const OptionsList &options_list_arg) :
symbol_list(symbol_list_arg),
options_list(options_list_arg)
{
......
......@@ -376,13 +376,13 @@ DataTree::AddSqRt(NodeID iArg1)
NodeID
DataTree::AddMaX(NodeID iArg1, NodeID iArg2)
{
return AddBinaryOp(iArg1, oMax, iArg2);
return AddBinaryOp(iArg1, oMax, iArg2);
}
NodeID
DataTree::AddMin(NodeID iArg1, NodeID iArg2)
{
return AddBinaryOp(iArg1, oMin, iArg2);
return AddBinaryOp(iArg1, oMin, iArg2);
}
NodeID
......
......@@ -480,12 +480,12 @@ VariableNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType ou
void
VariableNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence,
int Curr_block,
Model_Block *ModelBlock,
int equation,
map_idx_type &map_idx) const
temporary_terms_type &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence,
int Curr_block,
Model_Block *ModelBlock,
int equation,
map_idx_type &map_idx) const
{
if(type== eModelLocalVariable)
datatree.local_variables_table[symb_id]->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, Curr_block, ModelBlock, equation, map_idx);
......@@ -1080,7 +1080,7 @@ BinaryOpNode::cost(const temporary_terms_type &temporary_terms, bool is_matlab)
return cost + 90;
case oMax:
case oMin:
return cost + 110;
return cost + 110;
case oDivide:
return cost + 990;
case oPower:
......@@ -1278,7 +1278,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
if ((op_code == oPower && !OFFSET(output_type)) || op_code == oMax || op_code == oMin )
{
switch (op_code)
{
{
case oPower:
output << "pow(";
break;
......@@ -1290,7 +1290,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
break;
default:
;
}
}
arg1->writeOutput(output, output_type, temporary_terms);
output << ",";
arg2->writeOutput(output, output_type, temporary_terms);
......@@ -1404,7 +1404,7 @@ BinaryOpNode::collectExogenous(set<pair<int, int> > &result) const
}
TrinaryOpNode::TrinaryOpNode(DataTree &datatree_arg, const NodeID arg1_arg,
TrinaryOpcode op_code_arg, const NodeID arg2_arg, const NodeID arg3_arg) :
TrinaryOpcode op_code_arg, const NodeID arg2_arg, const NodeID arg3_arg) :
ExprNode(datatree_arg),
arg1(arg1_arg),
arg2(arg2_arg),
......@@ -1531,8 +1531,8 @@ TrinaryOpNode::cost(const temporary_terms_type &temporary_terms, bool is_matlab)
void
TrinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms,
bool is_matlab) const
temporary_terms_type &temporary_terms,
bool is_matlab) const
{
NodeID this2 = const_cast<TrinaryOpNode *>(this);
map<NodeID, int>::iterator it = reference_count.find(this2);
......@@ -1557,12 +1557,12 @@ TrinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
void
TrinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence,
int Curr_block,
Model_Block *ModelBlock,
int equation,
map_idx_type &map_idx) const
temporary_terms_type &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence,
int Curr_block,
Model_Block *ModelBlock,
int equation,
map_idx_type &map_idx) const
{
NodeID this2 = const_cast<TrinaryOpNode *>(this);
map<NodeID, int>::iterator it = reference_count.find(this2);
......@@ -1646,7 +1646,7 @@ TrinaryOpNode::collectTemporary_terms(const temporary_terms_type &temporary_term
void
TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms) const
const temporary_terms_type &temporary_terms) const
{
if (!OFFSET(output_type))
{
......
......@@ -114,7 +114,7 @@ IncidenceMatrix::Get_IM(int lead_lag, SymbolType type) const
}
else //eExogenous
{
it = List_IM_X.find(lead_lag);
it = List_IM_X.find(lead_lag);
if(it!=List_IM_X.end())
return(it->second);
else
......
......@@ -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"
......@@ -183,69 +183,69 @@ SimpleElem::Get_Data_Class(Data_Header_t data_header) const
returned_ReadData_t ret;
switch(data_header.DataType)
{
case miINT8: //8 bit, signed
case miUINT8: //8 bit, unsigned
ret.Type = Numerical;
ret.Simple = new INT8;
return(ret);
break;
case miINT16: //16-bit, signed
case miUINT16: //16-bit, unsigned
ret.Type = Numerical;
ret.Simple = new INT16;
return(ret);
break;
case miINT32: //32-bit, signed
case miUINT32: //32-bit, unsigned
ret.Type = Numerical;
ret.Simple = new INT32;
return(ret);
break;
case miINT64: //64-bit, signed
case miUINT64: //64-bit, unsigned
ret.Type = Numerical;
ret.Simple = new INT64;
return(ret);
break;
case miSINGLE: //IEEE 754 single format
ret.Type = Numerical;
ret.Simple = new Single;
return(ret);
break;
case miDOUBLE: //IEEE 754 double format
ret.Type = Numerical;
ret.Simple = new Double;
return(ret);
break;
case miMATRIX: //MATLAB array
ret.Type = Matrix;
ret.Simple = NULL;
return(ret);
break;
case miCOMPRESSED: //Compressed Data
ret.Type = Compressed;
ret.Simple = NULL;
return(ret);
break;
case miUTF8: //Unicode UTF-8 Encoded Character Data
ret.Type = AlphaNumeric;
ret.Simple = new UTF8;
return(ret);
break;
case miUTF16: //Unicode UTF-16 Encoded Character Data
ret.Type = AlphaNumeric;
ret.Simple = new UTF16;
return(ret);
break;
case miUTF32: //Unicode UTF-32 Encoded Character Data
ret.Type = AlphaNumeric;
ret.Simple = new UTF32;
return(ret);
break;
default:
ret.Type = Unknown;
ret.Simple = NULL;
return(ret);
case miINT8: //8 bit, signed
case miUINT8: //8 bit, unsigned
ret.Type = Numerical;
ret.Simple = new INT8;
return(ret);
break;
case miINT16: //16-bit, signed
case miUINT16: //16-bit, unsigned
ret.Type = Numerical;
ret.Simple = new INT16;
return(ret);
break;
case miINT32: //32-bit, signed
case miUINT32: //32-bit, unsigned
ret.Type = Numerical;
ret.Simple = new INT32;
return(ret);
break;
case miINT64: //64-bit, signed
case miUINT64: //64-bit, unsigned
ret.Type = Numerical;
ret.Simple = new INT64;
return(ret);
break;
case miSINGLE: //IEEE 754 single format
ret.Type = Numerical;
ret.Simple = new Single;
return(ret);
break;
case miDOUBLE: //IEEE 754 double format
ret.Type = Numerical;
ret.Simple = new Double;
return(ret);
break;
case miMATRIX: //MATLAB array
ret.Type = Matrix;
ret.Simple = NULL;
return(ret);
break;
case miCOMPRESSED: //Compressed Data
ret.Type = Compressed;
ret.Simple = NULL;
return(ret);
break;
case miUTF8: //Unicode UTF-8 Encoded Character Data
ret.Type = AlphaNumeric;
ret.Simple = new UTF8;
return(ret);
break;
case miUTF16: //Unicode UTF-16 Encoded Character Data
ret.Type = AlphaNumeric;
ret.Simple = new UTF16;
return(ret);
break;
case miUTF32: //Unicode UTF-32 Encoded Character Data
ret.Type = AlphaNumeric;
ret.Simple = new UTF32;
return(ret);
break;
default:
ret.Type = Unknown;
ret.Simple = NULL;
return(ret);
}
}
......@@ -259,36 +259,36 @@ SimpleElem::DataProceed(Data_Header data_header, char* InBuff, int* pBuff, FlagS
double tmpv;
switch(ret.Type)
{
case Numerical:
if(data_header.Number_of_Bytes/ret.Simple->size())
for(unsigned int i=0;i<data_header.Number_of_Bytes/ret.Simple->size();i++)
{
tmpv=ret.Simple->ReadNum(InBuff, pBuff);
VNumeric.push_back(tmpv);
}
//to align pBuff on a 4 Bytes
if(*pBuff % 4)
*pBuff += 4-(*pBuff % 4);
delete ret.Simple;
break;
case AlphaNumeric:
case Numerical:
if(data_header.Number_of_Bytes/ret.Simple->size())
for(unsigned int i=0;i<data_header.Number_of_Bytes/ret.Simple->size();i++)
Vstr.push_back(ret.Simple->ReadAlph(InBuff, pBuff, data_header.Number_of_Bytes));
//to align pBuff on a 4 Bytes
if(*pBuff % 4)
*pBuff += 4-(*pBuff % 4);
delete ret.Simple;
break;
case Matrix:
array_elem = matrix.ReadArray_class(InBuff, pBuff);
array_elem->ReadArray(InBuff, pBuff, flag);
break;
case Compressed:
cerr << "Error: Compressed data in Mat-file not implemnted yet!\n set option -v6 when saving to Mat-file\n";
exit(EXIT_FAILURE);
case Unknown:
cerr << "Error: Mat-file format use incomptible format with Matlab 7 specification!\n set option -v6 when saving to Mat-file\n";
exit(EXIT_FAILURE);
{
tmpv=ret.Simple->ReadNum(InBuff, pBuff);
VNumeric.push_back(tmpv);
}
//to align pBuff on a 4 Bytes
if(*pBuff % 4)
*pBuff += 4-(*pBuff % 4);
delete ret.Simple;
break;
case AlphaNumeric:
for(unsigned int i=0;i<data_header.Number_of_Bytes/ret.Simple->size();i++)
Vstr.push_back(ret.Simple->ReadAlph(InBuff, pBuff, data_header.Number_of_Bytes));
//to align pBuff on a 4 Bytes
if(*pBuff % 4)
*pBuff += 4-(*pBuff % 4);
delete ret.Simple;
break;
case Matrix:
array_elem = matrix.ReadArray_class(InBuff, pBuff);
array_elem->ReadArray(InBuff, pBuff, flag);
break;
case Compressed:
cerr << "Error: Compressed data in Mat-file not implemnted yet!\n set option -v6 when saving to Mat-file\n";
exit(EXIT_FAILURE);
case Unknown:
cerr << "Error: Mat-file format use incomptible format with Matlab 7 specification!\n set option -v6 when saving to Mat-file\n";
exit(EXIT_FAILURE);
}
}
......@@ -319,7 +319,7 @@ SimpleElem::Collect(const string &name, bool found, CollectStruct &collect_struc
{
array_elem->Collect(name, found, collect_struct);
}
}
}
}
......@@ -438,47 +438,47 @@ ArrayElem::ReadArray_class(char* InBuff, int* pBuff) const
array_flag=array_elem.ReadArrayFlag(InBuff, pBuff);
switch(array_flag.classe)
{
case Cell_array:
return(new CellArray);
break;
case Structure_:
return(new Structure);
break;
case Object_:
return(new Object);
break;
case Character_array:
return(new CharacterArray);
break;
case Sparse_array:
return(new SparseArray);
break;
case Double_precision_array:
return(new DoublePrecisionArray);
break;
case Single_precision_array:
return(new SinglePrecisionArray);
break;
case Signed_integer_8_bit:
return(new Bit8SignedInteger);
break;
case Unsigned_integer_8_bit:
return(new Bit8UnsignedInteger);
break;
case Signed_integer_16_bit:
return(new Bit16SignedInteger);
break;
case Unsigned_integer_16_bit:
return(new Bit16UnsignedInteger);
break;
case Signed_integer_32_bit:
return(new Bit32SignedInteger);
break;
case Unsigned_integer_32_bit:
return(new Bit32UnsignedInteger);
break;
default:
return(NULL);
case Cell_array:
return(new CellArray);
break;
case Structure_:
return(new Structure);
break;
case Object_:
return(new Object);
break;
case Character_array:
return(new CharacterArray);
break;
case Sparse_array:
return(new SparseArray);
break;
case Double_precision_array:
return(new DoublePrecisionArray);
break;
case Single_precision_array:
return(new SinglePrecisionArray);
break;
case Signed_integer_8_bit:
return(new Bit8SignedInteger);
break;
case Unsigned_integer_8_bit:
return(new Bit8UnsignedInteger);
break;
case Signed_integer_16_bit:
return(new Bit16SignedInteger);
break;
case Unsigned_integer_16_bit:
return(new Bit16UnsignedInteger);
break;
case Signed_integer_32_bit:
return(new Bit32SignedInteger);
break;
case Unsigned_integer_32_bit:
return(new Bit32UnsignedInteger);
break;
default:
return(NULL);
}
return(NULL);
}
......@@ -1024,7 +1024,7 @@ bool
MatlabFile::Collect(const string &name, CollectStruct &collect_struct) const
{
for(vector<PSimpleElem>::const_iterator it=VSimpl.begin(); it!=VSimpl.end(); it++)
(*it)->Collect(name, false, collect_struct);
(*it)->Collect(name, false, collect_struct);
return(!(collect_struct.variable_double_name.empty() and collect_struct.variable_string_name.empty()));
}
......@@ -1033,7 +1033,7 @@ void
MatlabFile::MatFilePrint()
{
for(vector<PSimpleElem>::iterator it=VSimpl.begin(); it!=VSimpl.end(); it++)
(*it)->Print();
(*it)->Print();
}
......@@ -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");
......@@ -1060,18 +1060,18 @@ main(int argc, char** argv)
//string tmp_s("stored_values");
tmp_b=matlab_file.Collect("stored_values", collect_struct);
if(tmp_b)
{
int i=0;
for(map<string,vector<double> >::iterator it2=collect_struct.variable_double_name.begin();it2!=collect_struct.variable_double_name.end();it2++)
{
i++;
cout << i << " " << it2->first.c_str() << " : ";
for(vector<double>::iterator it=it2->second.begin();it!=it2->second.end();it++)
cout << *it;
cout << "\n";
}
}
}
{
int i=0;
for(map<string,vector<double> >::iterator it2=collect_struct.variable_double_name.begin();it2!=collect_struct.variable_double_name.end();it2++)
{
i++;
cout << i << " " << it2->first.c_str() << " : ";
for(vector<double>::iterator it=it2->second.begin();it!=it2->second.end();it++)
cout <<