remove VIWB stuff
This commit is contained in:
parent
31de87229d
commit
d7e5098639
19 changed files with 18 additions and 222 deletions
|
@ -36,19 +36,18 @@ namespace MultiArrayTools
|
|||
auto getIndex(std::shared_ptr<RangeType> range)
|
||||
-> std::shared_ptr<typename RangeType::IndexType>
|
||||
{
|
||||
return std::dynamic_pointer_cast<IndexWrapper<typename RangeType::IndexType> >
|
||||
( range->index() )->get();
|
||||
return std::make_shared<typename RangeType::IndexType>(range);
|
||||
}
|
||||
|
||||
template <class RangeType>
|
||||
auto getIndex() -> std::shared_ptr<typename RangeType::IndexType>
|
||||
auto getIndex()
|
||||
-> std::shared_ptr<typename RangeType::IndexType>
|
||||
{
|
||||
static_assert( RangeType::defaultable,
|
||||
/*typeid(typename RangeType).name() + */" is not defaultable" );
|
||||
static auto f = RangeType::factory();
|
||||
static auto r = std::dynamic_pointer_cast<RangeType>( f.create() );
|
||||
return std::dynamic_pointer_cast<IndexWrapper<typename RangeType::IndexType> >
|
||||
( r->index() )->get();
|
||||
return std::make_shared<typename RangeType::IndexType>(r);
|
||||
}
|
||||
|
||||
template <class... RangeTypes>
|
||||
|
|
|
@ -44,8 +44,7 @@ namespace MultiArrayTools
|
|||
|
||||
virtual IndexType begin() const override;
|
||||
virtual IndexType end() const override;
|
||||
virtual std::shared_ptr<VIWB> index() const override;
|
||||
|
||||
|
||||
friend AnonymousRangeFactory;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -81,7 +81,6 @@ namespace MultiArrayTools
|
|||
template <size_t N>
|
||||
auto getPtr() -> decltype( std::get<N>( mIPack ) )&;
|
||||
|
||||
std::shared_ptr<VIWB> getVPtr(size_t n);
|
||||
size_t getStepSize(size_t n);
|
||||
|
||||
std::vector<IndexInfo> infoVec() const;
|
||||
|
@ -153,8 +152,6 @@ namespace MultiArrayTools
|
|||
|
||||
virtual IndexType begin() const override;
|
||||
virtual IndexType end() const override;
|
||||
|
||||
virtual std::shared_ptr<VIWB> index() const override;
|
||||
|
||||
friend ContainerRangeFactory<Ranges...>;
|
||||
|
||||
|
@ -329,17 +326,6 @@ namespace MultiArrayTools
|
|||
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>
|
||||
size_t ContainerIndex<Indices...>::getStepSize(size_t n)
|
||||
{
|
||||
|
@ -480,17 +466,6 @@ namespace MultiArrayTools
|
|||
i = size();
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "rbase_def.h"
|
||||
#include "range_base.h"
|
||||
#include "index_type.h"
|
||||
#include "vindex_wrapper.h"
|
||||
#include "index_info.h"
|
||||
|
||||
#include "xfor/xfor.h"
|
||||
|
@ -52,13 +51,6 @@ namespace MultiArrayTools
|
|||
|
||||
|
||||
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(); }
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "vindex_base.h"
|
||||
#include "index_type.h"
|
||||
|
||||
namespace MultiArrayTools
|
||||
|
|
|
@ -96,8 +96,7 @@ namespace MultiArrayTools
|
|||
|
||||
template <size_t N>
|
||||
auto getPtr() -> decltype( std::get<N>( mIPack ) )&;
|
||||
|
||||
std::shared_ptr<VIWB> getVPtr(size_t n);
|
||||
|
||||
size_t getStepSize(size_t n);
|
||||
|
||||
std::vector<IndexInfo> infoVec() const;
|
||||
|
@ -174,8 +173,6 @@ namespace MultiArrayTools
|
|||
virtual IndexType begin() const override;
|
||||
virtual IndexType end() const override;
|
||||
|
||||
virtual std::shared_ptr<VIWB> index() const override;
|
||||
|
||||
friend MultiRangeFactory<Ranges...>;
|
||||
|
||||
static constexpr bool defaultable = false;
|
||||
|
@ -373,18 +370,7 @@ namespace MultiArrayTools
|
|||
{
|
||||
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>
|
||||
size_t MultiIndex<Indices...>::getStepSize(size_t n)
|
||||
{
|
||||
|
@ -528,16 +514,6 @@ namespace MultiArrayTools
|
|||
i = size();
|
||||
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
|
||||
|
|
|
@ -13,7 +13,6 @@ namespace MultiArrayTools
|
|||
{
|
||||
class RangeBase;
|
||||
}
|
||||
#include "vindex_base.h"
|
||||
|
||||
namespace MultiArrayTools
|
||||
{
|
||||
|
@ -55,8 +54,6 @@ namespace MultiArrayTools
|
|||
|
||||
virtual size_t size() 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;
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace MultiArrayTools
|
|||
|
||||
virtual IndexType begin() 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>;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace MultiArrayTools
|
|||
|
||||
virtual IndexType begin() 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>;
|
||||
|
||||
|
|
|
@ -22,14 +22,6 @@ namespace MultiArrayTools
|
|||
template <class Index>
|
||||
class RangeInterface;
|
||||
|
||||
// index_base.h
|
||||
class VirtualIndexWrapperBase;
|
||||
typedef VirtualIndexWrapperBase VIWB;
|
||||
|
||||
// index_base.h
|
||||
template <class I>
|
||||
class IndexWrapper;
|
||||
|
||||
// index_base.h
|
||||
template <class I, typename MetaType>
|
||||
class IndexInterface;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#define __rpack_num_h__
|
||||
|
||||
#include <memory>
|
||||
#include "vindex_wrapper.h"
|
||||
#include "index_info.h"
|
||||
|
||||
namespace MultiArrayHelper
|
||||
|
@ -41,28 +40,6 @@ namespace MultiArrayHelper
|
|||
template <size_t N>
|
||||
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>
|
||||
static void initBlockSizes(std::array<size_t,sizeof...(Indices)+1>& bs,
|
||||
std::tuple<std::shared_ptr<Indices>...>& ip)
|
||||
|
@ -271,17 +248,6 @@ namespace MultiArrayHelper
|
|||
template<>
|
||||
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>
|
||||
static void initBlockSizes(std::array<size_t,sizeof...(Indices)+1>& bs,
|
||||
|
|
|
@ -57,7 +57,6 @@ namespace MultiArrayTools
|
|||
template <size_t N>
|
||||
void getPtr();
|
||||
|
||||
std::shared_ptr<VIWB> getVPtr(size_t n);
|
||||
size_t getStepSize(size_t n);
|
||||
|
||||
std::vector<IndexInfo> infoVec() const;
|
||||
|
@ -104,8 +103,7 @@ namespace MultiArrayTools
|
|||
|
||||
virtual IndexType begin() const override;
|
||||
virtual IndexType end() const override;
|
||||
virtual std::shared_ptr<VIWB> index() const override;
|
||||
|
||||
|
||||
friend SingleRangeFactory<U,TYPE>;
|
||||
|
||||
static constexpr bool defaultable = false;
|
||||
|
@ -221,12 +219,6 @@ namespace MultiArrayTools
|
|||
template <size_t N>
|
||||
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>
|
||||
std::vector<IndexInfo> SingleIndex<U,TYPE>::infoVec() const
|
||||
{
|
||||
|
@ -348,18 +340,6 @@ namespace MultiArrayTools
|
|||
i = size();
|
||||
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"
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -56,16 +56,17 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
// put this in the interface class !!!
|
||||
/*
|
||||
std::shared_ptr<VIWB> AnonymousRange::index() const
|
||||
{
|
||||
//typedef IndexWrapper<IndexType> IW;
|
||||
return std::shared_ptr<VIWB>();
|
||||
/* std::make_shared<IW>
|
||||
std::make_shared<IW>
|
||||
(std::make_shared<IndexType>
|
||||
( std::dynamic_pointer_cast<AnonymousRange>
|
||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) ); */ //!!!!
|
||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) ); //!!!!
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/*****************
|
||||
* Functions *
|
||||
|
|
|
@ -64,6 +64,7 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
// put this in the interface class !!!
|
||||
/*
|
||||
std::shared_ptr<VIWB> SingleRange<size_t,SpaceType::NONE>::index() const
|
||||
{
|
||||
typedef IndexWrapper<IndexType> IW;
|
||||
|
@ -72,6 +73,6 @@ namespace MultiArrayTools
|
|||
( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::NONE> >
|
||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
// put this in the interface class !!!
|
||||
/*
|
||||
std::shared_ptr<VIWB> SingleRange<size_t,SpaceType::SPIN>::index() const
|
||||
{
|
||||
typedef IndexWrapper<IndexType> IW;
|
||||
|
@ -70,6 +71,6 @@ namespace MultiArrayTools
|
|||
( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::SPIN> >
|
||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -162,12 +162,10 @@ namespace {
|
|||
auto gamma = MAT::getIndex<SR>();
|
||||
auto delta = MAT::getIndex<SR>();
|
||||
auto deltap = MAT::getIndex<SR>();
|
||||
auto vdeltap = MAT::make_viwb(deltap);
|
||||
|
||||
auto mix = MAT::mkMIndex( alpha, beta, gamma );
|
||||
|
||||
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){
|
||||
res1(delta, deltap) = ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix);
|
||||
}
|
||||
|
|
|
@ -215,12 +215,10 @@ namespace {
|
|||
auto gamma = MAT::getIndex<SR>();
|
||||
auto delta = MAT::getIndex<SR>();
|
||||
auto deltap = MAT::getIndex<SR>();
|
||||
auto vdeltap = MAT::make_viwb(deltap);
|
||||
|
||||
auto mix = MAT::mkMIndex( alpha, beta, gamma );
|
||||
|
||||
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);
|
||||
std::clock_t end = std::clock();
|
||||
std::cout << "MultiArray time: " << static_cast<double>( end - begin ) / CLOCKS_PER_SEC
|
||||
|
|
Loading…
Reference in a new issue