9#include <kernel/lafem/power_row_matrix.hpp>
10#include <kernel/lafem/power_col_matrix.hpp>
11#include <kernel/lafem/power_vector.hpp>
12#include <kernel/lafem/sparse_layout.hpp>
13#include <kernel/lafem/container.hpp>
54 static_assert((width_ > 0) && (height_ > 0),
"invalid matrix dimensions");
62 typedef typename SubMatrixType::DataType
DataType;
64 typedef typename SubMatrixType::IndexType
IndexType;
72 template <
typename DT2_ = DataType,
typename IT2_ = IndexType>
88 _container(std::move(cont))
106 _container(std::move(other._container))
121 _container = std::move(other);
135 _container = std::move(other);
147 _container = std::move(other);
155 _container = std::move(other._container);
192 return _container.
bytes();
207 template<
int i_,
int j_>
210 static_assert((0 <= i_) && (i_ < height_),
"invalid sub-matrix index");
211 static_assert((0 <= j_) && (j_ < width_),
"invalid sub-matrix index");
212 return _container.template at<i_, 0>().template at<0, j_>();
216 template<
int i_,
int j_>
219 static_assert((0 <= i_) && (i_ < height_),
"invalid sub-matrix index");
220 static_assert((0 <= j_) && (j_ < width_),
"invalid sub-matrix index");
221 return _container.template at<i_, 0>().template at<0, j_>();
235 XASSERTM((0 <= i) && (i < height_),
"invalid sub-matrix row index");
236 XASSERTM((0 <= j) && (j < width_),
"invalid sub-matrix column index");
237 return _container.
get(i, 0).
get(0, j);
243 XASSERTM((0 <= i) && (i < height_),
"invalid sub-matrix row index");
244 XASSERTM((0 <= j) && (j < width_),
"invalid sub-matrix column index");
245 return _container.
get(i, 0).
get(0, j);
249 int row_blocks()
const
254 int col_blocks()
const
259 Index get_length_of_line(
const Index row)
const
265 const Index col_start,
const Index stride = 1)
const
267 _container.set_line(row, pval_set, pcol_set, col_start, stride);
270 void set_line_reverse(
const Index row,
DataType *
const pval_set,
const Index stride = 1)
272 _container.set_line_reverse(row, pval_set, stride);
302 template <Perspective perspective_ = Perspective::native>
305 return _container.template rows<perspective_>();
314 template <Perspective perspective_ = Perspective::native>
317 return _container.template columns<perspective_>();
326 template <Perspective perspective_ = Perspective::native>
329 return _container.template used_elements<perspective_>();
335 return String(
"PowerFullMatrix<") + SubMatrixType::name() +
"," +
stringify(width_) +
"," +
stringify(height_) +
">";
338 template <Perspective perspective_ = Perspective::native>
341 return rows<perspective_>() * columns<perspective_>();
352 static_assert(width_ == height_,
"cannot extract diagonal from rectangular matrix");
353 Intern::ExtDiagPFM<width_>::extract_diag(*
this, diag);
358 _container.
apply(r, x);
361 void apply(DenseVector<DataType, IndexType>& r,
const DenseVector<DataType, IndexType>& x)
const
363 _container.
apply(r, x);
368 _container.
apply(r, x, y, alpha);
371 void apply(DenseVector<DataType, IndexType>& r,
const DenseVector<DataType, IndexType>& x,
372 const DenseVector<DataType, IndexType>& y,
DataType alpha =
DataType(1))
const
374 _container.
apply(r, x, y, alpha);
382 void apply_transposed(DenseVector<DataType, IndexType>& r,
const DenseVector<DataType, IndexType>& x)
const
392 void apply_transposed(DenseVector<DataType, IndexType>& r,
const DenseVector<DataType, IndexType>& x,
393 const DenseVector<DataType, IndexType>& y,
DataType alpha =
DataType(1))
const
422 template <
typename SubType2_>
425 _container.
convert(other._container);
428 template <
typename SubType2_>
429 void convert_reverse(PowerFullMatrix<SubType2_, width_, height_> & other)
const
431 _container.convert_reverse(other._container);
460 static_assert(n_ > 1,
"invalid block size");
461 template<
typename SMT_,
int m_>
462 static void extract_diag(
463 const PowerFullMatrix<SMT_, m_, m_>& matrix,
464 PowerVector<typename SMT_::VectorTypeL, m_>& diag)
466 ExtDiagPFM<n_-1>::extract_diag(matrix, diag);
467 matrix.template at<n_-1,n_-1>().extract_diag(diag.template at<n_-1>());
474 template<
typename SMT_,
int m_>
475 static void extract_diag(
476 const PowerFullMatrix<SMT_, m_, m_>& matrix,
477 PowerVector<typename SMT_::VectorTypeL, m_>& diag)
479 matrix.template at<0,0>().extract_diag(diag.template at<0>());
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Power-Col-Matrix meta class template.
PowerColMatrix clone(LAFEM::CloneMode mode=LAFEM::CloneMode::Weak) const
Creates and returns a deep copy of this matrix.
VectorTypeL create_vector_l() const
Returns a new compatible L-Vector.
void restore_from_checkpoint_data(std::vector< char > &data)
Extract object from checkpoint.
std::uint64_t get_checkpoint_size(SerialConfig &config)
Calculate size.
void write_out(FileMode mode, String filename) const
Write out matrix to file.
VectorTypeR create_vector_r() const
Returns a new compatible R-Vector.
void convert(const PowerColMatrix< SubType2_, blocks_ > &other)
Conversion method.
SubMatrixType & get(int i, int j)
Returns a sub-matrix block.
std::uint64_t set_checkpoint_data(std::vector< char > &data, SerialConfig &config)
void apply_transposed(VectorTypeR &r, const VectorTypeL &x) const
Applies this matrix onto a vector.
void format(DataType value=DataType(0))
Reset all elements of the container to a given value or zero if missing.
bool same_layout(const PowerColMatrix &x) const
Checks if the structural layout of this matrix matches that of another matrix. This excludes comparis...
void apply(VectorTypeL &r, const VectorTypeR &x) const
Applies this matrix onto a vector.
Index get_length_of_line(const Index row) const
Returns the number of NNZ-elements of the selected row.
std::size_t bytes() const
Returns the total amount of bytes allocated.
DataType max_rel_diff(const PowerColMatrix &x) const
Retrieve the maximum relative difference of this matrix and another one y.max_rel_diff(x) returns .
Power-Full-Matrix meta class template.
PowerFullMatrix(const SparseLayout< IndexType, layout_id > &layout)
sub-matrix layout ctor
PowerFullMatrix & operator=(PowerFullMatrix &&other)
move-assign operator
static constexpr int num_col_blocks
number of column blocks (horizontal size)
SubMatrixType & get(int i, int j)
Returns a sub-matrix block.
Index used_elements() const
Returns the total number of non-zeros in this matrix.
PowerFullMatrix()
default ctor
PowerFullMatrix(const PowerFullMatrix &)=delete
deleted copy-ctor
void write_out(FileMode mode, const String &filename) const
Write out matrix to file.
static constexpr SparseLayoutId layout_id
sub-matrix layout type
PowerFullMatrix & operator=(const PowerFullMatrix &)=delete
deleted copy-assign operator
const SubMatrixType & get(int i, int j) const
Returns a sub-matrix block.
PowerFullMatrix(FileMode mode, const String &filename)
Constructor.
std::size_t bytes() const
Returns the total amount of bytes allocated.
std::uint64_t set_checkpoint_data(std::vector< char > &data, SerialConfig &config)
PowerFullMatrix(FileMode mode, std::istream &file, const String &directory="")
Constructor.
static constexpr int num_row_blocks
number of row blocks (vertical size)
PowerFullMatrix clone(LAFEM::CloneMode mode=LAFEM::CloneMode::Weak) const
Creates and returns a deep copy of this matrix.
SubMatrixType::DataType DataType
sub-matrix data type
DataType max_rel_diff(const PowerFullMatrix &x) const
Retrieve the maximum relative difference of this matrix and another one y.max_rel_diff(x) returns .
SubType_ SubMatrixType
sub-matrix type
PowerVector< typename SubMatrixType::VectorTypeL, height_ > VectorTypeL
Compatible L-vector type.
PowerFullMatrix(PowerFullMatrix &&other)
move ctor
SubMatrixType::IndexType IndexType
sub-matrix index type
const SubMatrixType & at() const
Returns a sub-matrix block.
Index columns() const
Returns the total number of columns in this matrix.
SubMatrixType & at()
Returns a sub-matrix block.
static String name()
Returns a descriptive string for this container.
PowerFullMatrix(ContClass &&cont)
base-class emplacement constructor
std::uint64_t get_checkpoint_size(SerialConfig &config)
Calculate size.
virtual ~PowerFullMatrix()
virtual destructor
bool same_layout(const PowerFullMatrix &x) const
Checks if the structural layout of this matrix matches that of another matrix. This excludes comparis...
PowerColMatrix< PowerRowMatrix< SubType_, width_ >, height_ > ContClass
container-class typedef
PowerVector< typename SubMatrixType::VectorTypeR, width_ > VectorTypeR
Compatible R-vector type.
Index rows() const
Returns the total number of rows in this matrix.
void restore_from_checkpoint_data(std::vector< char > &data)
Extract object from checkpoint.
void extract_diag(VectorTypeL &diag) const
extract main diagonal vector from matrix
void read_from(FileMode mode, const String &filename)
Read in matrix from file.
SubMatrixType & get(int i, int j)
Returns a sub-matrix block.
Power-Vector meta class template.
Config class for serialize parameter.
Layout scheme for sparse matrix containers.
String class implementation.
String stringify(const T_ &item)
Converts an item into a String.
@ value
specifies whether the space should supply basis function values
std::uint64_t Index
Index data type.