Add missing sparse matrix constructor from sparse self-adjoint views, and add documentation for sparse time selfadjoint matrix

This commit is contained in:
Gael Guennebaud 2013-06-28 22:56:26 +02:00
parent 9f035c876a
commit 99bef0957b
2 changed files with 19 additions and 2 deletions

View File

@ -647,6 +647,15 @@ class SparseMatrix
check_template_parameters(); check_template_parameters();
*this = other.derived(); *this = other.derived();
} }
/** Constructs a sparse matrix from the sparse selfadjoint view \a other */
template<typename OtherDerived, unsigned int UpLo>
inline SparseMatrix(const SparseSelfAdjointView<OtherDerived, UpLo>& other)
: m_outerSize(0), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)
{
check_template_parameters();
*this = other;
}
/** Copy constructor (it performs a deep copy) */ /** Copy constructor (it performs a deep copy) */
inline SparseMatrix(const SparseMatrix& other) inline SparseMatrix(const SparseMatrix& other)

View File

@ -69,7 +69,11 @@ template<typename MatrixType, unsigned int UpLo> class SparseSelfAdjointView
const _MatrixTypeNested& matrix() const { return m_matrix; } const _MatrixTypeNested& matrix() const { return m_matrix; }
_MatrixTypeNested& matrix() { return m_matrix.const_cast_derived(); } _MatrixTypeNested& matrix() { return m_matrix.const_cast_derived(); }
/** Sparse self-adjoint matrix times sparse matrix product */ /** \returns an expression of the matrix product between a sparse self-adjoint matrix \c *this and a sparse matrix \a rhs.
*
* Note that there is no algorithmic advantage of performing such a product compared to a general sparse-sparse matrix product.
* Indeed, the SparseSelfadjointView operand is first copied into a temporary SparseMatrix before computing the product.
*/
template<typename OtherDerived> template<typename OtherDerived>
SparseSparseProduct<SparseMatrix<Scalar, (internal::traits<OtherDerived>::Flags&RowMajorBit) ? RowMajor : ColMajor,Index>, OtherDerived> SparseSparseProduct<SparseMatrix<Scalar, (internal::traits<OtherDerived>::Flags&RowMajorBit) ? RowMajor : ColMajor,Index>, OtherDerived>
operator*(const SparseMatrixBase<OtherDerived>& rhs) const operator*(const SparseMatrixBase<OtherDerived>& rhs) const
@ -77,7 +81,11 @@ template<typename MatrixType, unsigned int UpLo> class SparseSelfAdjointView
return SparseSparseProduct<SparseMatrix<Scalar, (internal::traits<OtherDerived>::Flags&RowMajorBit) ? RowMajor : ColMajor, Index>, OtherDerived>(*this, rhs.derived()); return SparseSparseProduct<SparseMatrix<Scalar, (internal::traits<OtherDerived>::Flags&RowMajorBit) ? RowMajor : ColMajor, Index>, OtherDerived>(*this, rhs.derived());
} }
/**sparse matrix times Sparse self-adjoint matrix product */ /** \returns an expression of the matrix product between a sparse matrix \a lhs and a sparse self-adjoint matrix \a rhs.
*
* Note that there is no algorithmic advantage of performing such a product compared to a general sparse-sparse matrix product.
* Indeed, the SparseSelfadjointView operand is first copied into a temporary SparseMatrix before computing the product.
*/
template<typename OtherDerived> friend template<typename OtherDerived> friend
SparseSparseProduct<OtherDerived, SparseMatrix<Scalar, (internal::traits<OtherDerived>::Flags&RowMajorBit) ? RowMajor : ColMajor,Index> > SparseSparseProduct<OtherDerived, SparseMatrix<Scalar, (internal::traits<OtherDerived>::Flags&RowMajorBit) ? RowMajor : ColMajor,Index> >
operator*(const SparseMatrixBase<OtherDerived>& lhs, const SparseSelfAdjointView& rhs) operator*(const SparseMatrixBase<OtherDerived>& lhs, const SparseSelfAdjointView& rhs)