diff --git a/dune/xt/la/container/eigen/base.hh b/dune/xt/la/container/eigen/base.hh index bb3001c23fa5b5c22b4869b6be13769a2065d7f4..e88e9b0c5dd78f0ea784fa78fd8ef09dd9ae183f 100644 --- a/dune/xt/la/container/eigen/base.hh +++ b/dune/xt/la/container/eigen/base.hh @@ -145,7 +145,7 @@ public: ScalarType get_entry(const size_t ii) const { assert(ii < size()); - return backend_->operator[](ii); + return backend()[ii]; } protected: @@ -198,7 +198,7 @@ public: if (other.size() != size()) DUNE_THROW(Common::Exceptions::shapes_do_not_match, "The size of other (" << other.size() << ") does not match the size of this (" << size() << ")!"); - return backend_->transpose() * *(other.backend_); + return backend_->transpose() * other.backend(); } // ... dot(...) virtual ScalarType dot(const VectorImpType& other) const override final @@ -208,17 +208,17 @@ public: virtual RealType l1_norm() const override final { - return backend_->template lpNorm<1>(); + return backend().template lpNorm<1>(); } virtual RealType l2_norm() const override final { - return backend_->template lpNorm<2>(); + return backend().template lpNorm<2>(); } virtual RealType sup_norm() const override final { - return backend_->template lpNorm<::Eigen::Infinity>(); + return backend().template lpNorm<::Eigen::Infinity>(); } template <class T1, class T2> @@ -244,7 +244,7 @@ public: if (other.size() != size()) DUNE_THROW(Common::Exceptions::shapes_do_not_match, "The size of other (" << other.size() << ") does not match the size of this (" << size() << ")!"); - backend() += *(other.backend_); + backend() += other.backend(); } // ... iadd(...) virtual void iadd(const VectorImpType& other) override final diff --git a/dune/xt/la/container/eigen/dense.hh b/dune/xt/la/container/eigen/dense.hh index dfdd9e64cba057a37d6832ec731403bbfbb6aed9..0d3b85cc5e7fbd382ceee8192c975f8029ed65fb 100644 --- a/dune/xt/la/container/eigen/dense.hh +++ b/dune/xt/la/container/eigen/dense.hh @@ -473,8 +473,7 @@ public: << "x" << cols() << ")!"); - const auto& xx_ref = *(xx.backend_); - backend() += alpha * xx_ref; + backend() += alpha * xx.backend(); } // ... axpy(...) bool has_equal_shape(const ThisType& other) const @@ -499,7 +498,7 @@ public: template <class T1, class T2> inline void mv(const EigenBaseVector<T1, ScalarType>& xx, EigenBaseVector<T2, ScalarType>& yy) const { - yy.backend().transpose() = backend_->operator*(*xx.backend_); + yy.backend().transpose() = backend() * xx.backend(); } void add_to_entry(const size_t ii, const size_t jj, const ScalarType& value) @@ -520,7 +519,7 @@ public: { assert(ii < rows()); assert(jj < cols()); - return backend_->operator()(ii, jj); + return backend()(ii, jj); } // ... get_entry(...) void clear_row(const size_t ii) diff --git a/dune/xt/la/container/eigen/sparse.hh b/dune/xt/la/container/eigen/sparse.hh index 01ac1319d8aef05bae1ff03991b2982543dfcdd0..706f507acaea8d2ccf23e0cb884f70034677ad1c 100644 --- a/dune/xt/la/container/eigen/sparse.hh +++ b/dune/xt/la/container/eigen/sparse.hh @@ -217,7 +217,7 @@ public: void scal(const ScalarType& alpha) { backend() *= alpha; - } // ... scal(...) + } void axpy(const ScalarType& alpha, const ThisType& xx) { @@ -228,8 +228,7 @@ public: << "x" << cols() << ")!"); - const auto& xx_ref = *(xx.backend_); - backend() += alpha * xx_ref; + backend() += alpha * xx.backend(); } // ... axpy(...) bool has_equal_shape(const ThisType& other) const @@ -254,7 +253,7 @@ public: template <class T1, class T2> inline void mv(const EigenBaseVector<T1, ScalarType>& xx, EigenBaseVector<T2, ScalarType>& yy) const { - yy.backend().transpose() = backend_->operator*(*xx.backend_); + yy.backend().transpose() = backend() * xx.backend(); } void add_to_entry(const size_t ii, const size_t jj, const ScalarType& value) @@ -275,7 +274,7 @@ public: { assert(ii < rows()); assert(jj < cols()); - return backend_->coeff(internal::boost_numeric_cast<EIGEN_size_t>(ii), + return backend().coeff(internal::boost_numeric_cast<EIGEN_size_t>(ii), internal::boost_numeric_cast<EIGEN_size_t>(jj)); } @@ -289,10 +288,10 @@ public: void clear_col(const size_t jj) { + ensure_uniqueness(); if (jj >= cols()) DUNE_THROW(Common::Exceptions::index_out_of_range, "Given jj (" << jj << ") is larger than the cols of this (" << cols() << ")!"); - ensure_uniqueness(); for (size_t row = 0; internal::boost_numeric_cast<EIGEN_size_t>(row) < backend_->outerSize(); ++row) { for (typename BackendType::InnerIterator row_it(*backend_, internal::boost_numeric_cast<EIGEN_size_t>(row)); row_it; @@ -325,13 +324,13 @@ public: void unit_col(const size_t jj) { + ensure_uniqueness(); if (jj >= cols()) DUNE_THROW(Common::Exceptions::index_out_of_range, "Given jj (" << jj << ") is larger than the cols of this (" << cols() << ")!"); if (jj >= rows()) DUNE_THROW(Common::Exceptions::index_out_of_range, "Given jj (" << jj << ") is larger than the rows of this (" << rows() << ")!"); - ensure_uniqueness(); for (size_t row = 0; internal::boost_numeric_cast<EIGEN_size_t>(row) < backend_->outerSize(); ++row) { for (typename BackendType::InnerIterator row_it(*backend_, internal::boost_numeric_cast<EIGEN_size_t>(row)); row_it; @@ -429,6 +428,7 @@ protected: if (!backend_.unique()) backend_ = std::make_shared<BackendType>(*backend_); } // ... ensure_uniqueness(...) + private: std::shared_ptr<BackendType> backend_; }; // class EigenRowMajorSparseMatrix