Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / selection / sm_compare.cpp
index b2d361c36e5ff4e7819efaa59f68bb00fc253217..51aa8a6d47d49c7efb9d2f57aef3784c23f3d1dd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  * \ingroup module_selection
  */
-#include "gromacs/legacyheaders/maths.h"
-#include "gromacs/legacyheaders/macros.h"
-#include "gromacs/legacyheaders/smalloc.h"
+#include "gmxpre.h"
+
+#include <cmath>
 
-#include "gromacs/selection/selmethod.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/math/utilities.h"
 #include "gromacs/utility/common.h"
 #include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/smalloc.h"
+
+#include "selmethod.h"
 
 /** Defines the comparison operator for comparison expressions. */
 typedef enum
@@ -195,17 +199,20 @@ comparison_type(char *str)
 static const char *
 comparison_type_str(e_comparison_t cmpt)
 {
+    const char *p = NULL;
     switch (cmpt)
     {
-        case CMP_INVALID: return "INVALID"; break;
-        case CMP_LESS:    return "<";  break;
-        case CMP_LEQ:     return "<="; break;
-        case CMP_GTR:     return ">";  break;
-        case CMP_GEQ:     return ">="; break;
-        case CMP_EQUAL:   return "=="; break;
-        case CMP_NEQ:     return "!="; break;
+        case CMP_INVALID: p = "INVALID"; break;
+        case CMP_LESS:    p = "<";       break;
+        case CMP_LEQ:     p = "<=";      break;
+        case CMP_GTR:     p = ">";       break;
+        case CMP_GEQ:     p = ">=";      break;
+        case CMP_EQUAL:   p = "==";      break;
+        case CMP_NEQ:     p = "!=";      break;
+            // No default clause so we intentionally get compiler errors
+            // if new selection choices are added later.
     }
-    return NULL;
+    return p;
 }
 
 /*!
@@ -375,17 +382,17 @@ convert_real_int(int n, t_compare_value *val, e_comparison_t cmpt, bool bRight)
         {
             case CMP_LESS:
             case CMP_GEQ:
-                iv[i] = (int)ceil(val->r[i]);
+                iv[i] = static_cast<int>(std::ceil(val->r[i]));
                 break;
             case CMP_GTR:
             case CMP_LEQ:
-                iv[i] = (int)floor(val->r[i]);
+                iv[i] = static_cast<int>(std::floor(val->r[i]));
                 break;
             case CMP_EQUAL:
             case CMP_NEQ:
                 sfree(iv);
                 /* TODO: Implement, although it isn't typically very useful.
-                 * Implementation is only a matter or proper initialization,
+                 * Implementation is only a matter of proper initialization,
                  * the evaluation function can already handle this case with
                  * proper preparations. */
                 GMX_THROW(gmx::NotImplementedError("Equality comparison between dynamic integer and static real expressions not implemented"));