Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
fe1b2411
Commit
fe1b2411
authored
Jun 17, 2011
by
Ferhat Mihoubi
Browse files
Add an option in bytecode to prevent the display of error messages .
parent
597a4b92
Changes
4
Hide whitespace changes
Inline
Side-by-side
mex/sources/bytecode/ErrorHandling.hh
View file @
fe1b2411
...
...
@@ -505,9 +505,6 @@ public:
Stack
.
push
(
get_variable
(
eParameter
,
var
));
if
(
compute
)
Stackf
.
push
(
params
[
var
]);
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
eEndogenous
:
var
=
((
FLDV_
*
)
it_code
->
second
)
->
get_pos
();
...
...
@@ -530,10 +527,6 @@ public:
else
Stackf
.
push
(
y
[(
it_
+
lag
)
*
y_size
+
var
]);
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
eExogenous
:
var
=
((
FLDV_
*
)
it_code
->
second
)
->
get_pos
();
...
...
@@ -549,9 +542,6 @@ public:
Stack
.
push
(
tmp_out
.
str
());
if
(
compute
)
Stackf
.
push
(
x
[
it_
+
lag
+
var
*
nb_row_x
]);
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
eExogenousDet
:
var
=
((
FLDV_
*
)
it_code
->
second
)
->
get_pos
();
...
...
@@ -567,9 +557,6 @@ public:
Stack
.
push
(
tmp_out
.
str
());
if
(
compute
)
Stackf
.
push
(
x
[
it_
+
lag
+
var
*
nb_row_xd
]);
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
eModelLocalVariable
:
break
;
...
...
@@ -590,9 +577,6 @@ public:
Stack
.
push
(
get_variable
(
eParameter
,
var
));
if
(
compute
)
Stackf
.
push
(
params
[
var
]);
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
eEndogenous
:
var
=
((
FLDSV_
*
)
it_code
->
second
)
->
get_pos
();
...
...
@@ -612,9 +596,6 @@ public:
else
Stackf
.
push
(
steady_y
[
var
]);
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
eExogenous
:
var
=
((
FLDSV_
*
)
it_code
->
second
)
->
get_pos
();
...
...
@@ -627,9 +608,6 @@ public:
#endif
if
(
compute
)
Stackf
.
push
(
x
[
var
]);
#ifdef DEBUG
mexPrintf
(
"okb
\n
"
);
#endif
break
;
case
eExogenousDet
:
var
=
((
FLDSV_
*
)
it_code
->
second
)
->
get_pos
();
...
...
@@ -639,9 +617,6 @@ public:
Stack
.
push
(
get_variable
(
eExogenousDet
,
var
));
if
(
compute
)
Stackf
.
push
(
x
[
var
]);
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
eModelLocalVariable
:
break
;
...
...
@@ -660,9 +635,6 @@ public:
Stack
.
push
(
tmp_out
.
str
());
if
(
compute
)
Stackf
.
push
(
T
[
var
*
(
periods
+
y_kmin
+
y_kmax
)
+
it_
]);
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FLDST
:
//load a temporary variable in the processor
...
...
@@ -675,9 +647,6 @@ public:
Stack
.
push
(
tmp_out
.
str
());
if
(
compute
)
Stackf
.
push
(
T
[
var
]);
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FLDU
:
//load u variable in the processor
...
...
@@ -691,9 +660,6 @@ public:
var
+=
Per_u_
;
if
(
compute
)
Stackf
.
push
(
u
[
var
]);
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FLDSU
:
//load u variable in the processor
...
...
@@ -706,9 +672,6 @@ public:
Stack
.
push
(
tmp_out
.
str
());
if
(
compute
)
Stackf
.
push
(
u
[
var
]);
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FLDR
:
var
=
((
FLDR_
*
)
it_code
->
second
)
->
get_pos
();
...
...
@@ -720,9 +683,6 @@ public:
Stack
.
push
(
tmp_out
.
str
());
if
(
compute
)
Stackf
.
push
(
r
[
var
]);
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FLDZ
:
//load 0 in the processor
...
...
@@ -734,9 +694,6 @@ public:
Stack
.
push
(
tmp_out
.
str
());
if
(
compute
)
Stackf
.
push
(
0.0
);
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FLDC
:
//load a numerical constant in the processor
...
...
@@ -749,9 +706,6 @@ public:
Stack
.
push
(
tmp_out
.
str
());
if
(
compute
)
Stackf
.
push
(
ll
);
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FSTPV
:
//load a variable in the processor
...
...
@@ -773,10 +727,6 @@ public:
params
[
var
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
eEndogenous
:
var
=
((
FSTPV_
*
)
it_code
->
second
)
->
get_pos
();
...
...
@@ -799,9 +749,6 @@ public:
y
[(
it_
+
lag
)
*
y_size
+
var
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
eExogenous
:
var
=
((
FSTPV_
*
)
it_code
->
second
)
->
get_pos
();
...
...
@@ -822,9 +769,6 @@ public:
x
[
it_
+
lag
+
var
*
nb_row_x
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
eExogenousDet
:
var
=
((
FSTPV_
*
)
it_code
->
second
)
->
get_pos
();
...
...
@@ -845,9 +789,6 @@ public:
x
[
it_
+
lag
+
var
*
nb_row_xd
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
default:
mexPrintf
(
"FSTPV: Unknown variable type
\n
"
);
...
...
@@ -874,9 +815,6 @@ public:
params
[
var
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
eEndogenous
:
var
=
((
FSTPSV_
*
)
it_code
->
second
)
->
get_pos
();
...
...
@@ -894,9 +832,6 @@ public:
y
[
var
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
eExogenous
:
case
eExogenousDet
:
...
...
@@ -915,9 +850,6 @@ public:
x
[
var
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
default:
mexPrintf
(
"FSTPSV: Unknown variable type
\n
"
);
...
...
@@ -938,9 +870,6 @@ public:
T
[
var
*
(
periods
+
y_kmin
+
y_kmax
)
+
it_
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FSTPST
:
go_on
=
false
;
...
...
@@ -957,9 +886,6 @@ public:
T
[
var
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FSTPU
:
go_on
=
false
;
...
...
@@ -977,9 +903,6 @@ public:
u
[
var
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FSTPSU
:
go_on
=
false
;
...
...
@@ -996,9 +919,6 @@ public:
u
[
var
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FSTPR
:
go_on
=
false
;
...
...
@@ -1015,9 +935,6 @@ public:
r
[
var
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FSTPG
:
go_on
=
false
;
...
...
@@ -1034,9 +951,6 @@ public:
g1
[
var
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FSTPG2
:
go_on
=
false
;
...
...
@@ -1054,9 +968,6 @@ public:
jacob
[
eq
+
size
*
var
]
=
Stackf
.
top
();
Stackf
.
pop
();
}
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
FSTPG3
:
//store in derivative (g) variable from the processor
...
...
@@ -1148,9 +1059,6 @@ public:
tmp_out
.
str
(
""
);
tmp_out
<<
v1
<<
" + "
<<
v2
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oMinus
:
#ifdef DEBUG
...
...
@@ -1173,9 +1081,6 @@ public:
if
(
found
!=
string
::
npos
)
tmp_out
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oTimes
:
#ifdef DEBUG
...
...
@@ -1198,9 +1103,6 @@ public:
if
(
found
!=
string
::
npos
)
tmp_out
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oDivide
:
#ifdef DEBUG
...
...
@@ -1235,9 +1137,6 @@ public:
if
(
found
!=
string
::
npos
)
tmp_out
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oLess
:
#ifdef DEBUG
...
...
@@ -1260,9 +1159,6 @@ public:
if
(
found
!=
string
::
npos
)
tmp_out
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oGreater
:
#ifdef DEBUG
...
...
@@ -1285,9 +1181,6 @@ public:
if
(
found
!=
string
::
npos
)
tmp_out
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oLessEqual
:
#ifdef DEBUG
...
...
@@ -1310,9 +1203,6 @@ public:
if
(
found
!=
string
::
npos
)
tmp_out
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oGreaterEqual
:
#ifdef DEBUG
...
...
@@ -1335,9 +1225,6 @@ public:
if
(
found
!=
string
::
npos
)
tmp_out
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oEqualEqual
:
#ifdef DEBUG
...
...
@@ -1360,9 +1247,6 @@ public:
if
(
found
!=
string
::
npos
)
tmp_out
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oDifferent
:
#ifdef DEBUG
...
...
@@ -1385,9 +1269,6 @@ public:
if
(
found
!=
string
::
npos
)
tmp_out
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oPower
:
#ifdef DEBUG
...
...
@@ -1421,9 +1302,6 @@ public:
if
(
found
!=
string
::
npos
)
tmp_out
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oPowerDeriv
:
{
...
...
@@ -1475,9 +1353,6 @@ public:
tmp_out
.
str
(
""
);
tmp_out
<<
"max("
<<
v1
<<
", "
<<
v2
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oMin
:
#ifdef DEBUG
...
...
@@ -1488,9 +1363,6 @@ public:
tmp_out
.
str
(
""
);
tmp_out
<<
"min("
<<
v1
<<
", "
<<
v2
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#ifdef DEBUG
mexPrintf
(
"ok
\n
"
);
#endif
break
;
case
oEqual
:
default:
...
...
mex/sources/bytecode/Interpreter.cc
View file @
fe1b2411
...
...
@@ -33,7 +33,7 @@ Interpreter::Interpreter(double *params_arg, double *y_arg, double *ya_arg, doub
int
nb_row_x_arg
,
int
nb_row_xd_arg
,
int
periods_arg
,
int
y_kmin_arg
,
int
y_kmax_arg
,
int
maxit_arg_
,
double
solve_tolf_arg
,
int
size_of_direction_arg
,
double
slowc_arg
,
int
y_decal_arg
,
double
markowitz_c_arg
,
string
&
filename_arg
,
int
minimal_solving_periods_arg
,
int
stack_solve_algo_arg
,
int
solve_algo_arg
,
bool
global_temporary_terms_arg
,
bool
print_arg
,
mxArray
*
GlobalTemporaryTerms_arg
)
bool
global_temporary_terms_arg
,
bool
print_arg
,
bool
print_error_arg
,
mxArray
*
GlobalTemporaryTerms_arg
)
{
params
=
params_arg
;
y
=
y_arg
;
...
...
@@ -64,6 +64,7 @@ Interpreter::Interpreter(double *params_arg, double *y_arg, double *ya_arg, doub
global_temporary_terms
=
global_temporary_terms_arg
;
print
=
print_arg
;
GlobalTemporaryTerms
=
GlobalTemporaryTerms_arg
;
print_error
=
print_error_arg
;
}
double
...
...
@@ -74,7 +75,8 @@ Interpreter::pow1(double a, double b)
{
res1
=
NAN
;
r
=
0.0000000000000000000000001
;
throw
PowExceptionHandling
(
a
,
b
);
if
(
print_error
)
throw
PowExceptionHandling
(
a
,
b
);
}
return
r
;
}
...
...
@@ -87,7 +89,8 @@ Interpreter::divide(double a, double b)
{
res1
=
NAN
;
r
=
1e70
;
throw
DivideExceptionHandling
(
a
,
b
);
if
(
print_error
)
throw
DivideExceptionHandling
(
a
,
b
);
}
return
r
;
}
...
...
@@ -100,7 +103,8 @@ Interpreter::log1(double a)
{
res1
=
NAN
;
r
=
-
1e70
;
throw
LogExceptionHandling
(
a
);
if
(
print_error
)
throw
LogExceptionHandling
(
a
);
}
return
r
;
}
...
...
@@ -113,7 +117,8 @@ Interpreter::log10_1(double a)
{
res1
=
NAN
;
r
=
-
1e70
;
throw
Log10ExceptionHandling
(
a
);
if
(
print_error
)
throw
Log10ExceptionHandling
(
a
);
}
return
r
;
}
...
...
mex/sources/bytecode/Interpreter.hh
View file @
fe1b2411
...
...
@@ -74,14 +74,14 @@ protected:
int
minimal_solving_periods
;
int
stack_solve_algo
,
solve_algo
;
bool
global_temporary_terms
;
bool
print
;
bool
print
,
print_error
;
public:
~
Interpreter
();
Interpreter
(
double
*
params_arg
,
double
*
y_arg
,
double
*
ya_arg
,
double
*
x_arg
,
double
*
steady_y_arg
,
double
*
steady_x_arg
,
double
*
direction_arg
,
int
y_size_arg
,
int
nb_row_x_arg
,
int
nb_row_xd_arg
,
int
periods_arg
,
int
y_kmin_arg
,
int
y_kmax_arg
,
int
maxit_arg_
,
double
solve_tolf_arg
,
int
size_o_direction_arg
,
double
slowc_arg
,
int
y_decal_arg
,
double
markowitz_c_arg
,
string
&
filename_arg
,
int
minimal_solving_periods_arg
,
int
stack_solve_algo_arg
,
int
solve_algo_arg
,
bool
global_temporary_terms_arg
,
bool
print_arg
,
mxArray
*
GlobalTemporaryTerms_arg
);
bool
global_temporary_terms_arg
,
bool
print_arg
,
bool
print_error_arg
,
mxArray
*
GlobalTemporaryTerms_arg
);
bool
compute_blocks
(
string
file_name
,
string
bin_basename
,
bool
steady_state
,
bool
evaluate
,
int
block
,
int
&
nb_blocks
);
inline
mxArray
*
get_jacob
(
int
block_num
)
...
...
mex/sources/bytecode/bytecode.cc
View file @
fe1b2411
...
...
@@ -68,6 +68,7 @@ Get_Arguments_and_global_variables(int nrhs,
bool
&
steady_state
,
bool
&
evaluate
,
int
&
block
,
mxArray
*
M_
[],
mxArray
*
oo_
[],
mxArray
*
options_
[],
bool
&
global_temporary_terms
,
bool
&
print
,
bool
&
print_error
,
mxArray
*
GlobalTemporaryTerms
[])
{
#ifdef DEBUG_EX
...
...
@@ -127,6 +128,8 @@ Get_Arguments_and_global_variables(int nrhs,
global_temporary_terms
=
true
;
else
if
(
Get_Argument
(
prhs
[
i
])
==
"print"
)
print
=
true
;
else
if
(
Get_Argument
(
prhs
[
i
])
==
"no_print_error"
)
print_error
=
false
;
else
{
int
pos
=
Get_Argument
(
prhs
[
i
]).
find
(
"block"
);
...
...
@@ -213,7 +216,7 @@ main(int nrhs, const char *prhs[])
double
*
yd
=
NULL
,
*
xd
=
NULL
;
int
count_array_argument
=
0
;
bool
global_temporary_terms
=
false
;
bool
print
=
false
;
bool
print
=
false
,
print_error
=
true
;
double
*
steady_yd
=
NULL
,
*
steady_xd
=
NULL
;
try
...
...
@@ -229,7 +232,7 @@ main(int nrhs, const char *prhs[])
#endif
steady_state
,
evaluate
,
block
,
&
M_
,
&
oo_
,
&
options_
,
global_temporary_terms
,
print
,
&
GlobalTemporaryTerms
);
print
,
print_error
,
&
GlobalTemporaryTerms
);
}
catch
(
GeneralExceptionHandling
&
feh
)
{
...
...
@@ -330,7 +333,7 @@ main(int nrhs, const char *prhs[])
int
nb_row_x
=
row_x
;
clock_t
t0
=
clock
();
Interpreter
interprete
(
params
,
y
,
ya
,
x
,
steady_yd
,
steady_xd
,
direction
,
y_size
,
nb_row_x
,
nb_row_xd
,
periods
,
y_kmin
,
y_kmax
,
maxit_
,
solve_tolf
,
size_of_direction
,
slowc
,
y_decal
,
markowitz_c
,
file_name
,
minimal_solving_periods
,
stack_solve_algo
,
solve_algo
,
global_temporary_terms
,
print
,
GlobalTemporaryTerms
);
Interpreter
interprete
(
params
,
y
,
ya
,
x
,
steady_yd
,
steady_xd
,
direction
,
y_size
,
nb_row_x
,
nb_row_xd
,
periods
,
y_kmin
,
y_kmax
,
maxit_
,
solve_tolf
,
size_of_direction
,
slowc
,
y_decal
,
markowitz_c
,
file_name
,
minimal_solving_periods
,
stack_solve_algo
,
solve_algo
,
global_temporary_terms
,
print
,
print_error
,
GlobalTemporaryTerms
);
string
f
(
fname
);
mxFree
(
fname
);
...
...
@@ -405,7 +408,7 @@ main(int nrhs, const char *prhs[])
jacob_field_number
=
0
;
jacob_exo_field_number
=
1
;
jacob_exo_det_field_number
=
2
;
jacob_other_endo_field_number
=
2
;
jacob_other_endo_field_number
=
3
;
mwSize
dims
[
1
]
=
{
nb_blocks
};
plhs
[
2
]
=
mxCreateStructArray
(
1
,
dims
,
4
,
field_names
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment