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: 2005/06/29 20:43:38 $
00007   Version:   $Revision: 1.21 $
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);
00085 
00087   typedef FixedArray<TComponent,
00088           itkGetStaticConstMacro(InternalDimension)> BaseArray;
00089   
00091   typedef FixedArray<TComponent, NDimension> EigenValuesArrayType;
00092   
00094   typedef Matrix<TComponent, NDimension, NDimension> MatrixType;
00095   typedef Matrix<TComponent, NDimension, NDimension> EigenVectorsMatrixType;
00096   
00098   typedef TComponent ComponentType;
00099   typedef typename Superclass::ValueType ValueType;
00100   typedef typename NumericTraits<ValueType>::RealType AccumulateValueType;
00101   typedef typename NumericTraits<ValueType>::RealType RealValueType;
00102   
00103   typedef SymmetricEigenAnalysis< MatrixType, 
00104             EigenValuesArrayType, EigenVectorsMatrixType >  SymmetricEigenAnalysisType;
00105 
00107   SymmetricSecondRankTensor() {this->Fill(0);}
00108   
00109   SymmetricSecondRankTensor (const ComponentType& r) { this->Fill(r); }
00110   
00111   typedef ComponentType ComponentArrayType[ itkGetStaticConstMacro(InternalDimension) ];
00112 
00114   SymmetricSecondRankTensor(const Self& r): BaseArray(r) {}
00115   SymmetricSecondRankTensor(const ComponentArrayType r): BaseArray(r) {}    
00116   
00118   Self& operator= (const Self& r);
00119   Self& operator= (const ComponentType& r);
00120   Self& operator= (const ComponentArrayType r);
00121 
00123   Self operator+(const Self &vec) const;
00124   Self operator-(const Self &vec) const;
00125   const Self & operator+=(const Self &vec);
00126   const Self & operator-=(const Self &vec);
00127 
00129   Self operator*(const RealValueType & scalar ) const;
00130   Self operator/(const RealValueType & scalar ) const;
00131   const Self & operator*=(const RealValueType & scalar );
00132   const Self & operator/=(const RealValueType & scalar );
00133  
00135   static unsigned int GetNumberOfComponents() 
00136     { 
00137     return itkGetStaticConstMacro(InternalDimension);
00138     }
00139 
00141   ComponentType GetNthComponent(int c) const
00142     { return this->operator[](c); }
00143 
00145   void SetNthComponent(int c, const ComponentType& v)  
00146     {  this->operator[](c) = v; }
00147 
00149   ValueType & operator()( unsigned int row, unsigned int col );
00150   const ValueType & operator()( unsigned int row, unsigned int col ) const;
00151 
00154   void SetIdentity();
00155 
00157   AccumulateValueType GetTrace() const;
00158 
00160   void ComputeEigenValues( EigenValuesArrayType & eigenValues ) const;
00161  
00164   void ComputeEigenAnalysis( EigenValuesArrayType & eigenValues,
00165                              EigenVectorsMatrixType & eigenVectors ) const;
00166 
00167 private:
00168 
00169   
00170 };
00171 
00174 typedef std::ostream               OutputStreamType;
00175 typedef std::istream               InputStreamType;
00176 
00177 template< typename TComponent, unsigned int NDimension  >  
00178 ITK_EXPORT OutputStreamType& operator<<(OutputStreamType& os, 
00179               const SymmetricSecondRankTensor<TComponent,NDimension> & c); 
00180 template< typename TComponent, unsigned int NDimension  >  
00181 ITK_EXPORT InputStreamType& operator>>(InputStreamType& is, 
00182                     SymmetricSecondRankTensor<TComponent,NDimension> & c); 
00183 
00184 template <typename TValueType, unsigned int VLength>
00185 inline SymmetricSecondRankTensor< TValueType, VLength> operator* 
00186     (double d, const SymmetricSecondRankTensor< TValueType, VLength > & f)
00187 {
00188   return f * d;
00189 }
00190 
00191 
00192 
00193 } // end namespace itk
00194 
00195 #ifndef ITK_MANUAL_INSTANTIATION
00196 #include "itkSymmetricSecondRankTensor.txx"
00197 #endif
00198 
00199 #endif

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