A quick implementation of a diagonal matrix with 1x1 and 2x2 blocks.
More...
#include <block_diag_matrix.h>
|
typedef std::unordered_map< int, el_type > | int_elt_map |
|
typedef std::vector< el_type > | elt_vector_type |
|
|
| block_diag_matrix (int n_rows=0, int n_cols=0) |
| Constructor for diagonal class. Initializes a 0x0 matrix when given no arguments.
|
|
void | resize (int n, el_type default_value) |
| Resizes this matrix to an n*n matrix with default_value on the main diagonal.
|
|
void | resize (int n) |
| Resizes this matrix to an n*n matrix.
|
|
int | n_rows () const |
|
int | n_cols () const |
|
int | nnz () const |
|
el_type & | operator[] (int i) |
|
el_type & | off_diagonal (int i) |
|
int | block_size (int i) const |
|
void | sqrt_solve (const elt_vector_type &b, elt_vector_type &x, bool transposed=false) |
| Solves the preconditioned problem |D| = Q|V|Q', where QVQ' is the eigendecomposition of D, and |.| is applied elementwise. More...
|
|
void | solve (const elt_vector_type &b, elt_vector_type &x) |
| Solves the system Dx = b. More...
|
|
std::string | to_string () const |
|
bool | save (std::string filename) const |
|
| ~block_diag_matrix () |
| Generic class destructor.
|
|
|
int | m_n_size |
| Dimension of the matrix.
|
|
int | nnz_count |
| Number of non-zeros in the matrix.
|
|
elt_vector_type | main_diag |
| Stores main diagonal elements.
|
|
int_elt_map | off_diag |
| Stores off-diagonal elements of 2x2 pivots.
|
|
template<class el_type>
class block_diag_matrix< el_type >
A quick implementation of a diagonal matrix with 1x1 and 2x2 blocks.
- Parameters
-
i | the index of the element. |
- Returns
- 2 if there is a diagonal pivot at D(i,i) and D(i+1,i+1). -2 if there is a diagonal pivot at D(i-1,i-1) and D(i,i). 1 if the pivot is only a 1x1 block.
- Returns
- Number of cols in the matrix.
- Returns
- Number of rows in the matrix.
- Returns
- Number of nonzeros in the matrix.
- Parameters
-
i | the index of the element. |
- Returns
- The D(i+1,i)th element.
- Parameters
-
i | the index of the element. |
- Returns
- The D(i,i)th element.
- Parameters
-
filename | the filename of the matrix to be saved. All matrices saved are in matrix market format (.mtx). |
- Returns
- True if the save succeeded, false otherwise.
template<class el_type>
void block_diag_matrix< el_type >::solve |
( |
const elt_vector_type & |
b, |
|
|
elt_vector_type & |
x |
|
) |
| |
|
inline |
Solves the system Dx = b.
- Parameters
-
b | the right hand side. |
x | a storage vector for the solution (must be same size as b). |
template<class el_type>
void block_diag_matrix< el_type >::sqrt_solve |
( |
const elt_vector_type & |
b, |
|
|
elt_vector_type & |
x, |
|
|
bool |
transposed = false |
|
) |
| |
|
inline |
Solves the preconditioned problem |D| = Q|V|Q', where QVQ' is the eigendecomposition of D, and |.| is applied elementwise.
- Parameters
-
b | the right hand side. |
x | a storage vector for the solution (must be same size as b). |
transposed | solves |V|^(1/2)Q' if true, Q|V|^(1/2) if false. |
- Returns
- A string reprepsentation of this matrix.
template<class el_type>
std::ostream& operator<< |
( |
std::ostream & |
os, |
|
|
const block_diag_matrix< el_type > & |
D |
|
) |
| |
|
friend |
Allows outputting the contents of the matrix via << operators.
The documentation for this class was generated from the following files: