vnl_rank.h
Go to the documentation of this file.
1 // This is core/vnl/vnl_rank.h
2 #ifndef vnl_rank_h_
3 #define vnl_rank_h_
4 //:
5 // \file
6 // \author Peter Vanroose, Leuven
7 // \date 27 March 2003
8 // \brief Direct computation of the rank of a matrix, without using svd
9 //
10 // The (row) rank of a matrix is its number of linearly independent rows.
11 // This turns out to be equal to the number of linearly independent columns,
12 // i.e., the column rank, so it is just called the rank of the matrix.
13 // This can be computed by row-reducing (or column-reducing) the matrix
14 // and then counting the number of non-zero rows (or columns).
15 
16 #include <vnl/vnl_matrix.h>
17 #include "vnl/vnl_export.h"
18 
21 
22 //: Returns the rank of a matrix
23 // By default, the row rank of the matrix is determined.
24 // Specify vnl_rank_column to obtain the column rank.
25 //
26 // \relatesalso vnl_matrix
27 template <class T> VNL_EXPORT
28 unsigned int vnl_rank(vnl_matrix<T> const& mat, vnl_rank_type = vnl_rank_both);
29 
30 //: Row reduce a matrix.
31 // First try to use 1 or -1 as pivot element in each row, to avoid divisions;
32 // then use any nonzero element as candidate pivot.
33 // Repeat this process until the matrix does not change any more.
34 // At that point, the matrix spans the same row space as before and contains
35 // as many zeros as possible.
36 //
37 // When specifying vnl_rank_pivot_one is given as second argument,
38 // only elements with value 1 or -1 are used as candidate pivot elements.
39 //
40 // Note that for integer matrices, the resulting matrix is still integer,
41 // and is guaranteed to be row equivalent with the original matrix.
42 //
43 // \relatesalso vnl_matrix
44 //
45 template <class T> VNL_EXPORT
48 
49 //: Column reduce a matrix.
50 //
51 // \relatesalso vnl_matrix
52 //
53 template <class T> VNL_EXPORT
56 
57 //: Row and column reduce a matrix.
58 // Perform both row reduction and column reduction on a matrix.
59 // The resulting matrix will in general no longer span the same row space
60 // (or column space) as the original matrix, but the rank will not have
61 // changed, and the number of nonzero elements will be minimal (viz at most
62 // one per row and one per column).
63 //
64 // \relatesalso vnl_matrix
65 //
66 template <class T> VNL_EXPORT
69 
70 #define VNL_RANK_INSTANTIATE(T) extern "please #include vnl/vnl_rank.hxx instead"
71 
72 #endif // vnl_rank_h_
VNL_EXPORT vnl_matrix< T > vnl_rank_row_reduce(vnl_matrix< T > const &mat, vnl_rank_pivot_type=vnl_rank_pivot_all)
Row reduce a matrix.
An ordinary mathematical matrix.
vnl_rank_type
Definition: vnl_rank.h:19
VNL_EXPORT vnl_matrix< T > vnl_rank_column_reduce(vnl_matrix< T > const &mat, vnl_rank_pivot_type=vnl_rank_pivot_all)
Column reduce a matrix.
An ordinary mathematical matrix.
Definition: vnl_adjugate.h:22
vnl_rank_pivot_type
Definition: vnl_rank.h:20
VNL_EXPORT unsigned int vnl_rank(vnl_matrix< T > const &mat, vnl_rank_type=vnl_rank_both)
Returns the rank of a matrix.
VNL_EXPORT vnl_matrix< T > vnl_rank_row_column_reduce(vnl_matrix< T > const &mat, vnl_rank_pivot_type=vnl_rank_pivot_all)
Row and column reduce a matrix.