remove VIWB stuff

This commit is contained in:
Christian Zimmermann 2018-02-15 16:24:54 +01:00
parent 31de87229d
commit d7e5098639
19 changed files with 18 additions and 222 deletions

View file

@ -36,19 +36,18 @@ namespace MultiArrayTools
auto getIndex(std::shared_ptr<RangeType> range) auto getIndex(std::shared_ptr<RangeType> range)
-> std::shared_ptr<typename RangeType::IndexType> -> std::shared_ptr<typename RangeType::IndexType>
{ {
return std::dynamic_pointer_cast<IndexWrapper<typename RangeType::IndexType> > return std::make_shared<typename RangeType::IndexType>(range);
( range->index() )->get();
} }
template <class RangeType> template <class RangeType>
auto getIndex() -> std::shared_ptr<typename RangeType::IndexType> auto getIndex()
-> std::shared_ptr<typename RangeType::IndexType>
{ {
static_assert( RangeType::defaultable, static_assert( RangeType::defaultable,
/*typeid(typename RangeType).name() + */" is not defaultable" ); /*typeid(typename RangeType).name() + */" is not defaultable" );
static auto f = RangeType::factory(); static auto f = RangeType::factory();
static auto r = std::dynamic_pointer_cast<RangeType>( f.create() ); static auto r = std::dynamic_pointer_cast<RangeType>( f.create() );
return std::dynamic_pointer_cast<IndexWrapper<typename RangeType::IndexType> > return std::make_shared<typename RangeType::IndexType>(r);
( r->index() )->get();
} }
template <class... RangeTypes> template <class... RangeTypes>

View file

@ -44,8 +44,7 @@ namespace MultiArrayTools
virtual IndexType begin() const override; virtual IndexType begin() const override;
virtual IndexType end() const override; virtual IndexType end() const override;
virtual std::shared_ptr<VIWB> index() const override;
friend AnonymousRangeFactory; friend AnonymousRangeFactory;
protected: protected:

View file

