Bytecode MEX: various fixes to debug mode

time-shift
Sébastien Villemot 2020-05-12 23:08:04 +02:00
parent ca0227c62c
commit 31a9a5e9ab
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
3 changed files with 37 additions and 37 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 2007-2017 Dynare Team * Copyright © 2007-2020 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -1789,7 +1789,7 @@ public:
unsigned int nb_add_input_arguments = fc->get_nb_add_input_arguments(); unsigned int nb_add_input_arguments = fc->get_nb_add_input_arguments();
function_type = fc->get_function_type(); function_type = fc->get_function_type();
#ifdef DEBUG #ifdef DEBUG
mexPrintf("function_type=%d ExternalFunctionWithoutDerivative=%d\n", function_type, ExternalFunctionWithoutDerivative); mexPrintf("function_type=%d ExternalFunctionWithoutDerivative=%d\n", function_type, ExternalFunctionType::withoutDerivative);
mexEvalString("drawnow;"); mexEvalString("drawnow;");
#endif #endif
mxArray **input_arguments; mxArray **input_arguments;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 2013-2017 Dynare Team * Copyright © 2013-2020 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -455,7 +455,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int
//load a temporary variable in the processor //load a temporary variable in the processor
var = static_cast<FLDT_ *>(it_code->second)->get_pos(); var = static_cast<FLDT_ *>(it_code->second)->get_pos();
#ifdef DEBUG #ifdef DEBUG
mexPrintf("T[it_=%d var=%d, y_kmin=%d, y_kmax=%d == %d]=>%f\n", it_, var, y_kmin, y_kmax, var*(periods+y_kmin+y_kmax)+it_, var); mexPrintf("FLDT T[it_=%d var=%d, y_kmin=%d, y_kmax=%d == %d]=>%f\n", it_, var, y_kmin, y_kmax, var*(periods+y_kmin+y_kmax)+it_, T[var*(periods+y_kmin+y_kmax)+it_]);
tmp_out << " T[" << it_ << ", " << var << "](" << T[var*(periods+y_kmin+y_kmax)+it_] << ")"; tmp_out << " T[" << it_ << ", " << var << "](" << T[var*(periods+y_kmin+y_kmax)+it_] << ")";
#endif #endif
Stack.push(T[var*(periods+y_kmin+y_kmax)+it_]); Stack.push(T[var*(periods+y_kmin+y_kmax)+it_]);
@ -783,11 +783,11 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int
tmp << " in compute_block_time, variable " << EQN_type << " not used yet\n"; tmp << " in compute_block_time, variable " << EQN_type << " not used yet\n";
throw FatalExceptionHandling(tmp.str()); throw FatalExceptionHandling(tmp.str());
} }
#ifdef DEBUG // #ifdef DEBUG
tmp_out << "=>"; // tmp_out << "=>";
mexPrintf(" g1[%d](%f)=%s\n", var, g1[var], tmp_out.str().c_str()); // mexPrintf(" g1[%d](%f)=%s\n", var, g1[var], tmp_out.str().c_str());
tmp_out.str(""); // tmp_out.str("");
#endif // #endif
Stack.pop(); Stack.pop();
break; break;
@ -1160,7 +1160,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int
unsigned int nb_add_input_arguments = fc->get_nb_add_input_arguments(); unsigned int nb_add_input_arguments = fc->get_nb_add_input_arguments();
function_type = fc->get_function_type(); function_type = fc->get_function_type();
#ifdef DEBUG #ifdef DEBUG
mexPrintf("function_type=%d ExternalFunctionWithoutDerivative=%d\n", function_type, ExternalFunctionWithoutDerivative); mexPrintf("function_type=%d ExternalFunctionWithoutDerivative=%d\n", function_type, ExternalFunctionType::withoutDerivative);
mexEvalString("drawnow;"); mexEvalString("drawnow;");
#endif #endif
mxArray **input_arguments; mxArray **input_arguments;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 2007-2017 Dynare Team * Copyright © 2007-2020 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -1083,23 +1083,23 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
while (it4 != IM.end()) while (it4 != IM.end())
{ {
var = it4->first.first.first; var = it4->first.first.first;
#ifdef DEBUG // #ifdef DEBUG
if (var < 0 || var >= Size) // if (var < 0 || var >= Size)
{ // {
ostringstream tmp; // ostringstream tmp;
tmp << " in Init_UMFPACK_Sparse, var (" << var << ") out of range\n"; // tmp << " in Init_UMFPACK_Sparse, var (" << var << ") out of range\n";
throw FatalExceptionHandling(tmp.str()); // throw FatalExceptionHandling(tmp.str());
} // }
#endif // #endif
eq = it4->first.second+Size*t; eq = it4->first.second+Size*t;
#ifdef DEBUG // #ifdef DEBUG
if (eq < 0 || eq >= Size) // if (eq < 0 || eq >= Size)
{ // {
ostringstream tmp; // ostringstream tmp;
tmp << " in Init_UMFPACK_Sparse, eq (" << eq << ") out of range\n"; // tmp << " in Init_UMFPACK_Sparse, eq (" << eq << ") out of range\n";
throw FatalExceptionHandling(tmp.str()); // throw FatalExceptionHandling(tmp.str());
} // }
#endif // #endif
lag = -it4->first.first.second; lag = -it4->first.first.second;
int index = it4->second+ (t-lag) * u_count_init; int index = it4->second+ (t-lag) * u_count_init;
if (var != last_var) if (var != last_var)
@ -1181,12 +1181,12 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
if (lag <= ti_new_y_kmax && lag >= ti_new_y_kmin) /*Build the index for sparse matrix containing the jacobian : u*/ if (lag <= ti_new_y_kmax && lag >= ti_new_y_kmin) /*Build the index for sparse matrix containing the jacobian : u*/
{ {
#ifdef DEBUG #ifdef DEBUG
if (index < 0 || index >= u_count_alloc || index > Size + Size*Size) // if (index < 0 || index >= u_count_alloc || index > Size + Size*Size)
{ // {
ostringstream tmp; // ostringstream tmp;
tmp << " in Init_UMFPACK_Sparse, index (" << index << ") out of range for u vector max = " << Size+Size*Size << " allocated = " << u_count_alloc << "\n"; // tmp << " in Init_UMFPACK_Sparse, index (" << index << ") out of range for u vector max = " << Size+Size*Size << " allocated = " << u_count_alloc << "\n";
throw FatalExceptionHandling(tmp.str()); // throw FatalExceptionHandling(tmp.str());
} // }
if (NZE >= max_nze) if (NZE >= max_nze)
{ {
ostringstream tmp; ostringstream tmp;
@ -1275,7 +1275,7 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
(*Ap)[Size*periods] = NZE; (*Ap)[Size*periods] = NZE;
#ifdef DEBUG #ifdef DEBUG
mexPrintf("*Ax = ["); mexPrintf("*Ax = [");
for (int i = 0; i < NZE; i++) for (int i = 0; i < static_cast<int>(NZE); i++)
mexPrintf("%f ", (*Ax)[i]); mexPrintf("%f ", (*Ax)[i]);
mexPrintf("]\n"); mexPrintf("]\n");
@ -1285,7 +1285,7 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
mexPrintf("]\n"); mexPrintf("]\n");
mexPrintf("*Ai = ["); mexPrintf("*Ai = [");
for (int i = 0; i < NZE; i++) for (int i = 0; i < static_cast<int>(NZE); i++)
mexPrintf("%d ", (*Ai)[i]); mexPrintf("%d ", (*Ai)[i]);
mexPrintf("]\n"); mexPrintf("]\n");
#endif #endif
@ -6294,9 +6294,9 @@ dynSparseMatrix::Simulate_One_Boundary(int block_num, int y_size, int y_kmin, in
break; break;
} }
if (select) if (select)
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]); mexPrintf("-> variable %s (%d) at time %d = %f direction = %f\n", get_variable(SymbolType::endogenous, j).c_str(), j+1, it_, y[j+it_*y_size], direction[j+it_*y_size]);
else else
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]); mexPrintf(" variable %s (%d) at time %d = %f direction = %f\n", get_variable(SymbolType::endogenous, j).c_str(), j+1, it_, y[j+it_*y_size], direction[j+it_*y_size]);
} }
#endif #endif
if (steady_state) if (steady_state)