Feel++ 0.91.0
|
block of matrices More...
#include <matrixblock.hpp>
Public Types | |
Typedefs | |
typedef MatrixType | matrix_type |
typedef MatrixSparse::value_type | value_type |
typedef boost::shared_ptr < matrix_type > | matrix_ptrtype |
typedef fusion::vector < NBLOCKSIZE, matrix_type > | vector_matrix_type |
typedef fusion::vector < NBLOCKSIZE, matrix_ptrtype > | vector_matrix_ptrtype |
Public Member Functions | |
Constructors, destructor | |
MatrixBlock (vector_matrix_ptrtype const &v) | |
MatrixBlock (MatrixBlock const &mb) | |
~MatrixBlock () | |
Operator overloads | |
MatrixBlock | operator= (MatrixBlock const &mb) |
Static Public Attributes | |
Constants | |
static const uint16_type | NBLOCKROWS = NR |
number of rows | |
static const uint16_type | NBLOCKCOLS = NC |
number of columns | |
static const uint16_type | NBLOCKSIZE = NR * NC |
Methods | |
void | init (const size_type m, const size_type n, const size_type m_l, const size_type n_l, graph_ptrtype const &graph) |
bool | hasGraph () const |
graph_ptrtype const & | graph () const |
void | setGraph (graph_ptrtype const &graph) |
void | clear () |
void | zero () |
void | close () const |
size_type | size1 () const |
size_type | size2 () const |
size_type | rowStart () const |
size_type | rowStop () const |
void | set (const size_type i, const size_type j, const value_type &value) |
void | add (const size_type i, const size_type j, const value_type &value) |
void | addMatrix (const ublas::matrix< value_type > &dm, const std::vector< size_type > &rows, const std::vector< size_type > &cols) |
void | addMatrix (const ublas::matrix< value_type > &dm, const std::vector< size_type > &dof_indices) |
void | addMatrix (const T, MatrixSparse< T > &) |
T | operator() (const size_type i, const size_type j) const |
real_type | l1Norm () const |
real_type | linftyNorm () const |
bool | closed () const |
void | print (std::ostream &os=std::cout) const |
void | printPersonal (std::ostream &=std::cout) const |
void | printMatlab (const std::string name="NULL") const |
void | createSubmatrix (MatrixSparse< T > &submatrix, const std::vector< size_type > &rows, const std::vector< size_type > &cols) const |
void | reinitSubmatrix (MatrixSparse< T > &submatrix, const std::vector< size_type > &rows, const std::vector< size_type > &cols) const |
void | zeroRows (std::vector< int > const &rows, std::vector< value_type > const &values, Vector< value_type > &rhs, Context const &on_context) |
template<typename U > | |
std::ostream & | operator<< (std::ostream &os, const MatrixSparse< U > &m) |
block of matrices
Matrix<2,2, MatrixType> MB( fusion::make_vector( A, B, C, D ) );
it is likely that MatrixBlock<> won't be used directly but will be constructed by a free-function, e.g. block<NR,NC>( make_vector() ), to ease the matrix assembly
form2( Xh, Xh, block<2,2>( A, B, C, D ) ) = integrate(...);
or alternatively
// store the object MatrixBlock, we can reuse it AUTO( myblock, block<2,2>( A, B, C, D ) ); form( Xh, Xh , myblock ) = ...; form( Xh, Xh , myblock ) += ...;
void Feel::MatrixBlock< NR, NC, MatrixType >::add | ( | const size_type | i, |
const size_type | j, | ||
const value_type & | value | ||
) | [virtual] |
Add value
to the element (i,j). Throws an error if the entry does not exist. Still, it is allowed to store zero values in non-existent fields.
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::addMatrix | ( | const ublas::matrix< value_type > & | dm, |
const std::vector< size_type > & | dof_indices | ||
) | [virtual] |
Same, but assumes the row and column maps are the same. Thus the matrix dm
must be square.
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::addMatrix | ( | const T | , |
MatrixSparse< T > & | |||
) | [virtual] |
Add a Sparse matrix _X
, scaled with _a
, to this
, stores the result in this:
.
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::addMatrix | ( | const ublas::matrix< value_type > & | dm, |
const std::vector< size_type > & | rows, | ||
const std::vector< size_type > & | cols | ||
) | [virtual] |
Add the full matrix to the Sparse matrix. This is useful for adding an element matrix at assembly time
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::clear | ( | ) | [virtual] |
Release all memory and return to a state just like after having called the default constructor.
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::close | ( | ) | const [virtual] |
Call the Sparse assemble routines. sends necessary messages to other processors
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
bool Feel::MatrixBlock< NR, NC, MatrixType >::closed | ( | ) | const [virtual] |
see if Sparse matrix has been closed and fully assembled yet
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::createSubmatrix | ( | MatrixSparse< T > & | submatrix, |
const std::vector< size_type > & | rows, | ||
const std::vector< size_type > & | cols | ||
) | const [inline, virtual] |
This function creates a matrix called "submatrix" which is defined by the row and column indices given in the "rows" and "cols" entries. Currently this operation is only defined for the PetscMatrix type.
Reimplemented from Feel::MatrixSparse< MatrixSparse::value_type >.
References Feel::MatrixSparse< MatrixSparse::value_type >::_get_submatrix().
graph_ptrtype const& Feel::MatrixBlock< NR, NC, MatrixType >::graph | ( | ) | const [inline] |
Reimplemented from Feel::MatrixSparse< MatrixSparse::value_type >.
Referenced by Feel::MatrixBlock< NR, NC, MatrixType >::setGraph().
bool Feel::MatrixBlock< NR, NC, MatrixType >::hasGraph | ( | ) | const [inline] |
Reimplemented from Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::init | ( | const size_type | m, |
const size_type | n, | ||
const size_type | m_l, | ||
const size_type | n_l, | ||
graph_ptrtype const & | graph | ||
) | [virtual] |
Initialize using sparsity structure computed by dof_map
.
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
real_type Feel::MatrixBlock< NR, NC, MatrixType >::l1Norm | ( | ) | const [virtual] |
Return the l1-norm of the matrix, that is , (max. sum of columns).
This is the natural matrix norm that is compatible to the l1-norm for vectors, i.e. .
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
real_type Feel::MatrixBlock< NR, NC, MatrixType >::linftyNorm | ( | ) | const [virtual] |
Return the linfty-norm of the matrix, that is
,
(max. sum of rows). This is the natural matrix norm that is compatible to the linfty-norm of vectors, i.e. .
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
T Feel::MatrixBlock< NR, NC, MatrixType >::operator() | ( | const size_type | i, |
const size_type | j | ||
) | const [virtual] |
Return the value of the entry (i,j). This may be an expensive operation and you should always take care where to call this function. In order to avoid abuse, this function throws an exception if the required element does not exist in the matrix.
In case you want a function that returns zero instead (for entries that are not in the sparsity pattern of the matrix), use the el
function.
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::print | ( | std::ostream & | os = std::cout | ) | const |
Print the contents of the matrix to the screen in a uniform style, regardless of matrix/solver package being used.
Reimplemented from Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::printMatlab | ( | const std::string | name = "NULL" | ) | const [inline, virtual] |
Print the contents of the matrix in Matlab's sparse matrix format. Optionally prints the matrix to the file named name
. If name
is not specified it is dumped to the screen.
Reimplemented from Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::printPersonal | ( | std::ostream & | = std::cout | ) | const [inline, virtual] |
Print the contents of the matrix to the screen in a package-personalized style, if available.
Reimplemented from Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::reinitSubmatrix | ( | MatrixSparse< T > & | submatrix, |
const std::vector< size_type > & | rows, | ||
const std::vector< size_type > & | cols | ||
) | const [inline, virtual] |
This function is similar to the one above, but it allows you to reuse the existing sparsity pattern of "submatrix" instead of reallocating it again. This should hopefully be more efficient if you are frequently extracting submatrices of the same size.
Reimplemented from Feel::MatrixSparse< MatrixSparse::value_type >.
References Feel::MatrixSparse< MatrixSparse::value_type >::_get_submatrix().
size_type Feel::MatrixBlock< NR, NC, MatrixType >::rowStart | ( | ) | const [virtual] |
return row_start, the index of the first matrix row stored on this processor
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
size_type Feel::MatrixBlock< NR, NC, MatrixType >::rowStop | ( | ) | const [virtual] |
return row_stop, the index of the last matrix row (+1) stored on this processor
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::set | ( | const size_type | i, |
const size_type | j, | ||
const value_type & | value | ||
) | [virtual] |
Set the element (i,j) to
value
. Throws an error if the entry does not exist. Still, it is allowed to store zero values in non-existent fields.
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::setGraph | ( | graph_ptrtype const & | graph | ) | [inline] |
set the graph associated to the sparse matrix
Reimplemented from Feel::MatrixSparse< MatrixSparse::value_type >.
References Feel::MatrixBlock< NR, NC, MatrixType >::graph().
size_type Feel::MatrixBlock< NR, NC, MatrixType >::size1 | ( | ) | const [virtual] |
m
, the row-dimension of the matrix where the marix is Implements Feel::MatrixSparse< MatrixSparse::value_type >.
size_type Feel::MatrixBlock< NR, NC, MatrixType >::size2 | ( | ) | const [virtual] |
n
, the column-dimension of the matrix where the marix is Implements Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::zero | ( | ) | [virtual] |
Set all entries to 0.
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
void Feel::MatrixBlock< NR, NC, MatrixType >::zeroRows | ( | std::vector< int > const & | rows, |
std::vector< value_type > const & | values, | ||
Vector< value_type > & | rhs, | ||
Context const & | on_context | ||
) | [virtual] |
eliminate rows without change pattern, and put 1 on the diagonal entry
Implements Feel::MatrixSparse< MatrixSparse::value_type >.
std::ostream& operator<< | ( | std::ostream & | os, |
const MatrixSparse< U > & | m | ||
) | [friend] |
Same as the print method above, but allows you to print to a stream in the standard syntax.
Reimplemented from Feel::MatrixSparse< MatrixSparse::value_type >.