Commit a67a20bf authored by ferhat's avatar ferhat
Browse files

- new Incidence_Matrix class

- lead and lag on exogenous variables
- corrections in dr1_sparse and dr11_sparse
- minor corrections in simulate

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@2255 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 01194422
......@@ -31,158 +31,346 @@ using namespace std;
#include "BlockTriangular.hh"
//------------------------------------------------------------------------------
/*BlockTriangular::BlockTriangular(const SymbolTable &symbol_table_arg) :
symbol_table(symbol_table_arg),
normalization(symbol_table_arg)*/
BlockTriangular::BlockTriangular(const SymbolTable &symbol_table_arg) :
symbol_table(symbol_table_arg),
normalization(symbol_table_arg)
normalization(symbol_table_arg),
incidencematrix(symbol_table_arg)
{
bt_verbose = 0;
ModelBlock = NULL;
Model_Max_Lead = 0;
Model_Max_Lag = 0;
periods = 0;
}
IncidenceMatrix::IncidenceMatrix(const SymbolTable &symbol_table_arg) :
symbol_table(symbol_table_arg)
{
Model_Max_Lead = Model_Max_Lead_Endo = Model_Max_Lead_Exo = 0;
Model_Max_Lag = Model_Max_Lag_Endo = Model_Max_Lag_Exo = 0;
}
//------------------------------------------------------------------------------
//For a lead or a lag build the Incidence Matrix structures
List_IM*
BlockTriangular::Build_IM(int lead_lag)
IncidenceMatrix::Build_IM(int lead_lag, SymbolType type)
{
List_IM* pIM = new List_IM;
int i;
List_IM* pIM = new List_IM;
if(type==eEndogenous)
{
Last_IM->pNext = pIM;
pIM->IM = (bool*)malloc(endo_nbr * endo_nbr * sizeof(pIM->IM[0]));
for(i = 0;i < endo_nbr*endo_nbr;i++)
pIM->IM = (bool*)malloc(symbol_table.endo_nbr * symbol_table.endo_nbr * sizeof(pIM->IM[0]));
for(i = 0;i < symbol_table.endo_nbr*symbol_table.endo_nbr;i++)
pIM->IM[i] = 0;
pIM->lead_lag = lead_lag;
if(lead_lag > 0)
{
if(lead_lag > Model_Max_Lead_Endo)
{
Model_Max_Lead_Endo = lead_lag;
if(lead_lag > Model_Max_Lead)
Model_Max_Lead = lead_lag;
}
}
else
{
if( -lead_lag > Model_Max_Lag)
if( -lead_lag > Model_Max_Lag_Endo)
{
Model_Max_Lag_Endo = -lead_lag;
if(-lead_lag > Model_Max_Lag)
Model_Max_Lag = -lead_lag;
}
}
pIM->pNext = NULL;
Last_IM = pIM;
}
else
{ //eExogenous
Last_IM_X->pNext = pIM;
pIM->IM = (bool*)malloc(symbol_table.exo_nbr * symbol_table.endo_nbr * sizeof(pIM->IM[0]));
for(i = 0;i < symbol_table.exo_nbr*symbol_table.endo_nbr;i++)
pIM->IM[i] = 0;
pIM->lead_lag = lead_lag;
if(lead_lag > 0)
{
if(lead_lag > Model_Max_Lead_Exo)
{
Model_Max_Lead_Exo = lead_lag;
if(lead_lag > Model_Max_Lead)
Model_Max_Lead = lead_lag;
}
}
else
{
if( -lead_lag > Model_Max_Lag_Exo)
{
Model_Max_Lag_Exo = -lead_lag;
if(-lead_lag > Model_Max_Lag)
Model_Max_Lag = -lead_lag;
}
}
pIM->pNext = NULL;
Last_IM_X = pIM;
}
return (pIM);
}
//------------------------------------------------------------------------------
// initialize all the incidence matrix structures
void
BlockTriangular::init_incidence_matrix(int nb_endo)
IncidenceMatrix::init_incidence_matrix()
{
int i;
endo_nbr = nb_endo;
First_IM = new List_IM;
First_IM->IM = (bool*)malloc(nb_endo * nb_endo * sizeof(First_IM->IM[0]));
for(i = 0;i < nb_endo*nb_endo;i++)
First_IM->IM = (bool*)malloc(symbol_table.endo_nbr * symbol_table.endo_nbr * sizeof(First_IM->IM[0]));
for(i = 0;i < symbol_table.endo_nbr*symbol_table.endo_nbr;i++)
First_IM->IM[i] = 0;
First_IM->lead_lag = 0;
First_IM->pNext = NULL;
Last_IM = First_IM;
//cout << "init_incidence_matrix done \n";
First_IM_X = new List_IM;
First_IM_X->IM = (bool*)malloc(symbol_table.exo_nbr * symbol_table.endo_nbr * sizeof(First_IM_X->IM[0]));
for(i = 0;i < symbol_table.endo_nbr*symbol_table.exo_nbr;i++)
First_IM_X->IM[i] = 0;
First_IM_X->lead_lag = 0;
First_IM_X->pNext = NULL;
Last_IM_X = First_IM_X;
}
void
BlockTriangular::Free_IM(List_IM* First_IM) const
IncidenceMatrix::Free_IM() const
{
#ifdef DEBUG
cout << "Free_IM\n";
#endif
List_IM *Cur_IM, *SFirst_IM;
Cur_IM = SFirst_IM = First_IM;
while(Cur_IM)
{
First_IM = Cur_IM->pNext;
SFirst_IM = Cur_IM->pNext;
free(Cur_IM->IM);
delete Cur_IM;
Cur_IM = First_IM;
Cur_IM = SFirst_IM;
}
Cur_IM = SFirst_IM = First_IM_X;
while(Cur_IM)
{
SFirst_IM = Cur_IM->pNext;
free(Cur_IM->IM);
delete Cur_IM;
Cur_IM = SFirst_IM;
}
//free(SFirst_IM);
//delete SFirst_IM;
}
//------------------------------------------------------------------------------
// Return the inceidence matrix related to a lead or a lag
// Return the incidence matrix related to a lead or a lag
List_IM*
BlockTriangular::Get_IM(int lead_lag)
IncidenceMatrix::Get_IM(int lead_lag, SymbolType type) const
{
List_IM* Cur_IM;
if(type==eEndogenous)
Cur_IM = First_IM;
else
Cur_IM = First_IM_X;
while ((Cur_IM != NULL) && (Cur_IM->lead_lag != lead_lag))
Cur_IM = Cur_IM->pNext;
return (Cur_IM);
}
bool*
BlockTriangular::bGet_IM(int lead_lag) const
IncidenceMatrix::bGet_IM(int lead_lag, SymbolType type) const
{
List_IM* Cur_IM;
if(type==eEndogenous)
Cur_IM = First_IM;
else
Cur_IM = First_IM_X;
while ((Cur_IM != NULL) && (Cur_IM->lead_lag != lead_lag))
{
Cur_IM = Cur_IM->pNext;
}
if((Cur_IM->lead_lag != lead_lag) || (Cur_IM==NULL))
{
cout << "the incidence matrix with lag " << lead_lag << " does not exist !!";
exit(EXIT_FAILURE);
}
if(Cur_IM)
return (Cur_IM->IM);
else
return(0);
}
//------------------------------------------------------------------------------
// Fill the incidence matrix related to a lead or a lag
void
BlockTriangular::fill_IM(int equation, int variable_endo, int lead_lag)
IncidenceMatrix::fill_IM(int equation, int variable, int lead_lag, SymbolType type)
{
List_IM* Cur_IM;
//cout << "equation=" << equation << " variable_endo=" << variable_endo << " lead_lag=" << lead_lag << "\n";
Cur_IM = Get_IM(lead_lag);
if(equation >= endo_nbr)
Cur_IM = Get_IM(lead_lag, type);
if(equation >= symbol_table.endo_nbr)
{
cout << "Error : The model has more equations (at least " << equation + 1 << ") than declared endogenous variables (" << endo_nbr << ")\n";
system("PAUSE");
cout << "Error : The model has more equations (at least " << equation + 1 << ") than declared endogenous variables (" << symbol_table.endo_nbr << ")\n";
exit(EXIT_FAILURE);
}
if (!Cur_IM)
Cur_IM = Build_IM(lead_lag);
Cur_IM->IM[equation*endo_nbr + variable_endo] = 1;
Cur_IM = Build_IM(lead_lag, type);
if(type==eEndogenous)
Cur_IM->IM[equation*symbol_table.endo_nbr + variable] = 1;
else
Cur_IM->IM[equation*symbol_table.exo_nbr + variable] = 1;
}
//------------------------------------------------------------------------------
// unFill the incidence matrix related to a lead or a lag
void
BlockTriangular::unfill_IM(int equation, int variable_endo, int lead_lag)
IncidenceMatrix::unfill_IM(int equation, int variable, int lead_lag, SymbolType type)
{
List_IM* Cur_IM;
//cout << "lead_lag=" << lead_lag << "\n";
Cur_IM = Get_IM(lead_lag);
/*if(equation >= endo_nbr)
Cur_IM = Get_IM(lead_lag, type);
if (!Cur_IM)
Cur_IM = Build_IM(lead_lag, type);
if(type==eEndogenous)
Cur_IM->IM[equation*symbol_table.endo_nbr + variable] = 0;
else
Cur_IM->IM[equation*symbol_table.exo_nbr + variable] = 0;
}
List_IM*
IncidenceMatrix::Get_First(SymbolType type) const
{
if(type==eEndogenous)
return(First_IM);
else
return(First_IM_X);
}
//------------------------------------------------------------------------------
//For a lead or a lag build the Incidence Matrix structures
/*List_IM*
IncidenceMatrix::Build_IM_X(int lead_lag)
{
List_IM* pIM_X = new List_IM;
int i;
Last_IM_X->pNext = pIM_X;
pIM_X->IM = (bool*)malloc(exo_nbr * endo_nbr * sizeof(pIM_X->IM[0]));
for(i = 0;i < exo_nbr*endo_nbr;i++)
pIM_X->IM[i] = 0;
pIM_X->lead_lag = lead_lag;
if(lead_lag > 0)
{
if(lead_lag > Model_Max_Lead_Exo)
{
Model_Max_Lead_Exo = lead_lag;
if(lead_lag > Model_Max_Lead)
Model_Max_Lead = lead_lag;
}
}
else
{
if( -lead_lag > Model_Max_Lag_Exo)
{
Model_Max_Lag_Exo = -lead_lag;
if(-lead_lag > Model_Max_Lag)
Model_Max_Lag = -lead_lag;
}
}
pIM_X->pNext = NULL;
Last_IM_X = pIM_X;
return (pIM_X);
}
//------------------------------------------------------------------------------
// initialize all the incidence matrix structures
void
IncidenceMatrix::init_incidence_matrix_X(int nb_exo)
{
int i;
//cout << "init_incidence_matrix_X nb_exo = " << nb_exo << " endo_nbr=" << endo_nbr << "\n";
exo_nbr = nb_exo;
First_IM_X = new List_IM;
First_IM_X->IM = (bool*)malloc(nb_exo * endo_nbr * sizeof(First_IM_X->IM[0]));
for(i = 0;i < endo_nbr*nb_exo;i++)
First_IM_X->IM[i] = 0;
First_IM_X->lead_lag = 0;
First_IM_X->pNext = NULL;
Last_IM_X = First_IM_X;
}
void
IncidenceMatrix::Free_IM_X(List_IM* First_IM_X) const
{
List_IM *Cur_IM_X, *SFirst_IM_X;
Cur_IM_X = SFirst_IM_X = First_IM_X;
while(Cur_IM_X)
{
First_IM_X = Cur_IM_X->pNext;
free(Cur_IM_X->IM);
delete Cur_IM_X;
Cur_IM_X = First_IM_X;
}
}
//------------------------------------------------------------------------------
// Return the inceidence matrix related to a lead or a lag
List_IM*
IncidenceMatrix::Get_IM_X(int lead_lag)
{
List_IM* Cur_IM_X;
Cur_IM_X = First_IM_X;
while ((Cur_IM_X != NULL) && (Cur_IM_X->lead_lag != lead_lag))
Cur_IM_X = Cur_IM_X->pNext;
return (Cur_IM_X);
}
bool*
IncidenceMatrix::bGet_IM_X(int lead_lag) const
{
List_IM* Cur_IM_X;
Cur_IM_X = First_IM_X;
while ((Cur_IM_X != NULL) && (Cur_IM_X->lead_lag != lead_lag))
{
Cur_IM_X = Cur_IM_X->pNext;
}
if(Cur_IM_X)
return (Cur_IM_X->IM);
else
return(0);
}
//------------------------------------------------------------------------------
// Fill the incidence matrix related to a lead or a lag
void
IncidenceMatrix::fill_IM_X(int equation, int variable_exo, int lead_lag)
{
List_IM* Cur_IM_X;
Cur_IM_X = Get_IM_X(lead_lag);
if(equation >= endo_nbr)
{
cout << "Error : The model has more equations (at least " << equation + 1 << ") than declared endogenous variables (" << endo_nbr << ")\n";
system("PAUSE");
exit(EXIT_FAILURE);
}*/
if (!Cur_IM)
Cur_IM = Build_IM(lead_lag);
Cur_IM->IM[equation*endo_nbr + variable_endo] = 0;
/*system("pause");*/
}
if (!Cur_IM_X)
{
Cur_IM_X = Build_IM_X(lead_lag);
}
Cur_IM_X->IM[equation*exo_nbr + variable_exo] = true;
}
*/
//------------------------------------------------------------------------------
//Print azn incidence matrix
void
BlockTriangular::Print_SIM(bool* IM, int n) const
IncidenceMatrix::Print_SIM(bool* IM, SymbolType type) const
{
int i, j;
for(i = 0;i < n;i++)
int i, j, n;
if(type == eEndogenous)
n = symbol_table.endo_nbr;
else
n = symbol_table.exo_nbr;
for(i = 0;i < symbol_table.endo_nbr;i++)
{
cout << " ";
for(j = 0;j < n;j++)
......@@ -194,15 +382,18 @@ BlockTriangular::Print_SIM(bool* IM, int n) const
//------------------------------------------------------------------------------
//Print all incidence matrix
void
BlockTriangular::Print_IM(int n) const
IncidenceMatrix::Print_IM(SymbolType type) const
{
List_IM* Cur_IM;
if(type == eEndogenous)
Cur_IM = First_IM;
else
Cur_IM = First_IM_X;
cout << "-------------------------------------------------------------------\n";
while(Cur_IM)
{
cout << "Incidence matrix for lead_lag = " << Cur_IM->lead_lag << "\n";
Print_SIM(Cur_IM->IM, n);
Print_SIM(Cur_IM->IM, type);
Cur_IM = Cur_IM->pNext;
}
}
......@@ -211,7 +402,7 @@ BlockTriangular::Print_IM(int n) const
//------------------------------------------------------------------------------
// Swap rows and columns of the incidence matrix
void
BlockTriangular::swap_IM_c(bool *SIM, int pos1, int pos2, int pos3, simple* Index_Var_IM, simple* Index_Equ_IM, int n)
IncidenceMatrix::swap_IM_c(bool *SIM, int pos1, int pos2, int pos3, simple* Index_Var_IM, simple* Index_Equ_IM, int n) const
{
int tmp_i, j;
bool tmp_b;
......@@ -269,15 +460,13 @@ BlockTriangular::Prologue_Epilogue(bool* IM, int* prologue, int* epilogue, int n
if ((k == 1) && IM0[Index_Equ_IM[i].index*n + Index_Var_IM[l].index])
{
modifie = 1;
swap_IM_c(IM, *prologue, i, l, Index_Var_IM, Index_Equ_IM, n);
incidencematrix.swap_IM_c(IM, *prologue, i, l, Index_Var_IM, Index_Equ_IM, n);
(*prologue)++;
}
}
}
*epilogue = 0;
modifie = 1;
/*print_SIM(IM,n);
print_SIM(IM*/
while(modifie)
{
modifie = 0;
......@@ -295,7 +484,7 @@ BlockTriangular::Prologue_Epilogue(bool* IM, int* prologue, int* epilogue, int n
if ((k == 1) && IM0[Index_Equ_IM[l].index*n + Index_Var_IM[i].index])
{
modifie = 1;
swap_IM_c(IM, n - (1 + *epilogue), l, i, Index_Var_IM, Index_Equ_IM, n);
incidencematrix.swap_IM_c(IM, n - (1 + *epilogue), l, i, Index_Var_IM, Index_Equ_IM, n);
(*epilogue)++;
}
}
......@@ -306,11 +495,12 @@ BlockTriangular::Prologue_Epilogue(bool* IM, int* prologue, int* epilogue, int n
void
BlockTriangular::Allocate_Block(int size, int *count_Equ, int *count_Block, BlockType type, Model_Block * ModelBlock)
{
int i, j, k, l, ls, m, i_1, Lead, Lag, size_list_lead_var, first_count_equ, i1;
int *list_lead_var, *tmp_size, *tmp_var, *tmp_endo, nb_lead_lag_endo;
int i, j, k, l, ls, m, i_1, Lead, Lag, first_count_equ, i1;
int *tmp_size, *tmp_size_exo, *tmp_var, *tmp_endo, *tmp_exo, tmp_nb_exo, nb_lead_lag_endo;
List_IM *Cur_IM;
bool *IM, OK;
ModelBlock->Periods = periods;
int Lag_Endo, Lead_Endo, Lag_Exo, Lead_Exo;
if ((type == PROLOGUE) || (type == EPILOGUE))
{
for(i = 0;i < size;i++)
......@@ -321,105 +511,166 @@ BlockTriangular::Allocate_Block(int size, int *count_Equ, int *count_Block, Bloc
ModelBlock->Block_List[*count_Block].Simulation_Type = UNKNOWN;
ModelBlock->Block_List[*count_Block].Temporary_terms=new temporary_terms_type ();
ModelBlock->Block_List[*count_Block].Temporary_terms->clear();
list_lead_var = (int*)malloc(Model_Max_Lead * endo_nbr * sizeof(int));
size_list_lead_var = 0;
tmp_endo = (int*)malloc((Model_Max_Lead + Model_Max_Lag + 1) * sizeof(int));
tmp_size = (int*)malloc((Model_Max_Lead + Model_Max_Lag + 1) * sizeof(int));
tmp_endo = (int*)malloc((incidencematrix.Model_Max_Lead + incidencematrix.Model_Max_Lag + 1) * sizeof(int));
tmp_size = (int*)malloc((incidencematrix.Model_Max_Lead + incidencematrix.Model_Max_Lag + 1) * sizeof(int));
tmp_var = (int*)malloc(sizeof(int));
memset(tmp_size, 0, (Model_Max_Lead + Model_Max_Lag + 1)*sizeof(int));
memset(tmp_endo, 0, (Model_Max_Lead + Model_Max_Lag + 1)*sizeof(int));
tmp_size_exo = (int*)malloc((incidencematrix.Model_Max_Lead + incidencematrix.Model_Max_Lag + 1) * sizeof(int));
memset(tmp_size_exo, 0, (incidencematrix.Model_Max_Lead + incidencematrix.Model_Max_Lag + 1)*sizeof(int));
memset(tmp_size, 0, (incidencematrix.Model_Max_Lead + incidencematrix.Model_Max_Lag + 1)*sizeof(int));
memset(tmp_endo, 0, (incidencematrix.Model_Max_Lead + incidencematrix.Model_Max_Lag + 1)*sizeof(int));
nb_lead_lag_endo = Lead = Lag = 0;
Cur_IM = First_IM;
Lag_Endo = Lead_Endo = Lag_Exo = Lead_Exo = 0;
Cur_IM = incidencematrix.Get_First(eEndogenous);
while(Cur_IM)
{
k = Cur_IM->lead_lag;
i_1 = Index_Equ_IM[*count_Equ].index * endo_nbr;
i_1 = Index_Equ_IM[*count_Equ].index * symbol_table.endo_nbr;
if(k > 0)
{
if(Cur_IM->IM[i_1 + Index_Var_IM[ /*j*/*count_Equ].index])
if(Cur_IM->IM[i_1 + Index_Var_IM[*count_Equ].index])
{
nb_lead_lag_endo++;
tmp_size[Model_Max_Lag + k]++;
tmp_size[incidencematrix.Model_Max_Lag_Endo + k]++;
if(k > Lead)
{
Lead = k;
list_lead_var[size_list_lead_var] = Index_Var_IM[*count_Equ].index + size * (k - 1);
size_list_lead_var++;
}
}
}
else
{
k = -k;
if(Cur_IM->IM[i_1 + Index_Var_IM[ /*j*/*count_Equ].index])
if(Cur_IM->IM[i_1 + Index_Var_IM[*count_Equ].index])
{
tmp_size[Model_Max_Lag - k]++;
tmp_size[incidencematrix.Model_Max_Lag_Endo - k]++;
nb_lead_lag_endo++;
if(k > Lag)
{
Lag = k;
}
}
Cur_IM = Cur_IM->pNext;
}
Lag_Endo = Lag;
Lead_Endo = Lead;
tmp_exo = (int*)malloc(symbol_table.exo_nbr * sizeof(int));
memset(tmp_exo, 0, symbol_table.exo_nbr * sizeof(int));
tmp_nb_exo = 0;
Cur_IM = incidencematrix.Get_First(eExogenous);
k = Cur_IM->lead_lag;
while(Cur_IM)
{
i_1 = Index_Equ_IM[*count_Equ].index * symbol_table.exo_nbr;
for(j=0;j<symbol_table.exo_nbr;j++)
if(Cur_IM->IM[i_1 + j])
{
if(!tmp_exo[j])
{
tmp_exo[j] = 1;
tmp_nb_exo++;
}
if(k>0 && k>Lead_Exo)
Lead_Exo = k;
else if(k<0 && (-k)>Lag_Exo)
Lag_Exo = -k;
if(k>0 && k>Lead)
Lead = k;
else if(k<0 && (-k)>Lag)
Lag = -k;
tmp_size_exo[k+incidencematrix.Model_Max_Lag_Exo]++;
}
Cur_IM = Cur_IM->pNext;
if(Cur_IM)
k = Cur_IM->lead_lag;
}
ModelBlock->Block_List[*count_Block].nb_exo = tmp_nb_exo;
ModelBlock->Block_List[*count_Block].Exogenous = (int*)malloc(tmp_nb_exo * sizeof(int));
k = 0;
for(j=0;j<symbol_table.exo_nbr;j++)
if(tmp_exo[j])
{
ModelBlock->Block_List[*count_Block].Exogenous[k] = j;
k++;
}
ModelBlock->Block_List[*count_Block].nb_exo_det = 0;
ModelBlock->Block_List[*count_Block].Max_Lag = Lag;
ModelBlock->Block_List[*count_Block].Max_Lead = Lead;
free(list_lead_var);
ModelBlock->Block_List[*count_Block].Max_Lag_Endo = Lag_Endo;
ModelBlock->Block_List[*count_Block].Max_Lead_Endo = Lead_Endo;
ModelBlock->Block_List[*count_Block].Max_Lag_Exo = Lag_Exo;
ModelBlock->Block_List[*count_Block].Max_Lead_Exo = Lead_Exo;
ModelBlock->Block_List[*count_Block].Equation = (int*)malloc(sizeof(int));
ModelBlock->Block_List[*count_Block].Variable = (int*)malloc(sizeof(int));
ModelBlock->Block_List[*count_Block].Variable_Sorted = (int*)malloc(sizeof(int));
ModelBlock->Block_List[*count_Block].Own_Derivative = (int*)malloc(sizeof(int));
ModelBlock->Block_List[*count_Block].Equation[0] = Index_Equ_IM[*count_Equ].index;
ModelBlock->Block_List[*count_Block].Variable[0] = Index_Var_IM[*count_Equ].index;
ModelBlock->Block_List[*count_Block].Variable_Sorted[0] = -1;
ModelBlock->in_Block_Equ[Index_Equ_IM[*count_Equ].index] = *count_Block;
ModelBlock->in_Block_Var[Index_Var_IM[*count_Equ].index] = *count_Block;
ModelBlock->in_Equ_of_Block[Index_Equ_IM[*count_Equ].index] = ModelBlock->in_Var_of_Block[Index_Var_IM[*count_Equ].index] = 0;
if ((Lead > 0) && (Lag > 0))
ModelBlock->Block_List[*count_Block].Simulation_Type = SOLVE_TWO_BOUNDARIES_SIMPLE;
else if((Lead > 0) && (Lag == 0))
ModelBlock->Block_List[*count_Block].Simulation_Type = SOLVE_BACKWARD_SIMPLE;
else
ModelBlock->Block_List[*count_Block].Simulation_Type = SOLVE_FORWARD_SIMPLE;
Cur_IM = incidencematrix.Get_First(eExogenous);
tmp_exo = (int*)malloc(symbol_table.exo_nbr * sizeof(int));
memset(tmp_exo, 0, symbol_table.exo_nbr * sizeof(int));
tmp_nb_exo = 0;
while(Cur_IM)
{
i_1 = Index_Equ_IM[*count_Equ].index * symbol_table.exo_nbr;
for(j=0;j<symbol_table.exo_nbr;j++)
if(Cur_IM->IM[i_1 + j] && (!tmp_exo[j]))
{
tmp_exo[j] = 1;