SparseMatrix< T > Class Template Reference
#include <sparse_matrix.h>

Public Member Functions | |
| SparseMatrix () | |
| virtual | ~SparseMatrix () |
| virtual bool | initialized () const |
| void | attach_dof_map (const DofMap &dof_map) |
| virtual bool | need_full_sparsity_pattern () const |
| virtual void | update_sparsity_pattern (const SparsityPattern::Graph &) |
| virtual void | init (const unsigned int m, const unsigned int n, const unsigned int m_l, const unsigned int n_l, const unsigned int nnz=30, const unsigned int noz=10)=0 |
| virtual void | init ()=0 |
| virtual void | clear ()=0 |
| virtual void | zero ()=0 |
| virtual void | zero_rows (std::vector< int > &rows, T diag_value=0.0) |
| virtual void | close () const =0 |
| virtual unsigned int | m () const =0 |
| virtual unsigned int | n () const =0 |
| virtual unsigned int | row_start () const =0 |
| virtual unsigned int | row_stop () const =0 |
| virtual void | set (const unsigned int i, const unsigned int j, const T value)=0 |
| virtual void | add (const unsigned int i, const unsigned int j, const T value)=0 |
| virtual void | add_matrix (const DenseMatrix< T > &dm, const std::vector< unsigned int > &rows, const std::vector< unsigned int > &cols)=0 |
| virtual void | add_matrix (const DenseMatrix< T > &dm, const std::vector< unsigned int > &dof_indices)=0 |
| virtual void | add (const T, SparseMatrix< T > &)=0 |
| virtual T | operator() (const unsigned int i, const unsigned int j) const =0 |
| virtual Real | l1_norm () const =0 |
| virtual Real | linfty_norm () const =0 |
| virtual bool | closed () const =0 |
| void | print (std::ostream &os=std::cout) const |
| virtual void | print_personal (std::ostream &os=std::cout) const =0 |
| virtual void | print_matlab (const std::string name="NULL") const |
| virtual void | create_submatrix (SparseMatrix< T > &submatrix, const std::vector< unsigned int > &rows, const std::vector< unsigned int > &cols) const |
| virtual void | reinit_submatrix (SparseMatrix< T > &submatrix, const std::vector< unsigned int > &rows, const std::vector< unsigned int > &cols) const |
| void | vector_mult (NumericVector< T > &dest, const NumericVector< T > &arg) const |
| void | vector_mult_add (NumericVector< T > &dest, const NumericVector< T > &arg) const |
| virtual void | get_diagonal (NumericVector< T > &dest) const =0 |
| virtual void | get_transpose (SparseMatrix< T > &dest) const =0 |
| template<> | |
| void | print (std::ostream &os) const |
Static Public Member Functions | |
| static AutoPtr< SparseMatrix< T > > | build (const SolverPackage solver_package=libMesh::default_solver_package()) |
| static std::string | get_info () |
| static void | print_info () |
| static unsigned int | n_objects () |
Protected Types | |
| typedef std::map< std::string, std::pair< unsigned int, unsigned int > > | Counts |
Protected Member Functions | |
| virtual void | _get_submatrix (SparseMatrix< T > &, const std::vector< unsigned int > &, const std::vector< unsigned int > &, const bool) const |
| void | increment_constructor_count (const std::string &name) |
| void | increment_destructor_count (const std::string &name) |
Protected Attributes | |
| DofMap const * | _dof_map |
| bool | _is_initialized |
Static Protected Attributes | |
| static Counts | _counts |
| static Threads::atomic < unsigned int > | _n_objects |
| static Threads::spin_mutex | _mutex |
Friends | |
| template<typename U > | |
| std::ostream & | operator<< (std::ostream &os, const SparseMatrix< U > &m) |
Detailed Description
template<typename T>
class SparseMatrix< T >
Generic sparse matrix. This class contains pure virtual members that must be overloaded in derived classes. Using a derived class allows for uniform access to sparse matrices from various different solver packages in different formats.
Definition at line 57 of file sparse_matrix.h.
Member Typedef Documentation
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited] |
Data structure to log the information. The log is identified by the class name.
Definition at line 105 of file reference_counter.h.
Constructor & Destructor Documentation
| SparseMatrix< T >::SparseMatrix | ( | ) | [inline] |
Constructor; initializes the matrix to be empty, without any structure, i.e. the matrix is not usable at all. This constructor is therefore only useful for matrices which are members of a class. All other matrices should be created at a point in the data flow where all necessary information is available.
You have to initialize the matrix before usage with init(...).
Definition at line 410 of file sparse_matrix.h.
00410 : 00411 _dof_map(NULL), 00412 _is_initialized(false) 00413 {}
| SparseMatrix< T >::~SparseMatrix | ( | ) | [inline, virtual] |
Destructor. Free all memory, but do not release the memory of the sparsity structure.
Definition at line 419 of file sparse_matrix.h.
Member Function Documentation
| virtual void SparseMatrix< T >::_get_submatrix | ( | SparseMatrix< T > & | , | |
| const std::vector< unsigned int > & | , | |||
| const std::vector< unsigned int > & | , | |||
| const | bool | |||
| ) | const [inline, protected, virtual] |
Protected implementation of the create_submatrix and reinit_submatrix routines. Note that this function must be redefined in derived classes for it to work properly!
Reimplemented in PetscMatrix< T >.
Definition at line 382 of file sparse_matrix.h.
Referenced by SparseMatrix< Real >::create_submatrix(), and SparseMatrix< Real >::reinit_submatrix().
00386 { 00387 std::cerr << "Error! This function is not yet implemented in the base class!" 00388 << std::endl; 00389 libmesh_error(); 00390 }
| virtual void SparseMatrix< T >::add | ( | const | T, | |
| SparseMatrix< T > & | ||||
| ) | [pure virtual] |
Add a Sparse matrix _X, scaled with _a, to this, stores the result in this:
.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual void SparseMatrix< T >::add | ( | const unsigned int | i, | |
| const unsigned int | j, | |||
| const T | value | |||
| ) | [pure 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.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual void SparseMatrix< T >::add_matrix | ( | const DenseMatrix< T > & | dm, | |
| const std::vector< unsigned int > & | dof_indices | |||
| ) | [pure virtual] |
Same, but assumes the row and column maps are the same. Thus the matrix dm must be square.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual void SparseMatrix< T >::add_matrix | ( | const DenseMatrix< T > & | dm, | |
| const std::vector< unsigned int > & | rows, | |||
| const std::vector< unsigned int > & | cols | |||
| ) | [pure virtual] |
Add the full matrix to the Sparse matrix. This is useful for adding an element matrix at assembly time
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| void SparseMatrix< T >::attach_dof_map | ( | const DofMap & | dof_map | ) | [inline] |
Get a pointer to the DofMap to use.
Definition at line 100 of file sparse_matrix.h.
Referenced by DofMap::attach_matrix().
00101 { _dof_map = &dof_map; }
| AutoPtr< SparseMatrix< T > > SparseMatrix< T >::build | ( | const SolverPackage | solver_package = libMesh::default_solver_package() |
) | [inline, static] |
Builds a SparseMatrix<T> using the linear solver package specified by solver_package
Definition at line 40 of file sparse_matrix.C.
References LASPACK_SOLVERS, libMeshEnums::PETSC_SOLVERS, and TRILINOS_SOLVERS.
00041 { 00042 // Build the appropriate vector 00043 switch (solver_package) 00044 { 00045 00046 00047 #ifdef LIBMESH_HAVE_LASPACK 00048 case LASPACK_SOLVERS: 00049 { 00050 AutoPtr<SparseMatrix<T> > ap(new LaspackMatrix<T>); 00051 return ap; 00052 } 00053 #endif 00054 00055 00056 #ifdef LIBMESH_HAVE_PETSC 00057 case PETSC_SOLVERS: 00058 { 00059 AutoPtr<SparseMatrix<T> > ap(new PetscMatrix<T>); 00060 return ap; 00061 } 00062 #endif 00063 00064 00065 #ifdef LIBMESH_HAVE_TRILINOS 00066 case TRILINOS_SOLVERS: 00067 { 00068 AutoPtr<SparseMatrix<T> > ap(new EpetraMatrix<T>); 00069 return ap; 00070 } 00071 #endif 00072 00073 00074 default: 00075 std::cerr << "ERROR: Unrecognized solver package: " 00076 << solver_package 00077 << std::endl; 00078 libmesh_error(); 00079 } 00080 00081 AutoPtr<SparseMatrix<T> > ap(NULL); 00082 return ap; 00083 }
| virtual void SparseMatrix< T >::clear | ( | ) | [pure virtual] |
Release all memory and return to a state just like after having called the default constructor.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
Referenced by PetscMatrix< T >::_get_submatrix(), and PetscMatrix< T >::get_transpose().
| virtual void SparseMatrix< T >::close | ( | ) | const [pure virtual] |
Call the Sparse assemble routines. sends necessary messages to other processors
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual bool SparseMatrix< T >::closed | ( | ) | const [pure virtual] |
see if Sparse matrix has been closed and fully assembled yet
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual void SparseMatrix< T >::create_submatrix | ( | SparseMatrix< T > & | submatrix, | |
| const std::vector< unsigned int > & | rows, | |||
| const std::vector< unsigned int > & | 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.
Definition at line 325 of file sparse_matrix.h.
00328 { 00329 this->_get_submatrix(submatrix, 00330 rows, 00331 cols, 00332 false); // false means DO NOT REUSE submatrix 00333 }
| virtual void SparseMatrix< T >::get_diagonal | ( | NumericVector< T > & | dest | ) | const [pure virtual] |
Copies the diagonal part of the matrix into dest.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| std::string ReferenceCounter::get_info | ( | ) | [static, inherited] |
Gets a string containing the reference information.
Definition at line 45 of file reference_counter.C.
References ReferenceCounter::_counts, and QuadratureRules::name().
Referenced by ReferenceCounter::print_info().
00046 { 00047 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG) 00048 00049 std::ostringstream out; 00050 00051 out << '\n' 00052 << " ---------------------------------------------------------------------------- \n" 00053 << "| Reference count information |\n" 00054 << " ---------------------------------------------------------------------------- \n"; 00055 00056 for (Counts::iterator it = _counts.begin(); 00057 it != _counts.end(); ++it) 00058 { 00059 const std::string name(it->first); 00060 const unsigned int creations = it->second.first; 00061 const unsigned int destructions = it->second.second; 00062 00063 out << "| " << name << " reference count information:\n" 00064 << "| Creations: " << creations << '\n' 00065 << "| Destructions: " << destructions << '\n'; 00066 } 00067 00068 out << " ---------------------------------------------------------------------------- \n"; 00069 00070 return out.str(); 00071 00072 #else 00073 00074 return ""; 00075 00076 #endif 00077 }
| virtual void SparseMatrix< T >::get_transpose | ( | SparseMatrix< T > & | dest | ) | const [pure virtual] |
Copies the transpose of the matrix into dest, which may be *this.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| void ReferenceCounter::increment_constructor_count | ( | const std::string & | name | ) | [inline, protected, inherited] |
Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.
Definition at line 149 of file reference_counter.h.
References ReferenceCounter::_counts, and Threads::spin_mtx.
Referenced by ReferenceCountedObject< SparseMatrix< T > >::ReferenceCountedObject().
00150 { 00151 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); 00152 std::pair<unsigned int, unsigned int>& p = _counts[name]; 00153 00154 p.first++; 00155 }
| void ReferenceCounter::increment_destructor_count | ( | const std::string & | name | ) | [inline, protected, inherited] |
Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.
Definition at line 167 of file reference_counter.h.
References ReferenceCounter::_counts, and Threads::spin_mtx.
Referenced by ReferenceCountedObject< SparseMatrix< T > >::~ReferenceCountedObject().
00168 { 00169 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); 00170 std::pair<unsigned int, unsigned int>& p = _counts[name]; 00171 00172 p.second++; 00173 }
| virtual void SparseMatrix< T >::init | ( | ) | [pure virtual] |
Initialize using sparsity structure computed by dof_map.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual void SparseMatrix< T >::init | ( | const unsigned int | m, | |
| const unsigned int | n, | |||
| const unsigned int | m_l, | |||
| const unsigned int | n_l, | |||
| const unsigned int | nnz = 30, |
|||
| const unsigned int | noz = 10 | |||
| ) | [pure virtual] |
Initialize a Sparse 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 10).
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual bool SparseMatrix< T >::initialized | ( | ) | const [inline, virtual] |
- Returns:
- true if the matrix has been initialized, false otherwise.
Definition at line 95 of file sparse_matrix.h.
Referenced by PetscMatrix< T >::_get_submatrix(), EpetraMatrix< T >::add(), PetscMatrix< T >::add(), LaspackMatrix< T >::add(), EpetraMatrix< T >::add_matrix(), PetscMatrix< T >::add_matrix(), LaspackMatrix< T >::add_matrix(), EpetraMatrix< T >::clear(), PetscMatrix< T >::clear(), LaspackMatrix< T >::clear(), EpetraMatrix< T >::closed(), PetscMatrix< T >::closed(), EpetraMatrix< T >::init(), PetscMatrix< T >::init(), LaspackMatrix< T >::init(), EpetraMatrix< T >::l1_norm(), PetscMatrix< T >::l1_norm(), EpetraMatrix< T >::linfty_norm(), PetscMatrix< T >::linfty_norm(), EpetraMatrix< T >::m(), PetscMatrix< T >::m(), LaspackMatrix< T >::m(), EpetraMatrix< T >::n(), PetscMatrix< T >::n(), LaspackMatrix< T >::n(), EpetraMatrix< T >::operator()(), PetscMatrix< T >::operator()(), LaspackMatrix< T >::operator()(), SparseMatrix< T >::print(), EpetraMatrix< T >::print_matlab(), PetscMatrix< T >::print_matlab(), EpetraMatrix< T >::print_personal(), PetscMatrix< T >::print_personal(), EpetraMatrix< T >::row_start(), PetscMatrix< T >::row_start(), EpetraMatrix< T >::row_stop(), PetscMatrix< T >::row_stop(), EpetraMatrix< T >::set(), PetscMatrix< T >::set(), LaspackMatrix< T >::set(), EpetraMatrix< T >::update_sparsity_pattern(), LaspackMatrix< T >::update_sparsity_pattern(), EpetraMatrix< T >::zero(), PetscMatrix< T >::zero(), and PetscMatrix< T >::zero_rows().
00095 { return _is_initialized; }
| virtual Real SparseMatrix< T >::l1_norm | ( | ) | const [pure 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.
.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual Real SparseMatrix< T >::linfty_norm | ( | ) | const [pure 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.
.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual unsigned int SparseMatrix< T >::m | ( | ) | const [pure virtual] |
- Returns:
m, the row-dimension of the matrix where the marix is
.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
Referenced by EpetraMatrix< T >::add(), PetscMatrix< T >::add(), LaspackMatrix< T >::add(), and SparseMatrix< T >::print().
| virtual unsigned int SparseMatrix< T >::n | ( | ) | const [pure virtual] |
- Returns:
n, the column-dimension of the matrix where the marix is
.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
Referenced by EpetraMatrix< T >::add(), PetscMatrix< T >::add(), LaspackMatrix< T >::add(), and SparseMatrix< T >::print().
| static unsigned int ReferenceCounter::n_objects | ( | ) | [inline, static, inherited] |
Prints the number of outstanding (created, but not yet destroyed) objects.
Definition at line 76 of file reference_counter.h.
References ReferenceCounter::_n_objects.
00077 { return _n_objects; }
| virtual bool SparseMatrix< T >::need_full_sparsity_pattern | ( | ) | const [inline, virtual] |
returns true if this sparse matrix format needs to be fed the graph of the sparse matrix. This is true in the case of the LaspackMatrix, but not for the PetscMatrix. In the case where the full graph is not required we can efficiently approximate it to provide a good estimate of the required size of the sparse matrix.
Reimplemented in LaspackMatrix< T >, and EpetraMatrix< T >.
Definition at line 110 of file sparse_matrix.h.
| virtual T SparseMatrix< T >::operator() | ( | const unsigned int | i, | |
| const unsigned int | j | |||
| ) | const [pure 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.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| void SparseMatrix< Complex >::print | ( | std::ostream & | os | ) | const [inline] |
Definition at line 429 of file sparse_matrix.h.
References SparseMatrix< T >::m(), and SparseMatrix< T >::n().
00430 { 00431 // std::complex<>::operator<<() is defined, but use this form 00432 00433 std::cout << "Real part:" << std::endl; 00434 for (unsigned int i=0; i<this->m(); i++) 00435 { 00436 for (unsigned int j=0; j<this->n(); j++) 00437 os << std::setw(8) << (*this)(i,j).real() << " "; 00438 os << std::endl; 00439 } 00440 00441 os << std::endl << "Imaginary part:" << std::endl; 00442 for (unsigned int i=0; i<this->m(); i++) 00443 { 00444 for (unsigned int j=0; j<this->n(); j++) 00445 os << std::setw(8) << (*this)(i,j).imag() << " "; 00446 os << std::endl; 00447 } 00448 }
| void SparseMatrix< T >::print | ( | std::ostream & | os = std::cout |
) | const [inline] |
Print the contents of the matrix to the screen in a uniform style, regardless of matrix/solver package being used.
Definition at line 118 of file sparse_matrix.C.
References SparseMatrix< T >::_dof_map, DofMap::end_dof(), DofMap::first_dof(), SparseMatrix< T >::initialized(), SparseMatrix< T >::m(), SparseMatrix< T >::n(), libMesh::n_processors(), and libMesh::processor_id().
Referenced by LaspackMatrix< T >::print_personal().
00119 { 00120 parallel_only(); 00121 00122 libmesh_assert (this->initialized()); 00123 00124 // We'll print the matrix from processor 0 to make sure 00125 // it's serialized properly 00126 if (libMesh::processor_id() == 0) 00127 { 00128 libmesh_assert(this->_dof_map->first_dof() == 0); 00129 for (unsigned int i=this->_dof_map->first_dof(); 00130 i!=this->_dof_map->end_dof(); ++i) 00131 { 00132 for (unsigned int j=0; j<this->n(); j++) 00133 os << (*this)(i,j) << " "; 00134 os << std::endl; 00135 } 00136 00137 std::vector<unsigned int> ibuf, jbuf; 00138 std::vector<T> cbuf; 00139 unsigned int currenti = this->_dof_map->end_dof(); 00140 for (unsigned int p=1; p < libMesh::n_processors(); ++p) 00141 { 00142 Parallel::receive(p, ibuf); 00143 Parallel::receive(p, jbuf); 00144 Parallel::receive(p, cbuf); 00145 libmesh_assert(ibuf.size() == jbuf.size()); 00146 libmesh_assert(ibuf.size() == cbuf.size()); 00147 00148 if (ibuf.empty()) 00149 continue; 00150 libmesh_assert(ibuf.front() >= currenti); 00151 libmesh_assert(ibuf.back() >= ibuf.front()); 00152 00153 unsigned int currentb = 0; 00154 for (;currenti <= ibuf.back(); ++currenti) 00155 { 00156 for (unsigned int j=0; j<this->n(); j++) 00157 { 00158 if (currentb < ibuf.size() && 00159 ibuf[currentb] == currenti && 00160 jbuf[currentb] == j) 00161 { 00162 os << cbuf[currentb] << " "; 00163 currentb++; 00164 } 00165 else 00166 os << static_cast<T>(0.0) << " "; 00167 } 00168 os << std::endl; 00169 } 00170 } 00171 for (; currenti != this->m(); ++currenti) 00172 { 00173 for (unsigned int j=0; j<this->n(); j++) 00174 os << static_cast<T>(0.0) << " "; 00175 os << std::endl; 00176 } 00177 } 00178 else 00179 { 00180 std::vector<unsigned int> ibuf, jbuf; 00181 std::vector<T> cbuf; 00182 00183 // We'll assume each processor has access to entire 00184 // matrix rows, so (*this)(i,j) is valid if i is a local index. 00185 for (unsigned int i=this->_dof_map->first_dof(); 00186 i!=this->_dof_map->end_dof(); ++i) 00187 { 00188 for (unsigned int j=0; j<this->n(); j++) 00189 { 00190 T c = (*this)(i,j); 00191 if (c != static_cast<T>(0.0)) 00192 { 00193 ibuf.push_back(i); 00194 jbuf.push_back(j); 00195 cbuf.push_back(c); 00196 } 00197 } 00198 } 00199 Parallel::send(0,ibuf); 00200 Parallel::send(0,jbuf); 00201 Parallel::send(0,cbuf); 00202 } 00203 }
| void ReferenceCounter::print_info | ( | ) | [static, inherited] |
Prints the reference information to std::cout.
Definition at line 83 of file reference_counter.C.
References ReferenceCounter::get_info().
00084 { 00085 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG) 00086 00087 std::cout << ReferenceCounter::get_info(); 00088 00089 #endif 00090 }
| virtual void SparseMatrix< T >::print_matlab | ( | 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. x
Reimplemented in PetscMatrix< T >, and EpetraMatrix< T >.
Definition at line 313 of file sparse_matrix.h.
00314 { 00315 std::cerr << "ERROR: Not Implemented in base class yet!" << std::endl; 00316 std::cerr << "ERROR writing MATLAB file " << name << std::endl; 00317 libmesh_error(); 00318 }
| virtual void SparseMatrix< T >::print_personal | ( | std::ostream & | os = std::cout |
) | const [pure virtual] |
Print the contents of the matrix to the screen in a package-personalized style, if available.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual void SparseMatrix< T >::reinit_submatrix | ( | SparseMatrix< T > & | submatrix, | |
| const std::vector< unsigned int > & | rows, | |||
| const std::vector< unsigned int > & | 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.
Definition at line 341 of file sparse_matrix.h.
00344 { 00345 this->_get_submatrix(submatrix, 00346 rows, 00347 cols, 00348 true); // true means REUSE submatrix 00349 }
| virtual unsigned int SparseMatrix< T >::row_start | ( | ) | const [pure virtual] |
return row_start, the index of the first matrix row stored on this processor
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual unsigned int SparseMatrix< T >::row_stop | ( | ) | const [pure virtual] |
return row_stop, the index of the last matrix row (+1) stored on this processor
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual void SparseMatrix< T >::set | ( | const unsigned int | i, | |
| const unsigned int | j, | |||
| const T | value | |||
| ) | [pure 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.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| virtual void SparseMatrix< T >::update_sparsity_pattern | ( | const SparsityPattern::Graph & | ) | [inline, virtual] |
Updates the matrix sparsity pattern. When your SparseMatrix<T> implementation does not need this data simply do not overload this method.
Reimplemented in LaspackMatrix< T >, and EpetraMatrix< T >.
Definition at line 118 of file sparse_matrix.h.
| void SparseMatrix< T >::vector_mult | ( | NumericVector< T > & | dest, | |
| const NumericVector< T > & | arg | |||
| ) | const [inline] |
Multiplies the matrix with arg and stores the result in dest.
Definition at line 87 of file sparse_matrix.C.
References SparseMatrix< T >::vector_mult_add(), and NumericVector< T >::zero().
00089 { 00090 dest.zero(); 00091 this->vector_mult_add(dest,arg); 00092 }
| void SparseMatrix< T >::vector_mult_add | ( | NumericVector< T > & | dest, | |
| const NumericVector< T > & | arg | |||
| ) | const [inline] |
Multiplies the matrix with arg and adds the result to dest.
Definition at line 97 of file sparse_matrix.C.
References NumericVector< T >::add_vector().
Referenced by SparseMatrix< T >::vector_mult().
00099 { 00100 /* This functionality is actually implemented in the \p 00101 NumericVector class. */ 00102 dest.add_vector(arg,*this); 00103 }
| virtual void SparseMatrix< T >::zero | ( | ) | [pure virtual] |
Set all entries to 0.
Implemented in LaspackMatrix< T >, PetscMatrix< T >, and EpetraMatrix< T >.
| void SparseMatrix< T >::zero_rows | ( | std::vector< int > & | rows, | |
| T | diag_value = 0.0 | |||
| ) | [inline, virtual] |
Set all row entries to 0 then puts diag_value in the diagonal entry
Reimplemented in PetscMatrix< T >.
Definition at line 108 of file sparse_matrix.C.
00109 { 00110 /* This functionality isn't implemented or stubbed in every subclass yet */ 00111 libmesh_not_implemented(); 00112 }
Friends And Related Function Documentation
| std::ostream& operator<< | ( | std::ostream & | os, | |
| const SparseMatrix< U > & | m | |||
| ) | [friend] |
Same as the print method above, but allows you to print to a stream in the standard syntax.
Member Data Documentation
ReferenceCounter::Counts ReferenceCounter::_counts [static, protected, inherited] |
Actually holds the data.
Definition at line 110 of file reference_counter.h.
Referenced by ReferenceCounter::get_info(), ReferenceCounter::increment_constructor_count(), and ReferenceCounter::increment_destructor_count().
DofMap const* SparseMatrix< T >::_dof_map [protected] |
The DofMap object associated with this object.
Definition at line 395 of file sparse_matrix.h.
Referenced by SparseMatrix< Real >::attach_dof_map(), EpetraMatrix< T >::init(), PetscMatrix< T >::init(), LaspackMatrix< T >::init(), SparseMatrix< T >::print(), EpetraMatrix< T >::update_sparsity_pattern(), and LaspackMatrix< T >::update_sparsity_pattern().
bool SparseMatrix< T >::_is_initialized [protected] |
Flag indicating whether or not the matrix has been initialized.
Definition at line 401 of file sparse_matrix.h.
Referenced by PetscMatrix< T >::_get_submatrix(), EpetraMatrix< T >::clear(), PetscMatrix< T >::clear(), LaspackMatrix< T >::clear(), PetscMatrix< T >::get_transpose(), EpetraMatrix< T >::init(), PetscMatrix< T >::init(), LaspackMatrix< T >::init(), SparseMatrix< Real >::initialized(), and PetscMatrix< T >::PetscMatrix().
Threads::spin_mutex ReferenceCounter::_mutex [static, protected, inherited] |
Mutual exclusion object to enable thread-safe reference counting.
Definition at line 123 of file reference_counter.h.
Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited] |
The number of objects. Print the reference count information when the number returns to 0.
Definition at line 118 of file reference_counter.h.
Referenced by ReferenceCounter::n_objects(), ReferenceCounter::ReferenceCounter(), and ReferenceCounter::~ReferenceCounter().
The documentation for this class was generated from the following files: