Unverified Commit 245f18cf authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Fixed compilation error in kernel with CustomIntegrator (#3187)

parent 4399fa69
......@@ -698,9 +698,16 @@ void ExpressionUtilities::processExpression(stringstream& out, const ExpressionT
case Operation::POWER_CONSTANT:
{
double exponent = dynamic_cast<const Operation::PowerConstant*>(&node.getOperation())->getValue();
if (exponent == 0.0)
if (exponent == 0.0) {
if (isVecType)
out << "make_" << tempType << "(1.0f)";
else
out << "1.0f";
}
else if (exponent == (int) exponent) {
if (isVecType)
out << "make_" << tempType << "(0.0f);\n";
else
out << "0.0f;\n";
temps.push_back(make_pair(node, name));
hasRecordedNode = true;
......@@ -727,7 +734,7 @@ void ExpressionUtilities::processExpression(stringstream& out, const ExpressionT
}
}
out << "{\n";
out << "real multiplier = " << (exponent < 0.0 ? "RECIP(" : "(") << getTempName(node.getChildren()[0], temps) << ");\n";
out << tempType << " multiplier = " << (exponent < 0.0 ? "RECIP(" : "(") << getTempName(node.getChildren()[0], temps) << ");\n";
bool done = false;
while (!done) {
done = true;
......
......@@ -543,7 +543,7 @@ void testPerDofVariables() {
integrator.addComputePerDof("v", "v+dt*f/m");
integrator.addComputePerDof("x", "x+dt*v");
integrator.addComputePerDof("pos", "x");
integrator.addComputePerDof("computed", "step(v)*log(x^2)");
integrator.addComputePerDof("computed", "step(v)*log(x^4)");
Context context(system, integrator, platform);
context.setPositions(positions);
vector<Vec3> initialValues(numParticles);
......@@ -571,7 +571,7 @@ void testPerDofVariables() {
}
else {
double v = state.getPositions()[j][k];
ASSERT_EQUAL_TOL(log(v*v), values[j][k], 1e-5);
ASSERT_EQUAL_TOL(log(v*v*v*v), values[j][k], 1e-5);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment