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

LinAlg::Mat2< T > Class Template Reference

#include <LinAlg/Mat2.h>

List of all members.


Detailed Description

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

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


Public Types

typedef Mat2< T > self_type
 This type.

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

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


Public Member Functions

 Mat2 ()
 Create an uninitialized matrix.

 Mat2 (const T v00, const T v10, const T v01, const T v11)
 Create a matrix from named values.

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

Mat2operator= (const Mat2 &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 Mat2 &lower, const Mat2 &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.

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

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

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

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

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

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

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

Mat2operator+= (const Mat2 &m)
 Add another matrix to this one.

Mat2operator-= (const Mat2 &m)
 Subtract another matrix from this one.

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

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


Static Public Member Functions

const Mat2zero ()
 Return the zero matrix.

const Mat2ident ()
 Return the identity matrix.

Mat2 inverse (const Vec2< T > &values, const Mat2 &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 [2 *2]
 The element storage.


Friends

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

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

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

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

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

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

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

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

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

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

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

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


Member Function Documentation

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