completely remove IndexInfo stuff

This commit is contained in:
Christian Zimmermann 2018-03-02 17:45:31 +01:00
parent b045b2d7e1
commit 10f6f75552
9 changed files with 0 additions and 294 deletions

View file

@ -12,12 +12,9 @@
#include "base_def.h" #include "base_def.h"
#include "mbase_def.h" #include "mbase_def.h"
//#include "block/block.h"
//#include "operation_utils.h"
#include "ranges/rheader.h" #include "ranges/rheader.h"
#include "pack_num.h" #include "pack_num.h"
#include "ranges/index_info.h"
#include "arith.h" #include "arith.h"
namespace MultiArrayTools namespace MultiArrayTools
@ -101,11 +98,6 @@ namespace MultiArrayTools
OperationMaster(MutableMultiArrayBase<T,Ranges...>& ma, const OpClass& second, OperationMaster(MutableMultiArrayBase<T,Ranges...>& ma, const OpClass& second,
IndexType& index); IndexType& index);
OperationMaster(MutableMultiArrayBase<T,Ranges...>& ma, const OpClass& second,
//std::shared_ptr<IndexType>& index,
IndexType& index,
const IndexInfo* blockIndex);
inline void set(size_t pos, T val) { mDataPtr[pos] = val; } inline void set(size_t pos, T val) { mDataPtr[pos] = val; }
inline void add(size_t pos, T val) { mDataPtr[pos] += val; } inline void add(size_t pos, T val) { mDataPtr[pos] += val; }
inline T get(size_t pos) const; inline T get(size_t pos) const;
@ -117,7 +109,6 @@ namespace MultiArrayTools
MutableMultiArrayBase<T,Ranges...>& mArrayRef; MutableMultiArrayBase<T,Ranges...>& mArrayRef;
T* mDataPtr; T* mDataPtr;
IndexType mIndex; IndexType mIndex;
//IndexInfo mIInfo;
}; };
@ -150,9 +141,7 @@ namespace MultiArrayTools
MultiArrayBase<T,Ranges...> const& mArrayRef; MultiArrayBase<T,Ranges...> const& mArrayRef;
const T* mDataPtr; const T* mDataPtr;
//std::shared_ptr<IndexType> mIndex;
IndexType mIndex; IndexType mIndex;
//IndexInfo mIInfo;
}; };
template <typename T, class... Ranges> template <typename T, class... Ranges>
@ -187,7 +176,6 @@ namespace MultiArrayTools
MutableMultiArrayBase<T,Ranges...>& mArrayRef; MutableMultiArrayBase<T,Ranges...>& mArrayRef;
T* mDataPtr; T* mDataPtr;
IndexType mIndex; IndexType mIndex;
//IndexInfo mIInfo;
}; };
template <class Op> template <class Op>
@ -388,17 +376,6 @@ namespace MultiArrayTools
performAssignment(0); performAssignment(0);
} }
template <typename T, class OpClass, class... Ranges>
OperationMaster<T,OpClass,Ranges...>::
OperationMaster(MutableMultiArrayBase<T,Ranges...>& ma, const OpClass& second,
IndexType& index,
const IndexInfo* blockIndex) :
mSecond(second), mArrayRef(ma), mDataPtr(mArrayRef.data()),
mIndex(index)
{
performAssignment(0);
}
template <typename T, class OpClass, class... Ranges> template <typename T, class OpClass, class... Ranges>
void OperationMaster<T,OpClass,Ranges...>::performAssignment(std::intptr_t blockIndexNum) void OperationMaster<T,OpClass,Ranges...>::performAssignment(std::intptr_t blockIndexNum)
{ {
@ -424,7 +401,6 @@ namespace MultiArrayTools
ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma, ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma,
const std::shared_ptr<typename Ranges::IndexType>&... indices) : const std::shared_ptr<typename Ranges::IndexType>&... indices) :
mArrayRef(ma), mDataPtr(mArrayRef.data()), mArrayRef(ma), mDataPtr(mArrayRef.data()),
//mIndex( mkIndex(ma,indices...) ), mIInfo(mIndex)
mIndex( ma.begin() ) mIndex( ma.begin() )
{ {
mIndex(indices...); mIndex(indices...);

View file

@ -93,8 +93,6 @@ namespace MultiArrayTools
size_t getStepSize(size_t n); size_t getStepSize(size_t n);
std::vector<IndexInfo> infoVec() const;
std::string id() const; std::string id() const;
void print(size_t offset); void print(size_t offset);
@ -390,15 +388,6 @@ namespace MultiArrayTools
return mBlockSizes[n+1]; return mBlockSizes[n+1];
} }
template <typename T, class... Indices>
std::vector<IndexInfo> ContainerIndex<T,Indices...>::infoVec() const
{
std::vector<IndexInfo> out;
out.reserve(sizeof...(Indices));
RPackNum<sizeof...(Indices)-1>::buildInfoVec(out, mIPack, mBlockSizes);
return std::move( out );
}
template <typename T, class... Indices> template <typename T, class... Indices>
std::string ContainerIndex<T,Indices...>::id() const std::string ContainerIndex<T,Indices...>::id() const
{ {

View file

@ -10,7 +10,6 @@
#include "rbase_def.h" #include "rbase_def.h"
#include "range_base.h" #include "range_base.h"
#include "index_type.h" #include "index_type.h"
#include "index_info.h"
#include "xfor/xfor.h" #include "xfor/xfor.h"
@ -54,8 +53,6 @@ namespace MultiArrayTools
std::shared_ptr<RangeBase> vrange() const { return mRangePtr; } std::shared_ptr<RangeBase> vrange() const { return mRangePtr; }
std::vector<IndexInfo> infoVec() const { return THIS().infoVec(); }
size_t getStepSize(size_t n) const { return THIS().getStepSize(n); } size_t getStepSize(size_t n) const { return THIS().getStepSize(n); }
operator size_t() const; operator size_t() const;
@ -67,8 +64,6 @@ 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))