@ -81,7 +81,6 @@ namespace MultiArrayTools
template <size_t N> template <size_t N>
auto getPtr() -> decltype( std::get<N>( mIPack ) )&; auto getPtr() -> decltype( std::get<N>( mIPack ) )&;
std::shared_ptr<VIWB> getVPtr(size_t n);
size_t getStepSize(size_t n); size_t getStepSize(size_t n);
std::vector<IndexInfo> infoVec() const; std::vector<IndexInfo> infoVec() const;
@ -153,8 +152,6 @@ namespace MultiArrayTools
virtual IndexType begin() const override; virtual IndexType begin() const override;
virtual IndexType end() const override; virtual IndexType end() const override;
virtual std::shared_ptr<VIWB> index() const override;
friend ContainerRangeFactory<Ranges...>; friend ContainerRangeFactory<Ranges...>;
@ -329,17 +326,6 @@ namespace MultiArrayTools
return std::get<N>( mIPack ); return std::get<N>( mIPack );
} }
template <class... Indices>
std::shared_ptr<VIWB> ContainerIndex<Indices...>::getVPtr(size_t n)
{
if(n >= sizeof...(Indices)){
assert(0);
// throw !!
}
ContainerIndex<Indices...> const* t = this;
return RPackNum<sizeof...(Indices)-1>::getIndexPtr(*t, n);
}
template <class... Indices> template <class... Indices>
size_t ContainerIndex<Indices...>::getStepSize(size_t n) size_t ContainerIndex<Indices...>::getStepSize(size_t n)
{ {
@ -480,17 +466,6 @@ namespace MultiArrayTools
i = size(); i = size();
return i; return i;
} }
template <class... Ranges>
std::shared_ptr<VIWB> ContainerRange<Ranges...>::index() const
{
typedef IndexWrapper<IndexType> IW;
return std::make_shared<IW>
( std::make_shared<IndexType>
( std::dynamic_pointer_cast<ContainerRange<Ranges...> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
}
} // end namespace MultiArrayTools } // end namespace MultiArrayTools

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 "vindex_wrapper.h"
#include "index_info.h" #include "index_info.h"
#include "xfor/xfor.h" #include "xfor/xfor.h"
@ -52,13 +51,6 @@ namespace MultiArrayTools
std::shared_ptr<RangeBase> vrange() const { return mRangePtr; } std::shared_ptr<RangeBase> vrange() const { return mRangePtr; }
/*auto range() const -> decltype( I::S_range(THIS()) ) { return I::S_range(THIS()); }
template <size_t N>
auto getPtr() const -> decltype(I::template S_get<N>(THIS()))
{ return I::template S_get<N>(THIS()); }
*/
std::shared_ptr<VIWB> getVPtr(size_t n) const { return THIS().getVPtr(n); }
std::vector<IndexInfo> infoVec() const { return THIS().infoVec(); } std::vector<IndexInfo> infoVec() const { return THIS().infoVec(); }

View file

@ -7,7 +7,6 @@
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
#include <memory> #include <memory>
#include "vindex_base.h"
#include "index_type.h" #include "index_type.h"
namespace MultiArrayTools namespace MultiArrayTools

View file

@ -96,8 +96,7 @@ namespace MultiArrayTools
template <size_t N> template <size_t N>
auto getPtr() -> decltype( std::get<N>( mIPack ) )&; auto getPtr() -> decltype( std::get<N>( mIPack ) )&;
std::shared_ptr<VIWB> getVPtr(size_t n);
size_t getStepSize(size_t n); size_t getStepSize(size_t n);
std::vector<IndexInfo> infoVec() const; std::vector<IndexInfo> infoVec() const;
@ -174,8 +173,6 @@ namespace MultiArrayTools
virtual IndexType begin() const override; virtual IndexType begin() const override;
virtual IndexType end() const override; virtual IndexType end() const override;
virtual std::shared_ptr<VIWB> index() const override;
friend MultiRangeFactory<Ranges...>; friend MultiRangeFactory<Ranges...>;
static constexpr bool defaultable = false; static constexpr bool defaultable = false;
@ -373,18 +370,7 @@ namespace MultiArrayTools
{ {
return std::get<N>(mIPack); return std::get<N>(mIPack);
} }
template <class... Indices>
std::shared_ptr<VIWB> MultiIndex<Indices...>::getVPtr(size_t n)
{
if(n >= sizeof...(Indices)){
assert(0);
// throw !!
}
MultiIndex<Indices...> const* t = this;
return RPackNum<sizeof...(Indices)-1>::getIndexPtr(*t, n);
}
template <class... Indices> template <class... Indices>
size_t MultiIndex<Indices...>::getStepSize(size_t n) size_t MultiIndex<Indices...>::getStepSize(size_t n)
{ {
@ -528,16 +514,6 @@ namespace MultiArrayTools
i = size(); i = size();
return i; return i;
} }
template <class... Ranges>
std::shared_ptr<VIWB> MultiRange<Ranges...>::index() const
{
typedef IndexWrapper<IndexType> IW;
return std::make_shared<IW>
( std::make_shared<IndexType>
( std::dynamic_pointer_cast<MultiRange<Ranges...> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
}
} }
#endif #endif

View file

@ -13,7 +13,6 @@ namespace MultiArrayTools
{ {
class RangeBase; class RangeBase;
} }
#include "vindex_base.h"
namespace MultiArrayTools namespace MultiArrayTools
{ {
@ -55,8 +54,6 @@ namespace MultiArrayTools
virtual size_t size() const = 0; virtual size_t size() const = 0;
virtual size_t dim() const = 0; virtual size_t dim() const = 0;
virtual std::shared_ptr<VIWB> index() const = 0;
bool operator==(const RangeBase& in) const; bool operator==(const RangeBase& in) const;
bool operator!=(const RangeBase& in) const; bool operator!=(const RangeBase& in) const;

View file

@ -37,7 +37,7 @@ namespace MultiArrayTools
virtual IndexType begin() const override; virtual IndexType begin() const override;
virtual IndexType end() const override; virtual IndexType end() const override;
virtual std::shared_ptr<VIWB> index() const override; //virtual std::shared_ptr<VIWB> index() const override;
friend SingleRangeFactory<size_t,SpaceType::NONE>; friend SingleRangeFactory<size_t,SpaceType::NONE>;

View file

@ -41,7 +41,7 @@ namespace MultiArrayTools
virtual IndexType begin() const override; virtual IndexType begin() const override;
virtual IndexType end() const override; virtual IndexType end() const override;
virtual std::shared_ptr<VIWB> index() const override; //virtual std::shared_ptr<VIWB> index() const override;
friend SingleRangeFactory<size_t,SpaceType::SPIN>; friend SingleRangeFactory<size_t,SpaceType::SPIN>;

View file

@ -22,14 +22,6 @@ namespace MultiArrayTools
template <class Index> template <class Index>
class RangeInterface; class RangeInterface;
// index_base.h
class VirtualIndexWrapperBase;
typedef VirtualIndexWrapperBase VIWB;
// index_base.h
template <class I>
class IndexWrapper;
// index_base.h // index_base.h
template <class I, typename MetaType> template <class I, typename MetaType>
class IndexInterface; class IndexInterface;

View file

@ -3,7 +3,6 @@
#define __rpack_num_h__ #define __rpack_num_h__
#include <memory> #include <memory>
#include "vindex_wrapper.h"
#include "index_info.h" #include "index_info.h"
namespace MultiArrayHelper namespace MultiArrayHelper
@ -41,28 +40,6 @@ namespace MultiArrayHelper
template <size_t N> template <size_t N>
struct RPackNum struct RPackNum
{ {
template <class IndexType>
static std::shared_ptr<VIWB> getIndex(const IndexType& in, size_t n)
{
if(n == N){
return make_viwb( in.template get<N>() );
}
else {
return RPackNum<N-1>::getIndex(in, n);
}
}
template <class IndexType>
static std::shared_ptr<VIWB> getIndexPtr(const IndexType& in, size_t n)
{
if(n == N){
return make_viwb( in.template getPtr<N>() );
}
else {
return RPackNum<N-1>::getIndexPtr(in, n);
}
}
template <class... Indices> template <class... Indices>
static void initBlockSizes(std::array<size_t,sizeof...(Indices)+1>& bs, static void initBlockSizes(std::array<size_t,sizeof...(Indices)+1>& bs,
std::tuple<std::shared_ptr<Indices>...>& ip) std::tuple<std::shared_ptr<Indices>...>& ip)
@ -271,17 +248,6 @@ namespace MultiArrayHelper
template<> template<>
struct RPackNum<0> struct RPackNum<0>
{ {
template <class IndexType>
static std::shared_ptr<VIWB> getIndex(const IndexType& in, size_t n)
{
return make_viwb( in.template get<0>() );
}
template <class IndexType>
static std::shared_ptr<VIWB> getIndexPtr(const IndexType& in, size_t n)
{
return make_viwb( in.template getPtr<0>() );
}
template <class... Indices> template <class... Indices>
static void initBlockSizes(std::array<size_t,sizeof...(Indices)+1>& bs, static void initBlockSizes(std::array<size_t,sizeof...(Indices)+1>& bs,

View file

@ -57,7 +57,6 @@ namespace MultiArrayTools
template <size_t N> template <size_t N>
void getPtr(); void getPtr();
std::shared_ptr<VIWB> getVPtr(size_t n);
size_t getStepSize(size_t n); size_t getStepSize(size_t n);
std::vector<IndexInfo> infoVec() const; std::vector<IndexInfo> infoVec() const;
@ -104,8 +103,7 @@ namespace MultiArrayTools
virtual IndexType begin() const override; virtual IndexType begin() const override;
virtual IndexType end() const override; virtual IndexType end() const override;
virtual std::shared_ptr<VIWB> index() const override;
friend SingleRangeFactory<U,TYPE>; friend SingleRangeFactory<U,TYPE>;
static constexpr bool defaultable = false; static constexpr bool defaultable = false;
@ -221,12 +219,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::shared_ptr<VIWB> SingleIndex<U,TYPE>::getVPtr(size_t n)
{
return std::shared_ptr<VIWB>();
}
template <typename U, SpaceType TYPE> template <typename U, SpaceType TYPE>
std::vector<IndexInfo> SingleIndex<U,TYPE>::infoVec() const std::vector<IndexInfo> SingleIndex<U,TYPE>::infoVec() const
{ {
@ -348,18 +340,6 @@ namespace MultiArrayTools
i = size(); i = size();
return i; return i;
} }
// put this in the interface class !!!
template <typename U, SpaceType TYPE>
std::shared_ptr<VIWB> SingleRange<U,TYPE>::index() const
{
typedef IndexWrapper<IndexType> IW;
return std::make_shared<IW>
( std::make_shared<IndexType>
( std::dynamic_pointer_cast<SingleRange<U,TYPE> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
}
} }
#include "range_types/header.h" #include "range_types/header.h"

View file

@ -1,35 +0,0 @@
#ifndef __vindex_base_h__
#define __vindex_base_h__
//#include "ranges/range_base.h"
#include "ranges/index_type.h"
#include "base_def.h"
namespace MultiArrayTools
{
#ifndef __range_base_h__
class RangeBase;
#endif
class VirtualIndexWrapperBase
{
public:
DEFAULT_MEMBERS(VirtualIndexWrapperBase);
virtual IndexType type() const = 0;
virtual size_t dim() const = 0;
virtual size_t pos() const = 0;
virtual size_t max() const = 0;
virtual std::shared_ptr<RangeBase> rangePtr() const = 0;
virtual std::shared_ptr<VirtualIndexWrapperBase> getPtr(size_t n) const = 0;
virtual std::intptr_t getPtrNum() const = 0;
virtual size_t getStepSize(size_t n) const = 0;
};
typedef VirtualIndexWrapperBase VIWB;
} // end namespace MultiArrayTools
#endif

View file

@ -1,43 +0,0 @@
#ifndef __vindex_wrapper_h__
#define __vindex_wrapper_h__
#include "ranges/vindex_base.h"
namespace MultiArrayTools
{
template <class I>
std::shared_ptr<IndexWrapper<I> > make_viwb(std::shared_ptr<I> idxPtr)
{
return std::make_shared<IndexWrapper<I> >(idxPtr);
}
template <class I>
class IndexWrapper : public VirtualIndexWrapperBase
{
public:
DEFAULT_MEMBERS(IndexWrapper);
IndexWrapper(std::shared_ptr<I> idxPtr) : mIdxPtr(idxPtr) {}
virtual IndexType type() const override { return mIdxPtr->type(); }
virtual size_t dim() const override { return mIdxPtr->dim(); }
virtual size_t pos() const override { return mIdxPtr->pos(); }
virtual size_t max() const override { return mIdxPtr->max(); }
virtual std::shared_ptr<RangeBase> rangePtr() const override { return mIdxPtr->vrange(); }
virtual std::shared_ptr<VirtualIndexWrapperBase> getPtr(size_t n) const override
{ return mIdxPtr->getVPtr(n); }
virtual std::intptr_t getPtrNum() const override { return reinterpret_cast<std::intptr_t>( mIdxPtr.get() ); }
virtual size_t getStepSize(size_t n) const override { return mIdxPtr->getStepSize(n); }
std::shared_ptr<I> get() const { return mIdxPtr; } // unwrap
private:
std::shared_ptr<I> mIdxPtr;
};
}
#endif

View file

@ -56,16 +56,17 @@ namespace MultiArrayTools
} }
// put this in the interface class !!! // put this in the interface class !!!
/*
std::shared_ptr<VIWB> AnonymousRange::index() const std::shared_ptr<VIWB> AnonymousRange::index() const
{ {
//typedef IndexWrapper<IndexType> IW; //typedef IndexWrapper<IndexType> IW;
return std::shared_ptr<VIWB>(); return std::shared_ptr<VIWB>();
/* std::make_shared<IW> std::make_shared<IW>
(std::make_shared<IndexType> (std::make_shared<IndexType>
( std::dynamic_pointer_cast<AnonymousRange> ( std::dynamic_pointer_cast<AnonymousRange>
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) ); */ //!!!! ( std::shared_ptr<RangeBase>( RB::mThis ) ) ) ); //!!!!
} }
*/
/***************** /*****************
* Functions * * Functions *

View file

@ -64,6 +64,7 @@ namespace MultiArrayTools
} }
// put this in the interface class !!! // put this in the interface class !!!
/*
std::shared_ptr<VIWB> SingleRange<size_t,SpaceType::NONE>::index() const std::shared_ptr<VIWB> SingleRange<size_t,SpaceType::NONE>::index() const
{ {
typedef IndexWrapper<IndexType> IW; typedef IndexWrapper<IndexType> IW;
@ -72,6 +73,6 @@ namespace MultiArrayTools
( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::NONE> > ( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::NONE> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) ); ( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
} }
*/
} }

View file

@ -62,6 +62,7 @@ namespace MultiArrayTools
} }
// put this in the interface class !!! // put this in the interface class !!!
/*
std::shared_ptr<VIWB> SingleRange<size_t,SpaceType::SPIN>::index() const std::shared_ptr<VIWB> SingleRange<size_t,SpaceType::SPIN>::index() const
{ {
typedef IndexWrapper<IndexType> IW; typedef IndexWrapper<IndexType> IW;
@ -70,6 +71,6 @@ namespace MultiArrayTools
( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::SPIN> > ( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::SPIN> >
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) ); ( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
} }
*/
} }

