10#ifndef EIGEN_SPARSEMATRIXBASE_H
11#define EIGEN_SPARSEMATRIXBASE_H
38 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
46 typename internal::packet_traits<Scalar>::type
54 template<
typename OtherDerived>
82 MaxColsAtCompileTime>::ret),
121#ifndef EIGEN_PARSED_BY_DOXYGEN
143 inline const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
144 inline Derived& derived() {
return *
static_cast<Derived*
>(
this); }
145 inline Derived& const_cast_derived()
const
146 {
return *
static_cast<Derived*
>(
const_cast<SparseMatrixBase*
>(
this)); }
148 typedef EigenBase<Derived> Base;
152#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase
153#ifdef EIGEN_PARSED_BY_DOXYGEN
154#define EIGEN_DOC_UNARY_ADDONS(METHOD,OP)
155#define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
156#define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND)
158#define EIGEN_DOC_UNARY_ADDONS(X,Y)
159#define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
160#define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND)
162# include "../plugins/CommonCwiseUnaryOps.h"
163# include "../plugins/CommonCwiseBinaryOps.h"
164# include "../plugins/MatrixCwiseUnaryOps.h"
165# include "../plugins/MatrixCwiseBinaryOps.h"
166# include "../plugins/BlockMethods.h"
167# ifdef EIGEN_SPARSEMATRIXBASE_PLUGIN
168# include EIGEN_SPARSEMATRIXBASE_PLUGIN
170#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
171#undef EIGEN_DOC_UNARY_ADDONS
172#undef EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
173#undef EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF
194 bool isRValue()
const {
return m_isRValue; }
195 Derived& markAsRValue() { m_isRValue =
true;
return derived(); }
197 SparseMatrixBase() : m_isRValue(false) { }
200 template<
typename OtherDerived>
201 Derived& operator=(
const ReturnByValue<OtherDerived>& other);
203 template<
typename OtherDerived>
204 inline Derived& operator=(
const SparseMatrixBase<OtherDerived>& other);
206 inline Derived& operator=(
const Derived& other);
210 template<
typename OtherDerived>
211 inline Derived& assign(
const OtherDerived& other);
213 template<
typename OtherDerived>
214 inline void assignGeneric(
const OtherDerived& other);
218 friend std::ostream & operator << (std::ostream & s,
const SparseMatrixBase& m)
220 typedef typename Derived::Nested Nested;
221 typedef typename internal::remove_all<Nested>::type NestedCleaned;
225 Nested nm(m.derived());
226 internal::evaluator<NestedCleaned> thisEval(nm);
227 for (
Index row=0; row<nm.outerSize(); ++row)
230 for (
typename internal::evaluator<NestedCleaned>::InnerIterator it(thisEval, row); it; ++it)
232 for ( ; col<it.index(); ++col)
234 s << it.value() <<
" ";
237 for ( ; col<m.cols(); ++col)
244 Nested nm(m.derived());
245 internal::evaluator<NestedCleaned> thisEval(nm);
248 for (
typename internal::evaluator<NestedCleaned>::InnerIterator it(thisEval, 0); it; ++it)
250 for ( ; row<it.index(); ++row)
251 s <<
"0" << std::endl;
252 s << it.value() << std::endl;
255 for ( ; row<m.rows(); ++row)
256 s <<
"0" << std::endl;
260 SparseMatrix<Scalar, RowMajorBit, StorageIndex> trans = m;
261 s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit, StorageIndex> >&>(trans);
268 template<
typename OtherDerived>
269 Derived& operator+=(
const SparseMatrixBase<OtherDerived>& other);
270 template<
typename OtherDerived>
271 Derived& operator-=(
const SparseMatrixBase<OtherDerived>& other);
273 template<
typename OtherDerived>
274 Derived& operator+=(
const DiagonalBase<OtherDerived>& other);
275 template<
typename OtherDerived>
276 Derived& operator-=(
const DiagonalBase<OtherDerived>& other);
278 template<
typename OtherDerived>
279 Derived& operator+=(
const EigenBase<OtherDerived> &other);
280 template<
typename OtherDerived>
281 Derived& operator-=(
const EigenBase<OtherDerived> &other);
283 Derived& operator*=(
const Scalar& other);
284 Derived& operator/=(
const Scalar& other);
296 template<
typename OtherDerived>
301 template<
typename OtherDerived>
307 template<
typename OtherDerived>
friend
313 template<
typename OtherDerived>
314 const Product<Derived,OtherDerived,AliasFreeProduct>
315 operator*(
const SparseMatrixBase<OtherDerived> &other)
const;
318 template<
typename OtherDerived>
319 const Product<Derived,OtherDerived>
320 operator*(
const MatrixBase<OtherDerived> &other)
const
321 {
return Product<Derived,OtherDerived>(derived(), other.derived()); }
324 template<
typename OtherDerived>
friend
325 const Product<OtherDerived,Derived>
326 operator*(
const MatrixBase<OtherDerived> &lhs,
const SparseMatrixBase& rhs)
327 {
return Product<OtherDerived,Derived>(lhs.derived(), rhs.derived()); }
335 template<
typename OtherDerived>
344 template<
unsigned int UpLo>
inline
346 template<
unsigned int UpLo>
inline
356 const ConstTransposeReturnType transpose()
const {
return ConstTransposeReturnType(derived()); }
357 const AdjointReturnType adjoint()
const {
return AdjointReturnType(transpose()); }
364 template<
typename OtherDerived>
365 bool isApprox(
const SparseMatrixBase<OtherDerived>& other,
366 const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
368 template<
typename OtherDerived>
369 bool isApprox(
const MatrixBase<OtherDerived>& other,
370 const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const
371 {
return toDense().
isApprox(other,prec); }
391 return internal::convert_index<StorageIndex>(idx);
394 template<
typename Dest>
void evalTo(Dest &)
const;
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition CwiseBinaryOp.h:84
EIGEN_DEVICE_FUNC bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition Fuzzy.h:103
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
Base class of any sparse matrices or sparse expressions.
Definition SparseMatrixBase.h:28
internal::traits< Derived >::StorageIndex StorageIndex
The integer type used to store indices within a SparseMatrix.
Definition SparseMatrixBase.h:43
Index size() const
Definition SparseMatrixBase.h:181
Index innerSize() const
Definition SparseMatrixBase.h:192
Index rows() const
Definition SparseMatrixBase.h:176
@ IsVectorAtCompileTime
This is set to true if either the number of rows or the number of columns is known at compile-time to...
Definition SparseMatrixBase.h:84
@ NumDimensions
This value is equal to Tensor::NumDimensions, i.e.
Definition SparseMatrixBase.h:90
@ ColsAtCompileTime
The number of columns at compile-time.
Definition SparseMatrixBase.h:65
@ Flags
This stores expression Flags flags which may or may not be inherited by new expressions constructed f...
Definition SparseMatrixBase.h:95
@ RowsAtCompileTime
The number of rows at compile-time.
Definition SparseMatrixBase.h:59
@ SizeAtCompileTime
This is equal to the number of coefficients, i.e.
Definition SparseMatrixBase.h:72
bool isVector() const
Definition SparseMatrixBase.h:186
Matrix< Scalar, EIGEN_SIZE_MAX(RowsAtCompileTime, ColsAtCompileTime), EIGEN_SIZE_MAX(RowsAtCompileTime, ColsAtCompileTime)> SquareMatrixType
type of the equivalent square matrix
Definition SparseMatrixBase.h:141
NumTraits< Scalar >::Real RealScalar
This is the "real scalar" type; if the Scalar type is already real numbers (e.g.
Definition SparseMatrixBase.h:128
Scalar value_type
The numeric type of the expression' coefficients, e.g.
Definition SparseMatrixBase.h:36
Index outerSize() const
Definition SparseMatrixBase.h:189
const SparseView< Derived > pruned(const Scalar &reference=Scalar(0), const RealScalar &epsilon=NumTraits< Scalar >::dummy_precision()) const
Definition SparseView.h:246
Index cols() const
Definition SparseMatrixBase.h:178
Matrix< Scalar, RowsAtCompileTime, ColsAtCompileTime > DenseMatrixType
type of the equivalent dense matrix
Definition SparseMatrixBase.h:138
SparseSymmetricPermutationProduct< Derived, Upper|Lower > twistedBy(const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
Definition SparseMatrixBase.h:330
const internal::eval< Derived >::type eval() const
Definition SparseMatrixBase.h:378
const unsigned int DirectAccessBit
Means that the underlying array of coefficients can be directly accessed as a plain strided array.
Definition Constants.h:155
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition EigenBase.h:30
Eigen::Index Index
The interface type of indices.
Definition EigenBase.h:39
Holds information about the various numeric (i.e.
Definition NumTraits.h:236
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition XprHelper.h:806
Definition SparseMatrixBase.h:342
Definition SparseMatrixBase.h:286
Definition SparseMatrixBase.h:341
Definition DenseCoeffsBase.h:17
Definition XprHelper.h:332
Definition BinaryFunctors.h:71
Definition XprHelper.h:282
Definition ForwardDeclarations.h:17