mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-22 04:44:25 +08:00
Make permutation compatible with sparse matrices
This commit is contained in:
parent
929e77192c
commit
cd0ff253ec
@ -143,7 +143,7 @@ if(NOT MSVC)
|
|||||||
ei_add_cxx_compiler_flag("-Wpointer-arith")
|
ei_add_cxx_compiler_flag("-Wpointer-arith")
|
||||||
ei_add_cxx_compiler_flag("-Wwrite-strings")
|
ei_add_cxx_compiler_flag("-Wwrite-strings")
|
||||||
ei_add_cxx_compiler_flag("-Wformat-security")
|
ei_add_cxx_compiler_flag("-Wformat-security")
|
||||||
ei_add_cxx_compiler_flag("-Wshorten-64-to-32")
|
# ei_add_cxx_compiler_flag("-Wshorten-64-to-32")
|
||||||
ei_add_cxx_compiler_flag("-Wenum-conversion")
|
ei_add_cxx_compiler_flag("-Wenum-conversion")
|
||||||
ei_add_cxx_compiler_flag("-Wc++11-extensions")
|
ei_add_cxx_compiler_flag("-Wc++11-extensions")
|
||||||
|
|
||||||
|
@ -56,11 +56,8 @@ struct Sparse {};
|
|||||||
#include "src/SparseCore/SparseSelfAdjointView.h"
|
#include "src/SparseCore/SparseSelfAdjointView.h"
|
||||||
#include "src/SparseCore/SparseTriangularView.h"
|
#include "src/SparseCore/SparseTriangularView.h"
|
||||||
#include "src/SparseCore/TriangularSolver.h"
|
#include "src/SparseCore/TriangularSolver.h"
|
||||||
|
|
||||||
#ifndef EIGEN_TEST_EVALUATORS
|
|
||||||
#include "src/SparseCore/SparsePermutation.h"
|
#include "src/SparseCore/SparsePermutation.h"
|
||||||
#include "src/SparseCore/SparseFuzzy.h"
|
#include "src/SparseCore/SparseFuzzy.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
template<int RowCol,typename IndicesType,typename MatrixType, typename StorageKind> class PermutedImpl;
|
// TODO: this does not seems to be needed at all:
|
||||||
|
// template<int RowCol,typename IndicesType,typename MatrixType, typename StorageKind> class PermutedImpl;
|
||||||
|
|
||||||
/** \class PermutationBase
|
/** \class PermutationBase
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
@ -276,6 +277,7 @@ template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex
|
|||||||
struct traits<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType> >
|
struct traits<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType> >
|
||||||
: traits<Matrix<_StorageIndexType,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
|
: traits<Matrix<_StorageIndexType,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
|
||||||
{
|
{
|
||||||
|
typedef PermutationStorage StorageKind;
|
||||||
typedef Matrix<_StorageIndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
|
typedef Matrix<_StorageIndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
|
||||||
typedef typename IndicesType::Index Index;
|
typedef typename IndicesType::Index Index;
|
||||||
typedef _StorageIndexType StorageIndexType;
|
typedef _StorageIndexType StorageIndexType;
|
||||||
@ -397,6 +399,7 @@ template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex
|
|||||||
struct traits<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType>,_PacketAccess> >
|
struct traits<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType>,_PacketAccess> >
|
||||||
: traits<Matrix<_StorageIndexType,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
|
: traits<Matrix<_StorageIndexType,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
|
||||||
{
|
{
|
||||||
|
typedef PermutationStorage StorageKind;
|
||||||
typedef Map<const Matrix<_StorageIndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1>, _PacketAccess> IndicesType;
|
typedef Map<const Matrix<_StorageIndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1>, _PacketAccess> IndicesType;
|
||||||
typedef typename IndicesType::Index Index;
|
typedef typename IndicesType::Index Index;
|
||||||
typedef _StorageIndexType StorageIndexType;
|
typedef _StorageIndexType StorageIndexType;
|
||||||
@ -468,8 +471,6 @@ class Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageInd
|
|||||||
* \sa class PermutationBase, class PermutationMatrix
|
* \sa class PermutationBase, class PermutationMatrix
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct PermutationStorage {};
|
|
||||||
|
|
||||||
template<typename _IndicesType> class TranspositionsWrapper;
|
template<typename _IndicesType> class TranspositionsWrapper;
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template<typename _IndicesType>
|
template<typename _IndicesType>
|
||||||
@ -665,6 +666,8 @@ struct traits<Transpose<PermutationBase<Derived> > >
|
|||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
|
// TODO: the specificties should be handled by the evaluator,
|
||||||
|
// at the very least we should only specialize TransposeImpl
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
class Transpose<PermutationBase<Derived> >
|
class Transpose<PermutationBase<Derived> >
|
||||||
: public EigenBase<Transpose<PermutationBase<Derived> > >
|
: public EigenBase<Transpose<PermutationBase<Derived> > >
|
||||||
|
@ -443,6 +443,9 @@ enum Action {GetAction, SetAction};
|
|||||||
/** The type used to identify a dense storage. */
|
/** The type used to identify a dense storage. */
|
||||||
struct Dense {};
|
struct Dense {};
|
||||||
|
|
||||||
|
/** The type used to identify a permutation storage. */
|
||||||
|
struct PermutationStorage {};
|
||||||
|
|
||||||
/** The type used to identify a matrix expression */
|
/** The type used to identify a matrix expression */
|
||||||
struct MatrixXpr {};
|
struct MatrixXpr {};
|
||||||
|
|
||||||
|
@ -557,18 +557,26 @@ template <typename B, typename ScalarA, typename ScalarB> struct cwise_promote_s
|
|||||||
* K * dense -> dense
|
* K * dense -> dense
|
||||||
* diag * K -> K
|
* diag * K -> K
|
||||||
* K * diag -> K
|
* K * diag -> K
|
||||||
|
* Perm * K -> K
|
||||||
|
* K * Perm -> K
|
||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
template <typename A, typename B, int ProductTag> struct product_promote_storage_type;
|
template <typename A, typename B, int ProductTag> struct product_promote_storage_type;
|
||||||
|
|
||||||
template <typename A, int ProductTag> struct product_promote_storage_type<A, A, ProductTag> { typedef A ret;};
|
template <typename A, int ProductTag> struct product_promote_storage_type<A, A, ProductTag> { typedef A ret;};
|
||||||
template <int ProductTag> struct product_promote_storage_type<Dense, Dense, ProductTag> { typedef Dense ret;};
|
template <int ProductTag> struct product_promote_storage_type<Dense, Dense, ProductTag> { typedef Dense ret;};
|
||||||
template <typename A, int ProductTag> struct product_promote_storage_type<A, Dense, ProductTag> { typedef Dense ret; };
|
template <typename A, int ProductTag> struct product_promote_storage_type<A, Dense, ProductTag> { typedef Dense ret; };
|
||||||
template <typename B, int ProductTag> struct product_promote_storage_type<Dense, B, ProductTag> { typedef Dense ret; };
|
template <typename B, int ProductTag> struct product_promote_storage_type<Dense, B, ProductTag> { typedef Dense ret; };
|
||||||
template <typename A, int ProductTag> struct product_promote_storage_type<A, DiagonalShape, ProductTag> { typedef A ret; };
|
|
||||||
template <typename B, int ProductTag> struct product_promote_storage_type<DiagonalShape,B, ProductTag> { typedef B ret; };
|
template <typename A, int ProductTag> struct product_promote_storage_type<A, DiagonalShape, ProductTag> { typedef A ret; };
|
||||||
template <int ProductTag> struct product_promote_storage_type<Dense, DiagonalShape, ProductTag> { typedef Dense ret; };
|
template <typename B, int ProductTag> struct product_promote_storage_type<DiagonalShape, B, ProductTag> { typedef B ret; };
|
||||||
template <int ProductTag> struct product_promote_storage_type<DiagonalShape,Dense, ProductTag> { typedef Dense ret; };
|
template <int ProductTag> struct product_promote_storage_type<Dense, DiagonalShape, ProductTag> { typedef Dense ret; };
|
||||||
|
template <int ProductTag> struct product_promote_storage_type<DiagonalShape, Dense, ProductTag> { typedef Dense ret; };
|
||||||
|
|
||||||
|
template <typename A, int ProductTag> struct product_promote_storage_type<A, PermutationStorage, ProductTag> { typedef A ret; };
|
||||||
|
template <typename B, int ProductTag> struct product_promote_storage_type<PermutationStorage, B, ProductTag> { typedef B ret; };
|
||||||
|
template <int ProductTag> struct product_promote_storage_type<Dense, PermutationStorage, ProductTag> { typedef Dense ret; };
|
||||||
|
template <int ProductTag> struct product_promote_storage_type<PermutationStorage, Dense, ProductTag> { typedef Dense ret; };
|
||||||
|
|
||||||
/** \internal gives the plain matrix or array type to store a row/column/diagonal of a matrix type.
|
/** \internal gives the plain matrix or array type to store a row/column/diagonal of a matrix type.
|
||||||
* \param Scalar optional parameter allowing to pass a different scalar type than the one of the MatrixType.
|
* \param Scalar optional parameter allowing to pass a different scalar type than the one of the MatrixType.
|
||||||
|
@ -152,7 +152,7 @@ struct unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>
|
|||||||
typedef CwiseUnaryOp<UnaryOp, ArgType> XprType;
|
typedef CwiseUnaryOp<UnaryOp, ArgType> XprType;
|
||||||
|
|
||||||
class InnerIterator;
|
class InnerIterator;
|
||||||
class ReverseInnerIterator;
|
// class ReverseInnerIterator;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<UnaryOp>::Cost,
|
CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<UnaryOp>::Cost,
|
||||||
@ -163,7 +163,7 @@ struct unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef typename evaluator<ArgType>::InnerIterator EvalIterator;
|
typedef typename evaluator<ArgType>::InnerIterator EvalIterator;
|
||||||
typedef typename evaluator<ArgType>::ReverseInnerIterator EvalReverseIterator;
|
// typedef typename evaluator<ArgType>::ReverseInnerIterator EvalReverseIterator;
|
||||||
|
|
||||||
const UnaryOp m_functor;
|
const UnaryOp m_functor;
|
||||||
typename evaluator<ArgType>::nestedType m_argImpl;
|
typename evaluator<ArgType>::nestedType m_argImpl;
|
||||||
@ -192,28 +192,28 @@ class unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::InnerIterat
|
|||||||
Scalar& valueRef();
|
Scalar& valueRef();
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename UnaryOp, typename ArgType>
|
// template<typename UnaryOp, typename ArgType>
|
||||||
class unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::ReverseInnerIterator
|
// class unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::ReverseInnerIterator
|
||||||
: public unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::EvalReverseIterator
|
// : public unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::EvalReverseIterator
|
||||||
{
|
// {
|
||||||
typedef typename XprType::Scalar Scalar;
|
// typedef typename XprType::Scalar Scalar;
|
||||||
typedef typename unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::EvalReverseIterator Base;
|
// typedef typename unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::EvalReverseIterator Base;
|
||||||
public:
|
// public:
|
||||||
|
//
|
||||||
EIGEN_STRONG_INLINE ReverseInnerIterator(const XprType& unaryOp, typename XprType::Index outer)
|
// EIGEN_STRONG_INLINE ReverseInnerIterator(const XprType& unaryOp, typename XprType::Index outer)
|
||||||
: Base(unaryOp.derived().nestedExpression(),outer), m_functor(unaryOp.derived().functor())
|
// : Base(unaryOp.derived().nestedExpression(),outer), m_functor(unaryOp.derived().functor())
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
EIGEN_STRONG_INLINE ReverseInnerIterator& operator--()
|
// EIGEN_STRONG_INLINE ReverseInnerIterator& operator--()
|
||||||
{ Base::operator--(); return *this; }
|
// { Base::operator--(); return *this; }
|
||||||
|
//
|
||||||
EIGEN_STRONG_INLINE Scalar value() const { return m_functor(Base::value()); }
|
// EIGEN_STRONG_INLINE Scalar value() const { return m_functor(Base::value()); }
|
||||||
|
//
|
||||||
protected:
|
// protected:
|
||||||
const UnaryOp m_functor;
|
// const UnaryOp m_functor;
|
||||||
private:
|
// private:
|
||||||
Scalar& valueRef();
|
// Scalar& valueRef();
|
||||||
};
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ struct unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef typename evaluator<ArgType>::InnerIterator EvalIterator;
|
typedef typename evaluator<ArgType>::InnerIterator EvalIterator;
|
||||||
typedef typename evaluator<ArgType>::ReverseInnerIterator EvalReverseIterator;
|
// typedef typename evaluator<ArgType>::ReverseInnerIterator EvalReverseIterator;
|
||||||
|
|
||||||
const ViewOp m_functor;
|
const ViewOp m_functor;
|
||||||
typename evaluator<ArgType>::nestedType m_argImpl;
|
typename evaluator<ArgType>::nestedType m_argImpl;
|
||||||
@ -266,27 +266,27 @@ class unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::InnerItera
|
|||||||
const ViewOp m_functor;
|
const ViewOp m_functor;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename ViewOp, typename ArgType>
|
// template<typename ViewOp, typename ArgType>
|
||||||
class unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::ReverseInnerIterator
|
// class unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::ReverseInnerIterator
|
||||||
: public unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::EvalReverseIterator
|
// : public unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::EvalReverseIterator
|
||||||
{
|
// {
|
||||||
typedef typename XprType::Scalar Scalar;
|
// typedef typename XprType::Scalar Scalar;
|
||||||
typedef typename unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::EvalReverseIterator Base;
|
// typedef typename unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::EvalReverseIterator Base;
|
||||||
public:
|
// public:
|
||||||
|
//
|
||||||
EIGEN_STRONG_INLINE ReverseInnerIterator(const XprType& unaryOp, typename XprType::Index outer)
|
// EIGEN_STRONG_INLINE ReverseInnerIterator(const XprType& unaryOp, typename XprType::Index outer)
|
||||||
: Base(unaryOp.derived().nestedExpression(),outer), m_functor(unaryOp.derived().functor())
|
// : Base(unaryOp.derived().nestedExpression(),outer), m_functor(unaryOp.derived().functor())
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
EIGEN_STRONG_INLINE ReverseInnerIterator& operator--()
|
// EIGEN_STRONG_INLINE ReverseInnerIterator& operator--()
|
||||||
{ Base::operator--(); return *this; }
|
// { Base::operator--(); return *this; }
|
||||||
|
//
|
||||||
EIGEN_STRONG_INLINE Scalar value() const { return m_functor(Base::value()); }
|
// EIGEN_STRONG_INLINE Scalar value() const { return m_functor(Base::value()); }
|
||||||
EIGEN_STRONG_INLINE Scalar& valueRef() { return m_functor(Base::valueRef()); }
|
// EIGEN_STRONG_INLINE Scalar& valueRef() { return m_functor(Base::valueRef()); }
|
||||||
|
//
|
||||||
protected:
|
// protected:
|
||||||
const ViewOp m_functor;
|
// const ViewOp m_functor;
|
||||||
};
|
// };
|
||||||
|
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
@ -736,8 +736,8 @@ class SparseMatrix
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
#ifndef EIGEN_TEST_EVALUATORS
|
#ifndef EIGEN_TEST_EVALUATORS
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
|
||||||
template<typename Lhs, typename Rhs>
|
template<typename Lhs, typename Rhs>
|
||||||
inline SparseMatrix& operator=(const SparseSparseProduct<Lhs,Rhs>& product)
|
inline SparseMatrix& operator=(const SparseSparseProduct<Lhs,Rhs>& product)
|
||||||
{ return Base::operator=(product); }
|
{ return Base::operator=(product); }
|
||||||
@ -748,12 +748,12 @@ class SparseMatrix
|
|||||||
initAssignment(other);
|
initAssignment(other);
|
||||||
return Base::operator=(other.derived());
|
return Base::operator=(other.derived());
|
||||||
}
|
}
|
||||||
|
#endif // EIGEN_TEST_EVALUATORS
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
inline SparseMatrix& operator=(const EigenBase<OtherDerived>& other)
|
inline SparseMatrix& operator=(const EigenBase<OtherDerived>& other)
|
||||||
{ return Base::operator=(other.derived()); }
|
{ return Base::operator=(other.derived()); }
|
||||||
#endif
|
#endif // EIGEN_PARSED_BY_DOXYGEN
|
||||||
#endif // EIGEN_TEST_EVALUATORS
|
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DONT_INLINE SparseMatrix& operator=(const SparseMatrixBase<OtherDerived>& other);
|
EIGEN_DONT_INLINE SparseMatrix& operator=(const SparseMatrixBase<OtherDerived>& other);
|
||||||
|
@ -103,7 +103,7 @@ struct permut_sparsematrix_product_retval
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef EIGEN_TEST_EVALUATORS
|
||||||
|
|
||||||
/** \returns the matrix with the permutation applied to the columns
|
/** \returns the matrix with the permutation applied to the columns
|
||||||
*/
|
*/
|
||||||
@ -143,6 +143,135 @@ operator*(const Transpose<PermutationBase<PermDerived> >& tperm, const SparseMat
|
|||||||
return internal::permut_sparsematrix_product_retval<PermutationBase<PermDerived>, SparseDerived, OnTheLeft, true>(tperm.nestedPermutation(), matrix.derived());
|
return internal::permut_sparsematrix_product_retval<PermutationBase<PermDerived>, SparseDerived, OnTheLeft, true>(tperm.nestedPermutation(), matrix.derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else // EIGEN_TEST_EVALUATORS
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
template <int ProductTag> struct product_promote_storage_type<Sparse, PermutationStorage, ProductTag> { typedef Sparse ret; };
|
||||||
|
template <int ProductTag> struct product_promote_storage_type<PermutationStorage, Sparse, ProductTag> { typedef Sparse ret; };
|
||||||
|
|
||||||
|
// TODO, the following need cleaning, this is just a copy-past of the dense case
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs, int ProductTag>
|
||||||
|
struct generic_product_impl<Lhs, Rhs, PermutationShape, SparseShape, ProductTag>
|
||||||
|
{
|
||||||
|
template<typename Dest>
|
||||||
|
static void evalTo(Dest& dst, const Lhs& lhs, const Rhs& rhs)
|
||||||
|
{
|
||||||
|
permut_sparsematrix_product_retval<Lhs, Rhs, OnTheLeft, false> pmpr(lhs, rhs);
|
||||||
|
pmpr.evalTo(dst);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs, int ProductTag>
|
||||||
|
struct generic_product_impl<Lhs, Rhs, SparseShape, PermutationShape, ProductTag>
|
||||||
|
{
|
||||||
|
template<typename Dest>
|
||||||
|
static void evalTo(Dest& dst, const Lhs& lhs, const Rhs& rhs)
|
||||||
|
{
|
||||||
|
permut_sparsematrix_product_retval<Rhs, Lhs, OnTheRight, false> pmpr(rhs, lhs);
|
||||||
|
pmpr.evalTo(dst);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs, int ProductTag>
|
||||||
|
struct generic_product_impl<Transpose<Lhs>, Rhs, PermutationShape, SparseShape, ProductTag>
|
||||||
|
{
|
||||||
|
template<typename Dest>
|
||||||
|
static void evalTo(Dest& dst, const Transpose<Lhs>& lhs, const Rhs& rhs)
|
||||||
|
{
|
||||||
|
permut_sparsematrix_product_retval<Lhs, Rhs, OnTheLeft, true> pmpr(lhs.nestedPermutation(), rhs);
|
||||||
|
pmpr.evalTo(dst);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs, int ProductTag>
|
||||||
|
struct generic_product_impl<Lhs, Transpose<Rhs>, SparseShape, PermutationShape, ProductTag>
|
||||||
|
{
|
||||||
|
template<typename Dest>
|
||||||
|
static void evalTo(Dest& dst, const Lhs& lhs, const Transpose<Rhs>& rhs)
|
||||||
|
{
|
||||||
|
permut_sparsematrix_product_retval<Rhs, Lhs, OnTheRight, true> pmpr(rhs.nestedPermutation(), lhs);
|
||||||
|
pmpr.evalTo(dst);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs, int ProductTag>
|
||||||
|
struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, PermutationShape, SparseShape, typename traits<Lhs>::Scalar, typename traits<Rhs>::Scalar>
|
||||||
|
: public evaluator<typename traits<permut_sparsematrix_product_retval<Lhs,Rhs,OnTheRight,false> >::ReturnType>::type
|
||||||
|
{
|
||||||
|
typedef Product<Lhs, Rhs, DefaultProduct> XprType;
|
||||||
|
typedef typename traits<permut_sparsematrix_product_retval<Lhs,Rhs,OnTheRight,false> >::ReturnType PlainObject;
|
||||||
|
typedef typename evaluator<PlainObject>::type Base;
|
||||||
|
|
||||||
|
product_evaluator(const XprType& xpr)
|
||||||
|
: m_result(xpr.rows(), xpr.cols())
|
||||||
|
{
|
||||||
|
::new (static_cast<Base*>(this)) Base(m_result);
|
||||||
|
generic_product_impl<Lhs, Rhs, PermutationShape, SparseShape, ProductTag>::evalTo(m_result, xpr.lhs(), xpr.rhs());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
PlainObject m_result;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Lhs, typename Rhs, int ProductTag>
|
||||||
|
struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, SparseShape, PermutationShape, typename traits<Lhs>::Scalar, typename traits<Rhs>::Scalar>
|
||||||
|
: public evaluator<typename traits<permut_sparsematrix_product_retval<Rhs,Lhs,OnTheRight,false> >::ReturnType>::type
|
||||||
|
{
|
||||||
|
typedef Product<Lhs, Rhs, DefaultProduct> XprType;
|
||||||
|
typedef typename traits<permut_sparsematrix_product_retval<Rhs,Lhs,OnTheRight,false> >::ReturnType PlainObject;
|
||||||
|
typedef typename evaluator<PlainObject>::type Base;
|
||||||
|
|
||||||
|
product_evaluator(const XprType& xpr)
|
||||||
|
: m_result(xpr.rows(), xpr.cols())
|
||||||
|
{
|
||||||
|
::new (static_cast<Base*>(this)) Base(m_result);
|
||||||
|
generic_product_impl<Lhs, Rhs, SparseShape, PermutationShape, ProductTag>::evalTo(m_result, xpr.lhs(), xpr.rhs());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
PlainObject m_result;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace internal
|
||||||
|
|
||||||
|
/** \returns the matrix with the permutation applied to the columns
|
||||||
|
*/
|
||||||
|
template<typename SparseDerived, typename PermDerived>
|
||||||
|
inline const Product<SparseDerived, PermDerived>
|
||||||
|
operator*(const SparseMatrixBase<SparseDerived>& matrix, const PermutationBase<PermDerived>& perm)
|
||||||
|
{ return Product<SparseDerived, PermDerived>(matrix.derived(), perm.derived()); }
|
||||||
|
|
||||||
|
/** \returns the matrix with the permutation applied to the rows
|
||||||
|
*/
|
||||||
|
template<typename SparseDerived, typename PermDerived>
|
||||||
|
inline const Product<PermDerived, SparseDerived>
|
||||||
|
operator*( const PermutationBase<PermDerived>& perm, const SparseMatrixBase<SparseDerived>& matrix)
|
||||||
|
{ return Product<PermDerived, SparseDerived>(perm.derived(), matrix.derived()); }
|
||||||
|
|
||||||
|
|
||||||
|
// TODO, the following specializations should not be needed as Transpose<Permutation*> should be a PermutationBase.
|
||||||
|
/** \returns the matrix with the inverse permutation applied to the columns.
|
||||||
|
*/
|
||||||
|
template<typename SparseDerived, typename PermDerived>
|
||||||
|
inline const Product<SparseDerived, Transpose<PermutationBase<PermDerived> > >
|
||||||
|
operator*(const SparseMatrixBase<SparseDerived>& matrix, const Transpose<PermutationBase<PermDerived> >& tperm)
|
||||||
|
{
|
||||||
|
return Product<SparseDerived, Transpose<PermutationBase<PermDerived> > >(matrix.derived(), tperm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \returns the matrix with the inverse permutation applied to the rows.
|
||||||
|
*/
|
||||||
|
template<typename SparseDerived, typename PermDerived>
|
||||||
|
inline const Product<Transpose<PermutationBase<PermDerived> >, SparseDerived>
|
||||||
|
operator*(const Transpose<PermutationBase<PermDerived> >& tperm, const SparseMatrixBase<SparseDerived>& matrix)
|
||||||
|
{
|
||||||
|
return Product<Transpose<PermutationBase<PermDerived> >, SparseDerived>(tperm, matrix.derived());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // EIGEN_TEST_EVALUATORS
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_SPARSE_SELFADJOINTVIEW_H
|
#endif // EIGEN_SPARSE_SELFADJOINTVIEW_H
|
||||||
|
@ -20,7 +20,7 @@ class SparseSelfAdjointTimeDenseProduct;
|
|||||||
template<typename Lhs, typename Rhs, int Mode>
|
template<typename Lhs, typename Rhs, int Mode>
|
||||||
class DenseTimeSparseSelfAdjointProduct;
|
class DenseTimeSparseSelfAdjointProduct;
|
||||||
|
|
||||||
#endif // #ifndef EIGEN_TEST_EVALUATORS
|
#endif // EIGEN_TEST_EVALUATORS
|
||||||
|
|
||||||
/** \ingroup SparseCore_Module
|
/** \ingroup SparseCore_Module
|
||||||
* \class SparseSelfAdjointView
|
* \class SparseSelfAdjointView
|
||||||
@ -177,7 +177,7 @@ template<typename MatrixType, unsigned int _Mode> class SparseSelfAdjointView
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of P H P^-1 */
|
/** \returns an expression of P H P^-1 */
|
||||||
#ifndef EIGEN_TEST_EVALUATORS
|
// #ifndef EIGEN_TEST_EVALUATORS
|
||||||
SparseSymmetricPermutationProduct<_MatrixTypeNested,Mode> twistedBy(const PermutationMatrix<Dynamic,Dynamic,Index>& perm) const
|
SparseSymmetricPermutationProduct<_MatrixTypeNested,Mode> twistedBy(const PermutationMatrix<Dynamic,Dynamic,Index>& perm) const
|
||||||
{
|
{
|
||||||
return SparseSymmetricPermutationProduct<_MatrixTypeNested,Mode>(m_matrix, perm);
|
return SparseSymmetricPermutationProduct<_MatrixTypeNested,Mode>(m_matrix, perm);
|
||||||
@ -189,7 +189,7 @@ template<typename MatrixType, unsigned int _Mode> class SparseSelfAdjointView
|
|||||||
permutedMatrix.evalTo(*this);
|
permutedMatrix.evalTo(*this);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif // EIGEN_TEST_EVALUATORS
|
// #endif // EIGEN_TEST_EVALUATORS
|
||||||
|
|
||||||
SparseSelfAdjointView& operator=(const SparseSelfAdjointView& src)
|
SparseSelfAdjointView& operator=(const SparseSelfAdjointView& src)
|
||||||
{
|
{
|
||||||
@ -680,7 +680,7 @@ void permute_symm_to_symm(const MatrixType& mat, SparseMatrix<typename MatrixTyp
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef EIGEN_TEST_EVALUATORS
|
// #ifndef EIGEN_TEST_EVALUATORS
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
@ -731,9 +731,9 @@ class SparseSymmetricPermutationProduct
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#else // EIGEN_TEST_EVALUATORS
|
// #else // EIGEN_TEST_EVALUATORS
|
||||||
|
|
||||||
#endif // EIGEN_TEST_EVALUATORS
|
// #endif // EIGEN_TEST_EVALUATORS
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
|
@ -233,13 +233,13 @@ endif(NOT EIGEN_TEST_EVALUATORS)
|
|||||||
ei_add_test(sparse_vector)
|
ei_add_test(sparse_vector)
|
||||||
ei_add_test(sparse_product)
|
ei_add_test(sparse_product)
|
||||||
ei_add_test(sparse_solvers)
|
ei_add_test(sparse_solvers)
|
||||||
if(NOT EIGEN_TEST_EVALUATORS)
|
|
||||||
ei_add_test(sparse_permutations)
|
ei_add_test(sparse_permutations)
|
||||||
ei_add_test(simplicial_cholesky)
|
ei_add_test(simplicial_cholesky)
|
||||||
ei_add_test(conjugate_gradient)
|
ei_add_test(conjugate_gradient)
|
||||||
ei_add_test(bicgstab)
|
ei_add_test(bicgstab)
|
||||||
ei_add_test(sparselu)
|
ei_add_test(sparselu)
|
||||||
ei_add_test(sparseqr)
|
ei_add_test(sparseqr)
|
||||||
|
if(NOT EIGEN_TEST_EVALUATORS)
|
||||||
endif(NOT EIGEN_TEST_EVALUATORS)
|
endif(NOT EIGEN_TEST_EVALUATORS)
|
||||||
ei_add_test(umeyama)
|
ei_add_test(umeyama)
|
||||||
ei_add_test(nesting_ops "${CMAKE_CXX_FLAGS_DEBUG}")
|
ei_add_test(nesting_ops "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user