changeset 156:441cfe8e7440 wasm

fill matrix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 08 Feb 2018 15:22:35 +0100
parents 7cd08a8ea7d0
children 2309e8d86efe
files Framework/Toolbox/GeometryToolbox.cpp Framework/Toolbox/GeometryToolbox.h
diffstat 2 files changed, 58 insertions(+), 0 deletions(-) [+]
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];
+      }      
+    }
   }
 }
--- a/Framework/Toolbox/GeometryToolbox.h	Fri Feb 02 10:02:27 2018 +0100
+++ b/Framework/Toolbox/GeometryToolbox.h	Thu Feb 08 15:22:35 2018 +0100
@@ -136,6 +136,18 @@
                                   const Vector& edgeFrom,
                                   const Vector& edgeTo);
 
+    void FillMatrix(Matrix& target,
+                    size_t rows,
+                    size_t columns,
+                    const double values[]);
+
+    void FillVector(Vector& target,
+                    size_t size,
+                    const double values[]);
+
+    void Convert(Matrix& target,
+                 const Vector& source);
+
     inline float ComputeBilinearInterpolationInternal(float x,
                                                       float y,
                                                       float f00,    // source(x, y)