Feel++
0.91.4
|
interface to gmm sparse matrix More...
#include <matrixgmm.hpp>
Public Member Functions | |
Constructors, destructor | |
MatrixGmm () | |
MatrixGmm (size_type r, size_type c) | |
MatrixGmm (MatrixGmm const &m) | |
~MatrixGmm () | |
Operator overloads | |
MatrixGmm< T, LayoutType > & | operator= (MatrixSparse< value_type > const &M) |
value_type | operator() (size_type i, size_type j) const |
Accessors | |
size_type | size1 () const |
size_type | size2 () const |
size_type | nnz () const |
size_type | rowStart () const |
size_type | rowStop () const |
bool | isInitialized () const |
void | close () const |
bool | closed () const |
matrix_type const & | mat () const |
matrix_type & | mat () |
write_matrix_type const & | wmat () const |
write_matrix_type & | wmat () |
Methods | |
void | init (const size_type m, const size_type n, const size_type m_l, const size_type n_l, const size_type nnz=30, const size_type noz=10) |
void | init (const size_type m, const size_type n, const size_type m_l, const size_type n_l, graph_ptrtype const &graph) |
void | clear () |
void | zero () |
void | zero (size_type start1, size_type stop1, size_type start2, size_type stop2) |
void | add (const size_type i, const size_type j, const value_type &value) |
void | set (const size_type i, const size_type j, const value_type &value) |
void | printMatlab (const std::string name="NULL") const |
void | fill (pattern_type const &) |
void | resize (size_type nr, size_type nc, bool=false) |
value_type | energy (Vector< value_type > const &__v, Vector< value_type > const &__u, bool transpose=false) const |
void | zeroRows (std::vector< int > const &rows, std::vector< value_type > const &values, Vector< value_type > &rhs, Context const &on_context) |
void | init () |
void | addMatrix (const ublas::matrix< T, ublas::row_major > &, const std::vector< size_type > &, const std::vector< size_type > &) |
void | addMatrix (const boost::numeric::ublas::matrix< T, ublas::row_major > &, const std::vector< size_type > &) |
void | addMatrix (value_type v, MatrixSparse< value_type > &_m) |
void | addMatrix (int *rows, int nrows, int *cols, int ncols, value_type *data) |
void | scale (const T a) |
void | transpose (MatrixSparse< value_type > &Mt) const |
real_type | l1Norm () const |
real_type | linftyNorm () const |
void | updateBlockMat (boost::shared_ptr< MatrixSparse< value_type > > m, size_type start_i, size_type start_j) |
Typedefs | |
typedef T | value_type |
typedef type_traits < value_type >::real_type | real_type |
typedef mpl::if_ < boost::is_same< LayoutType, gmm::row_major > , mpl::identity < gmm::csr_matrix< value_type > >, typename mpl::if_ < boost::is_same< LayoutType, gmm::col_major > , mpl::identity < gmm::csc_matrix< value_type > >, mpl::identity < boost::none_t > >::type > ::type::type | matrix_type |
typedef std::vector< std::set < size_type > > | pattern_type |
typedef gmm::row_matrix < gmm::wsvector< value_type > > | write_matrix_type |
typedef super::graph_type | graph_type |
typedef super::graph_ptrtype | graph_ptrtype |
static const bool | is_row_major = boost::is_same<LayoutType,gmm::row_major>::value |
interface to gmm sparse matrix
this class is a wrapper around csr_matrix<>
and csc_matrix<>
data type from gmm:
: .
// csr matrix MatrixGmm<T,gmm::row_major> m; // csc matrix MatrixGmm<T,gmm::col_major> m;
void Feel::MatrixGmm< T, LayoutType >::add | ( | const size_type | i, |
const size_type | j, | ||
const value_type & | value | ||
) | [inline, 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< T >.
void Feel::MatrixGmm< T, LayoutType >::addMatrix | ( | const ublas::matrix< T, ublas::row_major > & | , |
const std::vector< size_type > & | , | ||
const std::vector< size_type > & | |||
) | [inline] |
Add the full matrix to the Petsc matrix. This is useful for adding an element matrix at assembly time
void Feel::MatrixGmm< T, LayoutType >::addMatrix | ( | const boost::numeric::ublas::matrix< T, ublas::row_major > & | , |
const std::vector< size_type > & | |||
) | [inline] |
Same, but assumes the row and column maps are the same. Thus the matrix dm
must be square.
void Feel::MatrixGmm< T, LayoutType >::addMatrix | ( | value_type | v, |
MatrixSparse< value_type > & | _m | ||
) | [virtual] |
Add a Sparse matrix _X
, scaled with _a
, to this
, stores the result in this:
.
Implements Feel::MatrixSparse< T >.
References Feel::MatrixGmm< T, LayoutType >::closed(), and Feel::MatrixGmm< T, LayoutType >::mat().
void Feel::MatrixGmm< T, LayoutType >::addMatrix | ( | int * | rows, |
int | nrows, | ||
int * | cols, | ||
int | ncols, | ||
value_type * | data | ||
) | [inline, virtual] |
Add the full matrix to the Sparse matrix. This is useful for adding an element matrix at assembly time
Implements Feel::MatrixSparse< T >.
void Feel::MatrixGmm< T, LayoutType >::clear | ( | ) | [inline, virtual] |
Release all memory and return to a state just like after having called the default constructor.
Implements Feel::MatrixSparse< T >.
Referenced by Feel::MatrixGmm< T, LayoutType >::zero().
void Feel::MatrixGmm< T, LayoutType >::close | ( | ) | const [virtual] |
close
the gmm matrix, that will copy the content of write optimized matrix into a read optimized matrix
Implements Feel::MatrixSparse< T >.
bool Feel::MatrixGmm< T, LayoutType >::closed | ( | ) | const [inline, virtual] |
see if Gmm matrix has been closed and fully assembled yet
Implements Feel::MatrixSparse< T >.
Referenced by Feel::MatrixGmm< T, LayoutType >::addMatrix().
MatrixGmm< T, LayoutType >::value_type Feel::MatrixGmm< T, LayoutType >::energy | ( | Vector< value_type > const & | __v, |
Vector< value_type > const & | __u, | ||
bool | transpose = false |
||
) | const |
References Feel::Vector< T >::size(), and Feel::VectorUblas< T, Storage >::vec().
void Feel::MatrixGmm< T, LayoutType >::fill | ( | pattern_type const & | ) |
fill sparse matrix with non zero entries
void Feel::MatrixGmm< T, LayoutType >::init | ( | const size_type | m, |
const size_type | n, | ||
const size_type | m_l, | ||
const size_type | n_l, | ||
const size_type | nnz = 30 , |
||
const size_type | noz = 10 |
||
) | [virtual] |
Initialize a Gmm matrix that is of global dimension with local dimensions
.
nnz
is the number of on-processor nonzeros per row (defaults to 30). noz
is the number of on-processor nonzeros per row (defaults to 30).
Implements Feel::MatrixSparse< T >.
void Feel::MatrixGmm< T, LayoutType >::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< T >.
bool Feel::MatrixGmm< T, LayoutType >::isInitialized | ( | ) | const [inline, virtual] |
Reimplemented from Feel::MatrixSparse< T >.
real_type Feel::MatrixGmm< T, LayoutType >::l1Norm | ( | ) | const [inline, 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< T >.
real_type Feel::MatrixGmm< T, LayoutType >::linftyNorm | ( | ) | const [inline, 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< T >.
matrix_type const& Feel::MatrixGmm< T, LayoutType >::mat | ( | ) | const [inline] |
Returns the read optimized gmm matrix.
Referenced by Feel::MatrixGmm< T, LayoutType >::addMatrix(), and Feel::BackendGmm< T >::prod().
matrix_type& Feel::MatrixGmm< T, LayoutType >::mat | ( | ) | [inline] |
Returns the read optimized gmm matrix.
size_type Feel::MatrixGmm< T, LayoutType >::nnz | ( | ) | const [inline] |
value_type Feel::MatrixGmm< T, LayoutType >::operator() | ( | size_type | i, |
size_type | j | ||
) | const [inline, 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< T >.
void Feel::MatrixGmm< T, LayoutType >::printMatlab | ( | const std::string | name = "NULL" | ) | const [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< T >.
size_type Feel::MatrixGmm< T, LayoutType >::rowStart | ( | ) | const [inline, virtual] |
return row_start, the index of the first matrix row stored on this processor
Implements Feel::MatrixSparse< T >.
size_type Feel::MatrixGmm< T, LayoutType >::rowStop | ( | ) | const [inline, virtual] |
return row_stop, the index of the last matrix row (+1) stored on this processor
Implements Feel::MatrixSparse< T >.
void Feel::MatrixGmm< T, LayoutType >::set | ( | const size_type | i, |
const size_type | j, | ||
const value_type & | value | ||
) | [inline, virtual] |
set 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< T >.
size_type Feel::MatrixGmm< T, LayoutType >::size1 | ( | ) | const [inline, virtual] |
m
, the row-dimension of the matrix where the marix is Implements Feel::MatrixSparse< T >.
size_type Feel::MatrixGmm< T, LayoutType >::size2 | ( | ) | const [inline, virtual] |
n
, the column-dimension of the matrix where the marix is Implements Feel::MatrixSparse< T >.
void Feel::MatrixGmm< T, LayoutType >::transpose | ( | MatrixSparse< value_type > & | Mt | ) | const [virtual] |
Returns the transpose of a matrix
M | the matrix to transpose |
Mt | the matrix transposed |
Implements Feel::MatrixSparse< T >.
void Feel::MatrixGmm< T, LayoutType >::updateBlockMat | ( | boost::shared_ptr< MatrixSparse< value_type > > | m, |
size_type | start_i, | ||
size_type | start_j | ||
) | [inline, virtual] |
update a block matrix
Implements Feel::MatrixSparse< T >.
write_matrix_type const& Feel::MatrixGmm< T, LayoutType >::wmat | ( | ) | const [inline] |
Returns the write optimized gmm matrix.
write_matrix_type& Feel::MatrixGmm< T, LayoutType >::wmat | ( | ) | [inline] |
Returns the write optimized gmm matrix.
void Feel::MatrixGmm< T, LayoutType >::zero | ( | ) | [inline, virtual] |
Set all entries to 0. This method retains sparsity structure.
Implements Feel::MatrixSparse< T >.
References Feel::MatrixGmm< T, LayoutType >::clear().
void Feel::MatrixGmm< T, LayoutType >::zero | ( | size_type | start1, |
size_type | size1, | ||
size_type | start2, | ||
size_type | size2 | ||
) | [inline, virtual] |
Set entries between to 0.
Implements Feel::MatrixSparse< T >.
References Feel::MatrixGmm< T, LayoutType >::clear().
void Feel::MatrixGmm< T, LayoutType >::zeroRows | ( | std::vector< int > const & | rows, |
std::vector< value_type > const & | values, | ||
Vector< value_type > & | rhs, | ||
Context const & | on_context | ||
) | [virtual] |
eliminates row without change pattern, and put 1 on the diagonal entry
Implements Feel::MatrixSparse< T >.
References Feel::ON_ELIMINATION_KEEP_DIAGONAL, and Feel::Vector< T >::set().