// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr> // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
/** * \brief The Index type as used for the API. * \details To change this, \c \#define the preprocessor symbol \c EIGEN_DEFAULT_DENSE_INDEX_TYPE. * \sa \blank \ref TopicPreprocessorDirectives, StorageIndex.
*/
typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE Index;
namespace internal {
/** \internal * \file Meta.h * This file contains generic metaprogramming classes which are not specifically related to Eigen. * \note In case you wonder, yes we're aware that Boost already provides all these features, * we however don't want to add a dependency to Boost.
*/
// Only recent versions of ICC complain about using ptrdiff_t to hold pointers, // and older versions do not provide *intptr_t types. #if EIGEN_ICC_NEEDS_CSTDINT typedef std::intptr_t IntPtr; typedef std::uintptr_t UIntPtr; #else typedef std::ptrdiff_t IntPtr; typedef std::size_t UIntPtr; #endif #undef EIGEN_ICC_NEEDS_CSTDINT
struct true_type { enum { value = 1 }; }; struct false_type { enum { value = 0 }; };
// Some platforms define int64_t as `long long` even for C++03, where // `long long` is not guaranteed by the standard. In this case we are missing // the definition for make_unsigned. If we just define it, we run into issues // where `long long` doesn't exist in some compilers for C++03. We therefore add // the specialization for these platforms only. #if EIGEN_OS_MAC || EIGEN_COMP_MINGW template<> struct make_unsigned<unsignedlonglong> { typedefunsignedlonglong type; }; template<> struct make_unsigned<longlong> { typedefunsignedlonglong type; }; #endif #endif
/** \internal Allows to enable/disable an overload * according to a compile time condition.
*/ template<bool Condition, typename T=void> struct enable_if;
template<typename T> struct enable_if<true,T>
{ typedef T type; };
/** \internal * A base class do disable default copy ctor and copy assignment operator.
*/ class noncopyable
{
EIGEN_DEVICE_FUNC noncopyable(const noncopyable&);
EIGEN_DEVICE_FUNC const noncopyable& operator=(const noncopyable&); protected:
EIGEN_DEVICE_FUNC noncopyable() {}
EIGEN_DEVICE_FUNC ~noncopyable() {}
};
/** \internal * Provides access to the number of elements in the object of as a compile-time constant expression. * It "returns" Eigen::Dynamic if the size cannot be resolved at compile-time (default). * * Similar to std::tuple_size, but more general. * * It currently supports: * - any types T defining T::SizeAtCompileTime * - plain C arrays as T[N] * - std::array (c++11) * - some internal types such as SingleRange and AllRange * * The second template parameter eases SFINAE-based specializations.
*/ template<typename T, typename EnableIf = void> struct array_size { enum { value = Dynamic };
};
template<typename T, int N> struct array_size<const T (&)[N]> { enum { value = N };
}; template<typename T, int N> struct array_size<T (&)[N]> { enum { value = N };
};
#if EIGEN_HAS_CXX11 template<typename T, std::size_t N> struct array_size<const std::array<T,N> > { enum { value = N };
}; template<typename T, std::size_t N> struct array_size<std::array<T,N> > { enum { value = N };
}; #endif
/** \internal * Analogue of the std::size free function. * It returns the size of the container or view \a x of type \c T * * It currently supports: * - any types T defining a member T::size() const * - plain C arrays as T[N] *
*/ template<typename T>
EIGEN_CONSTEXPR Index size(const T& x) { return x.size(); }
template<typename T,std::size_t N>
EIGEN_CONSTEXPR Index size(const T (&) [N]) { return N; }
/** \internal * Convenient struct to get the result type of a nullary, unary, binary, or * ternary functor. * * Pre C++11: * Supports both a Func::result_type member and templated * Func::result<Func(ArgTypes...)>::type member. * * If none of these members is provided, then the type of the first * argument is returned. * * Post C++11: * This uses std::result_of. However, note the `type` member removes * const and converts references/pointers to their corresponding value type.
*/ #if EIGEN_HAS_STD_INVOKE_RESULT template<typename T> struct result_of;
// note that the following indirection is needed for gcc-3.3 enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))}; typedeftypename nullary_result_of_select<Func, FunctorType>::type type;
};
// note that the following indirection is needed for gcc-3.3 enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))}; typedeftypename unary_result_of_select<Func, ArgType, FunctorType>::type type;
};
// note that the following indirection is needed for gcc-3.3 enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))}; typedeftypename binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::type type;
};
// note that the following indirection is needed for gcc-3.3 enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))}; typedeftypename ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, FunctorType>::type type;
};
enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
};
/** \internal In short, it computes int(sqrt(\a Y)) with \a Y an integer. * Usage example: \code meta_sqrt<1023>::ret \endcode
*/ template<int Y, int InfX = 0, int SupX = ((Y==1) ? 1 : Y/2), bool Done = ((SupX-InfX)<=1 ? true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) > // use ?: instead of || just to shut up a stupid gcc 4.3 warning class meta_sqrt
{ enum {
MidX = (InfX+SupX)/2,
TakeInf = MidX*MidX > Y ? 1 : 0,
NewInf = int(TakeInf) ? InfX : int(MidX),
NewSup = int(TakeInf) ? int(MidX) : SupX
}; public: enum { ret = meta_sqrt<Y,NewInf,NewSup>::ret };
};
template<int Y, int InfX, int SupX> class meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
/** \internal Computes the least common multiple of two positive integer A and B * at compile-time.
*/ template<int A, int B, int K=1, bool Done = ((A*K)%B)==0, bool Big=(A>=B)> struct meta_least_common_multiple
{ enum { ret = meta_least_common_multiple<A,B,K+1>::ret };
}; template<int A, int B, int K, bool Done> struct meta_least_common_multiple<A,B,K,Done,false>
{ enum { ret = meta_least_common_multiple<B,A,K>::ret };
}; template<int A, int B, int K> struct meta_least_common_multiple<A,B,K,true,true>
{ enum { ret = A*K };
};
/** \internal determines whether the product of two numeric types is allowed and what the return type is */ template<typename T, typename U> struct scalar_product_traits
{ enum { Defined = 0 };
};
// FIXME quick workaround around current limitation of result_of // template<typename Scalar, typename ArgType0, typename ArgType1> // struct result_of<scalar_product_op<Scalar>(ArgType0,ArgType1)> { // typedef typename scalar_product_traits<typename remove_all<ArgType0>::type, typename remove_all<ArgType1>::type>::ReturnType type; // };
/** \internal Obtains a POD type suitable to use as storage for an object of a size * of at most Len bytes, aligned as specified by \c Align.
*/ template<unsigned Len, unsigned Align> struct aligned_storage { struct type {
EIGEN_ALIGN_TO_BOUNDARY(Align) unsignedchar data[Len];
};
};
} // end namespace internal
namespace numext {
#ifdefined(EIGEN_GPU_COMPILE_PHASE) template<typename T> EIGEN_DEVICE_FUNC void swap(T &a, T &b) { T tmp = b; b = a; a = tmp; } #else template<typename T> EIGEN_STRONG_INLINE void swap(T &a, T &b) { std::swap(a,b); } #endif
#ifdefined(EIGEN_GPU_COMPILE_PHASE) && !EIGEN_HAS_CXX11 using internal::device::numeric_limits; #else using std::numeric_limits; #endif
// Integer division with rounding up. // T is assumed to be an integer type with a>=0, and b>0 template<typename T>
EIGEN_DEVICE_FUNC
T div_ceil(const T &a, const T &b)
{ return (a+b-1) / b;
}
// The aim of the following functions is to bypass -Wfloat-equal warnings // when we really want a strict equality comparison on floating points. template<typename X, typename Y> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool equal_strict(const X& x,const Y& y) { return x == y; }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.