00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 }
00176
00177
00178 #ifndef ITK_MANUAL_INSTANTIATION
00179 #include "itkMatrix.txx"
00180 #endif
00181
00182
00183 #endif