View file

@ -1,104 +0,0 @@
// -*- C++ -*-
#ifndef __index_info_h__
#define __index_info_h__
#include <cstdlib>
#include <cstdint>
#include <vector>
#include <memory>
#include "index_type.h"
namespace MultiArrayTools
{
class IndexInfo;
class IndexInfo
{
public:
IndexInfo(IndexInfo&& in) = default;
IndexInfo& operator=(IndexInfo&& in) = default;
IndexInfo(const IndexInfo& in) = default;
IndexInfo& operator=(const IndexInfo& in) = default;
template <class IndexClass>
IndexInfo(const IndexClass& ind, size_t stepSize = 1);
template <class IndexClass>
IndexInfo& reassign(const IndexClass& ind, size_t stepSize = 1);
bool operator==(const IndexInfo& in) const;
bool operator!=(const IndexInfo& in) const;
bool operator<=(const IndexInfo& in) const;
bool operator<(const IndexInfo& in) const;
bool operator>(const IndexInfo& in) const;
bool operator>=(const IndexInfo& in) const;
const IndexInfo* getPtr(size_t inum) const;
std::intptr_t getPtrNum() const;
size_t dim() const;
size_t max() const;
size_t getStepSize(size_t inum) const;
size_t getStepSize() const;
IndexType type() const;
private:
IndexInfo() = default;
std::vector<IndexInfo> mNext;
std::intptr_t mPtrNum;
size_t mDim;
size_t mMax;
size_t mStepSize;
IndexType mType;
};
template <class IndexClass>
IndexInfo::IndexInfo(const IndexClass& ind, size_t stepSize) :
mNext(ind.infoVec()),
mPtrNum( reinterpret_cast<std::intptr_t>( &ind ) ),
mDim(ind.vrange()->dim()),
mMax(ind.max()),
mStepSize(stepSize),
mType(ind.type())
{}
template <class IndexClass>
IndexInfo& IndexInfo::reassign(const IndexClass& ind, size_t stepSize)
{
IndexInfo ii(ind, stepSize);
(*this) = std::move(ii);
return *this;
}
std::vector<IndexInfo> getRootIndices(const IndexInfo& info);
/*
inline size_t getStepSize(const IndexInfo& ii, std::intptr_t j)
{
if(ii.type() == IndexType::SINGLE){
return ii.getPtrNum() == j ? 1 : 0;
}
else {
size_t ss = 0;
size_t sx = 1;
for(size_t i = 0; i != ii.dim(); ++i){
const IndexInfo& itmp = *ii.getPtr(ii.dim()-i-1);
const size_t max = itmp.max();
const size_t tmp = getStepSize(itmp, j);
ss += tmp * sx;
sx *= max;
VCHECK(ss);
}
return ss;
}
}
*/
//size_t getStepSize(const std::vector<IndexInfo>& iv, std::intptr_t j);
} // end namespace MultiArrayTools
#endif

View file

