mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
the Index types change.
As discussed on the list (too long to explain here).
This commit is contained in:
@@ -29,29 +29,29 @@
|
||||
// implement and control fast level 2 and level 3 BLAS-like routines.
|
||||
|
||||
// forward declarations
|
||||
template<typename Scalar, int mr, int nr, typename Conj>
|
||||
template<typename Scalar, typename Index, int mr, int nr, typename Conj>
|
||||
struct ei_gebp_kernel;
|
||||
|
||||
template<typename Scalar, int nr, int StorageOrder, bool PanelMode=false>
|
||||
template<typename Scalar, typename Index, int nr, int StorageOrder, bool PanelMode=false>
|
||||
struct ei_gemm_pack_rhs;
|
||||
|
||||
template<typename Scalar, int mr, int StorageOrder, bool Conjugate = false, bool PanelMode = false>
|
||||
template<typename Scalar, typename Index, int mr, int StorageOrder, bool Conjugate = false, bool PanelMode = false>
|
||||
struct ei_gemm_pack_lhs;
|
||||
|
||||
template<
|
||||
typename Scalar,
|
||||
typename Scalar, typename Index,
|
||||
int LhsStorageOrder, bool ConjugateLhs,
|
||||
int RhsStorageOrder, bool ConjugateRhs,
|
||||
int ResStorageOrder>
|
||||
struct ei_general_matrix_matrix_product;
|
||||
|
||||
template<bool ConjugateLhs, bool ConjugateRhs, typename Scalar, typename RhsType>
|
||||
template<bool ConjugateLhs, bool ConjugateRhs, typename Scalar, typename Index, typename RhsType>
|
||||
static void ei_cache_friendly_product_colmajor_times_vector(
|
||||
int size, const Scalar* lhs, int lhsStride, const RhsType& rhs, Scalar* res, Scalar alpha);
|
||||
Index size, const Scalar* lhs, Index lhsStride, const RhsType& rhs, Scalar* res, Scalar alpha);
|
||||
|
||||
template<bool ConjugateLhs, bool ConjugateRhs, typename Scalar, typename ResType>
|
||||
template<bool ConjugateLhs, bool ConjugateRhs, typename Scalar, typename Index, typename ResType>
|
||||
static void ei_cache_friendly_product_rowmajor_times_vector(
|
||||
const Scalar* lhs, int lhsStride, const Scalar* rhs, int rhsSize, ResType& res, Scalar alpha);
|
||||
const Scalar* lhs, Index lhsStride, const Scalar* rhs, Index rhsSize, ResType& res, Scalar alpha);
|
||||
|
||||
// Provides scalar/packet-wise product and product with accumulation
|
||||
// with optional conjugation of the arguments.
|
||||
@@ -98,29 +98,29 @@ template<> struct ei_conj_helper<true,true>
|
||||
// Lightweight helper class to access matrix coefficients.
|
||||
// Yes, this is somehow redundant with Map<>, but this version is much much lighter,
|
||||
// and so I hope better compilation performance (time and code quality).
|
||||
template<typename Scalar, int StorageOrder>
|
||||
template<typename Scalar, typename Index, int StorageOrder>
|
||||
class ei_blas_data_mapper
|
||||
{
|
||||
public:
|
||||
ei_blas_data_mapper(Scalar* data, int stride) : m_data(data), m_stride(stride) {}
|
||||
EIGEN_STRONG_INLINE Scalar& operator()(int i, int j)
|
||||
ei_blas_data_mapper(Scalar* data, Index stride) : m_data(data), m_stride(stride) {}
|
||||
EIGEN_STRONG_INLINE Scalar& operator()(Index i, Index j)
|
||||
{ return m_data[StorageOrder==RowMajor ? j + i*m_stride : i + j*m_stride]; }
|
||||
protected:
|
||||
Scalar* EIGEN_RESTRICT m_data;
|
||||
int m_stride;
|
||||
Index m_stride;
|
||||
};
|
||||
|
||||
// lightweight helper class to access matrix coefficients (const version)
|
||||
template<typename Scalar, int StorageOrder>
|
||||
template<typename Scalar, typename Index, int StorageOrder>
|
||||
class ei_const_blas_data_mapper
|
||||
{
|
||||
public:
|
||||
ei_const_blas_data_mapper(const Scalar* data, int stride) : m_data(data), m_stride(stride) {}
|
||||
EIGEN_STRONG_INLINE const Scalar& operator()(int i, int j) const
|
||||
ei_const_blas_data_mapper(const Scalar* data, Index stride) : m_data(data), m_stride(stride) {}
|
||||
EIGEN_STRONG_INLINE const Scalar& operator()(Index i, Index j) const
|
||||
{ return m_data[StorageOrder==RowMajor ? j + i*m_stride : i + j*m_stride]; }
|
||||
protected:
|
||||
const Scalar* EIGEN_RESTRICT m_data;
|
||||
int m_stride;
|
||||
Index m_stride;
|
||||
};
|
||||
|
||||
// Defines various constant controlling level 3 blocking
|
||||
|
||||
@@ -94,6 +94,14 @@
|
||||
#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ColMajor
|
||||
#endif
|
||||
|
||||
#ifndef EIGEN_DEFAULT_DENSE_INDEX_TYPE
|
||||
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff_t
|
||||
#endif
|
||||
|
||||
#ifndef EIGEN_DEFAULT_SPARSE_INDEX_TYPE
|
||||
#define EIGEN_DEFAULT_SPARSE_INDEX_TYPE int
|
||||
#endif
|
||||
|
||||
/** Allows to disable some optimizations which might affect the accuracy of the result.
|
||||
* Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them.
|
||||
* They currently include:
|
||||
@@ -266,6 +274,8 @@
|
||||
typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex<T>, T were corresponding to RealScalar. */ \
|
||||
typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \
|
||||
typedef typename Eigen::ei_nested<Derived>::type Nested; \
|
||||
typedef typename Eigen::ei_traits<Derived>::StorageKind StorageKind; \
|
||||
typedef typename Eigen::ei_index<StorageKind>::type Index; \
|
||||
enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
|
||||
ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \
|
||||
Flags = Eigen::ei_traits<Derived>::Flags, \
|
||||
@@ -281,6 +291,8 @@
|
||||
typedef typename Base::PacketScalar PacketScalar; \
|
||||
typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \
|
||||
typedef typename Eigen::ei_nested<Derived>::type Nested; \
|
||||
typedef typename Eigen::ei_traits<Derived>::StorageKind StorageKind; \
|
||||
typedef typename Eigen::ei_index<StorageKind>::type Index; \
|
||||
enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
|
||||
ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \
|
||||
MaxRowsAtCompileTime = Eigen::ei_traits<Derived>::MaxRowsAtCompileTime, \
|
||||
|
||||
@@ -379,10 +379,10 @@ template<typename T, bool Align> inline T* ei_conditional_aligned_realloc_new(T*
|
||||
* other hand, we do not assume that the array address is a multiple of sizeof(Scalar), as that fails for
|
||||
* example with Scalar=double on certain 32-bit platforms, see bug #79.
|
||||
*
|
||||
* There is also the variant ei_first_aligned(const MatrixBase&, Integer) defined in Coeffs.h.
|
||||
* There is also the variant ei_first_aligned(const MatrixBase&) defined in DenseCoeffsBase.h.
|
||||
*/
|
||||
template<typename Scalar, typename Integer>
|
||||
inline static Integer ei_first_aligned(const Scalar* array, Integer size)
|
||||
template<typename Scalar, typename Index>
|
||||
inline static Index ei_first_aligned(const Scalar* array, Index size)
|
||||
{
|
||||
typedef typename ei_packet_traits<Scalar>::type Packet;
|
||||
enum { PacketSize = ei_packet_traits<Scalar>::size,
|
||||
@@ -403,7 +403,7 @@ inline static Integer ei_first_aligned(const Scalar* array, Integer size)
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::min<Integer>( (PacketSize - (Integer((size_t(array)/sizeof(Scalar))) & PacketAlignedMask))
|
||||
return std::min<Index>( (PacketSize - (Index((size_t(array)/sizeof(Scalar))) & PacketAlignedMask))
|
||||
& PacketAlignedMask, size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,27 +42,35 @@ class ei_no_assignment_operator
|
||||
ei_no_assignment_operator& operator=(const ei_no_assignment_operator&);
|
||||
};
|
||||
|
||||
/** \internal If the template parameter Value is Dynamic, this class is just a wrapper around an int variable that
|
||||
template<typename StorageKind> struct ei_index {};
|
||||
|
||||
template<>
|
||||
struct ei_index<Dense>
|
||||
{ typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE type; };
|
||||
|
||||
typedef typename ei_index<Dense>::type DenseIndex;
|
||||
|
||||
/** \internal If the template parameter Value is Dynamic, this class is just a wrapper around a T variable that
|
||||
* can be accessed using value() and setValue().
|
||||
* Otherwise, this class is an empty structure and value() just returns the template parameter Value.
|
||||
*/
|
||||
template<int Value> class ei_int_if_dynamic
|
||||
template<typename T, int Value> class ei_variable_if_dynamic
|
||||
{
|
||||
public:
|
||||
EIGEN_EMPTY_STRUCT_CTOR(ei_int_if_dynamic)
|
||||
explicit ei_int_if_dynamic(int v) { EIGEN_ONLY_USED_FOR_DEBUG(v); ei_assert(v == Value); }
|
||||
static int value() { return Value; }
|
||||
void setValue(int) {}
|
||||
EIGEN_EMPTY_STRUCT_CTOR(ei_variable_if_dynamic)
|
||||
explicit ei_variable_if_dynamic(T v) { EIGEN_ONLY_USED_FOR_DEBUG(v); ei_assert(v == T(Value)); }
|
||||
static T value() { return T(Value); }
|
||||
void setValue(T) {}
|
||||
};
|
||||
|
||||
template<> class ei_int_if_dynamic<Dynamic>
|
||||
template<typename T> class ei_variable_if_dynamic<T, Dynamic>
|
||||
{
|
||||
int m_value;
|
||||
ei_int_if_dynamic() { ei_assert(false); }
|
||||
T m_value;
|
||||
ei_variable_if_dynamic() { ei_assert(false); }
|
||||
public:
|
||||
explicit ei_int_if_dynamic(int value) : m_value(value) {}
|
||||
int value() const { return m_value; }
|
||||
void setValue(int value) { m_value = value; }
|
||||
explicit ei_variable_if_dynamic(T value) : m_value(value) {}
|
||||
T value() const { return m_value; }
|
||||
void setValue(T value) { m_value = value; }
|
||||
};
|
||||
|
||||
template<typename T> struct ei_functor_traits
|
||||
|
||||
Reference in New Issue
Block a user