core/vnl/algo/vnl_scatter_3x3.h
Go to the documentation of this file.
00001 // This is core/vnl/algo/vnl_scatter_3x3.h
00002 #ifndef vnl_scatter_3x3_h_
00003 #define vnl_scatter_3x3_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief  3x3 scatter matrix
00010 // \author Andrew W. Fitzgibbon, Oxford RRG
00011 // \date   02 Oct 96
00012 //
00013 // \verbatim
00014 //  Modifications
00015 //   18 Feb 2000. fsm: templated.
00016 //   4/4/01 LSB (Manchester) documentation tidied
00017 //   Feb.2002 - Peter Vanroose - brief doxygen comment placed on single line
00018 //   13 Jan.2003 - Peter Vanroose - added missing implem. for sub_outer_product
00019 // \endverbatim
00020 //-----------------------------------------------------------------------------
00021 
00022 #include <vnl/vnl_matrix_fixed.h>
00023 #include <vnl/vnl_vector_fixed.h>
00024 
00025 template <class T>
00026 class vnl_scatter_3x3 : public vnl_matrix_fixed<T,3,3>
00027 {
00028  public:
00029   typedef vnl_matrix_fixed<T,3,3> base;
00030   typedef vnl_vector_fixed<T,3> vect;
00031 
00032   //: Constructor.  Fills with zeros.
00033   vnl_scatter_3x3();
00034 
00035   //: Add v*v' to scatter.
00036   void add_outer_product(const vnl_vector_fixed<T,3> & v);
00037 
00038   //: Add v*u' to scatter.
00039   void add_outer_product(const vnl_vector_fixed<T,3> & u,
00040                          const vnl_vector_fixed<T,3> & v);
00041 
00042   //: Subtract v*v' from scatter.
00043   void sub_outer_product(const vnl_vector_fixed<T,3> & v);
00044 
00045   //: Subtract v*u' from scatter.
00046   void sub_outer_product(const vnl_vector_fixed<T,3> & u,
00047                          const vnl_vector_fixed<T,3> & v);
00048 
00049   //: Replace S with $(S+S^\top)/2$.
00050   void force_symmetric();
00051 
00052   //: Compute the eigensystem of S.
00053   void compute_eigensystem();
00054 
00055   //: Return the eigenvector corresponding to the smallest eigenvalue.
00056   vnl_vector_fixed<T,3> minimum_eigenvector() {
00057     if (!eigenvectors_currentp) compute_eigensystem();
00058     return vnl_vector_fixed<T,3>(V_(0,0), V_(1,0), V_(2,0));
00059   }
00060 
00061   //: Return the column matrix of eigenvectors, sorted in increasing order of eigenvalue.
00062   vnl_matrix_fixed<T,3,3>& V()
00063   {
00064     if (!eigenvectors_currentp) compute_eigensystem();
00065     return V_;
00066   }
00067 
00068  protected:
00069   bool symmetricp;
00070   bool eigenvectors_currentp;
00071   vnl_matrix_fixed<T,3,3> V_;
00072   vnl_vector_fixed<T,3> D;
00073 };
00074 
00075 
00076 #endif // vnl_scatter_3x3_h_