2009-07-06 23:43:20 +02:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
|
|
|
|
// for linear algebra.
|
|
|
|
|
//
|
2010-06-24 23:21:58 +02:00
|
|
|
// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
|
2009-07-06 23:43:20 +02:00
|
|
|
//
|
2012-07-13 14:42:47 -04:00
|
|
|
// 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/.
|
2009-07-06 23:43:20 +02:00
|
|
|
|
|
|
|
|
#ifndef EIGEN_SELFADJOINTMATRIX_H
|
|
|
|
|
#define EIGEN_SELFADJOINTMATRIX_H
|
|
|
|
|
|
2012-04-15 11:06:28 +01:00
|
|
|
namespace Eigen {
|
|
|
|
|
|
2009-07-06 23:43:20 +02:00
|
|
|
/** \class SelfAdjointView
|
2010-07-06 13:10:08 +01:00
|
|
|
* \ingroup Core_Module
|
2010-06-29 10:10:47 -04:00
|
|
|
*
|
2009-07-06 23:43:20 +02:00
|
|
|
*
|
|
|
|
|
* \brief Expression of a selfadjoint matrix from a triangular part of a dense matrix
|
|
|
|
|
*
|
|
|
|
|
* \param MatrixType the type of the dense matrix storing the coefficients
|
2011-05-03 17:08:14 +01:00
|
|
|
* \param TriangularPart can be either \c #Lower or \c #Upper
|
2009-07-06 23:43:20 +02:00
|
|
|
*
|
|
|
|
|
* This class is an expression of a sefladjoint matrix from a triangular part of a matrix
|
|
|
|
|
* with given dense storage of the coefficients. It is the return type of MatrixBase::selfadjointView()
|
|
|
|
|
* and most of the time this is the only way that it is used.
|
|
|
|
|
*
|
2011-03-31 10:02:02 +02:00
|
|
|
* \sa class TriangularBase, MatrixBase::selfadjointView()
|
2009-07-06 23:43:20 +02:00
|
|
|
*/
|
2010-10-25 10:15:22 -04:00
|
|
|
|
|
|
|
|
namespace internal {
|
2010-05-19 16:35:34 +02:00
|
|
|
template<typename MatrixType, unsigned int UpLo>
|
2010-10-25 10:15:22 -04:00
|
|
|
struct traits<SelfAdjointView<MatrixType, UpLo> > : traits<MatrixType>
|
2009-07-06 23:43:20 +02:00
|
|
|
{
|
2016-01-28 21:43:20 +01:00
|
|
|
typedef typename ref_selector<MatrixType>::non_const_type MatrixTypeNested;
|
2011-01-26 09:49:06 -05:00
|
|
|
typedef typename remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;
|
2009-07-06 23:43:20 +02:00
|
|
|
typedef MatrixType ExpressionType;
|
2014-07-22 12:54:03 +02:00
|
|
|
typedef typename MatrixType::PlainObject FullMatrixType;
|
2009-07-06 23:43:20 +02:00
|
|
|
enum {
|
2010-05-19 16:35:34 +02:00
|
|
|
Mode = UpLo | SelfAdjoint,
|
2014-10-07 18:29:28 +02:00
|
|
|
FlagsLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,
|
|
|
|
|
Flags = MatrixTypeNestedCleaned::Flags & (HereditaryBits|FlagsLvalueBit)
|
2014-03-11 13:33:44 +01:00
|
|
|
& (~(PacketAccessBit | DirectAccessBit | LinearAccessBit)) // FIXME these flags should be preserved
|
2009-07-06 23:43:20 +02:00
|
|
|
};
|
|
|
|
|
};
|
2010-10-25 10:15:22 -04:00
|
|
|
}
|
2009-07-06 23:43:20 +02:00
|
|
|
|
2016-12-20 16:33:53 +01:00
|
|
|
|
2013-12-13 18:09:07 +01:00
|
|
|
template<typename _MatrixType, unsigned int UpLo> class SelfAdjointView
|
|
|
|
|
: public TriangularBase<SelfAdjointView<_MatrixType, UpLo> >
|
2009-07-06 23:43:20 +02:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2013-12-13 18:09:07 +01:00
|
|
|
typedef _MatrixType MatrixType;
|
2009-07-06 23:43:20 +02:00
|
|
|
typedef TriangularBase<SelfAdjointView> Base;
|
2011-01-26 09:49:06 -05:00
|
|
|
typedef typename internal::traits<SelfAdjointView>::MatrixTypeNested MatrixTypeNested;
|
|
|
|
|
typedef typename internal::traits<SelfAdjointView>::MatrixTypeNestedCleaned MatrixTypeNestedCleaned;
|
2016-05-19 13:05:33 +02:00
|
|
|
typedef MatrixTypeNestedCleaned NestedExpression;
|
2010-07-25 20:29:07 +01:00
|
|
|
|
|
|
|
|
/** \brief The type of coefficients in this matrix */
|
2010-10-25 10:15:22 -04:00
|
|
|
typedef typename internal::traits<SelfAdjointView>::Scalar Scalar;
|
2014-12-04 22:48:53 +01:00
|
|
|
typedef typename MatrixType::StorageIndex StorageIndex;
|
2016-12-20 16:33:53 +01:00
|
|
|
typedef typename internal::remove_all<typename MatrixType::ConjugateReturnType>::type MatrixConjugateReturnType;
|
2010-05-30 16:00:58 -04:00
|
|
|
|
2009-07-06 23:43:20 +02:00
|
|
|
enum {
|
2013-12-13 18:09:07 +01:00
|
|
|
Mode = internal::traits<SelfAdjointView>::Mode,
|
2016-12-20 16:33:53 +01:00
|
|
|
Flags = internal::traits<SelfAdjointView>::Flags,
|
|
|
|
|
TransposeMode = ((Mode & Upper) ? Lower : 0) | ((Mode & Lower) ? Upper : 0)
|
2009-07-06 23:43:20 +02:00
|
|
|
};
|
2010-02-20 15:53:57 +01:00
|
|
|
typedef typename MatrixType::PlainObject PlainObject;
|
2009-07-06 23:43:20 +02:00
|
|
|
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2014-09-23 14:28:23 +02:00
|
|
|
explicit inline SelfAdjointView(MatrixType& matrix) : m_matrix(matrix)
|
2018-03-09 09:33:43 +01:00
|
|
|
{
|
|
|
|
|
EIGEN_STATIC_ASSERT(UpLo==Lower || UpLo==Upper,SELFADJOINTVIEW_ACCEPTS_UPPER_AND_LOWER_MODE_ONLY);
|
|
|
|
|
}
|
2009-07-06 23:43:20 +02:00
|
|
|
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Index rows() const { return m_matrix.rows(); }
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Index cols() const { return m_matrix.cols(); }
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Index outerStride() const { return m_matrix.outerStride(); }
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Index innerStride() const { return m_matrix.innerStride(); }
|
2010-05-19 16:35:34 +02:00
|
|
|
|
2009-07-06 23:43:20 +02:00
|
|
|
/** \sa MatrixBase::coeff()
|
|
|
|
|
* \warning the coordinates must fit into the referenced triangular part
|
|
|
|
|
*/
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Scalar coeff(Index row, Index col) const
|
2009-07-06 23:43:20 +02:00
|
|
|
{
|
|
|
|
|
Base::check_coordinates_internal(row, col);
|
|
|
|
|
return m_matrix.coeff(row, col);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \sa MatrixBase::coeffRef()
|
|
|
|
|
* \warning the coordinates must fit into the referenced triangular part
|
|
|
|
|
*/
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Scalar& coeffRef(Index row, Index col)
|
2009-07-06 23:43:20 +02:00
|
|
|
{
|
2014-10-07 18:29:28 +02:00
|
|
|
EIGEN_STATIC_ASSERT_LVALUE(SelfAdjointView);
|
2009-07-06 23:43:20 +02:00
|
|
|
Base::check_coordinates_internal(row, col);
|
2016-01-28 21:43:20 +01:00
|
|
|
return m_matrix.coeffRef(row, col);
|
2009-07-06 23:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \internal */
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2011-01-26 09:49:06 -05:00
|
|
|
const MatrixTypeNestedCleaned& _expression() const { return m_matrix; }
|
2009-07-06 23:43:20 +02:00
|
|
|
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2011-01-26 09:49:06 -05:00
|
|
|
const MatrixTypeNestedCleaned& nestedExpression() const { return m_matrix; }
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2016-01-28 21:43:20 +01:00
|
|
|
MatrixTypeNestedCleaned& nestedExpression() { return m_matrix; }
|
2010-03-21 11:28:03 -04:00
|
|
|
|
2013-12-13 18:09:07 +01:00
|
|
|
/** Efficient triangular matrix times vector/matrix product */
|
|
|
|
|
template<typename OtherDerived>
|
|
|
|
|
EIGEN_DEVICE_FUNC
|
|
|
|
|
const Product<SelfAdjointView,OtherDerived>
|
|
|
|
|
operator*(const MatrixBase<OtherDerived>& rhs) const
|
|
|
|
|
{
|
|
|
|
|
return Product<SelfAdjointView,OtherDerived>(*this, rhs.derived());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Efficient vector/matrix times triangular matrix product */
|
|
|
|
|
template<typename OtherDerived> friend
|
|
|
|
|
EIGEN_DEVICE_FUNC
|
|
|
|
|
const Product<OtherDerived,SelfAdjointView>
|
|
|
|
|
operator*(const MatrixBase<OtherDerived>& lhs, const SelfAdjointView& rhs)
|
|
|
|
|
{
|
|
|
|
|
return Product<OtherDerived,SelfAdjointView>(lhs.derived(),rhs);
|
|
|
|
|
}
|
2014-02-17 19:00:45 +01:00
|
|
|
|
|
|
|
|
friend EIGEN_DEVICE_FUNC
|
2016-06-14 11:26:57 +02:00
|
|
|
const SelfAdjointView<const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,MatrixType,product),UpLo>
|
2014-02-17 19:00:45 +01:00
|
|
|
operator*(const Scalar& s, const SelfAdjointView& mat)
|
|
|
|
|
{
|
|
|
|
|
return (s*mat.nestedExpression()).template selfadjointView<UpLo>();
|
|
|
|
|
}
|
2013-12-13 18:09:07 +01:00
|
|
|
|
2009-07-11 21:14:59 +02:00
|
|
|
/** Perform a symmetric rank 2 update of the selfadjoint matrix \c *this:
|
2010-11-19 17:16:28 +01:00
|
|
|
* \f$ this = this + \alpha u v^* + conj(\alpha) v u^* \f$
|
2009-07-23 21:22:51 +02:00
|
|
|
* \returns a reference to \c *this
|
2009-07-23 14:20:45 +02:00
|
|
|
*
|
2009-07-11 21:14:59 +02:00
|
|
|
* The vectors \a u and \c v \b must be column vectors, however they can be
|
|
|
|
|
* a adjoint expression without any overhead. Only the meaningful triangular
|
|
|
|
|
* part of the matrix is updated, the rest is left unchanged.
|
2009-07-27 13:17:39 +02:00
|
|
|
*
|
|
|
|
|
* \sa rankUpdate(const MatrixBase<DerivedU>&, Scalar)
|
2009-07-11 21:14:59 +02:00
|
|
|
*/
|
|
|
|
|
template<typename DerivedU, typename DerivedV>
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2013-04-12 15:26:55 +02:00
|
|
|
SelfAdjointView& rankUpdate(const MatrixBase<DerivedU>& u, const MatrixBase<DerivedV>& v, const Scalar& alpha = Scalar(1));
|
2009-07-11 21:14:59 +02:00
|
|
|
|
2009-07-23 19:01:20 +02:00
|
|
|
/** Perform a symmetric rank K update of the selfadjoint matrix \c *this:
|
2009-07-23 21:22:51 +02:00
|
|
|
* \f$ this = this + \alpha ( u u^* ) \f$ where \a u is a vector or matrix.
|
2009-07-27 13:17:39 +02:00
|
|
|
*
|
2009-07-23 21:22:51 +02:00
|
|
|
* \returns a reference to \c *this
|
2009-07-23 19:01:20 +02:00
|
|
|
*
|
|
|
|
|
* Note that to perform \f$ this = this + \alpha ( u^* u ) \f$ you can simply
|
|
|
|
|
* call this function with u.adjoint().
|
2009-07-27 13:17:39 +02:00
|
|
|
*
|
|
|
|
|
* \sa rankUpdate(const MatrixBase<DerivedU>&, const MatrixBase<DerivedV>&, Scalar)
|
2009-07-23 19:01:20 +02:00
|
|
|
*/
|
|
|
|
|
template<typename DerivedU>
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2013-04-12 15:26:55 +02:00
|
|
|
SelfAdjointView& rankUpdate(const MatrixBase<DerivedU>& u, const Scalar& alpha = Scalar(1));
|
2009-07-23 19:01:20 +02:00
|
|
|
|
2016-05-19 11:36:38 +02:00
|
|
|
/** \returns an expression of a triangular view extracted from the current selfadjoint view of a given triangular part
|
|
|
|
|
*
|
|
|
|
|
* The parameter \a TriMode can have the following values: \c #Upper, \c #StrictlyUpper, \c #UnitUpper,
|
|
|
|
|
* \c #Lower, \c #StrictlyLower, \c #UnitLower.
|
|
|
|
|
*
|
|
|
|
|
* If \c TriMode references the same triangular part than \c *this, then this method simply return a \c TriangularView of the nested expression,
|
|
|
|
|
* otherwise, the nested expression is first transposed, thus returning a \c TriangularView<Transpose<MatrixType>> object.
|
|
|
|
|
*
|
|
|
|
|
* \sa MatrixBase::triangularView(), class TriangularView
|
|
|
|
|
*/
|
|
|
|
|
template<unsigned int TriMode>
|
|
|
|
|
EIGEN_DEVICE_FUNC
|
|
|
|
|
typename internal::conditional<(TriMode&(Upper|Lower))==(UpLo&(Upper|Lower)),
|
|
|
|
|
TriangularView<MatrixType,TriMode>,
|
2016-05-19 13:01:51 +02:00
|
|
|
TriangularView<typename MatrixType::AdjointReturnType,TriMode> >::type
|
2016-05-19 11:36:38 +02:00
|
|
|
triangularView() const
|
|
|
|
|
{
|
2016-05-19 13:01:51 +02:00
|
|
|
typename internal::conditional<(TriMode&(Upper|Lower))==(UpLo&(Upper|Lower)), MatrixType&, typename MatrixType::ConstTransposeReturnType>::type tmp1(m_matrix);
|
|
|
|
|
typename internal::conditional<(TriMode&(Upper|Lower))==(UpLo&(Upper|Lower)), MatrixType&, typename MatrixType::AdjointReturnType>::type tmp2(tmp1);
|
2016-05-19 11:36:38 +02:00
|
|
|
return typename internal::conditional<(TriMode&(Upper|Lower))==(UpLo&(Upper|Lower)),
|
|
|
|
|
TriangularView<MatrixType,TriMode>,
|
2016-05-19 13:05:33 +02:00
|
|
|
TriangularView<typename MatrixType::AdjointReturnType,TriMode> >::type(tmp2);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 19:00:34 +02:00
|
|
|
typedef SelfAdjointView<const MatrixConjugateReturnType,UpLo> ConjugateReturnType;
|
2016-12-20 16:33:53 +01:00
|
|
|
/** \sa MatrixBase::conjugate() const */
|
|
|
|
|
EIGEN_DEVICE_FUNC
|
|
|
|
|
inline const ConjugateReturnType conjugate() const
|
|
|
|
|
{ return ConjugateReturnType(m_matrix.conjugate()); }
|
|
|
|
|
|
|
|
|
|
typedef SelfAdjointView<const typename MatrixType::AdjointReturnType,TransposeMode> AdjointReturnType;
|
|
|
|
|
/** \sa MatrixBase::adjoint() const */
|
|
|
|
|
EIGEN_DEVICE_FUNC
|
|
|
|
|
inline const AdjointReturnType adjoint() const
|
|
|
|
|
{ return AdjointReturnType(m_matrix.adjoint()); }
|
|
|
|
|
|
|
|
|
|
typedef SelfAdjointView<typename MatrixType::TransposeReturnType,TransposeMode> TransposeReturnType;
|
|
|
|
|
/** \sa MatrixBase::transpose() */
|
|
|
|
|
EIGEN_DEVICE_FUNC
|
|
|
|
|
inline TransposeReturnType transpose()
|
|
|
|
|
{
|
|
|
|
|
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
|
|
|
|
typename MatrixType::TransposeReturnType tmp(m_matrix);
|
|
|
|
|
return TransposeReturnType(tmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef SelfAdjointView<const typename MatrixType::ConstTransposeReturnType,TransposeMode> ConstTransposeReturnType;
|
|
|
|
|
/** \sa MatrixBase::transpose() const */
|
|
|
|
|
EIGEN_DEVICE_FUNC
|
|
|
|
|
inline const ConstTransposeReturnType transpose() const
|
|
|
|
|
{
|
|
|
|
|
return ConstTransposeReturnType(m_matrix.transpose());
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-19 13:05:33 +02:00
|
|
|
/** \returns a const expression of the main diagonal of the matrix \c *this
|
|
|
|
|
*
|
|
|
|
|
* This method simply returns the diagonal of the nested expression, thus by-passing the SelfAdjointView decorator.
|
|
|
|
|
*
|
|
|
|
|
* \sa MatrixBase::diagonal(), class Diagonal */
|
|
|
|
|
EIGEN_DEVICE_FUNC
|
|
|
|
|
typename MatrixType::ConstDiagonalReturnType diagonal() const
|
|
|
|
|
{
|
|
|
|
|
return typename MatrixType::ConstDiagonalReturnType(m_matrix);
|
2016-05-19 11:36:38 +02:00
|
|
|
}
|
|
|
|
|
|
2009-07-06 23:43:20 +02:00
|
|
|
/////////// Cholesky module ///////////
|
|
|
|
|
|
2010-02-20 15:53:57 +01:00
|
|
|
const LLT<PlainObject, UpLo> llt() const;
|
2010-06-03 22:22:14 +02:00
|
|
|
const LDLT<PlainObject, UpLo> ldlt() const;
|
2009-07-06 23:43:20 +02:00
|
|
|
|
2010-05-24 17:43:50 +01:00
|
|
|
/////////// Eigenvalue module ///////////
|
|
|
|
|
|
|
|
|
|
/** Real part of #Scalar */
|
|
|
|
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
|
|
|
|
/** Return type of eigenvalues() */
|
2010-10-25 10:15:22 -04:00
|
|
|
typedef Matrix<RealScalar, internal::traits<MatrixType>::ColsAtCompileTime, 1> EigenvaluesReturnType;
|
2010-05-24 17:43:50 +01:00
|
|
|
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2010-05-24 17:43:50 +01:00
|
|
|
EigenvaluesReturnType eigenvalues() const;
|
2013-08-01 16:26:57 +02:00
|
|
|
EIGEN_DEVICE_FUNC
|
2010-05-24 17:43:50 +01:00
|
|
|
RealScalar operatorNorm() const;
|
|
|
|
|
|
2009-07-06 23:43:20 +02:00
|
|
|
protected:
|
2012-02-03 23:18:26 +01:00
|
|
|
MatrixTypeNested m_matrix;
|
2009-07-06 23:43:20 +02:00
|
|
|
};
|
|
|
|
|
|
2009-07-23 10:05:38 +02:00
|
|
|
|
|
|
|
|
// template<typename OtherDerived, typename MatrixType, unsigned int UpLo>
|
2010-10-25 10:15:22 -04:00
|
|
|
// internal::selfadjoint_matrix_product_returntype<OtherDerived,SelfAdjointView<MatrixType,UpLo> >
|
2009-07-23 10:05:38 +02:00
|
|
|
// operator*(const MatrixBase<OtherDerived>& lhs, const SelfAdjointView<MatrixType,UpLo>& rhs)
|
|
|
|
|
// {
|
2010-10-25 10:15:22 -04:00
|
|
|
// return internal::matrix_selfadjoint_product_returntype<OtherDerived,SelfAdjointView<MatrixType,UpLo> >(lhs.derived(),rhs);
|
2009-07-23 10:05:38 +02:00
|
|
|
// }
|
|
|
|
|
|
2010-05-19 16:35:34 +02:00
|
|
|
// selfadjoint to dense matrix
|
|
|
|
|
|
2010-10-25 10:15:22 -04:00
|
|
|
namespace internal {
|
|
|
|
|
|
2013-12-13 18:09:07 +01:00
|
|
|
// TODO currently a selfadjoint expression has the form SelfAdjointView<.,.>
|
|
|
|
|
// in the future selfadjoint-ness should be defined by the expression traits
|
|
|
|
|
// such that Transpose<SelfAdjointView<.,.> > is valid. (currently TriangularBase::transpose() is overloaded to make it work)
|
|
|
|
|
template<typename MatrixType, unsigned int Mode>
|
|
|
|
|
struct evaluator_traits<SelfAdjointView<MatrixType,Mode> >
|
|
|
|
|
{
|
|
|
|
|
typedef typename storage_kind_to_evaluator_kind<typename MatrixType::StorageKind>::Kind Kind;
|
|
|
|
|
typedef SelfAdjointShape Shape;
|
|
|
|
|
};
|
2014-01-25 23:02:14 +01:00
|
|
|
|
2014-01-26 12:18:36 +01:00
|
|
|
template<int UpLo, int SetOpposite, typename DstEvaluatorTypeT, typename SrcEvaluatorTypeT, typename Functor, int Version>
|
|
|
|
|
class triangular_dense_assignment_kernel<UpLo,SelfAdjoint,SetOpposite,DstEvaluatorTypeT,SrcEvaluatorTypeT,Functor,Version>
|
|
|
|
|
: public generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version>
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
typedef generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version> Base;
|
|
|
|
|
typedef typename Base::DstXprType DstXprType;
|
|
|
|
|
typedef typename Base::SrcXprType SrcXprType;
|
|
|
|
|
using Base::m_dst;
|
|
|
|
|
using Base::m_src;
|
|
|
|
|
using Base::m_functor;
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
typedef typename Base::DstEvaluatorType DstEvaluatorType;
|
|
|
|
|
typedef typename Base::SrcEvaluatorType SrcEvaluatorType;
|
|
|
|
|
typedef typename Base::Scalar Scalar;
|
|
|
|
|
typedef typename Base::AssignmentTraits AssignmentTraits;
|
|
|
|
|
|
|
|
|
|
|
2014-10-13 17:18:26 +02:00
|
|
|
EIGEN_DEVICE_FUNC triangular_dense_assignment_kernel(DstEvaluatorType &dst, const SrcEvaluatorType &src, const Functor &func, DstXprType& dstExpr)
|
2014-01-26 12:18:36 +01:00
|
|
|
: Base(dst, src, func, dstExpr)
|
|
|
|
|
{}
|
|
|
|
|
|
2014-10-13 17:18:26 +02:00
|
|
|
EIGEN_DEVICE_FUNC void assignCoeff(Index row, Index col)
|
2014-01-26 12:18:36 +01:00
|
|
|
{
|
|
|
|
|
eigen_internal_assert(row!=col);
|
|
|
|
|
Scalar tmp = m_src.coeff(row,col);
|
|
|
|
|
m_functor.assignCoeff(m_dst.coeffRef(row,col), tmp);
|
|
|
|
|
m_functor.assignCoeff(m_dst.coeffRef(col,row), numext::conj(tmp));
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 17:18:26 +02:00
|
|
|
EIGEN_DEVICE_FUNC void assignDiagonalCoeff(Index id)
|
2014-01-26 12:18:36 +01:00
|
|
|
{
|
|
|
|
|
Base::assignCoeff(id,id);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 17:18:26 +02:00
|
|
|
EIGEN_DEVICE_FUNC void assignOppositeCoeff(Index, Index)
|
2014-01-26 12:18:36 +01:00
|
|
|
{ eigen_internal_assert(false && "should never be called"); }
|
|
|
|
|
};
|
|
|
|
|
|
2010-10-25 10:15:22 -04:00
|
|
|
} // end namespace internal
|
|
|
|
|
|
2009-07-06 23:43:20 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Implementation of MatrixBase methods
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
2017-01-04 22:01:50 +01:00
|
|
|
/** This is the const version of MatrixBase::selfadjointView() */
|
2009-07-06 23:43:20 +02:00
|
|
|
template<typename Derived>
|
2009-11-18 14:52:52 +01:00
|
|
|
template<unsigned int UpLo>
|
2017-03-01 11:47:47 -08:00
|
|
|
EIGEN_DEVICE_FUNC typename MatrixBase<Derived>::template ConstSelfAdjointViewReturnType<UpLo>::Type
|
2010-12-22 17:45:37 -05:00
|
|
|
MatrixBase<Derived>::selfadjointView() const
|
2009-07-06 23:43:20 +02:00
|
|
|
{
|
2014-09-23 14:28:23 +02:00
|
|
|
return typename ConstSelfAdjointViewReturnType<UpLo>::Type(derived());
|
2009-07-06 23:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
2017-01-04 22:01:50 +01:00
|
|
|
/** \returns an expression of a symmetric/self-adjoint view extracted from the upper or lower triangular part of the current matrix
|
|
|
|
|
*
|
|
|
|
|
* The parameter \a UpLo can be either \c #Upper or \c #Lower
|
|
|
|
|
*
|
|
|
|
|
* Example: \include MatrixBase_selfadjointView.cpp
|
|
|
|
|
* Output: \verbinclude MatrixBase_selfadjointView.out
|
|
|
|
|
*
|
|
|
|
|
* \sa class SelfAdjointView
|
|
|
|
|
*/
|
2009-07-06 23:43:20 +02:00
|
|
|
template<typename Derived>
|
2009-11-18 14:52:52 +01:00
|
|
|
template<unsigned int UpLo>
|
2017-03-01 11:47:47 -08:00
|
|
|
EIGEN_DEVICE_FUNC typename MatrixBase<Derived>::template SelfAdjointViewReturnType<UpLo>::Type
|
2010-12-22 17:45:37 -05:00
|
|
|
MatrixBase<Derived>::selfadjointView()
|
2009-07-06 23:43:20 +02:00
|
|
|
{
|
2014-09-23 14:28:23 +02:00
|
|
|
return typename SelfAdjointViewReturnType<UpLo>::Type(derived());
|
2009-07-06 23:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-15 11:06:28 +01:00
|
|
|
} // end namespace Eigen
|
|
|
|
|
|
2009-07-06 23:43:20 +02:00
|
|
|
#endif // EIGEN_SELFADJOINTMATRIX_H
|