vnl_determinant.h
Go to the documentation of this file.
1 // This is core/vnl/algo/vnl_determinant.h
2 #ifndef vnl_algo_determinant_h_
3 #define vnl_algo_determinant_h_
4 //:
5 // \file
6 // \brief calculates the determinant of a matrix
7 // \author fsm
8 //
9 // Evaluation of determinants of any size. For small
10 // matrices, will use the direct routines (no netlib)
11 // but for larger matrices, a matrix decomposition
12 // such as SVD or QR will be used.
13 //
14 // \verbatim
15 // Modifications
16 // dac (Manchester) 26/03/2001: tidied up documentation
17 // Feb.2002 - Peter Vanroose - brief doxygen comment placed on single line
18 // Sep.2003 - Peter Vanroose - specialisation for int added
19 // \endverbatim
20 
21 #include <vnl/vnl_matrix.h>
22 #include <vnl/vnl_matrix_fixed.h>
23 #include <vnl/algo/vnl_algo_export.h>
24 
25 //: direct evaluation for 2x2 matrix
26 template <class T> T vnl_determinant(T const *row0,
27  T const *row1);
28 
29 //: direct evaluation for 3x3 matrix
30 template <class T> T vnl_determinant(T const *row0,
31  T const *row1,
32  T const *row2);
33 
34 //: direct evaluation for 4x4 matrix
35 template <class T> T vnl_determinant(T const *row0,
36  T const *row1,
37  T const *row2,
38  T const *row3);
39 
40 // overload for int. Cannot specialize the template because gcc
41 // 2.95.4 can't handle the default value. This overload must appear
42 // before the template declaration because VC.net 7.0 gets confused
43 // otherwise.
44 int VNL_ALGO_EXPORT vnl_determinant(vnl_matrix<int> const &M, bool balance = false);
45 
46 //: evaluation using direct methods for sizes of 2x2, 3x3, and 4x4 or qr decomposition for other matrices.
47 // \relatesalso vnl_matrix
48 template <class T>
49 T vnl_determinant(vnl_matrix<T> const &M, bool balance = false);
50 
51 //: evaluation using direct methods for sizes of 2x2, 3x3, and 4x4 or qr decomposition for other matrices.
52 // convenience overload from vnl_matrix<T> variant
53 // \relatesalso vnl_matrix_fixed
54 template <class T, unsigned m, unsigned n>
55 inline T vnl_determinant(vnl_matrix_fixed<T,m,n> const &M, bool balance = false)
56 {
57  return vnl_determinant( M.as_ref(), balance );
58 }
59 
60 
61 #define VNL_DETERMINANT_INSTANTIATE(T) \
62 extern "you must include vnl/algo/vnl_determinant.hxx first"
63 
64 #endif // vnl_algo_determinant_h_
vnl_matrix_ref< T > as_ref()
Explicit conversion to a vnl_matrix_ref.
An ordinary mathematical matrix.
Fixed size, stack-stored, space-efficient matrix.
Definition: vnl_fwd.h:23
T vnl_determinant(vnl_matrix< T > const &M, bool balance=false)
evaluation using direct methods for sizes of 2x2, 3x3, and 4x4 or qr decomposition for other matrices...
fixed size matrix