mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
* added a Tridiagonalization class for selfadjoint matrices
* added MatrixBase::real()
* added the ability to extract a selfadjoint matrix from the
lower or upper part of a matrix, e.g.:
m.extract<Upper|SelfAdjoint>()
will ignore the strict lower part and return a selfadjoint.
This is compatible with ZeroDiag and UnitDiag.
This commit is contained in:
@@ -139,7 +139,7 @@ MatrixBase<Derived>::cwiseAbs2() const
|
||||
return derived();
|
||||
}
|
||||
|
||||
/** \returns an expression of the complex conjugate of *this.
|
||||
/** \returns an expression of the complex conjugate of \c *this.
|
||||
*
|
||||
* \sa adjoint() */
|
||||
template<typename Derived>
|
||||
@@ -149,6 +149,16 @@ MatrixBase<Derived>::conjugate() const
|
||||
return ConjugateReturnType(derived());
|
||||
}
|
||||
|
||||
/** \returns an expression of the real part of \c *this.
|
||||
*
|
||||
* \sa adjoint() */
|
||||
template<typename Derived>
|
||||
inline const typename MatrixBase<Derived>::RealReturnType
|
||||
MatrixBase<Derived>::real() const
|
||||
{
|
||||
return derived();
|
||||
}
|
||||
|
||||
/** \returns an expression of *this with the \a Scalar type casted to
|
||||
* \a NewScalar.
|
||||
*
|
||||
|
||||
@@ -77,7 +77,7 @@ template<typename MatrixType, unsigned int Mode> class Extract
|
||||
inline Scalar _coeff(int row, int col) const
|
||||
{
|
||||
if(Flags & LowerTriangularBit ? col>row : row>col)
|
||||
return (Scalar)0;
|
||||
return (Flags & SelfAdjointBit) ? ei_conj(m_matrix.coeff(col, row)) : (Scalar)0;
|
||||
if(Flags & UnitDiagBit)
|
||||
return col==row ? (Scalar)1 : m_matrix.coeff(row, col);
|
||||
else if(Flags & ZeroDiagBit)
|
||||
|
||||
@@ -204,6 +204,19 @@ template<typename Scalar, typename NewType>
|
||||
struct ei_functor_traits<ei_scalar_cast_op<Scalar,NewType> >
|
||||
{ enum { Cost = ei_is_same_type<Scalar, NewType>::ret ? 0 : NumTraits<NewType>::AddCost, IsVectorizable = false }; };
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to extract the real part of a complex
|
||||
*
|
||||
* \sa class CwiseUnaryOp, MatrixBase::real()
|
||||
*/
|
||||
template<typename Scalar>
|
||||
struct ei_scalar_real_op EIGEN_EMPTY_STRUCT {
|
||||
typedef typename NumTraits<Scalar>::Real result_type;
|
||||
inline result_type operator() (const Scalar& a) const { return ei_real(a); }
|
||||
};
|
||||
template<typename Scalar>
|
||||
struct ei_functor_traits<ei_scalar_real_op<Scalar> >
|
||||
{ enum { Cost = 0, IsVectorizable = false }; };
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to multiply a scalar by a fixed other one
|
||||
|
||||
@@ -197,6 +197,8 @@ template<typename Derived> class MatrixBase : public ArrayBase<Derived>
|
||||
CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Derived>,
|
||||
Derived&
|
||||
>::ret ConjugateReturnType;
|
||||
/** the return type of MatrixBase::real() */
|
||||
typedef CwiseUnaryOp<ei_scalar_real_op<Scalar>, Derived> RealReturnType;
|
||||
/** the return type of MatrixBase::adjoint() */
|
||||
typedef Transpose<NestByValue<typename ei_unref<ConjugateReturnType>::type> >
|
||||
AdjointReturnType;
|
||||
@@ -477,6 +479,7 @@ template<typename Derived> class MatrixBase : public ArrayBase<Derived>
|
||||
/// \name Coefficient-wise operations
|
||||
//@{
|
||||
const ConjugateReturnType conjugate() const;
|
||||
const RealReturnType real() const;
|
||||
|
||||
template<typename OtherDerived>
|
||||
const CwiseBinaryOp<ei_scalar_product_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
|
||||
|
||||
@@ -59,8 +59,6 @@ const unsigned int Upper = UpperTriangularBit;
|
||||
const unsigned int StrictlyUpper = UpperTriangularBit | ZeroDiagBit;
|
||||
const unsigned int Lower = LowerTriangularBit;
|
||||
const unsigned int StrictlyLower = LowerTriangularBit | ZeroDiagBit;
|
||||
|
||||
// additional possible values for the Mode parameter of part()
|
||||
const unsigned int SelfAdjoint = SelfAdjointBit;
|
||||
|
||||
// additional possible values for the Mode parameter of extract()
|
||||
|
||||
@@ -59,6 +59,7 @@ template<typename Scalar> struct ei_scalar_product_op;
|
||||
template<typename Scalar> struct ei_scalar_quotient_op;
|
||||
template<typename Scalar> struct ei_scalar_opposite_op;
|
||||
template<typename Scalar> struct ei_scalar_conjugate_op;
|
||||
template<typename Scalar> struct ei_scalar_real_op;
|
||||
template<typename Scalar> struct ei_scalar_abs_op;
|
||||
template<typename Scalar> struct ei_scalar_abs2_op;
|
||||
template<typename Scalar> struct ei_scalar_sqrt_op;
|
||||
|
||||
Reference in New Issue
Block a user