dev #2
3 changed files with 121 additions and 51 deletions
|
@ -10,9 +10,9 @@
|
||||||
namespace CNORXZ
|
namespace CNORXZ
|
||||||
{
|
{
|
||||||
|
|
||||||
/**********************
|
/*====================+
|
||||||
* COpInterface *
|
| COpInterface |
|
||||||
**********************/
|
+====================*/
|
||||||
|
|
||||||
template <class OpT>
|
template <class OpT>
|
||||||
template <class F, class IndexT>
|
template <class F, class IndexT>
|
||||||
|
@ -37,9 +37,9 @@ namespace CNORXZ
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************
|
/*===================+
|
||||||
* OpInterface *
|
| OpInterface |
|
||||||
*********************/
|
+===================*/
|
||||||
|
|
||||||
template <class OpT>
|
template <class OpT>
|
||||||
template <class IndexT, class F, class... Args>
|
template <class IndexT, class F, class... Args>
|
||||||
|
@ -56,9 +56,9 @@ namespace CNORXZ
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************
|
/*=============+
|
||||||
* COpRoot *
|
| COpRoot |
|
||||||
***************/
|
+=============*/
|
||||||
|
|
||||||
template <typename T, class IndexT>
|
template <typename T, class IndexT>
|
||||||
constexpr COpRoot<T,IndexT>::COpRoot(const CArrayBase<T>& a, const Sptr<IndexT>& ind) :
|
constexpr COpRoot<T,IndexT>::COpRoot(const CArrayBase<T>& a, const Sptr<IndexT>& ind) :
|
||||||
|
@ -123,9 +123,52 @@ namespace CNORXZ
|
||||||
return COpRoot<T,IndexT>(a, ind);
|
return COpRoot<T,IndexT>(a, ind);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************
|
/*=============+
|
||||||
* OpCont *
|
| POpRoot |
|
||||||
****************/
|
+=============*/
|
||||||
|
|
||||||
|
template <class IndexT, class Op>
|
||||||
|
constexpr POpRoot<IndexT,Op>::POpRoot(const Sptr<IndexT>& ind, const SizeT* parts, Op&& op) :
|
||||||
|
mIndex(ind),
|
||||||
|
mFp(1,parts),
|
||||||
|
mOp(std::forward<Op>(op))
|
||||||
|
{}
|
||||||
|
|
||||||
|
template <class IndexT, class Op>
|
||||||
|
template <class PosT>
|
||||||
|
constexpr decltype(auto) POpRoot<IndexT,Op>::operator()(const PosT& pos) const
|
||||||
|
{
|
||||||
|
return mOp(mFp(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class IndexT, class Op>
|
||||||
|
constexpr decltype(auto) POpRoot<IndexT,Op>::operator()() const
|
||||||
|
{
|
||||||
|
return mOp(mFp(SPos<0>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class IndexT, class Op>
|
||||||
|
template <SizeT I>
|
||||||
|
constexpr decltype(auto) POpRoot<IndexT,Op>::rootSteps(const IndexId<I>& id) const
|
||||||
|
{
|
||||||
|
return mIndex->stepSize(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class IndexT, class Op>
|
||||||
|
constexpr decltype(auto) POpRoot<IndexT,Op>::data() const
|
||||||
|
{
|
||||||
|
return mOp->data();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class IndexT, class Op>
|
||||||
|
constexpr decltype(auto) poproot(const Sptr<IndexT>& ind, const SizeT* parts, Op&& op)
|
||||||
|
{
|
||||||
|
return POpRoot(ind, parts, std::forward<Op>(op));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============+
|
||||||
|
| OpCont |
|
||||||
|
+==============*/
|
||||||
|
|
||||||
template <typename T, class IndexT>
|
template <typename T, class IndexT>
|
||||||
constexpr OpCont<T,IndexT>::OpCont(const Sptr<IndexT>& ind) :
|
constexpr OpCont<T,IndexT>::OpCont(const Sptr<IndexT>& ind) :
|
||||||
|
@ -236,9 +279,9 @@ namespace CNORXZ
|
||||||
return mC.data();
|
return mC.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************
|
/*==============+
|
||||||
* OpRoot *
|
| OpRoot |
|
||||||
****************/
|
+==============*/
|
||||||
|
|
||||||
template <typename T, class IndexT>
|
template <typename T, class IndexT>
|
||||||
constexpr OpRoot<T,IndexT>::OpRoot(ArrayBase<T>& a, const Sptr<IndexT>& ind) :
|
constexpr OpRoot<T,IndexT>::OpRoot(ArrayBase<T>& a, const Sptr<IndexT>& ind) :
|
||||||
|
@ -327,9 +370,9 @@ namespace CNORXZ
|
||||||
return OpRoot<T,IndexT>(a, ind);
|
return OpRoot<T,IndexT>(a, ind);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************
|
/*=================+
|
||||||
* Operation *
|
| Operation |
|
||||||
*******************/
|
+=================*/
|
||||||
|
|
||||||
template <class F, class... Ops>
|
template <class F, class... Ops>
|
||||||
constexpr Operation<F,Ops...>::Operation(F&& f, const Ops&... ops) :
|
constexpr Operation<F,Ops...>::Operation(F&& f, const Ops&... ops) :
|
||||||
|
@ -411,9 +454,9 @@ namespace CNORXZ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************
|
/*===================+
|
||||||
* Contraction *
|
| Contraction |
|
||||||
*********************/
|
+===================*/
|
||||||
|
|
||||||
template <class CXpr>
|
template <class CXpr>
|
||||||
constexpr Contraction<CXpr>::Contraction(CXpr&& cxpr) :
|
constexpr Contraction<CXpr>::Contraction(CXpr&& cxpr) :
|
||||||
|
@ -447,9 +490,9 @@ namespace CNORXZ
|
||||||
return Contraction<CXprT>( i->ifor( op, f ) );
|
return Contraction<CXprT>( i->ifor( op, f ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************
|
/*======================+
|
||||||
* various functions *
|
| various functions |
|
||||||
************************/
|
+======================*/
|
||||||
|
|
||||||
template <class IndexT>
|
template <class IndexT>
|
||||||
constexpr decltype(auto) indexOp(const Sptr<IndexT>& i)
|
constexpr decltype(auto) indexOp(const Sptr<IndexT>& i)
|
||||||
|
|
|
@ -97,6 +97,36 @@ namespace CNORXZ
|
||||||
template <typename T, class IndexT>
|
template <typename T, class IndexT>
|
||||||
constexpr decltype(auto) coproot(const T* a, const Sptr<IndexT>& ind);
|
constexpr decltype(auto) coproot(const T* a, const Sptr<IndexT>& ind);
|
||||||
|
|
||||||
|
template <class IndexT, class Op>
|
||||||
|
class POpRoot : public COpInterface<POpRoot<IndexT,Op>>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef COpInterface<POpRoot<IndexT,Op>> OI;
|
||||||
|
|
||||||
|
constexpr POpRoot() = default;
|
||||||
|
|
||||||
|
constexpr POpRoot(const Sptr<IndexT>& ind, const SizeT* parts, Op&& op);
|
||||||
|
|
||||||
|
template <class PosT>
|
||||||
|
constexpr decltype(auto) operator()(const PosT& pos) const;
|
||||||
|
|
||||||
|
constexpr decltype(auto) operator()() const;
|
||||||
|
|
||||||
|
template <SizeT I>
|
||||||
|
constexpr decltype(auto) rootSteps(const IndexId<I>& id) const;
|
||||||
|
|
||||||
|
constexpr decltype(auto) data() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
Sptr<IndexT> mIndex;
|
||||||
|
FPos mFp;
|
||||||
|
Op mOp;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class IndexT, class Op>
|
||||||
|
constexpr decltype(auto) poproot(const Sptr<IndexT>& ind, const SizeT* parts, Op&& op);
|
||||||
|
|
||||||
template <typename T, class IndexT>
|
template <typename T, class IndexT>
|
||||||
class OpCont : public OpInterface<OpCont<T,IndexT>>
|
class OpCont : public OpInterface<OpCont<T,IndexT>>
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@file include/ranges/prange.cc.h
|
@file include/ranges/prange.cc.h
|
||||||
@brief ...
|
@brief PRange, PRangeFactory and PIndex implementations.
|
||||||
|
|
||||||
|
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
|
||||||
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
|
|
||||||
Mail: chizeta@f3l.de
|
Mail: chizeta@f3l.de
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -18,9 +17,9 @@
|
||||||
|
|
||||||
namespace CNORXZ
|
namespace CNORXZ
|
||||||
{
|
{
|
||||||
/**************
|
/*============+
|
||||||
* PIndex *
|
| PIndex |
|
||||||
**************/
|
+============*/
|
||||||
|
|
||||||
template <class IndexT>
|
template <class IndexT>
|
||||||
PIndex<IndexT>::PIndex(const RangePtr& range, SizeT pos) :
|
PIndex<IndexT>::PIndex(const RangePtr& range, SizeT pos) :
|
||||||
|
@ -206,9 +205,7 @@ namespace CNORXZ
|
||||||
template <class IndexT>
|
template <class IndexT>
|
||||||
decltype(auto) PIndex<IndexT>::xpr(const Sptr<PIndex<IndexT>>& _this) const
|
decltype(auto) PIndex<IndexT>::xpr(const Sptr<PIndex<IndexT>>& _this) const
|
||||||
{
|
{
|
||||||
CXZ_ERROR("implement!!!");
|
return poproot( _this, mRangePtr->parts(), mOrig->xpr(mOrig) );
|
||||||
//return poperation( _this, mOrig, mRangePtr->parts(), mOrig->xpr(mOrig) );
|
|
||||||
return mOrig->xpr(mOrig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexT>
|
template <class IndexT>
|
||||||
|
@ -246,9 +243,9 @@ namespace CNORXZ
|
||||||
return mOrig;
|
return mOrig;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************
|
/*======================+
|
||||||
* PIndex (private) *
|
| PIndex (private) |
|
||||||
************************/
|
+======================*/
|
||||||
|
|
||||||
template <class IndexT>
|
template <class IndexT>
|
||||||
void PIndex<IndexT>::mkPos()
|
void PIndex<IndexT>::mkPos()
|
||||||
|
@ -264,9 +261,9 @@ namespace CNORXZ
|
||||||
CXZ_ERROR("meta position '" << toString(mOrig->meta()) << "' not part of range");
|
CXZ_ERROR("meta position '" << toString(mOrig->meta()) << "' not part of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************
|
/*=========================+
|
||||||
* PIndex (non-member) *
|
| PIndex (non-member) |
|
||||||
***************************/
|
+=========================*/
|
||||||
|
|
||||||
template <class I, class I1>
|
template <class I, class I1>
|
||||||
decltype(auto) operator*(const Sptr<PIndex<I>>& a, const Sptr<I1>& b)
|
decltype(auto) operator*(const Sptr<PIndex<I>>& a, const Sptr<I1>& b)
|
||||||
|
@ -274,9 +271,9 @@ namespace CNORXZ
|
||||||
return iptrMul(a, b);
|
return iptrMul(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************
|
/*===================+
|
||||||
* PRangeFactory *
|
| PRangeFactory |
|
||||||
*********************/
|
+===================*/
|
||||||
|
|
||||||
template <class RangeT>
|
template <class RangeT>
|
||||||
PRangeFactory<RangeT>::PRangeFactory(const Sptr<RangeT>& range, const Vector<SizeT>& _parts) :
|
PRangeFactory<RangeT>::PRangeFactory(const Sptr<RangeT>& range, const Vector<SizeT>& _parts) :
|
||||||
|
@ -301,9 +298,9 @@ namespace CNORXZ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************
|
/*============+
|
||||||
* PRange *
|
| PRange |
|
||||||
**************/
|
+============*/
|
||||||
|
|
||||||
template <class RangeT>
|
template <class RangeT>
|
||||||
SizeT PRange<RangeT>::size() const
|
SizeT PRange<RangeT>::size() const
|
||||||
|
@ -378,9 +375,9 @@ namespace CNORXZ
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************
|
/*======================+
|
||||||
* PRange (private) *
|
| PRange (private) |
|
||||||
************************/
|
+======================*/
|
||||||
|
|
||||||
template <class RangeT>
|
template <class RangeT>
|
||||||
PRange<RangeT>::PRange(const Sptr<RangeT>& range, const Vector<SizeT>& _parts) :
|
PRange<RangeT>::PRange(const Sptr<RangeT>& range, const Vector<SizeT>& _parts) :
|
||||||
|
@ -396,9 +393,9 @@ namespace CNORXZ
|
||||||
return Vector<Uuid> { mRange->id() };
|
return Vector<Uuid> { mRange->id() };
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************
|
/*==========================+
|
||||||
* non-member functions *
|
| non-member functions |
|
||||||
****************************/
|
+==========================*/
|
||||||
|
|
||||||
template <class RangeT>
|
template <class RangeT>
|
||||||
RangePtr prange(const Sptr<RangeT>& range, const Vector<SizeT>& parts)
|
RangePtr prange(const Sptr<RangeT>& range, const Vector<SizeT>& parts)
|
||||||
|
|
Loading…
Reference in a new issue