10 #ifndef EIGEN_SPARSEMATRIXBASE_H 11 #define EIGEN_SPARSEMATRIXBASE_H 26 template<
typename Derived>
class SparseMatrixBase
27 #ifndef EIGEN_PARSED_BY_DOXYGEN
28 :
public internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar,
29 typename NumTraits<typename internal::traits<Derived>::Scalar>::Real,
33 #endif // not EIGEN_PARSED_BY_DOXYGEN 37 typedef typename internal::traits<Derived>::Scalar Scalar;
44 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
45 typedef typename internal::traits<Derived>::StorageKind StorageKind;
46 typedef typename internal::traits<Derived>::StorageIndex StorageIndex;
47 typedef typename internal::add_const_on_value_type_if_arithmetic<
48 typename internal::packet_traits<Scalar>::type
49 >::type PacketReturnType;
56 template<
typename OtherDerived>
74 SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
75 internal::traits<Derived>::ColsAtCompileTime>::ret),
83 MaxSizeAtCompileTime = (internal::size_at_compile_time<MaxRowsAtCompileTime,
84 MaxColsAtCompileTime>::ret),
92 Flags = internal::traits<Derived>::Flags,
102 #ifndef EIGEN_PARSED_BY_DOXYGEN
108 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
111 >::type AdjointReturnType;
118 #ifndef EIGEN_PARSED_BY_DOXYGEN 129 typedef typename internal::conditional<_HasDirectAccess, const Scalar&, Scalar>::type CoeffReturnType;
140 inline const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
141 inline Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
142 inline Derived& const_cast_derived()
const 145 typedef internal::special_scalar_op_base<Derived, Scalar, RealScalar, EigenBase<Derived> > Base;
146 using Base::operator*;
147 using Base::operator/;
148 #endif // not EIGEN_PARSED_BY_DOXYGEN 150 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase 151 # include "../plugins/CommonCwiseUnaryOps.h" 152 # include "../plugins/CommonCwiseBinaryOps.h" 153 # include "../plugins/MatrixCwiseUnaryOps.h" 154 # include "../plugins/MatrixCwiseBinaryOps.h" 155 # include "../plugins/BlockMethods.h" 156 # ifdef EIGEN_SPARSEMATRIXBASE_PLUGIN 157 # include EIGEN_SPARSEMATRIXBASE_PLUGIN 159 # undef EIGEN_CURRENT_STORAGE_BASE_CLASS 160 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS 181 bool isRValue()
const {
return m_isRValue; }
182 Derived& markAsRValue() { m_isRValue =
true;
return derived(); }
187 template<
typename OtherDerived>
188 Derived& operator=(
const ReturnByValue<OtherDerived>& other);
190 template<
typename OtherDerived>
193 inline Derived& operator=(
const Derived& other);
197 template<
typename OtherDerived>
198 inline Derived& assign(
const OtherDerived& other);
200 template<
typename OtherDerived>
201 inline void assignGeneric(
const OtherDerived& other);
205 friend std::ostream & operator << (std::ostream & s,
const SparseMatrixBase& m)
207 typedef typename Derived::Nested Nested;
208 typedef typename internal::remove_all<Nested>::type NestedCleaned;
216 for (
typename NestedCleaned::InnerIterator it(nm.derived(),
row); it; ++it)
218 for ( ; col<it.index(); ++
col)
220 s << it.value() <<
" ";
233 for (
typename NestedCleaned::InnerIterator it(nm.derived(), 0); it; ++it)
235 for ( ; row<it.index(); ++
row)
236 s <<
"0" << std::endl;
237 s << it.value() << std::endl;
241 s <<
"0" << std::endl;
246 s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit, StorageIndex> >&>(trans);
252 template<
typename OtherDerived>
254 template<
typename OtherDerived>
257 template<
typename OtherDerived>
258 Derived& operator+=(
const DiagonalBase<OtherDerived>& other);
259 template<
typename OtherDerived>
260 Derived& operator-=(
const DiagonalBase<OtherDerived>& other);
262 Derived& operator*=(
const Scalar& other);
263 Derived& operator/=(
const Scalar& other);
265 template<
typename OtherDerived>
struct CwiseProductDenseReturnType {
266 typedef CwiseBinaryOp<internal::scalar_product_op<
typename internal::scalar_product_traits<
267 typename internal::traits<Derived>::Scalar,
268 typename internal::traits<OtherDerived>::Scalar
275 template<
typename OtherDerived>
276 EIGEN_STRONG_INLINE
const typename CwiseProductDenseReturnType<OtherDerived>::Type
280 template<
typename OtherDerived>
282 operator*(
const DiagonalBase<OtherDerived> &other)
const 286 template<
typename OtherDerived>
friend 292 template<
typename OtherDerived>
297 template<
typename OtherDerived>
303 template<
typename OtherDerived>
friend 311 return SparseSymmetricPermutationProduct<Derived,Upper|Lower>(
derived(), perm);
314 template<
typename OtherDerived>
323 template<
unsigned int UpLo>
inline 324 typename ConstSelfAdjointViewReturnType<UpLo>::Type selfadjointView()
const;
325 template<
unsigned int UpLo>
inline 326 typename SelfAdjointViewReturnType<UpLo>::Type selfadjointView();
330 RealScalar squaredNorm()
const;
331 RealScalar norm()
const;
332 RealScalar blueNorm()
const;
334 TransposeReturnType transpose() {
return TransposeReturnType(
derived()); }
335 const ConstTransposeReturnType transpose()
const {
return ConstTransposeReturnType(
derived()); }
336 const AdjointReturnType adjoint()
const {
return AdjointReturnType(transpose()); }
350 DenseMatrixType toDense()
const 352 return DenseMatrixType(
derived());
355 template<
typename OtherDerived>
359 template<
typename OtherDerived>
362 {
return toDense().isApprox(other,prec); }
369 inline const typename internal::eval<Derived>::type
eval()
const 370 {
return typename internal::eval<Derived>::type(
derived()); }
374 inline const SparseView<Derived>
381 static inline StorageIndex convert_index(
const Index idx) {
382 return internal::convert_index<StorageIndex>(idx);
385 template<
typename Dest>
void evalTo(Dest &)
const;
390 #endif // EIGEN_SPARSEMATRIXBASE_H Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:44
Definition: SparseMatrixBase.h:86
Index size() const
Definition: SparseMatrixBase.h:168
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:107
A versatible sparse matrix representation.
Definition: SparseMatrix.h:92
Definition: SparseMatrixBase.h:92
Expression of the transpose of a matrix.
Definition: Transpose.h:53
const unsigned int DirectAccessBit
Definition: Constants.h:149
RowXpr row(Index i)
Definition: SparseMatrixBase.h:797
const CwiseBinaryOp< internal::scalar_product_op< typename Derived::Scalar, typename OtherDerived::Scalar >, const Derived, const OtherDerived > cwiseProduct(const Eigen::SparseMatrixBase< OtherDerived > &other) const
Definition: SparseMatrixBase.h:24
Definition: SparseMatrixBase.h:61
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:107
const SparseView< Derived > pruned(const Scalar &reference=Scalar(0), const RealScalar &epsilon=NumTraits< Scalar >::dummy_precision()) const
Definition: SparseView.h:214
Derived & derived()
Definition: EigenBase.h:44
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:37
const unsigned int RowMajorBit
Definition: Constants.h:61
Definition: EigenBase.h:28
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:78
Base class of any sparse matrices or sparse expressions.
Definition: ForwardDeclarations.h:278
Index outerSize() const
Definition: SparseMatrixBase.h:176
const internal::eval< Derived >::type eval() const
Definition: SparseMatrixBase.h:369
InnerVectorReturnType innerVector(Index outer)
Definition: SparseBlock.h:322
Definition: SparseMatrixBase.h:74
const ScalarMultipleReturnType operator*(const Scalar &scalar) const
Definition: SparseMatrixBase.h:57
Index cols() const
Definition: SparseMatrixBase.h:165
Scalar value_type
Definition: SparseMatrixBase.h:42
SparseSymmetricPermutationProduct< Derived, Upper|Lower > twistedBy(const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
Definition: SparseMatrixBase.h:309
InnerVectorsReturnType innerVectors(Index outerStart, Index outerSize)
Definition: SparseBlock.h:337
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:104
Expression of a triangular part in a matrix.
Definition: TriangularMatrix.h:186
Index rows() const
Definition: SparseMatrixBase.h:163
ColXpr col(Index i)
Definition: SparseMatrixBase.h:778
Index innerSize() const
Definition: SparseMatrixBase.h:179
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:56
bool isVector() const
Definition: SparseMatrixBase.h:173
Definition: SparseMatrixBase.h:67
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48