Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

fl::MatrixAbstract< T > Class Template Reference

#include <matrix.h>

Inheritance diagram for fl::MatrixAbstract< T >:

fl::Matrix< T > fl::Matrix2x2< T > fl::Matrix3x3< T > fl::MatrixDiagonal< T > fl::MatrixIdentity< T > fl::MatrixPacked< T > fl::MatrixRegion< T > fl::MatrixSparse< T > fl::MatrixTranspose< T > List of all members.

Public Methods

virtual ~MatrixAbstract ()
virtual T & operator() (const int row, const int column) const=0
 Element accesss.

virtual T & operator[] (const int row) const
 Element access, treating us as a vector.

virtual int rows () const
virtual int columns () const
virtual MatrixAbstract * duplicate () const=0
 Make a new instance of self on the heap, with shallow copy semantics. Used for views. Since this is class sensitive, it must be overridden.

virtual void clear (const T scalar=(T) 0)
 Set all elements to given value.

virtual void resize (const int rows, const int columns=1)=0
 Change number of rows and columns. Does not preserve data.

virtual T frob (T n) const
 Generalized Frobenius norm: (sum_elements (element^n))^(1/n). Effectively: INFINITY is max, 1 is sum, 2 is standard Frobenius norm.

virtual T sumSquares () const
 Similar to frob(2), but without taking the square root.

virtual void normalize (const T scalar=1.0)
 View matrix as vector and adjust so frob (2) == scalar.

virtual T dot (const MatrixAbstract &B) const
 View both matrices as vectors and return dot product. Ie: returns the sum of the products of corresponding elements.

virtual Matrix< T > cross (const MatrixAbstract &B) const
 View both matrices as vectors and return cross product. (Is there a better definition that covers 2D matrices?).

virtual void identity (const T scalar=1.0)
 Set main diagonal to scalar and everything else to zero.

virtual MatrixRegion< T > row (const int r) const
 Returns a view row r. The matrix is oriented "horizontal".

virtual MatrixRegion< T > column (const int c) const
 Returns a view of column c.

virtual MatrixRegion< T > region (const int firstRow=0, const int firstColumn=0, int lastRow=-1, int lastColumn=-1) const
 Same as call to MatrixRegion<T> (*this, firstRow, firstColumn, lastRow, lastColumn).

virtual bool operator== (const MatrixAbstract &B) const
 Two matrices are equal if they have the same shape and the same elements.

bool operator!= (const MatrixAbstract &B) const
virtual Matrix< T > operator * (const MatrixAbstract &B) const
 Multiply matrices: this * B.

virtual Matrix< T > elementMultiply (const MatrixAbstract &B) const
 Elementwise multiplication. This isn't a C operator, but certainly a basic operation.

virtual Matrix< T > operator+ (const MatrixAbstract &B) const
 Elementwise sum.

virtual Matrix< T > operator- (const MatrixAbstract &B) const
 Elementwise difference.

virtual MatrixAbstract & operator *= (const MatrixAbstract &B)
 this = this * B

virtual MatrixAbstract & operator *= (const T scalar)
 this = this * scalar

virtual MatrixAbstract & operator/= (const T scalar)
 this = this / scalar

virtual MatrixAbstract & operator+= (const MatrixAbstract &B)
 Elementwise sum, stored back to this.

virtual MatrixAbstract & operator-= (const MatrixAbstract &B)
 Elementwise difference, stored back to this.

virtual MatrixAbstract & operator-= (const T scalar)
 Decrease each element by scalar.

virtual void read (std::istream &stream)
virtual void write (std::ostream &stream, bool withName=false) const

Static Public Attributes

int displayWidth = 10
 Number of character positions per cell to use when printing out matrix.

int displayPrecision = 6
 Number of significant digits to output.


Detailed Description

template<class T>
class fl::MatrixAbstract< T >

We reserve the name "Matrix" for a dense matrix, rather than for the abstract type. This makes coding a little prettier, since dense matrices are the most common case.


Constructor & Destructor Documentation

template<class T>
fl::MatrixAbstract< T >::~MatrixAbstract   [virtual]
 


Member Function Documentation

template<class T>
void fl::MatrixAbstract< T >::clear const T    scalar = (T) 0 [virtual]
 

Set all elements to given value.

Reimplemented in fl::Matrix< T >, fl::MatrixPacked< T >, fl::MatrixSparse< T >, fl::MatrixIdentity< T >, fl::MatrixDiagonal< T >, fl::MatrixTranspose< T >, fl::MatrixRegion< T >, fl::Matrix< float >, fl::Matrix< bool >, and fl::MatrixSparse< int >.

template<class T>
MatrixRegion< T > fl::MatrixAbstract< T >::column const int    c const [virtual]
 

Returns a view of column c.

template<class T>
int fl::MatrixAbstract< T >::columns   [virtual]
 

