libgenua
Basic Geometry, Numerical Algorithms and Interfaces
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
SMatrix< N, M, Type > Class Template Reference

Detailed Description

template<uint N, uint M, class Type = Real>
class SMatrix< N, M, Type >

Fixed size matrix.

Matrix template for applications where the dimensions are known at compile time, e.g.

  SMatrix<3,2,float>  m1;
  SMatrix<4,4,double>  m2;

The first template argument is the number of rows. Default initialization sets all values to zero.

GCC > 3.3 will unroll most operations on SMatrix if you specify the compiler option -funroll-loops. Note that most operations on SMatrix and SVector have value copy semantics. Since GCC performs named return value optimization, it will eliminate many of the temporaries, but it also means that SMatrix is not a good choice for large dimensions (say, M,N > 20).

#include <smatrix.h>

Public Types

typedef Eigen::Matrix< Type,
int(N), int(M)> 
EigenMatrix
 for interfacing with the Eigen library
 

Public Member Functions

 SMatrix ()
 create zero matrix
 
 SMatrix (const Type &init)
 initialized constructor
 
 SMatrix (const Type *v)
 initialized constructor from column-major data
 
template<typename OtherFloat >
 SMatrix (const SMatrix< N, M, OtherFloat > &src)
 copy construction
 
template<typename ConvertibleType >
 SMatrix (const SVector< N, ConvertibleType > &c0, const SVector< N, ConvertibleType > &c1)
 set the first two columns
 
template<typename ConvertibleType >
 SMatrix (const SVector< N, ConvertibleType > &c0, const SVector< N, ConvertibleType > &c1, const SVector< N, ConvertibleType > &c2)
 set the first three columns
 
SMatrix< N, M, Type > & operator= (const SMatrix< N, M, Type > &src)
 assignment to another matrix
 
SMatrix< N, M, Type > & operator= (const Type &x)
 assign a scalar to all values
 
bool operator== (const SMatrix< N, M, Type > &rhs) const
 element comparison
 
bool operator!= (const SMatrix< N, M, Type > &rhs) const
 element comparison
 
Type * pointer ()
 data pointer
 
const Type * pointer () const
 data pointer
 
Type * colpointer (uint j)
 column pointer
 
const Type * colpointer (uint j) const
 column pointer
 
void assign (const Type *ptr)
 assign from pointer
 
uint ldim () const
 leading dimensions
 
reference operator[] (uint i)
 mutable linear access
 
const_reference operator[] (uint i) const
 const linear access, returns object
 
reference operator() (uint i)
 mutable linear access
 
const_reference operator() (uint i) const
 const linear access, returns object
 
reference operator() (uint r, uint c)
 mutable 2D access
 
const_reference operator() (uint r, uint c) const
 const 2D access
 
uint nrows () const
 row count
 
uint ncols () const
 column count
 
uint size () const
 total size
 
iterator begin ()
 mutable start pointer
 
const_iterator begin () const
 const start pointer
 
iterator end ()
 one-past-end pointer
 
const_iterator end () const
 one-past-end pointer
 
void assignColumn (size_t jcol, const SVector< N, Type > &c)
 convenience shortcut to make numerical method code more expressive
 
void assignRow (size_t irow, const SVector< M, Type > &c)
 convenience shortcut (stride-N access!)
 
SVector< N, Type > column (size_t jcol) const
 convenience shortcut
 
SVector< M, Type > row (size_t irow) const
 convenience shortcut
 
SMatrix< N, M, Type > operator- () const
 sign inversion
 
SMatrix< M, N, Type > transposed () const
 return transposed copy
 
SVector< N, Type > trans_mult (const SVector< M, Type > &a) const
 transpose multiplication
 
EigenMap mmap ()
 create a mutable map object for interfacing with Eigen
 
ConstEigenMap cmap () const
 create a mutable map object for interfacing with Eigen
 
void clear ()
 fill with zeros
 

Static Public Member Functions

static SMatrix< N, M, Type > identity ()
 create identity matrix
 

Private Attributes

Type data [M *N]
 static array
 

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