Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkMatrix.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMatrix.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/07/18 15:12:10 $
00007   Version:   $Revision: 1.20 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkMatrix_h
00018 #define __itkMatrix_h
00019 
00020 
00021 #include "itkPoint.h"
00022 #include "itkVector.h"
00023 #include "itkCovariantVector.h"
00024 #include "vnl/vnl_matrix_fixed.h"
00025 
00026 
00027 namespace itk
00028 {
00029 
00038 template<class T, unsigned int NRows=3, unsigned int NColumns=3>
00039 class Matrix {
00040 public:
00042   typedef Matrix  Self;
00043 
00045   typedef T ValueType;
00046   typedef T ComponentType;
00047 
00049   itkStaticConstMacro(RowDimensions,    unsigned int, NRows);
00050   itkStaticConstMacro(ColumnDimensions, unsigned int, NColumns);
00052 
00054   typedef vnl_matrix_fixed<T,NRows,NColumns>  InternalMatrixType;
00055 
00057   Vector<T,NRows> operator*(const Vector<T,NColumns> & vector) const;
00058 
00060   Point<T,NRows> operator*(const Point<T,NColumns> & vector) const;
00061 
00063   CovariantVector<T,NRows> 
00064   operator*(const CovariantVector<T,NColumns> & vector) const;
00065 
00067   Self operator*(const Self & matrix) const;
00068 
00070   Self operator+(const Self & matrix) const;
00071   const Self & operator+=(const Self & matrix );
00073 
00075   Self operator-(const Self & matrix) const;
00076   const Self & operator-=(const Self & matrix );
00078 
00080   vnl_matrix<T> operator*(const vnl_matrix<T> & matrix) const;
00081 
00083   void operator*=(const Self & matrix);
00084 
00086   void operator*=(const vnl_matrix<T> & matrix);
00087 
00089   vnl_vector<T> operator*(const vnl_vector<T> & matrix) const;
00090 
00092   void operator*=(const T & value)
00093     { m_Matrix *= value; }
00094 
00096   Self operator*(const T & value)
00097     { Self result( *this );
00098       result *= value;
00099       return result; }
00101 
00103   void operator/=(const T & value)
00104     { m_Matrix /= value; }
00105 
00107   Self operator/(const T & value)
00108     { Self result( *this );
00109       result /= value;
00110       return result; }
00112 
00113 
00115   inline T & operator()( unsigned int row, unsigned int col )
00116     { return m_Matrix(row,col); }
00117 
00119   inline const T & operator()( unsigned int row, unsigned int col ) const
00120     { return m_Matrix(row,col); }
00121 
00123   inline T * operator[]( unsigned int i )
00124     { return m_Matrix[i]; }
00125 
00127   inline const T * operator[]( unsigned int i ) const
00128     { return m_Matrix[i]; }
00129 
00131   inline InternalMatrixType & GetVnlMatrix( void )
00132     { return m_Matrix; }
00133 
00135   inline const InternalMatrixType & GetVnlMatrix( void ) const
00136     { return m_Matrix; }
00137 
00139   inline void SetIdentity( void ) 
00140     { m_Matrix.set_identity(); }
00141 
00143   inline void Fill( const T & value ) 
00144     { m_Matrix.fill( value ); }
00145 
00147   inline const Self & operator=( const vnl_matrix<T> & matrix);
00148 
00150   inline bool operator==( const Self & matrix);
00151   inline bool operator!=( const Self & matrix);
00153 
00155   inline const Self & operator=( const Self & matrix);
00156 
00158   inline vnl_matrix_fixed<T,NColumns,NRows> GetInverse( void ) const;
00159 
00161   inline vnl_matrix_fixed<T,NColumns,NRows> GetTranspose( void ) const;
00162 
00164   Matrix() : m_Matrix(NumericTraits<T>::Zero) {};
00165 
00167   Matrix(const Self & matrix) : m_Matrix( matrix.m_Matrix ) {};
00168 
00169  // Rename some operators for wrapping
00170   inline T& Get( unsigned int row, unsigned int col )
00171     { return m_Matrix(row,col); }
00172 
00173   inline void Set( unsigned int row, unsigned int col, T value )
00174     { m_Matrix(row,col) = value; }
00175   
00176   
00177 private:
00178   InternalMatrixType     m_Matrix;
00179 
00180 };
00181 
00182 template< class T, unsigned int NRows, unsigned int NColumns >  
00183 ITK_EXPORT std::ostream& operator<<(std::ostream& os, 
00184                                     const Matrix<T,NRows,NColumns> & v) 
00185                             { os << v.GetVnlMatrix(); return os; }
00186 
00187 
00188   
00189 } // end namespace itk
00190   
00191 
00192 #ifndef ITK_MANUAL_INSTANTIATION
00193 #include "itkMatrix.txx"
00194 #endif
00195 
00196 
00197 #endif 
00198 

Generated at Fri Sep 8 03:40:27 2006 for ITK by doxygen 1.4.7 written by Dimitri van Heesch, © 1997-2000