@ -100,8 +100,6 @@ namespace MultiArrayTools
size_t getStepSize(size_t n); size_t getStepSize(size_t n);
std::vector<IndexInfo> infoVec() const;
std::string id() const; std::string id() const;
void print(size_t offset); void print(size_t offset);
@ -385,15 +383,6 @@ namespace MultiArrayTools
return mBlockSizes[n+1]; return mBlockSizes[n+1];
} }
template <class... Indices>
std::vector<IndexInfo> MultiIndex<Indices...>::infoVec() const
{
std::vector<IndexInfo> out;
out.reserve(sizeof...(Indices));
RPackNum<sizeof...(Indices)-1>::buildInfoVec(out, mIPack, mBlockSizes);
return std::move( out );
}
template <class... Indices> template <class... Indices>
std::string MultiIndex<Indices...>::id() const std::string MultiIndex<Indices...>::id() const
{ {

View file

@ -3,7 +3,6 @@
#define __rpack_num_h__ #define __rpack_num_h__
#include <memory> #include <memory>
#include "index_info.h"
namespace MultiArrayHelper namespace MultiArrayHelper
{ {
@ -224,16 +223,6 @@ namespace MultiArrayHelper
RPackNum<N-1>::template checkDefaultable<Ranges...>(); RPackNum<N-1>::template checkDefaultable<Ranges...>();
} }
template <class... Indices>
static void buildInfoVec(std::vector<IndexInfo>& out,
const std::tuple<std::shared_ptr<Indices>...>& ip,
const std::array<size_t,sizeof...(Indices)+1>& bs)
{
static const size_t POS = sizeof...(Indices)-N-1;
out.emplace_back(*std::get<POS>(ip), std::get<POS>(bs));
RPackNum<N-1>::buildInfoVec(out, ip, bs);
}
template <class IndexPack, class Exprs> template <class IndexPack, class Exprs>
static auto mkFor(const IndexPack& ipack, Exprs exs) static auto mkFor(const IndexPack& ipack, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-N-1>(ipack) -> decltype(std::get<std::tuple_size<IndexPack>::value-N-1>(ipack)
@ -415,15 +404,6 @@ namespace MultiArrayHelper
static_assert( Range::defaultable, "not defaultable" ); static_assert( Range::defaultable, "not defaultable" );
} }
template <class... Indices>
static void buildInfoVec(std::vector<IndexInfo>& out,
const std::tuple<std::shared_ptr<Indices>...>& ip,
const std::array<size_t,sizeof...(Indices)+1>& bs)
{
static const size_t POS = sizeof...(Indices)-1;
out.emplace_back(*std::get<POS>(ip), std::get<POS>(bs));
}
template <class IndexPack, class Exprs> template <class IndexPack, class Exprs>
static auto mkFor(const IndexPack& ipack, Exprs exs) static auto mkFor(const IndexPack& ipack, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack) -> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)

View file

@ -60,8 +60,6 @@ namespace MultiArrayTools
size_t getStepSize(size_t n); size_t getStepSize(size_t n);
std::vector<IndexInfo> infoVec() const;
std::string id() const; std::string id() const;
void print(size_t offset); void print(size_t offset);
@ -220,12 +218,6 @@ namespace MultiArrayTools
template <size_t N> template <size_t N>
void SingleIndex<U,TYPE>::getPtr() {} void SingleIndex<U,TYPE>::getPtr() {}
template <typename U, SpaceType TYPE>
std::vector<IndexInfo> SingleIndex<U,TYPE>::infoVec() const
{
return std::move( std::vector<IndexInfo>() );
}
template <typename U, SpaceType TYPE> template <typename U, SpaceType TYPE>
size_t SingleIndex<U,TYPE>::getStepSize(size_t n) size_t SingleIndex<U,TYPE>::getStepSize(size_t n)
{ {

View file

@ -1,7 +1,6 @@
set(libmultiarray_a_SOURCES set(libmultiarray_a_SOURCES
${CMAKE_SOURCE_DIR}/src/lib/ranges/range_base.cc ${CMAKE_SOURCE_DIR}/src/lib/ranges/range_base.cc
${CMAKE_SOURCE_DIR}/src/lib/ranges/index_info.cc
${CMAKE_SOURCE_DIR}/src/lib/ranges/anonymous_range.cc ${CMAKE_SOURCE_DIR}/src/lib/ranges/anonymous_range.cc
) )

View file

@ -1,110 +0,0 @@
#include "ranges/index_info.h"
#include "ranges/range_base.h"
namespace MultiArrayTools
{
bool IndexInfo::operator==(const IndexInfo& in) const
{
return mPtrNum == in.mPtrNum;
}
bool IndexInfo::operator!=(const IndexInfo& in) const
{
return mPtrNum != in.mPtrNum;
}
bool IndexInfo::operator<=(const IndexInfo& in) const
{
return mPtrNum <= in.mPtrNum;
}
bool IndexInfo::operator<(const IndexInfo& in) const
{
return mPtrNum < in.mPtrNum;
}
bool IndexInfo::operator>(const IndexInfo& in) const
{
return mPtrNum > in.mPtrNum;
}
bool IndexInfo::operator>=(const IndexInfo& in) const
{
return mPtrNum >= in.mPtrNum;
}
const IndexInfo* IndexInfo::getPtr(size_t inum) const
{
return &mNext[inum];
}
std::intptr_t IndexInfo::getPtrNum() const
{
return mPtrNum;
}
size_t IndexInfo::dim() const
{
return mDim;
}
size_t IndexInfo::max() const
{
return mMax;
}
size_t IndexInfo::getStepSize(size_t inum) const
{
return mNext[inum].getStepSize();
}
size_t IndexInfo::getStepSize() const
{
return mStepSize;
}
IndexType IndexInfo::type() const
{
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;
}
//inline size_t getStepSize(const IndexInfo& ii, std::intptr_t j)
size_t getStepSize(const std::vector<IndexInfo>& iv, std::intptr_t j)
{
size_t ss = 1;
for(auto ii = iv.end() - 1; ii != iv.begin(); --ii){
if(ii->getPtrNum() == j){
return ss;
}
ss *= ii->max();
}
if(iv.begin()->getPtrNum() == j){
return ss;
} else {
return 0;
}
}
} // end namespace MultiArrayTools