regina::NMatrixRing< T > Class Template Reference
[Mathematical Support]

Represents a matrix of elements from a given ring T. More...

#include <nmatrix.h>

Inheritance diagram for regina::NMatrixRing< T >:
regina::NMatrix< T >

List of all members.

Public Member Functions

 NMatrixRing (unsigned long rows, unsigned long cols)
 Creates a new matrix of the given size.
 NMatrixRing (const NMatrix< T > &cloneMe)
 Creates a new matrix that is a clone of the given matrix.
void makeIdentity ()
 Turns this matrix into an identity matrix.
bool isIdentity () const
 Determines whether this matrix is a square identity matrix.
void addRow (unsigned long source, unsigned long dest)
 Adds the given source row to the given destination row.
void addRow (unsigned long source, unsigned long dest, T copies)
 Adds the given number of copies of the given source row to the given destination row.
void addCol (unsigned long source, unsigned long dest)
 Adds the given source column to the given destination column.
void addCol (unsigned long source, unsigned long dest, T copies)
 Adds the given number of copies of the given source column to the given destination column.
void multRow (unsigned long row, T factor)
 Multiplies the given row by the given factor.
void multCol (unsigned long column, T factor)
 Multiplies the given column by the given factor.
std::auto_ptr< NMatrixRing< T > > operator* (const NMatrixRing< T > &other) const
 Multiplies this by the given matrix, and returns the result.
template<class MatrixClass >
std::auto_ptr< MatrixClass > multiplyAs (const NMatrixRing< T > &other) const
 Multiplies this by the given matrix, and returns a new matrix of subclass MatrixClass.
det () const
 Evaluates the determinant of the matrix.

Static Public Attributes

static T zero
 Zero in the underlying ring.
static T one
 One (the multiplicative identity) in the underlying ring.

Detailed Description

template<class T>
class regina::NMatrixRing< T >

Represents a matrix of elements from a given ring T.

Precondition:
Type T has a default constructor and overloads the assignment (=) operator.
An element t of type T can be written to an output stream out using the standard expression out << t.
Type T provides binary operators +, - and * and unary operators +=, -= and *=.
Type T has a long integer constructor. That is, if a is of type T, then a can be initialised to a long integer l using a(l). Here the value 1 refers to the multiplicative identity in the ring T.
Python:
Not present, although the subclass NMatrixInt is.

Constructor & Destructor Documentation

template<class T>
regina::NMatrixRing< T >::NMatrixRing ( unsigned long  rows,
unsigned long  cols 
) [inline]

Creates a new matrix of the given size.

All entries will be initialised using their default constructors.

Precondition:
The given number of rows and columns are both strictly positive.
Parameters:
rows the number of rows in the new matrix.
cols the number of columns in the new matrix.
template<class T>
regina::NMatrixRing< T >::NMatrixRing ( const NMatrix< T > &  cloneMe  )  [inline]

Creates a new matrix that is a clone of the given matrix.

Parameters:
cloneMe the matrix to clone.

Member Function Documentation

template<class T>
void regina::NMatrixRing< T >::addCol ( unsigned long  source,
unsigned long  dest,
copies 
) [inline]

Adds the given number of copies of the given source column to the given destination column.

Note that copies is passed by value in case it is an element of the row to be changed.

Precondition:
The two given columns are distinct and between 0 and columns()-1 inclusive.
Parameters:
source the columns to add.
dest the column that will be added to.
copies the number of copies of source to add to dest.
template<class T>
void regina::NMatrixRing< T >::addCol ( unsigned long  source,
unsigned long  dest 
) [inline]

Adds the given source column to the given destination column.

Precondition:
The two given columns are distinct and between 0 and columns()-1 inclusive.
Parameters:
source the columns to add.
dest the column that will be added to.
template<class T>
void regina::NMatrixRing< T >::addRow ( unsigned long  source,
unsigned long  dest,
copies 
) [inline]

Adds the given number of copies of the given source row to the given destination row.

Note that copies is passed by value in case it is an element of the row to be changed.

