CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
eindex.cc.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_eindex_cc_h__
13#define __cxz_eindex_cc_h__
14
15#include "eindex.h"
16#include "lindex.h"
17#include "srange.h"
18
19namespace CNORXZ
20{
21
22 template <typename MetaT, SizeT S, SizeT L>
27
28 template <typename MetaT, SizeT S, SizeT L>
29 template <class Xpr, class F>
30 decltype(auto) EIndex<MetaT,S,L>::ifor(const Xpr& xpr, F&& f) const
31 {
32 return EFor<S,L,Xpr>(mLI->id(), xpr, std::forward<F>(f));
33 }
34
35 template <typename MetaT, SizeT S, SizeT L, class I1>
36 decltype(auto) operator*(const Sptr<EIndex<MetaT,S,L>>& a, const Sptr<I1>& b)
37 {
38 return iptrMul(a, b);
39 }
40
41 template <typename MetaT, SizeT S, SizeT L>
42 decltype(auto) eindexPtr(const Sptr<LIndex<SIndex<MetaT,S>,L>>& i)
43 {
44 return std::make_shared<EIndex<MetaT,S,L>>(i);
45 }
46
47 template <SizeT L, typename MetaT, SizeT S>
48 decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>>& i)
49 {
50 return eindexPtr( lindexPtr<L>( i ) );
51 }
52
53 template <typename MetaT, SizeT S, SizeT L>
54 decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>>& i, CSizeT<L> l)
55 {
56 return eindexPtr<l>( i );
57 }
58
59 template <SizeT S, SizeT L1, SizeT L2, class Index>
60 decltype(auto) eplex(const Sptr<Index>& i)
61 {
62 const SizeT isize = i->lmax().val();
63 CXZ_ASSERT(isize % S == 0, "index max (= " << isize
64 << " ) not dividable by extension size = " << S);
65 auto ci = std::make_shared<CIndex>( CRangeFactory(isize/S).create() );
66 auto m = iter<0,S>([](auto i) { return i; },
67 [](const auto&... e) { return Arr<SizeT,S>{ e... }; } );
68 auto ei = eindexPtr<L1>( std::make_shared<SIndex<SizeT,S>>
69 ( SRangeFactory<SizeT,S>(m).create() ) );
70 if constexpr(L2 == 0){
71 return spackp(ci,ei);
72 }
73 else {
74 return spackp(lindexPtr<L2>(ci),ei);
75 }
76 }
77
78 template <class Index, SizeT S, SizeT L>
79 decltype(auto) eplex(const Sptr<Index>& i, CSizeT<S> s, CSizeT<L> l)
80 {
81 return eplex<s,l,0>(i);
82 }
83
84 template <class Index, SizeT S, SizeT L1, SizeT L2>
86 {
87 return eplex<s,l1,l2>(i);
88 }
89
90}
91
92#endif
#define CXZ_ASSERT(statement, errmsg)
Definition assert.h:40
EIndex(const Sptr< LIndex< SIndex< MetaT, S >, L > > &i)
Definition eindex.cc.h:23
Extension index declaration.
Statically labeled index.
decltype(auto) eindexPtr(const Sptr< LIndex< SIndex< MetaT, S >, L > > &i)
Definition eindex.cc.h:42
decltype(auto) eplex(const Sptr< Index > &i)
Definition eindex.cc.h:60
uint64_t SizeT
Definition types.h:38
decltype(auto) xpr(const Sptr< I > &i)
std::integral_constant< SizeT, N > CSizeT
Definition types.h:81
Sptr< Range > rangeCast(const RangePtr r)
std::array< T, N > Arr
Definition types.h:45
decltype(auto) iptrMul(const Sptr< I1 > &a, const Sptr< I2 > &b)
constexpr decltype(auto) spackp(const Sptr< Indices > &... inds)
std::shared_ptr< T > Sptr
Definition types.h:48
SRange, SRangeFactory and SIndex declaration.