10 #ifndef EIGEN_SPARSEMATRIXBASE_H
11 #define EIGEN_SPARSEMATRIXBASE_H
30 typedef typename internal::traits<Derived>::Scalar Scalar;
37 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
38 typedef typename internal::traits<Derived>::StorageKind StorageKind;
39 typedef typename internal::traits<Derived>::StorageIndex StorageIndex;
40 typedef typename internal::add_const_on_value_type_if_arithmetic<
41 typename internal::packet_traits<Scalar>::type
42 >::type PacketReturnType;
49 template<
typename OtherDerived>
67 SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
68 internal::traits<Derived>::ColsAtCompileTime>::ret),
76 MaxSizeAtCompileTime = (internal::size_at_compile_time<MaxRowsAtCompileTime,
77 MaxColsAtCompileTime>::ret),
85 Flags = internal::traits<Derived>::Flags,
95 #ifndef EIGEN_PARSED_BY_DOXYGEN
101 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
104 >::type AdjointReturnType;
111 #ifndef EIGEN_PARSED_BY_DOXYGEN
122 typedef typename internal::conditional<_HasDirectAccess, const Scalar&, Scalar>::type CoeffReturnType;
133 inline const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
134 inline Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
135 inline Derived& const_cast_derived()
const
136 {
return *
static_cast<Derived*
>(
const_cast<SparseMatrixBase*
>(
this)); }
137 #endif // not EIGEN_PARSED_BY_DOXYGEN
139 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase
140 # include "../plugins/CommonCwiseUnaryOps.h"
141 # include "../plugins/CommonCwiseBinaryOps.h"
142 # include "../plugins/MatrixCwiseUnaryOps.h"
143 # include "../plugins/MatrixCwiseBinaryOps.h"
144 # include "../plugins/BlockMethods.h"
145 # ifdef EIGEN_SPARSEMATRIXBASE_PLUGIN
146 # include EIGEN_SPARSEMATRIXBASE_PLUGIN
148 # undef EIGEN_CURRENT_STORAGE_BASE_CLASS
149 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
170 bool isRValue()
const {
return m_isRValue; }
171 Derived& markAsRValue() { m_isRValue =
true;
return derived(); }
176 template<
typename OtherDerived>
177 Derived& operator=(
const ReturnByValue<OtherDerived>& other);
179 template<
typename OtherDerived>
182 inline Derived& operator=(
const Derived& other);
186 template<
typename OtherDerived>
187 inline Derived& assign(
const OtherDerived& other);
189 template<
typename OtherDerived>
190 inline void assignGeneric(
const OtherDerived& other);
194 friend std::ostream & operator << (std::ostream & s,
const SparseMatrixBase& m)
196 typedef typename Derived::Nested Nested;
197 typedef typename internal::remove_all<Nested>::type NestedCleaned;
205 for (
typename NestedCleaned::InnerIterator it(nm.derived(),
row); it; ++it)
207 for ( ; col<it.index(); ++
col)
209 s << it.value() <<
" ";
222 for (
typename NestedCleaned::InnerIterator it(nm.derived(), 0); it; ++it)
224 for ( ; row<it.index(); ++
row)
225 s <<
"0" << std::endl;
226 s << it.value() << std::endl;
230 s <<
"0" << std::endl;
234 SparseMatrix<Scalar, RowMajorBit, StorageIndex> trans = m;
235 s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit, StorageIndex> >&>(trans);
241 template<
typename OtherDerived>
242 Derived& operator+=(
const SparseMatrixBase<OtherDerived>& other);
243 template<
typename OtherDerived>
246 template<
typename OtherDerived>
247 Derived& operator+=(
const DiagonalBase<OtherDerived>& other);
248 template<
typename OtherDerived>
249 Derived& operator-=(
const DiagonalBase<OtherDerived>& other);
251 Derived& operator*=(
const Scalar& other);
252 Derived& operator/=(
const Scalar& other);
254 #define EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE \
256 internal::scalar_product_op< \
257 typename internal::scalar_product_traits< \
258 typename internal::traits<Derived>::Scalar, \
259 typename internal::traits<OtherDerived>::Scalar \
266 template<
typename OtherDerived>
267 EIGEN_STRONG_INLINE
const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE
271 template<
typename OtherDerived>
273 operator*(
const DiagonalBase<OtherDerived> &other)
const
277 template<
typename OtherDerived>
friend
283 template<
typename OtherDerived>
284 const Product<Derived,OtherDerived>
285 operator*(
const SparseMatrixBase<OtherDerived> &other)
const;
288 template<
typename OtherDerived>
289 const Product<Derived,OtherDerived>
290 operator*(
const MatrixBase<OtherDerived> &other)
const
291 {
return Product<Derived,OtherDerived>(
derived(), other.derived()); }
294 template<
typename OtherDerived>
friend
295 const Product<OtherDerived,Derived>
296 operator*(
const MatrixBase<OtherDerived> &lhs,
const SparseMatrixBase& rhs)
302 return SparseSymmetricPermutationProduct<Derived,Upper|Lower>(
derived(), perm);
305 template<
typename OtherDerived>
314 template<
unsigned int UpLo>
inline
315 typename ConstSelfAdjointViewReturnType<UpLo>::Type selfadjointView()
const;
316 template<
unsigned int UpLo>
inline
317 typename SelfAdjointViewReturnType<UpLo>::Type selfadjointView();
319 template<
typename OtherDerived> Scalar dot(
const MatrixBase<OtherDerived>& other)
const;
320 template<
typename OtherDerived> Scalar dot(
const SparseMatrixBase<OtherDerived>& other)
const;
321 RealScalar squaredNorm()
const;
322 RealScalar norm()
const;
323 RealScalar blueNorm()
const;
325 TransposeReturnType transpose() {
return TransposeReturnType(
derived()); }
326 const ConstTransposeReturnType transpose()
const {
return ConstTransposeReturnType(
derived()); }
327 const AdjointReturnType adjoint()
const {
return AdjointReturnType(transpose()); }
341 DenseMatrixType toDense()
const
343 return DenseMatrixType(
derived());
346 template<
typename OtherDerived>
350 template<
typename OtherDerived>
353 {
return toDense().isApprox(other,prec); }
360 inline const typename internal::eval<Derived>::type
eval()
const
361 {
return typename internal::eval<Derived>::type(
derived()); }
365 inline const SparseView<Derived>
372 static inline StorageIndex convert_index(
const Index idx) {
373 return internal::convert_index<StorageIndex>(idx);
376 template<
typename Dest>
void evalTo(Dest &)
const;
381 #endif // EIGEN_SPARSEMATRIXBASE_H
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:44
Index size() const
Definition: SparseMatrixBase.h:157
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:107
A versatible sparse matrix representation.
Definition: SparseMatrix.h:92
Expression of the transpose of a matrix.
Definition: Transpose.h:53
const unsigned int DirectAccessBit
Definition: Constants.h:141
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
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:213
Definition: SparseMatrixBase.h:67
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:53
Definition: SparseMatrixBase.h:54
Definition: EigenBase.h:28
Base class of any sparse matrices or sparse expressions.
Definition: SparseMatrixBase.h:26
Index outerSize() const
Definition: SparseMatrixBase.h:165
const internal::eval< Derived >::type eval() const
Definition: SparseMatrixBase.h:360
InnerVectorReturnType innerVector(Index outer)
Definition: SparseBlock.h:299
const ScalarMultipleReturnType operator*(const Scalar &scalar) const
Definition: SparseMatrixBase.h:57
Index cols() const
Definition: SparseMatrixBase.h:154
Scalar value_type
Definition: SparseMatrixBase.h:35
SparseSymmetricPermutationProduct< Derived, Upper|Lower > twistedBy(const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
Definition: SparseMatrixBase.h:300
Definition: SparseMatrixBase.h:79
InnerVectorsReturnType innerVectors(Index outerStart, Index outerSize)
Definition: SparseBlock.h:314
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:152
ColXpr col(Index i)
Definition: SparseMatrixBase.h:778
Definition: SparseMatrixBase.h:85
Index innerSize() const
Definition: SparseMatrixBase.h:168
Definition: SparseMatrixBase.h:60
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:56
bool isVector() const
Definition: SparseMatrixBase.h:162
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48