diff Framework/Toolbox/GeometryToolbox.cpp @ 156:441cfe8e7440 wasm

fill matrix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 08 Feb 2018 15:22:35 +0100
parents c5044bbfc303
children 2309e8d86efe
line wrap: on
line diff
--- a/Framework/Toolbox/GeometryToolbox.cpp	Fri Feb 02 10:02:27 2018 +0100
+++ b/Framework/Toolbox/GeometryToolbox.cpp	Thu Feb 08 15:22:35 2018 +0100
@@ -482,5 +482,51 @@
         }
       }
     }
+
+
+    void FillMatrix(Matrix& target,
+                    size_t rows,
+                    size_t columns,
+                    const double values[])
+    {
+      target.resize(rows, columns);
+
+      size_t index = 0;
+
+      for (size_t y = 0; y < rows; y++)
+      {
+        for (size_t x = 0; x < columns; x++, index++)
+        {
+          target(y, x) = values[index];
+        }
+      }
+    }
+
+
+    void FillVector(Vector& target,
+                    size_t size,
+                    const double values[])
+    {
+      target.resize(size);
+
+      for (size_t i = 0; i < size; i++)
+      {
+        target[i] = values[i];
+      }
+    }
+
+
+    void Convert(Matrix& target,
+                 const Vector& source)
+    {
+      const size_t n = source.size();
+
+      target.resize(n, 1);
+
+      for (size_t i = 0; i < n; i++)
+      {
+        target(i, 0) = source[i];
+      }      
+    }
   }
 }