vnl_matrix_inverse.h
Go to the documentation of this file.
1 // This is core/vnl/algo/vnl_matrix_inverse.h
2 #ifndef vnl_matrix_inverse_h_
3 #define vnl_matrix_inverse_h_
4 //:
5 // \file
6 // \brief Calculates inverse of a matrix (wrapper around vnl_svd<double>)
7 // \author Andrew W. Fitzgibbon, Oxford RRG
8 // \date 22 Nov 96
9 //
10 // \verbatim
11 // Modifications
12 // dac (Manchester) 28/03/2001: tidied up documentation
13 // \endverbatim
14 
15 #include <vnl/algo/vnl_svd.h>
16 #include <vnl/algo/vnl_algo_export.h>
17 
18 //: Calculates inverse of a matrix (wrapper around vnl_svd<double>)
19 // vnl_matrix_inverse is a wrapper around vnl_svd<double> that allows
20 // you to write
21 // \code
22 // x = vnl_matrix_inverse<double>(A) * b;
23 // \endcode
24 // This is exactly equivalent to
25 // \code
26 // x = vnl_svd<double>(A).solve(b);
27 // \endcode
28 // but is arguably clearer, and also allows for the vnl_matrix_inverse
29 // class to be changed to use vnl_qr, say.
30 
31 template <class T>
32 struct vnl_matrix_inverse : public vnl_svd<T>
33 {
35  ~vnl_matrix_inverse() override = default;
36 
37  operator vnl_matrix<T> () const { return this->inverse(); }
38 };
39 
40 template <class T>
41 inline
43  vnl_vector<T> const & B)
44 {
45  return i.solve(B);
46 }
47 
48 template <class T>
49 inline
51  vnl_matrix<T> const & B)
52 {
53  return i.solve(B);
54 }
55 
56 #endif // vnl_matrix_inverse_h_
vnl_matrix_inverse(vnl_matrix< T > const &M)
vnl_matrix< T > inverse() const
Definition: vnl_svd.h:133
vnl_matrix< T > solve(vnl_matrix< T > const &B) const
Solve the matrix equation M X = B, returning X.
Definition: vnl_svd.hxx:275
~vnl_matrix_inverse() override=default
An ordinary mathematical matrix.
Definition: vnl_adjugate.h:22
Mathematical vector class, templated by type of element.
Definition: vnl_fwd.h:16
Holds the singular value decomposition of a vnl_matrix.
Calculates inverse of a matrix (wrapper around vnl_svd<double>).
Definition: vnl_algo_fwd.h:6
Holds the singular value decomposition of a vnl_matrix.
Definition: vnl_algo_fwd.h:7
vnl_bignum operator *(vnl_bignum const &r1, vnl_bignum const &r2)
Returns the product of two bignum numbers.
Definition: vnl_bignum.h:302