Skip to content

Commit

Permalink
fix for jacobian tmp var in cpp template
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13883 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
niklwors committed Nov 13, 2012
1 parent 5b0d61b commit a4f5f0f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Compiler/Template/CodegenCpp.tpl
Expand Up @@ -2038,6 +2038,7 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
HistoryImplType* _historyImpl;
SparseMatrix _jacobian;
ublas::vector<double> _jac_y;
ublas::vector<double> _jac_tmp;
ublas::vector<double> _jac_x;
boost::shared_ptr<IAlgLoopSolverFactory>
_algLoopSolverFactory; ///< Factory that provides an appropriate solver
Expand Down Expand Up @@ -6865,6 +6866,7 @@ case "A" then
{
_jacobian = SparseMatrix(<%index_%>,<%indexColumn%>,<%sp_size_index%>);
_jac_y = ublas::zero_vector<double>(<%index_%>);
_jac_tmp = ublas::zero_vector<double>(<%index_%>);
_jac_x = ublas::zero_vector<double>(<%index_%>);
}
Expand Down Expand Up @@ -6966,7 +6968,7 @@ case _ then

let jaccol = ( indexes |> i_index =>
//' _jacobian(<%index0%>,<%intSub(cref(i_index),1)%>) = _jac_y(<%intSub(cref(i_index),1)%>);'
' _jacobian(<%index0%>,<%cref(i_index)%>) = _jac_y(<%cref(i_index)%>);'
' _jacobian(<%index0%>,<%cref(i_index)%><%matrixname%>$indexdiff) = _jac_y(<%cref(i_index)%><%matrixname%>$indexdiff);'
;separator="\n" )
' _jac_x(<%index0%>)=1;
calcJacobianColumn();
Expand Down Expand Up @@ -7062,7 +7064,7 @@ template defineSparseIndexes(list<SimVar> diffVars, list<SimVar> diffedVars, Str
Generates Matrixes for Linear Model."
::=
let diffVarsResult = (diffVars |> var as SIMVAR(name=name) hasindex index0 =>
'#define <%cref(name)%> <%index0%>'
'#define <%cref(name)%><%matrixName%>$indexdiff <%index0%>'
;separator="\n")
/* generate at least one print command to have the same index and avoid the strange side effect */
<<
Expand Down

0 comments on commit a4f5f0f

Please sign in to comment.