From 0b30b31efb40ed75b7f64c45081ee70ed9ad9e17 Mon Sep 17 00:00:00 2001
From: Christian Mattes <christian.mattes@rwth-aachen.de>
Date: Fri, 1 Feb 2019 14:14:51 +0100
Subject: [PATCH] implemented outer_product review hints

---
 src/tg/detail/functions/outer_product.hh | 43 +++++++++++++++++++-----
 1 file changed, 34 insertions(+), 9 deletions(-)

diff --git a/src/tg/detail/functions/outer_product.hh b/src/tg/detail/functions/outer_product.hh
index dfdf317..8ef78ff 100644
--- a/src/tg/detail/functions/outer_product.hh
+++ b/src/tg/detail/functions/outer_product.hh
@@ -1,17 +1,42 @@
 #pragma once
-#include <tg/types/vec.hh>
-#include <tg/types/mat.hh>
+
+#include "../../types/mat.hh"
+#include "../../types/vec.hh"
 
 namespace tg
 {
-template <int D, class ScalarT>
-constexpr tg::mat<D, D, ScalarT> outer_product(tg::vec<D, ScalarT> const &lhs, tg::vec<D, ScalarT> const &rhs)
+template <class ScalarT>
+constexpr mat<1, 1, ScalarT> outer_product(vec<1, ScalarT> const &lhs, vec<1, ScalarT> const &rhs)
+{
+    mat<1, 1, ScalarT> res;
+    res[0] = lhs * rhs[0];
+    return res;
+}
+template <class ScalarT>
+constexpr mat<2, 2, ScalarT> outer_product(vec<2, ScalarT> const &lhs, vec<2, ScalarT> const &rhs)
+{
+    mat<2, 2, ScalarT> res;
+    res[0] = lhs * rhs[0];
+    res[1] = lhs * rhs[1];
+    return res;
+}
+template <class ScalarT>
+constexpr mat<3, 3, ScalarT> outer_product(vec<3, ScalarT> const &lhs, vec<3, ScalarT> const &rhs)
+{
+    mat<3, 3, ScalarT> res;
+    res[0] = lhs * rhs[0];
+    res[1] = lhs * rhs[1];
+    res[2] = lhs * rhs[2];
+    return res;
+}
+template <class ScalarT>
+constexpr mat<4, 4, ScalarT> outer_product(vec<4, ScalarT> const &lhs, vec<4, ScalarT> const &rhs)
 {
-    tg::mat<D, D, ScalarT> res;
-    for (int i = 0; i < D; i++)
-    {
-        res[i] = lhs * rhs[i];
-    }
+    mat<4, 4, ScalarT> res;
+    res[0] = lhs * rhs[0];
+    res[1] = lhs * rhs[1];
+    res[2] = lhs * rhs[2];
+    res[3] = lhs * rhs[3];
     return res;
 }
 } // namespace tg
-- 
GitLab