Precondition:
The two given rows are distinct and between 0 and rows()-1 inclusive.
Parameters:
source the row to add.
dest the row that will be added to.
copies the number of copies of source to add to dest.
template<class T>
void regina::NMatrixRing< T >::addRow ( unsigned long  source,
unsigned long  dest 
) [inline]

Adds the given source row to the given destination row.

Precondition:
The two given rows are distinct and between 0 and rows()-1 inclusive.
Parameters:
source the row to add.
dest the row that will be added to.
template<class T>
T regina::NMatrixRing< T >::det (  )  const [inline]

Evaluates the determinant of the matrix.

This algorithm has quartic complexity, and uses the dynamic programming approach of Mahajan and Vinay. For further details, see Meena Mahajan and V. Vinay, "Determinant: Combinatorics, algorithms, and complexity", Chicago J. Theor. Comput. Sci., Vol. 1997, Article 5.

Precondition:
This is a square matrix.
Returns:
the determinant of this matrix.
template<class T>
bool regina::NMatrixRing< T >::isIdentity (  )  const [inline]

Determines whether this matrix is a square identity matrix.

If this matrix is square, isIdentity() will return true if and only if the matrix has ones in the main diagonal and zeroes everywhere else.

If this matrix is not square, isIdentity() will always return false (even if makeIdentity() was called earlier).

Returns:
true if and only if this is a square identity matrix.
template<class T>
void regina::NMatrixRing< T >::makeIdentity (  )  [inline]

Turns this matrix into an identity matrix.

This matrix need not be square; after this routine it will have entry(r,c) equal to one if r == c and zero otherwise.

template<class T>
void regina::NMatrixRing< T >::multCol ( unsigned long  column,
factor 
) [inline]

Multiplies the given column by the given factor.

Note that factor is passed by value in case it is an element of the row to be changed.

Precondition:
The given column is between 0 and columns()-1 inclusive.
Parameters:
column the column to work with.
factor the factor by which to multiply the given column.
template<class T>
template<class MatrixClass >
std::auto_ptr<MatrixClass> regina::NMatrixRing< T >::multiplyAs ( const NMatrixRing< T > &  other  )  const [inline]

Multiplies this by the given matrix, and returns a new matrix of subclass MatrixClass.

This matrix is not changed.

Precondition:
The number of columns in this matrix equals the number of rows in the given matrix.
The class MatrixClass is a subclass of NMatrixRing<T>, and can be fully initialised by calling the two-argument constructor (passing the row and column counts) and then settng individual elements via data[r][c]. In particular, there should not be any new data members that need explicit initialisation.
Python:
Not present, but the python multiplication operator performs the same task (see the python notes for operator *).
Parameters:
other the matrix by which to multiply this matrix.
Returns:
a newly allocated matrix representing this * other.
template<class T>
void regina::NMatrixRing< T >::multRow ( unsigned long  row,
factor 
) [inline]

Multiplies the given row by the given factor.

Note that factor is passed by value in case it is an element of the row to be changed.

Precondition:
The given row is between 0 and rows()-1 inclusive.
Parameters:
row the row to work with.
factor the factor by which to multiply the given row.
template<class T>
std::auto_ptr<NMatrixRing<T> > regina::NMatrixRing< T >::operator* ( const NMatrixRing< T > &  other  )  const [inline]

Multiplies this by the given matrix, and returns the result.

This matrix is not changed.

Precondition:
The number of columns in this matrix equals the number of rows in the given matrix.
Warning:
The returned matrix will be of the exact class NMatrixRing<T>, even if both this and other are of some common subclass of NMatrixRing<T>. If you need a subclass to be returned, consider calling multiplyAs() instead.
Python:
The multiplication operator for a subclass (such as NMatrixInt) will return a new matrix of that same subclass. That is, the python multiplication operator really calls multiplyAs(), not this routine.
Parameters:
other the matrix by which to multiply this matrix.
Returns:
a newly allocated matrix representing this * other.

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

Copyright © 1999-2009, Ben Burton
This software is released under the GNU General Public License.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).