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 inline T * operator[]( unsigned int i )
00100 { return m_Matrix[i]; }
00101
00103 inline const T * operator[]( unsigned int i ) const
00104 { return m_Matrix[i]; }
00105
00107 inline InternalMatrixType & GetVnlMatrix( void )
00108 { return m_Matrix; }
00109
00111 inline const InternalMatrixType & GetVnlMatrix( void ) const
00112 { return m_Matrix; }
00113
00115 inline void SetIdentity( void )
00116 { m_Matrix.set_identity(); }
00117
00119 inline void Fill( const T & value )
00120 { m_Matrix.fill( value ); }
00121
00123 inline const Self & operator=( const vnl_matrix<T> & matrix);
00124
00126 inline const Self & operator=( const Self & matrix);
00127
00129 inline vnl_matrix_fixed<T,NColumns,NRows> GetInverse( void ) const;
00130
00132 inline vnl_matrix_fixed<T,NColumns,NRows> GetTranspose( void ) const;
00133
00135 Matrix() : m_Matrix(NumericTraits<T>::Zero) {};
00136
00138 Matrix(const Self & matrix) : m_Matrix( matrix.m_Matrix ) {};
00139
00140 private:
00141 InternalMatrixType m_Matrix;
00142
00143 };
00144
00145 template< class T, unsigned int NRows, unsigned int NColumns >
00146 ITK_EXPORT std::ostream& operator<<(std::ostream& os,
00147 const Matrix<T,NRows,NColumns> & v)
00148 { os << v.GetVnlMatrix(); return os; }
00149
00150
00151
00152 }
00153
00154
00155 #ifndef ITK_MANUAL_INSTANTIATION
00156 #include "itkMatrix.txx"
00157 #endif
00158
00159
00160 #endif