Reorganization of error handling in bytecode
parent
61a251535f
commit
bdfa881a96
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -41,47 +41,30 @@
|
|||
using namespace std;
|
||||
|
||||
#define pow_ pow
|
||||
typedef vector<pair<Tags, void * > > code_liste_type;
|
||||
typedef code_liste_type::const_iterator it_code_type;
|
||||
|
||||
class Interpreter : SparseMatrix
|
||||
class Interpreter : public SparseMatrix
|
||||
{
|
||||
private:
|
||||
vector<mxArray*> jacobian_block, jacobian_other_endo_block, jacobian_exo_block, jacobian_det_exo_block;
|
||||
ExpressionType EQN_type;
|
||||
char *P_endo_names, *P_exo_names, *P_param_names;
|
||||
unsigned int nb_endo, nb_exo, nb_param;
|
||||
unsigned int endo_name_length, exo_name_length, param_name_length;
|
||||
unsigned int EQN_equation, EQN_block, EQN_block_number;
|
||||
unsigned int EQN_dvar1, EQN_dvar2, EQN_dvar3;
|
||||
int EQN_lag1, EQN_lag2, EQN_lag3;
|
||||
it_code_type it_code_expr;
|
||||
protected:
|
||||
double pow1(double a, double b);
|
||||
double divide(double a, double b);
|
||||
double log1(double a);
|
||||
double log10_1(double a);
|
||||
/*string remove_white(string str);*/
|
||||
string add_underscore_to_fpe(const string &str);
|
||||
string get_variable(const SymbolType variable_type, const unsigned int variable_num);
|
||||
string error_location(bool evaluate, bool steady_state, int size, int block_num);
|
||||
void compute_block_time(int Per_u_, bool evaluate, int block_num, int size, bool steady_state);
|
||||
string print_expression(it_code_type it_code, bool evaluate, int size, int block_num, bool steady_state);
|
||||
void evaluate_a_block(const int size, const int type, string bin_basename, bool steady_state, int block_num,
|
||||
const bool is_linear = false, const int symbol_table_endo_nbr = 0, const int Block_List_Max_Lag = 0, const int Block_List_Max_Lead = 0, const int u_count_int = 0, int block = -1);
|
||||
int simulate_a_block(const int size, const int type, string file_name, string bin_basename, bool Gaussian_Elimination, bool steady_state, int block_num,
|
||||
const bool is_linear = false, const int symbol_table_endo_nbr = 0, const int Block_List_Max_Lag = 0, const int Block_List_Max_Lead = 0, const int u_count_int = 0);
|
||||
double *T;
|
||||
vector<Block_contain_type> Block_Contain;
|
||||
code_liste_type code_liste;
|
||||
it_code_type it_code;
|
||||
int Block_Count, Per_u_, Per_y_;
|
||||
int it_, nb_row_x, nb_row_xd, maxit_, size_of_direction;
|
||||
double *g2, *g1, *r;
|
||||
int it_, maxit_, size_of_direction;
|
||||
double solve_tolf;
|
||||
bool GaussSeidel;
|
||||
double *x, *params;
|
||||
double *steady_y, *steady_x;
|
||||
map<pair<pair<int, int>, int>, int> IM_i;
|
||||
int equation, derivative_equation, derivative_variable;
|
||||
string filename;
|
||||
|
|
|
@ -2877,9 +2877,9 @@ SparseMatrix::Simulate_Newton_One_Boundary(int blck, int y_size, int it_, int y_
|
|||
break;
|
||||
}
|
||||
if (select)
|
||||
mexPrintf("-> variable %d at time %d = %f direction = %f\n", j+1, it_, y[j+it_*y_size], direction[j+it_*y_size]);
|
||||
mexPrintf("-> variable %s (%d) at time %d = %f direction = %f\n", get_variable(eEndogenous, j).c_str(), j+1, it_, y[j+it_*y_size], direction[j+it_*y_size]);
|
||||
else
|
||||
mexPrintf(" variable %d at time %d = %f direction = %f\n", j+1, it_, y[j+it_*y_size], direction[j+it_*y_size]);
|
||||
mexPrintf(" variable %s (%d) at time %d = %f direction = %f\n", get_variable(eEndogenous, j).c_str(), j+1, it_, y[j+it_*y_size], direction[j+it_*y_size]);
|
||||
}
|
||||
if (steady_state)
|
||||
{
|
||||
|
@ -3248,7 +3248,13 @@ SparseMatrix::fixe_u(double **u, int u_count_int, int max_lag_plus_max_lead_plus
|
|||
{
|
||||
u_count = u_count_int * periods;
|
||||
u_count_alloc = 2*u_count;
|
||||
#if DEBUG
|
||||
mexPrintf("fixe_u : alloc(%d double)\n",u_count_alloc);
|
||||
#endif
|
||||
(*u) = (double *) mxMalloc(u_count_alloc*sizeof(double));
|
||||
#if DEBUG
|
||||
mexPrintf("*u=%d\n",*u);
|
||||
#endif
|
||||
memset((*u), 0, u_count_alloc*sizeof(double));
|
||||
u_count_init = max_lag_plus_max_lead_plus_1;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ const double very_big = 1e24;
|
|||
const int alt_symbolic_count_max = 1;
|
||||
const double mem_increasing_factor = 1.1;
|
||||
|
||||
class SparseMatrix
|
||||
class SparseMatrix : public ErrorMsg
|
||||
{
|
||||
public:
|
||||
SparseMatrix();
|
||||
|
@ -153,13 +153,12 @@ private:
|
|||
protected:
|
||||
vector<double> residual;
|
||||
int u_count_alloc, u_count_alloc_save;
|
||||
double *u, *y, *ya;
|
||||
vector<double*> jac;
|
||||
double *jcb;
|
||||
double res1, res2, max_res;
|
||||
int max_res_idx;
|
||||
double slowc, slowc_save, prev_slowc_save, markowitz_c;
|
||||
int y_kmin, y_kmax, y_size, periods, y_decal;
|
||||
int y_decal;
|
||||
int *index_vara, *index_equa;
|
||||
int u_count, tbreak_g;
|
||||
int iter;
|
||||
|
|
|
@ -378,28 +378,27 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
|
|||
jacob_exo_det_field_number=2;
|
||||
jacob_other_endo_field_number=2;
|
||||
mwSize dims[1] = {nb_blocks };
|
||||
//block_structur =
|
||||
plhs[2] = mxCreateStructArray(1, dims, 4, field_names);
|
||||
}
|
||||
else if (!mxIsStruct(block_structur))
|
||||
{
|
||||
//plhs[2] = mxDuplicateArray(interprete.get_jacob(0));
|
||||
plhs[2] = interprete.get_jacob(0);
|
||||
//mexCallMATLAB(0,NULL, 1, &plhs[2], "disp");
|
||||
dont_store_a_structure = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
jacob_field_number = mxAddField(block_structur, "g1");
|
||||
plhs[2] = block_structur;
|
||||
jacob_field_number = mxAddField(plhs[2], "g1");
|
||||
if (jacob_field_number == -1)
|
||||
DYN_MEX_FUNC_ERR_MSG_TXT("Fatal error in bytecode: in main, cannot add extra field jacob to the structArray\n");
|
||||
jacob_exo_field_number = mxAddField(block_structur, "g1_x");
|
||||
jacob_exo_field_number = mxAddField(plhs[2], "g1_x");
|
||||
if (jacob_exo_field_number == -1)
|
||||
DYN_MEX_FUNC_ERR_MSG_TXT("Fatal error in bytecode: in main, cannot add extra field jacob_exo to the structArray\n");
|
||||
jacob_exo_det_field_number = mxAddField(block_structur, "g1_xd");
|
||||
jacob_exo_det_field_number = mxAddField(plhs[2], "g1_xd");
|
||||
if (jacob_exo_det_field_number == -1)
|
||||
DYN_MEX_FUNC_ERR_MSG_TXT("Fatal error in bytecode: in main, cannot add extra field jacob_exo_det to the structArray\n");
|
||||
jacob_other_endo_field_number = mxAddField(block_structur, "g1_o");
|
||||
jacob_other_endo_field_number = mxAddField(plhs[2], "g1_o");
|
||||
if (jacob_other_endo_field_number == -1)
|
||||
DYN_MEX_FUNC_ERR_MSG_TXT("Fatal error in bytecode: in main, cannot add extra field jacob_other_endo to the structArray\n");
|
||||
}
|
||||
|
@ -407,12 +406,11 @@ mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
|
|||
{
|
||||
for (int i = 0; i < nb_blocks; i++)
|
||||
{
|
||||
mxSetFieldByNumber(block_structur,i,jacob_field_number,interprete.get_jacob(i));
|
||||
mxSetFieldByNumber(block_structur,i,jacob_exo_field_number,interprete.get_jacob_exo(i));
|
||||
mxSetFieldByNumber(block_structur,i,jacob_exo_det_field_number,interprete.get_jacob_exo_det(i));
|
||||
mxSetFieldByNumber(block_structur,i,jacob_other_endo_field_number,interprete.get_jacob_other_endo(i));
|
||||
mxSetFieldByNumber(plhs[2],i,jacob_field_number,interprete.get_jacob(i));
|
||||
mxSetFieldByNumber(plhs[2],i,jacob_exo_field_number,interprete.get_jacob_exo(i));
|
||||
mxSetFieldByNumber(plhs[2],i,jacob_exo_det_field_number,interprete.get_jacob_exo_det(i));
|
||||
mxSetFieldByNumber(plhs[2],i,jacob_other_endo_field_number,interprete.get_jacob_other_endo(i));
|
||||
}
|
||||
plhs[2] = block_structur;
|
||||
}
|
||||
if (nlhs > 3)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue