v2DM-DOCI  1.0
doci2DM::BlockStructure< BlockType > Class Template Reference

#include <BlockStructure.h>

+ Inheritance diagram for doci2DM::BlockStructure< BlockType >:
+ Collaboration diagram for doci2DM::BlockStructure< BlockType >:

Public Member Functions

 BlockStructure (int)
 
 BlockStructure (const BlockStructure< BlockType > &)
 
 BlockStructure (BlockStructure< BlockType > &&)
 
virtual ~BlockStructure ()=default
 
void setDim (int, int, int)
 
BlockStructureoperator= (const BlockStructure< BlockType > &)
 
BlockStructureoperator= (BlockStructure< BlockType > &&)
 
BlockStructureoperator= (double)
 
BlockStructureoperator+= (const BlockStructure< BlockType > &)
 
BlockStructureoperator-= (const BlockStructure< BlockType > &)
 
BlockStructuredaxpy (double alpha, const BlockStructure< BlockType > &)
 
BlockStructureoperator*= (double)
 
BlockStructureoperator/= (double)
 
BlockType & operator[] (int block)
 
const BlockType & operator[] (int block) const
 
double & operator() (int block, int i, int j)
 
double operator() (int block, int i, int j) const
 
double & operator() (int block, int index)
 
double operator() (int block, int index) const
 
int gnr () const
 
int gdim (int) const
 
int gdeg (int) const
 
double trace () const
 
double ddot (const BlockStructure< BlockType > &) const
 
void dscal (double alpha)
 
double min () const
 
double max () const
 
void fill_Random ()
 
void fill_Random (int)
 
virtual void invert ()
 
virtual void sqrt (int)
 
virtual void L_map (const BlockStructure< BlockType > &, const BlockStructure< BlockType > &)
 
virtual BlockStructure< BlockType > & mprod (const BlockStructure< BlockType > &, const BlockStructure< BlockType > &)
 
void symmetrize ()
 
void sort ()
 
virtual void sep_pm (BlockStructure< BlockType > &, BlockStructure< BlockType > &)
 
template<>
double & operator() (int block, int i, int j)
 
template<>
double operator() (int block, int i, int j) const
 
template<>
double & operator() (int block, int index)
 
template<>
double operator() (int block, int index) const
 
template<>
void sort ()
 

Private Attributes

std::vector< std::unique_ptr< BlockType > > blocks
 
std::vector< int > degen
 degeneracy of the blocks More...
 

Friends

template<class MyBlockType >
std::ostream & operator<< (std::ostream &output, const doci2DM::BlockStructure< MyBlockType > &blocks_p)
 

Detailed Description

template<class BlockType>
class doci2DM::BlockStructure< BlockType >

Author
Brecht Verstichel
Date
5-04-2010

This is a class written for symmetric block matrices. It containts an array of Matrix objects and an array containing the dimensions of the different block. It redefines all the member functions of the Matrix class, which uses the lapack and blas routines for matrix computations.

Definition at line 45 of file BlockStructure.h.

Constructor & Destructor Documentation

template<class BlockType >
BlockStructure::BlockStructure ( int  nr)

constructor: Watch out, the matrices themself haven't been allocated yet. Only the Blockmatrix itself is allocated and the array containing the dimensions, but not initialized.

Parameters
nrnumber of blocks in the blockmatrix

Definition at line 38 of file BlockStructure.cpp.

template<class BlockType >
BlockStructure::BlockStructure ( const BlockStructure< BlockType > &  blockmat_copy)

copy constructor, make sure the input matrix and all the blocks have been allocated and filled before the copying

Parameters
blockmat_copyThe blockmatrix you want to be copied into the object you are constructing

Definition at line 50 of file BlockStructure.cpp.

template<class BlockType >
BlockStructure::BlockStructure ( BlockStructure< BlockType > &&  blockmat_copy)

Definition at line 62 of file BlockStructure.cpp.

template<class BlockType>
virtual doci2DM::BlockStructure< BlockType >::~BlockStructure ( )
virtualdefault

Member Function Documentation

template<class BlockType >
BlockStructure< BlockType > & BlockStructure::daxpy ( double  alpha,
const BlockStructure< BlockType > &  blockmat_pl 
)

add the matrix matrix_pl times the constant alpha to this

Parameters
alphathe constant to multiply the matrix_pl with
blockmat_plthe BlockStructure to be multiplied by alpha and added to this

Definition at line 172 of file BlockStructure.cpp.

template<class BlockType >
double BlockStructure::ddot ( const BlockStructure< BlockType > &  blocks_in) const
Returns
inproduct of (*this) blocks with blocks_in, defined as Tr (A B)
Parameters
blocks_ininput matrix

Definition at line 293 of file BlockStructure.cpp.

template<class BlockType >
void BlockStructure::dscal ( double  alpha)

Scale the blocks (*this) with parameter alpha

Parameters
alphascalefactor

Definition at line 320 of file BlockStructure.cpp.

template<class BlockType >
void BlockStructure::fill_Random ( )

Fill the matrix with random numbers.

Definition at line 331 of file BlockStructure.cpp.

template<class BlockType >
void BlockStructure::fill_Random ( int  seed)

Fill the matrix with random numbers.

Parameters
seedthe seed to use

Definition at line 342 of file BlockStructure.cpp.

template<class BlockType >
int BlockStructure::gdeg ( int  i) const
Returns
the degeneracy of the block with index i

Definition at line 268 of file BlockStructure.cpp.

+ Here is the caller graph for this function:

template<class BlockType >
int BlockStructure::gdim ( int  i) const
Returns
the dimension of the Matrix on the block with index i

Definition at line 259 of file BlockStructure.cpp.

+ Here is the caller graph for this function:

template<class BlockType >
int BlockStructure::gnr ( ) const
Returns
the blocks.size() of blocks

Definition at line 250 of file BlockStructure.cpp.

+ Here is the caller graph for this function:

template<class BlockType >
void BlockStructure::invert ( )
virtual

Invert positive semidefinite symmetric blocks which is stored in (*this), original matrix (*this) is destroyed

Reimplemented in doci2DM::PHM.

Definition at line 308 of file BlockStructure.cpp.

template<class BlockType >
void BlockStructure::L_map ( const BlockStructure< BlockType > &  map,
const BlockStructure< BlockType > &  object 
)
virtual

Multiply symmetric blocks object left en right with symmetric blocks map to form another symmetric blocks and put it in (*this): this = map*object*map

Parameters
mapBlockStructure that will be multiplied to the left en to the right of matrix object
objectcentral BlockStructure

Definition at line 367 of file BlockStructure.cpp.

template<class BlockType>
double doci2DM::BlockStructure< BlockType >::max ( ) const
template<class BlockType>
double doci2DM::BlockStructure< BlockType >::min ( ) const
template<class BlockType >
BlockStructure< BlockType > & BlockStructure::mprod ( const BlockStructure< BlockType > &  A,
const BlockStructure< BlockType > &  B 
)
virtual

BlockStructure product of two general blockmatrices A en B, put result in this

Parameters
Aleft matrix
Bright matrix

Definition at line 380 of file BlockStructure.cpp.

template<class BlockType>
double& doci2DM::BlockStructure< BlockType >::operator() ( int  block,
int  i,
int  j 
)
template<class BlockType>
double doci2DM::BlockStructure< BlockType >::operator() ( int  block,
int  i,
int  j 
) const
template<class BlockType>
double& doci2DM::BlockStructure< BlockType >::operator() ( int  block,
int  index 
)
template<class BlockType>
double doci2DM::BlockStructure< BlockType >::operator() ( int  block,
int  index 
) const
template<>
double & doci2DM::BlockStructure< Matrix >::operator() ( int  block,
int  i,
int  j 
)

write access to your blocks, change the number in block "block", on row i and column j

Parameters
blockThe index of the block you want to access
irow number
jcolumn number
Returns
the entry on place block,i,j

Definition at line 214 of file BlockStructure.cpp.

template<>
double doci2DM::BlockStructure< Matrix >::operator() ( int  block,
int  i,
int  j 
) const

read access to your blocks, read the number in block "block" on row i and column j

Parameters
blockThe index of the block you want to access
irow number
jcolumn number
Returns
the entry on place block,i,j

Definition at line 227 of file BlockStructure.cpp.

template<>
double & doci2DM::BlockStructure< Vector >::operator() ( int  block,
int  index 
)

Definition at line 233 of file BlockStructure.cpp.

template<>
double doci2DM::BlockStructure< Vector >::operator() ( int  block,
int  index 
) const

Definition at line 239 of file BlockStructure.cpp.

template<class BlockType >
BlockStructure< BlockType > & BlockStructure::operator*= ( double  c)

Definition at line 196 of file BlockStructure.cpp.

template<class BlockType >
BlockStructure< BlockType > & BlockStructure::operator+= ( const BlockStructure< BlockType > &  blockmat_pl)

overload the += operator for matrices

Parameters
blockmat_plThe matrix you want to add to this

