- The function getPowerDeriv must end with an "end" instruction

issue#70
Ferhat Mihoubi 2010-12-17 14:21:35 +01:00
parent 1dd5493c1a
commit 7a6776197d
3 changed files with 12 additions and 8 deletions

View File

@ -651,13 +651,15 @@ DataTree::writePowerDeriv(ostream &output, bool use_dll) const
<< "% The k-th derivative of x^p" << endl
<< "%" << endl
<< "function dxp=getPowerDeriv(x,p,k)" << endl
<< "if (abs(x) < " << NEAR_ZERO << ") && (p > 0) && (k >= p) && (abs(p - round(p)) < " << NEAR_ZERO << ")" << endl
<< " dxp = 0;" << endl
<< "else" << endl
<< " dxp = x^(p-k);" << endl
<< " for i=0:k-1" << endl
<< " dxp = dxp*p;" << endl
<< " p = p-1;" << endl
<< " if (abs(x) < " << NEAR_ZERO << ") && (p > 0) && (k >= p) && (abs(p - round(p)) < " << NEAR_ZERO << ")" << endl
<< " dxp = 0;" << endl
<< " else" << endl
<< " dxp = x^(p-k);" << endl
<< " for i=0:k-1" << endl
<< " dxp = dxp*p;" << endl
<< " p = p-1;" << endl
<< " end" << endl
<< " end" << endl
<< "end" << endl;
}

View File

@ -795,6 +795,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
default:
break;
}
output << "end" << endl;
writePowerDeriv(output, false);
output.close();
}
@ -2033,7 +2034,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
open_par = false;
mDynamicModelFile << " oo_.endo_simul = y';\n";
mDynamicModelFile << "return;\n";
mDynamicModelFile << "end" << endl;
writePowerDeriv(mDynamicModelFile, false);
mDynamicModelFile.close();

View File

@ -407,6 +407,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &static_basename) const
default:
break;
}
output << "end" << endl;
writePowerDeriv(output, false);
output.close();
}