im com
This commit is contained in:
parent
f1b1298c69
commit
cf5fabd04b
2 changed files with 38 additions and 9 deletions
|
@ -222,7 +222,7 @@ namespace CNORXZ
|
||||||
OpRoot<T,Index> ArrayBase<T>::operator()(const Sptr<Index>& i)
|
OpRoot<T,Index> ArrayBase<T>::operator()(const Sptr<Index>& i)
|
||||||
{
|
{
|
||||||
//CXZ_WARNING("FORMAT / BLOCKSIZES!!!");
|
//CXZ_WARNING("FORMAT / BLOCKSIZES!!!");
|
||||||
auto j = moveToPtr( begin()->reformat(i) ); // moveToPtr: keep original instance of sub indices
|
auto j = moveToPtr( begin()->formatTo(i) ); // moveToPtr: keep original instance of sub indices
|
||||||
return oproot(*this, j);
|
return oproot(*this, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ namespace CNORXZ
|
||||||
inline decltype(auto) ArrayBase<T>::operator()(const SPack<Indices...>& pack)
|
inline decltype(auto) ArrayBase<T>::operator()(const SPack<Indices...>& pack)
|
||||||
{
|
{
|
||||||
//CXZ_WARNING("FORMAT / BLOCKSIZES!!!");
|
//CXZ_WARNING("FORMAT / BLOCKSIZES!!!");
|
||||||
auto j = moveToPtr( begin()->reformat(mindexPtr(pack)) );
|
auto j = moveToPtr( begin()->formatTo(mindexPtr(pack)) );
|
||||||
return oproot(*this, j);
|
return oproot(*this, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ namespace CNORXZ
|
||||||
inline decltype(auto) ArrayBase<T>::operator()(const DPack& pack)
|
inline decltype(auto) ArrayBase<T>::operator()(const DPack& pack)
|
||||||
{
|
{
|
||||||
//CXZ_WARNING("FORMAT / BLOCKSIZES!!!");
|
//CXZ_WARNING("FORMAT / BLOCKSIZES!!!");
|
||||||
auto j = moveToPtr( begin()->reformat(yindexPtr(pack)) );
|
auto j = moveToPtr( begin()->formatTo(yindexPtr(pack)) );
|
||||||
return oproot(*this, j);
|
return oproot(*this, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,16 +387,45 @@ namespace CNORXZ
|
||||||
template <class Index>
|
template <class Index>
|
||||||
decltype(auto) GMIndex<FormatT,Indices...>::formatFrom(const Index& ind) const
|
decltype(auto) GMIndex<FormatT,Indices...>::formatFrom(const Index& ind) const
|
||||||
{
|
{
|
||||||
if constexpr(index_is_multi<Index>::value){
|
static_assert(is_index<Index>::value, "got non-index");
|
||||||
// controll compatibility, coherent blocks etc...
|
CXZ_ASSERT(ind.dim() >= dim(), "for formatting index of dimension " << dim()
|
||||||
// two possibilities: single index (CIndex, UIndex, DIndex)
|
<< " need index of at least the same dimension, got " << ind.dim());
|
||||||
// or multi index (MIndex,YIndex)
|
|
||||||
|
|
||||||
|
if constexpr(index_is_multi<Index>::value){
|
||||||
|
if constexpr(has_static_sub<Index>::value){ // static dim (GMIndex)
|
||||||
|
// assert either same dim, dim == 1, or static sizes
|
||||||
|
CXZ_WARNING("not implemented!");
|
||||||
|
}
|
||||||
|
else { // YIndex
|
||||||
|
SizeT j = 0;
|
||||||
|
iter<0,NI>
|
||||||
|
( [&](auto i){
|
||||||
|
CXZ_ASSERT(j < ind.dim(), "no sub indices left");
|
||||||
|
const auto isize = pack()[i]->size();
|
||||||
|
SizeT ssize = 1;
|
||||||
|
for(; j < ind.dim() and ssize < isize; ++j){
|
||||||
|
ssize *= ind.pack()[j];
|
||||||
|
}
|
||||||
|
CXZ_ASSERT(ssize == isize, "incompatible sizes: " << ssize
|
||||||
|
<< " vs " << isize);
|
||||||
|
},
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// no input format, keep the original format
|
if(ind.dim() > 1) { // DIndex to YIndex
|
||||||
return *this
|
|
||||||
|
}
|
||||||
|
else { // this->dim() == 1 and ind.dim() == 1
|
||||||
|
static_assert
|
||||||
|
(std::is_same<FormatT,std::remove_reference<decltype(ind.format())>>::type,
|
||||||
|
"got incompatible static index format types");
|
||||||
|
mFormat = ind.format();
|
||||||
|
// assert that all lower indices in ind have dim == 1!!!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class FormatT, class... Indices>
|
template <class FormatT, class... Indices>
|
||||||
|
|
Loading…
Reference in a new issue