// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2011-2014 Gael Guennebaud <gael.guennebaud@inria.fr> // Copyright (C) 2010 Daniel Lowengrub <lowdanie@gmail.com> // // 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/.
/** \ingroup SparseCore_Module * \class SparseView * * \brief Expression of a dense or sparse matrix with zero or too small values removed * * \tparam MatrixType the type of the object of which we are removing the small entries * * This class represents an expression of a given dense or sparse matrix with * entries smaller than \c reference * \c epsilon are removed. * It is the return type of MatrixBase::sparseView() and SparseMatrixBase::pruned() * and most of the time this is the only way it is used. * * \sa MatrixBase::sparseView(), SparseMatrixBase::pruned()
*/ template<typename MatrixType> class SparseView : public SparseMatrixBase<SparseView<MatrixType> >
{ typedeftypename MatrixType::Nested MatrixTypeNested; typedeftypename internal::remove_all<MatrixTypeNested>::type _MatrixTypeNested; typedef SparseMatrixBase<SparseView > Base; public:
EIGEN_SPARSE_PUBLIC_INTERFACE(SparseView) typedeftypename internal::remove_all<MatrixType>::type NestedExpression;
// TODO find a way to unify the two following variants // This is tricky because implementing an inner iterator on top of an IndexBased evaluator is // not easy because the evaluators do not expose the sizes of the underlying expression.
/** \ingroup SparseCore_Module * * \returns a sparse expression of the dense expression \c *this with values smaller than * \a reference * \a epsilon removed. * * This method is typically used when prototyping to convert a quickly assembled dense Matrix \c D to a SparseMatrix \c S: * \code * MatrixXd D(n,m); * SparseMatrix<double> S; * S = D.sparseView(); // suppress numerical zeros (exact) * S = D.sparseView(reference); * S = D.sparseView(reference,epsilon); * \endcode * where \a reference is a meaningful non zero reference value, * and \a epsilon is a tolerance factor defaulting to NumTraits<Scalar>::dummy_precision(). *
* \sa SparseMatrixBase::pruned(), class SparseView */ template<typename Derived> const SparseView<Derived> MatrixBase<Derived>::sparseView(const Scalar& reference, consttypename NumTraits<Scalar>::Real& epsilon) const
{ return SparseView<Derived>(derived(), reference, epsilon);
}
/** \returns an expression of \c *this with values smaller than * \a reference * \a epsilon removed. * * This method is typically used in conjunction with the product of two sparse matrices * to automatically prune the smallest values as follows: * \code * C = (A*B).pruned(); // suppress numerical zeros (exact) * C = (A*B).pruned(ref); * C = (A*B).pruned(ref,epsilon); * \endcode * where \c ref is a meaningful non zero reference value.
* */ template<typename Derived> const SparseView<Derived>
SparseMatrixBase<Derived>::pruned(const Scalar& reference, const RealScalar& epsilon) const
{ return SparseView<Derived>(derived(), reference, epsilon);
}
} // end namespace Eigen
#endif
¤ Dauer der Verarbeitung: 0.25 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.