32 typedef typename internal::traits<Derived>::Scalar Scalar;
39 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
40 typedef typename internal::traits<Derived>::StorageKind StorageKind;
44 typedef typename internal::traits<Derived>::StorageIndex
StorageIndex;
46 typedef typename internal::add_const_on_value_type_if_arithmetic<typename internal::packet_traits<Scalar>::type>::type
54 template <
typename OtherDerived>
79 MaxSizeAtCompileTime = internal::size_at_compile_time(MaxRowsAtCompileTime, MaxColsAtCompileTime),
94 Flags = internal::traits<Derived>::Flags,
105#ifndef EIGEN_PARSED_BY_DOXYGEN
111 typedef std::conditional_t<NumTraits<Scalar>::IsComplex,
121#ifndef EIGEN_PARSED_BY_DOXYGEN
128 typedef typename NumTraits<Scalar>::Real RealScalar;
132 typedef std::conditional_t<HasDirectAccess_, const Scalar&, Scalar> CoeffReturnType;
144 inline const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
145 inline Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
146 inline Derived& const_cast_derived()
const {
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, \
157#define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
160#define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF( \
164#define EIGEN_DOC_UNARY_ADDONS(X, Y)
165#define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
166#define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND)
168#include "../plugins/CommonCwiseUnaryOps.inc"
169#include "../plugins/CommonCwiseBinaryOps.inc"
170#include "../plugins/MatrixCwiseUnaryOps.inc"
171#include "../plugins/MatrixCwiseBinaryOps.inc"
172#include "../plugins/BlockMethods.inc"
173#ifdef EIGEN_SPARSEMATRIXBASE_PLUGIN
174#include EIGEN_SPARSEMATRIXBASE_PLUGIN
176#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
177#undef EIGEN_DOC_UNARY_ADDONS
178#undef EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
179#undef EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF
200 bool isRValue()
const {
return m_isRValue; }
201 Derived& markAsRValue() {
206 SparseMatrixBase() : m_isRValue(false) {
209 template <
typename OtherDerived>
210 Derived& operator=(
const ReturnByValue<OtherDerived>& other);
212 template <
typename OtherDerived>
213 inline Derived& operator=(
const SparseMatrixBase<OtherDerived>& other);
215 inline Derived& operator=(
const Derived& other);
218 template <
typename OtherDerived>
219 inline Derived& assign(
const OtherDerived& other);
221 template <
typename OtherDerived>
222 inline void assignGeneric(
const OtherDerived& other);
226 friend std::ostream& operator<<(std::ostream& s,
const SparseMatrixBase& m) {
227 typedef typename Derived::Nested Nested;
228 typedef internal::remove_all_t<Nested> NestedCleaned;
231 Nested nm(m.derived());
232 internal::evaluator<NestedCleaned> thisEval(nm);
233 for (Index row = 0; row < nm.outerSize(); ++row) {
235 for (
typename internal::evaluator<NestedCleaned>::InnerIterator it(thisEval, row); it; ++it) {
236 for (; col < it.index(); ++col) s <<
"0 ";
237 s << it.value() <<
" ";
240 for (; col < m.cols(); ++col) s <<
"0 ";
244 Nested nm(m.derived());
245 internal::evaluator<NestedCleaned> thisEval(nm);
248 for (
typename internal::evaluator<NestedCleaned>::InnerIterator it(thisEval, 0); it; ++it) {
249 for (; row < it.index(); ++row) s <<
"0" << std::endl;
250 s << it.value() << std::endl;
253 for (; row < m.rows(); ++row) s <<
"0" << std::endl;
255 SparseMatrix<Scalar, RowMajorBit, StorageIndex> trans = m;
256 s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit, StorageIndex> >&>(trans);
263 template <
typename OtherDerived>
264 Derived& operator+=(
const SparseMatrixBase<OtherDerived>& other);
265 template <
typename OtherDerived>
266 Derived& operator-=(
const SparseMatrixBase<OtherDerived>& other);
268 template <
typename OtherDerived>
269 Derived& operator+=(
const DiagonalBase<OtherDerived>& other);
270 template <
typename OtherDerived>
271 Derived& operator-=(
const DiagonalBase<OtherDerived>& other);
273 template <
typename OtherDerived>
274 Derived& operator+=(
const EigenBase<OtherDerived>& other);
275 template <
typename OtherDerived>
276 Derived& operator-=(
const EigenBase<OtherDerived>& other);
278 Derived& operator*=(
const Scalar& other);
279 Derived& operator/=(
const Scalar& other);
281 template <
typename OtherDerived>
282 struct CwiseProductDenseReturnType {
283 typedef CwiseBinaryOp<
284 internal::scalar_product_op<
typename ScalarBinaryOpTraits<
285 typename internal::traits<Derived>::Scalar,
typename internal::traits<OtherDerived>::Scalar>::ReturnType>,
286 const Derived,
const OtherDerived>
290 template <
typename OtherDerived>
291 EIGEN_STRONG_INLINE
const typename CwiseProductDenseReturnType<OtherDerived>::Type cwiseProduct(
292 const MatrixBase<OtherDerived>& other)
const;
295 template <
typename OtherDerived>
296 const Product<Derived, OtherDerived> operator*(
const DiagonalBase<OtherDerived>& other)
const {
297 return Product<Derived, OtherDerived>(
derived(), other.derived());
301 template <
typename OtherDerived>
302 friend const Product<OtherDerived, Derived> operator*(
const DiagonalBase<OtherDerived>& lhs,
303 const SparseMatrixBase& rhs) {
304 return Product<OtherDerived, Derived>(lhs.derived(), rhs.derived());
308 template <
typename OtherDerived>
309 const Product<Derived, OtherDerived, AliasFreeProduct> operator*(
const SparseMatrixBase<OtherDerived>& other)
const;
312 template <
typename OtherDerived>
313 const Product<Derived, OtherDerived> operator*(
const MatrixBase<OtherDerived>& other)
const {
314 return Product<Derived, OtherDerived>(
derived(), other.derived());
318 template <
typename OtherDerived>
319 friend const Product<OtherDerived, Derived> operator*(
const MatrixBase<OtherDerived>& lhs,
320 const SparseMatrixBase& rhs) {
321 return Product<OtherDerived, Derived>(lhs.derived(), rhs.derived());
325 SparseSymmetricPermutationProduct<Derived, Upper | Lower>
twistedBy(
327 return SparseSymmetricPermutationProduct<Derived, Upper | Lower>(
derived(), perm);
330 template <
typename OtherDerived>
336 template <
unsigned int UpLo>
337 struct SelfAdjointViewReturnType {
340 template <
unsigned int UpLo>
341 struct ConstSelfAdjointViewReturnType {
342 typedef const SparseSelfAdjointView<const Derived, UpLo> Type;
345 template <
unsigned int UpLo>
346 inline typename ConstSelfAdjointViewReturnType<UpLo>::Type selfadjointView()
const;
347 template <
unsigned int UpLo>
348 inline typename SelfAdjointViewReturnType<UpLo>::Type selfadjointView();
350 template <
typename OtherDerived>
351 Scalar dot(
const MatrixBase<OtherDerived>& other)
const;
352 template <
typename OtherDerived>
353 Scalar dot(
const SparseMatrixBase<OtherDerived>& other)
const;
354 RealScalar squaredNorm()
const;
355 RealScalar norm()
const;
356 RealScalar blueNorm()
const;
358 TransposeReturnType transpose() {
return TransposeReturnType(
derived()); }
359 const ConstTransposeReturnType transpose()
const {
return ConstTransposeReturnType(
derived()); }
360 const AdjointReturnType adjoint()
const {
return AdjointReturnType(transpose()); }
362 DenseMatrixType toDense()
const {
return DenseMatrixType(
derived()); }
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);
379 inline const typename internal::eval<Derived>::type
eval()
const {
380 return typename internal::eval<Derived>::type(
derived());
391 static inline StorageIndex convert_index(
const Index idx) {
return internal::convert_index<StorageIndex>(idx); }
394 template <
typename Dest>
395 void evalTo(Dest&)
const;