preprocessor: fix bug introduced in eb2890d1f5
parent
2846a7023d
commit
0fdf76dcf7
|
@ -2122,9 +2122,15 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
|
||||||
julia ? oJuliaDynamicModel : oMatlabDynamicModel);
|
julia ? oJuliaDynamicModel : oMatlabDynamicModel);
|
||||||
|
|
||||||
deriv_node_temp_terms_t tef_terms;
|
deriv_node_temp_terms_t tef_terms;
|
||||||
|
temporary_terms_t temp_terms;
|
||||||
|
if (julia)
|
||||||
|
temp_terms = temporary_terms_res;
|
||||||
|
else
|
||||||
|
temp_terms = temporary_terms;
|
||||||
|
|
||||||
writeModelLocalVariables(model_local_vars_output, output_type, tef_terms);
|
writeModelLocalVariables(model_local_vars_output, output_type, tef_terms);
|
||||||
|
|
||||||
writeTemporaryTerms(temporary_terms_res, model_output, output_type, tef_terms);
|
writeTemporaryTerms(temp_terms, model_output, output_type, tef_terms);
|
||||||
|
|
||||||
writeModelEquations(model_output, output_type);
|
writeModelEquations(model_output, output_type);
|
||||||
|
|
||||||
|
@ -2132,7 +2138,12 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
|
||||||
int hessianColsNbr = dynJacobianColsNbr * dynJacobianColsNbr;
|
int hessianColsNbr = dynJacobianColsNbr * dynJacobianColsNbr;
|
||||||
|
|
||||||
// Writing Jacobian
|
// Writing Jacobian
|
||||||
writeTemporaryTerms(temporary_terms_g1, jacobian_output, output_type, tef_terms);
|
if (julia)
|
||||||
|
{
|
||||||
|
temp_terms = temporary_terms_g1;
|
||||||
|
if (!first_derivatives.empty())
|
||||||
|
writeTemporaryTerms(temp_terms, jacobian_output, output_type, tef_terms);
|
||||||
|
}
|
||||||
for (first_derivatives_t::const_iterator it = first_derivatives.begin();
|
for (first_derivatives_t::const_iterator it = first_derivatives.begin();
|
||||||
it != first_derivatives.end(); it++)
|
it != first_derivatives.end(); it++)
|
||||||
{
|
{
|
||||||
|
@ -2142,13 +2153,17 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
|
||||||
|
|
||||||
jacobianHelper(jacobian_output, eq, getDynJacobianCol(var), output_type);
|
jacobianHelper(jacobian_output, eq, getDynJacobianCol(var), output_type);
|
||||||
jacobian_output << "=";
|
jacobian_output << "=";
|
||||||
d1->writeOutput(jacobian_output, output_type, temporary_terms_g1, tef_terms);
|
d1->writeOutput(jacobian_output, output_type, temp_terms, tef_terms);
|
||||||
jacobian_output << ";" << endl;
|
jacobian_output << ";" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writing Hessian
|
// Writing Hessian
|
||||||
if (second_derivatives.size() > 0)
|
if (julia)
|
||||||
writeTemporaryTerms(temporary_terms_g2, hessian_output, output_type, tef_terms);
|
{
|
||||||
|
temp_terms = temporary_terms_g2;
|
||||||
|
if (!second_derivatives.empty())
|
||||||
|
writeTemporaryTerms(temp_terms, hessian_output, output_type, tef_terms);
|
||||||
|
}
|
||||||
int k = 0; // Keep the line of a 2nd derivative in v2
|
int k = 0; // Keep the line of a 2nd derivative in v2
|
||||||
for (second_derivatives_t::const_iterator it = second_derivatives.begin();
|
for (second_derivatives_t::const_iterator it = second_derivatives.begin();
|
||||||
it != second_derivatives.end(); it++)
|
it != second_derivatives.end(); it++)
|
||||||
|
@ -2169,7 +2184,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
|
||||||
{
|
{
|
||||||
for_sym << "g2[" << eq + 1 << "," << col_nb + 1 << "]";
|
for_sym << "g2[" << eq + 1 << "," << col_nb + 1 << "]";
|
||||||
hessian_output << " @inbounds " << for_sym.str() << " = ";
|
hessian_output << " @inbounds " << for_sym.str() << " = ";
|
||||||
d2->writeOutput(hessian_output, output_type, temporary_terms_g2, tef_terms);
|
d2->writeOutput(hessian_output, output_type, temp_terms, tef_terms);
|
||||||
hessian_output << endl;
|
hessian_output << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2182,7 +2197,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
|
||||||
|
|
||||||
sparseHelper(2, hessian_output, k, 2, output_type);
|
sparseHelper(2, hessian_output, k, 2, output_type);
|
||||||
hessian_output << "=";
|
hessian_output << "=";
|
||||||
d2->writeOutput(hessian_output, output_type, temporary_terms, tef_terms);
|
d2->writeOutput(hessian_output, output_type, temp_terms, tef_terms);
|
||||||
hessian_output << ";" << endl;
|
hessian_output << ";" << endl;
|
||||||
|
|
||||||
k++;
|
k++;
|
||||||
|
@ -2211,8 +2226,12 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writing third derivatives
|
// Writing third derivatives
|
||||||
if (third_derivatives.size() > 0)
|
if (julia)
|
||||||
writeTemporaryTerms(temporary_terms_g3, third_derivatives_output, output_type, tef_terms);
|
{
|
||||||
|
temp_terms = temporary_terms_g3;
|
||||||
|
if (!third_derivatives.empty())
|
||||||
|
writeTemporaryTerms(temp_terms, third_derivatives_output, output_type, tef_terms);
|
||||||
|
}
|
||||||
k = 0; // Keep the line of a 3rd derivative in v3
|
k = 0; // Keep the line of a 3rd derivative in v3
|
||||||
for (third_derivatives_t::const_iterator it = third_derivatives.begin();
|
for (third_derivatives_t::const_iterator it = third_derivatives.begin();
|
||||||
it != third_derivatives.end(); it++)
|
it != third_derivatives.end(); it++)
|
||||||
|
@ -2235,7 +2254,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
|
||||||
{
|
{
|
||||||
for_sym << "g3[" << eq + 1 << "," << ref_col + 1 << "]";
|
for_sym << "g3[" << eq + 1 << "," << ref_col + 1 << "]";
|
||||||
third_derivatives_output << " @inbounds " << for_sym.str() << " = ";
|
third_derivatives_output << " @inbounds " << for_sym.str() << " = ";
|
||||||
d3->writeOutput(third_derivatives_output, output_type, temporary_terms_g3, tef_terms);
|
d3->writeOutput(third_derivatives_output, output_type, temp_terms, tef_terms);
|
||||||
third_derivatives_output << endl;
|
third_derivatives_output << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2248,7 +2267,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia
|
||||||
|
|
||||||
sparseHelper(3, third_derivatives_output, k, 2, output_type);
|
sparseHelper(3, third_derivatives_output, k, 2, output_type);
|
||||||
third_derivatives_output << "=";
|
third_derivatives_output << "=";
|
||||||
d3->writeOutput(third_derivatives_output, output_type, temporary_terms, tef_terms);
|
d3->writeOutput(third_derivatives_output, output_type, temp_terms, tef_terms);
|
||||||
third_derivatives_output << ";" << endl;
|
third_derivatives_output << ";" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue