summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-09-02 10:39:48 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-09-02 10:39:48 +0200
commit63e525a09ac46cb3db7a7680ac4134454f346e40 (patch)
tree617de4c73486a4ad7f91140cab0bf7fdff68d9ff
parent93192abf96943d564185c3fe5fe098ce4de90f02 (diff)
Working on unit reduction
-rw-r--r--modules/codec-unit/c++/unit.tmpl.hpp18
-rw-r--r--modules/codec-unit/c++/unit_transform.hpp33
2 files changed, 51 insertions, 0 deletions
diff --git a/modules/codec-unit/c++/unit.tmpl.hpp b/modules/codec-unit/c++/unit.tmpl.hpp
index 8b13789..7412199 100644
--- a/modules/codec-unit/c++/unit.tmpl.hpp
+++ b/modules/codec-unit/c++/unit.tmpl.hpp
@@ -1 +1,19 @@
+namespace saw {
+template<typename BaseSchema, typename... Elements>
+data<schema::Unit<BaseSchema, Elements...>, encode::Native>
+data<schema::Unit<BaseSchema, Elements...>, encode::Native>::operator+(const
+data<schema::Unit<BaseSchema, Elements...>, encode::Native>& rhs){
+ auto add = dat_ + rhs.dat_;
+ return {add};
+}
+
+template<typename BaseSchema, typename... Elements>
+data<schema::Unit<BaseSchema, Elements...>, encode::Native>
+data<schema::Unit<BaseSchema, Elements...>, encode::Native>::operator-(const
+data<schema::Unit<BaseSchema, Elements...>, encode::Native>& rhs){
+ auto sub = dat_ - rhs.dat_;
+ return {sub};
+}
+
+}
diff --git a/modules/codec-unit/c++/unit_transform.hpp b/modules/codec-unit/c++/unit_transform.hpp
index 6f40df5..3cae3c5 100644
--- a/modules/codec-unit/c++/unit_transform.hpp
+++ b/modules/codec-unit/c++/unit_transform.hpp
@@ -15,5 +15,38 @@ class unit_redux_list {
using reduced_type = unit_redux_list<>;
};
+
+template<typename LR, typename RR>
+class unit_matching {
+ static_assert(is_always_false<LR,RR>, "Template type not supported");
+};
+
+template<typename... Ele>
+class unit_matching<unit_redux_list<>, unit_redux_list<Ele...>> {
+ using Type = unit_redux_list<Ele...>;
+};
+
+template<typename Ele0, typename... EleL, typename... EleR>
+class unit_matching<unit_redux_list<Ele0, ELeL...>, unit_redux_list<EleR...>> {
+ using Type =
+};
}
+
+template<typename... UE>
+struct unit_element_reduction {
+ using Schema = typename impl::unit_matching<impl::unit_redux_list<UE...>, impl::unit_redux_list<>>::Schema;
+};
+
+template<typename U0, typename U1>
+struct unit_multiplication {
+ static_assert(is_always_false<U0,U1>, "Template type not supported");
+};
+
+template<typename... UnitT, int64_t... UnitE, typename... UnitRhsT, int64_t... UnitRhsE>
+class unit_multiplication<
+ schema::Unit<schema::UnitElement<UnitT,UnitE>...>,schema::Unit<schema::UnitElement<UnitRhsT,UnitRhsE>...>
+> {
+ using Schema = typename unit_reduction<schema::UnitElement<UnitT,UnitE>..., schema::UnitElement<UnitRhsT, UnitRhsE>...>::Schema;
+};
+
}