Matrix Class Reference

Simple matrix class. More...

#include <matrix.h>

List of all members.

Public Member Functions

double & val (unsigned int row, unsigned int col)
 the value of a cell of the matrix
const double & val (unsigned int row, unsigned int col) const
 read-only access to the values of a matrix cell
unsigned int dim () const
 get the dimension of the matrix
void changeDimension (const unsigned int dimension)
 Reset matrix to new dimension.
void add (const Matrix *m)
 Adds the matrix to the current matrix.
void subtract (const Matrix *m)
 Subtracts a matrix from the current matrix.
auto_array< double > band (int &n, int &nsdiag) const
 Returns the matrix in bandfrom which is needed for arpack++.
int split (Matrix &a, Matrix &b, std::vector< unsigned int > &indexMap, std::list< unsigned int > &indices) const
 Splits the matrix into two new matrices.
Matrixinject (const Matrix &m, unsigned int index)
 Injects a small matrix into a larger one at an arbitrary position.
void transform (double *vec) const
 Transforms a vector.
void diag (const double *diag, unsigned int dim)
 Resets the matrix to have diag with dimension dim on its diagonal.
Matrixoperator= (double val)
 Sets all elements in the matrix to the given value val.
Matrixoperator+= (const Matrix &operand)
 Convience function for add().
Matrixoperator-= (const Matrix &operand)
 Convience function for subtract().
 Matrix (unsigned int dimension=0)
 Creates an empty matrix with the given dimension.
 Matrix (const double *diag, unsigned int dim)
 Create a new diagonal matrix.
 Matrix (const Matrix &clone)
 Matrix copy constructor.
virtual ~Matrix ()
 Matrix destructor.
virtual Matrixoperator= (const Matrix &clone)
 Matrix assignment operator.

Protected Attributes

double ** value_
unsigned int dimension_


Detailed Description

Simple matrix class.

Matrix is a simple quadratic matrix class containing all operations needed by the ncut library.


Constructor & Destructor Documentation

Matrix::Matrix unsigned int  dimension = 0  ) 
 

Creates an empty matrix with the given dimension.

Parameters:
dimension The dimension for the new matrix (default=0).

Matrix::Matrix const double *  diag,
unsigned int  dim
 

Create a new diagonal matrix.

Parameters:
diag The vector that will be on the matrix's diagonal.
dim The dimension for the new matrix (default=0).
Creates a matrix of dimension dim with diag on its diagonal

Matrix::Matrix const Matrix clone  ) 
 

Matrix copy constructor.

Parameters:
clone The matrix to be cloned.


Member Function Documentation

void Matrix::add const Matrix m  ) 
 

Adds the matrix to the current matrix.

Parameters:
m The matrix which should be added.

auto_array< double > Matrix::band int &  n,
int &  nsdiag
const
 

Returns the matrix in bandfrom which is needed for arpack++.

Parameters:
n The dimension of the matrix will be written into this variable.
nsdiag The number of the non-zero diagonals will be written into this variable.
Returns:
An array of doubles (which is needed for aprack++).

void Matrix::changeDimension const unsigned int  dimension  ) 
 

Reset matrix to new dimension.

Parameters:
dimension The new dimension of the matrix.
Changes the dimension, deletes the old matrix and creates a new one with the given dimension

void Matrix::diag const double *  diag,
unsigned int  dim
 

Resets the matrix to have diag with dimension dim on its diagonal.

Parameters:
diag The new diagonal vector of this matrix.
dim The new dimension of this matrix.

unsigned int Matrix::dim  )  const [inline]
 

get the dimension of the matrix

Returns:
the dimension of the matrix

Matrix & Matrix::inject const Matrix m,
unsigned int  index
 

Injects a small matrix into a larger one at an arbitrary position.

Parameters:
m The Matrix to be injected.
index The position where m should be injected.
Returns:
This object.
Matrix m is copied into this Matrix starting at position (index , index ). m does not have to fit inside this matrix, but if it doesn't, only the values of m that do fit are copied. All values in this matrix remain unchanged except the ones overwritten by m.

Matrix & Matrix::operator+= const Matrix operand  ) 
 

Convience function for add().

Parameters:
operand he matrix to be added.
Returns:
This object.

Matrix & Matrix::operator-= const Matrix operand  ) 
 

Convience function for subtract().

Parameters:
operand The matrix to be subtracted.
Returns:
This object.

Matrix & Matrix::operator= const Matrix clone  )  [virtual]
 

Matrix assignment operator.

Parameters:
clone The matrix to be cloned.
Returns:
This object.

Matrix & Matrix::operator= double  val  ) 
 

Sets all elements in the matrix to the given value val.

Parameters:
val All elements of the matrix will be set to this value.
Returns:
This matrix.

int Matrix::split Matrix a,
Matrix b,
std::vector< unsigned int > &  indexMap,
std::list< unsigned int > &  indices
const
 

Splits the matrix into two new matrices.

Parameters:
a One part will be written into this matrix.
b The second part will be written into this matrix.
indexMap A mapping of index numbers in the old matrix to the associated index in one of the new matrices.
indices The list of indices in matrix a.
Returns:
0 if there was no error

void Matrix::subtract const Matrix m  ) 
 

Subtracts a matrix from the current matrix.

Parameters:
m The matrix which should be subtracted.

void Matrix::transform double *  vec  )  const
 

Transforms a vector.

Parameters:
vec The vector to be transformed.
The vector vec is multiplied from the left with this matrix. The size of the vec array has to match the dimension of this matrix, otherwise the result is undefined.

const double& Matrix::val unsigned int  row,
unsigned int  col
const [inline]
 

read-only access to the values of a matrix cell

Parameters:
row the row
col the column
Returns:
constant value of the specified cell

double& Matrix::val unsigned int  row,
unsigned int  col
[inline]
 

the value of a cell of the matrix

Parameters:
row the row
col the column
Returns:
the value of the specified cell


Member Data Documentation

unsigned int Matrix::dimension_ [protected]
 

The dimension of the matrix

double** Matrix::value_ [protected]
 

All elements in the matrix


The documentation for this class was generated from the following files:
Generated on Thu Jun 22 14:47:20 2006 for ncut.kdevelop by  doxygen 1.4.6