Bug correction in error messages and reduction of memory requirement during simulation
parent
e466748993
commit
faa5da07dc
|
@ -112,26 +112,32 @@ Interpreter::get_variable(SymbolType variable_type, int variable_num)
|
||||||
C = mxGetN(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "endo_names")));
|
C = mxGetN(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "endo_names")));
|
||||||
R = mxGetM(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "endo_names")));
|
R = mxGetM(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "endo_names")));
|
||||||
P = (char*) mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "endo_names")));
|
P = (char*) mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "endo_names")));
|
||||||
if (EQN_dvar1 < R)
|
if (variable_num < R)
|
||||||
for (unsigned int i = 0; i < C; i++)
|
for (unsigned int i = 0; i < C; i++)
|
||||||
res << P[2*(EQN_dvar1+i*R)];
|
res << P[2*(variable_num+i*R)];
|
||||||
|
else
|
||||||
|
mexPrintf("=> Unknown endogenous variable n° %d",EQN_dvar1);
|
||||||
break;
|
break;
|
||||||
case eExogenous:
|
case eExogenous:
|
||||||
case eExogenousDet:
|
case eExogenousDet:
|
||||||
C = mxGetN(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "exo_names")));
|
C = mxGetN(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "exo_names")));
|
||||||
R = mxGetM(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "exo_names")));
|
R = mxGetM(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "exo_names")));
|
||||||
P = (char*) mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "exo_names")));
|
P = (char*) mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "exo_names")));
|
||||||
if (EQN_dvar1 < R)
|
if (variable_num < R)
|
||||||
for (unsigned int i = 0; i < C; i++)
|
for (unsigned int i = 0; i < C; i++)
|
||||||
res << P[2*(EQN_dvar1+i*R)];
|
res << P[2*(variable_num+i*R)];
|
||||||
|
else
|
||||||
|
mexPrintf("=> Unknown exogenous variable n° %d",EQN_dvar1);
|
||||||
break;
|
break;
|
||||||
case eParameter:
|
case eParameter:
|
||||||
C = mxGetN(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "param_names")));
|
C = mxGetN(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "param_names")));
|
||||||
R = mxGetM(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "param_names")));
|
R = mxGetM(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "param_names")));
|
||||||
P = (char*) mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "param_names")));
|
P = (char*) mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "param_names")));
|
||||||
if (EQN_dvar1 < R)
|
if (variable_num < R)
|
||||||
for (unsigned int i = 0; i < C; i++)
|
for (unsigned int i = 0; i < C; i++)
|
||||||
res << P[2*(EQN_dvar1+i*R)];
|
res << P[2*(variable_num+i*R)];
|
||||||
|
else
|
||||||
|
mexPrintf("=> Unknown parameter n° %d",EQN_dvar1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1832,7 +1832,7 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
|
||||||
{
|
{
|
||||||
if (nop+1 >= nopa)
|
if (nop+1 >= nopa)
|
||||||
{
|
{
|
||||||
nopa = int (1.5*nopa);
|
nopa = long (mem_increasing_factor*(double)nopa);
|
||||||
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
||||||
}
|
}
|
||||||
save_op_s = (t_save_op_s *)(&(save_op[nop]));
|
save_op_s = (t_save_op_s *)(&(save_op[nop]));
|
||||||
|
@ -1872,7 +1872,7 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
|
||||||
{
|
{
|
||||||
if (nop+j*2+1 >= nopa)
|
if (nop+j*2+1 >= nopa)
|
||||||
{
|
{
|
||||||
nopa = int (1.5*nopa);
|
nopa = long (mem_increasing_factor*(double)nopa);
|
||||||
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
||||||
}
|
}
|
||||||
save_op_s = (t_save_op_s *)(&(save_op[nop+j*2]));
|
save_op_s = (t_save_op_s *)(&(save_op[nop+j*2]));
|
||||||
|
@ -1891,7 +1891,7 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
|
||||||
{
|
{
|
||||||
if (nop+1 >= nopa)
|
if (nop+1 >= nopa)
|
||||||
{
|
{
|
||||||
nopa = int (1.5*nopa);
|
nopa = long (mem_increasing_factor*(double)nopa);
|
||||||
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
||||||
}
|
}
|
||||||
save_op_s = (t_save_op_s *)(&(save_op[nop]));
|
save_op_s = (t_save_op_s *)(&(save_op[nop]));
|
||||||
|
@ -1926,13 +1926,10 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
|
||||||
{
|
{
|
||||||
if (record)
|
if (record)
|
||||||
{
|
{
|
||||||
if (nop+2 >= nopa)
|
if (nop+1 >= nopa)
|
||||||
{
|
{
|
||||||
//#pragma omp critical
|
nopa = long (mem_increasing_factor*(double)nopa);
|
||||||
{
|
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
||||||
nopa = int (1.5*nopa);
|
|
||||||
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
save_op_s_l = (t_save_op_s *)(&(save_op[nop]));
|
save_op_s_l = (t_save_op_s *)(&(save_op[nop]));
|
||||||
save_op_s_l->operat = IFLD;
|
save_op_s_l->operat = IFLD;
|
||||||
|
@ -1979,11 +1976,8 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
|
||||||
{
|
{
|
||||||
if (nop+2 >= nopa)
|
if (nop+2 >= nopa)
|
||||||
{
|
{
|
||||||
//#pragma omp critical
|
nopa = long (mem_increasing_factor*(double)nopa);
|
||||||
{
|
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
||||||
nopa = int (1.5*nopa);
|
|
||||||
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
save_op_s_l = (t_save_op_s *)(&(save_op[nop]));
|
save_op_s_l = (t_save_op_s *)(&(save_op[nop]));
|
||||||
save_op_s_l->operat = IFLESS;
|
save_op_s_l->operat = IFLESS;
|
||||||
|
@ -2037,11 +2031,8 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
|
||||||
{
|
{
|
||||||
if (nop+3 >= nopa)
|
if (nop+3 >= nopa)
|
||||||
{
|
{
|
||||||
//#pragma omp critical
|
nopa = long (mem_increasing_factor*(double)nopa);
|
||||||
{
|
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
||||||
nopa = int (1.5*nopa);
|
|
||||||
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
save_op_s_l = (t_save_op_s *)(&(save_op[nop]));
|
save_op_s_l = (t_save_op_s *)(&(save_op[nop]));
|
||||||
save_op_s_l->operat = IFSUB;
|
save_op_s_l->operat = IFSUB;
|
||||||
|
@ -2074,11 +2065,8 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
|
||||||
{
|
{
|
||||||
if (nop+3 >= nopa)
|
if (nop+3 >= nopa)
|
||||||
{
|
{
|
||||||
//#pragma omp critical
|
nopa = long (mem_increasing_factor*(double)nopa);
|
||||||
{
|
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
||||||
nopa = int (1.5*nopa);
|
|
||||||
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
save_op_s_l = (t_save_op_s *)(&(save_op[nop]));
|
save_op_s_l = (t_save_op_s *)(&(save_op[nop]));
|
||||||
save_op_s_l->operat = IFSUB;
|
save_op_s_l->operat = IFSUB;
|
||||||
|
|
|
@ -94,6 +94,7 @@ const int IFADD = 7;
|
||||||
const double eps = 1e-10;
|
const double eps = 1e-10;
|
||||||
const double very_big = 1e24;
|
const double very_big = 1e24;
|
||||||
const int alt_symbolic_count_max = 1;
|
const int alt_symbolic_count_max = 1;
|
||||||
|
const double mem_increasing_factor = 1.1;
|
||||||
|
|
||||||
class SparseMatrix
|
class SparseMatrix
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue