"csrc/vscode:/vscode.git/clone" did not exist on "edbb1bc3ffc73d33a612ad254b6b75fc904ba222"
Unverified Commit 0e104b49 authored by David Williams's avatar David Williams Committed by GitHub
Browse files

Detect NaN to avoid infinite loop in JAMA::Eigenvalue (#3758)

parent 6db41c67
...@@ -7571,6 +7571,13 @@ double CommonCalcRMSDForceKernel::executeImpl(ContextImpl& context) { ...@@ -7571,6 +7571,13 @@ double CommonCalcRMSDForceKernel::executeImpl(ContextImpl& context) {
vector<REAL> b; vector<REAL> b;
buffer.download(b); buffer.download(b);
// JAMA::Eigenvalue may run into an infinite loop if we have any NaN
for (int i = 0; i < 9; i++) {
if (b[i] != b[i])
throw OpenMMException("NaN encountered during RMSD force calculation");
}
Array2D<double> F(4, 4); Array2D<double> F(4, 4);
F[0][0] = b[0*3+0] + b[1*3+1] + b[2*3+2]; F[0][0] = b[0*3+0] + b[1*3+1] + b[2*3+2];
F[1][0] = b[1*3+2] - b[2*3+1]; F[1][0] = b[1*3+2] - b[2*3+1];
......
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