im com (re-enabling oputest)

This commit is contained in:
Christian Zimmermann 2018-02-13 21:36:41 +01:00
parent c674c541a1
commit bcc6b98882
5 changed files with 64 additions and 10 deletions

View file

@ -254,7 +254,7 @@ namespace MultiArrayTools
std::tuple<Ops...> mOps; std::tuple<Ops...> mOps;
public: public:
typedef decltype(PackNum<sizeof...(Ops)-1>::mkSteps(0, mOps)) ETuple; typedef decltype(PackNum<sizeof...(Ops)-1>::template mkSteps<Ops...>(0, mOps)) ETuple;
Operation(const Ops&... ops); Operation(const Ops&... ops);
@ -469,7 +469,7 @@ namespace MultiArrayTools
template <typename T, class... Ranges> template <typename T, class... Ranges>
MExt<void> ConstOperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const MExt<void> ConstOperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
{ {
return MExt<void>(0u); // !!!!!! return MExt<void>(getStepSize( getRootIndices( mIndex->info() ), iPtrNum ));
} }
@ -520,7 +520,7 @@ namespace MultiArrayTools
template <typename T, class... Ranges> template <typename T, class... Ranges>
MExt<void> OperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const MExt<void> OperationRoot<T,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
{ {
return MExt<void>(0u); // !!!!!! return MExt<void>(getStepSize( getRootIndices( mIndex->info() ), iPtrNum ));
} }
template <typename T, class... Ranges> template <typename T, class... Ranges>

View file

@ -59,7 +59,7 @@ namespace MultiArrayHelper
} }
template <class... Ops> template <class... Ops>
static auto mkSteps(std::intptr_t ii, const std::tuple<Ops const&...>& otp) static auto mkSteps(std::intptr_t ii, const std::tuple<Ops...>& otp)
-> decltype(together(PackNum<N-1>::mkSteps(ii, otp), std::get<N>(otp).rootSteps(ii))) -> decltype(together(PackNum<N-1>::mkSteps(ii, otp), std::get<N>(otp).rootSteps(ii)))
{ {
return together(PackNum<N-1>::mkSteps(ii, otp), std::get<N>(otp).rootSteps(ii) ); return together(PackNum<N-1>::mkSteps(ii, otp), std::get<N>(otp).rootSteps(ii) );
@ -130,7 +130,7 @@ namespace MultiArrayHelper
} }
template <class... Ops> template <class... Ops>
static auto mkSteps(std::intptr_t ii, const std::tuple<Ops const&...>& otp) static auto mkSteps(std::intptr_t ii, const std::tuple<Ops...>& otp)
-> decltype(std::get<0>(otp).rootSteps(ii)) -> decltype(std::get<0>(otp).rootSteps(ii))
{ {
return std::get<0>(otp).rootSteps(ii); return std::get<0>(otp).rootSteps(ii);

View file

@ -73,13 +73,15 @@ namespace MultiArrayTools
void print(size_t offset = 0) const { THIS().print(offset); } void print(size_t offset = 0) const { THIS().print(offset); }
IndexInfo info() const { return IndexInfo(THIS()); }
// CHECK / IMPLEMENT !!!!!! // CHECK / IMPLEMENT !!!!!!
template <class Expr> template <class Expr>
auto ifor(const Expr&& ex) const -> decltype(THIS().template ifor<Expr>(ex)) auto ifor(const Expr ex) const -> decltype(THIS().template ifor<Expr>(ex))
{ return THIS().template ifor<Expr>(ex); } { return THIS().template ifor<Expr>(ex); }
template <class Expr> template <class Expr>
auto iforh(const Expr&& ex) const -> decltype(THIS().template iforh<Expr>(ex)) auto iforh(const Expr ex) const -> decltype(THIS().template iforh<Expr>(ex))
{ return THIS().template iforh<Expr>(ex); } { return THIS().template iforh<Expr>(ex); }
private: private:

View file

@ -71,4 +71,52 @@ namespace MultiArrayTools
return mType; return mType;
} }
std::vector<IndexInfo> getRootIndices(const IndexInfo& info)
{
std::vector<IndexInfo> out;
out.reserve(info.dim());
if(info.type() == IndexType::SINGLE){
out.push_back(info);
}
else {
for(size_t i = 0; i != info.dim(); ++i){
auto vv = getRootIndices(*info.getPtr(i));
out.insert(out.end(), vv.begin(), vv.end());
}
}
return out;
}
size_t getStepSize(const std::vector<IndexInfo>& iv, const IndexInfo& j)
{
size_t ss = 1;
auto ii = iv.end() - 1;
auto end = iv.begin();
while(*ii != j){
ss *= ii->max();
--ii;
if(ii == end){
break;
}
}
return ss;
}
size_t getStepSize(const std::vector<IndexInfo>& iv, std::intptr_t j)
{
size_t ss = 1;
auto ii = iv.end() - 1;
auto end = iv.begin();
while(ii->getPtrNum() != j){
ss *= ii->max();
--ii;
if(ii == end){
break;
}
}
return ss;
}
} // end namespace MultiArrayTools } // end namespace MultiArrayTools

View file

@ -20,8 +20,8 @@ namespace MultiArrayTools
IndexInfo(IndexInfo&& in) = default; IndexInfo(IndexInfo&& in) = default;
IndexInfo& operator=(IndexInfo&& in) = default; IndexInfo& operator=(IndexInfo&& in) = default;
//IndexInfo(const IndexInfo& in) = default; IndexInfo(const IndexInfo& in) = default;
//IndexInfo& operator=(const IndexInfo& in) = default; IndexInfo& operator=(const IndexInfo& in) = default;
template <class IndexClass> template <class IndexClass>
IndexInfo(const IndexClass& ind, size_t stepSize = 1); IndexInfo(const IndexClass& ind, size_t stepSize = 1);
@ -76,7 +76,11 @@ namespace MultiArrayTools
return *this; return *this;
} }
std::vector<IndexInfo> getRootIndices(const IndexInfo& info);
size_t getStepSize(const std::vector<IndexInfo>& iv, const IndexInfo& j);
size_t getStepSize(const std::vector<IndexInfo>& iv, std::intptr_t j);
} // end namespace MultiArrayTools } // end namespace MultiArrayTools
#endif #endif