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: 2008-03-10 22:48:13 $
00007   Version:   $Revision: 1.25 $
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   
00112   typedef ComponentType ComponentArrayType[ itkGetStaticConstMacro(InternalDimension) ];
00113 
00115   SymmetricSecondRankTensor(const Self& r): BaseArray(r) {}
00116   SymmetricSecondRankTensor(const ComponentArrayType r): BaseArray(r) {}    
00118 
00120   Self& operator= (const Self& r);
00121   Self& operator= (const ComponentType& r);
00122   Self& operator= (const ComponentArrayType r);
00124 
00126   Self operator+(const Self &vec) const;
00127   Self operator-(const Self &vec) const;
00128   const Self & operator+=(const Self &vec);
00129   const Self & operator-=(const Self &vec);
00131 
00133   Self operator*(const RealValueType & scalar ) const;
00134   Self operator/(const RealValueType & scalar ) const;
00135   const Self & operator*=(const RealValueType & scalar );
00136   const Self & operator/=(const RealValueType & scalar );
00138 
00140   static unsigned int GetNumberOfComponents() 
00141     { 
00142     return itkGetStaticConstMacro(InternalDimension);
00143     }
00144 
00146   ComponentType GetNthComponent(int c) const
00147     { return this->operator[](c); }
00148 
00150   void SetNthComponent(int c, const ComponentType& v)  
00151     {  this->operator[](c) = v; }
00152 
00154   ValueType & operator()( unsigned int row, unsigned int col );
00155   const ValueType & operator()( unsigned int row, unsigned int col ) const;
00157 
00160   void SetIdentity();
00161 
00163   AccumulateValueType GetTrace() const;
00164 
00166   void ComputeEigenValues( EigenValuesArrayType & eigenValues ) const;
00167 
00170   void ComputeEigenAnalysis( EigenValuesArrayType & eigenValues,
00171                              EigenVectorsMatrixType & eigenVectors ) const;
00172 
00174   Self PreMultiply( const MatrixType & m ) const;
00175 
00177   Self PostMultiply( const MatrixType & m ) const;
00178 
00179 private:
00180 
00181   
00182 };
00183 
00184 
00187 typedef std::ostream               OutputStreamType;
00188 typedef std::istream               InputStreamType;
00189 
00190 template< typename TComponent, unsigned int NDimension  >  
00191 ITK_EXPORT OutputStreamType& operator<<(OutputStreamType& os, 
00192               const SymmetricSecondRankTensor<TComponent,NDimension> & c); 
00193 template< typename TComponent, unsigned int NDimension  >  
00194 ITK_EXPORT InputStreamType& operator>>(InputStreamType& is, 
00195                     SymmetricSecondRankTensor<TComponent,NDimension> & c); 
00196 
00197    
00198 
00199 } // end namespace itk
00200 
00201 #include "itkNumericTraitsTensorPixel.h"
00202 
00203 
00204 // Define instantiation macro for this template.
00205 #define ITK_TEMPLATE_SymmetricSecondRankTensor(_, EXPORT, x, y) namespace itk { \
00206   _(2(class EXPORT SymmetricSecondRankTensor< ITK_TEMPLATE_2 x >)) \
00207   namespace Templates { typedef SymmetricSecondRankTensor< ITK_TEMPLATE_2 x > \
00208                                          SymmetricSecondRankTensor##y; } \
00209   }
00210 
00211 #if ITK_TEMPLATE_EXPLICIT
00212 # include "Templates/itkSymmetricSecondRankTensor+-.h"
00213 #endif
00214 
00215 #if ITK_TEMPLATE_TXX
00216 # include "itkSymmetricSecondRankTensor.txx"
00217 #endif
00218 
00219 
00220 #endif
00221 

Generated at Thu Nov 6 00:24:16 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000