sym-ildl  1.2
Incomplete LDL' factorizations of indefinite symmetric and skew-symmetric matrices.
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
block_diag_matrix< el_type > Class Template Reference

A quick implementation of a diagonal matrix with 1x1 and 2x2 blocks. More...

#include <block_diag_matrix.h>

Collaboration diagram for block_diag_matrix< el_type >:
Collaboration graph
[legend]

Public Types

typedef std::unordered_map< int, el_type > int_elt_map
 
typedef std::vector< el_type > elt_vector_type
 

Public Member Functions

 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.
 

Public Attributes

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.
 

Friends

std::ostream & operator<< (std::ostream &os, const block_diag_matrix &D)
 

Detailed Description

template<class el_type>
class block_diag_matrix< el_type >

A quick implementation of a diagonal matrix with 1x1 and 2x2 blocks.

Member Function Documentation

template<class el_type>
int block_diag_matrix< el_type >::block_size ( int  i) const
inline
Parameters
ithe 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.
template<class el_type>
int block_diag_matrix< el_type >::n_cols ( ) const
inline
Returns
Number of cols in the matrix.
template<class el_type>
int block_diag_matrix< el_type >::n_rows ( ) const
inline
Returns
Number of rows in the matrix.
template<class el_type>
int block_diag_matrix< el_type >::nnz ( ) const
inline
Returns
Number of nonzeros in the matrix.
template<class el_type>
el_type& block_diag_matrix< el_type >::off_diagonal ( int  i)
inline
Parameters
ithe index of the element.
Returns
The D(i+1,i)th element.
template<class el_type>
el_type& block_diag_matrix< el_type >::operator[] ( int  i)
inline
Parameters
ithe index of the element.
Returns
The D(i,i)th element.
template<class el_type >
bool block_diag_matrix< el_type >::save ( std::string  filename) const
Parameters
filenamethe 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
bthe right hand side.
xa 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
bthe right hand side.
xa storage vector for the solution (must be same size as b).
transposedsolves |V|^(1/2)Q' if true, Q|V|^(1/2) if false.
template<class el_type >
std::string block_diag_matrix< el_type >::to_string ( ) const
Returns
A string reprepsentation of this matrix.

Friends And Related Function Documentation

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: