dev #2
7 changed files with 303 additions and 63 deletions
|
@ -5,7 +5,7 @@
|
||||||
@brief ...
|
@brief ...
|
||||||
|
|
||||||
|
|
||||||
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
|
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
|
||||||
Mail: chizeta@f3l.de
|
Mail: chizeta@f3l.de
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -20,7 +20,17 @@
|
||||||
|
|
||||||
namespace CNORXZ
|
namespace CNORXZ
|
||||||
{
|
{
|
||||||
|
/** *****
|
||||||
|
Extension Index
|
||||||
|
|
||||||
|
Elements accessed through this index in a loop
|
||||||
|
are treated and processed through a single access
|
||||||
|
allowing the usage of vector extensions
|
||||||
|
|
||||||
|
@tparam MetaT Index meta data type
|
||||||
|
@tparam S Vector size
|
||||||
|
@tparam L Static index label
|
||||||
|
*/
|
||||||
template <typename MetaT, SizeT S, SizeT L>
|
template <typename MetaT, SizeT S, SizeT L>
|
||||||
class EIndex : public LIndex<SIndex<MetaT,S>,L>
|
class EIndex : public LIndex<SIndex<MetaT,S>,L>
|
||||||
{
|
{
|
||||||
|
@ -28,9 +38,15 @@ namespace CNORXZ
|
||||||
typedef typename LIndex<SIndex<MetaT,S>,L>::IB IB;
|
typedef typename LIndex<SIndex<MetaT,S>,L>::IB IB;
|
||||||
typedef typename LIndex<SIndex<MetaT,S>,L>::RangeType RangeType;
|
typedef typename LIndex<SIndex<MetaT,S>,L>::RangeType RangeType;
|
||||||
|
|
||||||
DEFAULT_MEMBERS(EIndex);
|
DEFAULT_MEMBERS(EIndex); /**< default constructors and assignments */
|
||||||
EIndex(const Sptr<LIndex<SIndex<MetaT,S>,L>>& i);
|
EIndex(const Sptr<LIndex<SIndex<MetaT,S>,L>>& i);
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::ifor()
|
||||||
|
|
||||||
|
Specialization for EIndex: access all elements
|
||||||
|
at once, allowing usage of vector extensions
|
||||||
|
@see EFor
|
||||||
|
*/
|
||||||
template <class Xpr, class F>
|
template <class Xpr, class F>
|
||||||
decltype(auto) ifor(const Xpr& xpr, F&& f) const;
|
decltype(auto) ifor(const Xpr& xpr, F&& f) const;
|
||||||
|
|
||||||
|
@ -38,6 +54,10 @@ namespace CNORXZ
|
||||||
Sptr<LIndex<SIndex<MetaT,S>,L>> mLI;
|
Sptr<LIndex<SIndex<MetaT,S>,L>> mLI;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** ***
|
||||||
|
EIndex is an index
|
||||||
|
@see is_index
|
||||||
|
*/
|
||||||
template <typename MetaT, SizeT S, SizeT L>
|
template <typename MetaT, SizeT S, SizeT L>
|
||||||
struct is_index<EIndex<MetaT,S,L>>
|
struct is_index<EIndex<MetaT,S,L>>
|
||||||
{
|
{
|
||||||
|
@ -54,24 +74,51 @@ namespace CNORXZ
|
||||||
static constexpr bool value = true;
|
static constexpr bool value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Make index pack from EIndex and second index of arbitrary type
|
||||||
|
*/
|
||||||
template <typename MetaT, SizeT S, SizeT L, class I1>
|
template <typename MetaT, SizeT S, SizeT L, class I1>
|
||||||
decltype(auto) operator*(const Sptr<EIndex<MetaT,S,L>>& a, const Sptr<I1>& b);
|
decltype(auto) operator*(const Sptr<EIndex<MetaT,S,L>>& a, const Sptr<I1>& b);
|
||||||
|
|
||||||
|
/** Create Eindex pointer from LIndex pointer
|
||||||
|
*/
|
||||||
template <typename MetaT, SizeT S, SizeT L>
|
template <typename MetaT, SizeT S, SizeT L>
|
||||||
decltype(auto) eindexPtr(const Sptr<LIndex<SIndex<MetaT,S>,L>>& i);
|
decltype(auto) eindexPtr(const Sptr<LIndex<SIndex<MetaT,S>,L>>& i);
|
||||||
|
|
||||||
|
/** Create Eindex pointer from SIndex pointer
|
||||||
|
@tparam L Static index label
|
||||||
|
*/
|
||||||
template <SizeT L, typename MetaT, SizeT S>
|
template <SizeT L, typename MetaT, SizeT S>
|
||||||
decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>>& i);
|
decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>>& i);
|
||||||
|
|
||||||
|
/** Create Eindex pointer from LIndex pointer
|
||||||
|
@param l Static index label
|
||||||
|
*/
|
||||||
template <typename MetaT, SizeT S, SizeT L>
|
template <typename MetaT, SizeT S, SizeT L>
|
||||||
decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>>& i, CSizeT<L> l);
|
decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>>& i, CSizeT<L> l);
|
||||||
|
|
||||||
|
/** Split given index into pack of EIndex and remainder index
|
||||||
|
@param i Index to be split
|
||||||
|
@tparam S Vector size
|
||||||
|
@tparam L1 label of EIndex
|
||||||
|
@tparam L2 label of remainder index
|
||||||
|
*/
|
||||||
template <SizeT S, SizeT L1, SizeT L2, class Index>
|
template <SizeT S, SizeT L1, SizeT L2, class Index>
|
||||||
decltype(auto) eplex(const Sptr<Index>& i);
|
decltype(auto) eplex(const Sptr<Index>& i);
|
||||||
|
|
||||||
|
/** Split given index into pack of EIndex and remainder index
|
||||||
|
@param i Index to be split
|
||||||
|
@param s Vector size
|
||||||
|
@param l label of EIndex
|
||||||
|
*/
|
||||||
template <class Index, SizeT S, SizeT L>
|
template <class Index, SizeT S, SizeT L>
|
||||||
decltype(auto) eplex(const Sptr<Index>& i, CSizeT<S> s, CSizeT<L> l);
|
decltype(auto) eplex(const Sptr<Index>& i, CSizeT<S> s, CSizeT<L> l);
|
||||||
|
|
||||||
|
/** Split given index into pack of EIndex and remainder index
|
||||||
|
@param i Index to be split
|
||||||
|
@param s Vector size
|
||||||
|
@param l1 label of EIndex
|
||||||
|
@param l2 label of remainder index
|
||||||
|
*/
|
||||||
template <class Index, SizeT S, SizeT L1, SizeT L2>
|
template <class Index, SizeT S, SizeT L1, SizeT L2>
|
||||||
decltype(auto) eplex(const Sptr<Index>& i, CSizeT<S> s, CSizeT<L1> l1, CSizeT<L2> l2);
|
decltype(auto) eplex(const Sptr<Index>& i, CSizeT<S> s, CSizeT<L1> l1, CSizeT<L2> l2);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
@brief ...
|
@brief ...
|
||||||
|
|
||||||
|
|
||||||
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
|
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
|
||||||
Mail: chizeta@f3l.de
|
Mail: chizeta@f3l.de
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -18,26 +18,51 @@
|
||||||
|
|
||||||
namespace CNORXZ
|
namespace CNORXZ
|
||||||
{
|
{
|
||||||
|
/** ****
|
||||||
|
Type trait: Check if format has static size.
|
||||||
|
*/
|
||||||
template <class FormatT> struct is_static_format { CXZ_CVAL_FALSE; };
|
template <class FormatT> struct is_static_format { CXZ_CVAL_FALSE; };
|
||||||
|
|
||||||
|
/** ****
|
||||||
|
Multi index format of static size.
|
||||||
|
Wrapper of standard array of UPos.
|
||||||
|
@tparam N Format size
|
||||||
|
*/
|
||||||
template <SizeT N>
|
template <SizeT N>
|
||||||
class MFormat
|
class MFormat
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Arr<UPos,N> InputType;
|
typedef Arr<UPos,N> InputType;
|
||||||
|
|
||||||
SP_DEFAULT_MEMBERS(constexpr,MFormat);
|
SP_DEFAULT_MEMBERS(constexpr,MFormat); /**< default constructors and assignments */
|
||||||
|
|
||||||
|
/** Construct MFormat from standard array.
|
||||||
|
@param b Input array
|
||||||
|
*/
|
||||||
explicit constexpr MFormat(const Arr<UPos,N>& b);
|
explicit constexpr MFormat(const Arr<UPos,N>& b);
|
||||||
|
|
||||||
|
/** Construct MFormat from format of arbitrary type.
|
||||||
|
The input format size has to match the static size N.
|
||||||
|
@param f Input format
|
||||||
|
*/
|
||||||
template <class FormatT>
|
template <class FormatT>
|
||||||
constexpr MFormat(const FormatT& f);
|
constexpr MFormat(const FormatT& f);
|
||||||
|
|
||||||
|
/** Get underlying array. */
|
||||||
const Arr<UPos,N>& all() const;
|
const Arr<UPos,N>& all() const;
|
||||||
|
|
||||||
|
/** Get format size. */
|
||||||
constexpr decltype(auto) size() const;
|
constexpr decltype(auto) size() const;
|
||||||
|
|
||||||
|
/** Get format element.
|
||||||
|
@param i CSizeT indicating static element position
|
||||||
|
*/
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
constexpr decltype(auto) get(CSizeT<I> i) const;
|
constexpr decltype(auto) get(CSizeT<I> i) const;
|
||||||
|
|
||||||
|
/** Get format element.
|
||||||
|
@param i CSizeT indicating static element position
|
||||||
|
*/
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
constexpr decltype(auto) operator[](CSizeT<I> i) const;
|
constexpr decltype(auto) operator[](CSizeT<I> i) const;
|
||||||
|
|
||||||
|
@ -46,27 +71,58 @@ namespace CNORXZ
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** ****
|
||||||
|
MFormat has static size.
|
||||||
|
@see is_static_format
|
||||||
|
*/
|
||||||
template <SizeT N> struct is_static_format<MFormat<N>> { CXZ_CVAL_TRUE; };
|
template <SizeT N> struct is_static_format<MFormat<N>> { CXZ_CVAL_TRUE; };
|
||||||
|
|
||||||
|
/** ****
|
||||||
|
Multi index format of static size.
|
||||||
|
Wrapper of standard tuple of position types.
|
||||||
|
@tparam PosT Position types.
|
||||||
|
*/
|
||||||
template <class... PosT>
|
template <class... PosT>
|
||||||
class GMFormat
|
class GMFormat
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Tuple<PosT...> InputType;
|
typedef Tuple<PosT...> InputType;
|
||||||
|
|
||||||
SP_DEFAULT_MEMBERS(constexpr,GMFormat);
|
SP_DEFAULT_MEMBERS(constexpr,GMFormat); /**< default constructors and assignments */
|
||||||
|
|
||||||
|
/** Construct from tuple.
|
||||||
|
@param b Input tuple.
|
||||||
|
*/
|
||||||
explicit constexpr GMFormat(const Tuple<PosT...>& b);
|
explicit constexpr GMFormat(const Tuple<PosT...>& b);
|
||||||
|
|
||||||
|
/** Construct from tuple (move).
|
||||||
|
@param b Input tuple.
|
||||||
|
*/
|
||||||
explicit constexpr GMFormat(Tuple<PosT...>&& b);
|
explicit constexpr GMFormat(Tuple<PosT...>&& b);
|
||||||
|
|
||||||
|
/** Construct MFormat from format of arbitrary type.
|
||||||
|
The input format size has to match the number of entries
|
||||||
|
and the input entries have to be compatible with the position types.
|
||||||
|
@param f Input format
|
||||||
|
*/
|
||||||
template <class FormatT>
|
template <class FormatT>
|
||||||
constexpr GMFormat(const FormatT& f);
|
constexpr GMFormat(const FormatT& f);
|
||||||
|
|
||||||
|
/** Get underlying tuple. */
|
||||||
const Tuple<PosT...>& all() const;
|
const Tuple<PosT...>& all() const;
|
||||||
|
|
||||||
|
/** Get format size. */
|
||||||
constexpr decltype(auto) size() const;
|
constexpr decltype(auto) size() const;
|
||||||
|
|
||||||
|
/** Get format element.
|
||||||
|
@param i CSizeT indicating static element position
|
||||||
|
*/
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
constexpr decltype(auto) get(CSizeT<I> i) const;
|
constexpr decltype(auto) get(CSizeT<I> i) const;
|
||||||
|
|
||||||
|
/** Get format element.
|
||||||
|
@param i CSizeT indicating static element position
|
||||||
|
*/
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
constexpr decltype(auto) operator[](CSizeT<I> i) const;
|
constexpr decltype(auto) operator[](CSizeT<I> i) const;
|
||||||
|
|
||||||
|
@ -74,38 +130,76 @@ namespace CNORXZ
|
||||||
Tuple<PosT...> mB;
|
Tuple<PosT...> mB;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Create GMFormat from position types.
|
||||||
|
@param ps Position types.
|
||||||
|
*/
|
||||||
template <class... PosT>
|
template <class... PosT>
|
||||||
constexpr decltype(auto) gmformat(const PosT&... ps);
|
constexpr decltype(auto) gmformat(const PosT&... ps);
|
||||||
|
|
||||||
|
/** ****
|
||||||
|
GMFormat has static size.
|
||||||
|
@see is_static_format
|
||||||
|
*/
|
||||||
template <class... PosT> struct is_static_format<GMFormat<PosT...>> { CXZ_CVAL_TRUE; };
|
template <class... PosT> struct is_static_format<GMFormat<PosT...>> { CXZ_CVAL_TRUE; };
|
||||||
|
|
||||||
|
/** ****
|
||||||
|
Multi index format of variable size
|
||||||
|
Wrapper of standard vector of UPos.
|
||||||
|
*/
|
||||||
class YFormat
|
class YFormat
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Vector<UPos> InputType;
|
typedef Vector<UPos> InputType;
|
||||||
|
|
||||||
DEFAULT_MEMBERS(YFormat);
|
DEFAULT_MEMBERS(YFormat); /**< default constructors and assignments */
|
||||||
|
|
||||||
|
/** Construct from vector.
|
||||||
|
@param b Input vector.
|
||||||
|
*/
|
||||||
explicit YFormat(const Vector<UPos>& b);
|
explicit YFormat(const Vector<UPos>& b);
|
||||||
|
|
||||||
|
/** Construct from format of arbitrary type.
|
||||||
|
@param f Input format.
|
||||||
|
*/
|
||||||
template <class FormatT>
|
template <class FormatT>
|
||||||
YFormat(const FormatT& f);
|
YFormat(const FormatT& f);
|
||||||
|
|
||||||
|
/** Get underlying vector. */
|
||||||
const Vector<UPos>& all() const;
|
const Vector<UPos>& all() const;
|
||||||
|
|
||||||
|
/** Get format size. */
|
||||||
SizeT size() const;
|
SizeT size() const;
|
||||||
|
|
||||||
|
/** Get format element.
|
||||||
|
@param i CSizeT indicating static element position
|
||||||
|
*/
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
const UPos& get(CSizeT<I> i) const;
|
const UPos& get(CSizeT<I> i) const;
|
||||||
|
|
||||||
|
/** Get format element.
|
||||||
|
@param i CSizeT indicating static element position
|
||||||
|
*/
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
const UPos& operator[](CSizeT<I> i) const;
|
const UPos& operator[](CSizeT<I> i) const;
|
||||||
|
|
||||||
|
/** Get format element.
|
||||||
|
@param i E element position
|
||||||
|
*/
|
||||||
const UPos& get(SizeT i) const;
|
const UPos& get(SizeT i) const;
|
||||||
|
|
||||||
|
/** Get format element.
|
||||||
|
@param i E element position
|
||||||
|
*/
|
||||||
const UPos& operator[](SizeT i) const;
|
const UPos& operator[](SizeT i) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<UPos> mB;
|
Vector<UPos> mB;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Check if format is trivial, i.e. f[i-1] = f[i]*s[i].
|
||||||
|
@param f Vector representing the index format.
|
||||||
|
@param s Vector representing the sub-index maxima.
|
||||||
|
*/
|
||||||
bool formatIsTrivial(const Vector<SizeT>& f, const Vector<SizeT>& s);
|
bool formatIsTrivial(const Vector<SizeT>& f, const Vector<SizeT>& s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@file include/ranges/index_mul.h
|
@file include/ranges/index_mul.h
|
||||||
@brief ...
|
@brief Index multiplication
|
||||||
|
|
||||||
|
Indices can be multiplied yielding index packs.
|
||||||
|
|
||||||
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
|
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
|
||||||
Mail: chizeta@f3l.de
|
Mail: chizeta@f3l.de
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -35,30 +36,71 @@ namespace CNORXZ
|
||||||
Isq<Is...> is, Isq<Js...> js);
|
Isq<Is...> is, Isq<Js...> js);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Combine two indices to a static index 2-pack.
|
||||||
|
@param a First index.
|
||||||
|
@param b Second index.
|
||||||
|
@return Static index 2-pack
|
||||||
|
*/
|
||||||
template <class I1, typename Meta1, class I2, typename Meta2>
|
template <class I1, typename Meta1, class I2, typename Meta2>
|
||||||
inline decltype(auto) operator*(const IndexInterface<I1,Meta1>& a,
|
inline decltype(auto) operator*(const IndexInterface<I1,Meta1>& a,
|
||||||
const IndexInterface<I2,Meta2>& b);
|
const IndexInterface<I2,Meta2>& b);
|
||||||
|
|
||||||
|
/** Extend static index pack on the l.h.s.
|
||||||
|
@param a Index to be appended.
|
||||||
|
@param b Index pack to be extended.
|
||||||
|
@return Extended pack.
|
||||||
|
*/
|
||||||
template <class I1, typename Meta1, class... Indices>
|
template <class I1, typename Meta1, class... Indices>
|
||||||
inline decltype(auto) operator*(const IndexInterface<I1,Meta1>& a,
|
inline decltype(auto) operator*(const IndexInterface<I1,Meta1>& a,
|
||||||
const SPack<Indices...>& b);
|
const SPack<Indices...>& b);
|
||||||
|
|
||||||
|
/** Extend static index pack on the r.h.s.
|
||||||
|
@param a Index pack to be extended.
|
||||||
|
@param b Index to be appended.
|
||||||
|
@return Extended pack.
|
||||||
|
*/
|
||||||
template <class I2, typename Meta2, class... Indices>
|
template <class I2, typename Meta2, class... Indices>
|
||||||
inline decltype(auto) operator*(const SPack<Indices...>& a,
|
inline decltype(auto) operator*(const SPack<Indices...>& a,
|
||||||
const IndexInterface<I2,Meta2>& b);
|
const IndexInterface<I2,Meta2>& b);
|
||||||
|
|
||||||
|
/** Combine two static index packs
|
||||||
|
@param a First Index pack.
|
||||||
|
@param b Second Index pack.
|
||||||
|
@return New index pack. a is appended on the l.h.s. of b.
|
||||||
|
*/
|
||||||
template <class... Indices1, class... Indices2>
|
template <class... Indices1, class... Indices2>
|
||||||
inline decltype(auto) operator*(const SPack<Indices1...>& a, const SPack<Indices2...>& b);
|
inline decltype(auto) operator*(const SPack<Indices1...>& a, const SPack<Indices2...>& b);
|
||||||
|
|
||||||
|
/** Extend dynamic index pack on the l.h.s.
|
||||||
|
@param a Index to be appended.
|
||||||
|
@param b Index pack to be extended.
|
||||||
|
@return Extended pack.
|
||||||
|
*/
|
||||||
template <class I1, typename Meta1>
|
template <class I1, typename Meta1>
|
||||||
inline decltype(auto) operator*(const IndexInterface<I1,Meta1>& a, const DPack& b);
|
inline decltype(auto) operator*(const IndexInterface<I1,Meta1>& a, const DPack& b);
|
||||||
|
|
||||||
|
/** Extend dynamic index pack on the r.h.s.
|
||||||
|
@param a Index pack to be extended.
|
||||||
|
@param b Index to be appended.
|
||||||
|
@return Extended pack.
|
||||||
|
*/
|
||||||
template <class I2, typename Meta2>
|
template <class I2, typename Meta2>
|
||||||
inline decltype(auto) operator*(const DPack& a, const IndexInterface<I2,Meta2>& b);
|
inline decltype(auto) operator*(const DPack& a, const IndexInterface<I2,Meta2>& b);
|
||||||
|
|
||||||
|
/** Combine two dynamic index packs
|
||||||
|
@param a First Index pack.
|
||||||
|
@param b Second Index pack.
|
||||||
|
@return New index pack. a is appended on the l.h.s. of b.
|
||||||
|
*/
|
||||||
inline decltype(auto) operator*(const DPack& a, const DPack& b);
|
inline decltype(auto) operator*(const DPack& a, const DPack& b);
|
||||||
|
|
||||||
|
/** Combine two index pointers to an index 2-pack.
|
||||||
|
YIndices and DIndices will be combined into a DPack,
|
||||||
|
otherwise a SPack is returned.
|
||||||
|
@param a First index.
|
||||||
|
@param b Second index.
|
||||||
|
@return Index 2-pack.
|
||||||
|
*/
|
||||||
template <class I1, class I2>
|
template <class I1, class I2>
|
||||||
decltype(auto) iptrMul(const Sptr<I1>& a, const Sptr<I2>& b);
|
decltype(auto) iptrMul(const Sptr<I1>& a, const Sptr<I2>& b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
@file include/ranges/index_traits.h
|
@file include/ranges/index_traits.h
|
||||||
@brief index traits
|
@brief index traits
|
||||||
|
|
||||||
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
|
Copyright (c) 2023 Christian Zimmermann. All rights reserved.
|
||||||
Mail: chizeta@f3l.de
|
Mail: chizeta@f3l.de
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
// -*- C++ -*-
|
|
||||||
/**
|
|
||||||
|
|
||||||
@file include/ranges/index_utils.h
|
|
||||||
@brief ...
|
|
||||||
|
|
||||||
|
|
||||||
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
|
|
||||||
Mail: chizeta@f3l.de
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef __cxz_index_utils_h__
|
|
||||||
#define __cxz_index_utils_h__
|
|
||||||
|
|
||||||
#include "base/base.h"
|
|
||||||
#include "index_base.h"
|
|
||||||
|
|
||||||
namespace CNORXZ
|
|
||||||
{
|
|
||||||
// automatically set static format if SIndices are used!
|
|
||||||
template <class... Indices>
|
|
||||||
constexpr decltype(auto) autoiPtr(const SPack<Indices...>& pack);
|
|
||||||
|
|
||||||
inline SPtr<YIndex> autoiPtr(const DPack& pack);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -2,10 +2,12 @@
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@file include/ranges/lindex.h
|
@file include/ranges/lindex.h
|
||||||
@brief ...
|
@brief Statically labeled index.
|
||||||
|
|
||||||
|
Static index labels are usefull to resolve extensions and relations to
|
||||||
|
other indices at compile time.
|
||||||
|
|
||||||
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
|
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
|
||||||
Mail: chizeta@f3l.de
|
Mail: chizeta@f3l.de
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -20,7 +22,11 @@
|
||||||
|
|
||||||
namespace CNORXZ
|
namespace CNORXZ
|
||||||
{
|
{
|
||||||
// static label to enforce loop unrolling
|
/** ****
|
||||||
|
Statically labeled index.
|
||||||
|
@tparam Index Underlying index.
|
||||||
|
@tparam L Static label.
|
||||||
|
*/
|
||||||
template <class Index, SizeT L>
|
template <class Index, SizeT L>
|
||||||
class LIndex : public Index
|
class LIndex : public Index
|
||||||
{
|
{
|
||||||
|
@ -28,14 +34,25 @@ namespace CNORXZ
|
||||||
typedef typename Index::IB IB;
|
typedef typename Index::IB IB;
|
||||||
typedef typename Index::RangeType RangeType;
|
typedef typename Index::RangeType RangeType;
|
||||||
|
|
||||||
DEFAULT_MEMBERS(LIndex);
|
DEFAULT_MEMBERS(LIndex); /**< Default constructors and assignments. */
|
||||||
|
|
||||||
|
/** Construct from index pointer.
|
||||||
|
@param i Input index.
|
||||||
|
*/
|
||||||
LIndex(const Sptr<Index>& i);
|
LIndex(const Sptr<Index>& i);
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::id()
|
||||||
|
Specialization: Static id equals L.
|
||||||
|
*/
|
||||||
IndexId<L> id() const;
|
IndexId<L> id() const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::stepSize()
|
||||||
|
Specialization: stepSize may be static.
|
||||||
|
*/
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
decltype(auto) stepSize(const IndexId<I>& id) const;
|
decltype(auto) stepSize(const IndexId<I>& id) const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::stepSize() */
|
||||||
template <class Xpr, class F>
|
template <class Xpr, class F>
|
||||||
decltype(auto) ifor(const Xpr& xpr, F&& f) const;
|
decltype(auto) ifor(const Xpr& xpr, F&& f) const;
|
||||||
|
|
||||||
|
@ -43,6 +60,10 @@ namespace CNORXZ
|
||||||
Sptr<Index> mI;
|
Sptr<Index> mI;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** ***
|
||||||
|
LIndex is an index
|
||||||
|
@see is_index
|
||||||
|
*/
|
||||||
template <class Index, SizeT L>
|
template <class Index, SizeT L>
|
||||||
struct is_index<LIndex<Index,L>>
|
struct is_index<LIndex<Index,L>>
|
||||||
{
|
{
|
||||||
|
@ -59,12 +80,27 @@ namespace CNORXZ
|
||||||
static constexpr bool value = index_expression_exists<Index>::value;
|
static constexpr bool value = index_expression_exists<Index>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Specialize index multiplication for LIndex.
|
||||||
|
@param a Pointer to first index which is a LIndex.
|
||||||
|
@param b Pointer to second index of arbitrary type.
|
||||||
|
@return Resulting index pack.
|
||||||
|
*/
|
||||||
template <class Index, SizeT L, class I1>
|
template <class Index, SizeT L, class I1>
|
||||||
decltype(auto) operator*(const Sptr<LIndex<Index,L>>& a, const Sptr<I1>& b);
|
decltype(auto) operator*(const Sptr<LIndex<Index,L>>& a, const Sptr<I1>& b);
|
||||||
|
|
||||||
|
/** Create LIndex from index pointer.
|
||||||
|
@param i Input index.
|
||||||
|
@tparam L Static label.
|
||||||
|
@return Resulting LIndex.
|
||||||
|
*/
|
||||||
template <SizeT L, class Index>
|
template <SizeT L, class Index>
|
||||||
decltype(auto) lindexPtr(const Sptr<Index>& i);
|
decltype(auto) lindexPtr(const Sptr<Index>& i);
|
||||||
|
|
||||||
|
/** Create LIndex from index pointer.
|
||||||
|
@param i Input index.
|
||||||
|
@param l CSizeT indicating the static label.
|
||||||
|
@return Resulting LIndex.
|
||||||
|
*/
|
||||||
template <class Index, SizeT L>
|
template <class Index, SizeT L>
|
||||||
decltype(auto) lindexPtr(const Sptr<Index>& i, CSizeT<L> l);
|
decltype(auto) lindexPtr(const Sptr<Index>& i, CSizeT<L> l);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,15 @@
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@file include/ranges/mrange.h
|
@file include/ranges/mrange.h
|
||||||
@brief ...
|
@brief MRange, GMIndex and MIndex declaration
|
||||||
|
|
||||||
|
MRange is a multi-range consisting of of a compile-time fixed number of sub-ranges.
|
||||||
|
|
||||||
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
|
GMIndex and MIndex are multi-index consisting of a compile-time fixed number of sub-indices.
|
||||||
|
The difference between the two index types is that MIndex has a statically trivial format,
|
||||||
|
while GMIndex can have an arbitrary format (MFormat or GMFormat).
|
||||||
|
|
||||||
|
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
|
||||||
Mail: chizeta@f3l.de
|
Mail: chizeta@f3l.de
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -22,8 +27,13 @@
|
||||||
|
|
||||||
namespace CNORXZ
|
namespace CNORXZ
|
||||||
{
|
{
|
||||||
// template <class FormatT, class... Indices>
|
|
||||||
// -> Format + IndexTuple
|
/** ****
|
||||||
|
Multi-index with fixed number of sub-indices of arbitrary type
|
||||||
|
and arbitrary index format.
|
||||||
|
@tparam FormatT Index format type.
|
||||||
|
@tparam Indices Sub-index types.
|
||||||
|
*/
|
||||||
template <class FormatT, class... Indices>
|
template <class FormatT, class... Indices>
|
||||||
class GMIndex : public IndexInterface<GMIndex<FormatT,Indices...>,
|
class GMIndex : public IndexInterface<GMIndex<FormatT,Indices...>,
|
||||||
Tuple<typename Indices::MetaType...> >
|
Tuple<typename Indices::MetaType...> >
|
||||||
|
@ -32,7 +42,6 @@ namespace CNORXZ
|
||||||
|
|
||||||
typedef IndexInterface<GMIndex<FormatT,Indices...>,
|
typedef IndexInterface<GMIndex<FormatT,Indices...>,
|
||||||
Tuple<typename Indices::MetaType...>> IB;
|
Tuple<typename Indices::MetaType...>> IB;
|
||||||
//typedef Tuple<Sptr<Indices>...> IndexPack;
|
|
||||||
typedef Tuple<typename Indices::MetaType...> MetaType;
|
typedef Tuple<typename Indices::MetaType...> MetaType;
|
||||||
typedef MRange<typename Indices::RangeType...> RangeType;
|
typedef MRange<typename Indices::RangeType...> RangeType;
|
||||||
static constexpr SizeT NI = sizeof...(Indices);
|
static constexpr SizeT NI = sizeof...(Indices);
|
||||||
|
@ -52,36 +61,86 @@ namespace CNORXZ
|
||||||
constexpr GMIndex(const RangePtr& range, SizeT lexpos = 0);
|
constexpr GMIndex(const RangePtr& range, SizeT lexpos = 0);
|
||||||
constexpr GMIndex(const RangePtr& range, const FormatT& format, SizeT lexpos = 0);
|
constexpr GMIndex(const RangePtr& range, const FormatT& format, SizeT lexpos = 0);
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::operator=(SizeT) */
|
||||||
GMIndex& operator=(SizeT pos);
|
GMIndex& operator=(SizeT pos);
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::operator++() */
|
||||||
GMIndex& operator++();
|
GMIndex& operator++();
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::operator--() */
|
||||||
GMIndex& operator--();
|
GMIndex& operator--();
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::operator+() */
|
||||||
GMIndex operator+(Int n) const;
|
GMIndex operator+(Int n) const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::operator-() */
|
||||||
GMIndex operator-(Int n) const;
|
GMIndex operator-(Int n) const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::operator-(CIndex) */
|
||||||
SizeT operator-(const GMIndex& i) const;
|
SizeT operator-(const GMIndex& i) const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::operator+=() */
|
||||||
GMIndex& operator+=(Int n);
|
GMIndex& operator+=(Int n);
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::operator-=() */
|
||||||
GMIndex& operator-=(Int n);
|
GMIndex& operator-=(Int n);
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::lex() */
|
||||||
SizeT lex() const;
|
SizeT lex() const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::pmax() */
|
||||||
constexpr decltype(auto) pmax() const;
|
constexpr decltype(auto) pmax() const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::lmax() */
|
||||||
constexpr decltype(auto) lmax() const;
|
constexpr decltype(auto) lmax() const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::id() */
|
||||||
IndexId<0> id() const;
|
IndexId<0> id() const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::operator*() */
|
||||||
MetaType operator*() const;
|
MetaType operator*() const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::dim() */
|
||||||
constexpr SizeT dim() const;
|
constexpr SizeT dim() const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::range() */
|
||||||
Sptr<RangeType> range() const;
|
Sptr<RangeType> range() const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::stepSize() */
|
||||||
template <SizeT I>
|
template <SizeT I>
|
||||||
decltype(auto) stepSize(const IndexId<I>& id) const;
|
decltype(auto) stepSize(const IndexId<I>& id) const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::stringMeta() */
|
||||||
String stringMeta() const;
|
String stringMeta() const;
|
||||||
MetaType meta() const;
|
|
||||||
GMIndex& at(const MetaType& metaPos);
|
|
||||||
decltype(auto) xpr(const Sptr<MIndex<Indices...>>& _this) const;
|
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::meta() */
|
||||||
|
MetaType meta() const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::at() */
|
||||||
|
GMIndex& at(const MetaType& metaPos);
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::prange() */
|
||||||
|
RangePtr prange(const GMIndex<FormatT,Indices...>& last) const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::deepFormat() */
|
||||||
|
auto deepFormat() const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::deepMax() */
|
||||||
|
auto deepMax() const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::reformat() */
|
||||||
|
GMIndex& reformat(const Vector<SizeT>& f, const Vector<SizeT>& s);
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::ifor() */
|
||||||
template <class Xpr, class F>
|
template <class Xpr, class F>
|
||||||
constexpr decltype(auto) ifor(const Xpr& xpr, F&& f) const;
|
constexpr decltype(auto) ifor(const Xpr& xpr, F&& f) const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::formatIsTrivial() */
|
||||||
|
bool formatIsTrivial() const;
|
||||||
|
|
||||||
|
/** @copydoc IndexInterface::xpr() */
|
||||||
|
decltype(auto) xpr(const Sptr<MIndex<Indices...>>& _this) const;
|
||||||
|
|
||||||
// replace sub-index instances; only use if you know what you are doing!
|
// replace sub-index instances; only use if you know what you are doing!
|
||||||
GMIndex& operator()(const Sptr<MIndex<Indices...>>& mi);
|
GMIndex& operator()(const Sptr<MIndex<Indices...>>& mi);
|
||||||
GMIndex& operator()();
|
GMIndex& operator()();
|
||||||
|
@ -89,18 +148,9 @@ namespace CNORXZ
|
||||||
const SPack<Indices...>& pack() const;
|
const SPack<Indices...>& pack() const;
|
||||||
const auto& format() const;
|
const auto& format() const;
|
||||||
const auto& lexFormat() const;
|
const auto& lexFormat() const;
|
||||||
RangePtr prange(const GMIndex<FormatT,Indices...>& last) const;
|
|
||||||
auto deepFormat() const;
|
|
||||||
auto deepMax() const;
|
|
||||||
|
|
||||||
/** @copydoc IndexInterface::reformat() */
|
|
||||||
GMIndex& reformat(const Vector<SizeT>& f, const Vector<SizeT>& s);
|
|
||||||
|
|
||||||
GMIndex& setFormat(const FormatT& bs);
|
GMIndex& setFormat(const FormatT& bs);
|
||||||
|
|
||||||
/** @copydoc IndexInterface::formatIsTrivial() */
|
|
||||||
bool formatIsTrivial() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <SizeT... Is>
|
template <SizeT... Is>
|
||||||
static constexpr decltype(auto) mkLexFormat(const SPack<Indices...>& ipack, Isq<Is...> is);
|
static constexpr decltype(auto) mkLexFormat(const SPack<Indices...>& ipack, Isq<Is...> is);
|
||||||
|
|
Loading…
Reference in a new issue