Reimplemented in fl::Matrix< T >, fl::MatrixPacked< T >, fl::MatrixSparse< T >, fl::MatrixIdentity< T >, fl::MatrixDiagonal< T >, fl::MatrixTranspose< T >, fl::MatrixRegion< T >, fl::Matrix2x2< T >, fl::Matrix3x3< T >, fl::Point, fl::Matrix< float >, fl::Matrix< bool >, fl::MatrixSparse< int >, fl::Matrix2x2< double >, and fl::Matrix2x2< float >.

template<class T>
Matrix< T > fl::MatrixAbstract< T >::cross const MatrixAbstract< T > &    B const [virtual]
 

View both matrices as vectors and return cross product. (Is there a better definition that covers 2D matrices?).

template<class T>
T fl::MatrixAbstract< T >::dot const MatrixAbstract< T > &    B const [virtual]
 

View both matrices as vectors and return dot product. Ie: returns the sum of the products of corresponding elements.

template<class T>
virtual MatrixAbstract* fl::MatrixAbstract< T >::duplicate   [pure virtual]
 

Make a new instance of self on the heap, with shallow copy semantics. Used for views. Since this is class sensitive, it must be overridden.

Implemented in fl::Matrix< T >, fl::Vector< T >, fl::MatrixPacked< T >, fl::MatrixSparse< T >, fl::MatrixIdentity< T >, fl::MatrixDiagonal< T >, fl::MatrixTranspose< T >, fl::MatrixRegion< T >, fl::Matrix2x2< T >, fl::Matrix3x3< T >, fl::Point, fl::Matrix< float >, fl::Matrix< bool >, fl::Vector< float >, fl::MatrixSparse< int >, fl::Matrix2x2< double >, and fl::Matrix2x2< float >.

template<class T>
Matrix< T > fl::MatrixAbstract< T >::elementMultiply const MatrixAbstract< T > &    B const [virtual]
 

Elementwise multiplication. This isn't a C operator, but certainly a basic operation.

template<class T>
T fl::MatrixAbstract< T >::frob   n const [virtual]
 

Generalized Frobenius norm: (sum_elements (element^n))^(1/n). Effectively: INFINITY is max, 1 is sum, 2 is standard Frobenius norm.

Reimplemented in fl::Matrix< T >, fl::MatrixSparse< T >, fl::Matrix< float >, fl::Matrix< bool >, and fl::MatrixSparse< int >.

template<class T>
void fl::MatrixAbstract< T >::identity const T    scalar = 1.0 [virtual]
 

Set main diagonal to scalar and everything else to zero.

template<class T>
void fl::MatrixAbstract< T >::normalize const T    scalar = 1.0 [virtual]
 

View matrix as vector and adjust so frob (2) == scalar.

template<class T>
Matrix< T > fl::MatrixAbstract< T >::operator * const MatrixAbstract< T > &    B const [virtual]
 

Multiply matrices: this * B.

template<class T>
MatrixAbstract< T > & fl::MatrixAbstract< T >::operator *= const T    scalar [virtual]
 

this = this * scalar

Reimplemented in fl::Matrix< T >, fl::Matrix2x2< T >, fl::Matrix< float >, fl::Matrix< bool >, fl::Matrix2x2< double >, and fl::Matrix2x2< float >.

template<class T>
MatrixAbstract< T > & fl::MatrixAbstract< T >::operator *= const MatrixAbstract< T > &    B [virtual]
 

this = this * B

template<class T>
bool fl::MatrixAbstract< T >::operator!= const MatrixAbstract< T > &    B const [inline]
 

template<class T>
virtual T& fl::MatrixAbstract< T >::operator() const int    row,
const int    column
const [pure virtual]
 

Element accesss.

Implemented in fl::Matrix< T >, fl::MatrixPacked< T >, fl::MatrixSparse< T >, fl::MatrixIdentity< T >, fl::MatrixDiagonal< T >, fl::MatrixTranspose< T >, fl::MatrixRegion< T >, fl::Matrix2x2< T >, fl::Matrix3x3< T >, fl::Point, fl::Matrix< float >, fl::Matrix< bool >, fl::MatrixSparse< int >, fl::Matrix2x2< double >, and fl::Matrix2x2< float >.

template<class T>
Matrix< T > fl::MatrixAbstract< T >::operator+ const MatrixAbstract< T > &    B const [virtual]
 

Elementwise sum.

template<class T>
MatrixAbstract< T > & fl::MatrixAbstract< T >::operator+= const MatrixAbstract< T > &    B [virtual]
 

Elementwise sum, stored back to this.

template<class T>
Matrix< T > fl::MatrixAbstract< T >::operator- const MatrixAbstract< T > &    B const [virtual]
 

Elementwise difference.

