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);
00051 
00053   typedef vnl_matrix_fixed<T,NRows,NColumns>  InternalMatrixType;
00054 
00056   Vector<T,NRows> operator*(const Vector<T,NColumns> & vector) const;
00057  
00059   Point<T,NRows> operator*(const Point<T,NColumns> & vector) const;
00060  
00062   CovariantVector<T,NRows> 
00063   operator*(const CovariantVector<T,NColumns> & vector) const;
00064   
00066   Self operator*(const Self & matrix) const;
00067  
00069   Self operator+(const Self & matrix) const;
00070   const Self & operator+=(const Self & matrix );
00071  
00073   Self operator-(const Self & matrix) const;
00074   const Self & operator-=(const Self & matrix );
00075  
00077   vnl_matrix<T> operator*(const vnl_matrix<T> & matrix) const;
00078 
00080   void operator*=(const Self & matrix);
00081  
00083   void operator*=(const vnl_matrix<T> & matrix);
00084 
00086   vnl_vector<T> operator*(const vnl_vector<T> & matrix) const;
00087 
00089   void operator*=(const T & value)
00090     { m_Matrix *= value; }
00091 
00093   Self operator*(const T & value)
00094     { Self result( *this );
00095       result *= value;
00096       return result; }
00097       
00099   void operator/=(const T & value)
00100     { m_Matrix /= value; }
00101   
00103   Self operator/(const T & value)
00104     { Self result( *this );
00105       result /= value;
00106       return result; }
00107 
00108 
00110   inline T & operator()( unsigned int row, unsigned int col )
00111     { return m_Matrix(row,col); }
00112 
00114   inline const T & operator()( unsigned int row, unsigned int col ) const
00115     { return m_Matrix(row,col); }
00116 
00118   inline T * operator[]( unsigned int i )
00119     { return m_Matrix[i]; }
00120 
00122   inline const T * operator[]( unsigned int i ) const
00123     { return m_Matrix[i]; }
00124 
00126   inline InternalMatrixType & GetVnlMatrix( void )
00127     { return m_Matrix; }
00128 
00130   inline const InternalMatrixType & GetVnlMatrix( void ) const
00131     { return m_Matrix; }
00132 
00134   inline void SetIdentity( void ) 
00135     { m_Matrix.set_identity(); }
00136 
00138   inline void Fill( const T & value ) 
00139     { m_Matrix.fill( value ); }
00140 
00142   inline const Self & operator=( const vnl_matrix<T> & matrix);
00143 
00145   inline bool operator==( const Self & matrix);
00146   inline bool operator!=( const Self & matrix);
00147 
00149   inline const Self & operator=( const Self & matrix);
00150 
00152   inline vnl_matrix_fixed<T,NColumns,NRows> GetInverse( void ) const;
00153  
00155   inline vnl_matrix_fixed<T,NColumns,NRows> GetTranspose( void ) const;
00156 
00158   Matrix() : m_Matrix(NumericTraits<T>::Zero) {};
00159 
00161   Matrix(const Self & matrix) : m_Matrix( matrix.m_Matrix ) {};
00162  
00163 private:
00164   InternalMatrixType     m_Matrix;
00165 
00166 };
00167 
00168 template< class T, unsigned int NRows, unsigned int NColumns >  
00169 ITK_EXPORT std::ostream& operator<<(std::ostream& os, 
00170                                     const Matrix<T,NRows,NColumns> & v) 
00171                             { os << v.GetVnlMatrix(); return os; }
00172 
00173 
00174   
00175 } // end namespace itk
00176   
00177 
00178 #ifndef ITK_MANUAL_INSTANTIATION
00179 #include "itkMatrix.txx"
00180 #endif
00181 
00182 
00183 #endif 

Generated at Wed May 24 23:37:40 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000