9#include <kernel/adjacency/graph.hpp> 
   10#include <kernel/lafem/vector_mirror.hpp> 
   11#include <kernel/lafem/matrix_mirror_buffer.hpp> 
   12#include <kernel/lafem/sparse_matrix_bcsr.hpp> 
   13#include <kernel/lafem/sparse_matrix_csr.hpp> 
   14#include <kernel/lafem/sparse_matrix_banded.hpp> 
   31    template<
typename DT_, 
typename IT_>
 
   98      template<
int bw_, 
int bh_>
 
  151        XASSERT(buffer.
rows() == this->_row_mirror.num_indices());
 
  153        XASSERT(matrix.
rows() == this->_row_mirror.size());
 
  157        const IT_* row_ptr_a(matrix.
row_ptr());
 
  158        const IT_* col_idx_a(matrix.
col_ind());
 
  159        const DT_* val_a(matrix.
val());
 
  162        const IT_* row_ptr_b(buffer.
row_ptr());
 
  163        const IT_* col_idx_b(buffer.
col_ind());
 
  164        DT_* val_b(buffer.
val());
 
  167        const IT_* mir_idx_r(this->_row_mirror.
indices());
 
  168        const IT_* mir_idx_c(this->_col_mirror.
indices());
 
  171        for(IT_ i(0); i < IT_(buffer.
rows()); ++i)
 
  174          const IT_ ridx = mir_idx_r[i];
 
  177          for(IT_ j(row_ptr_b[i]); j < row_ptr_b[i+1]; ++j)
 
  183            const IT_ cidx = mir_idx_c[col_idx_b[j]];
 
  186            for(IT_ k(row_ptr_a[ridx]); k < row_ptr_a[ridx+1]; ++k)
 
  188              if(col_idx_a[k] == cidx)
 
  213        const DT_ alpha = DT_(1))
 const 
  216        XASSERT(buffer.
rows() == this->_row_mirror.num_indices());
 
  218        XASSERT(matrix.
rows() == this->_row_mirror.size());
 
  222        const IT_* row_ptr_a(matrix.
row_ptr());
 
  223        const IT_* col_idx_a(matrix.
col_ind());
 
  224        DT_* val_a(matrix.
val());
 
  227        const IT_* row_ptr_b(buffer.
row_ptr());
 
  228        const IT_* col_idx_b(buffer.
col_ind());
 
  229        const DT_* val_b(buffer.
val());
 
  232        const IT_* mir_idx_r(this->_row_mirror.
indices());
 
  233        const IT_* mir_idx_c(this->_col_mirror.
indices());
 
  236        for(IT_ i(0); i < IT_(buffer.
rows()); ++i)
 
  239          const IT_ ridx = mir_idx_r[i];
 
  242          for(IT_ j(row_ptr_b[i]); j < row_ptr_b[i+1]; ++j)
 
  245            const IT_ cidx = mir_idx_c[col_idx_b[j]];
 
  248            for(IT_ k(row_ptr_a[ridx]); k < row_ptr_a[ridx+1]; ++k)
 
  250              if(col_idx_a[k] == cidx)
 
  252                val_a[k] += alpha*val_b[j];
 
  269      template<
int bw_, 
int bh_>
 
  275        XASSERT(buffer.
rows() == this->_row_mirror.num_indices());
 
  277        XASSERT(matrix.
rows() == this->_row_mirror.size());
 
  283        const IT_* row_ptr_a(matrix.
row_ptr());
 
  284        const IT_* col_idx_a(matrix.
col_ind());
 
  285        const ValueType* val_a(matrix.
val());
 
  288        const IT_* row_ptr_b(buffer.
row_ptr());
 
  289        const IT_* col_idx_b(buffer.
col_ind());
 
  290        ValueType* val_b = 
reinterpret_cast<ValueType*
>(buffer.
val());
 
  293        const IT_* mir_idx_r(this->_row_mirror.
indices());
 
  294        const IT_* mir_idx_c(this->_col_mirror.
indices());
 
  297        for(IT_ i(0); i < IT_(buffer.
rows()); ++i)
 
  300          const IT_ ridx = mir_idx_r[i];
 
  303          for(IT_ j(row_ptr_b[i]); j < row_ptr_b[i+1]; ++j)
 
  309            const IT_ cidx = mir_idx_c[col_idx_b[j]];
 
  312            for(IT_ k(row_ptr_a[ridx]); k < row_ptr_a[ridx+1]; ++k)
 
  314              if(col_idx_a[k] == cidx)
 
  336      template<
int bw_, 
int bh_>
 
  340        const DT_ alpha = DT_(1))
 const 
  343        XASSERT(buffer.
rows() == this->_row_mirror.num_indices());
 
  345        XASSERT(matrix.
rows() == this->_row_mirror.size());
 
  351        const IT_* row_ptr_a(matrix.
row_ptr());
 
  352        const IT_* col_idx_a(matrix.
col_ind());
 
  353        ValueType* val_a(matrix.
val());
 
  356        const IT_* row_ptr_b(buffer.
row_ptr());
 
  357        const IT_* col_idx_b(buffer.
col_ind());
 
  358        const ValueType* val_b = 
reinterpret_cast<const ValueType*
>(buffer.
val());
 
  361        const IT_* mir_idx_r(this->_row_mirror.
indices());
 
  362        const IT_* mir_idx_c(this->_col_mirror.
indices());
 
  365        for(IT_ i(0); i < IT_(buffer.
rows()); ++i)
 
  368          const IT_ ridx = mir_idx_r[i];
 
  371          for(IT_ j(row_ptr_b[i]); j < row_ptr_b[i+1]; ++j)
 
  374            const IT_ cidx = mir_idx_c[col_idx_b[j]];
 
  377            for(IT_ k(row_ptr_a[ridx]); k < row_ptr_a[ridx+1]; ++k)
 
  379              if(col_idx_a[k] == cidx)
 
  381                val_a[k].axpy(alpha, val_b[j]);
 
  617      template<
