mathglpp::Matrix2< T > Class Template Reference

#include <Matrix.h>

Collaboration diagram for mathglpp::Matrix2< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<typename T>
class mathglpp::Matrix2< T >

Row-major 2D matrix class, useful for image manipulation and vertex framing.

Definition at line 35 of file Matrix.h.

Public Types

typedef size_t dim_type
 Use size_t to conform with STL.
typedef T value_type
typedef std::valarray< value_typevector_type
typedef std::slice_array<
value_type
sliced_vector_type

Public Member Functions

 Matrix2 (const dim_type &m, const dim_type &n)
 Create a square Matrix.
 Matrix2 (const Matrix2 &mat)
 Copy constructor.
 ~Matrix2 ()
 Default destructor.
Matrix2operator= (const Matrix2 &rhs)
 Default assignment.
Matrix2identity ()
Matrix2 filter (T(*filter_func)(const Matrix2 &, const dim_type, const dim_type))
value_typeoperator() (const dim_type i, const dim_type j)
 Fortran style element access.
const value_typeoperator() (const dim_type i, const dim_type j) const
 Fortran style element access.
value_typeoperator[] (const dim_type ind)
 C/C++ style element access.
const value_typeoperator[] (const dim_type ind) const
 C/C++ style element access.
const sliced_vector_typeoperator[] (const std::slice &sl)
 C/C++ style element slice access.
const sliced_vector_typerow (dim_type rn, dim_type cstart=0)
const sliced_vector_typerow (dim_type rn, dim_type cstart, dim_type cend)
const sliced_vector_typecol (dim_type cn, dim_type rstart=0)
const sliced_vector_typecol (dim_type cn, dim_type rstart, dim_type rend)
const std::slice row_slice (dim_type rn, dim_type cstart=0) const
 Row slice.
const std::slice row_slice (dim_type rn, dim_type cstart, dim_type cend) const
 Row slice, bounded.
const std::slice col_slice (dim_type cn, dim_type rstart=0) const
 Column slice.
const std::slice col_slice (dim_type cn, dim_type rstart, dim_type rend) const
 Column slice, bounded.
const dim_typegetM () const
 Get the dimensions.
const dim_typegetN () const
const dim_typesize () const
 operator vector_type & ()
 Return the vector.
 operator const vector_type & () const
 operator const value_type * () const

Protected Attributes

dim_type rows
 dimensions
dim_type cols
vector_type vec
 The actual row major vector of values.


Member Typedef Documentation

template<typename T>
typedef size_t mathglpp::Matrix2< T >::dim_type

Use size_t to conform with STL.

Definition at line 40 of file Matrix.h.


Constructor & Destructor Documentation

template<typename T>
mathglpp::Matrix2< T >::Matrix2 ( const dim_type m,
const dim_type n 
) [inline]

Create a square Matrix.

Definition at line 46 of file Matrix.h.

00047     :rows(m),cols(n),vec(m*n)
00048     { }

template<typename T>
mathglpp::Matrix2< T >::Matrix2 ( const Matrix2< T > &  mat  )  [inline]

Copy constructor.

Definition at line 51 of file Matrix.h.

00052     :rows(mat.rows),cols(mat.cols),vec(mat.vec)
00053     { }

template<typename T>
mathglpp::Matrix2< T >::~Matrix2 (  )  [inline]

Default destructor.

Definition at line 56 of file Matrix.h.

00057     { }


Member Function Documentation

template<typename T>
Matrix2& mathglpp::Matrix2< T >::operator= ( const Matrix2< T > &  rhs  )  [inline]

Default assignment.

Definition at line 60 of file Matrix.h.

References mathglpp::Matrix2< T >::cols, mathglpp::Matrix2< T >::rows, and mathglpp::Matrix2< T >::vec.

00061     {
00062         if(&rhs != this)
00063         { rows = rhs.rows; cols = rhs.cols; vec = rhs.vec; }
00064         return *this;
00065     }

template<typename T>
value_type& mathglpp::Matrix2< T >::operator() ( const dim_type  i,
const dim_type  j 
) [inline]

Fortran style element access.

Definition at line 83 of file Matrix.h.

References mathglpp::Matrix2< T >::cols, and mathglpp::Matrix2< T >::vec.

00083 { return vec[i*cols+j]; }

template<typename T>
const value_type& mathglpp::Matrix2< T >::operator() ( const dim_type  i,
const dim_type  j 
) const [inline]

