libMesh::CouplingMatrix Class Reference

#include <coupling_matrix.h>

Public Member Functions

 CouplingMatrix (const unsigned int n=0)
 
unsigned char operator() (const unsigned int i, const unsigned int j) const
 
unsigned char & operator() (const unsigned int i, const unsigned int j)
 
unsigned int size () const
 
void resize (const unsigned int n)
 
void clear ()
 
bool empty () const
 

Private Attributes

std::vector< unsigned char > _values
 
unsigned int _size
 

Detailed Description

This class defines a coupling matrix. A coupling matrix is simply a matrix of ones and zeros describing how different components in a system couple with each other. A coupling matrix is necessarily square but not necessarily symmetric.

Definition at line 42 of file coupling_matrix.h.

Constructor & Destructor Documentation

libMesh::CouplingMatrix::CouplingMatrix ( const unsigned int  n = 0)
inlineexplicit

Constructor.

Definition at line 111 of file coupling_matrix.h.

References resize().

111  :
112  _values(), _size(n)
113 {
114  this->resize(n);
115 }

Member Function Documentation

void libMesh::CouplingMatrix::clear ( )
inline

Clears the matrix.

Definition at line 165 of file coupling_matrix.h.

References _size, and _values.

166 {
167  _size = 0;
168 
169  _values.clear();
170 }
bool libMesh::CouplingMatrix::empty ( ) const
inline
Returns
true if the matrix is empty.

Definition at line 175 of file coupling_matrix.h.

References _size.

Referenced by libMesh::SparsityPattern::Build::operator()().

176 {
177  return (_size == 0);
178 }
unsigned char libMesh::CouplingMatrix::operator() ( const unsigned int  i,
const unsigned int  j 
) const
inline
Returns
the (i,j) entry of the matrix.

Definition at line 120 of file coupling_matrix.h.

References _size, and _values.

122 {
123  libmesh_assert_less (i, _size);
124  libmesh_assert_less (j, _size);
125 
126  return _values[i*_size + j];
127 }
unsigned char & libMesh::CouplingMatrix::operator() ( const unsigned int  i,
const unsigned int  j 
)
inline
Returns
the (i,j) entry of the matrix as a writeable reference.

Definition at line 132 of file coupling_matrix.h.

References _size, and _values.

134 {
135  libmesh_assert_less (i, _size);
136  libmesh_assert_less (j, _size);
137 
138  return _values[i*_size + j];
139 }
void libMesh::CouplingMatrix::resize ( const unsigned int  n)
inline

Resizes the matrix and initializes all entries to be 0.

Definition at line 152 of file coupling_matrix.h.

References _size, and _values.

Referenced by CouplingMatrix().

153 {
154  _size = n;
155 
156  _values.resize(_size*_size);
157 
158  for (unsigned int i=0; i<_values.size(); i++)
159  _values[i] = 0;
160 }
unsigned int libMesh::CouplingMatrix::size ( ) const
inline
Returns
the size of the matrix, i.e. N for an NxN matrix.

Definition at line 144 of file coupling_matrix.h.

References _size.

Referenced by libMesh::SparsityPattern::Build::operator()().

145 {
146  return _size;
147 }

Member Data Documentation

unsigned int libMesh::CouplingMatrix::_size
private

The size of the matrix.

Definition at line 100 of file coupling_matrix.h.

Referenced by clear(), empty(), operator()(), resize(), and size().

std::vector<unsigned char> libMesh::CouplingMatrix::_values
private

The actual matrix values. These are stored as unsigned chars because a vector of bools is not what you think.

Definition at line 95 of file coupling_matrix.h.

Referenced by clear(), operator()(), and resize().


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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:15 UTC

Hosted By:
SourceForge.net Logo