changeset 181:ff8556874557 wasm

speedup
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 14 Mar 2018 17:48:02 +0100
parents 4da803580da9
children 2cbfb08f3a95
files Framework/Toolbox/LinearAlgebra.cpp Framework/Toolbox/LinearAlgebra.h
diffstat 2 files changed, 81 insertions(+), 117 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Toolbox/LinearAlgebra.cpp	Tue Mar 13 20:02:39 2018 +0100
+++ b/Framework/Toolbox/LinearAlgebra.cpp	Wed Mar 14 17:48:02 2018 +0100
@@ -94,97 +94,6 @@
     }
 
 
-    void AssignVector(Vector& v,
-                      double v1,
-                      double v2)
-    {
-      v.resize(2);
-      v[0] = v1;
-      v[1] = v2;
-    }
-
-
-    void AssignVector(Vector& v,
-                      double v1)
-    {
-      v.resize(1);
-      v[0] = v1;
-    }
-
-
-    void AssignVector(Vector& v,
-                      double v1,
-                      double v2,
-                      double v3)
-    {
-      v.resize(3);
-      v[0] = v1;
-      v[1] = v2;
-      v[2] = v3;
-    }
-
-
-    void AssignVector(Vector& v,
-                      double v1,
-                      double v2,
-                      double v3,
-                      double v4)
-    {
-      v.resize(4);
-      v[0] = v1;
-      v[1] = v2;
-      v[2] = v3;
-      v[3] = v4;
-    }
-
-
-    Vector CreateVector(double v1)
-    {
-      Vector v;
-      AssignVector(v, v1);
-      return v;
-    }
-
-    
-    Vector CreateVector(double v1,
-                        double v2)
-    {
-      Vector v;
-      AssignVector(v, v1, v2);
-      return v;
-    }
-
-    
-    Vector CreateVector(double v1,
-                        double v2,
-                        double v3)
-    {
-      Vector v;
-      AssignVector(v, v1, v2, v3);
-      return v;
-    }
-
-    
-    Vector CreateVector(double v1,
-                        double v2,
-                        double v3,
-                        double v4)
-    {
-      Vector v;
-      AssignVector(v, v1, v2, v3, v4);
-      return v;
-    }
-
-
-    bool IsNear(double x,
-                double y)
-    {
-      // As most input is read as single-precision numbers, we take the
-      // epsilon machine for float32 into consideration to compare numbers
-      return IsNear(x, y, 10.0 * std::numeric_limits<float>::epsilon());
-    }
-
-
     void NormalizeVector(Vector& u)
     {
       double norm = boost::numeric::ublas::norm_2(u);
--- a/Framework/Toolbox/LinearAlgebra.h	Tue Mar 13 20:02:39 2018 +0100
+++ b/Framework/Toolbox/LinearAlgebra.h	Wed Mar 14 17:48:02 2018 +0100
@@ -51,37 +51,87 @@
                      const Orthanc::DicomMap& dataset,
                      const Orthanc::DicomTag& tag);
 
-    void AssignVector(Vector& v,
-                      double v1);
+    inline void AssignVector(Vector& v,
+                             double v1,
+                             double v2)
+    {
+      v.resize(2);
+      v[0] = v1;
+      v[1] = v2;
+    }
+
 
-    void AssignVector(Vector& v,
-                      double v1,
-                      double v2);
+    inline void AssignVector(Vector& v,
+                             double v1)
+    {
+      v.resize(1);
+      v[0] = v1;
+    }
+
 
-    void AssignVector(Vector& v,
-                      double v1,
-                      double v2,
-                      double v3);
+    inline void AssignVector(Vector& v,
+                             double v1,
+                             double v2,
+                             double v3)
+    {
+      v.resize(3);
+      v[0] = v1;
+      v[1] = v2;
+      v[2] = v3;
+    }
+
 
-    void AssignVector(Vector& v,
-                      double v1,
-                      double v2,
-                      double v3,
-                      double v4);
+    inline void AssignVector(Vector& v,
+                             double v1,
+                             double v2,
+                             double v3,
+                             double v4)
+    {
+      v.resize(4);
+      v[0] = v1;
+      v[1] = v2;
+      v[2] = v3;
+      v[3] = v4;
+    }
 
-    Vector CreateVector(double v1);
+
+    inline Vector CreateVector(double v1)
+    {
+      Vector v;
+      AssignVector(v, v1);
+      return v;
+    }
 
-    Vector CreateVector(double v1,
-                        double v2);
+    
+    inline Vector CreateVector(double v1,
+                               double v2)
+    {
+      Vector v;
+      AssignVector(v, v1, v2);
+      return v;
+    }
 
-    Vector CreateVector(double v1,
-                        double v2,
-                        double v3);
+    
+    inline Vector CreateVector(double v1,
+                               double v2,
+                               double v3)
+    {
+      Vector v;
+      AssignVector(v, v1, v2, v3);
+      return v;
+    }
+
     
-    Vector CreateVector(double v1,
-                        double v2,
-                        double v3,
-                        double v4);
+    inline Vector CreateVector(double v1,
+                               double v2,
+                               double v3,
+                               double v4)
+    {
+      Vector v;
+      AssignVector(v, v1, v2, v3, v4);
+      return v;
+    }
+
 
     inline bool IsNear(double x,
                        double y,
@@ -90,8 +140,13 @@
       return fabs(x - y) < threshold;
     }
 
-    bool IsNear(double x,
-                double y);
+    inline bool IsNear(double x,
+                       double y)
+    {
+      // As most input is read as single-precision numbers, we take the
+      // epsilon machine for float32 into consideration to compare numbers
+      return IsNear(x, y, 10.0 * std::numeric_limits<float>::epsilon());
+    }
 
     inline bool IsCloseToZero(double x)
     {