10 #ifndef EIGEN_SPARSEMATRIXBASE_H 11 #define EIGEN_SPARSEMATRIXBASE_H 26 template<
typename Derived>
class SparseMatrixBase
27 :
public EigenBase<Derived>
31 typedef typename internal::traits<Derived>::Scalar Scalar;
38 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
39 typedef typename internal::traits<Derived>::StorageKind StorageKind;
43 typedef typename internal::traits<Derived>::StorageIndex
StorageIndex;
45 typedef typename internal::add_const_on_value_type_if_arithmetic<
46 typename internal::packet_traits<Scalar>::type
47 >::type PacketReturnType;
54 template<
typename OtherDerived>
72 SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
73 internal::traits<Derived>::ColsAtCompileTime>::ret),
81 MaxSizeAtCompileTime = (internal::size_at_compile_time<MaxRowsAtCompileTime,
82 MaxColsAtCompileTime>::ret),
90 Flags = internal::traits<Derived>::Flags,
100 #ifndef EIGEN_PARSED_BY_DOXYGEN
106 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
109 >::type AdjointReturnType;
116 #ifndef EIGEN_PARSED_BY_DOXYGEN 127 typedef typename internal::conditional<_HasDirectAccess, const Scalar&, Scalar>::type CoeffReturnType;
138 inline const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
139 inline Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
140 inline Derived& const_cast_derived()
const 145 #endif // not EIGEN_PARSED_BY_DOXYGEN 147 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase 148 #ifdef EIGEN_PARSED_BY_DOXYGEN 149 #define EIGEN_DOC_UNARY_ADDONS(METHOD,OP) 150 #define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 151 #define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND) 153 #define EIGEN_DOC_UNARY_ADDONS(X,Y) 154 #define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 155 #define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND) 157 # include "../plugins/CommonCwiseUnaryOps.h" 158 # include "../plugins/CommonCwiseBinaryOps.h" 159 # include "../plugins/MatrixCwiseUnaryOps.h" 160 # include "../plugins/MatrixCwiseBinaryOps.h" 161 # include "../plugins/BlockMethods.h" 162 # ifdef EIGEN_SPARSEMATRIXBASE_PLUGIN 163 # include EIGEN_SPARSEMATRIXBASE_PLUGIN 165 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS 166 #undef EIGEN_DOC_UNARY_ADDONS 167 #undef EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL 168 #undef EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF 189 bool isRValue()
const {
return m_isRValue; }
190 Derived& markAsRValue() { m_isRValue =
true;
return derived(); }
195 template<
typename OtherDerived>
196 Derived& operator=(
const ReturnByValue<OtherDerived>& other);
198 template<
typename OtherDerived>
201 inline Derived& operator=(
const Derived& other);
205 template<
typename OtherDerived>
206 inline Derived& assign(
const OtherDerived& other);
208 template<
typename OtherDerived>
209 inline void assignGeneric(
const OtherDerived& other);
213 friend std::ostream & operator << (std::ostream & s,
const SparseMatrixBase& m)
215 typedef typename Derived::Nested Nested;
216 typedef typename internal::remove_all<Nested>::type NestedCleaned;
220 Nested nm(m.derived());
221 internal::evaluator<NestedCleaned> thisEval(nm);
225 for (
typename internal::evaluator<NestedCleaned>::InnerIterator it(thisEval,
row); it; ++it)
227 for ( ; col<it.index(); ++
col)
229 s << it.value() <<
" ";
232 for ( ; col<m.cols(); ++
col)
239 Nested nm(m.derived());
240 internal::evaluator<NestedCleaned> thisEval(nm);
243 for (
typename internal::evaluator<NestedCleaned>::InnerIterator it(thisEval, 0); it; ++it)
245 for ( ; row<it.index(); ++
row)
246 s <<
"0" << std::endl;
247 s << it.value() << std::endl;
250 for ( ; row<m.rows(); ++
row)
251 s <<
"0" << std::endl;
256 s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit, StorageIndex> >&>(trans);
262 template<
typename OtherDerived>
264 template<
typename OtherDerived>
267 template<
typename OtherDerived>
268 Derived& operator+=(
const DiagonalBase<OtherDerived>& other);
269 template<
typename OtherDerived>
270 Derived& operator-=(
const DiagonalBase<OtherDerived>& other);
272 template<
typename OtherDerived>
274 template<
typename OtherDerived>
277 Derived& operator*=(
const Scalar& other);
278 Derived& operator/=(
const Scalar& other);
280 template<
typename OtherDerived>
struct CwiseProductDenseReturnType {
282 typename internal::traits<Derived>::Scalar,
283 typename internal::traits<OtherDerived>::Scalar
290 template<
typename OtherDerived>
291 EIGEN_STRONG_INLINE
const typename CwiseProductDenseReturnType<OtherDerived>::Type
295 template<
typename OtherDerived>
297 operator*(
const DiagonalBase<OtherDerived> &other)
const 301 template<
typename OtherDerived>
friend 307 template<
typename OtherDerived>
312 template<
typename OtherDerived>
318 template<
typename OtherDerived>
friend 326 return SparseSymmetricPermutationProduct<Derived,Upper|Lower>(
derived(), perm);
329 template<
typename OtherDerived>
338 template<
unsigned int UpLo>
inline 339 typename ConstSelfAdjointViewReturnType<UpLo>::Type selfadjointView()
const;
340 template<
unsigned int UpLo>
inline 341 typename SelfAdjointViewReturnType<UpLo>::Type selfadjointView();
345 RealScalar squaredNorm()
const;
346 RealScalar norm()
const;
347 RealScalar blueNorm()
const;
349 TransposeReturnType transpose() {
return TransposeReturnType(
derived()); }
350 const ConstTransposeReturnType transpose()
const {
return ConstTransposeReturnType(
derived()); }
351 const AdjointReturnType adjoint()
const {
return AdjointReturnType(transpose()); }
365 DenseMatrixType toDense()
const 367 return DenseMatrixType(
derived());
370 template<
typename OtherDerived>
374 template<
typename OtherDerived>
377 {
return toDense().isApprox(other,prec); }
384 inline const typename internal::eval<Derived>::type
eval()
const 385 {
return typename internal::eval<Derived>::type(
derived()); }
396 static inline StorageIndex convert_index(
const Index idx) {
397 return internal::convert_index<StorageIndex>(idx);
400 template<
typename Dest>
void evalTo(Dest &)
const;
405 #endif // EIGEN_SPARSEMATRIXBASE_H Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:60
const CwiseBinaryOp< internal::scalar_product_op< Derived ::Scalar, OtherDerived ::Scalar >, const Derived, const OtherDerived > cwiseProduct(const Eigen::SparseMatrixBase< OtherDerived > &other) const
Definition: SparseMatrixBase.h:24
Index innerSize() const
Definition: SparseMatrixBase.h:187
Index cols() const
Definition: SparseMatrixBase.h:173
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:71
A versatible sparse matrix representation.
Definition: SparseMatrix.h:96
Definition: SparseMatrixBase.h:72
Expression of the transpose of a matrix.
Definition: Transpose.h:52
const unsigned int DirectAccessBit
Definition: Constants.h:150
RowXpr row(Index i)
Definition: SparseMatrixBase.h:860
Namespace containing all symbols from the Eigen library.
Definition: Core:287
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
Definition: SparseSelfAdjointView.h:43
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:150
Definition: SparseMatrixBase.h:90
Index outerSize() const
Definition: SparseMatrixBase.h:184
Derived & derived()
Definition: EigenBase.h:45
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:38
const unsigned int RowMajorBit
Definition: Constants.h:61
bool isVector() const
Definition: SparseMatrixBase.h:181
Definition: EigenBase.h:29
Index size() const
Definition: SparseMatrixBase.h:176
const SparseView< Derived > pruned(const Scalar &reference=Scalar(0), const RealScalar &epsilon=NumTraits< Scalar >::dummy_precision()) const
Definition: SparseView.h:245
internal::traits< Derived >::StorageIndex StorageIndex
Definition: SparseMatrixBase.h:43
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:77
Index rows() const
Definition: SparseMatrixBase.h:171
Base class of any sparse matrices or sparse expressions.
Definition: ForwardDeclarations.h:281
const CwiseBinaryOp< internal::scalar_product_op< Scalar, T >, Derived, Constant< T > > operator*(const T &scalar) const
InnerVectorReturnType innerVector(Index outer)
Definition: SparseBlock.h:333
Definition: SparseMatrixBase.h:65
Expression of a dense or sparse matrix with zero or too small values removed.
Definition: ForwardDeclarations.h:126
Scalar value_type
Definition: SparseMatrixBase.h:36
InnerVectorsReturnType innerVectors(Index outerStart, Index outerSize)
Definition: SparseBlock.h:348
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Definition: SparseMatrixBase.h:84
Expression of a triangular part in a matrix.
Definition: TriangularMatrix.h:186
SparseSymmetricPermutationProduct< Derived, Upper|Lower > twistedBy(const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
Definition: SparseMatrixBase.h:324
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:766
const internal::eval< Derived >::type eval() const
Definition: SparseMatrixBase.h:384
ColXpr col(Index i)
Definition: SparseMatrixBase.h:839
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: SparseMatrixBase.h:59