core/vnl/algo/vnl_determinant.h
Go to the documentation of this file.
00001 // This is core/vnl/algo/vnl_determinant.h
00002 #ifndef vnl_algo_determinant_h_
00003 #define vnl_algo_determinant_h_
00004 //:
00005 // \file
00006 // \brief calculates the determinant of a matrix
00007 // \author fsm
00008 //
00009 //  Evaluation of determinants of any size. For small
00010 //  matrices, will use the direct routines (no netlib)
00011 //  but for larger matrices, a matrix decomposition
00012 //  such as SVD or QR will be used.
00013 //
00014 // \verbatim
00015 //  Modifications
00016 //   dac (Manchester) 26/03/2001: tidied up documentation
00017 //   Feb.2002 - Peter Vanroose - brief doxygen comment placed on single line
00018 //   Sep.2003 - Peter Vanroose - specialisation for int added
00019 // \endverbatim
00020 
00021 #include <vnl/vnl_matrix.h>
00022 #include <vnl/vnl_matrix_fixed.h>
00023 
00024 //: direct evaluation for 2x2 matrix
00025 template <class T> T vnl_determinant(T const *row0,
00026                                      T const *row1);
00027 
00028 //: direct evaluation for 3x3 matrix
00029 template <class T> T vnl_determinant(T const *row0,
00030                                      T const *row1,
00031                                      T const *row2);
00032 
00033 //: direct evaluation for 4x4 matrix
00034 template <class T> T vnl_determinant(T const *row0,
00035                                      T const *row1,
00036                                      T const *row2,
00037                                      T const *row3);
00038 
00039 // overload for int.  Cannot specialize the template because gcc
00040 // 2.95.4 can't handle the default value.  This overload must appear
00041 // before the template declaration because VC.net 7.0 gets confused
00042 // otherwise.
00043 int vnl_determinant(vnl_matrix<int> const &M, bool balance = false);
00044 
00045 //: evaluation using direct methods for sizes of 2x2, 3x3, and 4x4 or qr decomposition for other matrices.
00046 //  \relatesalso vnl_matrix
00047 template <class T>
00048 T vnl_determinant(vnl_matrix<T> const &M, bool balance = false);
00049 
00050 //: evaluation using direct methods for sizes of 2x2, 3x3, and 4x4 or qr decomposition for other matrices.
00051 //  convenience overload from vnl_matrix<T> variant
00052 //  \relatesalso vnl_matrix_fixed
00053 template <class T, unsigned m, unsigned n>
00054 inline T vnl_determinant(vnl_matrix_fixed<T,m,n> const &M, bool balance = false)
00055 {
00056   return vnl_determinant( M.as_ref(), balance );
00057 }
00058 
00059 
00060 #define VNL_DETERMINANT_INSTANTIATE(T) \
00061 extern "you must include vnl/algo/vnl_determinant.txx first"
00062 
00063 #endif // vnl_algo_determinant_h_