From a549fb6b9c7a32331892b48104a8d1866b84fd46 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Wed, 23 Oct 2024 22:39:36 -0700 Subject: [PATCH] mkSFPos --- src/include/xpr/pos_type.cc.h | 32 ++++++++++++++++++++++++++++---- src/include/xpr/pos_type.h | 4 ++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/include/xpr/pos_type.cc.h b/src/include/xpr/pos_type.cc.h index 21fada7..2837adb 100644 --- a/src/include/xpr/pos_type.cc.h +++ b/src/include/xpr/pos_type.cc.h @@ -280,6 +280,17 @@ namespace CNORXZ { return FPos(pos.val(), map); } + + template + static constexpr decltype(auto) mks(const PosT& pos, std::index_sequence is) + { + if constexpr(is_static_pos_type::value){ + return SFPos {}; + } + else { + return mk(pos, &SFPos<0,Is...>::permutation[0]); + } + } }; template @@ -289,6 +300,13 @@ namespace CNORXZ { return mkMPos( MkFPos::mk( pos, map ), MkFPos::mk( pos.next(), map ) ); } + + template + static constexpr decltype(auto) mks(const MPos& pos, + std::index_sequence is) + { + return mkMPos( MkFPos::mks( pos, is ), MkFPos::mks( pos.next(), is ) ); + } }; template @@ -297,13 +315,19 @@ namespace CNORXZ return MkFPos::mk(pos, map); } + template + constexpr decltype(auto) mkSFPos(const PosT& pos, std::index_sequence is) + { + return MkFPos::mks(pos, is); + } + /*===========+ | SFPos | +===========*/ template - Arr SFPos::sMs = { Ms... }; + Arr SFPos::permutation = { Ms... }; template constexpr SizeT SFPos::size() const @@ -343,10 +367,10 @@ namespace CNORXZ } else { if constexpr(is_epos_type::value){ - return FPos(N * a.scal().val(), &sMs[0]); + return FPos(N * a.scal().val(), &permutation[0]); } else { - return FPos(N * a.val(), &sMs[0]); + return FPos(N * a.val(), &permutation[0]); } } } @@ -392,7 +416,7 @@ namespace CNORXZ template constexpr SFPos::operator FPos() const { - return FPos(N, &sMs[0]); + return FPos(N, &permutation[0]); } template diff --git a/src/include/xpr/pos_type.h b/src/include/xpr/pos_type.h index 6879f4f..14505d1 100644 --- a/src/include/xpr/pos_type.h +++ b/src/include/xpr/pos_type.h @@ -129,9 +129,9 @@ namespace CNORXZ template class SFPos { - private: - static Arr sMs; public: + static Arr permutation; + constexpr SFPos() = default; constexpr SizeT size() const;