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;
40 typedef typename internal::traits<Derived>::StorageIndex StorageIndex;
41 typedef typename internal::add_const_on_value_type_if_arithmetic<
42 typename internal::packet_traits<Scalar>::type
43 >::type PacketReturnType;
50 template<
typename OtherDerived>
68 SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
69 internal::traits<Derived>::ColsAtCompileTime>::ret),
77 MaxSizeAtCompileTime = (internal::size_at_compile_time<MaxRowsAtCompileTime,
78 MaxColsAtCompileTime>::ret),
86 Flags = internal::traits<Derived>::Flags,
96 #ifndef EIGEN_PARSED_BY_DOXYGEN
102 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
105 >::type AdjointReturnType;
112 #ifndef EIGEN_PARSED_BY_DOXYGEN 123 typedef typename internal::conditional<_HasDirectAccess, const Scalar&, Scalar>::type CoeffReturnType;
134 inline const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
135 inline Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
136 inline Derived& const_cast_derived()
const 141 #endif // not EIGEN_PARSED_BY_DOXYGEN 143 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase 144 # include "../plugins/CommonCwiseUnaryOps.h" 145 # include "../plugins/CommonCwiseBinaryOps.h" 146 # include "../plugins/MatrixCwiseUnaryOps.h" 147 # include "../plugins/MatrixCwiseBinaryOps.h" 148 # include "../plugins/BlockMethods.h" 149 # ifdef EIGEN_SPARSEMATRIXBASE_PLUGIN 150 # include EIGEN_SPARSEMATRIXBASE_PLUGIN 152 # undef EIGEN_CURRENT_STORAGE_BASE_CLASS 153 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS 174 bool isRValue()
const {
return m_isRValue; }
175 Derived& markAsRValue() { m_isRValue =
true;
return derived(); }
180 template<
typename OtherDerived>
181 Derived& operator=(
const ReturnByValue<OtherDerived>& other);
183 template<
typename OtherDerived>
186 inline Derived& operator=(
const Derived& other);
190 template<
typename OtherDerived>
191 inline Derived& assign(
const OtherDerived& other);
193 template<
typename OtherDerived>
194 inline void assignGeneric(
const OtherDerived& other);
198 friend std::ostream & operator << (std::ostream & s,
const SparseMatrixBase& m)
200 typedef typename Derived::Nested Nested;
201 typedef typename internal::remove_all<Nested>::type NestedCleaned;
205 const Nested nm(m.derived());
209 for (
typename NestedCleaned::InnerIterator it(nm.derived(),
row); it; ++it)
211 for ( ; col<it.index(); ++
col)
213 s << it.value() <<
" ";
216 for ( ; col<m.cols(); ++
col)
223 const Nested nm(m.derived());
226 for (
typename NestedCleaned::InnerIterator it(nm.derived(), 0); it; ++it)
228 for ( ; row<it.index(); ++
row)
229 s <<
"0" << std::endl;
230 s << it.value() << std::endl;
233 for ( ; row<m.rows(); ++
row)
234 s <<
"0" << std::endl;
239 s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit, StorageIndex> >&>(trans);
245 template<
typename OtherDerived>
247 template<
typename OtherDerived>
250 template<
typename OtherDerived>
251 Derived& operator+=(
const DiagonalBase<OtherDerived>& other);
252 template<
typename OtherDerived>
253 Derived& operator-=(
const DiagonalBase<OtherDerived>& other);
255 Derived& operator*=(
const Scalar& other);
256 Derived& operator/=(
const Scalar& other);
258 template<
typename OtherDerived>
struct CwiseProductDenseReturnType {
260 typename internal::traits<Derived>::Scalar,
261 typename internal::traits<OtherDerived>::Scalar
268 template<
typename OtherDerived>
269 EIGEN_STRONG_INLINE
const typename CwiseProductDenseReturnType<OtherDerived>::Type
273 template<
typename OtherDerived>
275 operator*(
const DiagonalBase<OtherDerived> &other)
const 279 template<
typename OtherDerived>
friend 285 template<
typename OtherDerived>
290 template<
typename OtherDerived>
296 template<
typename OtherDerived>
friend 304 return SparseSymmetricPermutationProduct<Derived,Upper|Lower>(
derived(), perm);
307 template<
typename OtherDerived>
316 template<
unsigned int UpLo>
inline 317 typename ConstSelfAdjointViewReturnType<UpLo>::Type selfadjointView()
const;
318 template<
unsigned int UpLo>
inline 319 typename SelfAdjointViewReturnType<UpLo>::Type selfadjointView();
323 RealScalar squaredNorm()
const;
324 RealScalar norm()
const;
325 RealScalar blueNorm()
const;
327 TransposeReturnType transpose() {
return TransposeReturnType(
derived()); }
328 const ConstTransposeReturnType transpose()
const {
return ConstTransposeReturnType(
derived()); }
329 const AdjointReturnType adjoint()
const {
return AdjointReturnType(transpose()); }
343 DenseMatrixType toDense()
const 345 return DenseMatrixType(
derived());
348 template<
typename OtherDerived>
352 template<
typename OtherDerived>
355 {
return toDense().isApprox(other,prec); }
362 inline const typename internal::eval<Derived>::type
eval()
const 363 {
return typename internal::eval<Derived>::type(
derived()); }
367 inline const SparseView<Derived>
374 static inline StorageIndex convert_index(
const Index idx) {
375 return internal::convert_index<StorageIndex>(idx);
378 template<
typename Dest>
void evalTo(Dest &)
const;
383 #endif // EIGEN_SPARSEMATRIXBASE_H Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:43
Definition: SparseMatrixBase.h:80
Index size() const
Definition: SparseMatrixBase.h:161
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:71
A versatible sparse matrix representation.
Definition: SparseMatrix.h:92
Definition: SparseMatrixBase.h:55
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:802
Namespace containing all symbols from the Eigen library.
Definition: Core:271
const CwiseBinaryOp< internal::scalar_product_op< Scalar, T >, Derived, Constant< T > > operator*(const T &scalar) const
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:167
const SparseView< Derived > pruned(const Scalar &reference=Scalar(0), const RealScalar &epsilon=NumTraits< Scalar >::dummy_precision()) const
Definition: SparseView.h:214
Definition: SparseMatrixBase.h:86
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:77
Base class of any sparse matrices or sparse expressions.
Definition: ForwardDeclarations.h:281
Index outerSize() const
Definition: SparseMatrixBase.h:169
const internal::eval< Derived >::type eval() const
Definition: SparseMatrixBase.h:362
InnerVectorReturnType innerVector(Index outer)
Definition: SparseBlock.h:331
Index cols() const
Definition: SparseMatrixBase.h:158
Scalar value_type
Definition: SparseMatrixBase.h:36
SparseSymmetricPermutationProduct< Derived, Upper|Lower > twistedBy(const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
Definition: SparseMatrixBase.h:302
Definition: SparseMatrixBase.h:61
InnerVectorsReturnType innerVectors(Index outerStart, Index outerSize)
Definition: SparseBlock.h:346
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Expression of a triangular part in a matrix.
Definition: TriangularMatrix.h:186
Definition: SparseMatrixBase.h:68
Index rows() const
Definition: SparseMatrixBase.h:156
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:741
ColXpr col(Index i)
Definition: SparseMatrixBase.h:783
Index innerSize() const
Definition: SparseMatrixBase.h:172
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
bool isVector() const
Definition: SparseMatrixBase.h:166
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48