10#include <kernel/lafem/sparse_matrix_csr.hpp>
11#include <kernel/lafem/sparse_matrix_bcsr.hpp>
12#include <kernel/lafem/dense_vector.hpp>
13#include <kernel/lafem/sparse_vector.hpp>
14#include <kernel/lafem/arch/unit_filter_dense_vec.hpp>
15#include <kernel/lafem/arch/unit_filter_dense_csr.hpp>
16#include <kernel/lafem/arch/unit_filter_dense_weak_csr.hpp>
42 template <
typename DT2_ = DT_,
typename IT2_ = IT_>
46 template <
typename DataType2_,
typename IndexType2_>
49 static constexpr bool is_global =
false;
50 static constexpr bool is_local =
true;
70 _sv(size_in, num_nzes_in)
82 _sv(size_in, values, indices)
113 _sv = std::forward<SparseVector<DT_, IT_>>(other._sv);
127 other.clone(*
this, clone_mode);
134 _sv.clone(other.get_filter_vector(), clone_mode);
138 template<
typename DT2_,
typename IT2_>
141 _sv.convert(other.get_filter_vector());
162 const SparseVector<DT_, IT_>& get_filter_vector()
const
177 return _sv.size_raw();
183 return _sv.num_nzes();
189 return _sv.num_nzes_raw();
207 return _sv.elements_arbiter();
213 return _sv.elements_arbiter();
219 return _sv.elements_view_r(loc);
225 return _sv.elements_view_w(loc);
231 return _sv.elements_view_rw(loc);
245 return _sv.elements_view(loc, acc);
251 return _sv.indices_arbiter();
257 return _sv.indices_arbiter();
263 return _sv.indices_view_r(loc);
269 return _sv.indices_view_w(loc);
275 return _sv.indices_view_rw(loc);
289 return _sv.indices_view(loc, acc);
345 _sv.indices_arbiter(),
_sv.num_nzes(),
true, 1);
353 XASSERTM(
_sv.size() == matrix.num_rows(),
"Matrix size does not match!");
355 Arch::UnitFilterDenseCSR::template exec<DT_, IT_>(matrix.val_arbiter(), matrix.row_ptr_arbiter(), matrix.col_idx_arbiter(),
356 _sv.indices_arbiter(),
_sv.num_nzes(),
false, 1);
364 template<
int block_w
idth_>
370 XASSERTM(
_sv.size() == matrix.num_rows(),
"Matrix size does not match!");
372 Arch::UnitFilterDenseCSR::template exec<DT_, IT_>(matrix.val_arbiter(), matrix.row_ptr_arbiter(), matrix.col_idx_arbiter(),
373 _sv.indices_arbiter(),
_sv.num_nzes(),
false, block_width_);
376 template<
int block_height_>
408 Arch::UnitFilterDenseWeakCSR::template exec<DT_, IT_>(
410 _sv.elements_arbiter(),
_sv.indices_arbiter(),
_sv.num_nzes());
427 Arch::UnitFilterDenseVec::template exec<DT_, IT_>(vector.
elements_arbiter(),
428 _sv.elements_arbiter(),
_sv.indices_arbiter(),
_sv.num_nzes(),
false);
456 Arch::UnitFilterDenseVec::template exec<DT_, IT_>(vector.
elements_arbiter(),
457 _sv.elements_arbiter(),
_sv.indices_arbiter(),
_sv.num_nzes(),
true);
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Dense data vector class template.
Memory::Arbiter & elements_arbiter()
Returns a reference to the element array arbiter.
Index size() const
Returns the size of this vector, i.e. its number of entries.
Memory::Arbiter & val_arbiter()
Returns a reference to the values array arbiter.
Index num_cols() const
Retrieve matrix column count.
Index num_rows() const
Retrieve matrix row count.
Memory::Arbiter & col_idx_arbiter()
Returns a reference to the column-index array arbiter.
Index num_nzes() const
Retrieve non zero element count.
Memory::Arbiter & row_ptr_arbiter()
Returns a reference to the row-pointer array arbiter.
Sparse vector class template.
Unit Filter class template.
Memory::Arbiter & indices_arbiter()
Returns a reference to the indices memory arbiter.
UnitFilter clone(CloneMode clone_mode=CloneMode::Deep) const
Creates a clone of itself.
UnitFilter()
default constructor
Memory::TypedView< IT_ > indices_view_w(Memory::Location loc=Memory::Location::main)
Creates a write-only memory view for the indices array for a given memory location.
UnitFilter(Index size_in, Index num_nzes_in)
Constructor.
void clone(const UnitFilter &other, CloneMode clone_mode=CloneMode::Deep)
Clones data from another UnitFilter.
DenseVector< DataType, IndexType > VectorType
our supported vector type
void permute(Adjacency::Permutation &perm)
Permute internal vector according to the given Permutation.
SparseVector< DT_, IT_ > _sv
SparseVector, containing all entries of the unit filter.
void filter_mat(MatrixType &matrix) const
Applies the filter onto a system matrix.
void filter_weak_matrix_rows(SparseMatrixCSR< DT_, IT_ > &matrix_a, const SparseMatrixCSR< DT_, IT_ > &matrix_m) const
Replaces the rows of the system matrix by scaled rows of another matrix.
Memory::TypedView< DT_ > elements_view_rw(Memory::Location loc=Memory::Location::main)
Creates a read-write memory view for the elements array for a given memory location.
Index num_nzes() const
Returns the number of non-zero entries in the filter.
void filter_def(DenseVector< DT_, IT_ > &vector) const
Applies the filter onto a defect vector.
void filter_cor(DenseVector< DT_, IT_ > &vector) const
Applies the filter onto a correction vector.
Memory::TypedView< DT_ > elements_view_w(Memory::Location loc=Memory::Location::main)
Creates a write-only memory view for the elements array for a given memory location.
UnitFilter(Index size_in, DenseVector< DT_, IT_ > &values, DenseVector< IT_, IT_ > &indices)
Constructor.
Index size() const
Returns the total native size of the filter.
void filter_offdiag_col_mat(MatrixType &matrix) const
Filter the non-diagonal entries, column wise.
Index num_nzes_raw() const
Returns the raw number of non-zero entries in the filter.
void filter_offdiag_row_mat(MatrixType &matrix) const
Filter the non-diagonal entries, row wise.
Memory::TypedView< DT_ > elements_view(Memory::Location loc, Memory::Access acc)
Creates a memory view for the elements array.
UnitFilter & operator=(UnitFilter &&other)
move-assignment operator
void filter_rhs(DenseVector< DT_, IT_ > &vector) const
Applies the filter onto the right-hand-side vector.
void convert(const UnitFilter< DT2_, IT2_ > &other)
Converts data from another UnitFilter.
Memory::TypedView< DT_ > elements_view_r(Memory::Location loc=Memory::Location::main) const
Creates a read-only memory view for the elements array for a given memory location.
virtual ~UnitFilter()
virtual destructor
const Memory::Arbiter & indices_arbiter() const
Returns a const reference to the indices memory arbiter.
Memory::TypedView< IT_ > indices_view(Memory::Location loc, Memory::Access acc)
Creates a memory view for the indices array.
std::size_t bytes() const
Returns the total amount of bytes allocated.
void filter_sol(DenseVector< DT_, IT_ > &vector) const
Applies the filter onto the solution vector.
UnitFilter(UnitFilter &&other)
move-ctor
Memory::Arbiter & elements_arbiter()
Returns a reference to the elements memory arbiter.
bool empty() const
Checks whether the size of the filter is zero.
bool hollow() const
Checks whether the filter does not contain any non-zero elements.
UnitFilter(SparseVector< DT_, IT_ > &&sv)
Constructor.
DT_ DataType
data-type typedef
Memory::TypedView< IT_ > indices_view_r(Memory::Location loc=Memory::Location::main) const
Creates a read-only memory view for the indices array for a given memory location.
IT_ IndexType
index-type typedef
Index size_raw() const
Returns the total raw size of the filter.
Memory::TypedView< IT_ > indices_view_rw(Memory::Location loc=Memory::Location::main)
Creates a read-write memory view for the indices array for a given memory location.
void clear()
Clears the underlying data (namely the SparseVector)
const Memory::Arbiter & elements_arbiter() const
Returns a const reference to the elements memory arbiter.
Access
Memory access enumeration.
Location
Memory location enumeration.
std::uint64_t Index
Index data type.