From 611e614170e9afa333794bd8591294f05fa42887 Mon Sep 17 00:00:00 2001
From: sjplimp <sjplimp@f3b2605a-c512-4ea7-a41b-209d697bcdaa>
Date: Fri, 1 Jun 2012 17:21:22 +0000
Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8207
 f3b2605a-c512-4ea7-a41b-209d697bcdaa

---
 lib/README                |  2 ++
 lib/colvars/colvarcomp.h  |  3 ++-
 lib/colvars/colvarvalue.h | 12 ++++++++----
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/lib/README b/lib/README
index 84895ba92d..98f4cbef17 100644
--- a/lib/README
+++ b/lib/README
@@ -13,6 +13,8 @@ atc           atomistic-to-continuum methods, USER-ATC package
                 from Reese Jones, Jeremy Templeton, Jon Zimmerman (Sandia)
 awpmd         antisymmetrized wave packet molecular dynamics, AWPMD package
                 from Ilya Valuev (JIHT RAS)
+colvars	      collective variable module (Metadynamics, ABF and more)
+                from Giacomo Fiorin and Jerome Henin (ICMS, Temple U)
 cuda	      NVIDIA GPU routines, USER-CUDA package
                 from Christian Trott (U Tech Ilmenau)
 gpu	      graphical processor (GPU) routines, GPU package
diff --git a/lib/colvars/colvarcomp.h b/lib/colvars/colvarcomp.h
index fd58983c00..93278400f9 100644
--- a/lib/colvars/colvarcomp.h
+++ b/lib/colvars/colvarcomp.h
@@ -1223,7 +1223,8 @@ inline void colvar::spin_angle::wrap (colvarvalue &x) const
   inline cvm::real colvar::TYPE::dist2 (colvarvalue const &x1,          \
                                         colvarvalue const &x2) const    \
   {                                                                     \
-    return std::pow (x1.real_value - x2.real_value, int (2));              \
+    const cvm::real tmp = x1.real_value - x2.real_value;                \
+    return tmp*tmp;                                                     \
   }                                                                     \
                                                                         \
   inline colvarvalue colvar::TYPE::dist2_lgrad (colvarvalue const &x1,  \
diff --git a/lib/colvars/colvarvalue.h b/lib/colvars/colvarvalue.h
index 42085bae5a..d78c082af8 100644
--- a/lib/colvars/colvarvalue.h
+++ b/lib/colvars/colvarvalue.h
@@ -636,13 +636,17 @@ inline cvm::real colvarvalue::dist2 (colvarvalue const &x2) const
     colvarvalue::check_types (*this, x2);
 
   switch (this->value_type) {
-  case colvarvalue::type_scalar:
-    return std::pow (this->real_value - x2.real_value, int (2));
+  case colvarvalue::type_scalar: {
+    const cvm::real tmp = this->real_value - x2.real_value;
+    return tmp*tmp;
+  }
   case colvarvalue::type_vector:
     return (this->rvector_value - x2.rvector_value).norm2();
-  case colvarvalue::type_unitvector:
+  case colvarvalue::type_unitvector: {
     // angle between (*this) and x2 is the distance
-    return std::pow (std::acos (this->rvector_value * x2.rvector_value), int (2));
+    const cvm::real tmp = std::acos (this->rvector_value * x2.rvector_value);
+    return tmp*tmp;
+  }
   case colvarvalue::type_quaternion:
     // angle between (*this) and x2 is the distance, the quaternion
     // object has it implemented internally
-- 
GitLab