Salome HOME
Merge branch 'occ/24009'
[tools/medcoupling.git] / src / INTERP_KERNEL / VectorUtils.hxx
index 7ac0582bd6b7b711101a3e36b5387d72e2296f7b..728c932d0a47ec6b7c9d31fec03aee8f456afebb 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 #ifndef __VECTORUTILS_HXX__
 #define __VECTORUTILS_HXX__
 
+#include <algorithm>
 #include <sstream>
 #include <numeric>
 #include <string>
 #include <cmath>
 #include <map>
 
+
 namespace INTERP_KERNEL
 {
   /// Precision used for tests of 3D part of INTERP_KERNEL
@@ -183,6 +185,23 @@ namespace INTERP_KERNEL
     return relError < relTol;
   }
 
+  inline double sumOfAbsoluteValues(const double row[3])
+  {
+    double ret(0.);
+    std::for_each(row,row+3,[&ret](double v) { ret += std::abs(v); });
+    return ret;
+  }
+
+  /*!
+   * Returns the infinite norm of a 3x3 input matrix \a mat.
+   * The max of absolute value of row sum.
+   */
+  inline double normInf(const double mat[9])
+  {
+    double ret(std::max(sumOfAbsoluteValues(mat),sumOfAbsoluteValues(mat+3)));
+    return std::max(ret,sumOfAbsoluteValues(mat+6));
+  }
+
 }
 
 #endif