Skip to content
Snippets Groups Projects
Commit 24e95c14 authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

[container.eigen] update backend/ensure_uniqueness usage

parent f4af3f53
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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)
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment