CouplingMatrix Class Reference

#include <coupling_matrix.h>

List of all members.

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 41 of file coupling_matrix.h.


Constructor & Destructor Documentation

CouplingMatrix::CouplingMatrix ( const unsigned int  n = 0  )  [inline]

Constructor.

Definition at line 109 of file coupling_matrix.h.

References resize().

00109                                                     :
00110   _size(n)
00111 {
00112   this->resize(n);
00113 }


Member Function Documentation

void CouplingMatrix::clear (  )  [inline]

Clears the matrix.

Definition at line 163 of file coupling_matrix.h.

References _size, and _values.

00164 {
00165   _size = 0;
00166 
00167   _values.clear();
00168 }

bool CouplingMatrix::empty (  )  const [inline]

Returns:
true if the matrix is empty.

Definition at line 173 of file coupling_matrix.h.

References _size.

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

00174 {
00175   return (_size == 0);
00176 }

unsigned char & 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 130 of file coupling_matrix.h.

References _size, and _values.

00132 {
00133   libmesh_assert (i < _size);
00134   libmesh_assert (j < _size);
00135 
00136   return _values[i*_size + j];
00137 }

unsigned char CouplingMatrix::operator() ( const unsigned int  i,
const unsigned int  j 
) const [inline]

Returns:
the (i,j) entry of the matrix.

Definition at line 118 of file coupling_matrix.h.

References _size, and _values.

00120 {
00121   libmesh_assert (i < _size);
00122   libmesh_assert (j < _size);
00123 
00124   return _values[i*_size + j];
00125 }

void CouplingMatrix::resize ( const unsigned int  n  )  [inline]

Resizes the matrix and initializes all entries to be 0.

Definition at line 150 of file coupling_matrix.h.

References _size, and _values.

Referenced by CouplingMatrix().

00151 {
00152   _size = n;
00153 
00154   _values.resize(_size*_size);
00155 
00156   for (unsigned int i=0; i<_values.size(); i++)
00157     _values[i] = 0;
00158 }

unsigned int CouplingMatrix::size (  )  const [inline]

Returns:
the size of the matrix, i.e. N for an NxN matrix.

Definition at line 142 of file coupling_matrix.h.

References _size.

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

00143 {
00144   return _size;
00145 }


Member Data Documentation

unsigned int CouplingMatrix::_size [private]

The size of the matrix.

Definition at line 98 of file coupling_matrix.h.

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

std::vector<unsigned char> 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 93 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: November 25 2009 03:44:02.

Hosted By:
SourceForge.net Logo