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

LinAlg::Mat4< T > Class Template Reference

#include <LinAlg/Mat4.h>

Inheritance diagram for LinAlg::Mat4< T >:

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

Detailed Description

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

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


Public Types

typedef Mat4< T > self_type
 This type.

typedef Vec4< 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 = 4 }
 The number of dimensions.

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


Public Member Functions

 Mat4 ()
 Create an uninitialized matrix.

 Mat4 (const T v00, const T v10, const T v20, const T v30, const T v01, const T v11, const T v21, const T v31, const T v02, const T v12, const T v22, const T v32, const T v03, const T v13, const T v23, const T v33)
 Create a matrix from named values.

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

Mat4operator= (const Mat4 &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 Mat4 &lower, const Mat4 &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.

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

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

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

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

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

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

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

Mat4operator+= (const Mat4 &m)
 Add another matrix to this one.

Mat4operator-= (const Mat4 &m)
 Subtract another matrix from this one.

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

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


Static Public Member Functions

const Mat4zero ()
 Return the zero matrix.

const Mat4ident ()
 Return the identity matrix.

Mat4 inverse (const Vec4< T > &values, const Mat4 &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 [4 *4]
 The element storage.


Friends

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

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

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

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

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

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

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

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

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

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

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

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


Member Function Documentation

template<typename T>
T * LinAlg::Mat4< 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::Mat4< 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::Mat4< T >::eigs Vec4< T > &  values,
Mat4< 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.