Documentation


animal::Matrix< T > Struct Template Reference

#include <matrix.h>

List of all members.


Detailed Description

template<class T>
struct animal::Matrix< T >

Dense 2d array stored as a dense 1d array.

Size is given to the constructor and can not be modified. In debug mode,range checking is performed on row indices. No range checking is performed on column indices.

Linear algebra operations defined in linear.h (see linear.readme) can be applied.

Examples:

matrix_test.cpp.

Definition at line 35 of file matrix.h.

Public Member Functions

 Matrix (int nrow=0, int ncol=0)
 Constructor using number of rows and columns.

void resize (int r, int c)
 Resize to r rows and c columns. Data is lost.

void fill (const T &v)
 Assign all entries to v.

void setIdentity ()
 Assign to identity. Undefined result if the matrix is not square. Checked by an assert unless -NDEBUG is use as a compile flag.

T * operator[] (int r)
 Access row.

const T * operator[] (int r) const
 Access row read-only.

int nrows () const
 Number of rows.

int ncols () const
 Number of columns.


Private Attributes

std::vector< T > value
 the values

int nr
 number of rows

int nc
 number of cols


Friends

template<class U> friend::std::ostream & operator<< (::std::ostream &out, const Matrix< U > &m)
 Output operator.

template<class U> friend::std::istream & operator>> (::std::istream &in, animal::Matrix< U > &m)
 Input operator.


Constructor & Destructor Documentation

template<class T>
animal::Matrix< T >::Matrix int  nrow = 0,
int  ncol = 0
[inline]
 

Constructor using number of rows and columns.

Definition at line 39 of file matrix.h.

References animal::Matrix< T >::nc, animal::Matrix< T >::nr, and animal::Matrix< T >::value.


Member Function Documentation

template<class T>
void animal::Matrix< T >::fill const T &  v  )  [inline]
 

Assign all entries to v.

Definition at line 55 of file matrix.h.

References animal::Matrix< T >::value.

Referenced by animal::Matrix< T >::setIdentity().

template<class T>
int animal::Matrix< T >::ncols  )  const [inline]
 

Number of columns.

Definition at line 87 of file matrix.h.

References animal::Matrix< T >::nc.

Referenced by animal::octree::getMatrixInverse(), animal::ncols(), and animal::Matrix< T >::setIdentity().

template<class T>
int animal::Matrix< T >::nrows  )  const [inline]
 

Number of rows.

Definition at line 84 of file matrix.h.

References animal::Matrix< T >::nr.

Referenced by animal::octree::getMatrixInverse(), animal::nrows(), and animal::Matrix< T >::setIdentity().

template<class T>
const T* animal::Matrix< T >::operator[] int  r  )  const [inline]
 

Access row read-only.

Definition at line 77 of file matrix.h.

References animal::Matrix< T >::nc, animal::Matrix< T >::nr, and animal::Matrix< T >::value.

template<class T>
T* animal::Matrix< T >::operator[] int  r  )  [inline]
 

Access row.

Definition at line 70 of file matrix.h.

References animal::Matrix< T >::nc, animal::Matrix< T >::nr, and animal::Matrix< T >::value.

template<class T>
void animal::Matrix< T >::resize int  r,
int  c
[inline]
 

Resize to r rows and c columns. Data is lost.

Definition at line 48 of file matrix.h.

References animal::Matrix< T >::nc, animal::Matrix< T >::nr, and animal::Matrix< T >::value.

Referenced by animal::octree::Frame::Frame().

template<class T>
void animal::Matrix< T >::setIdentity  )  [inline]
 

Assign to identity. Undefined result if the matrix is not square. Checked by an assert unless -NDEBUG is use as a compile flag.

Definition at line 62 of file matrix.h.

References animal::Matrix< T >::fill(), animal::Matrix< T >::ncols(), animal::Matrix< T >::nr, and animal::Matrix< T >::nrows().


Friends And Related Function Documentation

template<class T>
template<class U>
::std::ostream& operator<< ::std::ostream &  out,
const Matrix< U > &  m
[friend]
 

Output operator.

Definition at line 91 of file matrix.h.

template<class T>
template<class U>
::std::istream& operator>> ::std::istream &  in,
animal::Matrix< U > &  m
[friend]
 

Input operator.

Definition at line 102 of file matrix.h.


Member Data Documentation

template<class T>
int animal::Matrix< T >::nc [private]
 

number of cols

Definition at line 114 of file matrix.h.

Referenced by animal::Matrix< T >::Matrix(), animal::Matrix< T >::ncols(), animal::Matrix< T >::operator[](), and animal::Matrix< T >::resize().

template<class T>
int animal::Matrix< T >::nr [private]
 

number of rows

Definition at line 113 of file matrix.h.

Referenced by animal::Matrix< T >::Matrix(), animal::Matrix< T >::nrows(), animal::Matrix< T >::operator[](), animal::Matrix< T >::resize(), and animal::Matrix< T >::setIdentity().

template<class T>
std::vector<T> animal::Matrix< T >::value [private]
 

the values

Definition at line 112 of file matrix.h.

Referenced by animal::Matrix< T >::fill(), animal::Matrix< T >::Matrix(), animal::Matrix< T >::operator[](), and animal::Matrix< T >::resize().


The documentation for this struct was generated from the following file:
Generated on Thu Dec 23 13:52:30 2004 by doxygen 1.3.6