10 #ifndef EIGEN_SPARSE_SELFADJOINTVIEW_H    11 #define EIGEN_SPARSE_SELFADJOINTVIEW_H    31 template<
typename MatrixType, 
unsigned int Mode>
    35 template<
int SrcMode,
int DstMode,
typename MatrixType,
int DestOrder>
    38 template<
int Mode,
typename MatrixType,
int DestOrder>
    44   : 
public EigenBase<SparseSelfAdjointView<MatrixType,_Mode> >
    55     typedef typename MatrixType::Scalar 
Scalar;
    63       eigen_assert(rows()==cols() && 
"SelfAdjointView is only for squared matrices");
    66     inline Index rows()
 const { 
return m_matrix.rows(); }
    67     inline Index cols()
 const { 
return m_matrix.cols(); }
    70     const _MatrixTypeNested& 
matrix()
 const { 
return m_matrix; }
    78     template<
typename OtherDerived>
    90     template<
typename OtherDerived> 
friend    98     template<
typename OtherDerived>
   106     template<
typename OtherDerived> 
friend   121     template<
typename DerivedU>
   131     template<
typename SrcMatrixType,
int SrcMode>
   144     template<
typename SrcMatrixType,
unsigned int SrcMode>
   155       eigen_assert(rows == this->rows() && cols == this->cols()
   156                 && 
"SparseSelfadjointView::resize() does not actually allow to resize.");
   165     template<
typename Dest> 
void evalTo(Dest &) 
const;
   172 template<
typename Derived>
   173 template<
unsigned int UpLo>
   179 template<
typename Derived>
   180 template<
unsigned int UpLo>
   190 template<
typename MatrixType, 
unsigned int Mode>
   191 template<
typename DerivedU>
   197     m_matrix = tmp.template triangularView<Mode>();
   199     m_matrix += alpha * tmp.template triangularView<Mode>();
   209 template<
typename MatrixType, 
unsigned int Mode>
   221 template< 
typename DstXprType, 
typename SrcXprType, 
typename Functor>
   225   template<
typename DestScalar,
int StorageOrder>
   228     internal::permute_symm_to_fullsymm<SrcXprType::Mode>(src.matrix(), dst);
   231   template<
typename DestScalar>
   236     internal::permute_symm_to_fullsymm<SrcXprType::Mode>(src.matrix(), tmp);
   249 template<
int Mode, 
typename SparseLhsType, 
typename DenseRhsType, 
typename DenseResType, 
typename AlphaType>
   257   typedef typename LhsEval::InnerIterator LhsIterator;
   258   typedef typename SparseLhsType::Scalar LhsScalar;
   264           || ( (Mode&
Upper) && !LhsIsRowMajor)
   265           || ( (Mode&
Lower) && LhsIsRowMajor),
   266     ProcessSecondHalf = !ProcessFirstHalf
   269   SparseLhsTypeNested lhs_nested(lhs);
   270   LhsEval lhsEval(lhs_nested);
   273   for (
Index k=0; k<rhs.cols(); ++k)
   275     for (
Index j=0; j<lhs.outerSize(); ++j)
   277       LhsIterator i(lhsEval,j);
   279       if (ProcessSecondHalf)
   281         while (i && i.index()<j) ++i;
   282         if(i && i.index()==j)
   284           res(j,k) += alpha * i.value() * rhs(j,k);
   292       typename DenseResType::Scalar res_j(0);
   293       for(; (ProcessFirstHalf ? i && i.index() < j : i) ; ++i)
   295         LhsScalar lhs_ij = i.value();
   296         if(!LhsIsRowMajor) lhs_ij = numext::conj(lhs_ij);
   297         res_j += lhs_ij * rhs(i.index(),k);
   298         res(i.index(),k) += numext::conj(lhs_ij) * rhs_j;
   300       res(j,k) += alpha * res_j;
   303       if (ProcessFirstHalf && i && (i.index()==j))
   304         res(j,k) += alpha * i.value() * rhs(j,k);
   310 template<
typename LhsView, 
typename Rhs, 
int ProductType>
   312 : 
generic_product_impl_base<LhsView, Rhs, generic_product_impl<LhsView, Rhs, SparseSelfAdjointShape, DenseShape, ProductType> >
   314   template<