Definition at line 143 of file BlockStructure.cpp.

template<class BlockType >
BlockStructure< BlockType > & BlockStructure::operator-= ( const BlockStructure< BlockType > &  blockmat_pl)

overload the -= operator for matrices

Parameters
blockmat_plThe matrix you want to deduct from this

Definition at line 157 of file BlockStructure.cpp.

template<class BlockType >
BlockStructure< BlockType > & BlockStructure::operator/= ( double  c)

/= operator overloaded: divide by a constant

Parameters
cthe number to divide your matrix through

Definition at line 186 of file BlockStructure.cpp.

template<class BlockType >
BlockStructure< BlockType > & BlockStructure::operator= ( const BlockStructure< BlockType > &  blockmat_copy)

overload the equality operator: Make sure the blocks in both matrices have been allocated to the same dimensions and have the same degeneracy!

Parameters
blockmat_copyThe matrix you want to be copied into this

Definition at line 113 of file BlockStructure.cpp.

template<class BlockType>
BlockStructure& doci2DM::BlockStructure< BlockType >::operator= ( BlockStructure< BlockType > &&  )
template<class BlockType >
BlockStructure< BlockType > & BlockStructure::operator= ( double  a)

Make all the numbers in your blocks equal to the number a, e.g. usefull for initialization (BlockStructure M = 0)

Parameters
athe number

Definition at line 129 of file BlockStructure.cpp.

template<class BlockType >
BlockType & BlockStructure::operator[] ( int  block)

[] overloaded, will return a reference to the block block in the blocks.

Parameters
blockindex of the block to be returned
Returns
A reference to the Matrix object located on blocks[block].

Definition at line 91 of file BlockStructure.cpp.

template<class BlockType >
const BlockType & BlockStructure::operator[] ( int  block) const

[] overloaded, const version, will return a const reference to the block block in the blocks.

Parameters
blockindex of the block to be returned
Returns
A reference to the Matrix object located on blocks[block].

Definition at line 102 of file BlockStructure.cpp.

template<class BlockType >
void BlockStructure::sep_pm ( BlockStructure< BlockType > &  pos,
BlockStructure< BlockType > &  neg 
)
virtual

Definition at line 410 of file BlockStructure.cpp.

template<class BlockType >
void BlockStructure::setDim ( int  block,
int  dim,
int  degeneracy 
)

function that allocates the memory of the blocks block with dimension dim sets and the degeneracy of the matrix

Parameters
blockthe index of the block that will be allocated
dimthe dimension of the particular block to be allocated
degeneracythe degeneracy of block "block"

Definition at line 76 of file BlockStructure.cpp.

+ Here is the caller graph for this function:

template<class BlockType>
void doci2DM::BlockStructure< BlockType >::sort ( )
template<>
void doci2DM::BlockStructure< Vector >::sort ( )

Definition at line 402 of file BlockStructure.cpp.

template<class BlockType >
void BlockStructure::sqrt ( int  option)
virtual

Take the square root out of the positive semidefinite blocks, destroys original blocks, square root will be put in (*this)

Parameters
option= 1, positive square root, = -1, negative square root.

Reimplemented in doci2DM::PHM.

Definition at line 353 of file BlockStructure.cpp.

template<class BlockType >
void BlockStructure::symmetrize ( )

Copy upper triangle into lower triangle.

Definition at line 393 of file BlockStructure.cpp.

template<class BlockType >
double BlockStructure::trace ( ) const
Returns
the trace of the matrix, each block matrix is weighed with its degeneracy.

Definition at line 277 of file BlockStructure.cpp.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

template<class BlockType>
template<class MyBlockType >
std::ostream& operator<< ( std::ostream &  output,
const doci2DM::BlockStructure< MyBlockType > &  blocks_p 
)
friend

Output stream operator overloaded, the usage is simple, if you want to print to a file, make an ifstream object and type:

object << blockmatrix << endl;

For output onto the screen type:

cout << blockmatrix << endl;

Parameters
outputThe stream to which you are writing (e.g. cout)
blocks_pthe BlockMatrix you want to print

Definition at line 420 of file BlockStructure.cpp.

Member Data Documentation

template<class BlockType>
std::vector< std::unique_ptr<BlockType> > doci2DM::BlockStructure< BlockType >::blocks
private

Definition at line 150 of file BlockStructure.h.

template<class BlockType>
std::vector<int> doci2DM::BlockStructure< BlockType >::degen
private

degeneracy of the blocks

Definition at line 153 of file BlockStructure.h.


The documentation for this class was generated from the following files: