Main Page | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

LinAlg::Mat3< T > Class Template Reference

#include <LinAlg/Mat3.h>

Inheritance diagram for LinAlg::Mat3< T >:

LinAlg::Transform2< T > List of all members.

Detailed Description

template<typename T>
class LinAlg::Mat3< T >

A linear algebra matrix class of fixed type and size 3.


Public Types

typedef Mat3< T > self_type
 This type.

typedef Vec3< T > vec_type
 The vector type of the same dimension.

typedef T value_type
 The underlying data type.

typedef T * iterator
 An iterator.

typedef const T * const_iterator
 A constant iterator.

enum  { num_dims = 3 }
 The number of dimensions.

enum  { num_elements = 3 * 3 }
 The number of elements.


Public Member Functions

 Mat3 ()
 Create an uninitialized matrix.

 Mat3 (const T v00, const T v10, const T v20, const T v01, const T v11, const T v21, const T v02, const T v12, const T v22)
 Create a matrix from named values.

template<typename Other>  Mat3 (const Mat3< Other > &m)
 Copy another matrix of possibly a different type.

Mat3operator= (const Mat3 &m)
 Assign another matrix to this matrix.

const T & operator() (const unsigned i, const unsigned j) const
 Read-only element access.

T & operator() (const unsigned i, const unsigned j)
 Read-write element access.

const T * data () const
 Direct read-only access to the underlying m_data.

T * data ()
 Direct read-write access to the underlying m_data.

const_iterator begin () const
 Get a read-only iterator to the first element.

iterator begin ()
 Get a read-write pointer to the first element.

const_iterator end () const
 Get a read-only iterator to past the last element.

iterator end ()
 Get a read-write iterator to past the last element.

unsigned size1 () const
 The number of rows.

unsigned size2 () const
 The number of columns.

void limit (const std::pair< T, T > &l)
 Limit each element to the range [l.first, l.second].

void limit (const T lower, const T upper)
 Limit each element to the range [lower, upper].

void limit (const Mat3 &lower, const Mat3 &upper)
 Limit element (i,j) to the range [lower(i,j), upper(i,j)].

sum () const
 Return the sum of all the elements.

prod () const
 Return the product of all the elements.

Mat3 trans () const
 Return the transpose of this matrix.

Vec3< T > getCol (const unsigned i) const
 Get the i'th column of the matrix.

void setCol (const unsigned i, const Vec3< T > &v)
 Set the i'th column of the matrix.

Vec3< T > getRow (const unsigned i) const
 Get the i'th row of the matrix.

void setRow (const unsigned i, const Vec3< T > &v)
 Set the i'th row of the matrix.

void eigs (Vec3< T > &values, Mat3 &vectors) const
 Compute the eigenvalues and eigenvectors.

bool equal (const Mat3< T > &v, const T eps) const
 Compare entries with another matrix, within eps.

Mat3operator+= (const Mat3 &m)
 Add another matrix to this one.

Mat3operator-= (const Mat3 &m)
 Subtract another matrix from this one.

template<typename Scalar> Mat3operator *= (const Scalar d)
 Multiply this matrix by a scalar value.

template<typename Scalar> Mat3operator/= (const Scalar d)
 Divided this matrix by a scalar value.


Static Public Member Functions

const Mat3zero ()
 Return the zero matrix.

const Mat3ident ()
 Return the identity matrix.

Mat3 inverse (const Vec3< T > &values, const Mat3 &vectors)
 Calculate the inverse of a matrix from its eigenvalues and eigenvectors.

std::string description ()
 Return a description like "2D float", useful for debugging and messages.


Protected Attributes

m_data [3 *3]
 The element storage.


Friends

Mat3 operator- (const Mat3 &u)
 Return the negation of a matrix.

Mat3 operator+ (const Mat3 &u, const Mat3 &v)
 Add two matrices together.

Mat3 operator- (const Mat3 &u, const Mat3 &v)
 Subtract two matrices.

Mat3 operator * (const Mat3 &u, const Mat3 &v)
 Multiply two matrices.

Mat3< T > operator * (const Mat3< T > &u, const T s)
 Right-multiply a matrix by a scalar.

Mat3< T > operator * (const T s, const Mat3< T > &u)
 Left-multiply a matrix by a scalar.

Mat3< T > operator/ (const Mat3< T > &u, const T s)
 Divide a matrix by a scalar.

Vec3< T > operator * (const Mat3 &m, const Vec3< T > &v)
 Multiply a vector by a matrix.

bool operator== (const Mat3 &u, const Mat3 &v)
 Exact equality -- use with caution on floating-point base types.

bool operator!= (const Mat3 &u, const Mat3 &v)
 Exact inequality -- use with caution on floating-point base types.

Mat3 min (const Mat3 &u, const Mat3 &v)
 Per-element minimum.

Mat3 max (const Mat3 &u, const Mat3 &v)
 Per-element maximum.


Member Function Documentation

template<typename T>
T * LinAlg::Mat3< T >::data  )  [inline]
 

Direct read-write access to the underlying m_data.

The elements are stored densely in column-major order.

template<typename T>
const T * LinAlg::Mat3< T >::data  )  const [inline]
 

Direct read-only access to the underlying m_data.

The elements are stored densely in column-major order.

template<typename T>
void LinAlg::Mat3< T >::eigs Vec3< T > &  values,
Mat3< T > &  vectors
const
 

Compute the eigenvalues and eigenvectors.

The eigenvectors are stored as the columns of vectors.


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

© 2005-2008 Adrian Secord.