9#include <kernel/lafem/dense_vector.hpp>
10#include <kernel/lafem/dense_vector_blocked.hpp>
20 template<
typename DT_,
typename IT_,
int size_>
21 struct BlockedVectorHelper
23 static_assert(size_ > 1,
"invalid block size");
24 typedef DenseVectorBlocked<DT_, IT_, size_> VectorType;
27 template<
typename DT_,
typename IT_>
28 struct BlockedVectorHelper<DT_, IT_, 1>
30 typedef DenseVector<DT_, IT_> VectorType;
54 template<
typename DT_,
typename IT_,
int block_height_ = 1,
int block_w
idth_ = 1>
57 static_assert(block_height_ > 0,
"invalid block size");
58 static_assert(block_width_ > 0,
"invalid block size");
76 template <
typename DT2_ = DT_,
typename IT2_ = IT_>
80 template <
typename DataType2_,
typename IndexType2_>
84 typedef typename Intern::BlockedVectorHelper<DT_, IT_, block_height_>::VectorType
VectorTypeL;
86 typedef typename Intern::BlockedVectorHelper<DT_, IT_, block_width_>::VectorType
VectorTypeR;
88 static constexpr bool is_global =
false;
89 static constexpr bool is_local =
true;
116 _num_rows(rows_in), _num_cols(columns_in)
141 this->_num_rows = other._num_rows;
142 this->_num_cols = other._num_cols;
168 template<
typename DT2_,
typename IT2_>
173 this->_num_rows = other.num_rows();
174 this->_num_cols = other.num_cols();
184 template <
typename DT2_,
typename IT2_>
187 this->_num_rows = other.num_rows();
188 this->_num_cols = other.num_cols();
200 return this->_num_cols;
212 return this->_num_rows *
Index(block_height_);
218 return this->_num_cols *
Index(block_width_);
245 this->_num_rows = rows_in;
246 this->_num_cols = columns_in;
256 return std::size_t(0);
295 const DT_ DOXY(alpha) = DT_(1))
302 XASSERTM(x.
num_nzes() == this->num_nzes(),
"Matrix used_elements do not match!");
317 XASSERTM(x.
num_nzes() == this->num_nzes(),
"Nonzero count does not match!");
340 XASSERTM(row_norms.size() == this->num_rows(),
"Matrix/Vector dimension mismatch");
353 XASSERTM(row_norms.size() == this->num_rows(),
"Matrix/Vector dimension mismatch");
388 XASSERTM(r.
size() == this->num_rows_raw(),
"Vector size of r does not match!");
389 XASSERTM(x.
size() == this->num_cols_raw(),
"Vector size of x does not match!");
402 XASSERTM(r.
size() == this->num_cols_raw(),
"Vector size of r does not match!");
403 XASSERTM(x.
size() == this->num_rows_raw(),
"Vector size of x does not match!");
416 XASSERTM(r.
size() == this->num_rows(),
"Vector size of r does not match!");
417 XASSERTM(x.
size() == this->num_cols_raw(),
"Vector size of x does not match!");
430 XASSERTM(r.
size() == this->num_cols(),
"Vector size of r does not match!");
431 XASSERTM(x.
size() == this->num_rows_raw(),
"Vector size of x does not match!");
444 XASSERTM(r.
size() == this->num_rows_raw(),
"Vector size of r does not match!");
445 XASSERTM(x.
size() == this->num_cols(),
"Vector size of x does not match!");
458 XASSERTM(r.
size() == this->num_cols_raw(),
"Vector size of r does not match!");
459 XASSERTM(x.
size() == this->num_rows(),
"Vector size of x does not match!");
472 XASSERTM(r.
size() == this->num_rows(),
"Vector size of r does not match!");
473 XASSERTM(x.
size() == this->num_cols(),
"Vector size of x does not match!");
486 XASSERTM(r.
size() == this->num_cols(),
"Vector size of r does not match!");
487 XASSERTM(x.
size() == this->num_rows(),
"Vector size of x does not match!");
504 const DT_ DOXY(alpha) = DT_(1))
const
506 XASSERTM(r.
size() == this->num_rows_raw(),
"Vector size of r does not match!");
507 XASSERTM(x.
size() == this->num_cols_raw(),
"Vector size of x does not match!");
508 XASSERTM(y.
size() == this->num_rows_raw(),
"Vector size of y does not match!");
525 const DT_ DOXY(alpha) = DT_(1))
const
527 XASSERTM(r.
size() == this->num_cols_raw(),
"Vector size of r does not match!");
528 XASSERTM(x.
size() == this->num_rows_raw(),
"Vector size of x does not match!");
529 XASSERTM(y.
size() == this->num_cols_raw(),
"Vector size of y does not match!");
546 const DT_ DOXY(alpha) = DT_(1))
const
548 XASSERTM(r.
size() == this->num_rows(),
"Vector size of r does not match!");
549 XASSERTM(x.
size() == this->num_cols_raw(),
"Vector size of x does not match!");
550 XASSERTM(y.
size() == this->num_rows(),
"Vector size of y does not match!");
566 const DT_ DOXY(alpha) = DT_(1))
const
568 XASSERTM(r.
size() == this->num_cols(),
"Vector size of r does not match!");
569 XASSERTM(x.
size() == this->num_rows_raw(),
"Vector size of x does not match!");
570 XASSERTM(y.
size() == this->num_cols(),
"Vector size of y does not match!");
588 const DT_ DOXY(alpha) = DT_(1))
const
590 XASSERTM(r.
size() == this->num_rows_raw(),
"Vector size of r does not match!");
591 XASSERTM(x.
size() == this->num_cols(),
"Vector size of x does not match!");
592 XASSERTM(y.
size() == this->num_rows_raw(),
"Vector size of y does not match!");
609 const DT_ DOXY(alpha) = DT_(1))
const
611 XASSERTM(r.
size() == this->num_cols_raw(),
"Vector size of r does not match!");
612 XASSERTM(x.
size() == this->num_rows(),
"Vector size of x does not match!");
613 XASSERTM(y.
size() == this->num_cols_raw(),
"Vector size of y does not match!");
630 const DT_ DOXY(alpha) = DT_(1))
const
632 XASSERTM(r.
size() == this->num_rows(),
"Vector size of r does not match!");
633 XASSERTM(x.
size() == this->num_cols(),
"Vector size of x does not match!");
634 XASSERTM(y.
size() == this->num_rows(),
"Vector size of y does not match!");
651 const DT_ DOXY(alpha) = DT_(1))
const
653 XASSERTM(r.
size() == this->num_cols(),
"Vector size of r does not match!");
654 XASSERTM(x.
size() == this->num_rows(),
"Vector size of x does not match!");
655 XASSERTM(y.
size() == this->num_cols(),
"Vector size of y does not match!");
672 const DT_ DOXY(alpha) = DT_(1))
const
674 XASSERTM(r.
size() == this->num_rows(),
"Vector size of r does not match!");
675 XASSERTM(x.
size() == this->num_cols(),
"Vector size of x does not match!");
676 XASSERTM(y.
size() == this->num_rows_raw(),
"Vector size of y does not match!");
693 const DT_ DOXY(alpha) = DT_(1))
const
695 XASSERTM(r.
size() == this->num_cols(),
"Vector size of r does not match!");
696 XASSERTM(x.
size() == this->num_rows(),
"Vector size of x does not match!");
697 XASSERTM(y.
size() == this->num_cols_raw(),
"Vector size of y does not match!");
707 XASSERTM(lump.size() ==
num_rows(),
"lump vector size does not match matrix row count!");
731 XASSERTM(diag.size() ==
num_rows(),
"diag size does not match matrix row count!");
752 VectorTypeR create_vector_r()
const
762 template<
typename IT2_>
763 Index get_row_col_indices(
const Index, IT2_ *
const,
const IT2_)
const
768 template<
typename DT2_>
769 Index get_row_values(
const Index, DT2_ *
const)
const
774 template<
typename DT2_>
775 Index set_row_values(
const Index,
const DT2_ *
const)
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
void format()
Reset all elements of the container to a given value or zero if missing.
Blocked Dense data vector class template.
void copy(const DenseVectorBlocked &x, bool full=false)
Performs .
Index size() const
Returns the size of this vector, i.e. its number of entries.
Dense data vector class template.
void copy(const VT_ &a)
Performs .
Index size() const
Returns the size of this vector, i.e. its number of entries.
Null Matrix implementation.
Index num_cols() const
Retrieve matrix column count.
void apply(DenseVectorBlocked< DT_, IT_, block_height_ > &r, const DenseVector< DT_, IT_ > &x) const
Calculate .
Index num_nzes() const
Retrieve matrix non-zero element count.
void apply_transposed(DenseVectorBlocked< DT_, IT_, block_width_ > &r, const DenseVectorBlocked< DT_, IT_, block_height_ > &x) const
Calculate .
ImageIterator image_begin(Index domain_node) const
void apply_transposed(DenseVectorBlocked< DT_, IT_, block_width_ > &r, const DenseVector< DT_, IT_ > &x) const
Calculate .
NullMatrix(NullMatrix &&other)
Move Constructor.
DT_ DataType
Our datatype.
static String name()
Returns a descriptive string.
ImageIterator image_end(Index domain_node) const
IT_ IndexType
Our indextype.
void apply(DenseVectorBlocked< DT_, IT_, block_height_ > &r, const DenseVector< DT_, IT_ > &x, const DenseVectorBlocked< DT_, IT_, block_height_ > &y, const DT_ alpha=DT_(1)) const
Calculate .
void apply(DenseVector< DT_, IT_ > &r, const DenseVector< DT_, IT_ > &x, const DenseVector< DT_, IT_ > &y, const DT_ alpha=DT_(1)) const
Calculate .
VectorTypeL extract_diag() const
extract main diagonal vector from matrix
NullMatrix & operator=(NullMatrix &&other)
Move operator.
void apply_transposed(DenseVector< DT_, IT_ > &r, const DenseVectorBlocked< DT_, IT_, block_height_ > &x, const DenseVector< DT_, IT_ > &y, const DT_ alpha=DT_(1)) const
Calculate .
void format(const DT_ value=DT_(0))
Reset all elements of the container to a given value or zero if missing.
Index num_rows_raw() const
Retrieve matrix row count.
Tiny::Matrix< DataType, block_height, block_width > ValueType
Value type, meaning the type of each block.
void copy(const NullMatrix &x, bool full=false)
Performs .
NullMatrix< DT_, IT_, block_width_, block_height_ > transpose() const
Calculate .
void lump_rows(VectorTypeL &lump) const
static constexpr int block_height
Our block height.
void apply_transposed(DenseVectorBlocked< DT_, IT_, block_width_ > &r, const DenseVectorBlocked< DT_, IT_, block_height_ > &x, const DenseVector< DT_, IT_ > &y, const DT_ alpha=DT_(1)) const
Calculate .
DT_ norm_frobenius() const
Calculates the Frobenius norm of this matrix.
std::size_t bytes() const
Returns the total amount of bytes allocated.
void apply(DenseVector< DT_, IT_ > &r, const DenseVectorBlocked< DT_, IT_, block_width_ > &x) const
Calculate .
Intern::BlockedVectorHelper< DT_, IT_, block_width_ >::VectorType VectorTypeR
Compatible R-vector type.
void convert(const NullMatrix< DT2_, IT2_, block_height_, block_width_ > &other)
Conversion method.
void transpose(const NullMatrix< DT_, IT_, block_width_, block_height_ > &x)
Calculate .
void scale(const NullMatrix &x, const DT_ alpha)
Calculate .
void apply(DenseVectorBlocked< DT_, IT_, block_height_ > &r, const DenseVectorBlocked< DT_, IT_, block_width_ > &x, const DenseVectorBlocked< DT_, IT_, block_height_ > &y, const DT_ alpha=DT_(1)) const
Calculate .
Index get_num_nodes_domain() const
NullMatrix(Index rows_in, Index columns_in)
Constructor.
void resize(Index rows_in, Index columns_in)
Resizes the matrix to different dimensions.
void extract_diag(VectorTypeL &diag) const
Index get_num_nodes_image() const
Index num_nzes_raw() const
Retrieve matrix non-zero element count.
Index num_rows() const
Retrieve matrix row count.
void apply(DenseVectorBlocked< DT_, IT_, block_height_ > &r, const DenseVectorBlocked< DT_, IT_, block_width_ > &x) const
Calculate .
void row_norm2(VectorTypeL &row_norms) const
Computes the 2-norm for every row.
Index _num_rows
matrix dimensions
void clone(const NullMatrix< DT2_, IT2_, block_height_, block_width_ > &other, CloneMode clone_mode=CloneMode::Weak)
Clone operation.
NullMatrix clone(CloneMode clone_mode=CloneMode::Weak) const
Clone operation.
void apply_transposed(DenseVector< DT_, IT_ > &r, const DenseVector< DT_, IT_ > &x) const
Calculate .
void apply(DenseVector< DT_, IT_ > &r, const DenseVector< DT_, IT_ > &x) const
Calculate .
void apply_transposed(DenseVector< DT_, IT_ > &r, const DenseVector< DT_, IT_ > &x, const DenseVector< DT_, IT_ > &y, const DT_ alpha=DT_(1)) const
Calculate .
VectorTypeL lump_rows() const
Returns the lumped rows vector.
void set_checkpoint_data(std::vector< char > &)
const IT_ * ImageIterator
ImageIterator typedef for Adjactor interface implementation.
void axpy(const NullMatrix &x, const NullMatrix &y, const DT_ alpha=DT_(1))
Calculate .
void apply_transposed(DenseVectorBlocked< DT_, IT_, block_width_ > &r, const DenseVector< DT_, IT_ > &x, const DenseVectorBlocked< DT_, IT_, block_width_ > &y, const DT_ alpha=DT_(1)) const
Calculate .
uint64_t get_checkpoint_size()
Calculate size.
static constexpr int block_width
Our block width.
void restore_from_checkpoint_data(std::vector< char > &)
Extract object from checkpoint.
void apply_transposed(DenseVectorBlocked< DT_, IT_, block_width_ > &r, const DenseVectorBlocked< DT_, IT_, block_height_ > &x, const DenseVectorBlocked< DT_, IT_, block_width_ > &y, const DT_ alpha=DT_(1)) const
Calculate .
Intern::BlockedVectorHelper< DT_, IT_, block_height_ >::VectorType VectorTypeL
Compatible L-vector type.
Index num_cols_raw() const
Retrieve matrix column count.
void apply_transposed(DenseVector< DT_, IT_ > &r, const DenseVectorBlocked< DT_, IT_, block_height_ > &x) const
Calculate .
void row_norm2sqr(VectorTypeL &row_norms) const
Computes the square of the 2-norm for every row.
void apply(DenseVector< DT_, IT_ > &r, const DenseVectorBlocked< DT_, IT_, block_width_ > &x, const DenseVector< DT_, IT_ > &y, const DT_ alpha=DT_(1)) const
Calculate .
void apply(DenseVectorBlocked< DT_, IT_, block_height_ > &r, const DenseVectorBlocked< DT_, IT_, block_width_ > &x, const DenseVector< DT_, IT_ > &y, const DT_ alpha=DT_(1)) const
Calculate .
String class implementation.
Tiny Matrix class template.
LAFEM common type definitions.
@ value
specifies whether the space should supply basis function values
std::uint64_t Index
Index data type.