2008-06-26 23:22:26 +00:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
2009-05-22 20:25:33 +02:00
|
|
|
// for linear algebra.
|
2008-06-26 23:22:26 +00:00
|
|
|
//
|
2011-11-28 16:36:37 +01:00
|
|
|
// Copyright (C) 2008-2011 Gael Guennebaud <gael.guennebaud@inria.fr>
|
2008-06-26 23:22:26 +00: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/.
|
2008-06-26 23:22:26 +00:00
|
|
|
|
|
|
|
|
#ifndef EIGEN_SPARSEMATRIXBASE_H
|
|
|
|
|
#define EIGEN_SPARSEMATRIXBASE_H
|
|
|
|
|
|
2012-04-15 11:06:28 +01:00
|
|
|
namespace Eigen {
|
|
|
|
|
|
2011-11-28 16:36:37 +01:00
|
|
|
/** \ingroup SparseCore_Module
|
2009-05-19 09:40:00 +02:00
|
|
|
*
|
|
|
|
|
* \class SparseMatrixBase
|
|
|
|
|
*
|
|
|
|
|
* \brief Base class of any sparse matrices or sparse expressions
|
|
|
|
|
*
|
2011-02-13 22:50:57 +00:00
|
|
|
* \tparam Derived
|
2009-05-19 09:40:00 +02:00
|
|
|
*
|
2011-02-13 22:50:57 +00:00
|
|
|
* This class can be extended with the help of the plugin mechanism described on the page
|
|
|
|
|
* \ref TopicCustomizingEigen by defining the preprocessor symbol \c EIGEN_SPARSEMATRIXBASE_PLUGIN.
|
2009-05-19 09:40:00 +02:00
|
|
|
*/
|
2010-02-20 15:26:02 +01:00
|
|
|
template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
|
2008-06-26 23:22:26 +00:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2010-10-25 10:15:22 -04:00
|
|
|
typedef typename internal::traits<Derived>::Scalar Scalar;
|
|
|
|
|
typedef typename internal::packet_traits<Scalar>::type PacketScalar;
|
|
|
|
|
typedef typename internal::traits<Derived>::StorageKind StorageKind;
|
|
|
|
|
typedef typename internal::traits<Derived>::Index Index;
|
2011-10-11 11:28:13 +02:00
|
|
|
typedef typename internal::add_const_on_value_type_if_arithmetic<
|
|
|
|
|
typename internal::packet_traits<Scalar>::type
|
|
|
|
|
>::type PacketReturnType;
|
2010-05-30 16:00:58 -04:00
|
|
|
|
2009-11-17 16:04:19 +01:00
|
|
|
typedef SparseMatrixBase StorageBaseType;
|
2010-11-15 14:14:05 +01:00
|
|
|
typedef EigenBase<Derived> Base;
|
|
|
|
|
|
|
|
|
|
template<typename OtherDerived>
|
2014-06-20 15:42:13 +02:00
|
|
|
Derived& operator=(const EigenBase<OtherDerived> &other);
|
2009-01-14 14:24:10 +00:00
|
|
|
|
2008-06-26 23:22:26 +00:00
|
|
|
enum {
|
2009-01-14 14:24:10 +00:00
|
|
|
|
2010-10-25 10:15:22 -04:00
|
|
|
RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
|
2009-01-14 14:24:10 +00:00
|
|
|
/**< The number of rows at compile-time. This is just a copy of the value provided
|
|
|
|
|
* by the \a Derived type. If a value is not known at compile-time,
|
|
|
|
|
* it is set to the \a Dynamic constant.
|
|
|
|
|
* \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */
|
|
|
|
|
|
2010-10-25 10:15:22 -04:00
|
|
|
ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
|
2009-01-14 14:24:10 +00:00
|
|
|
/**< The number of columns at compile-time. This is just a copy of the value provided
|
|
|
|
|
* by the \a Derived type. If a value is not known at compile-time,
|
|
|
|
|
* it is set to the \a Dynamic constant.
|
|
|
|
|
* \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */
|
|
|
|
|
|
|
|
|
|
|
2010-10-25 10:15:22 -04:00
|
|
|
SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
|
|
|
|
|
internal::traits<Derived>::ColsAtCompileTime>::ret),
|
2009-01-14 14:24:10 +00:00
|
|
|
/**< This is equal to the number of coefficients, i.e. the number of
|
|
|
|
|
* rows times the number of columns, or to \a Dynamic if this is not
|
|
|
|
|
* known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */
|
|
|
|
|
|
|
|
|
|
MaxRowsAtCompileTime = RowsAtCompileTime,
|
|
|
|
|
MaxColsAtCompileTime = ColsAtCompileTime,
|
|
|
|
|
|
2010-10-25 10:15:22 -04:00
|
|
|
MaxSizeAtCompileTime = (internal::size_at_compile_time<MaxRowsAtCompileTime,
|
2009-01-14 14:24:10 +00:00
|
|
|
MaxColsAtCompileTime>::ret),
|
|
|
|
|
|
|
|
|
|
IsVectorAtCompileTime = RowsAtCompileTime == 1 || ColsAtCompileTime == 1,
|
|
|
|
|
/**< This is set to true if either the number of rows or the number of
|
|
|
|
|
* columns is known at compile-time to be equal to 1. Indeed, in that case,
|
|
|
|
|
* we are dealing with a column-vector (if there is only one column) or with
|
|
|
|
|
* a row-vector (if there is only one row). */
|
|
|
|
|
|
2010-10-25 10:15:22 -04:00
|
|
|
Flags = internal::traits<Derived>::Flags,
|
2009-01-14 14:24:10 +00:00
|
|
|
/**< This stores expression \ref flags flags which may or may not be inherited by new expressions
|
|
|
|
|
* constructed from this one. See the \ref flags "list of flags".
|
|
|
|
|
*/
|
2009-05-19 09:40:00 +02:00
|
|
|
|
2010-10-25 10:15:22 -04:00
|
|
|
CoeffReadCost = internal::traits<Derived>::CoeffReadCost,
|
2009-01-14 14:24:10 +00:00
|
|
|
/**< This is a rough measure of how expensive it is to read one coefficient from
|
|
|
|
|
* this expression.
|
|
|
|
|
*/
|
|
|
|
|
|
2009-11-16 18:19:08 +01:00
|
|
|
IsRowMajor = Flags&RowMajorBit ? 1 : 0,
|
2013-07-16 09:49:01 +02:00
|
|
|
|
|
|
|
|
InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? int(SizeAtCompileTime)
|
|
|
|
|
: int(IsRowMajor) ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
|
2009-11-16 18:19:08 +01:00
|
|
|
|
|
|
|
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
|
|
|
|
_HasDirectAccess = (int(Flags)&DirectAccessBit) ? 1 : 0 // workaround sunCC
|
|
|
|
|
#endif
|
2008-06-26 23:22:26 +00:00
|
|
|
};
|
|
|
|
|
|
2009-01-14 14:24:10 +00:00
|
|
|
/** \internal the return type of MatrixBase::adjoint() */
|
2010-10-25 22:13:49 +02:00
|
|
|
typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
|
2011-01-07 05:16:01 -05:00
|
|
|
CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, Eigen::Transpose<const Derived> >,
|
|
|
|
|
Transpose<const Derived>
|
2010-10-25 22:13:49 +02:00
|
|
|
>::type AdjointReturnType;
|
2009-01-14 14:24:10 +00:00
|
|
|
|
2011-01-07 05:16:01 -05:00
|
|
|
|
2013-07-19 11:46:54 +02:00
|
|
|
typedef SparseMatrix<Scalar, Flags&RowMajorBit ? RowMajor : ColMajor, Index> PlainObject;
|
2009-12-16 19:18:40 +01:00
|
|
|
|
2009-11-16 19:39:29 +01:00
|
|
|
|
2009-01-14 14:24:10 +00:00
|
|
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
|
|
|
|
/** This is the "real scalar" type; if the \a Scalar type is already real numbers
|
|
|
|
|
* (e.g. int, float or double) then \a RealScalar is just the same as \a Scalar. If
|
|
|
|
|
* \a Scalar is \a std::complex<T> then RealScalar is \a T.
|
|
|
|
|
*
|
|
|
|
|
* \sa class NumTraits
|
|
|
|
|
*/
|
|
|
|
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
|
|
|
|
|
2009-11-16 18:19:08 +01:00
|
|
|
/** \internal the return type of coeff()
|
|
|
|
|
*/
|
2010-10-25 22:13:49 +02:00
|
|
|
typedef typename internal::conditional<_HasDirectAccess, const Scalar&, Scalar>::type CoeffReturnType;
|
2009-11-16 18:19:08 +01:00
|
|
|
|
2009-11-17 10:11:27 +01:00
|
|
|
/** \internal Represents a matrix with all coefficients equal to one another*/
|
2010-10-25 10:15:22 -04:00
|
|
|
typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Matrix<Scalar,Dynamic,Dynamic> > ConstantReturnType;
|
2009-11-17 10:11:27 +01:00
|
|
|
|
2009-01-14 14:24:10 +00:00
|
|
|
/** type of the equivalent square matrix */
|
2010-06-11 07:56:50 -04:00
|
|
|
typedef Matrix<Scalar,EIGEN_SIZE_MAX(RowsAtCompileTime,ColsAtCompileTime),
|
|
|
|
|
EIGEN_SIZE_MAX(RowsAtCompileTime,ColsAtCompileTime)> SquareMatrixType;
|
2009-01-14 14:24:10 +00:00
|
|
|
|
2008-06-26 23:22:26 +00:00
|
|
|
inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
|
|
|
|
|
inline Derived& derived() { return *static_cast<Derived*>(this); }
|
|
|
|
|
inline Derived& const_cast_derived() const
|
|
|
|
|
{ return *static_cast<Derived*>(const_cast<SparseMatrixBase*>(this)); }
|
2009-01-14 14:24:10 +00:00
|
|
|
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
2008-06-26 23:22:26 +00:00
|
|
|
|
2012-01-11 11:00:30 -05:00
|
|
|
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase
|
|
|
|
|
# include "../plugins/CommonCwiseUnaryOps.h"
|
|
|
|
|
# include "../plugins/CommonCwiseBinaryOps.h"
|
|
|
|
|
# include "../plugins/MatrixCwiseUnaryOps.h"
|
|
|
|
|
# include "../plugins/MatrixCwiseBinaryOps.h"
|
2012-11-16 09:02:50 +01:00
|
|
|
# include "../plugins/BlockMethods.h"
|
2012-01-11 11:00:30 -05:00
|
|
|
# ifdef EIGEN_SPARSEMATRIXBASE_PLUGIN
|
|
|
|
|
# include EIGEN_SPARSEMATRIXBASE_PLUGIN
|
|
|
|
|
# endif
|
|
|
|
|
# undef EIGEN_CURRENT_STORAGE_BASE_CLASS
|
|
|
|
|
#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
|
|
|
|
|
|
2011-12-02 19:02:49 +01:00
|
|
|
/** \returns the number of rows. \sa cols() */
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Index rows() const { return derived().rows(); }
|
2011-12-02 19:02:49 +01:00
|
|
|
/** \returns the number of columns. \sa rows() */
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Index cols() const { return derived().cols(); }
|
2009-01-14 14:24:10 +00:00
|
|
|
/** \returns the number of coefficients, which is \a rows()*cols().
|
2011-12-02 19:02:49 +01:00
|
|
|
* \sa rows(), cols(). */
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Index size() const { return rows() * cols(); }
|
2009-01-14 14:24:10 +00:00
|
|
|
/** \returns the number of nonzero coefficients which is in practice the number
|
|
|
|
|
* of stored coefficients. */
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Index nonZeros() const { return derived().nonZeros(); }
|
2009-01-14 14:24:10 +00:00
|
|
|
/** \returns true if either the number of rows or the number of columns is equal to 1.
|
|
|
|
|
* In other words, this function returns
|
|
|
|
|
* \code rows()==1 || cols()==1 \endcode
|
|
|
|
|
* \sa rows(), cols(), IsVectorAtCompileTime. */
|
|
|
|
|
inline bool isVector() const { return rows()==1 || cols()==1; }
|
|
|
|
|
/** \returns the size of the storage major dimension,
|
|
|
|
|
* i.e., the number of columns for a columns major matrix, and the number of rows otherwise */
|
2010-05-30 16:00:58 -04:00
|
|
|
Index outerSize() const { return (int(Flags)&RowMajorBit) ? this->rows() : this->cols(); }
|
2009-01-14 14:24:10 +00:00
|
|
|
/** \returns the size of the inner dimension according to the storage order,
|
|
|
|
|
* i.e., the number of rows for a columns major matrix, and the number of cols otherwise */
|
2010-05-30 16:00:58 -04:00
|
|
|
Index innerSize() const { return (int(Flags)&RowMajorBit) ? this->cols() : this->rows(); }
|
2008-06-26 23:22:26 +00:00
|
|
|
|
|
|
|
|
bool isRValue() const { return m_isRValue; }
|
2008-06-29 21:29:12 +00:00
|
|
|
Derived& markAsRValue() { m_isRValue = true; return derived(); }
|
2008-06-26 23:22:26 +00:00
|
|
|
|
2009-01-14 14:24:10 +00:00
|
|
|
SparseMatrixBase() : m_isRValue(false) { /* TODO check flags */ }
|
2011-11-30 21:55:54 +01:00
|
|
|
|
2010-10-27 14:31:23 +02:00
|
|
|
|
|
|
|
|
template<typename OtherDerived>
|
2014-06-20 15:42:13 +02:00
|
|
|
Derived& operator=(const ReturnByValue<OtherDerived>& other);
|
2009-01-14 14:24:10 +00:00
|
|
|
|
2008-06-26 23:22:26 +00:00
|
|
|
template<typename OtherDerived>
|
2014-06-20 15:42:13 +02:00
|
|
|
inline Derived& operator=(const SparseMatrixBase<OtherDerived>& other);
|
|
|
|
|
|
|
|
|
|
inline Derived& operator=(const Derived& other);
|
2008-06-26 23:22:26 +00:00
|
|
|
|
2011-11-30 21:55:54 +01:00
|
|
|
protected:
|
2009-01-14 14:24:10 +00:00
|
|
|
|
2008-06-26 23:22:26 +00:00
|
|
|
template<typename OtherDerived>
|
2014-06-20 15:42:13 +02:00
|
|
|
inline Derived& assign(const OtherDerived& other);
|
2008-06-26 23:22:26 +00:00
|
|
|
|
2011-11-30 21:55:54 +01:00
|
|
|
template<typename OtherDerived>
|
2014-06-20 15:42:13 +02:00
|
|
|
inline void assignGeneric(const OtherDerived& other);
|
2011-11-30 21:55:54 +01:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2008-06-28 23:07:14 +00:00
|
|
|
template<typename Lhs, typename Rhs>
|
2010-06-25 10:26:24 +02:00
|
|
|
inline Derived& operator=(const SparseSparseProduct<Lhs,Rhs>& product);
|
2008-06-28 23:07:14 +00:00
|
|
|
|
2008-06-26 23:22:26 +00:00
|
|
|
friend std::ostream & operator << (std::ostream & s, const SparseMatrixBase& m)
|
|
|
|
|
{
|
2011-12-22 14:01:06 +01:00
|
|
|
typedef typename Derived::Nested Nested;
|
|
|
|
|
typedef typename internal::remove_all<Nested>::type NestedCleaned;
|
|
|
|
|
|
2008-06-26 23:22:26 +00:00
|
|
|
if (Flags&RowMajorBit)
|
|
|
|
|
{
|
2011-12-22 14:01:06 +01:00
|
|
|
const Nested nm(m.derived());
|
|
|
|
|
for (Index row=0; row<nm.outerSize(); ++row)
|
2008-06-26 23:22:26 +00:00
|
|
|
{
|
2010-05-30 16:00:58 -04:00
|
|
|
Index col = 0;
|
2011-12-22 14:01:06 +01:00
|
|
|
for (typename NestedCleaned::InnerIterator it(nm.derived(), row); it; ++it)
|
2008-06-26 23:22:26 +00:00
|
|
|
{
|
|
|
|
|
for ( ; col<it.index(); ++col)
|
|
|
|
|
s << "0 ";
|
2008-08-21 18:40:56 +00:00
|
|
|
s << it.value() << " ";
|
2008-06-29 21:29:12 +00:00
|
|
|
++col;
|
2008-06-26 23:22:26 +00:00
|
|
|
}
|
|
|
|
|
for ( ; col<m.cols(); ++col)
|
|
|
|
|
s << "0 ";
|
|
|
|
|
s << std::endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-12-22 14:01:06 +01:00
|
|
|
const Nested nm(m.derived());
|
2008-09-02 15:28:49 +00:00
|
|
|
if (m.cols() == 1) {
|
2010-05-30 16:00:58 -04:00
|
|
|
Index row = 0;
|
2011-12-22 14:01:06 +01:00
|
|
|
for (typename NestedCleaned::InnerIterator it(nm.derived(), 0); it; ++it)
|
2008-09-02 15:28:49 +00:00
|
|
|
{
|
|
|
|
|
for ( ; row<it.index(); ++row)
|
|
|
|
|
s << "0" << std::endl;
|
|
|
|
|
s << it.value() << std::endl;
|
|
|
|
|
++row;
|
|
|
|
|
}
|
|
|
|
|
for ( ; row<m.rows(); ++row)
|
|
|
|
|
s << "0" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-02-13 23:58:28 +01:00
|
|
|
SparseMatrix<Scalar, RowMajorBit, Index> trans = m;
|
|
|
|
|
s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit, Index> >&>(trans);
|
2008-09-02 15:28:49 +00:00
|
|
|
}
|
2008-06-26 23:22:26 +00:00
|
|
|
}
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-14 14:24:10 +00:00
|
|
|
template<typename OtherDerived>
|
|
|
|
|
Derived& operator+=(const SparseMatrixBase<OtherDerived>& other);
|
|
|
|
|
template<typename OtherDerived>
|
|
|
|
|
Derived& operator-=(const SparseMatrixBase<OtherDerived>& other);
|
|
|
|
|
|
2009-12-16 19:18:40 +01:00
|
|
|
Derived& operator*=(const Scalar& other);
|
|
|
|
|
Derived& operator/=(const Scalar& other);
|
|
|
|
|
|
|
|
|
|
#define EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE \
|
|
|
|
|
CwiseBinaryOp< \
|
2010-10-25 10:15:22 -04:00
|
|
|
internal::scalar_product_op< \
|
|
|
|
|
typename internal::scalar_product_traits< \
|
|
|
|
|
typename internal::traits<Derived>::Scalar, \
|
|
|
|
|
typename internal::traits<OtherDerived>::Scalar \
|
2009-12-16 19:18:40 +01:00
|
|
|
>::ReturnType \
|
|
|
|
|
>, \
|
2013-06-28 17:10:53 +02:00
|
|
|
const Derived, \
|
|
|
|
|
const OtherDerived \
|
2009-12-16 19:18:40 +01:00
|
|
|
>
|
|
|
|
|
|
|
|
|
|
template<typename OtherDerived>
|
|
|
|
|
EIGEN_STRONG_INLINE const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE
|
|
|
|
|
cwiseProduct(const MatrixBase<OtherDerived> &other) const;
|
2009-01-14 14:24:10 +00:00
|
|
|
|
2009-07-04 11:16:27 +02:00
|
|
|
// sparse * sparse
|
2009-01-14 14:24:10 +00:00
|
|
|
template<typename OtherDerived>
|
2010-06-25 10:26:24 +02:00
|
|
|
const typename SparseSparseProductReturnType<Derived,OtherDerived>::Type
|
2009-01-14 14:24:10 +00:00
|
|
|
operator*(const SparseMatrixBase<OtherDerived> &other) const;
|
2009-05-19 09:40:00 +02:00
|
|
|
|
2009-07-04 11:16:27 +02:00
|
|
|
// sparse * diagonal
|
|
|
|
|
template<typename OtherDerived>
|
|
|
|
|
const SparseDiagonalProduct<Derived,OtherDerived>
|
|
|
|
|
operator*(const DiagonalBase<OtherDerived> &other) const;
|
|
|
|
|
|
|
|
|
|
// diagonal * sparse
|
2009-07-07 11:39:19 +02:00
|
|
|
template<typename OtherDerived> friend
|
2009-07-04 11:16:27 +02:00
|
|
|
const SparseDiagonalProduct<OtherDerived,Derived>
|
|
|
|
|
operator*(const DiagonalBase<OtherDerived> &lhs, const SparseMatrixBase& rhs)
|
|
|
|
|
{ return SparseDiagonalProduct<OtherDerived,Derived>(lhs.derived(), rhs.derived()); }
|
|
|
|
|
|
2010-06-25 11:36:38 +02:00
|
|
|
/** dense * sparse (return a dense object unless it is an outer product) */
|
2009-05-19 09:40:00 +02:00
|
|
|
template<typename OtherDerived> friend
|
2010-06-25 11:36:38 +02:00
|
|
|
const typename DenseSparseProductReturnType<OtherDerived,Derived>::Type
|
2009-01-14 17:41:55 +00:00
|
|
|
operator*(const MatrixBase<OtherDerived>& lhs, const Derived& rhs)
|
2010-06-25 11:36:38 +02:00
|
|
|
{ return typename DenseSparseProductReturnType<OtherDerived,Derived>::Type(lhs.derived(),rhs); }
|
2009-05-19 09:40:00 +02:00
|
|
|
|
2010-06-25 11:36:38 +02:00
|
|
|
/** sparse * dense (returns a dense object unless it is an outer product) */
|
2009-01-14 17:41:55 +00:00
|
|
|
template<typename OtherDerived>
|
2010-06-25 11:36:38 +02:00
|
|
|
const typename SparseDenseProductReturnType<Derived,OtherDerived>::Type
|
2009-01-14 17:41:55 +00:00
|
|
|
operator*(const MatrixBase<OtherDerived> &other) const;
|
2012-02-08 18:22:48 +01:00
|
|
|
|
2012-06-07 16:18:00 +02:00
|
|
|
/** \returns an expression of P H P^-1 where H is the matrix represented by \c *this */
|
2012-02-08 18:22:48 +01:00
|
|
|
SparseSymmetricPermutationProduct<Derived,Upper|Lower> twistedBy(const PermutationMatrix<Dynamic,Dynamic,Index>& perm) const
|
|
|
|
|
{
|
|
|
|
|
return SparseSymmetricPermutationProduct<Derived,Upper|Lower>(derived(), perm);
|
|
|
|
|
}
|
2009-01-14 14:24:10 +00:00
|
|
|
|
|
|
|
|
template<typename OtherDerived>
|
|
|
|
|
Derived& operator*=(const SparseMatrixBase<OtherDerived>& other);
|
|
|
|
|
|
2009-12-22 17:37:11 +01:00
|
|
|
#ifdef EIGEN2_SUPPORT
|
2009-04-05 16:30:10 +00:00
|
|
|
// deprecated
|
2009-01-14 14:24:10 +00:00
|
|
|
template<typename OtherDerived>
|
2010-10-25 10:15:22 -04:00
|
|
|
typename internal::plain_matrix_type_column_major<OtherDerived>::type
|
2009-01-14 14:24:10 +00:00
|
|
|
solveTriangular(const MatrixBase<OtherDerived>& other) const;
|
|
|
|
|
|
2009-04-05 16:30:10 +00:00
|
|
|
// deprecated
|
2009-01-14 14:24:10 +00:00
|
|
|
template<typename OtherDerived>
|
|
|
|
|
void solveTriangularInPlace(MatrixBase<OtherDerived>& other) const;
|
2009-12-22 17:37:11 +01:00
|
|
|
#endif // EIGEN2_SUPPORT
|
2009-04-05 16:30:10 +00:00
|
|
|
|
|
|
|
|
template<int Mode>
|
2009-11-18 14:52:52 +01:00
|
|
|
inline const SparseTriangularView<Derived, Mode> triangularView() const;
|
|
|
|
|
|
|
|
|
|
template<unsigned int UpLo> inline const SparseSelfAdjointView<Derived, UpLo> selfadjointView() const;
|
|
|
|
|
template<unsigned int UpLo> inline SparseSelfAdjointView<Derived, UpLo> selfadjointView();
|
2009-01-14 14:24:10 +00:00
|
|
|
|
|
|
|
|
template<typename OtherDerived> Scalar dot(const MatrixBase<OtherDerived>& other) const;
|
|
|
|
|
template<typename OtherDerived> Scalar dot(const SparseMatrixBase<OtherDerived>& other) const;
|
|
|
|
|
RealScalar squaredNorm() const;
|
|
|
|
|
RealScalar norm() const;
|
2013-01-11 17:27:12 +01:00
|
|
|
RealScalar blueNorm() const;
|
2009-01-14 14:24:10 +00:00
|
|
|
|
2009-11-16 18:19:08 +01:00
|
|
|
Transpose<Derived> transpose() { return derived(); }
|
2011-01-07 05:16:01 -05:00
|
|
|
const Transpose<const Derived> transpose() const { return derived(); }
|
2009-12-01 13:16:51 +01:00
|
|
|
const AdjointReturnType adjoint() const { return transpose(); }
|
2009-01-14 14:24:10 +00:00
|
|
|
|
2012-11-16 09:02:50 +01:00
|
|
|
// inner-vector
|
|
|
|
|
typedef Block<Derived,IsRowMajor?1:Dynamic,IsRowMajor?Dynamic:1,true> InnerVectorReturnType;
|
|
|
|
|
typedef Block<const Derived,IsRowMajor?1:Dynamic,IsRowMajor?Dynamic:1,true> ConstInnerVectorReturnType;
|
|
|
|
|
InnerVectorReturnType innerVector(Index outer);
|
|
|
|
|
const ConstInnerVectorReturnType innerVector(Index outer) const;
|
|
|
|
|
|
|
|
|
|
// set of inner-vectors
|
|
|
|
|
Block<Derived,Dynamic,Dynamic,true> innerVectors(Index outerStart, Index outerSize);
|
|
|
|
|
const Block<const Derived,Dynamic,Dynamic,true> innerVectors(Index outerStart, Index outerSize) const;
|
2009-01-14 14:24:10 +00:00
|
|
|
|
2013-06-10 00:06:40 +02:00
|
|
|
/** \internal use operator= */
|
|
|
|
|
template<typename DenseDerived>
|
|
|
|
|
void evalTo(MatrixBase<DenseDerived>& dst) const
|
|
|
|
|
{
|
|
|
|
|
dst.setZero();
|
|
|
|
|
for (Index j=0; j<outerSize(); ++j)
|
|
|
|
|
for (typename Derived::InnerIterator i(derived(),j); i; ++i)
|
|
|
|
|
dst.coeffRef(i.row(),i.col()) = i.value();
|
|
|
|
|
}
|
2009-07-07 09:05:20 +02:00
|
|
|
|
2013-06-10 00:06:40 +02:00
|
|
|
Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime> toDense() const
|
|
|
|
|
{
|
|
|
|
|
return derived();
|
|
|
|
|
}
|
2009-01-14 14:24:10 +00:00
|
|
|
|
|
|
|
|
template<typename OtherDerived>
|
|
|
|
|
bool isApprox(const SparseMatrixBase<OtherDerived>& other,
|
2012-06-28 21:01:02 +02:00
|
|
|
const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const
|
2009-01-14 14:24:10 +00:00
|
|
|
{ return toDense().isApprox(other.toDense(),prec); }
|
|
|
|
|
|
|
|
|
|
template<typename OtherDerived>
|
|
|
|
|
bool isApprox(const MatrixBase<OtherDerived>& other,
|
2012-06-28 21:01:02 +02:00
|
|
|
const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const
|
2009-01-14 14:24:10 +00:00
|
|
|
{ return toDense().isApprox(other,prec); }
|
|
|
|
|
|
|
|
|
|
/** \returns the matrix or vector obtained by evaluating this expression.
|
|
|
|
|
*
|
|
|
|
|
* Notice that in the case of a plain matrix or vector (not an expression) this function just returns
|
|
|
|
|
* a const reference, in order to avoid a useless copy.
|
|
|
|
|
*/
|
2010-10-25 10:15:22 -04:00
|
|
|
inline const typename internal::eval<Derived>::type eval() const
|
|
|
|
|
{ return typename internal::eval<Derived>::type(derived()); }
|
2009-01-14 14:24:10 +00:00
|
|
|
|
|
|
|
|
Scalar sum() const;
|
2009-01-07 17:01:57 +00:00
|
|
|
|
2008-06-26 23:22:26 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
bool m_isRValue;
|
|
|
|
|
};
|
|
|
|
|
|
2012-04-15 11:06:28 +01:00
|
|
|
} // end namespace Eigen
|
|
|
|
|
|
2008-06-26 23:22:26 +00:00
|
|
|
#endif // EIGEN_SPARSEMATRIXBASE_H
|