mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-03 18:24:02 +08:00
Fix compilation issues with MSVC and NVCC.
Added a few typedef of complex return types in MatrixBase (Needed by MSVC)
This commit is contained in:
parent
5da60897ab
commit
c6789a279c
@ -6,7 +6,7 @@
|
||||
#ifdef __GNUC__
|
||||
#define EIGEN_GNUC_AT_LEAST(x,y) (__GNUC__>=x && __GNUC_MINOR__>=y) || __GNUC__>x
|
||||
#else
|
||||
#define EIGEN_GNUC_AT_LEAST(x,y) false
|
||||
#define EIGEN_GNUC_AT_LEAST(x,y) 0
|
||||
#endif
|
||||
|
||||
#ifndef EIGEN_DONT_VECTORIZE
|
||||
@ -34,6 +34,7 @@
|
||||
#include <cmath>
|
||||
#include <complex>
|
||||
#include <cassert>
|
||||
#include <functional>
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
|
@ -321,25 +321,23 @@ inline const Block<Derived> MatrixBase<Derived>::end(int size) const
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<int Size>
|
||||
inline Block<Derived, ei_traits<Derived>::RowsAtCompileTime == 1 ? 1 : Size,
|
||||
ei_traits<Derived>::ColsAtCompileTime == 1 ? 1 : Size>
|
||||
inline typename MatrixBase<Derived>::template SubVectorReturnType<Size>::Type
|
||||
MatrixBase<Derived>::start()
|
||||
{
|
||||
ei_assert(IsVectorAtCompileTime);
|
||||
return Block<Derived, RowsAtCompileTime == 1 ? 1 : Size,
|
||||
ColsAtCompileTime == 1 ? 1 : Size>(derived(), 0, 0);
|
||||
return Block<Derived, (RowsAtCompileTime == 1 ? 1 : Size),
|
||||
(ColsAtCompileTime == 1 ? 1 : Size)>(derived(), 0, 0);
|
||||
}
|
||||
|
||||
/** This is the const version of start<int>().*/
|
||||
template<typename Derived>
|
||||
template<int Size>
|
||||
inline const Block<Derived, ei_traits<Derived>::RowsAtCompileTime == 1 ? 1 : Size,
|
||||
ei_traits<Derived>::ColsAtCompileTime == 1 ? 1 : Size>
|
||||
inline const typename MatrixBase<Derived>::template SubVectorReturnType<Size>::Type
|
||||
MatrixBase<Derived>::start() const
|
||||
{
|
||||
ei_assert(IsVectorAtCompileTime);
|
||||
return Block<Derived, RowsAtCompileTime == 1 ? 1 : Size,
|
||||
ColsAtCompileTime == 1 ? 1 : Size>(derived(), 0, 0);
|
||||
return Block<Derived, (RowsAtCompileTime == 1 ? 1 : Size),
|
||||
(ColsAtCompileTime == 1 ? 1 : Size)>(derived(), 0, 0);
|
||||
}
|
||||
|
||||
/** \returns a fixed-size expression of the last coefficients of *this.
|
||||
@ -355,8 +353,7 @@ MatrixBase<Derived>::start() const
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<int Size>
|
||||
inline Block<Derived, ei_traits<Derived>::RowsAtCompileTime == 1 ? 1 : Size,
|
||||
ei_traits<Derived>::ColsAtCompileTime == 1 ? 1 : Size>
|
||||
inline typename MatrixBase<Derived>::template SubVectorReturnType<Size>::Type
|
||||
MatrixBase<Derived>::end()
|
||||
{
|
||||
ei_assert(IsVectorAtCompileTime);
|
||||
@ -370,8 +367,7 @@ MatrixBase<Derived>::end()
|
||||
/** This is the const version of end<int>.*/
|
||||
template<typename Derived>
|
||||
template<int Size>
|
||||
inline const Block<Derived, ei_traits<Derived>::RowsAtCompileTime == 1 ? 1 : Size,
|
||||
ei_traits<Derived>::ColsAtCompileTime == 1 ? 1 : Size>
|
||||
inline const typename MatrixBase<Derived>::template SubVectorReturnType<Size>::Type
|
||||
MatrixBase<Derived>::end() const
|
||||
{
|
||||
ei_assert(IsVectorAtCompileTime);
|
||||
|
@ -172,7 +172,7 @@ MatrixBase<Derived>::create(const CustomNullaryOp& func)
|
||||
* \sa class CwiseNullaryOp
|
||||
*/
|
||||
template<typename Derived>
|
||||
const CwiseNullaryOp<ei_scalar_constant_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
const typename MatrixBase<Derived>::ConstantReturnType
|
||||
MatrixBase<Derived>::constant(int rows, int cols, const Scalar& value)
|
||||
{
|
||||
return create(rows, cols, ei_scalar_constant_op<Scalar>(value));
|
||||
@ -194,7 +194,7 @@ MatrixBase<Derived>::constant(int rows, int cols, const Scalar& value)
|
||||
* \sa class CwiseNullaryOp
|
||||
*/
|
||||
template<typename Derived>
|
||||
const CwiseNullaryOp<ei_scalar_constant_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
const typename MatrixBase<Derived>::ConstantReturnType
|
||||
MatrixBase<Derived>::constant(int size, const Scalar& value)
|
||||
{
|
||||
return create(size, ei_scalar_constant_op<Scalar>(value));
|
||||
@ -210,7 +210,7 @@ MatrixBase<Derived>::constant(int size, const Scalar& value)
|
||||
* \sa class CwiseNullaryOp
|
||||
*/
|
||||
template<typename Derived>
|
||||
const CwiseNullaryOp<ei_scalar_constant_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
const typename MatrixBase<Derived>::ConstantReturnType
|
||||
MatrixBase<Derived>::constant(const Scalar& value)
|
||||
{
|
||||
return create(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_constant_op<Scalar>(value));
|
||||
@ -254,7 +254,7 @@ Derived& MatrixBase<Derived>::setConstant(const Scalar& value)
|
||||
* \sa zero(), zero(int)
|
||||
*/
|
||||
template<typename Derived>
|
||||
const CwiseNullaryOp<ei_scalar_constant_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
const typename MatrixBase<Derived>::ConstantReturnType
|
||||
MatrixBase<Derived>::zero(int rows, int cols)
|
||||
{
|
||||
return constant(rows, cols, Scalar(0));
|
||||
@ -277,7 +277,7 @@ MatrixBase<Derived>::zero(int rows, int cols)
|
||||
* \sa zero(), zero(int,int)
|
||||
*/
|
||||
template<typename Derived>
|
||||
const CwiseNullaryOp<ei_scalar_constant_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
const typename MatrixBase<Derived>::ConstantReturnType
|
||||
MatrixBase<Derived>::zero(int size)
|
||||
{
|
||||
return constant(size, Scalar(0));
|
||||
@ -294,7 +294,7 @@ MatrixBase<Derived>::zero(int size)
|
||||
* \sa zero(int), zero(int,int)
|
||||
*/
|
||||
template<typename Derived>
|
||||
const CwiseNullaryOp<ei_scalar_constant_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
const typename MatrixBase<Derived>::ConstantReturnType
|
||||
MatrixBase<Derived>::zero()
|
||||
{
|
||||
return constant(Scalar(0));
|
||||
@ -349,7 +349,7 @@ Derived& MatrixBase<Derived>::setZero()
|
||||
* \sa ones(), ones(int), isOnes(), class Ones
|
||||
*/
|
||||
template<typename Derived>
|
||||
const CwiseNullaryOp<ei_scalar_constant_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
const typename MatrixBase<Derived>::ConstantReturnType
|
||||
MatrixBase<Derived>::ones(int rows, int cols)
|
||||
{
|
||||
return constant(rows, cols, Scalar(1));
|
||||
@ -372,7 +372,7 @@ MatrixBase<Derived>::ones(int rows, int cols)
|
||||
* \sa ones(), ones(int,int), isOnes(), class Ones
|
||||
*/
|
||||
template<typename Derived>
|
||||
const CwiseNullaryOp<ei_scalar_constant_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
const typename MatrixBase<Derived>::ConstantReturnType
|
||||
MatrixBase<Derived>::ones(int size)
|
||||
{
|
||||
return constant(size, Scalar(1));
|
||||
@ -389,7 +389,7 @@ MatrixBase<Derived>::ones(int size)
|
||||
* \sa ones(int), ones(int,int), isOnes(), class Ones
|
||||
*/
|
||||
template<typename Derived>
|
||||
const CwiseNullaryOp<ei_scalar_constant_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
const typename MatrixBase<Derived>::ConstantReturnType
|
||||
MatrixBase<Derived>::ones()
|
||||
{
|
||||
return constant(Scalar(1));
|
||||
|
@ -165,7 +165,7 @@ MatrixBase<Derived>::cast() const
|
||||
|
||||
/** \relates MatrixBase */
|
||||
template<typename Derived>
|
||||
inline const CwiseUnaryOp<ei_scalar_multiple_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
inline const typename MatrixBase<Derived>::ScalarMultipleReturnType
|
||||
MatrixBase<Derived>::operator*(const Scalar& scalar) const
|
||||
{
|
||||
return CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, Derived>
|
||||
|
@ -132,7 +132,7 @@ inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<
|
||||
* \sa norm()
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline const CwiseUnaryOp<ei_scalar_multiple_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
inline const typename MatrixBase<Derived>::ScalarMultipleReturnType
|
||||
MatrixBase<Derived>::normalized() const
|
||||
{
|
||||
return (*this) * (RealScalar(1)/norm());
|
||||
|
@ -163,6 +163,20 @@ template<typename Derived> class MatrixBase
|
||||
* \sa rows(), cols(), IsVectorAtCompileTime. */
|
||||
inline bool isVector() const { return rows()==1 || cols()==1; }
|
||||
//@}
|
||||
|
||||
/// \name Default return types
|
||||
//@{
|
||||
/** Represents a constant matrix */
|
||||
typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType;
|
||||
/** Represents a vector block of a matrix */
|
||||
template<int Size> struct SubVectorReturnType
|
||||
{
|
||||
typedef Block<Derived, (ei_traits<Derived>::RowsAtCompileTime == 1 ? 1 : Size),
|
||||
(ei_traits<Derived>::ColsAtCompileTime == 1 ? 1 : Size)> Type;
|
||||
};
|
||||
/** Represents a product scalar-matrix */
|
||||
typedef CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, Derived> ScalarMultipleReturnType;
|
||||
//@}
|
||||
|
||||
/// \name Copying and initialization
|
||||
//@{
|
||||
@ -244,8 +258,7 @@ template<typename Derived> class MatrixBase
|
||||
Derived& operator*=(const Scalar& other);
|
||||
Derived& operator/=(const Scalar& other);
|
||||
|
||||
const CwiseUnaryOp<ei_scalar_multiple_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
operator*(const Scalar& scalar) const;
|
||||
const ScalarMultipleReturnType operator*(const Scalar& scalar) const;
|
||||
const CwiseUnaryOp<ei_scalar_quotient1_op<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
operator/(const Scalar& scalar) const;
|
||||
|
||||
@ -274,7 +287,7 @@ template<typename Derived> class MatrixBase
|
||||
Scalar dot(const MatrixBase<OtherDerived>& other) const;
|
||||
RealScalar norm2() const;
|
||||
RealScalar norm() const;
|
||||
const CwiseUnaryOp<ei_scalar_multiple_op<typename ei_traits<Derived>::Scalar>, Derived> normalized() const;
|
||||
const ScalarMultipleReturnType normalized() const;
|
||||
|
||||
Transpose<Derived> transpose();
|
||||
const Transpose<Derived> transpose() const;
|
||||
@ -320,18 +333,14 @@ template<typename Derived> class MatrixBase
|
||||
template<int CRows, int CCols> const Block<Derived, CRows, CCols> corner(CornerType type) const;
|
||||
|
||||
template<int Size>
|
||||
Block<Derived, ei_traits<Derived>::RowsAtCompileTime == 1 ? 1 : Size,
|
||||
ei_traits<Derived>::ColsAtCompileTime == 1 ? 1 : Size> start();
|
||||
typename SubVectorReturnType<Size>::Type start(void);
|
||||
template<int Size>
|
||||
const Block<Derived, ei_traits<Derived>::RowsAtCompileTime == 1 ? 1 : Size,
|
||||
ei_traits<Derived>::ColsAtCompileTime == 1 ? 1 : Size> start() const;
|
||||
const typename SubVectorReturnType<Size>::Type start() const;
|
||||
|
||||
template<int Size>
|
||||
Block<Derived, ei_traits<Derived>::RowsAtCompileTime == 1 ? 1 : Size,
|
||||
ei_traits<Derived>::ColsAtCompileTime == 1 ? 1 : Size> end();
|
||||
typename SubVectorReturnType<Size>::Type end();
|
||||
template<int Size>
|
||||
const Block<Derived, ei_traits<Derived>::RowsAtCompileTime == 1 ? 1 : Size,
|
||||
ei_traits<Derived>::ColsAtCompileTime == 1 ? 1 : Size> end() const;
|
||||
const typename SubVectorReturnType<Size>::Type end() const;
|
||||
|
||||
DiagonalCoeffs<Derived> diagonal();
|
||||
const DiagonalCoeffs<Derived> diagonal() const;
|
||||
@ -339,11 +348,11 @@ template<typename Derived> class MatrixBase
|
||||
|
||||
/// \name Generating special matrices
|
||||
//@{
|
||||
static const CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived>
|
||||
static const ConstantReturnType
|
||||
constant(int rows, int cols, const Scalar& value);
|
||||
static const CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived>
|
||||
static const ConstantReturnType
|
||||
constant(int size, const Scalar& value);
|
||||
static const CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived>
|
||||
static const ConstantReturnType
|
||||
constant(const Scalar& value);
|
||||
|
||||
template<typename CustomNullaryOp>
|
||||
@ -359,12 +368,12 @@ template<typename Derived> class MatrixBase
|
||||
static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> random(int rows, int cols);
|
||||
static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> random(int size);
|
||||
static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> random();
|
||||
static const CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> zero(int rows, int cols);
|
||||
static const CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> zero(int size);
|
||||
static const CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> zero();
|
||||
static const CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ones(int rows, int cols);
|
||||
static const CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ones(int size);
|
||||
static const CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ones();
|
||||
static const ConstantReturnType zero(int rows, int cols);
|
||||
static const ConstantReturnType zero(int size);
|
||||
static const ConstantReturnType zero();
|
||||
static const ConstantReturnType ones(int rows, int cols);
|
||||
static const ConstantReturnType ones(int size);
|
||||
static const ConstantReturnType ones();
|
||||
static const CwiseNullaryOp<ei_scalar_identity_op<Scalar>,Derived> identity();
|
||||
static const CwiseNullaryOp<ei_scalar_identity_op<Scalar>,Derived> identity(int rows, int cols);
|
||||
|
||||
|
@ -167,13 +167,13 @@ template<typename T> class ei_product_eval_to_column_major
|
||||
template<typename T, int n=1> struct ei_product_nested_rhs
|
||||
{
|
||||
typedef typename ei_meta_if<
|
||||
ei_is_temporary<T>::ret && !(ei_traits<T>::Flags & RowMajorBit),
|
||||
(ei_is_temporary<T>::ret && !(ei_traits<T>::Flags & RowMajorBit)),
|
||||
T,
|
||||
typename ei_meta_if<
|
||||
(ei_traits<T>::Flags & EvalBeforeNestingBit)
|
||||
((ei_traits<T>::Flags & EvalBeforeNestingBit)
|
||||
|| (ei_traits<T>::Flags & RowMajorBit)
|
||||
|| (!(ei_traits<T>::Flags & DirectAccessBit))
|
||||
|| (n+1) * NumTraits<typename ei_traits<T>::Scalar>::ReadCost < (n-1) * T::CoeffReadCost,
|
||||
|| (n+1) * (NumTraits<typename ei_traits<T>::Scalar>::ReadCost) < (n-1) * T::CoeffReadCost),
|
||||
typename ei_product_eval_to_column_major<T>::type,
|
||||
const T&
|
||||
>::ret
|
||||
@ -185,10 +185,10 @@ template<typename T, int n=1> struct ei_product_nested_lhs
|
||||
typedef typename ei_meta_if<
|
||||
ei_is_temporary<T>::ret && !(ei_traits<T>::Flags & RowMajorBit),
|
||||
T,
|
||||
typename ei_meta_if<
|
||||
typename ei_meta_if<(
|
||||
(ei_traits<T>::Flags & EvalBeforeNestingBit)
|
||||
|| (!(ei_traits<T>::Flags & DirectAccessBit))
|
||||
|| (n+1) * NumTraits<typename ei_traits<T>::Scalar>::ReadCost < (n-1) * T::CoeffReadCost,
|
||||
|| (n+1) * (NumTraits<typename ei_traits<T>::Scalar>::ReadCost) < (n-1) * T::CoeffReadCost),
|
||||
typename ei_eval<T>::type,
|
||||
const T&
|
||||
>::ret
|
||||
|
@ -135,7 +135,7 @@ typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
|
||||
typedef typename Base::PacketScalar PacketScalar; \
|
||||
typedef typename Eigen::ei_nested<Derived>::type Nested; \
|
||||
typedef typename Eigen::ei_eval<Derived>::type Eval; \
|
||||
typedef Eigen::Flagged<Derived, TemporaryBit, 0> Temporary; \
|
||||
typedef Eigen::Flagged<Derived, Eigen::TemporaryBit, 0> Temporary; \
|
||||
enum { RowsAtCompileTime = Base::RowsAtCompileTime, \
|
||||
ColsAtCompileTime = Base::ColsAtCompileTime, \
|
||||
MaxRowsAtCompileTime = Base::MaxRowsAtCompileTime, \
|
||||
|
@ -194,7 +194,7 @@ template<typename T> struct ei_unconst<const T> { typedef T type; };
|
||||
|
||||
template<typename T> struct ei_is_temporary
|
||||
{
|
||||
enum { ret = ei_traits<T>::Flags & TemporaryBit };
|
||||
enum { ret = int(ei_traits<T>::Flags) & TemporaryBit };
|
||||
};
|
||||
|
||||
template<typename T, int n=1> struct ei_nested
|
||||
|
Loading…
x
Reference in New Issue
Block a user