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")));
|
||||
R = mxGetM(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++)
|
||||
res << P[2*(EQN_dvar1+i*R)];
|
||||
res << P[2*(variable_num+i*R)];
|
||||
else
|
||||
mexPrintf("=> Unknown endogenous variable n° %d",EQN_dvar1);
|
||||
break;
|
||||
case eExogenous:
|
||||
case eExogenousDet:
|
||||
C = mxGetN(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")));
|
||||
if (EQN_dvar1 < R)
|
||||
if (variable_num < R)
|
||||
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;
|
||||
case eParameter:
|
||||
C = mxGetN(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")));
|
||||
if (EQN_dvar1 < R)
|
||||
if (variable_num < R)
|
||||
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;
|
||||
default:
|
||||
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)
|
||||
{
|
||||
nopa = int (1.5*nopa);
|
||||
nopa = long (mem_increasing_factor*(double)nopa);
|
||||
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
||||
}
|
||||
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)
|
||||
{
|
||||
nopa = int (1.5*nopa);
|
||||
nopa = long (mem_increasing_factor*(double)nopa);
|
||||
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
||||
}
|
||||
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)
|
||||
{
|
||||
nopa = int (1.5*nopa);
|
||||
nopa = long (mem_increasing_factor*(double)nopa);
|
||||
save_op = (int *) mxRealloc(save_op, nopa*sizeof(int));
|
||||
}
|
||||
save_op_s = (t_save_op_s *)(&(save_op[nop]));
|
||||
|
@ -1926,14 +1926,11 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
|
|||
{
|
||||
if (record)
|
||||
{
|
||||
if (nop+2 >= nopa)
|
||||
if (nop+1 >= nopa)
|
||||
{
|
||||
//#pragma omp critical
|
||||
{
|
||||
nopa = int (1.5*nopa);
|
||||
nopa = long (mem_increasing_factor*(double)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->operat = IFLD;
|
||||
save_op_s_l->first = first->u_index;
|
||||
|
@ -1979,12 +1976,9 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
|
|||
{
|
||||
if (nop+2 >= nopa)
|
||||
{
|
||||
//#pragma omp critical
|
||||
{
|
||||
nopa = int (1.5*nopa);
|
||||
nopa = long (mem_increasing_factor*(double)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->operat = IFLESS;
|
||||
save_op_s_l->first = tmp_u_count;
|
||||
|
@ -2037,12 +2031,9 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
|
|||
{
|
||||
if (nop+3 >= nopa)
|
||||
{
|
||||
//#pragma omp critical
|
||||
{
|
||||
nopa = int (1.5*nopa);
|
||||
nopa = long (mem_increasing_factor*(double)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->operat = IFSUB;
|
||||
save_op_s_l->first = first_sub->u_index;
|
||||
|
@ -2074,12 +2065,9 @@ SparseMatrix::simulate_NG1(int blck, int y_size, int it_, int y_kmin, int y_kmax
|
|||
{
|
||||
if (nop+3 >= nopa)
|
||||
{
|
||||
//#pragma omp critical
|
||||
{
|
||||
nopa = int (1.5*nopa);
|
||||
nopa = long (mem_increasing_factor*(double)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->operat = IFSUB;
|
||||
save_op_s_l->first = b[row];
|
||||
|
|
|
@ -94,6 +94,7 @@ const int IFADD = 7;
|
|||
const double eps = 1e-10;
|
||||
const double very_big = 1e24;
|
||||
const int alt_symbolic_count_max = 1;
|
||||
const double mem_increasing_factor = 1.1;
|
||||
|
||||
class SparseMatrix
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue