mat3 Class Template Reference

Matrix class (3x3). More...

#include <mat3.h>

Inheritance diagram for mat3:

List of all members.

Public Types

typedef af::tiny_plain
< NumType, 9 > 
base_type

Public Member Functions

 mat3 ()
 Default constructor. Elements are not initialized.
 mat3 (NumType const &e00, NumType const &e01, NumType const &e02, NumType const &e10, NumType const &e11, NumType const &e12, NumType const &e20, NumType const &e21, NumType const &e22)
 Constructor.
 mat3 (base_type const &a)
 Constructor.
 mat3 (const NumType *a)
 Constructor.
 mat3 (NumType const &diag)
 Constructor for diagonal matrix.
 mat3 (NumType const &diag0, NumType const &diag1, NumType const &diag2)
 Constructor for diagonal matrix.
 mat3 (af::tiny_plain< NumType, 3 > const &diag)
 Constructor for diagonal matrix.
 mat3 (sym_mat3< NumType > const &m)
 Construction from symmetric matrix.
NumType const & operator() (std::size_t r, std::size_t c) const
 Access elements with 2-dimensional indices.
NumType & operator() (std::size_t r, std::size_t c)
 Access elements with 2-dimensional indices.
vec3< NumType > get_row (std::size_t i) const
 Return a row.
void set_row (std::size_t i, af::tiny_plain< NumType, 3 > const &v)
 Set a row.
void swap_rows (std::size_t i1, std::size_t i2)
 Swap two rows in place.
vec3< NumType > get_column (std::size_t i) const
 Return a column.
void set_column (std::size_t i, af::tiny_plain< NumType, 3 > const &v)
 Set a column.
void swap_columns (std::size_t i1, std::size_t i2)
 Swap two columns in place.
vec3< NumType > diagonal () const
 Return diagonal elements.
mat3 transpose () const
 Return the transposed matrix.
NumType trace () const
 Return trace (sum of diagonal elements).
NumType determinant () const
 Return determinant.
NumType max_abs () const
 Maximum of the absolute values of the elements of this matrix.
bool is_symmetric () const
 Test for symmetric matrix.
bool is_symmetric (NumType const &relative_tolerance) const
 Test for symmetric matrix.
mat3 co_factor_matrix_transposed () const
 Return the transposed of the co-factor matrix.
mat3 inverse () const
 Return the inverse matrix.
mat3 error_minimizing_inverse (std::size_t iterations) const
 Returns the inverse matrix, after minimizing the error numerically.
mat3scale (af::tiny_plain< NumType, 3 > const &v)
 Scale matrix in place.
mat3 ortho () const
 Return a matrix with orthogonal base vectors.
std::pair< mat3, vec3< NumType > > decompose () const
 Decomposes the matrix into a rotation and scaling part.
sym_mat3< NumType > self_times_self_transpose () const
 (*this) * this->transpose().
sym_mat3< NumType > self_transpose_times_self () const
 this->transpose() * (*this).
NumType dot (mat3 const &other) const
 Sum of element-wise products.

Static Public Member Functions

static mat3 cross_product_matrix (vec3< NumType > const &v)
 Matrix associated with vector cross product.


Detailed Description

template<typename NumType>
class scitbx::mat3< NumType >

Matrix class (3x3).

This class represents a 3x3 matrix that can be used to store linear transformations.

Enhanced version of the python mat3 class by Matthias Baas (baas@ira.uka.de). See http://cgkit.sourceforge.net/ for more information.


Member Function Documentation

bool is_symmetric (  )  const [inline]

Test for symmetric matrix.

Returns false if the absolute value of the difference between any pair of off-diagonal elements is different from zero.

Referenced by sym_mat3< scitbx::sym_mat3< double > >::sym_mat3().

bool is_symmetric ( NumType const &  relative_tolerance  )  const [inline]

Test for symmetric matrix.

Returns false if the absolute value of the difference between any pair of off-diagonal elements is larger than max_abs()*relative_tolerance.

mat3 co_factor_matrix_transposed (  )  const [inline]

Return the transposed of the co-factor matrix.

The inverse matrix is obtained by dividing the result by the determinant().

Referenced by mat3< scitbx::sym_mat3< double > >::inverse(), and float_asu::volume_vertices().

mat3 inverse (  )  const [inline]

Return the inverse matrix.

An exception is thrown if the matrix is not invertible, i.e. if the determinant() is zero.

Referenced by mat3< scitbx::sym_mat3< double > >::error_minimizing_inverse().

mat3 error_minimizing_inverse ( std::size_t  iterations  )  const [inline]

Returns the inverse matrix, after minimizing the error numerically.

Here's the theory: M*M^-1 = I-E, where E is the error M*M^-1*(I+E) = (I-E)*(I+E) M*(M^-1*(I+E)) = I^2-E^2 M*(M^-1*(I+E)) = I-E^2 let M^-1*(I+E) = M1 let E^2 = E2 M*M1*(I+E2) = (I-E2)*(I+E2) M*M2 = I-E4 M*Mi = I-E2^i Supposedly this will drive the error pretty low after only a few repetitions. The error rate should be ~E^(2^iterations), which I think is pretty good. This assumes that E is "<< 1", whatever that means. Attributed to Judah I. Rosenblatt.

2*I - (I-E) ==> 2*I - I + E = I + E

mat3& scale ( af::tiny_plain< NumType, 3 > const &  v  )  [inline]

Scale matrix in place.

Each row of this is multiplied element-wise with v.

static mat3 cross_product_matrix ( vec3< NumType > const &  v  )  [inline, static]

Matrix associated with vector cross product.

a.cross(b) is equivalent to cross_product_matrix(a) * b. Useful for simplification of equations. Used frequently in robotics and classical mechanics literature.


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

Generated on Tue Sep 1 17:12:35 2009 for cctbx by  doxygen 1.5.6