typename Dest>
   315   static void scaleAndAddTo(Dest& dst, 
const LhsView& lhsView, 
const Rhs& rhs, 
const typename Dest::Scalar& alpha)
   317     typedef typename LhsView::_MatrixTypeNested Lhs;
   320     LhsNested lhsNested(lhsView.matrix());
   321     RhsNested rhsNested(rhs);
   323     internal::sparse_selfadjoint_time_dense_product<LhsView::Mode>(lhsNested, rhsNested, dst, alpha);
   327 template<
typename Lhs, 
typename RhsView, 
int ProductType>
   329 : 
generic_product_impl_base<Lhs, RhsView, generic_product_impl<Lhs, RhsView, DenseShape, SparseSelfAdjointShape, ProductType> >
   331   template<
typename Dest>
   332   static void scaleAndAddTo(Dest& dst, 
const Lhs& lhs, 
const RhsView& rhsView, 
const typename Dest::Scalar& alpha)
   334     typedef typename RhsView::_MatrixTypeNested Rhs;
   337     LhsNested lhsNested(lhs);
   338     RhsNested rhsNested(rhsView.matrix());
   342     internal::sparse_selfadjoint_time_dense_product<RhsView::Mode>(rhsNested.transpose(), lhsNested.transpose(), dstT, alpha);
   349 template<
typename LhsView, 
typename Rhs, 
int ProductTag>
   351   : 
public evaluator<typename Product<typename Rhs::PlainObject, Rhs, DefaultProduct>::PlainObject>
   358     : m_lhs(xpr.lhs()), m_result(xpr.rows(), xpr.cols())
   360     ::new (static_cast<Base*>(
this)) Base(m_result);
   369 template<
typename Lhs, 
typename RhsView, 
int ProductTag>
   371   : 
public evaluator<typename Product<Lhs, typename Lhs::PlainObject, DefaultProduct>::PlainObject>
   378     : m_rhs(xpr.rhs()), m_result(xpr.rows(), xpr.cols())
   380     ::new (static_cast<Base*>(
this)) Base(m_result);
   396 template<
int Mode,
typename MatrixType,
int DestOrder>
   399   typedef typename MatrixType::StorageIndex StorageIndex;
   400   typedef typename MatrixType::Scalar Scalar;
   406   MatEval matEval(mat);
   409     StorageOrderMatch = int(Dest::IsRowMajor) == int(MatrixType::IsRowMajor)
   412   Index size = mat.rows();
   416   dest.resize(size,size);
   417   for(
Index j = 0; j<size; ++j)
   419     Index jp = perm ? perm[j] : j;
   420     for(MatIterator it(matEval,j); it; ++it)
   422       Index i = it.index();
   425       Index ip = perm ? perm[i] : i;
   427         count[StorageOrderMatch ? jp : ip]++;
   430       else if(( Mode==
Lower && r>c) || ( Mode==
Upper && r<c))
   437   Index nnz = count.sum();
   440   dest.resizeNonZeros(nnz);
   441   dest.outerIndexPtr()[0] = 0;
   442   for(
Index j=0; j<size; ++j)
   443     dest.outerIndexPtr()[j+1] = dest.outerIndexPtr()[j] + count[j];
   444   for(
Index j=0; j<size; ++j)
   445     count[j] = dest.outerIndexPtr()[j];
   448   for(StorageIndex j = 0; j<size; ++j)
   450     for(MatIterator it(matEval,j); it; ++it)
   452       StorageIndex i = internal::convert_index<StorageIndex>(it.index());
   456       StorageIndex jp = perm ? perm[j] : j;
   457       StorageIndex ip = perm ? perm[i] : i;
   461         Index k = count[StorageOrderMatch ? jp : ip]++;
   462         dest.innerIndexPtr()[k] = StorageOrderMatch ? ip : jp;
   463         dest.valuePtr()[k] = it.value();
   467         Index k = count[ip]++;
   468         dest.innerIndexPtr()[k] = ip;
   469         dest.valuePtr()[k] = it.value();
   471       else if(( (Mode&
Lower)==Lower && r>c) || ( (Mode&
Upper)==Upper && r<c))
   473         if(!StorageOrderMatch)
   475         Index k = count[jp]++;
   476         dest.innerIndexPtr()[k] = ip;
   477         dest.valuePtr()[k] = it.value();
   479         dest.innerIndexPtr()[k] = jp;
   480         dest.valuePtr()[k] = numext::conj(it.value());
   486 template<
