base+ranges: more docu
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
62f83de07b
commit
c055ef39da
24 changed files with 414 additions and 163 deletions
|
@ -1132,7 +1132,7 @@ FORTRAN_COMMENT_AFTER = 72
|
|||
# also VERBATIM_HEADERS is set to NO.
|
||||
# The default value is: NO.
|
||||
|
||||
SOURCE_BROWSER = NO
|
||||
SOURCE_BROWSER = YES
|
||||
|
||||
# Setting the INLINE_SOURCES tag to YES will include the body of functions,
|
||||
# classes and enums directly into the documentation.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/assert.h
|
||||
|
@ -13,13 +14,27 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
/** library error tag */
|
||||
#define CXZ_ERRTAG __FILE__ << '@' << __LINE__ << '(' << __func__ << "): error"
|
||||
|
||||
/** library warning tag */
|
||||
#define CXZ_WARNTAG __FILE__ << '@' << __LINE__ << ": warning"
|
||||
#define CXZ_ERROR(errmsg) {\
|
||||
|
||||
/** throw error
|
||||
@param errmsg error message
|
||||
*/
|
||||
#define CXZ_ERROR(errmsg) { \
|
||||
auto mkerr = [&](){ std::stringstream ss; ss << CXZ_ERRTAG << ": " << errmsg << std::flush; return ss.str(); }; \
|
||||
throw std::runtime_error(mkerr()); }
|
||||
|
||||
/** print warning
|
||||
@param errmsg warning message
|
||||
*/
|
||||
#define CXZ_WARNING(errmsg) {\
|
||||
std::cerr << CXZ_WARNTAG << ": " << errmsg << std::endl; }
|
||||
|
||||
/** throw error if given statement is not fulfilled
|
||||
@param statement statement to be checked
|
||||
@param errmsg error message
|
||||
*/
|
||||
#define CXZ_ASSERT(statement, errmsg) if(not (statement)) { CXZ_ERROR(errmsg); }
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/base.cc.h
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/base.h
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/config.h
|
||||
|
@ -20,10 +21,13 @@ namespace CNORXZ
|
|||
{
|
||||
namespace Config
|
||||
{
|
||||
/** return cnorxz version */
|
||||
String version();
|
||||
|
||||
/** return git hash */
|
||||
String commit();
|
||||
|
||||
/** return compile flags */
|
||||
String flags();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/dtype.cc.h
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/dtype.h
|
||||
|
@ -24,6 +25,9 @@
|
|||
|
||||
namespace CNORXZ
|
||||
{
|
||||
/** ****
|
||||
Type erasing class wrapping std::any
|
||||
*/
|
||||
class DType
|
||||
{
|
||||
private:
|
||||
|
@ -38,22 +42,60 @@ namespace CNORXZ
|
|||
void _mkComp();
|
||||
|
||||
public:
|
||||
DEFAULT_MEMBERS(DType);
|
||||
DEFAULT_MEMBERS(DType); /**< default constructors and assignments */
|
||||
|
||||
/** Generic constructor template
|
||||
|
||||
Constructs a DType from the given argument
|
||||
@tparam T input data type
|
||||
@param d input
|
||||
*/
|
||||
template <typename T>
|
||||
DType(const T& d);
|
||||
|
||||
/** Generic assignment template
|
||||
|
||||
Assigns the given argument to the DType
|
||||
@tparam T input data type
|
||||
@param d input
|
||||
*/
|
||||
template <typename T>
|
||||
DType& operator=(const T& d);
|
||||
|
||||
/** convert contained data so string */
|
||||
String str() const { return mToStr(mD); }
|
||||
|
||||
/** return reference to type-erased data */
|
||||
const std::any& get() const { return mD; }
|
||||
|
||||
/** check for equality
|
||||
@param a variable to compare with
|
||||
*/
|
||||
bool operator==(const DType& a) const { return mComp(mD,a.mD) == 0; }
|
||||
|
||||
/** check for inequality
|
||||
@param a variable to compare with
|
||||
*/
|
||||
bool operator!=(const DType& a) const { return mComp(mD,a.mD) != 0; }
|
||||
|
||||
/** check smaller
|
||||
@param a variable to compare with
|
||||
*/
|
||||
bool operator<(const DType& a) const { return mComp(mD,a.mD) == -1; }
|
||||
|
||||
/** check greater
|
||||
@param a variable to compare with
|
||||
*/
|
||||
bool operator>(const DType& a) const { return mComp(mD,a.mD) == 1; }
|
||||
|
||||
/** check not greater
|
||||
@param a variable to compare with
|
||||
*/
|
||||
bool operator<=(const DType& a) const { auto c = mComp(mD,a.mD); return c <= 0; }
|
||||
|
||||
/** check not smaller
|
||||
@param a variable to compare with
|
||||
*/
|
||||
bool operator>=(const DType& a) const { auto c = mComp(mD,a.mD); return c == 1 or c == 0; }
|
||||
};
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/isq.h
|
||||
|
@ -19,6 +20,7 @@
|
|||
|
||||
namespace CNORXZ
|
||||
{
|
||||
/** @cond 0 */
|
||||
template <SizeT O, SizeT... Is>
|
||||
std::index_sequence<(Is+O)...> mkIsqAdd(std::index_sequence<Is...> is) { return {}; }
|
||||
|
||||
|
@ -33,7 +35,12 @@ namespace CNORXZ
|
|||
|
||||
typedef decltype(make()) type;
|
||||
};
|
||||
/** @endcond */
|
||||
|
||||
/** static consecutive integer sequence
|
||||
@tparam B begin integer
|
||||
@tparam E end integer
|
||||
*/
|
||||
template <SizeT B, SizeT E>
|
||||
using Isqr = typename MkIsq<B,E>::type;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/iter.cc.h
|
||||
@brief Static for-loops
|
||||
|
||||
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
|
||||
Mail: chizeta@f3l.de
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __cxz_iter_cc_h__
|
||||
#define __cxz_iter_cc_h__
|
||||
|
@ -7,6 +17,7 @@
|
|||
|
||||
namespace CNORXZ
|
||||
{
|
||||
/** @cond 0 */
|
||||
template <class G, class F, SizeT... Is>
|
||||
constexpr decltype(auto) iteri(const G& g, const F& f, Isq<Is...> is)
|
||||
{
|
||||
|
@ -17,6 +28,7 @@ namespace CNORXZ
|
|||
return f( g(CSizeT<Is>{}) ... );
|
||||
}
|
||||
}
|
||||
/** @endcond */
|
||||
|
||||
template <SizeT B, SizeT E, class G, class F>
|
||||
constexpr decltype(auto) iter(const G& g, const F& f)
|
||||
|
@ -24,6 +36,7 @@ namespace CNORXZ
|
|||
return iteri(g, f, Isqr<B,E>{});
|
||||
}
|
||||
|
||||
/** @cond 0 */
|
||||
template <SizeT E, SizeT I, class G, class F, class C, typename... Args>
|
||||
constexpr decltype(auto) iterIfi(const G& g, const F& f, const C& c, const Args&... args)
|
||||
{
|
||||
|
@ -44,6 +57,7 @@ namespace CNORXZ
|
|||
}
|
||||
}
|
||||
}
|
||||
/** @endcond */
|
||||
|
||||
template <SizeT B, SizeT E, class G, class F, class C>
|
||||
constexpr decltype(auto) iterIf(const G& g, const F& f, const C& c)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/iter.h
|
||||
|
@ -18,15 +19,37 @@
|
|||
|
||||
namespace CNORXZ
|
||||
{
|
||||
/** @cond 0 */
|
||||
template <class G, class F, SizeT... Is>
|
||||
constexpr decltype(auto) iteri(const G& g, const F& f, Isq<Is...> is);
|
||||
/** @endcond */
|
||||
|
||||
/** static for loop
|
||||
@tparam B begin index
|
||||
@tparam E end index
|
||||
@tparam G type of expression to executed for each element
|
||||
@tparam F type of accumulating expression collecting result for all elements
|
||||
@param g expression to executed for each element
|
||||
@param f accumulating expression collecting result for all elements
|
||||
*/
|
||||
template <SizeT B, SizeT E, class G, class F>
|
||||
constexpr decltype(auto) iter(const G& g, const F& f);
|
||||
|
||||
/** @cond 0 */
|
||||
template <SizeT E, SizeT I, class G, class F, class C, typename... Args>
|
||||
constexpr decltype(auto) iterIfi(const G& g, const F& f, const C& c, const Args&... args);
|
||||
/** @endcond */
|
||||
|
||||
/** static conditional for loop
|
||||
@tparam B begin index
|
||||
@tparam E end index
|
||||
@tparam G type of expression to executed for each element
|
||||
@tparam F type of accumulating expression collecting result for all elements
|
||||
@tparam C type of condition expression
|
||||
@param g expression to executed for each element
|
||||
@param f accumulating expression collecting result for all elements
|
||||
@param c condition expression
|
||||
*/
|
||||
template <SizeT B, SizeT E, class G, class F, class C>
|
||||
constexpr decltype(auto) iterIf(const G& g, const F& f, const C& c);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/macros.h
|
||||
|
@ -24,26 +25,90 @@
|
|||
<< " in " << __func__ << ": " << #a << " = " << a << std::endl;
|
||||
#endif
|
||||
|
||||
/** shortcut for defining default constructor */
|
||||
#define DEFAULT_C(__class_name__) __class_name__() = default
|
||||
|
||||
/** shortcut for defining default copy constructor */
|
||||
#define DEFAULT_COPY_C(__class_name__) __class_name__(const __class_name__& a) = default
|
||||
|
||||
/** shortcut for defining default copy assignment */
|
||||
#define DEFAULT_COPY_A(__class_name__) __class_name__& operator=(const __class_name__& a) = default
|
||||
|
||||
/** shortcut for defining default move constructor */
|
||||
#define DEFAULT_MOVE_C(__class_name__) __class_name__(__class_name__&& a) = default
|
||||
|
||||
/** shortcut for defining default move assignment */
|
||||
#define DEFAULT_MOVE_A(__class_name__) __class_name__& operator=(__class_name__&& a) = default
|
||||
|
||||
/** shortcut for defining default copy constructor and assignment */
|
||||
#define DEFAULT_COPY(__class_name__) DEFAULT_COPY_C(__class_name__); DEFAULT_COPY_A(__class_name__)
|
||||
|
||||
/** shortcut for defining default move constructor and assignment */
|
||||
#define DEFAULT_MOVE(__class_name__) DEFAULT_MOVE_C(__class_name__); DEFAULT_MOVE_A(__class_name__)
|
||||
|
||||
/** shortcut for defining default copy and move constructor and assignment */
|
||||
#define DEFAULT_MEMBERS_X(__class_name__) DEFAULT_COPY(__class_name__); DEFAULT_MOVE(__class_name__)
|
||||
|
||||
/** shortcut for defining default constructor, default copy and move constructor and assignment */
|
||||
#define DEFAULT_MEMBERS(__class_name__) DEFAULT_C(__class_name__); DEFAULT_MEMBERS_X(__class_name__)
|
||||
|
||||
/** shortcut for defining default constructor
|
||||
@param __spec__ specifier
|
||||
@param __class_name__ class name
|
||||
*/
|
||||
#define SP_DEFAULT_C(__spec__,__class_name__) __spec__ __class_name__() = default
|
||||
|
||||
/** shortcut for defining default copy constructor
|
||||
@param __spec__ specifier
|
||||
@param __class_name__ class name
|
||||
*/
|
||||
#define SP_DEFAULT_COPY_C(__spec__,__class_name__) __spec__ __class_name__(const __class_name__& a) = default
|
||||
|
||||
/** shortcut for defining default copy assignment
|
||||
@param __spec__ specifier
|
||||
@param __class_name__ class name
|
||||
*/
|
||||
#define SP_DEFAULT_COPY_A(__spec__,__class_name__) __spec__ __class_name__& operator=(const __class_name__& a) = default
|
||||
|
||||
/** shortcut for defining default move constructor
|
||||
@param __spec__ specifier
|
||||
@param __class_name__ class name
|
||||
*/
|
||||
#define SP_DEFAULT_MOVE_C(__spec__,__class_name__) __spec__ __class_name__(__class_name__&& a) = default
|
||||
|
||||
/** shortcut for defining default move assignment
|
||||
@param __spec__ specifier
|
||||
@param __class_name__ class name
|
||||
*/
|
||||
#define SP_DEFAULT_MOVE_A(__spec__,__class_name__) __spec__ __class_name__& operator=(__class_name__&& a) = default
|
||||
|
||||
/** shortcut for defining default copy constructor and assignment
|
||||
@param __spec__ specifier
|
||||
@param __class_name__ class name
|
||||
*/
|
||||
#define SP_DEFAULT_COPY(__spec__,__class_name__) SP_DEFAULT_COPY_C(__spec__,__class_name__); SP_DEFAULT_COPY_A(__spec__,__class_name__)
|
||||
|
||||
/** shortcut for defining default move constructor and assignment
|
||||
@param __spec__ specifier
|
||||
@param __class_name__ class name
|
||||
*/
|
||||
#define SP_DEFAULT_MOVE(__spec__,__class_name__) SP_DEFAULT_MOVE_C(__spec__,__class_name__); SP_DEFAULT_MOVE_A(__spec__,__class_name__)
|
||||
|
||||
/** shortcut for defining default copy and move constructor and assignment
|
||||
@param __spec__ specifier
|
||||
@param __class_name__ class name
|
||||
*/
|
||||
#define SP_DEFAULT_MEMBERS_X(__spec__,__class_name__) SP_DEFAULT_COPY(__spec__,__class_name__); SP_DEFAULT_MOVE(__spec__,__class_name__)
|
||||
|
||||
/** shortcut for defining default constructor, default copy and move constructor and assignment
|
||||
@param __spec__ specifier
|
||||
@param __class_name__ class name
|
||||
*/
|
||||
#define SP_DEFAULT_MEMBERS(__spec__,__class_name__) SP_DEFAULT_C(__spec__,__class_name__); SP_DEFAULT_MEMBERS_X(__spec__,__class_name__)
|
||||
|
||||
/** shortcut for all typedefs needed to use a class as iterator
|
||||
@param __meta_type__ meta data type
|
||||
*/
|
||||
#define INDEX_RANDOM_ACCESS_ITERATOR_DEFS(__meta_type__) typedef std::random_access_iterator_tag iterator_category; \
|
||||
typedef SizeT difference_type; \
|
||||
typedef __meta_type__ value_type; \
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/obj_handle.cc.h
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/obj_handle.h
|
||||
|
@ -19,24 +20,62 @@
|
|||
namespace CNORXZ
|
||||
{
|
||||
|
||||
/** ****
|
||||
unique pointer wrapper
|
||||
|
||||
Allows to handle objects accessed through abstract base class pointers
|
||||
as if they were complete (non-virtual) types.
|
||||
Each type to be handled is required to have a copy() member function
|
||||
that returns a copy of itself
|
||||
|
||||
@tparam T object type
|
||||
*/
|
||||
template <typename T>
|
||||
class ObjHandle
|
||||
{
|
||||
protected:
|
||||
Uptr<T> mC;
|
||||
Uptr<T> mC; /**< pointer to the object data */
|
||||
|
||||
public:
|
||||
|
||||
/** default constructor */
|
||||
ObjHandle();
|
||||
|
||||
/** construct from unique pointer
|
||||
@param a unique pointer
|
||||
*/
|
||||
ObjHandle(Uptr<T>&& a);
|
||||
|
||||
/** copy construct
|
||||
@param a input
|
||||
*/
|
||||
ObjHandle(const ObjHandle& a);
|
||||
|
||||
/** move construct
|
||||
@param a input
|
||||
*/
|
||||
ObjHandle(ObjHandle&& a);
|
||||
|
||||
/** copy assign
|
||||
@param a input
|
||||
*/
|
||||
ObjHandle& operator=(const ObjHandle& a);
|
||||
|
||||
/** move assign
|
||||
@param a input
|
||||
*/
|
||||
ObjHandle& operator=(ObjHandle&& a);
|
||||
|
||||
/** access data */
|
||||
T& operator*();
|
||||
|
||||
/** get pointer to data */
|
||||
T* operator->();
|
||||
|
||||
/** access data (const) */
|
||||
const T& operator*() const;
|
||||
|
||||
/** get pointer to data (const) */
|
||||
const T* operator->() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/to_string.cc.h
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/to_string.h
|
||||
|
@ -17,48 +18,101 @@
|
|||
|
||||
namespace CNORXZ
|
||||
{
|
||||
/** ***
|
||||
Generic cast to string
|
||||
@tparam T type to be casted
|
||||
*/
|
||||
template <typename T>
|
||||
struct ToString
|
||||
{
|
||||
/** cast to string
|
||||
@param a object to be casted
|
||||
*/
|
||||
static String func(const T& a);
|
||||
};
|
||||
|
||||
/** ***
|
||||
Specialization of ToString for strings
|
||||
*/
|
||||
template <>
|
||||
struct ToString<String>
|
||||
{
|
||||
/** cast to string
|
||||
@param a string to be casted
|
||||
*/
|
||||
static String func(const String& a);
|
||||
};
|
||||
|
||||
/** ***
|
||||
Specialization of ToString for vectors
|
||||
@tparam T vector element type
|
||||
*/
|
||||
template <typename T>
|
||||
struct ToString<Vector<T>>
|
||||
{
|
||||
/** cast to string
|
||||
@param a vector to be casted
|
||||
*/
|
||||
static String func(const Vector<T>& a);
|
||||
};
|
||||
|
||||
/** ***
|
||||
Specialization of ToString for arrays
|
||||
@tparam T array element type
|
||||
@tparam N array size
|
||||
*/
|
||||
template <typename T, SizeT N>
|
||||
struct ToString<Arr<T,N>>
|
||||
{
|
||||
/** cast to string
|
||||
@param a array to be casted
|
||||
*/
|
||||
static String func(const Arr<T,N>& a);
|
||||
};
|
||||
|
||||
/** ***
|
||||
Specialization of ToString for tuples
|
||||
@tparam Ts tuple element types
|
||||
*/
|
||||
template <typename... Ts>
|
||||
struct ToString<Tuple<Ts...>>
|
||||
{
|
||||
/** cast to string
|
||||
@param a tuple to be casted
|
||||
*/
|
||||
static String func(const Tuple<Ts...>& t);
|
||||
};
|
||||
|
||||
/** ***
|
||||
Specialization of ToString for pairs
|
||||
@tparam T first element type
|
||||
@tparam S second element type
|
||||
*/
|
||||
template <typename T, typename S>
|
||||
struct ToString<std::pair<T,S>>
|
||||
{
|
||||
/** cast to string
|
||||
@param a pair to be casted
|
||||
*/
|
||||
static String func(const std::pair<T,S>& t);
|
||||
};
|
||||
|
||||
/** ***
|
||||
Specialization of ToString for DType
|
||||
*/
|
||||
template <>
|
||||
struct ToString<DType>
|
||||
{
|
||||
/** cast to string
|
||||
@param a DType to be casted
|
||||
*/
|
||||
static String func(const DType& a);
|
||||
};
|
||||
|
||||
/** wrapper function for ToString
|
||||
@tparam T type to be casted
|
||||
@param a object to be casted
|
||||
*/
|
||||
template <typename T>
|
||||
String toString(const T& a);
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/types.h
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/utils.h
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// -*- C++ -*-
|
||||
/**
|
||||
|
||||
@file include/base/uuid.h
|
||||
|
@ -16,39 +17,67 @@
|
|||
|
||||
namespace CNORXZ
|
||||
{
|
||||
/** ***
|
||||
uuid
|
||||
*/
|
||||
struct Uuid
|
||||
{
|
||||
uint64_t i1;
|
||||
uint64_t i2;
|
||||
uint64_t i1; /**< first 8 bytes */
|
||||
uint64_t i2; /**< second 8 bytes */
|
||||
};
|
||||
|
||||
/** create new uuid */
|
||||
Uuid mkUuid();
|
||||
|
||||
/** operator equal to
|
||||
@param a left hand side
|
||||
@param b right hand side
|
||||
*/
|
||||
inline bool operator==(const Uuid& a, const Uuid& b)
|
||||
{
|
||||
return a.i1 == b.i1 and a.i2 == b.i2;
|
||||
}
|
||||
|
||||
/** operator not equal to
|
||||
@param a left hand side
|
||||
@param b right hand side
|
||||
*/
|
||||
inline bool operator!=(const Uuid& a, const Uuid& b)
|
||||
{
|
||||
return a.i1 != b.i1 or a.i2 != b.i2;
|
||||
}
|
||||
|
||||
/** operator less than
|
||||
@param a left hand side
|
||||
@param b right hand side
|
||||
*/
|
||||
inline bool operator<(const Uuid& a, const Uuid& b)
|
||||
{
|
||||
return (a.i1 == b.i1) ? a.i2 < b.i2 : a.i1 < b.i1;
|
||||
}
|
||||
|
||||
/** operator greater than
|
||||
@param a left hand side
|
||||
@param b right hand side
|
||||
*/
|
||||
inline bool operator>(const Uuid& a, const Uuid& b)
|
||||
{
|
||||
return (a.i1 == b.i1) ? a.i2 > b.i2 : a.i1 > b.i1;
|
||||
}
|
||||
|
||||
/** operator less or equal
|
||||
@param a left hand side
|
||||
@param b right hand side
|
||||
*/
|
||||
inline bool operator<=(const Uuid& a, const Uuid& b)
|
||||
{
|
||||
return not( (a.i1 == b.i1) ? a.i2 > b.i2 : a.i1 > b.i1 );
|
||||
}
|
||||
|
||||
/** operator greater or equal
|
||||
@param a left hand side
|
||||
@param b right hand side
|
||||
*/
|
||||
inline bool operator>=(const Uuid& a, const Uuid& b)
|
||||
{
|
||||
return not( (a.i1 == b.i1) ? a.i2 < b.i2 : a.i1 < b.i1 );
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
|
||||
namespace CNORXZ
|
||||
{
|
||||
/** ****
|
||||
specific index for CRange
|
||||
*/
|
||||
class CIndex : public IndexInterface<CIndex,SizeT>
|
||||
{
|
||||
public:
|
||||
|
@ -29,46 +32,82 @@ namespace CNORXZ
|
|||
typedef SizeT MetaType;
|
||||
|
||||
INDEX_RANDOM_ACCESS_ITERATOR_DEFS(MetaType);
|
||||
DEFAULT_MEMBERS(CIndex);
|
||||
DEFAULT_MEMBERS(CIndex); /**< default constructors and assignments */
|
||||
|
||||
/** constrcut index from range and position
|
||||
@param range Range to iterate over
|
||||
@param pos lexicographic position
|
||||
*/
|
||||
CIndex(const RangePtr& range, SizeT pos = 0);
|
||||
|
||||
/** @copydoc IndexInterface::operator=(SizeT) */
|
||||
CIndex& operator=(SizeT lexpos);
|
||||
|
||||
/** @copydoc IndexInterface::operator++() */
|
||||
CIndex& operator++();
|
||||
|
||||
/** @copydoc IndexInterface::operator--() */
|
||||
CIndex& operator--();
|
||||
|
||||
/** @copydoc IndexInterface::operator+() */
|
||||
CIndex operator+(Int n) const;
|
||||
|
||||
/** @copydoc IndexInterface::operator-() */
|
||||
CIndex operator-(Int n) const;
|
||||
|
||||
/** @copydoc IndexInterface::operator-(CIndex) */
|
||||
SizeT operator-(const CIndex& i) const;
|
||||
|
||||
/** @copydoc IndexInterface::operator+=() */
|
||||
CIndex& operator+=(Int n);
|
||||
|
||||
/** @copydoc IndexInterface::operator-=() */
|
||||
CIndex& operator-=(Int n);
|
||||
|
||||
/** @copydoc IndexInterface::lex() */
|
||||
SizeT lex() const;
|
||||
|
||||
/** @copydoc IndexInterface::pmax() */
|
||||
UPos pmax() const;
|
||||
|
||||
/** @copydoc IndexInterface::lmax() */
|
||||
UPos lmax() const;
|
||||
|
||||
/** @copydoc IndexInterface::id() */
|
||||
IndexId<0> id() const;
|
||||
|
||||
/** @copydoc IndexInterface::operator*() */
|
||||
SizeT operator*() const;
|
||||
|
||||
/** @copydoc IndexInterface::dim() */
|
||||
SizeT dim() const; // = 1
|
||||
|
||||
/** @copydoc IndexInterface::range() */
|
||||
Sptr<RangeType> range() const;
|
||||
|
||||
/** @copydoc IndexInterface::stepSize() */
|
||||
template <SizeT I>
|
||||
decltype(auto) stepSize(const IndexId<I>& id) const;
|
||||
|
||||
/** @copydoc IndexInterface::stringMeta() */
|
||||
String stringMeta() const;
|
||||
|
||||
/** @copydoc IndexInterface::meta() */
|
||||
SizeT meta() const;
|
||||
|
||||
/** @copydoc IndexInterface::at() */
|
||||
CIndex& at(const SizeT& metaPos);
|
||||
|
||||
/** @copydoc IndexInterface::xpr() */
|
||||
COpRoot<SizeT,CIndex> xpr(const Sptr<CIndex>& _this) const;
|
||||
|
||||
/** @copydoc IndexInterface::prange() */
|
||||
RangePtr prange(const CIndex& last) const;
|
||||
|
||||
/** @copydoc IndexInterface::deepFormat() */
|
||||
SizeT deepFormat() const;
|
||||
/*
|
||||
template <class Index>
|
||||
decltype(auto) formatFrom(const Index& ind) const;
|
||||
|
||||
template <class Index>
|
||||
decltype(auto) slice(const Sptr<Index>& ind) const;
|
||||
*/
|
||||
/** @copydoc IndexInterface::ifor() */
|
||||
template <class Xpr, class F = NoF>
|
||||
decltype(auto) ifor(const Xpr& xpr, F&& f) const;
|
||||
|
||||
|
@ -76,15 +115,31 @@ namespace CNORXZ
|
|||
Sptr<RangeType> mRangePtr;
|
||||
};
|
||||
|
||||
/** make index pack of a CIndex and another index
|
||||
@tparam type of the second index
|
||||
@param a pointer to CIndex
|
||||
@param b pointer to another index
|
||||
*/
|
||||
template <class I>
|
||||
decltype(auto) operator*(const Sptr<CIndex>& a, const Sptr<I>& b);
|
||||
|
||||
/** ****
|
||||
specific factory for CRange
|
||||
*/
|
||||
class CRangeFactory : public RangeFactoryBase
|
||||
{
|
||||
public:
|
||||
typedef CRange oType;
|
||||
|
||||
/** construct and setup factory
|
||||
@param size size of the range to be constructed
|
||||
*/
|
||||
CRangeFactory(SizeT size);
|
||||
|
||||
/** construct and setup factory
|
||||
@param size size of the range to be constructed
|
||||
@param ref range the range to be constructed is related to
|
||||
*/
|
||||
CRangeFactory(SizeT size, RangePtr ref);
|
||||
|
||||
protected:
|
||||
|
@ -95,6 +150,12 @@ namespace CNORXZ
|
|||
RangePtr mRef;
|
||||
};
|
||||
|
||||
/** ****
|
||||
Classic Range
|
||||
The parameter space is given by a
|
||||
set of positve integer numbers running
|
||||
form 0 to size-1
|
||||
*/
|
||||
class CRange : public RangeInterface<CRange>
|
||||
{
|
||||
public:
|
||||
|
@ -112,25 +173,43 @@ namespace CNORXZ
|
|||
virtual const TypeInfo& metaType() const override final;
|
||||
virtual RangePtr extend(const RangePtr& r) const override final;
|
||||
|
||||
/** return meta data at given position
|
||||
@param pos position, size type
|
||||
*/
|
||||
SizeT get(SizeT pos) const;
|
||||
|
||||
/** return position for given meta data
|
||||
@param metaPos meta data, size type
|
||||
*/
|
||||
SizeT getMeta(SizeT metaPos) const;
|
||||
|
||||
protected:
|
||||
|
||||
/** default constructor */
|
||||
CRange() = default;
|
||||
|
||||
CRange(const CRange& in) = delete;
|
||||
|
||||
/** create range of given size
|
||||
@param size, input size, size type
|
||||
*/
|
||||
CRange(SizeT size);
|
||||
|
||||
virtual Vector<Uuid> key() const override final;
|
||||
|
||||
SizeT mSize = 0;
|
||||
SizeT mSize = 0; /**< range size */
|
||||
|
||||
SERIALIZATION_FUNCTIONS_NOPUB;
|
||||
};
|
||||
|
||||
/** ***
|
||||
Specialize RangeCast for casts to CRange
|
||||
@see RangeCast
|
||||
*/
|
||||
template <>
|
||||
struct RangeCast<CRange>
|
||||
{
|
||||
/** cast the range */
|
||||
static Sptr<CRange> func(const RangePtr& r);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -110,27 +110,27 @@ namespace CNORXZ
|
|||
*/
|
||||
bool operator==(const IndexInterface& i) const;
|
||||
|
||||
/** check if indices are non-equal
|
||||
/** check if indices are not equal
|
||||
@param i Index to compare with
|
||||
*/
|
||||
bool operator!=(const IndexInterface& i) const;
|
||||
|
||||
/** check if index is smaller than i
|
||||
/** check if index position is less than that of i
|
||||
@param i Index to compare with
|
||||
*/
|
||||
bool operator<(const IndexInterface& i) const;
|
||||
|
||||
/** check if index is greater than i
|
||||
/** check if index position is greater than that of i
|
||||
@param i Index to compare with
|
||||
*/
|
||||
bool operator>(const IndexInterface& i) const;
|
||||
|
||||
/** check if index is not greater than i
|
||||
/** check if index position is less or equal than that of i
|
||||
@param i Index to compare with
|
||||
*/
|
||||
bool operator<=(const IndexInterface& i) const;
|
||||
|
||||
/** check if index is not smaller than i
|
||||
/** check if index position is greater or equal than that of i
|
||||
@param i Index to compare with
|
||||
*/
|
||||
bool operator>=(const IndexInterface& i) const;
|
||||
|
|
|
@ -399,17 +399,7 @@ namespace CNORXZ
|
|||
( [&](auto i) { return mIPack[i]->stepSize(id) * format()[i]; },
|
||||
[](const auto&... ss) { return ( ss + ... ); });
|
||||
}
|
||||
/*
|
||||
template <class FormatT, class... Indices>
|
||||
template <class Index>
|
||||
decltype(auto) GMIndex<FormatT,Indices...>::formatFrom(const Index& ind) const
|
||||
{
|
||||
static_assert(is_index<Index>::value, "got non-index");
|
||||
CXZ_ASSERT(ind.dim() >= dim(), "for formatting index of dimension " << dim()
|
||||
<< " need index of at least the same dimension, got " << ind.dim());
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
|
||||
template <class FormatT, class... Indices>
|
||||
String GMIndex<FormatT,Indices...>::stringMeta() const
|
||||
{
|
||||
|
|
|
@ -74,9 +74,6 @@ namespace CNORXZ
|
|||
template <SizeT I>
|
||||
decltype(auto) stepSize(const IndexId<I>& id) const;
|
||||
|
||||
//template <class Index>
|
||||
//decltype(auto) formatFrom(const Index& ind) const;
|
||||
|
||||
String stringMeta() const;
|
||||
MetaType meta() const;
|
||||
GMIndex& at(const MetaType& metaPos);
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
namespace CNORXZ
|
||||
{
|
||||
/***************
|
||||
* CIndex *
|
||||
***************/
|
||||
/*=====================================================+
|
||||
| Implementations of member functions of CIndex |
|
||||
+=====================================================*/
|
||||
|
||||
CIndex::CIndex(const RangePtr& range, SizeT pos) :
|
||||
IndexInterface<CIndex,SizeT>(pos), mRangePtr(rangeCast<RangeType>(range))
|
||||
|
@ -139,9 +139,9 @@ namespace CNORXZ
|
|||
return 1;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* CRangeFactory *
|
||||
**********************/
|
||||
/*============================================================+
|
||||
| Implementations of member functions of CRangeFactory |
|
||||
+============================================================*/
|
||||
|
||||
CRangeFactory::CRangeFactory(SizeT size) :
|
||||
mSize(size) {}
|
||||
|
@ -162,9 +162,9 @@ namespace CNORXZ
|
|||
}
|
||||
}
|
||||
|
||||
/***************
|
||||
* CRange *
|
||||
***************/
|
||||
/*=====================================================+
|
||||
| Implementations of member functions of CRange |
|
||||
+=====================================================*/
|
||||
|
||||
CRange::CRange(SizeT size) : mSize(size) {}
|
||||
|
||||
|
@ -214,9 +214,9 @@ namespace CNORXZ
|
|||
return Vector<Uuid> { this->id() };
|
||||
}
|
||||
|
||||
/*******************
|
||||
* Range Casts *
|
||||
*******************/
|
||||
/*======================================+
|
||||
| Implementations of range casts |
|
||||
+======================================*/
|
||||
|
||||
Sptr<CRange> RangeCast<CRange>::func(const RangePtr& r)
|
||||
{
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
|
||||
|
||||
#include <cstdlib>
|
||||
#include "gtest/gtest.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "cnorxz.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <cmath>
|
||||
|
||||
namespace MAT = CNORXZ;
|
||||
|
||||
double xround(double arg)
|
||||
{
|
||||
if(std::isnan(arg)) { return 0.; }
|
||||
return roundf(arg * 100000.) / 100000.;
|
||||
}
|
||||
|
||||
using namespace MAT;
|
||||
|
||||
typedef ClassicRange CR;
|
||||
typedef ClassicRF CRF;
|
||||
typedef DynamicRange DR;
|
||||
typedef DynamicRangeFactory DRF;
|
||||
|
||||
template <class Factory>
|
||||
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr)
|
||||
{
|
||||
auto nptr = std::make_shared<Factory>();
|
||||
fptr = nptr;
|
||||
}
|
||||
|
||||
template <class Factory, typename T>
|
||||
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::initializer_list<T> ilist)
|
||||
{
|
||||
vector<T> tmp = ilist;
|
||||
auto nptr = std::make_shared<Factory>( tmp );
|
||||
fptr = nptr;
|
||||
}
|
||||
|
||||
template <class Factory, typename T>
|
||||
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, vector<T>& ilist)
|
||||
{
|
||||
vector<T> tmp = ilist;
|
||||
auto nptr = std::make_shared<Factory>( tmp );
|
||||
fptr = nptr;
|
||||
}
|
||||
|
||||
|
||||
template <class Factory, class... Rs>
|
||||
void swapMFactory(std::shared_ptr<RangeFactoryBase>& fptr, const Rs&... rs)
|
||||
{
|
||||
auto nptr = std::make_shared<Factory>( rs... );
|
||||
fptr = nptr;
|
||||
}
|
||||
|
||||
template <typename... Ts>
|
||||
auto mkt(Ts&&... ts) -> decltype(std::make_tuple(ts...))
|
||||
{
|
||||
return std::make_tuple(ts...);
|
||||
}
|
||||
|
||||
template <typename... Ts>
|
||||
auto mkts(Ts&&... ts) -> decltype(std::make_tuple(ts...))
|
||||
{
|
||||
return std::make_tuple(static_cast<size_t>( ts )...);
|
||||
}
|
||||
|
||||
//typedef Expressions1 EC1;
|
||||
|
||||
template <typename T>
|
||||
struct Pow
|
||||
{
|
||||
static constexpr bool FISSTATIC = true;
|
||||
typedef T value_type;
|
||||
|
||||
static inline T apply(T b, T e)
|
||||
{
|
||||
return pow(b, e);
|
||||
}
|
||||
|
||||
template <class... Ops>
|
||||
static auto mk(const Ops&... ops)
|
||||
-> Operation<T,Pow<T>,Ops...>
|
||||
{
|
||||
return Operation<T,Pow<T>,Ops...>(ops...);
|
||||
}
|
||||
|
||||
static inline T apply(const std::tuple<double, double>& arg)
|
||||
{
|
||||
return pow(std::get<0>(arg), std::get<1>(arg));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct Monopole
|
||||
{
|
||||
static constexpr bool FISSTATIC = true;
|
||||
|
||||
static inline T apply(T f0, T x, T n)
|
||||
{
|
||||
return f0 / ( 1 + x / n );
|
||||
}
|
||||
|
||||
template <class... Ops>
|
||||
static auto mk(const Ops&... ops)
|
||||
-> Operation<T,Monopole<T>,Ops...>
|
||||
{
|
||||
return Operation<T,Monopole<T>,Ops...>(ops...);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in a new issue