C++11: convert {Unary,Binary,Trinary}Opcode to class enums
parent
11b1fdcffd
commit
4ad0e500d4
|
@ -174,59 +174,59 @@ enum ExpressionType
|
||||||
ThirdParamDerivative
|
ThirdParamDerivative
|
||||||
};
|
};
|
||||||
|
|
||||||
enum UnaryOpcode
|
enum class UnaryOpcode
|
||||||
{
|
{
|
||||||
oUminus,
|
uminus,
|
||||||
oExp,
|
exp,
|
||||||
oLog,
|
log,
|
||||||
oLog10,
|
log10,
|
||||||
oCos,
|
cos,
|
||||||
oSin,
|
sin,
|
||||||
oTan,
|
tan,
|
||||||
oAcos,
|
acos,
|
||||||
oAsin,
|
asin,
|
||||||
oAtan,
|
atan,
|
||||||
oCosh,
|
cosh,
|
||||||
oSinh,
|
sinh,
|
||||||
oTanh,
|
tanh,
|
||||||
oAcosh,
|
acosh,
|
||||||
oAsinh,
|
asinh,
|
||||||
oAtanh,
|
atanh,
|
||||||
oSqrt,
|
sqrt,
|
||||||
oAbs,
|
abs,
|
||||||
oSign,
|
sign,
|
||||||
oSteadyState,
|
steadyState,
|
||||||
oSteadyStateParamDeriv, // for the derivative of the STEADY_STATE operator w.r.t. to a parameter
|
steadyStateParamDeriv, // for the derivative of the STEADY_STATE operator w.r.t. to a parameter
|
||||||
oSteadyStateParam2ndDeriv, // for the 2nd derivative of the STEADY_STATE operator w.r.t. to a parameter
|
steadyStateParam2ndDeriv, // for the 2nd derivative of the STEADY_STATE operator w.r.t. to a parameter
|
||||||
oExpectation,
|
expectation,
|
||||||
oErf,
|
erf,
|
||||||
oDiff,
|
diff,
|
||||||
oAdl
|
adl
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BinaryOpcode
|
enum class BinaryOpcode
|
||||||
{
|
{
|
||||||
oPlus,
|
plus,
|
||||||
oMinus,
|
minus,
|
||||||
oTimes,
|
times,
|
||||||
oDivide,
|
divide,
|
||||||
oPower,
|
power,
|
||||||
oPowerDeriv, // for the derivative of the power function (see trac ticket #78)
|
powerDeriv, // for the derivative of the power function (see trac ticket #78)
|
||||||
oEqual,
|
equal,
|
||||||
oMax,
|
max,
|
||||||
oMin,
|
min,
|
||||||
oLess,
|
less,
|
||||||
oGreater,
|
greater,
|
||||||
oLessEqual,
|
lessEqual,
|
||||||
oGreaterEqual,
|
greaterEqual,
|
||||||
oEqualEqual,
|
equalEqual,
|
||||||
oDifferent
|
different
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TrinaryOpcode
|
enum class TrinaryOpcode
|
||||||
{
|
{
|
||||||
oNormcdf,
|
normcdf,
|
||||||
oNormpdf
|
normpdf
|
||||||
};
|
};
|
||||||
|
|
||||||
enum external_function_type
|
enum external_function_type
|
||||||
|
|
|
@ -946,16 +946,16 @@ RamseyConstraintsStatement::writeOutput(ostream &output, const string &basename,
|
||||||
output << "{" << it->endo + 1 << ", '";
|
output << "{" << it->endo + 1 << ", '";
|
||||||
switch (it->code)
|
switch (it->code)
|
||||||
{
|
{
|
||||||
case oLess:
|
case BinaryOpcode::less:
|
||||||
output << '<';
|
output << '<';
|
||||||
break;
|
break;
|
||||||
case oGreater:
|
case BinaryOpcode::greater:
|
||||||
output << '>';
|
output << '>';
|
||||||
break;
|
break;
|
||||||
case oLessEqual:
|
case BinaryOpcode::lessEqual:
|
||||||
output << "<=";
|
output << "<=";
|
||||||
break;
|
break;
|
||||||
case oGreaterEqual:
|
case BinaryOpcode::greaterEqual:
|
||||||
output << ">=";
|
output << ">=";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -981,16 +981,16 @@ RamseyConstraintsStatement::writeJsonOutput(ostream &output) const
|
||||||
output << "{\"constraint\": \"" << symbol_table.getName(it->endo) << " ";
|
output << "{\"constraint\": \"" << symbol_table.getName(it->endo) << " ";
|
||||||
switch (it->code)
|
switch (it->code)
|
||||||
{
|
{
|
||||||
case oLess:
|
case BinaryOpcode::less:
|
||||||
output << '<';
|
output << '<';
|
||||||
break;
|
break;
|
||||||
case oGreater:
|
case BinaryOpcode::greater:
|
||||||
output << '>';
|
output << '>';
|
||||||
break;
|
break;
|
||||||
case oLessEqual:
|
case BinaryOpcode::lessEqual:
|
||||||
output << "<=";
|
output << "<=";
|
||||||
break;
|
break;
|
||||||
case oGreaterEqual:
|
case BinaryOpcode::greaterEqual:
|
||||||
output << ">=";
|
output << ">=";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -98,7 +98,7 @@ DataTree::AddPlus(expr_t iArg1, expr_t iArg2)
|
||||||
{
|
{
|
||||||
// Simplify x+(-y) in x-y
|
// Simplify x+(-y) in x-y
|
||||||
auto *uarg2 = dynamic_cast<UnaryOpNode *>(iArg2);
|
auto *uarg2 = dynamic_cast<UnaryOpNode *>(iArg2);
|
||||||
if (uarg2 != nullptr && uarg2->get_op_code() == oUminus)
|
if (uarg2 != nullptr && uarg2->get_op_code() == UnaryOpcode::uminus)
|
||||||
return AddMinus(iArg1, uarg2->get_arg());
|
return AddMinus(iArg1, uarg2->get_arg());
|
||||||
|
|
||||||
// To treat commutativity of "+"
|
// To treat commutativity of "+"
|
||||||
|
@ -109,7 +109,7 @@ DataTree::AddPlus(expr_t iArg1, expr_t iArg2)
|
||||||
iArg1 = iArg2;
|
iArg1 = iArg2;
|
||||||
iArg2 = tmp;
|
iArg2 = tmp;
|
||||||
}
|
}
|
||||||
return AddBinaryOp(iArg1, oPlus, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::plus, iArg2);
|
||||||
}
|
}
|
||||||
else if (iArg1 != Zero)
|
else if (iArg1 != Zero)
|
||||||
return iArg1;
|
return iArg1;
|
||||||
|
@ -131,7 +131,7 @@ DataTree::AddMinus(expr_t iArg1, expr_t iArg2)
|
||||||
if (iArg1 == iArg2)
|
if (iArg1 == iArg2)
|
||||||
return Zero;
|
return Zero;
|
||||||
|
|
||||||
return AddBinaryOp(iArg1, oMinus, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::minus, iArg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
|
@ -141,10 +141,10 @@ DataTree::AddUMinus(expr_t iArg1)
|
||||||
{
|
{
|
||||||
// Simplify -(-x) in x
|
// Simplify -(-x) in x
|
||||||
auto *uarg = dynamic_cast<UnaryOpNode *>(iArg1);
|
auto *uarg = dynamic_cast<UnaryOpNode *>(iArg1);
|
||||||
if (uarg != nullptr && uarg->get_op_code() == oUminus)
|
if (uarg != nullptr && uarg->get_op_code() == UnaryOpcode::uminus)
|
||||||
return uarg->get_arg();
|
return uarg->get_arg();
|
||||||
|
|
||||||
return AddUnaryOp(oUminus, iArg1);
|
return AddUnaryOp(UnaryOpcode::uminus, iArg1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
|
@ -167,7 +167,7 @@ DataTree::AddTimes(expr_t iArg1, expr_t iArg2)
|
||||||
iArg1 = iArg2;
|
iArg1 = iArg2;
|
||||||
iArg2 = tmp;
|
iArg2 = tmp;
|
||||||
}
|
}
|
||||||
return AddBinaryOp(iArg1, oTimes, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::times, iArg2);
|
||||||
}
|
}
|
||||||
else if (iArg1 != Zero && iArg1 != One && iArg2 == One)
|
else if (iArg1 != Zero && iArg1 != One && iArg2 == One)
|
||||||
return iArg1;
|
return iArg1;
|
||||||
|
@ -198,50 +198,50 @@ DataTree::AddDivide(expr_t iArg1, expr_t iArg2) noexcept(false)
|
||||||
if (iArg1 == iArg2)
|
if (iArg1 == iArg2)
|
||||||
return One;
|
return One;
|
||||||
|
|
||||||
return AddBinaryOp(iArg1, oDivide, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::divide, iArg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddLess(expr_t iArg1, expr_t iArg2)
|
DataTree::AddLess(expr_t iArg1, expr_t iArg2)
|
||||||
{
|
{
|
||||||
return AddBinaryOp(iArg1, oLess, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::less, iArg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddGreater(expr_t iArg1, expr_t iArg2)
|
DataTree::AddGreater(expr_t iArg1, expr_t iArg2)
|
||||||
{
|
{
|
||||||
return AddBinaryOp(iArg1, oGreater, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::greater, iArg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddLessEqual(expr_t iArg1, expr_t iArg2)
|
DataTree::AddLessEqual(expr_t iArg1, expr_t iArg2)
|
||||||
{
|
{
|
||||||
return AddBinaryOp(iArg1, oLessEqual, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::lessEqual, iArg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddGreaterEqual(expr_t iArg1, expr_t iArg2)
|
DataTree::AddGreaterEqual(expr_t iArg1, expr_t iArg2)
|
||||||
{
|
{
|
||||||
return AddBinaryOp(iArg1, oGreaterEqual, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::greaterEqual, iArg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddEqualEqual(expr_t iArg1, expr_t iArg2)
|
DataTree::AddEqualEqual(expr_t iArg1, expr_t iArg2)
|
||||||
{
|
{
|
||||||
return AddBinaryOp(iArg1, oEqualEqual, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::equalEqual, iArg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddDifferent(expr_t iArg1, expr_t iArg2)
|
DataTree::AddDifferent(expr_t iArg1, expr_t iArg2)
|
||||||
{
|
{
|
||||||
return AddBinaryOp(iArg1, oDifferent, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::different, iArg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddPower(expr_t iArg1, expr_t iArg2)
|
DataTree::AddPower(expr_t iArg1, expr_t iArg2)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero && iArg2 != Zero && iArg1 != One && iArg2 != One)
|
if (iArg1 != Zero && iArg2 != Zero && iArg1 != One && iArg2 != One)
|
||||||
return AddBinaryOp(iArg1, oPower, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::power, iArg2);
|
||||||
else if (iArg1 == One)
|
else if (iArg1 == One)
|
||||||
return One;
|
return One;
|
||||||
else if (iArg2 == One)
|
else if (iArg2 == One)
|
||||||
|
@ -256,26 +256,26 @@ expr_t
|
||||||
DataTree::AddPowerDeriv(expr_t iArg1, expr_t iArg2, int powerDerivOrder)
|
DataTree::AddPowerDeriv(expr_t iArg1, expr_t iArg2, int powerDerivOrder)
|
||||||
{
|
{
|
||||||
assert(powerDerivOrder > 0);
|
assert(powerDerivOrder > 0);
|
||||||
return AddBinaryOp(iArg1, oPowerDeriv, iArg2, powerDerivOrder);
|
return AddBinaryOp(iArg1, BinaryOpcode::powerDeriv, iArg2, powerDerivOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddDiff(expr_t iArg1)
|
DataTree::AddDiff(expr_t iArg1)
|
||||||
{
|
{
|
||||||
return AddUnaryOp(oDiff, iArg1);
|
return AddUnaryOp(UnaryOpcode::diff, iArg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddAdl(expr_t iArg1, const string &name, const vector<int> &lags)
|
DataTree::AddAdl(expr_t iArg1, const string &name, const vector<int> &lags)
|
||||||
{
|
{
|
||||||
return AddUnaryOp(oAdl, iArg1, 0, 0, 0, string(name), lags);
|
return AddUnaryOp(UnaryOpcode::adl, iArg1, 0, 0, 0, string(name), lags);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddExp(expr_t iArg1)
|
DataTree::AddExp(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oExp, iArg1);
|
return AddUnaryOp(UnaryOpcode::exp, iArg1);
|
||||||
else
|
else
|
||||||
return One;
|
return One;
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ expr_t
|
||||||
DataTree::AddLog(expr_t iArg1)
|
DataTree::AddLog(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero && iArg1 != One)
|
if (iArg1 != Zero && iArg1 != One)
|
||||||
return AddUnaryOp(oLog, iArg1);
|
return AddUnaryOp(UnaryOpcode::log, iArg1);
|
||||||
else if (iArg1 == One)
|
else if (iArg1 == One)
|
||||||
return Zero;
|
return Zero;
|
||||||
else
|
else
|
||||||
|
@ -298,7 +298,7 @@ expr_t
|
||||||
DataTree::AddLog10(expr_t iArg1)
|
DataTree::AddLog10(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero && iArg1 != One)
|
if (iArg1 != Zero && iArg1 != One)
|
||||||
return AddUnaryOp(oLog10, iArg1);
|
return AddUnaryOp(UnaryOpcode::log10, iArg1);
|
||||||
else if (iArg1 == One)
|
else if (iArg1 == One)
|
||||||
return Zero;
|
return Zero;
|
||||||
else
|
else
|
||||||
|
@ -312,7 +312,7 @@ expr_t
|
||||||
DataTree::AddCos(expr_t iArg1)
|
DataTree::AddCos(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oCos, iArg1);
|
return AddUnaryOp(UnaryOpcode::cos, iArg1);
|
||||||
else
|
else
|
||||||
return One;
|
return One;
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ expr_t
|
||||||
DataTree::AddSin(expr_t iArg1)
|
DataTree::AddSin(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oSin, iArg1);
|
return AddUnaryOp(UnaryOpcode::sin, iArg1);
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ expr_t
|
||||||
DataTree::AddTan(expr_t iArg1)
|
DataTree::AddTan(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oTan, iArg1);
|
return AddUnaryOp(UnaryOpcode::tan, iArg1);
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ expr_t
|
||||||
DataTree::AddAcos(expr_t iArg1)
|
DataTree::AddAcos(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != One)
|
if (iArg1 != One)
|
||||||
return AddUnaryOp(oAcos, iArg1);
|
return AddUnaryOp(UnaryOpcode::acos, iArg1);
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ expr_t
|
||||||
DataTree::AddAsin(expr_t iArg1)
|
DataTree::AddAsin(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oAsin, iArg1);
|
return AddUnaryOp(UnaryOpcode::asin, iArg1);
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ expr_t
|
||||||
DataTree::AddAtan(expr_t iArg1)
|
DataTree::AddAtan(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oAtan, iArg1);
|
return AddUnaryOp(UnaryOpcode::atan, iArg1);
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,7 @@ expr_t
|
||||||
DataTree::AddCosh(expr_t iArg1)
|
DataTree::AddCosh(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oCosh, iArg1);
|
return AddUnaryOp(UnaryOpcode::cosh, iArg1);
|
||||||
else
|
else
|
||||||
return One;
|
return One;
|
||||||
}
|
}
|
||||||
|
@ -375,7 +375,7 @@ expr_t
|
||||||
DataTree::AddSinh(expr_t iArg1)
|
DataTree::AddSinh(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oSinh, iArg1);
|
return AddUnaryOp(UnaryOpcode::sinh, iArg1);
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,7 @@ expr_t
|
||||||
DataTree::AddTanh(expr_t iArg1)
|
DataTree::AddTanh(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oTanh, iArg1);
|
return AddUnaryOp(UnaryOpcode::tanh, iArg1);
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
}
|
}
|
||||||
|
@ -393,7 +393,7 @@ expr_t
|
||||||
DataTree::AddAcosh(expr_t iArg1)
|
DataTree::AddAcosh(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != One)
|
if (iArg1 != One)
|
||||||
return AddUnaryOp(oAcosh, iArg1);
|
return AddUnaryOp(UnaryOpcode::acosh, iArg1);
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
}
|
}
|
||||||
|
@ -402,7 +402,7 @@ expr_t
|
||||||
DataTree::AddAsinh(expr_t iArg1)
|
DataTree::AddAsinh(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oAsinh, iArg1);
|
return AddUnaryOp(UnaryOpcode::asinh, iArg1);
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
}
|
}
|
||||||
|
@ -411,7 +411,7 @@ expr_t
|
||||||
DataTree::AddAtanh(expr_t iArg1)
|
DataTree::AddAtanh(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oAtanh, iArg1);
|
return AddUnaryOp(UnaryOpcode::atanh, iArg1);
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ expr_t
|
||||||
DataTree::AddSqrt(expr_t iArg1)
|
DataTree::AddSqrt(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oSqrt, iArg1);
|
return AddUnaryOp(UnaryOpcode::sqrt, iArg1);
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ DataTree::AddAbs(expr_t iArg1)
|
||||||
if (iArg1 == One)
|
if (iArg1 == One)
|
||||||
return One;
|
return One;
|
||||||
else
|
else
|
||||||
return AddUnaryOp(oAbs, iArg1);
|
return AddUnaryOp(UnaryOpcode::abs, iArg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
|
@ -444,14 +444,14 @@ DataTree::AddSign(expr_t iArg1)
|
||||||
if (iArg1 == One)
|
if (iArg1 == One)
|
||||||
return One;
|
return One;
|
||||||
else
|
else
|
||||||
return AddUnaryOp(oSign, iArg1);
|
return AddUnaryOp(UnaryOpcode::sign, iArg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddErf(expr_t iArg1)
|
DataTree::AddErf(expr_t iArg1)
|
||||||
{
|
{
|
||||||
if (iArg1 != Zero)
|
if (iArg1 != Zero)
|
||||||
return AddUnaryOp(oErf, iArg1);
|
return AddUnaryOp(UnaryOpcode::erf, iArg1);
|
||||||
else
|
else
|
||||||
return Zero;
|
return Zero;
|
||||||
}
|
}
|
||||||
|
@ -459,49 +459,49 @@ DataTree::AddErf(expr_t iArg1)
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddMax(expr_t iArg1, expr_t iArg2)
|
DataTree::AddMax(expr_t iArg1, expr_t iArg2)
|
||||||
{
|
{
|
||||||
return AddBinaryOp(iArg1, oMax, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::max, iArg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddMin(expr_t iArg1, expr_t iArg2)
|
DataTree::AddMin(expr_t iArg1, expr_t iArg2)
|
||||||
{
|
{
|
||||||
return AddBinaryOp(iArg1, oMin, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::min, iArg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddNormcdf(expr_t iArg1, expr_t iArg2, expr_t iArg3)
|
DataTree::AddNormcdf(expr_t iArg1, expr_t iArg2, expr_t iArg3)
|
||||||
{
|
{
|
||||||
return AddTrinaryOp(iArg1, oNormcdf, iArg2, iArg3);
|
return AddTrinaryOp(iArg1, TrinaryOpcode::normcdf, iArg2, iArg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddNormpdf(expr_t iArg1, expr_t iArg2, expr_t iArg3)
|
DataTree::AddNormpdf(expr_t iArg1, expr_t iArg2, expr_t iArg3)
|
||||||
{
|
{
|
||||||
return AddTrinaryOp(iArg1, oNormpdf, iArg2, iArg3);
|
return AddTrinaryOp(iArg1, TrinaryOpcode::normpdf, iArg2, iArg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddSteadyState(expr_t iArg1)
|
DataTree::AddSteadyState(expr_t iArg1)
|
||||||
{
|
{
|
||||||
return AddUnaryOp(oSteadyState, iArg1);
|
return AddUnaryOp(UnaryOpcode::steadyState, iArg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddSteadyStateParamDeriv(expr_t iArg1, int param_symb_id)
|
DataTree::AddSteadyStateParamDeriv(expr_t iArg1, int param_symb_id)
|
||||||
{
|
{
|
||||||
return AddUnaryOp(oSteadyStateParamDeriv, iArg1, 0, param_symb_id);
|
return AddUnaryOp(UnaryOpcode::steadyStateParamDeriv, iArg1, 0, param_symb_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddSteadyStateParam2ndDeriv(expr_t iArg1, int param1_symb_id, int param2_symb_id)
|
DataTree::AddSteadyStateParam2ndDeriv(expr_t iArg1, int param1_symb_id, int param2_symb_id)
|
||||||
{
|
{
|
||||||
return AddUnaryOp(oSteadyStateParam2ndDeriv, iArg1, 0, param1_symb_id, param2_symb_id);
|
return AddUnaryOp(UnaryOpcode::steadyStateParam2ndDeriv, iArg1, 0, param1_symb_id, param2_symb_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddExpectation(int iArg1, expr_t iArg2)
|
DataTree::AddExpectation(int iArg1, expr_t iArg2)
|
||||||
{
|
{
|
||||||
return AddUnaryOp(oExpectation, iArg2, iArg1);
|
return AddUnaryOp(UnaryOpcode::expectation, iArg2, iArg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t
|
expr_t
|
||||||
|
@ -529,7 +529,7 @@ DataTree::AddPacExpectation(const string &model_name)
|
||||||
expr_t
|
expr_t
|
||||||
DataTree::AddEqual(expr_t iArg1, expr_t iArg2)
|
DataTree::AddEqual(expr_t iArg1, expr_t iArg2)
|
||||||
{
|
{
|
||||||
return AddBinaryOp(iArg1, oEqual, iArg2);
|
return AddBinaryOp(iArg1, BinaryOpcode::equal, iArg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -706,14 +706,14 @@ DataTree::minLagForSymbol(int symb_id) const
|
||||||
void
|
void
|
||||||
DataTree::writePowerDerivCHeader(ostream &output) const
|
DataTree::writePowerDerivCHeader(ostream &output) const
|
||||||
{
|
{
|
||||||
if (isBinaryOpUsed(oPowerDeriv))
|
if (isBinaryOpUsed(BinaryOpcode::powerDeriv))
|
||||||
output << "double getPowerDeriv(double, double, int);" << endl;
|
output << "double getPowerDeriv(double, double, int);" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DataTree::writePowerDeriv(ostream &output) const
|
DataTree::writePowerDeriv(ostream &output) const
|
||||||
{
|
{
|
||||||
if (isBinaryOpUsed(oPowerDeriv))
|
if (isBinaryOpUsed(BinaryOpcode::powerDeriv))
|
||||||
output << "/*" << endl
|
output << "/*" << endl
|
||||||
<< " * The k-th derivative of x^p" << endl
|
<< " * The k-th derivative of x^p" << endl
|
||||||
<< " */" << endl
|
<< " */" << endl
|
||||||
|
@ -739,7 +739,7 @@ void
|
||||||
DataTree::writeNormcdfCHeader(ostream &output) const
|
DataTree::writeNormcdfCHeader(ostream &output) const
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
|
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
|
||||||
if (isTrinaryOpUsed(oNormcdf))
|
if (isTrinaryOpUsed(TrinaryOpcode::normcdf))
|
||||||
output << "#ifdef _MSC_VER" << endl
|
output << "#ifdef _MSC_VER" << endl
|
||||||
<< "double normcdf(double);" << endl
|
<< "double normcdf(double);" << endl
|
||||||
<< "#endif" << endl;
|
<< "#endif" << endl;
|
||||||
|
@ -750,7 +750,7 @@ void
|
||||||
DataTree::writeNormcdf(ostream &output) const
|
DataTree::writeNormcdf(ostream &output) const
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
|
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
|
||||||
if (isTrinaryOpUsed(oNormcdf))
|
if (isTrinaryOpUsed(TrinaryOpcode::normcdf))
|
||||||
output << endl
|
output << endl
|
||||||
<< "#ifdef _MSC_VER" << endl
|
<< "#ifdef _MSC_VER" << endl
|
||||||
<< "/*" << endl
|
<< "/*" << endl
|
||||||
|
|
|
@ -348,9 +348,9 @@ DataTree::AddUnaryOp(UnaryOpcode op_code, expr_t arg, int arg_exp_info_set, int
|
||||||
return it->second;
|
return it->second;
|
||||||
|
|
||||||
// Try to reduce to a constant
|
// Try to reduce to a constant
|
||||||
// Case where arg is a constant and op_code == oUminus (i.e. we're adding a negative constant) is skipped
|
// Case where arg is a constant and op_code == UnaryOpcode::uminus (i.e. we're adding a negative constant) is skipped
|
||||||
auto *carg = dynamic_cast<NumConstNode *>(arg);
|
auto *carg = dynamic_cast<NumConstNode *>(arg);
|
||||||
if (op_code != oUminus || carg == nullptr)
|
if (op_code != UnaryOpcode::uminus || carg == nullptr)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -953,15 +953,15 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
|
||||||
fldu.write(code_file, instruction_number);
|
fldu.write(code_file, instruction_number);
|
||||||
FLDV_ fldv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(it->first.first), it->first.second};
|
FLDV_ fldv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(it->first.first), it->first.second};
|
||||||
fldv.write(code_file, instruction_number);
|
fldv.write(code_file, instruction_number);
|
||||||
FBINARY_ fbinary(oTimes);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::times)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
if (it != derivatives[i].begin())
|
if (it != derivatives[i].begin())
|
||||||
{
|
{
|
||||||
FBINARY_ fbinary(oPlus);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::plus)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FBINARY_ fbinary(oMinus);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
}
|
}
|
||||||
FSTPU_ fstpu(i);
|
FSTPU_ fstpu(i);
|
||||||
|
@ -1273,7 +1273,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
|
||||||
lhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
|
lhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
|
||||||
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
|
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
|
||||||
|
|
||||||
FBINARY_ fbinary(oMinus);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
FSTPR_ fstpr(i - block_recursive);
|
FSTPR_ fstpr(i - block_recursive);
|
||||||
fstpr.write(code_file, instruction_number);
|
fstpr.write(code_file, instruction_number);
|
||||||
|
@ -1362,7 +1362,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
|
||||||
FLDV_ fldv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(Uf[v].Ufl->var), Uf[v].Ufl->lag};
|
FLDV_ fldv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(Uf[v].Ufl->var), Uf[v].Ufl->lag};
|
||||||
fldv.write(code_file, instruction_number);
|
fldv.write(code_file, instruction_number);
|
||||||
|
|
||||||
FBINARY_ fbinary(oTimes);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::times)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
|
|
||||||
FCUML_ fcuml;
|
FCUML_ fcuml;
|
||||||
|
@ -1375,7 +1375,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
|
||||||
free(Uf[v].Ufl);
|
free(Uf[v].Ufl);
|
||||||
Uf[v].Ufl = Uf[v].Ufl_First;
|
Uf[v].Ufl = Uf[v].Ufl_First;
|
||||||
}
|
}
|
||||||
FBINARY_ fbinary(oMinus);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
|
|
||||||
FSTPU_ fstpu(i - block_recursive);
|
FSTPU_ fstpu(i - block_recursive);
|
||||||
|
@ -1585,7 +1585,7 @@ DynamicModel::writeDynamicCFile(const string &basename, const int order) const
|
||||||
mDynamicModelFile << "#define max(a, b) (((a) > (b)) ? (a) : (b))" << endl
|
mDynamicModelFile << "#define max(a, b) (((a) > (b)) ? (a) : (b))" << endl
|
||||||
<< "#define min(a, b) (((a) > (b)) ? (b) : (a))" << endl;
|
<< "#define min(a, b) (((a) > (b)) ? (b) : (a))" << endl;
|
||||||
|
|
||||||
// Write function definition if oPowerDeriv is used
|
// Write function definition if BinaryOpcode::powerDeriv is used
|
||||||
writePowerDerivCHeader(mDynamicModelFile);
|
writePowerDerivCHeader(mDynamicModelFile);
|
||||||
writeNormcdfCHeader(mDynamicModelFile);
|
writeNormcdfCHeader(mDynamicModelFile);
|
||||||
|
|
||||||
|
@ -5567,7 +5567,7 @@ DynamicModel::fillEvalContext(eval_context_t &eval_context) const
|
||||||
// First, auxiliary variables
|
// First, auxiliary variables
|
||||||
for (auto aux_equation : aux_equations)
|
for (auto aux_equation : aux_equations)
|
||||||
{
|
{
|
||||||
assert(aux_equation->get_op_code() == oEqual);
|
assert(aux_equation->get_op_code() == BinaryOpcode::equal);
|
||||||
auto *auxvar = dynamic_cast<VariableNode *>(aux_equation->get_arg1());
|
auto *auxvar = dynamic_cast<VariableNode *>(aux_equation->get_arg1());
|
||||||
assert(auxvar != nullptr);
|
assert(auxvar != nullptr);
|
||||||
try
|
try
|
||||||
|
@ -5620,7 +5620,7 @@ void
|
||||||
DynamicModel::addStaticOnlyEquation(expr_t eq, int lineno, const vector<pair<string, string>> &eq_tags)
|
DynamicModel::addStaticOnlyEquation(expr_t eq, int lineno, const vector<pair<string, string>> &eq_tags)
|
||||||
{
|
{
|
||||||
auto *beq = dynamic_cast<BinaryOpNode *>(eq);
|
auto *beq = dynamic_cast<BinaryOpNode *>(eq);
|
||||||
assert(beq != nullptr && beq->get_op_code() == oEqual);
|
assert(beq != nullptr && beq->get_op_code() == BinaryOpcode::equal);
|
||||||
|
|
||||||
vector<pair<string, string>> soe_eq_tags;
|
vector<pair<string, string>> soe_eq_tags;
|
||||||
for (const auto & eq_tag : eq_tags)
|
for (const auto & eq_tag : eq_tags)
|
||||||
|
|
|
@ -411,7 +411,7 @@ public:
|
||||||
//! Transforms the model by removing all lags on exos
|
//! Transforms the model by removing all lags on exos
|
||||||
void substituteExoLag(bool deterministic_model);
|
void substituteExoLag(bool deterministic_model);
|
||||||
|
|
||||||
//! Transforms the model by removing all oExpectation
|
//! Transforms the model by removing all UnaryOpcode::expectation
|
||||||
void substituteExpectation(bool partial_information_model);
|
void substituteExpectation(bool partial_information_model);
|
||||||
|
|
||||||
//! Transforms the model by decreasing the lead/lag of predetermined variables in model equations by one
|
//! Transforms the model by decreasing the lead/lag of predetermined variables in model equations by one
|
||||||
|
|
1058
src/ExprNode.cc
1058
src/ExprNode.cc
File diff suppressed because it is too large
Load Diff
|
@ -726,7 +726,7 @@ private:
|
||||||
const expr_t arg;
|
const expr_t arg;
|
||||||
//! Stores the information set. Only used for expectation operator
|
//! Stores the information set. Only used for expectation operator
|
||||||
const int expectation_information_set;
|
const int expectation_information_set;
|
||||||
//! Only used for oSteadyStateParamDeriv and oSteadyStateParam2ndDeriv
|
//! Only used for UnaryOpcode::steadyStateParamDeriv and UnaryOpcode::steadyStateParam2ndDeriv
|
||||||
const int param1_symb_id, param2_symb_id;
|
const int param1_symb_id, param2_symb_id;
|
||||||
const UnaryOpcode op_code;
|
const UnaryOpcode op_code;
|
||||||
const string adl_param_name;
|
const string adl_param_name;
|
||||||
|
|
|
@ -273,29 +273,29 @@ ModFile::checkPass(bool nostrict, bool stochastic)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stochastic_statement_present
|
if (stochastic_statement_present
|
||||||
&& (dynamic_model.isUnaryOpUsed(oSign)
|
&& (dynamic_model.isUnaryOpUsed(UnaryOpcode::sign)
|
||||||
|| dynamic_model.isUnaryOpUsed(oAbs)
|
|| dynamic_model.isUnaryOpUsed(UnaryOpcode::abs)
|
||||||
|| dynamic_model.isBinaryOpUsed(oMax)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::max)
|
||||||
|| dynamic_model.isBinaryOpUsed(oMin)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::min)
|
||||||
|| dynamic_model.isBinaryOpUsed(oGreater)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::greater)
|
||||||
|| dynamic_model.isBinaryOpUsed(oLess)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::less)
|
||||||
|| dynamic_model.isBinaryOpUsed(oGreaterEqual)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::greaterEqual)
|
||||||
|| dynamic_model.isBinaryOpUsed(oLessEqual)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::lessEqual)
|
||||||
|| dynamic_model.isBinaryOpUsed(oEqualEqual)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::equalEqual)
|
||||||
|| dynamic_model.isBinaryOpUsed(oDifferent)))
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::different)))
|
||||||
warnings << "WARNING: you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which is unsuitable for a stochastic context; see the reference manual, section about \"Expressions\", for more details." << endl;
|
warnings << "WARNING: you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which is unsuitable for a stochastic context; see the reference manual, section about \"Expressions\", for more details." << endl;
|
||||||
|
|
||||||
if (linear
|
if (linear
|
||||||
&& (dynamic_model.isUnaryOpUsed(oSign)
|
&& (dynamic_model.isUnaryOpUsed(UnaryOpcode::sign)
|
||||||
|| dynamic_model.isUnaryOpUsed(oAbs)
|
|| dynamic_model.isUnaryOpUsed(UnaryOpcode::abs)
|
||||||
|| dynamic_model.isBinaryOpUsed(oMax)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::max)
|
||||||
|| dynamic_model.isBinaryOpUsed(oMin)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::min)
|
||||||
|| dynamic_model.isBinaryOpUsed(oGreater)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::greater)
|
||||||
|| dynamic_model.isBinaryOpUsed(oLess)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::less)
|
||||||
|| dynamic_model.isBinaryOpUsed(oGreaterEqual)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::greaterEqual)
|
||||||
|| dynamic_model.isBinaryOpUsed(oLessEqual)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::lessEqual)
|
||||||
|| dynamic_model.isBinaryOpUsed(oEqualEqual)
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::equalEqual)
|
||||||
|| dynamic_model.isBinaryOpUsed(oDifferent)))
|
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::different)))
|
||||||
warnings << "WARNING: you have declared your model 'linear' but you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which potentially makes it non-linear." << endl;
|
warnings << "WARNING: you have declared your model 'linear' but you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which potentially makes it non-linear." << endl;
|
||||||
|
|
||||||
// Test if some estimated parameters are used within the values of shocks
|
// Test if some estimated parameters are used within the values of shocks
|
||||||
|
@ -905,17 +905,17 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
|
||||||
// If using USE_DLL with MSVC 10.0 or earlier, check that the user didn't use a function not supported by the compiler (because MSVC <= 10.0 doesn't comply with C99 standard)
|
// If using USE_DLL with MSVC 10.0 or earlier, check that the user didn't use a function not supported by the compiler (because MSVC <= 10.0 doesn't comply with C99 standard)
|
||||||
if (use_dll && msvc)
|
if (use_dll && msvc)
|
||||||
{
|
{
|
||||||
if (dynamic_model.isUnaryOpUsed(oAcosh))
|
if (dynamic_model.isUnaryOpUsed(UnaryOpcode::acosh))
|
||||||
{
|
{
|
||||||
cerr << "ERROR: acosh() function is not supported with USE_DLL option and older MSVC compilers; use Cygwin, MinGW or upgrade your MSVC compiler to 11.0 (2012) or later." << endl;
|
cerr << "ERROR: acosh() function is not supported with USE_DLL option and older MSVC compilers; use Cygwin, MinGW or upgrade your MSVC compiler to 11.0 (2012) or later." << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (dynamic_model.isUnaryOpUsed(oAsinh))
|
if (dynamic_model.isUnaryOpUsed(UnaryOpcode::asinh))
|
||||||
{
|
{
|
||||||
cerr << "ERROR: asinh() function is not supported with USE_DLL option and older MSVC compilers; use Cygwin, MinGW or upgrade your MSVC compiler to 11.0 (2012) or later." << endl;
|
cerr << "ERROR: asinh() function is not supported with USE_DLL option and older MSVC compilers; use Cygwin, MinGW or upgrade your MSVC compiler to 11.0 (2012) or later." << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (dynamic_model.isUnaryOpUsed(oAtanh))
|
if (dynamic_model.isUnaryOpUsed(UnaryOpcode::atanh))
|
||||||
{
|
{
|
||||||
cerr << "ERROR: atanh() function is not supported with USE_DLL option and older MSVC compilers; use Cygwin, MinGW or upgrade your MSVC compiler to 11.0 (2012) or later." << endl;
|
cerr << "ERROR: atanh() function is not supported with USE_DLL option and older MSVC compilers; use Cygwin, MinGW or upgrade your MSVC compiler to 11.0 (2012) or later." << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -1587,7 +1587,7 @@ ModelTree::compileModelEquations(ostream &code_file, unsigned int &instruction_n
|
||||||
lhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, dynamic, steady_dynamic);
|
lhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, dynamic, steady_dynamic);
|
||||||
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, dynamic, steady_dynamic);
|
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, dynamic, steady_dynamic);
|
||||||
|
|
||||||
FBINARY_ fbinary(oMinus);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
|
|
||||||
FSTPR_ fstpr(eq);
|
FSTPR_ fstpr(eq);
|
||||||
|
@ -1729,7 +1729,7 @@ void
|
||||||
ModelTree::addEquation(expr_t eq, int lineno)
|
ModelTree::addEquation(expr_t eq, int lineno)
|
||||||
{
|
{
|
||||||
auto *beq = dynamic_cast<BinaryOpNode *>(eq);
|
auto *beq = dynamic_cast<BinaryOpNode *>(eq);
|
||||||
assert(beq != nullptr && beq->get_op_code() == oEqual);
|
assert(beq != nullptr && beq->get_op_code() == BinaryOpcode::equal);
|
||||||
|
|
||||||
equations.push_back(beq);
|
equations.push_back(beq);
|
||||||
equations_lineno.push_back(lineno);
|
equations_lineno.push_back(lineno);
|
||||||
|
@ -1748,7 +1748,7 @@ void
|
||||||
ModelTree::addAuxEquation(expr_t eq)
|
ModelTree::addAuxEquation(expr_t eq)
|
||||||
{
|
{
|
||||||
auto *beq = dynamic_cast<BinaryOpNode *>(eq);
|
auto *beq = dynamic_cast<BinaryOpNode *>(eq);
|
||||||
assert(beq != nullptr && beq->get_op_code() == oEqual);
|
assert(beq != nullptr && beq->get_op_code() == BinaryOpcode::equal);
|
||||||
|
|
||||||
aux_equations.push_back(beq);
|
aux_equations.push_back(beq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3156,7 +3156,7 @@ ParsingDriver::is_there_one_integer_argument() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (unaryNode->get_op_code() != oUminus)
|
if (unaryNode->get_op_code() != UnaryOpcode::uminus)
|
||||||
return { false, 0 };
|
return { false, 0 };
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3516,25 +3516,25 @@ ParsingDriver::add_ramsey_constraints_statement()
|
||||||
void
|
void
|
||||||
ParsingDriver::ramsey_constraint_add_less(const string *name, const expr_t rhs)
|
ParsingDriver::ramsey_constraint_add_less(const string *name, const expr_t rhs)
|
||||||
{
|
{
|
||||||
add_ramsey_constraint(name, oLess, rhs);
|
add_ramsey_constraint(name, BinaryOpcode::less, rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::ramsey_constraint_add_greater(const string *name, const expr_t rhs)
|
ParsingDriver::ramsey_constraint_add_greater(const string *name, const expr_t rhs)
|
||||||
{
|
{
|
||||||
add_ramsey_constraint(name, oGreater, rhs);
|
add_ramsey_constraint(name, BinaryOpcode::greater, rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::ramsey_constraint_add_less_equal(const string *name, const expr_t rhs)
|
ParsingDriver::ramsey_constraint_add_less_equal(const string *name, const expr_t rhs)
|
||||||
{
|
{
|
||||||
add_ramsey_constraint(name, oLessEqual, rhs);
|
add_ramsey_constraint(name, BinaryOpcode::lessEqual, rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::ramsey_constraint_add_greater_equal(const string *name, const expr_t rhs)
|
ParsingDriver::ramsey_constraint_add_greater_equal(const string *name, const expr_t rhs)
|
||||||
{
|
{
|
||||||
add_ramsey_constraint(name, oGreaterEqual, rhs);
|
add_ramsey_constraint(name, BinaryOpcode::greaterEqual, rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -487,15 +487,15 @@ StaticModel::writeModelEquationsCode(const string &basename, map_idx_t map_idx)
|
||||||
fldsu.write(code_file, instruction_number);
|
fldsu.write(code_file, instruction_number);
|
||||||
FLDSV_ fldsv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(it->first)};
|
FLDSV_ fldsv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(it->first)};
|
||||||
fldsv.write(code_file, instruction_number);
|
fldsv.write(code_file, instruction_number);
|
||||||
FBINARY_ fbinary(oTimes);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::times)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
if (it != derivatives[i].begin())
|
if (it != derivatives[i].begin())
|
||||||
{
|
{
|
||||||
FBINARY_ fbinary(oPlus);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::plus)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FBINARY_ fbinary(oMinus);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
}
|
}
|
||||||
FSTPSU_ fstpsu(i);
|
FSTPSU_ fstpsu(i);
|
||||||
|
@ -710,7 +710,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
|
||||||
lhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false);
|
lhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false);
|
||||||
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false);
|
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false);
|
||||||
|
|
||||||
FBINARY_ fbinary(oMinus);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
|
|
||||||
FSTPR_ fstpr(i - block_recursive);
|
FSTPR_ fstpr(i - block_recursive);
|
||||||
|
@ -789,7 +789,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
|
||||||
FLDSV_ fldsv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(Uf[v].Ufl->var)};
|
FLDSV_ fldsv{static_cast<int>(SymbolType::endogenous), static_cast<unsigned int>(Uf[v].Ufl->var)};
|
||||||
fldsv.write(code_file, instruction_number);
|
fldsv.write(code_file, instruction_number);
|
||||||
|
|
||||||
FBINARY_ fbinary(oTimes);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::times)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
|
|
||||||
FCUML_ fcuml;
|
FCUML_ fcuml;
|
||||||
|
@ -802,7 +802,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
|
||||||
free(Uf[v].Ufl);
|
free(Uf[v].Ufl);
|
||||||
Uf[v].Ufl = Uf[v].Ufl_First;
|
Uf[v].Ufl = Uf[v].Ufl_First;
|
||||||
}
|
}
|
||||||
FBINARY_ fbinary(oMinus);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
|
|
||||||
FSTPSU_ fstpsu(i - block_recursive);
|
FSTPSU_ fstpsu(i - block_recursive);
|
||||||
|
@ -906,7 +906,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
|
||||||
lhs->compile(code_file, instruction_number, false, tt2, map_idx2[block], false, false);
|
lhs->compile(code_file, instruction_number, false, tt2, map_idx2[block], false, false);
|
||||||
rhs->compile(code_file, instruction_number, false, tt2, map_idx2[block], false, false);
|
rhs->compile(code_file, instruction_number, false, tt2, map_idx2[block], false, false);
|
||||||
|
|
||||||
FBINARY_ fbinary(oMinus);
|
FBINARY_ fbinary{static_cast<int>(BinaryOpcode::minus)};
|
||||||
fbinary.write(code_file, instruction_number);
|
fbinary.write(code_file, instruction_number);
|
||||||
|
|
||||||
FSTPR_ fstpr(i - block_recursive);
|
FSTPR_ fstpr(i - block_recursive);
|
||||||
|
@ -1899,7 +1899,7 @@ StaticModel::writeStaticCFile(const string &basename) const
|
||||||
output << "#define max(a, b) (((a) > (b)) ? (a) : (b))" << endl
|
output << "#define max(a, b) (((a) > (b)) ? (a) : (b))" << endl
|
||||||
<< "#define min(a, b) (((a) > (b)) ? (b) : (a))" << endl;
|
<< "#define min(a, b) (((a) > (b)) ? (b) : (a))" << endl;
|
||||||
|
|
||||||
// Write function definition if oPowerDeriv is used
|
// Write function definition if BinaryOpcode::powerDeriv is used
|
||||||
writePowerDerivCHeader(output);
|
writePowerDerivCHeader(output);
|
||||||
writeNormcdfCHeader(output);
|
writeNormcdfCHeader(output);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue