check function output argument sizes

time-shift
Houtan Bastani 2015-08-20 15:08:24 +02:00
parent b00ed9f0a4
commit a686a47ce7
2 changed files with 9 additions and 0 deletions

View File

@ -2373,6 +2373,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
<< "# Expected inputs of Outputs:" << endl
<< "# residual: Array(Float64, " << nrows << ", 1)" << endl
<< "#" << endl
<< "@assert size(residual) == " << nrows << endl
<< "fill!(residual, 0.0)" << endl << endl
<< "#" << endl
<< "# Model equations" << endl
@ -2390,6 +2391,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
<< " # residual: Array(Float64, " << nrows << ", 1)" << endl
<< " # g1: Array(Float64, " << nrows << ", " << dynJacobianColsNbr << ")" << endl
<< " #" << endl
<< " @assert size(g1) == (" << nrows << ", " << dynJacobianColsNbr << ")" << endl
<< " fill!(g1, 0.0)" << endl << endl
<< " dynamic!(y, x, params, steady_state, it_, residual)" << endl
<< model_output.str()
@ -2409,6 +2411,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
<< " # g1: Array(Float64, " << nrows << ", " << dynJacobianColsNbr << ")" << endl
<< " # g2: spzeros(" << nrows << ", " << hessianColsNbr << ")" << endl
<< " #" << endl << endl
<< " @assert size(g2) == (" << nrows << ", " << hessianColsNbr << ")" << endl
<< " dynamic!(y, x, params, steady_state, it_, residual, g1)" << endl;
if (second_derivatives.size())
DynamicOutput << model_output.str()
@ -2432,6 +2435,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
<< " # g2: spzeros(" << nrows << ", " << hessianColsNbr << ")" << endl
<< " # g3: spzeros(" << nrows << ", " << ncols << ")" << endl
<< " #" << endl << endl
<< " @assert size(g3) == (" << nrows << ", " << ncols << ")" << endl
<< " dynamic!(y, x, params, steady_state, it_, residual, g1, g2)" << endl;
if (third_derivatives.size())
DynamicOutput << model_output.str()

View File

@ -1443,6 +1443,7 @@ StaticModel::writeStaticModel(ostream &StaticOutput, bool use_dll, bool julia) c
<< "# Expected inputs of Outputs:" << endl
<< "# residual: Array(Float64, " << equations.size() << ", 1)" << endl
<< "#" << endl
<< "@assert size(residual) == " << equations.size() << endl
<< "fill!(residual, 0.0)" << endl << endl
<< "#" << endl
<< "# Model equations" << endl
@ -1462,6 +1463,8 @@ StaticModel::writeStaticModel(ostream &StaticOutput, bool use_dll, bool julia) c
<< " # g1: Array(Float64, " << equations.size() << ", "
<< symbol_table.endo_nbr() << ")" << endl
<< " #" << endl
<< " @assert size(g1) == (" << equations.size() << ", " << symbol_table.endo_nbr()
<< ")" << endl
<< " fill!(g1, 0.0)" << endl << endl
<< " static!(y, x, params, residual)" << endl
<< model_output.str()
@ -1484,6 +1487,7 @@ StaticModel::writeStaticModel(ostream &StaticOutput, bool use_dll, bool julia) c
<< symbol_table.endo_nbr() << ")" << endl
<< " # g2: spzeros(" << equations.size() << ", " << g2ncols << ")" << endl
<< " #" << endl << endl
<< " @assert size(g2) == (" << equations.size() << ", " << g2ncols << ")" << endl
<< " static!(y, x, params, residual, g1)" << endl;
if (second_derivatives.size())
StaticOutput << model_output.str()
@ -1508,6 +1512,7 @@ StaticModel::writeStaticModel(ostream &StaticOutput, bool use_dll, bool julia) c
<< " # g2: spzeros(" << equations.size() << ", " << g2ncols << ")" << endl
<< " # g3: spzeros(" << nrows << ", " << ncols << ")" << endl
<< " #" << endl << endl
<< " @assert size(g3) == (" << nrows << ", " << ncols << ")" << endl
<< " static!(y, x, params, residual, g1, g2)" << endl;
if (third_derivatives.size())
StaticOutput << model_output.str()