template<class T>
MatrixAbstract< T > & fl::MatrixAbstract< T >::operator-= const T    scalar [virtual]
 

Decrease each element by scalar.

Reimplemented in fl::Matrix< T >, fl::Matrix< float >, and fl::Matrix< bool >.

template<class T>
MatrixAbstract< T > & fl::MatrixAbstract< T >::operator-= const MatrixAbstract< T > &    B [virtual]
 

Elementwise difference, stored back to this.

template<class T>
MatrixAbstract< T > & fl::MatrixAbstract< T >::operator/= const T    scalar [virtual]
 

this = this / scalar

Reimplemented in fl::Matrix< T >, fl::Matrix< float >, and fl::Matrix< bool >.

template<class T>
bool fl::MatrixAbstract< T >::operator== const MatrixAbstract< T > &    B const [virtual]
 

Two matrices are equal if they have the same shape and the same elements.

template<class T>
T & fl::MatrixAbstract< T >::operator[] const int    row const [virtual]
 

Element access, treating us as a vector.

Reimplemented in fl::Matrix< T >, fl::MatrixPacked< T >, fl::MatrixDiagonal< T >, fl::MatrixTranspose< T >, fl::MatrixRegion< T >, fl::Matrix2x2< T >, fl::Matrix3x3< T >, fl::Point, fl::Matrix< float >, fl::Matrix< bool >, fl::Matrix2x2< double >, and fl::Matrix2x2< float >.

template<class T>
void fl::MatrixAbstract< T >::read std::istream &    stream [virtual]
 

Reimplemented in fl::Matrix< T >, fl::MatrixPacked< T >, fl::MatrixSparse< T >, fl::Matrix2x2< T >, fl::Matrix3x3< T >, fl::Point, fl::PointInterest, fl::PointAffine, fl::Matrix< float >, fl::Matrix< bool >, fl::MatrixSparse< int >, fl::Matrix2x2< double >, and fl::Matrix2x2< float >.

template<class T>
MatrixRegion< T > fl::MatrixAbstract< T >::region const int    firstRow = 0,
const int    firstColumn = 0,
int    lastRow = -1,
int    lastColumn = -1
const [virtual]
 

Same as call to MatrixRegion<T> (*this, firstRow, firstColumn, lastRow, lastColumn).

template<class T>
virtual void fl::MatrixAbstract< T >::resize const int    rows,
const int    columns = 1
[pure virtual]
 

Change number of rows and columns. Does not preserve data.

Implemented in fl::Matrix< T >, fl::Vector< T >, fl::MatrixPacked< T >, fl::MatrixSparse< T >, fl::MatrixIdentity< T >, fl::MatrixDiagonal< T >, fl::MatrixTranspose< T >, fl::MatrixRegion< T >, fl::Matrix2x2< T >, fl::Matrix3x3< T >, fl::Point, fl::Matrix< float >, fl::Matrix< bool >, fl::Vector< float >, fl::MatrixSparse< int >, fl::Matrix2x2< double >, and fl::Matrix2x2< float >.

template<class T>
MatrixRegion< T > fl::MatrixAbstract< T >::row const int    r const [virtual]
 

Returns a view row r. The matrix is oriented "horizontal".

template<class T>
int fl::MatrixAbstract< T >::rows   [virtual]
 

Reimplemented in fl::Matrix< T >, fl::MatrixPacked< T >, fl::MatrixSparse< T >, fl::MatrixIdentity< T >, fl::MatrixDiagonal< T >, fl::MatrixTranspose< T >, fl::MatrixRegion< T >, fl::Matrix2x2< T >, fl::Matrix3x3< T >, fl::Point, fl::Matrix< float >, fl::Matrix< bool >, fl::MatrixSparse< int >, fl::Matrix2x2< double >, and fl::Matrix2x2< float >.

template<class T>
T fl::MatrixAbstract< T >::sumSquares   [virtual]
 

Similar to frob(2), but without taking the square root.

Reimplemented in fl::Matrix< T >, fl::Matrix< float >, and fl::Matrix< bool >.

template<class T>
void fl::MatrixAbstract< T >::write std::ostream &    stream,
bool    withName = false
const [virtual]
 

Reimplemented in fl::Matrix< T >, fl::MatrixPacked< T >, fl::MatrixSparse< T >, fl::Matrix2x2< T >, fl::Matrix3x3< T >, fl::Matrix< float >, fl::Matrix< bool >, fl::MatrixSparse< int >, fl::Matrix2x2< double >, and fl::Matrix2x2< float >.


Member Data Documentation

template<class T>
int fl::MatrixAbstract< T >::displayPrecision = 6 [static]
 

Number of significant digits to output.

template<class T>
int MatrixAbstract::displayWidth = 10 [static]
 

Number of character positions per cell to use when printing out matrix.


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 17:13:25 2004 for fl by doxygen1.2.18