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

itkSymmetricSecondRankTensor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkSymmetricSecondRankTensor.h,v $
00005   Language:  C++
00006   Date:      $Date: 2010-04-09 21:25:10 $
00007   Version:   $Revision: 1.29 $
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 __itkSymmetricSecondRankTensor_h
00018 #define __itkSymmetricSecondRankTensor_h
00019 
00020 // Undefine an eventual SymmetricSecondRankTensor macro
00021 #ifdef SymmetricSecondRankTensor
00022 #undef SymmetricSecondRankTensor
00023 #endif
00024 
00025 #include "itkIndent.h"
00026 #include "itkFixedArray.h"
00027 #include "itkMatrix.h"
00028 #include "itkSymmetricEigenAnalysis.h"
00029 
00030 namespace itk
00031 {
00032 
00073 template < typename TComponent, unsigned int NDimension=3 >
00074 class SymmetricSecondRankTensor: public 
00075         FixedArray<TComponent,NDimension*(NDimension+1)/2>
00076 {
00077 public:
00079   typedef SymmetricSecondRankTensor  Self;
00080   typedef FixedArray<TComponent,NDimension*(NDimension+1)/2> Superclass;
00081 
00083   itkStaticConstMacro(Dimension, unsigned int, NDimension);
00084   itkStaticConstMacro(InternalDimension, unsigned int, NDimension*(NDimension+1)/2);
00086 
00088   typedef FixedArray<TComponent,
00089           itkGetStaticConstMacro(InternalDimension)> BaseArray;
00090 
00092   typedef FixedArray<TComponent, NDimension> EigenValuesArrayType;
00093 
00095   typedef Matrix<TComponent, NDimension, NDimension> MatrixType;
00096   typedef Matrix<TComponent, NDimension, NDimension> EigenVectorsMatrixType;
00097 
00099   typedef TComponent                                  ComponentType;
00100   typedef typename Superclass::ValueType              ValueType;
00101   typedef typename NumericTraits<ValueType>::RealType AccumulateValueType;
00102   typedef typename NumericTraits<ValueType>::RealType RealValueType;
00103 
00104   typedef SymmetricEigenAnalysis< MatrixType, 
00105             EigenValuesArrayType, EigenVectorsMatrixType >  SymmetricEigenAnalysisType;
00106 
00108   SymmetricSecondRankTensor() {this->Fill(0);}
00109 
00110   SymmetricSecondRankTensor (const ComponentType& r) { this->Fill(r); }
00111   
00113   template < typename TCoordRepB >
00114   SymmetricSecondRankTensor( const SymmetricSecondRankTensor<TCoordRepB,NDimension> & pa ):
00115     BaseArray(pa) { }
00116 
00117   typedef ComponentType ComponentArrayType[ itkGetStaticConstMacro(InternalDimension) ];
00118 
00120   SymmetricSecondRankTensor(const ComponentArrayType r): BaseArray(r) {}
00121 
00123   template < typename TCoordRepB >
00124   Self& operator= ( const SymmetricSecondRankTensor<TCoordRepB,NDimension> & pa )
00125   {
00126     BaseArray::operator=(pa);
00127     return *this;
00128   }
00130 
00132   Self& operator= (const ComponentType& r);
00133   Self& operator= (const ComponentArrayType r);
00135 
00137   Self operator+(const Self &vec) const;
00138   Self operator-(const Self &vec) const;
00139   const Self & operator+=(const Self &vec);
00140   const Self & operator-=(const Self &vec);
00142 
00144   Self operator*(const RealValueType & scalar ) const;
00145   Self operator/(const RealValueType & scalar ) const;
00146   const Self & operator*=(const RealValueType & scalar );
00147   const Self & operator/=(const RealValueType & scalar );
00149 
00151   static unsigned int GetNumberOfComponents() 
00152     { 
00153     return itkGetStaticConstMacro(InternalDimension);
00154     }
00155 
00157   ComponentType GetNthComponent(int c) const
00158     { return this->operator[](c); }
00159 
00161   void SetNthComponent(int c, const ComponentType& v)  
00162     {  this->operator[](c) = v; }
00163 
00165   ValueType & operator()( unsigned int row, unsigned int col );
00166   const ValueType & operator()( unsigned int row, unsigned int col ) const;
00168 
00171   void SetIdentity();
00172 
00174   AccumulateValueType GetTrace() const;
00175 
00177   void ComputeEigenValues( EigenValuesArrayType & eigenValues ) const;
00178 
00181   void ComputeEigenAnalysis( EigenValuesArrayType & eigenValues,
00182                              EigenVectorsMatrixType & eigenVectors ) const;
00183 
00185   Self PreMultiply( const MatrixType & m ) const;
00186 
00188   Self PostMultiply( const MatrixType & m ) const;
00189 
00190 private:
00191 
00192   
00193 };
00194 
00195 
00198 typedef std::ostream               OutputStreamType;
00199 typedef std::istream               InputStreamType;
00200 
00201 template< typename TComponent, unsigned int NDimension  >  
00202 ITK_EXPORT OutputStreamType& operator<<(OutputStreamType& os, 
00203               const SymmetricSecondRankTensor<TComponent,NDimension> & c); 
00204 template< typename TComponent, unsigned int NDimension  >  
00205 ITK_EXPORT InputStreamType& operator>>(InputStreamType& is, 
00206                     SymmetricSecondRankTensor<TComponent,NDimension> & c); 
00207 
00208    
00209 
00210 } // end namespace itk
00211 
00212 #include "itkNumericTraitsTensorPixel.h"
00213 
00214 
00215 // Define instantiation macro for this template.
00216 #define ITK_TEMPLATE_SymmetricSecondRankTensor(_, EXPORT, x, y) namespace itk { \
00217   _(2(class EXPORT SymmetricSecondRankTensor< ITK_TEMPLATE_2 x >)) \
00218   namespace Templates { typedef SymmetricSecondRankTensor< ITK_TEMPLATE_2 x > \
00219                                          SymmetricSecondRankTensor##y; } \
00220   }
00221 
00222 #if ITK_TEMPLATE_EXPLICIT
00223 # include "Templates/itkSymmetricSecondRankTensor+-.h"
00224 #endif
00225 
00226 #if ITK_TEMPLATE_TXX
00227 # include "itkSymmetricSecondRankTensor.txx"
00228 #endif
00229 
00230 
00231 #endif
00232 

Generated at Fri Apr 16 19:47:53 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000