int _SrcMode,
int _DstMode,
typename MatrixType,
int DstOrder>
   489   typedef typename MatrixType::StorageIndex StorageIndex;
   490   typedef typename MatrixType::Scalar Scalar;
   498     StorageOrderMatch = int(SrcOrder) == int(DstOrder),
   503   MatEval matEval(mat);
   505   Index size = mat.rows();
   508   dest.resize(size,size);
   509   for(StorageIndex j = 0; j<size; ++j)
   511     StorageIndex jp = perm ? perm[j] : j;
   512     for(MatIterator it(matEval,j); it; ++it)
   514       StorageIndex i = it.index();
   515       if((
int(SrcMode)==
int(
Lower) && i<j) || (
int(SrcMode)==
int(
Upper) && i>j))
   518       StorageIndex ip = perm ? perm[i] : i;
   522   dest.outerIndexPtr()[0] = 0;
   523   for(
Index j=0; j<size; ++j)
   524     dest.outerIndexPtr()[j+1] = dest.outerIndexPtr()[j] + count[j];
   525   dest.resizeNonZeros(dest.outerIndexPtr()[size]);
   526   for(
Index j=0; j<size; ++j)
   527     count[j] = dest.outerIndexPtr()[j];
   529   for(StorageIndex j = 0; j<size; ++j)
   532     for(MatIterator it(matEval,j); it; ++it)
   534       StorageIndex i = it.index();
   535       if((
int(SrcMode)==
int(
Lower) && i<j) || (
int(SrcMode)==
int(
Upper) && i>j))
   538       StorageIndex jp = perm ? perm[j] : j;
   539       StorageIndex ip = perm? perm[i] : i;
   545       if( ((
int(DstMode)==
int(
Lower) && ip<jp) || (
int(DstMode)==
int(
Upper) && ip>jp)))
   546         dest.valuePtr()[k] = numext::conj(it.value());
   548         dest.valuePtr()[k] = it.value();
   559 template<
typename MatrixType, 
int Mode>
   565 template<
typename MatrixType,
int Mode>
   567   : 
public EigenBase<SparseSymmetricPermutationProduct<MatrixType,Mode> >
   570     typedef typename MatrixType::Scalar 
Scalar;
   584       : m_matrix(mat), m_perm(perm)
   590     const NestedExpression& 
matrix()
 const { 
return m_matrix; }
   591     const Perm& 
perm()
 const { 
return m_perm; }
   601 template<
typename DstXprType, 
typename MatrixType, 
int Mode, 
typename Scalar>
   605   typedef typename DstXprType::StorageIndex 
DstIndex;
   606   template<
int Options>
   611     internal::permute_symm_to_fullsymm<Mode>(src.
matrix(),tmp,src.
perm().
indices().data());
   615   template<
typename DestType,
unsigned int DestMode>
   626 #endif // EIGEN_SPARSE_SELFADJOINTVIEW_H 
EigenBase< SparseSelfAdjointView > Base
XprType::PlainObject PlainObject
Product< SparseSelfAdjointView, OtherDerived > operator*(const SparseMatrixBase< OtherDerived > &rhs) const
Expression of the product of two arbitrary matrices or vectors. 
product_evaluator(const XprType &xpr)
SparseSelfAdjointView(MatrixType &matrix)
A versatible sparse matrix representation. 
PermutationMatrix< Dynamic, Dynamic, StorageIndex > Perm
EIGEN_DEVICE_FUNC const LhsNestedCleaned & lhs() const
Expression of the transpose of a matrix. 
friend Product< OtherDerived, SparseSelfAdjointView > operator*(const SparseMatrixBase< OtherDerived > &lhs, const SparseSelfAdjointView &rhs)
friend Product< OtherDerived, SparseSelfAdjointView > operator*(const MatrixBase< OtherDerived > &lhs, const SparseSelfAdjointView &rhs)
product_evaluator(const XprType &xpr)
static void run(SparseSelfAdjointView< DestType, DestMode > &dst, const SrcXprType &src, const internal::assign_op< Scalar, typename MatrixType::Scalar > &)
SparseSymmetricPermutationProduct(const MatrixType &mat, const Perm &perm)
internal::remove_reference< MatrixTypeNested >::type & matrix()
MatrixTypeNested m_matrix
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix. 
Matrix< StorageIndex, Dynamic, 1 > VectorI
void sparse_selfadjoint_time_dense_product(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const AlphaType &alpha)
internal::remove_all< MatrixTypeNested >::type _MatrixTypeNested
static void scaleAndAddTo(Dest &dst, const Lhs &lhs, const RhsView &rhsView, const typename Dest::Scalar &alpha)
Eigen::Index Index
The interface type of indices. 
static void scaleAndAddTo(Dest &dst, const LhsView &lhsView, const Rhs &rhs, const typename Dest::Scalar &alpha)
const unsigned int RowMajorBit
XprType::PlainObject PlainObject
const NestedExpression & matrix() const
SparseSelfAdjointView & operator=(const SparseSelfAdjointView &src)
Base class of any sparse matrices or sparse expressions. 
storage_kind_to_evaluator_kind< typename MatrixType::StorageKind >::Kind Kind
const _MatrixTypeNested & matrix() const
static void run(SparseMatrix< Scalar, Options, DstIndex > &dst, const SrcXprType &src, const internal::assign_op< Scalar, typename MatrixType::Scalar > &)
const IndicesType & indices() const
SparseSelfAdjointView & operator=(const SparseSymmetricPermutationProduct< SrcMatrixType, SrcMode > &permutedMatrix)
evaluator< PlainObject > Base
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API. 
SparseSelfAdjoint2Sparse Kind
SparseSelfAdjointShape Shape
void permute_symm_to_symm(const MatrixType &mat, SparseMatrix< typename MatrixType::Scalar, DestOrder, typename MatrixType::StorageIndex > &_dest, const typename MatrixType::StorageIndex *perm=0)
const AdjointReturnType adjoint() const
Product< Lhs, RhsView, DefaultProduct > XprType
internal::ref_selector< MatrixType >::non_const_type MatrixTypeNested
DstXprType::StorageIndex DstIndex
MatrixType::StorageIndex StorageIndex
void permute_symm_to_fullsymm(const MatrixType &mat, SparseMatrix< typename MatrixType::Scalar, DestOrder, typename MatrixType::StorageIndex > &_dest, const typename MatrixType::StorageIndex *perm=0)
MatrixType::Scalar Scalar
Product< SparseSelfAdjointView, OtherDerived > operator*(const MatrixBase< OtherDerived > &rhs) const
ConstSelfAdjointViewReturnType< UpLo >::Type selfadjointView() const
SparseSelfAdjointView & rankUpdate(const SparseMatrixBase< DerivedU > &u, const Scalar &alpha=Scalar(1))
MatrixType::StorageIndex StorageIndex
const Perm & perm() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment_no_alias_no_transpose(Dst &dst, const Src &src, const Func &func)
int64_t max(int64_t a, const int b)
evaluator< PlainObject > Base
SparseSymmetricPermutationProduct< _MatrixTypeNested, Mode > twistedBy(const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
Matrix< StorageIndex, Dynamic, 1 > VectorI
const Derived & derived() const
SparseSelfAdjointView & operator=(const SparseSelfAdjointView< SrcMatrixType, SrcMode > &src)
SparseSymmetricPermutationProduct< MatrixType, Mode > SrcXprType
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
MatrixType::Nested MatrixTypeNested
DstXprType::StorageIndex StorageIndex
static void run(SparseMatrix< DestScalar, StorageOrder, StorageIndex > &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
internal::remove_all< MatrixTypeNested >::type NestedExpression
MatrixType::Scalar Scalar
MatrixTypeNested m_matrix
Base class for all dense matrices, vectors, and expressions. 
Product< LhsView, Rhs, DefaultProduct > XprType
void swap(scoped_array< T > &a, scoped_array< T > &b)
void resize(Index rows, Index cols)
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
EIGEN_DEVICE_FUNC const RhsNestedCleaned & rhs() const
static void run(DynamicSparseMatrix< DestScalar, ColMajor, StorageIndex > &dst, const SrcXprType &src, const internal::assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)