typename MT_>
 
  631        const Index* dom_ptr = mat_graph.get_domain_ptr();
 
  632        const Index* img_idx = mat_graph.get_image_idx();
 
  641        std::map<Index,Index> col_map;
 
  642        for(
Index i(0); i < ncols; ++i)
 
  643          col_map.emplace(cidx[i], i);
 
  647        for(
Index i(0); i < nrows; ++i)
 
  649          const Index irow = ridx[i];
 
  650          for(
Index j(dom_ptr[irow]); j < dom_ptr[irow+1]; ++j)
 
  652            if(col_map.find(img_idx[j]) != col_map.end())
 
  658        Adjacency::Graph graph(nrows, ncols, count);
 
  659        Index* row_ptr = graph.get_domain_ptr();
 
  660        Index* col_idx = graph.get_image_idx();
 
  663        row_ptr[0] = 
Index(0);
 
  664        for(
Index i(0); i < nrows; ++i)
 
  666          const Index irow = ridx[i];
 
  667          Index k = row_ptr[i];
 
  668          for(
Index j(dom_ptr[irow]); j < dom_ptr[irow+1]; ++j)
 
  670            auto it = col_map.find(img_idx[j]);
 
  671            if(it != col_map.end())
 
  673              col_idx[k] = it->second;
 
  679        XASSERT(row_ptr[nrows] == count);
 
  682        graph.sort_indices();
 
#define XASSERT(expr)
Assertion macro definition.
Adjacency Graph implementation.
Matrix Mirror Buffer class template.
DT_ * val()
Retrieve non zero element array.
Index columns() const
Retrieve matrix column count.
IT_ * row_ptr()
Retrieve row start index array.
IT_ * col_ind()
Retrieve column indices array.
Index entries_per_nonzero() const
Retrieve entries per non zero element count.
Index rows() const
Retrieve matrix row count.
Matrix-Mirror class template.
IT_ IndexType
index-type typedef
void scatter_axpy(LAFEM::SparseMatrixCSR< DT_, IT_ > &matrix, const LAFEM::MatrixMirrorBuffer< DT_, IT_ > &buffer, const DT_ alpha=DT_(1)) const
Performs a scatter-axpy-operation on an operator matrix.
MatrixMirror(MatrixMirror &&other)
move constructor
LAFEM::VectorMirror< DT_, IT_ > VectorMirrorType
vector mirror type
const VectorMirrorType & _row_mirror
row-mirror reference
MatrixMirror(const VectorMirrorType &row_mirror, const VectorMirrorType &col_mirror)
Constructor.
DT_ DataType
data-type typedef
void gather(LAFEM::MatrixMirrorBuffer< DT_, IT_ > &buffer, const LAFEM::SparseMatrixBCSR< DT_, IT_, bw_, bh_ > &matrix) const
Performs a gather-operation on an operator matrix.
LAFEM::MatrixMirrorBuffer< DT_, IT_ > create_buffer(const LAFEM::SparseMatrixBanded< DT_, IT_ > &matrix) const
Creates a buffer matrix based on a banded template matrix.
void scatter_axpy(LAFEM::SparseMatrixBCSR< DT_, IT_, bw_, bh_ > &matrix, const LAFEM::MatrixMirrorBuffer< DT_, IT_ > &buffer, const DT_ alpha=DT_(1)) const
Performs a scatter-axpy-operation on an operator matrix.
const VectorMirrorType & get_row_mirror() const
virtual ~MatrixMirror()
virtual destructor
LAFEM::MatrixMirrorBuffer< DT_, IT_ > create_buffer(const LAFEM::SparseMatrixBCSR< DT_, IT_, bw_, bh_ > &matrix) const
Creates a buffer matrix based on a BCSR template matrix.
const VectorMirrorType & get_col_mirror() const
LAFEM::MatrixMirrorBuffer< DT_, IT_ > create_buffer(const LAFEM::SparseMatrixCSR< DT_, IT_ > &matrix) const
Creates a buffer matrix based on a CSR template matrix.
const VectorMirrorType & _col_mirror
col-mirror reference
void gather(LAFEM::MatrixMirrorBuffer< DT_, IT_ > &buffer, const LAFEM::SparseMatrixCSR< DT_, IT_ > &matrix) const
Performs a gather-operation on an operator matrix.
CSR based blocked sparse matrix.
Index rows() const
Retrieve matrix row count.
IT_ * col_ind()
Retrieve column indices array.
IT_ * row_ptr()
Retrieve row start index array.
Index columns() const
Retrieve matrix column count.
auto val() const -> const typename Intern::BCSRPerspectiveHelper< DT_, BlockHeight_, BlockWidth_, perspective_ >::Type *
Retrieve non zero element array.
IT_ * col_ind()
Retrieve column indices array.
DT_ * val()
Retrieve non zero element array.
Index rows() const
Retrieve matrix row count.
Index columns() const
Retrieve matrix column count.
IT_ * row_ptr()
Retrieve row start index array.
Handles vector prolongation, restriction and serialization.
IT_ * indices()
Get a pointer to the non zero indices array.
Index num_indices() const
Returns the number of indices in the mirror.
Tiny Matrix class template.
@ injectify
Render-Injectified mode.
std::uint64_t Index
Index data type.