Go to the documentation of this file.
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> >
79 template<
typename OtherDerived>
91 template<
typename OtherDerived>
friend
99 template<
typename OtherDerived>
107 template<
typename OtherDerived>
friend
122 template<
typename DerivedU>
132 template<
typename SrcMatrixType,
int SrcMode>
148 template<
typename SrcMatrixType,
unsigned int SrcMode>
160 &&
"SparseSelfadjointView::resize() does not actually allow to resize.");
169 template<
typename Dest>
void evalTo(Dest &)
const;
176 template<
typename Derived>
177 template<
unsigned int UpLo>
183 template<
typename Derived>
184 template<
unsigned int UpLo>
194 template<
typename MatrixType,
unsigned int Mode>
195 template<
typename DerivedU>
201 m_matrix = tmp.template triangularView<Mode>();
203 m_matrix +=
alpha * tmp.template triangularView<Mode>();
213 template<
typename MatrixType,
unsigned int Mode>
225 template<
typename DstXprType,
typename SrcXprType,
typename Functor>
231 template<
typename DestScalar,
int StorageOrder>
234 internal::permute_symm_to_fullsymm<SrcXprType::Mode>(src.matrix(), dst);
238 template<
typename DestScalar,
int StorageOrder,
typename AssignFunc>
246 template<
typename DestScalar,
int StorageOrder>
255 template<
typename DestScalar,
int StorageOrder>
264 template<
typename DestScalar>
269 internal::permute_symm_to_fullsymm<SrcXprType::Mode>(src.matrix(), tmp);
282 template<
int Mode,
typename SparseLhsType,
typename DenseRhsType,
typename DenseResType,
typename AlphaType>
290 typedef typename LhsEval::InnerIterator LhsIterator;
297 || ( (Mode&
Upper) && !LhsIsRowMajor)
298 || ( (Mode&
Lower) && LhsIsRowMajor),
299 ProcessSecondHalf = !ProcessFirstHalf
302 SparseLhsTypeNested lhs_nested(lhs);
303 LhsEval lhsEval(lhs_nested);
306 for (
Index k=0; k<rhs.cols(); ++k)
308 for (
Index j=0;
j<lhs.outerSize(); ++
j)
310 LhsIterator
i(lhsEval,
j);
312 if (ProcessSecondHalf)
314 while (
i &&
i.index()<
j) ++
i;
315 if(
i &&
i.index()==
j)
317 res.coeffRef(
j,k) +=
alpha *
i.value() * rhs.coeff(
j,k);
323 typename ScalarBinaryOpTraits<AlphaType, typename DenseRhsType::Scalar>::ReturnType rhs_j(
alpha*rhs(
j,k));
326 for(; (ProcessFirstHalf ?
i &&
i.index() <
j :
i) ; ++
i)
328 LhsScalar lhs_ij =
i.value();
330 res_j += lhs_ij * rhs.coeff(
i.index(),k);
336 if (ProcessFirstHalf &&
i && (
i.index()==
j))
337 res.coeffRef(
j,k) +=
alpha *
i.value() * rhs.coeff(
j,k);
343 template<
typename LhsView,
typename Rhs,
int ProductType>
344 struct generic_product_impl<LhsView,
Rhs, SparseSelfAdjointShape, DenseShape, ProductType>
345 : generic_product_impl_base<LhsView, Rhs, generic_product_impl<LhsView, Rhs, SparseSelfAdjointShape, DenseShape, ProductType> >
347 template<
typename Dest>
348 static void scaleAndAddTo(Dest& dst,
const LhsView& lhsView,
const Rhs& rhs,
const typename Dest::Scalar&
alpha)
350 typedef typename LhsView::_MatrixTypeNested
Lhs;
353 LhsNested lhsNested(lhsView.matrix());
354 RhsNested rhsNested(rhs);
356 internal::sparse_selfadjoint_time_dense_product<LhsView::Mode>(lhsNested, rhsNested, dst,
alpha);
360 template<
typename Lhs,
typename RhsView,
int ProductType>
361 struct generic_product_impl<
Lhs, RhsView,
DenseShape, SparseSelfAdjointShape, ProductType>
362 : generic_product_impl_base<Lhs, RhsView, generic_product_impl<Lhs, RhsView, DenseShape, SparseSelfAdjointShape, ProductType> >
364 template<
typename Dest>
365 static void scaleAndAddTo(Dest& dst,
const Lhs& lhs,
const RhsView& rhsView,
const typename Dest::Scalar&
alpha)
367 typedef typename RhsView::_MatrixTypeNested
Rhs;
370 LhsNested lhsNested(lhs);
371 RhsNested rhsNested(rhsView.matrix());
375 internal::sparse_selfadjoint_time_dense_product<RhsView::TransposeMode>(rhsNested.transpose(), lhsNested.transpose(), dstT,
alpha);
382 template<
typename LhsView,
typename Rhs,
int ProductTag>
384 :
public evaluator<typename Product<typename Rhs::PlainObject, Rhs, DefaultProduct>::PlainObject>
391 : m_lhs(xpr.lhs()), m_result(xpr.
rows(), xpr.
cols())
393 ::new (
static_cast<Base*
>(
this))
Base(m_result);
398 typename Rhs::PlainObject m_lhs;
399 PlainObject m_result;
402 template<
typename Lhs,
typename RhsView,
int ProductTag>
404 :
public evaluator<typename Product<Lhs, typename Lhs::PlainObject, DefaultProduct>::PlainObject>
411 : m_rhs(xpr.rhs()), m_result(xpr.
rows(), xpr.
cols())
413 ::new (
static_cast<Base*
>(
this))
Base(m_result);
418 typename Lhs::PlainObject m_rhs;
419 PlainObject m_result;
429 template<
int Mode,
typename MatrixType,
int DestOrder>
432 typedef typename MatrixType::StorageIndex StorageIndex;
439 MatEval matEval(
mat);
440 Dest& dest(_dest.derived());
442 StorageOrderMatch =
int(Dest::IsRowMajor) ==
int(MatrixType::IsRowMajor)
453 for(MatIterator it(matEval,
j); it; ++it)
460 count[StorageOrderMatch ? jp : ip]++;
470 Index nnz = count.sum();
473 dest.resizeNonZeros(nnz);
474 dest.outerIndexPtr()[0] = 0;
476 dest.outerIndexPtr()[
j+1] = dest.outerIndexPtr()[
j] + count[
j];
478 count[
j] = dest.outerIndexPtr()[
j];
481 for(StorageIndex
j = 0;
j<
size; ++
j)
483 for(MatIterator it(matEval,
j); it; ++it)
485 StorageIndex
i = internal::convert_index<StorageIndex>(it.index());
494 Index k = count[StorageOrderMatch ? jp : ip]++;
495 dest.innerIndexPtr()[k] = StorageOrderMatch ? ip : jp;
496 dest.valuePtr()[k] = it.value();
500 Index k = count[ip]++;
501 dest.innerIndexPtr()[k] = ip;
502 dest.valuePtr()[k] = it.value();
506 if(!StorageOrderMatch)
508 Index k = count[jp]++;
509 dest.innerIndexPtr()[k] = ip;
510 dest.valuePtr()[k] = it.value();
512 dest.innerIndexPtr()[k] = jp;
519 template<
int _SrcMode,
int _DstMode,
typename MatrixType,
int DstOrder>
520 void permute_symm_to_symm(
const MatrixType&
mat, SparseMatrix<typename MatrixType::Scalar,DstOrder,typename MatrixType::StorageIndex>& _dest,
const typename MatrixType::StorageIndex*
perm)
522 typedef typename MatrixType::StorageIndex StorageIndex;
531 StorageOrderMatch =
int(SrcOrder) ==
int(DstOrder),
536 MatEval matEval(
mat);
542 for(StorageIndex
j = 0;
j<
size; ++
j)
545 for(MatIterator it(matEval,
j); it; ++it)
547 StorageIndex
i = it.index();
548 if((
int(SrcMode)==
int(
Lower) &&
i<
j) || (
int(SrcMode)==
int(
Upper) &&
i>
j))
555 dest.outerIndexPtr()[0] = 0;
557 dest.outerIndexPtr()[
j+1] = dest.outerIndexPtr()[
j] + count[
j];
558 dest.resizeNonZeros(dest.outerIndexPtr()[
size]);
560 count[
j] = dest.outerIndexPtr()[
j];
562 for(StorageIndex
j = 0;
j<
size; ++
j)
565 for(MatIterator it(matEval,
j); it; ++it)
567 StorageIndex
i = it.index();
578 if( ((
int(DstMode)==
int(
Lower) && ip<jp) || (
int(DstMode)==
int(
Upper) && ip>jp)))
581 dest.valuePtr()[k] = it.value();
592 template<
typename MatrixType,
int Mode>
598 template<
typename MatrixType,
int Mode>
600 :
public EigenBase<SparseSymmetricPermutationProduct<MatrixType,Mode> >
634 template<
typename DstXprType,
typename MatrixType,
int Mode,
typename Scalar>
638 typedef typename DstXprType::StorageIndex
DstIndex;
639 template<
int Options>
644 internal::permute_symm_to_fullsymm<Mode>(src.
matrix(),tmp,src.
perm().
indices().data());
648 template<
typename DestType,
unsigned int DestMode>
659 #endif // EIGEN_SPARSE_SELFADJOINTVIEW_H
A sparse matrix class designed for matrix assembly purpose.
idx_t idx_t idx_t idx_t idx_t * perm
XprType::PlainObject PlainObject
Namespace containing all symbols from the Eigen library.
A versatible sparse matrix representation.
void sparse_selfadjoint_time_dense_product(const SparseLhsType &lhs, const DenseRhsType &rhs, DenseResType &res, const AlphaType &alpha)
const Perm & perm() const
static void run(DynamicSparseMatrix< DestScalar, ColMajor, StorageIndex > &dst, const SrcXprType &src, const AssignOpType &)
Matrix< StorageIndex, Dynamic, 1 > VectorI
Eigen::Index Index
The interface type of indices.
Product< SparseSelfAdjointView, OtherDerived > operator*(const SparseMatrixBase< OtherDerived > &rhs) const
friend Product< OtherDerived, SparseSelfAdjointView > operator*(const MatrixBase< OtherDerived > &lhs, const SparseSelfAdjointView &rhs)
const IndicesType & indices() const
SparseSelfAdjointView & operator=(const SparseSelfAdjointView< SrcMatrixType, SrcMode > &src)
SparseSymmetricPermutationProduct< MatrixType, Mode > SrcXprType
static void run(SparseSelfAdjointView< DestType, DestMode > &dst, const SrcXprType &src, const internal::assign_op< Scalar, typename MatrixType::Scalar > &)
SparseSelfAdjointView(MatrixType &matrix)
const unsigned int RowMajorBit
internal::remove_reference< MatrixTypeNested >::type & matrix()
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Matrix< StorageIndex, Dynamic, 1 > VectorI
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment_no_alias_no_transpose(Dst &dst, const Src &src, const Func &func)
Expression of the transpose of a matrix.
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
SparseSelfAdjointView & operator=(const SparseSelfAdjointView &src)
void evalTo(Dest &) const
static void run(SparseMatrix< DestScalar, StorageOrder, StorageIndex > &dst, const SrcXprType &src, const internal::add_assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
EigenBase< SparseSelfAdjointView > Base
XprType::PlainObject PlainObject
const NestedExpression & matrix() const
MatrixType::Nested MatrixTypeNested
Product< SparseSelfAdjointView, OtherDerived > operator*(const MatrixBase< OtherDerived > &rhs) const
SparseSelfAdjointView & operator=(const SparseSymmetricPermutationProduct< SrcMatrixType, SrcMode > &permutedMatrix)
SparseSelfAdjointView & rankUpdate(const SparseMatrixBase< DerivedU > &u, const Scalar &alpha=Scalar(1))
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)
static void run(SparseMatrix< DestScalar, StorageOrder, StorageIndex > &dst, const SrcXprType &src, const AssignFunc &func)
static void run(SparseMatrix< DestScalar, StorageOrder, StorageIndex > &dst, const SrcXprType &src, const internal::sub_assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > &)
internal::remove_all< MatrixTypeNested >::type _MatrixTypeNested
Expression of the product of two arbitrary matrices or vectors.
storage_kind_to_evaluator_kind< typename MatrixType::StorageKind >::Kind Kind
MatrixTypeNested m_matrix
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE LhsNestedCleaned & lhs() const
const AdjointReturnType adjoint() const
AnnoyingScalar conj(const AnnoyingScalar &x)
void resize(Index rows, Index cols)
#define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS)
CwiseBinaryOp< internal::scalar_sum_op< double, double >, const CpyMatrixXd, const CpyMatrixXd > XprType
MatrixType::StorageIndex StorageIndex
MatrixType::StorageIndex StorageIndex
static void run(SparseMatrix< Scalar, Options, DstIndex > &dst, const SrcXprType &src, const internal::assign_op< Scalar, typename MatrixType::Scalar > &)
SparseSelfAdjointShape Shape
MatrixTypeNested m_matrix
static void run(SparseMatrix< DestScalar, StorageOrder, StorageIndex > &dst, const SrcXprType &src, const AssignOpType &)
SparseSymmetricPermutationProduct< _MatrixTypeNested, Mode > twistedBy(const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE RhsNestedCleaned & rhs() const
ConstSelfAdjointViewReturnType< UpLo >::Type selfadjointView() const
Base class of any sparse matrices or sparse expressions.
PermutationMatrix< Dynamic, Dynamic, StorageIndex > Perm
const _MatrixTypeNested & matrix() const
const Derived & derived() const
void permute_symm_to_symm(const MatrixType &mat, SparseMatrix< typename MatrixType::Scalar, DestOrder, typename MatrixType::StorageIndex > &_dest, const typename MatrixType::StorageIndex *perm=0)
MatrixType::Scalar Scalar
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
SparseSymmetricPermutationProduct(const MatrixType &mat, const Perm &perm)
internal::ref_selector< MatrixType >::non_const_type MatrixTypeNested
Base class for all dense matrices, vectors, and expressions.
friend Product< OtherDerived, SparseSelfAdjointView > operator*(const SparseMatrixBase< OtherDerived > &lhs, const SparseSelfAdjointView &rhs)
EIGEN_CONSTEXPR Index size(const T &x)
internal::remove_all< MatrixTypeNested >::type NestedExpression
DstXprType::StorageIndex DstIndex
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
SparseSelfAdjoint2Sparse Kind
internal::assign_op< typename DstXprType::Scalar, typename SrcXprType::Scalar > AssignOpType
DstXprType::StorageIndex StorageIndex
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:13:50