Skip to content
Snippets Groups Projects
Commit ba9920a8 authored by Tobias Leibner's avatar Tobias Leibner
Browse files

[container] add get_entry_ref to matrix interface

parent 7ffd3eed
No related branches found
No related tags found
No related merge requests found
......@@ -553,6 +553,13 @@ public:
return backend()[ii][jj];
} // ... get_entry(...)
ScalarType& get_entry_ref(const size_t ii, const size_t jj)
{
assert(ii < rows());
assert(jj < cols());
return backend()[ii][jj];
} // ... get_entry(...)
void clear_row(const size_t ii)
{
auto& backend_ref = backend();
......@@ -840,6 +847,15 @@ public:
return index == size_t(-1) ? ScalarType(0) : entries_->operator[](index);
}
inline ScalarType& get_entry_ref(const size_t rr, const size_t cc)
{
std::lock_guard<std::mutex> DUNE_UNUSED(lock)(mutex_);
const size_t index = get_entry_index(rr, cc, false);
if (index == size_t(-1))
DUNE_THROW(Dune::RangeError, "Entry not in matrix pattern!");
return entries_->operator[](index);
}
inline void set_entry(const size_t rr, const size_t cc, const ScalarType value)
{
ensure_uniqueness();
......
......@@ -566,6 +566,13 @@ public:
return backend()(ii, jj);
} // ... get_entry(...)
ScalarType& get_entry_ref(const size_t ii, const size_t jj)
{
assert(ii < rows());
assert(jj < cols());
return backend()(ii, jj);
} // ... get_entry(...)
void clear_row(const size_t ii)
{
auto& backend_ref = backend();
......
......@@ -292,6 +292,15 @@ public:
internal::boost_numeric_cast<EIGEN_size_t>(jj));
}
ScalarType& get_entry_ref(const size_t ii, const size_t jj)
{
std::lock_guard<std::mutex> DUNE_UNUSED(lock)(mutex_);
assert(ii < rows());
assert(jj < cols());
return backend().coeffRef(internal::boost_numeric_cast<EIGEN_size_t>(ii),
internal::boost_numeric_cast<EIGEN_size_t>(jj));
}
void clear_row(const size_t ii)
{
auto& backend_ref = backend();
......
......@@ -558,6 +558,15 @@ public:
return ScalarType(0);
} // ... get_entry(...)
ScalarType& get_entry_ref(const size_t ii, const size_t jj)
{
assert(ii < rows());
assert(jj < cols());
if (!these_are_valid_indices(ii, jj))
DUNE_THROW(Dune::RangeError, "Matrix entry not in pattern!");
return backend_->operator[](ii)[jj][0][0];
} // ... get_entry(...)
void clear_row(const size_t ii)
{
auto& backend_ref = backend();
......
......@@ -86,6 +86,12 @@ public:
return this->as_imp().get_entry(ii, jj);
}
inline ScalarType& get_entry_ref(const size_t ii, const size_t jj)
{
CHECK_CRTP(this->as_imp().get_entry_ref(ii, jj));
return this->as_imp().get_entry_ref(ii, jj);
}
inline void clear_row(const size_t ii)
{
CHECK_AND_CALL_CRTP(this->as_imp().clear_row(ii));
......
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