Throw when attempting to normalize a Zero RDGeom::Point (#8008)

* throw if close to zero

* fix moldraw2DTestCatch

* Fix testRGroupDecomp

* fix one test in distGeomHelpersCatch

* fix tests in distGeomHelpersCatch

* retry finding a dir vector when adding Hs

* push UFF fixes to calculateCosY

* fix the setTerminalAtomCoords deg 4 patch

* add a test

* reduce zero tolerance
This commit is contained in:
Ricardo Rodriguez
2024-11-18 22:33:22 -05:00
committed by GitHub
parent ffb100d928
commit 39d4662ae7
7 changed files with 108 additions and 19 deletions

View File

@@ -22,6 +22,8 @@
#include <boost/random.hpp>
#include <boost/smart_ptr.hpp>
static constexpr double zero_tolerance = 1.e-16;
namespace RDNumeric {
//! A class to represent vectors of numbers.
@@ -260,6 +262,9 @@ class Vector {
//! Normalize the vector using the L2 norm
inline void normalize() {
TYPE val = this->normL2();
if (val < zero_tolerance) {
throw std::runtime_error("Cannot normalize a zero length vector");
}
(*this) /= val;
}