Fortran style element access.

Definition at line 85 of file Matrix.h.

References mathglpp::Matrix2< T >::cols, and mathglpp::Matrix2< T >::vec.

00085 { return vec[i*cols+j]; }

template<typename T>
value_type& mathglpp::Matrix2< T >::operator[] ( const dim_type  ind  )  [inline]

C/C++ style element access.

Definition at line 87 of file Matrix.h.

References mathglpp::Matrix2< T >::vec.

00087 { return vec[ind]; }

template<typename T>
const value_type& mathglpp::Matrix2< T >::operator[] ( const dim_type  ind  )  const [inline]

C/C++ style element access.

Definition at line 89 of file Matrix.h.

References mathglpp::Matrix2< T >::vec.

00089 { return vec[ind]; }

template<typename T>
const sliced_vector_type& mathglpp::Matrix2< T >::operator[] ( const std::slice &  sl  )  [inline]

C/C++ style element slice access.

Definition at line 91 of file Matrix.h.

References mathglpp::Matrix2< T >::vec.

00091 { return vec[sl]; }

template<typename T>
const std::slice mathglpp::Matrix2< T >::row_slice ( dim_type  rn,
dim_type  cstart = 0 
) const [inline]

Row slice.

Definition at line 103 of file Matrix.h.

References mathglpp::Matrix2< T >::cols.

Referenced by mathglpp::Matrix2< T >::row().

00104     { return std::slice(cstart+rn*cols,cols-cstart,1); }

template<typename T>
const std::slice mathglpp::Matrix2< T >::row_slice ( dim_type  rn,
dim_type  cstart,
dim_type  cend 
) const [inline]

Row slice, bounded.

Definition at line 106 of file Matrix.h.

References mathglpp::Matrix2< T >::cols.

00107     { return std::slice(cstart+rn*cols,cend-cstart,1); }

template<typename T>
const std::slice mathglpp::Matrix2< T >::col_slice ( dim_type  cn,
dim_type  rstart = 0 
) const [inline]

Column slice.

Definition at line 110 of file Matrix.h.

References mathglpp::Matrix2< T >::cols, and mathglpp::Matrix2< T >::rows.

Referenced by mathglpp::Matrix2< T >::col().

00111     { return std::slice(cn+rstart*cols,rows-rstart,cols); }

template<typename T>
const std::slice mathglpp::Matrix2< T >::col_slice ( dim_type  cn,
dim_type  rstart,
dim_type  rend 
) const [inline]

Column slice, bounded.

Definition at line 113 of file Matrix.h.

References mathglpp::Matrix2< T >::cols.

00114     { return std::slice(cn+rstart*cols,rend-rstart,cols); }

template<typename T>
const dim_type& mathglpp::Matrix2< T >::getM (  )  const [inline]

Get the dimensions.

Definition at line 117 of file Matrix.h.

References mathglpp::Matrix2< T >::rows.

00117 { return rows; }

template<typename T>
mathglpp::Matrix2< T >::operator vector_type & (  )  [inline]

Return the vector.

Definition at line 122 of file Matrix.h.

References mathglpp::Matrix2< T >::vec.

00122 { return vec; }


Member Data Documentation

template<typename T>
dim_type mathglpp::Matrix2< T >::rows [protected]

dimensions

Definition at line 156 of file Matrix.h.

Referenced by mathglpp::Matrix2< T >::col_slice(), mathglpp::Matrix2< T >::filter(), mathglpp::Matrix2< T >::getM(), mathglpp::Matrix2< T >::identity(), and mathglpp::Matrix2< T >::operator=().

template<typename T>
vector_type mathglpp::Matrix2< T >::vec [protected]

The actual row major vector of values.

Definition at line 158 of file Matrix.h.

Referenced by mathglpp::Matrix2< T >::col(), mathglpp::Matrix2< T >::identity(), mathglpp::Matrix2< T >::operator const value_type *(), mathglpp::Matrix2< T >::operator const vector_type &(), mathglpp::Matrix2< T >::operator vector_type &(), mathglpp::Matrix2< T >::operator()(), mathglpp::Matrix2< T >::operator=(), mathglpp::Matrix2< T >::operator[](), mathglpp::Matrix2< T >::row(), and mathglpp::Matrix2< T >::size().


The documentation for this class was generated from the following file:
Generated on Wed Oct 3 12:50:54 2007 for MathGL++ by  doxygen 1.5.2