mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +08:00
Fix return nullary return types: it must be based on the PlainObject type instead of the expression type.
This commit is contained in:
parent
b3b3dcad05
commit
0848ba0a6e
@ -83,22 +83,10 @@ template<typename Derived> class ArrayBase
|
|||||||
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
/** \internal the plain matrix type corresponding to this expression. Note that is not necessarily
|
typedef typename Base::PlainObject PlainObject;
|
||||||
* exactly the return type of eval(): in the case of plain matrices, the return type of eval() is a const
|
|
||||||
* reference to a matrix, not a matrix! It is however guaranteed that the return type of eval() is either
|
|
||||||
* PlainObject or const PlainObject&.
|
|
||||||
*/
|
|
||||||
typedef Array<typename internal::traits<Derived>::Scalar,
|
|
||||||
internal::traits<Derived>::RowsAtCompileTime,
|
|
||||||
internal::traits<Derived>::ColsAtCompileTime,
|
|
||||||
AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),
|
|
||||||
internal::traits<Derived>::MaxRowsAtCompileTime,
|
|
||||||
internal::traits<Derived>::MaxColsAtCompileTime
|
|
||||||
> PlainObject;
|
|
||||||
|
|
||||||
|
|
||||||
/** \internal Represents a matrix with all coefficients equal to one another*/
|
/** \internal Represents a matrix with all coefficients equal to one another*/
|
||||||
typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Derived> ConstantReturnType;
|
typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,PlainObject> ConstantReturnType;
|
||||||
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
|
||||||
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase
|
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase
|
||||||
|
@ -113,10 +113,10 @@ class CwiseNullaryOp : public internal::dense_xpr_base< CwiseNullaryOp<NullaryOp
|
|||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
template<typename CustomNullaryOp>
|
template<typename CustomNullaryOp>
|
||||||
EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, Derived>
|
EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>
|
||||||
DenseBase<Derived>::NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func)
|
DenseBase<Derived>::NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func)
|
||||||
{
|
{
|
||||||
return CwiseNullaryOp<CustomNullaryOp, Derived>(rows, cols, func);
|
return CwiseNullaryOp<CustomNullaryOp, PlainObject>(rows, cols, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of a matrix defined by a custom functor \a func
|
/** \returns an expression of a matrix defined by a custom functor \a func
|
||||||
@ -139,12 +139,12 @@ DenseBase<Derived>::NullaryExpr(Index rows, Index cols, const CustomNullaryOp& f
|
|||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
template<typename CustomNullaryOp>
|
template<typename CustomNullaryOp>
|
||||||
EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, Derived>
|
EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>
|
||||||
DenseBase<Derived>::NullaryExpr(Index size, const CustomNullaryOp& func)
|
DenseBase<Derived>::NullaryExpr(Index size, const CustomNullaryOp& func)
|
||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||||
if(RowsAtCompileTime == 1) return CwiseNullaryOp<CustomNullaryOp, Derived>(1, size, func);
|
if(RowsAtCompileTime == 1) return CwiseNullaryOp<CustomNullaryOp, PlainObject>(1, size, func);
|
||||||
else return CwiseNullaryOp<CustomNullaryOp, Derived>(size, 1, func);
|
else return CwiseNullaryOp<CustomNullaryOp, PlainObject>(size, 1, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of a matrix defined by a custom functor \a func
|
/** \returns an expression of a matrix defined by a custom functor \a func
|
||||||
@ -158,10 +158,10 @@ DenseBase<Derived>::NullaryExpr(Index size, const CustomNullaryOp& func)
|
|||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
template<typename CustomNullaryOp>
|
template<typename CustomNullaryOp>
|
||||||
EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, Derived>
|
EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>
|
||||||
DenseBase<Derived>::NullaryExpr(const CustomNullaryOp& func)
|
DenseBase<Derived>::NullaryExpr(const CustomNullaryOp& func)
|
||||||
{
|
{
|
||||||
return CwiseNullaryOp<CustomNullaryOp, Derived>(RowsAtCompileTime, ColsAtCompileTime, func);
|
return CwiseNullaryOp<CustomNullaryOp, PlainObject>(RowsAtCompileTime, ColsAtCompileTime, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of a constant matrix of value \a value
|
/** \returns an expression of a constant matrix of value \a value
|
||||||
|
@ -178,6 +178,35 @@ template<typename Derived> class DenseBase
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum { IsPlainObjectBase = 0 };
|
enum { IsPlainObjectBase = 0 };
|
||||||
|
|
||||||
|
/** The plain matrix type corresponding to this expression.
|
||||||
|
* \sa PlainObject */
|
||||||
|
typedef Matrix<typename internal::traits<Derived>::Scalar,
|
||||||
|
internal::traits<Derived>::RowsAtCompileTime,
|
||||||
|
internal::traits<Derived>::ColsAtCompileTime,
|
||||||
|
AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),
|
||||||
|
internal::traits<Derived>::MaxRowsAtCompileTime,
|
||||||
|
internal::traits<Derived>::MaxColsAtCompileTime
|
||||||
|
> PlainMatrix;
|
||||||
|
|
||||||
|
/** The plain array type corresponding to this expression.
|
||||||
|
* \sa PlainObject */
|
||||||
|
typedef Array<typename internal::traits<Derived>::Scalar,
|
||||||
|
internal::traits<Derived>::RowsAtCompileTime,
|
||||||
|
internal::traits<Derived>::ColsAtCompileTime,
|
||||||
|
AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),
|
||||||
|
internal::traits<Derived>::MaxRowsAtCompileTime,
|
||||||
|
internal::traits<Derived>::MaxColsAtCompileTime
|
||||||
|
> PlainArray;
|
||||||
|
|
||||||
|
/** \brief The plain matrix or array type corresponding to this expression.
|
||||||
|
*
|
||||||
|
* This is not necessarily exactly the return type of eval(). In the case of plain matrices,
|
||||||
|
* the return type of eval() is a const reference to a matrix, not a matrix! It is however guaranteed
|
||||||
|
* that the return type of eval() is either PlainObject or const PlainObject&.
|
||||||
|
*/
|
||||||
|
typedef typename internal::conditional<internal::is_same<typename internal::traits<Derived>::XprKind,MatrixXpr >::value,
|
||||||
|
PlainMatrix, PlainArray>::type PlainObject;
|
||||||
|
|
||||||
/** \returns the number of nonzero coefficients which is in practice the number
|
/** \returns the number of nonzero coefficients which is in practice the number
|
||||||
* of stored coefficients. */
|
* of stored coefficients. */
|
||||||
@ -237,13 +266,12 @@ template<typename Derived> class DenseBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
|
||||||
/** \internal Represents a matrix with all coefficients equal to one another*/
|
/** \internal Represents a matrix with all coefficients equal to one another*/
|
||||||
typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Derived> ConstantReturnType;
|
typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,PlainObject> ConstantReturnType;
|
||||||
/** \internal Represents a vector with linearly spaced coefficients that allows sequential access only. */
|
/** \internal Represents a vector with linearly spaced coefficients that allows sequential access only. */
|
||||||
typedef CwiseNullaryOp<internal::linspaced_op<Scalar,false>,Derived> SequentialLinSpacedReturnType;
|
typedef CwiseNullaryOp<internal::linspaced_op<Scalar,false>,PlainObject> SequentialLinSpacedReturnType;
|
||||||
/** \internal Represents a vector with linearly spaced coefficients that allows random access. */
|
/** \internal Represents a vector with linearly spaced coefficients that allows random access. */
|
||||||
typedef CwiseNullaryOp<internal::linspaced_op<Scalar,true>,Derived> RandomAccessLinSpacedReturnType;
|
typedef CwiseNullaryOp<internal::linspaced_op<Scalar,true>,PlainObject> RandomAccessLinSpacedReturnType;
|
||||||
/** \internal the return type of MatrixBase::eigenvalues() */
|
/** \internal the return type of MatrixBase::eigenvalues() */
|
||||||
typedef Matrix<typename NumTraits<typename internal::traits<Derived>::Scalar>::Real, internal::traits<Derived>::ColsAtCompileTime, 1> EigenvaluesReturnType;
|
typedef Matrix<typename NumTraits<typename internal::traits<Derived>::Scalar>::Real, internal::traits<Derived>::ColsAtCompileTime, 1> EigenvaluesReturnType;
|
||||||
|
|
||||||
@ -322,13 +350,13 @@ template<typename Derived> class DenseBase
|
|||||||
LinSpaced(const Scalar& low, const Scalar& high);
|
LinSpaced(const Scalar& low, const Scalar& high);
|
||||||
|
|
||||||
template<typename CustomNullaryOp> EIGEN_DEVICE_FUNC
|
template<typename CustomNullaryOp> EIGEN_DEVICE_FUNC
|
||||||
static const CwiseNullaryOp<CustomNullaryOp, Derived>
|
static const CwiseNullaryOp<CustomNullaryOp, PlainObject>
|
||||||
NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func);
|
NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func);
|
||||||
template<typename CustomNullaryOp> EIGEN_DEVICE_FUNC
|
template<typename CustomNullaryOp> EIGEN_DEVICE_FUNC
|
||||||
static const CwiseNullaryOp<CustomNullaryOp, Derived>
|
static const CwiseNullaryOp<CustomNullaryOp, PlainObject>
|
||||||
NullaryExpr(Index size, const CustomNullaryOp& func);
|
NullaryExpr(Index size, const CustomNullaryOp& func);
|
||||||
template<typename CustomNullaryOp> EIGEN_DEVICE_FUNC
|
template<typename CustomNullaryOp> EIGEN_DEVICE_FUNC
|
||||||
static const CwiseNullaryOp<CustomNullaryOp, Derived>
|
static const CwiseNullaryOp<CustomNullaryOp, PlainObject>
|
||||||
NullaryExpr(const CustomNullaryOp& func);
|
NullaryExpr(const CustomNullaryOp& func);
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC static const ConstantReturnType Zero(Index rows, Index cols);
|
EIGEN_DEVICE_FUNC static const ConstantReturnType Zero(Index rows, Index cols);
|
||||||
@ -466,9 +494,10 @@ template<typename Derived> class DenseBase
|
|||||||
ConstColwiseReturnType colwise() const;
|
ConstColwiseReturnType colwise() const;
|
||||||
ColwiseReturnType colwise();
|
ColwiseReturnType colwise();
|
||||||
|
|
||||||
static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(Index rows, Index cols);
|
typedef CwiseNullaryOp<internal::scalar_random_op<Scalar>,PlainObject> RandomReturnType;
|
||||||
static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(Index size);
|
static const RandomReturnType Random(Index rows, Index cols);
|
||||||
static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random();
|
static const RandomReturnType Random(Index size);
|
||||||
|
static const RandomReturnType Random();
|
||||||
|
|
||||||
template<typename ThenDerived,typename ElseDerived>
|
template<typename ThenDerived,typename ElseDerived>
|
||||||
const Select<Derived,ThenDerived,ElseDerived>
|
const Select<Derived,ThenDerived,ElseDerived>
|
||||||
|
@ -101,23 +101,11 @@ template<typename Derived> class MatrixBase
|
|||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
inline Index diagonalSize() const { return (std::min)(rows(),cols()); }
|
inline Index diagonalSize() const { return (std::min)(rows(),cols()); }
|
||||||
|
|
||||||
/** \brief The plain matrix type corresponding to this expression.
|
typedef typename Base::PlainObject PlainObject;
|
||||||
*
|
|
||||||
* This is not necessarily exactly the return type of eval(). In the case of plain matrices,
|
|
||||||
* the return type of eval() is a const reference to a matrix, not a matrix! It is however guaranteed
|
|
||||||
* that the return type of eval() is either PlainObject or const PlainObject&.
|
|
||||||
*/
|
|
||||||
typedef Matrix<typename internal::traits<Derived>::Scalar,
|
|
||||||
internal::traits<Derived>::RowsAtCompileTime,
|
|
||||||
internal::traits<Derived>::ColsAtCompileTime,
|
|
||||||
AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),
|
|
||||||
internal::traits<Derived>::MaxRowsAtCompileTime,
|
|
||||||
internal::traits<Derived>::MaxColsAtCompileTime
|
|
||||||
> PlainObject;
|
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
/** \internal Represents a matrix with all coefficients equal to one another*/
|
/** \internal Represents a matrix with all coefficients equal to one another*/
|
||||||
typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Derived> ConstantReturnType;
|
typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,PlainObject> ConstantReturnType;
|
||||||
/** \internal the return type of MatrixBase::adjoint() */
|
/** \internal the return type of MatrixBase::adjoint() */
|
||||||
typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
|
typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
|
||||||
CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, ConstTransposeReturnType>,
|
CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, ConstTransposeReturnType>,
|
||||||
@ -126,7 +114,7 @@ template<typename Derived> class MatrixBase
|
|||||||
/** \internal Return type of eigenvalues() */
|
/** \internal Return type of eigenvalues() */
|
||||||
typedef Matrix<std::complex<RealScalar>, internal::traits<Derived>::ColsAtCompileTime, 1, ColMajor> EigenvaluesReturnType;
|
typedef Matrix<std::complex<RealScalar>, internal::traits<Derived>::ColsAtCompileTime, 1, ColMajor> EigenvaluesReturnType;
|
||||||
/** \internal the return type of identity */
|
/** \internal the return type of identity */
|
||||||
typedef CwiseNullaryOp<internal::scalar_identity_op<Scalar>,Derived> IdentityReturnType;
|
typedef CwiseNullaryOp<internal::scalar_identity_op<Scalar>,PlainObject> IdentityReturnType;
|
||||||
/** \internal the return type of unit vectors */
|
/** \internal the return type of unit vectors */
|
||||||
typedef Block<const CwiseNullaryOp<internal::scalar_identity_op<Scalar>, SquareMatrixType>,
|
typedef Block<const CwiseNullaryOp<internal::scalar_identity_op<Scalar>, SquareMatrixType>,
|
||||||
internal::traits<Derived>::RowsAtCompileTime,
|
internal::traits<Derived>::RowsAtCompileTime,
|
||||||
|
@ -53,7 +53,7 @@ struct functor_traits<scalar_random_op<Scalar> >
|
|||||||
* \sa DenseBase::setRandom(), DenseBase::Random(Index), DenseBase::Random()
|
* \sa DenseBase::setRandom(), DenseBase::Random(Index), DenseBase::Random()
|
||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
|
inline const typename DenseBase<Derived>::RandomReturnType
|
||||||
DenseBase<Derived>::Random(Index rows, Index cols)
|
DenseBase<Derived>::Random(Index rows, Index cols)
|
||||||
{
|
{
|
||||||
return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>());
|
return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>());
|
||||||
@ -84,7 +84,7 @@ DenseBase<Derived>::Random(Index rows, Index cols)
|
|||||||
* \sa DenseBase::setRandom(), DenseBase::Random(Index,Index), DenseBase::Random()
|
* \sa DenseBase::setRandom(), DenseBase::Random(Index,Index), DenseBase::Random()
|
||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
|
inline const typename DenseBase<Derived>::RandomReturnType
|
||||||
DenseBase<Derived>::Random(Index size)
|
DenseBase<Derived>::Random(Index size)
|
||||||
{
|
{
|
||||||
return NullaryExpr(size, internal::scalar_random_op<Scalar>());
|
return NullaryExpr(size, internal::scalar_random_op<Scalar>());
|
||||||
@ -110,7 +110,7 @@ DenseBase<Derived>::Random(Index size)
|
|||||||
* \sa DenseBase::setRandom(), DenseBase::Random(Index,Index), DenseBase::Random(Index)
|
* \sa DenseBase::setRandom(), DenseBase::Random(Index,Index), DenseBase::Random(Index)
|
||||||
*/
|
*/
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
|
inline const typename DenseBase<Derived>::RandomReturnType
|
||||||
DenseBase<Derived>::Random()
|
DenseBase<Derived>::Random()
|
||||||
{
|
{
|
||||||
return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>());
|
return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>());
|
||||||
|
Loading…
Reference in New Issue
Block a user