CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
index_pack.cc.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_index_pack_cc_h__
13#define __cxz_index_pack_cc_h__
14
15#include "index_pack.h"
16
17namespace CNORXZ
18{
19 /*===========+
20 | SPack |
21 +===========*/
22
23 template <class... Indices>
25 mIs(is...)
26 {}
27
28 template <class... Indices>
30 mIs(is)
31 {}
32
33 template <class... Indices>
34 constexpr const Tuple<Sptr<Indices>...>& SPack<Indices...>::all() const
35 {
36 return mIs;
37 }
38
39 template <class... Indices>
40 template <SizeT I>
41 constexpr decltype(auto) SPack<Indices...>::get(CSizeT<I> i) const
42 {
43 return std::get<I>(mIs);
44 }
46 template <class... Indices>
47 template <SizeT I>
48 constexpr decltype(auto) SPack<Indices...>::operator[](CSizeT<I> i) const
49 {
50 return get(i);
51 }
52
53 template <class... Indices>
54 template <class Index>
55 constexpr decltype(auto) SPack<Indices...>::rmul(const Sptr<Index>& i) const
56 {
57 return SPack<Indices...,Index>( std::tuple_cat(mIs,std::make_tuple(i)) );
58 }
59
60 template <class... Indices>
61 template <class Index>
62 constexpr decltype(auto) SPack<Indices...>::lmul(const Sptr<Index>& i) const
63 {
64 return SPack<Index,Indices...>( std::tuple_cat(std::make_tuple(i), mIs) );
65 }
66
67 template <class... Indices>
68 template <class... Indices2>
69 constexpr decltype(auto) SPack<Indices...>::mul(const SPack<Indices2...>& p) const
70 {
71 return SPack<Indices...,Indices2...>( std::tuple_cat(mIs, all()) );
72 }
73
74 template <class... Indices>
75 decltype(auto) SPack<Indices...>::mkRange() const
76 {
77 return iter<0,sizeof...(Indices)>( [&](auto i) { return get(i)->range(); },
78 [](const auto&... e) { return mrange(e...); } );
79 }
80
81 template <class... Indices>
83 {
84 return iter<0,sizeof...(Indices)-1>
85 ( [&](auto i) { return get(i)->lex() * iter<i+1,sizeof...(Indices)>
86 ( [&](auto j) { return get(j)->lmax().val(); },
87 [](const auto&... m) { return ( m * ... ); } ); },
88 [](const auto&... e) { return ( e + ... ); } ) +
89 get(CSizeT<sizeof...(Indices)-1>{})->lex() ;
90 }
91
92 template <class... Indices>
94 {
95 return lex();
96 }
98 /*========================+
99 | SPack (non-member) |
100 +========================*/
101
102 template <class... Indices>
103 constexpr decltype(auto) spack(const Indices&... inds)
104 {
105 static_assert((is_index<Indices>::value and ...), "got non-index type");
106 return SPack<Indices...>( std::make_shared<Indices>(inds)... );
108
109 template <class... Indices>
110 constexpr decltype(auto) spackp(const Sptr<Indices>&... inds)
111 {
112 static_assert((is_index<Indices>::value and ...), "got non-index type");
113 return SPack<Indices...>( inds... );
114 }
115
116 /*===========+
117 | DPack |
118 +===========*/
119
120 template <class... Indices>
122 mIs( iter<0,sizeof...(Indices)>
123 ( [&](auto i) { return xindexPtr(p[i]); },
124 [](const auto&... e) { return Vector<XIndexPtr>( { e... } ); } )
125 )
126 {}
127
128
129 /*========================+
130 | DPack (non-member) |
131 +========================*/
132
133 template <class... Indices>
135 {
136 return DPack( Vector<XIndexPtr>( { xindexPtr( std::make_shared<Indices>( inds ) )... } ) );
137 }
138
139 template <class... Indices>
141 {
142 return DPack( Vector<XIndexPtr>( { xindexPtr( inds )... } ) );
143 }
144
145}
146
147#endif
DPack(const Vector< XIndexPtr > &is)
Definition index_pack.cc:16
constexpr SPack(const Sptr< Indices > &... is)
SizeT lex() const
SizeT pos() const
constexpr const Tuple< Sptr< Indices >... > & all() const
Index pack declarations.
DPack dpack(const Indices &... inds)
DPack dpackp(const Sptr< Indices > &... inds)
uint64_t SizeT
Definition types.h:38
std::vector< T, Allocator< T > > Vector
Definition types.h:310
constexpr decltype(auto) spack(const Indices &... inds)
RangePtr mrange(const Sptr< Ranges > &... rs)
Definition mrange.cc.h:800
std::integral_constant< SizeT, N > CSizeT
Definition types.h:81
Sptr< Range > rangeCast(const RangePtr r)
XIndexPtr xindexPtr(const Sptr< Index > &i)
Definition xindex.cc.h:217
std::tuple< T... > Tuple
Definition types.h:60
constexpr decltype(auto) spackp(const Sptr< Indices > &... inds)
std::shared_ptr< T > Sptr
Definition types.h:48
constexpr decltype(auto) iter(const G &g, const F &f)
Definition iter.cc.h:34