View file

@ -162,12 +162,10 @@ namespace {
auto gamma = MAT::getIndex<SR>(); auto gamma = MAT::getIndex<SR>();
auto delta = MAT::getIndex<SR>(); auto delta = MAT::getIndex<SR>();
auto deltap = MAT::getIndex<SR>(); auto deltap = MAT::getIndex<SR>();
auto vdeltap = MAT::make_viwb(deltap);
auto mix = MAT::mkMIndex( alpha, beta, gamma ); auto mix = MAT::mkMIndex( alpha, beta, gamma );
std::clock_t begin = std::clock(); std::clock_t begin = std::clock();
//res1(delta, deltap).set(vdeltap) = ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix);
for(size_t i = 0; i != 1000; ++i){ for(size_t i = 0; i != 1000; ++i){
res1(delta, deltap) = ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix); res1(delta, deltap) = ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix);
} }

View file

@ -215,12 +215,10 @@ namespace {
auto gamma = MAT::getIndex<SR>(); auto gamma = MAT::getIndex<SR>();
auto delta = MAT::getIndex<SR>(); auto delta = MAT::getIndex<SR>();
auto deltap = MAT::getIndex<SR>(); auto deltap = MAT::getIndex<SR>();
auto vdeltap = MAT::make_viwb(deltap);
auto mix = MAT::mkMIndex( alpha, beta, gamma ); auto mix = MAT::mkMIndex( alpha, beta, gamma );
std::clock_t begin = std::clock(); std::clock_t begin = std::clock();
//res1(delta, deltap).set(vdeltap) = ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix);
res1(delta, deltap) = ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix); res1(delta, deltap) = ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix);
std::clock_t end = std::clock(); std::clock_t end = std::clock();
std::cout << "MultiArray time: " << static_cast<double>( end - begin ) / CLOCKS_PER_SEC std::cout << "MultiArray time: " << static_cast<double>( end - begin ) / CLOCKS_PER_SEC