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

itkVariableSizeMatrix.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkVariableSizeMatrix.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/10/24 19:48:52 $
00007   Version:   $Revision: 1.6 $
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 __itkVariableSizeMatrix_h
00018 #define __itkVariableSizeMatrix_h
00019 
00020 
00021 #include "itkPoint.h"
00022 #include "itkVector.h"
00023 #include "itkCovariantVector.h"
00024 #include "vnl/vnl_matrix_fixed.h"
00025 #include "itkArray.h"
00026 
00027 
00028 namespace itk
00029 {
00030 
00040 template<class T >
00041 class VariableSizeMatrix {
00042 public:
00044   typedef VariableSizeMatrix  Self;
00045 
00047   typedef T ValueType;
00048   typedef T ComponentType;
00049 
00051   typedef vnl_matrix<T>  InternalMatrixType;
00052 
00054   Array<T> operator*(const Array<T> & vector) const;
00055  
00057   Self operator*(const Self & matrix) const;
00058  
00060   Self operator+(const Self & matrix) const;
00061   const Self & operator+=(const Self & matrix );
00062  
00064   Self operator-(const Self & matrix) const;
00065   const Self & operator-=(const Self & matrix );
00066  
00068   vnl_matrix<T> operator*(const vnl_matrix<T> & matrix) const;
00069 
00071   void operator*=(const Self & matrix);
00072  
00074   void operator*=(const vnl_matrix<T> & matrix);
00075 
00077   vnl_vector<T> operator*(const vnl_vector<T> & matrix) const;
00078 
00080   void operator*=(const T & value)
00081     { m_Matrix *= value; }
00082 
00084   Self operator*(const T & value)
00085     { Self result( *this );
00086       result *= value;
00087       return result; }
00088 
00090   void operator/=(const T & value)
00091     { m_Matrix /= value; }
00092   
00094   Self operator/(const T & value)
00095     { Self result( *this );
00096       result /= value;
00097       return result; }
00098 
00100   inline T & operator()( unsigned int row, unsigned int col )
00101     { return m_Matrix(row,col); }
00102 
00104   inline const T & operator()( unsigned int row, unsigned int col ) const
00105     { return m_Matrix(row,col); }
00106 
00108   inline T * operator[]( unsigned int i )
00109     { return m_Matrix[i]; }
00110 
00112   inline const T * operator[]( unsigned int i ) const
00113     { return m_Matrix[i]; }
00114 
00116   inline InternalMatrixType & GetVnlMatrix( void )
00117     { return m_Matrix; }
00118 
00120   inline const InternalMatrixType & GetVnlMatrix( void ) const
00121     { return m_Matrix; }
00122 
00124   inline void SetIdentity( void ) 
00125     { m_Matrix.set_identity(); }
00126 
00128   inline void Fill( const T & value ) 
00129     { m_Matrix.fill( value ); }
00130 
00132   inline const Self & operator=( const vnl_matrix<T> & matrix);
00133 
00135   inline bool operator==( const Self & matrix) const;
00136   inline bool operator!=( const Self & matrix) const;
00137 
00139   inline const Self & operator=( const Self & matrix);
00140 
00142   inline vnl_matrix<T> GetInverse( void ) const;
00143  
00145   inline vnl_matrix<T> GetTranspose( void ) const;
00146 
00148   VariableSizeMatrix() : m_Matrix() {};
00149   
00150   VariableSizeMatrix(unsigned int rows, unsigned int cols);
00151 
00153   VariableSizeMatrix(const Self & matrix) : m_Matrix( matrix.m_Matrix ) {};
00154 
00156   inline unsigned int Rows() const { return m_Matrix.rows(); } 
00157   
00159   inline unsigned int Cols() const { return m_Matrix.cols(); } 
00160 
00162   inline bool SetSize( unsigned int r, unsigned int c)
00163     {  return m_Matrix.set_size( r, c );  }
00164     
00165  
00166  
00167 private:
00168   InternalMatrixType     m_Matrix;
00169 };
00170 
00171 template< class T >  
00172 ITK_EXPORT std::ostream& operator<<(std::ostream& os, 
00173                                     const VariableSizeMatrix<T> & v) 
00174                             { os << v.GetVnlMatrix(); return os; }
00175 
00176 
00177   
00178 } // end namespace itk
00179   
00180 
00181 #ifndef ITK_MANUAL_INSTANTIATION
00182 #include "itkVariableSizeMatrix.txx"
00183 #endif
00184 
00185 
00186 #endif 

Generated at Thu May 25 00:10:46 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000