| OpenCV 3.4.1 Open Source Computer Vision

Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
cv::SVD Class Reference
Core functionality » Operations on arrays

Singular Value Decomposition. More...

`#include "core.hpp"`

## Public Types
enum | Flags { MODIFY_A = 1, NO_UV = 2, FULL_UV = 4 }

## Public Member Functions
| SVD ()
| the default constructor More...
| SVD (InputArray src, int flags=0)
void | backSubst (InputArray rhs, OutputArray dst) const
| performs a singular value back substitution. More...
SVD & | operator() (InputArray src, int flags=0)
| the operator that performs SVD. The previously allocated u, w and vt are released. More...

## Static Public Member Functions
static void | backSubst (InputArray w, InputArray u, InputArray vt, InputArray rhs, OutputArray dst)
| performs back substitution More...
template<typename _Tp , int m, int n, int nm, int nb>
static void | backSubst (const Matx< _Tp, nm, 1 > &w, const Matx< _Tp, m, nm > &u, const Matx< _Tp, n, nm > &vt, const Matx< _Tp, m, nb > &rhs, Matx< _Tp, n, nb > &dst)
static void | compute (InputArray src, OutputArray w, OutputArray u, OutputArray vt, int flags=0)
| decomposes matrix and stores the results to user-provided matrices More...
static void | compute (InputArray src, OutputArray w, int flags=0)
template<typename _Tp , int m, int n, int nm>
static void | compute (const Matx< _Tp, m, n > &a, Matx< _Tp, nm, 1 > &w, Matx< _Tp, m, nm > &u, Matx< _Tp, n, nm > &vt)
template<typename _Tp , int m, int n, int nm>
static void | compute (const Matx< _Tp, m, n > &a, Matx< _Tp, nm, 1 > &w)
static void | solveZ (InputArray src, OutputArray dst)
| solves an under-determined singular linear system More...

## Public Attributes
Mat | u
Mat | vt
Mat | w

## Detailed Description

Singular Value Decomposition.

Class for computing Singular Value Decomposition of a floating-point matrix. The Singular Value Decomposition is used to solve least-square problems, under-determined linear systems, invert matrices, compute condition numbers, and so on.

If you want to compute a condition number of a matrix or an absolute value of its determinant, you do not need `u` and `vt`. You can pass flags=SVD::NO_UV|... . Another flag SVD::FULL_UV indicates that full-size u and vt must be computed, which is not necessary most of the time.

See also
  invert, solve, eigen, determinant

## Member Enumeration Documentation

## § Flags

enum cv::SVD::Flags

Enumerator
MODIFY_A | allow the algorithm to modify the decomposed matrix; it can save space and speed up processing. currently ignored.
NO_UV | indicates that only a vector of singular values `w` is to be processed, while u and vt will be set to empty matrices
FULL_UV | when the matrix is not square, by default the algorithm produces u and vt matrices of sufficiently large size for the further A reconstruction; if, however, FULL_UV flag is specified, u and vt will be full-size square orthogonal matrices.

## Constructor & Destructor Documentation

## § SVD() [1/2]

cv::SVD::SVD | ( |  | ) |

the default constructor

initializes an empty SVD structure

## § SVD() [2/2]

cv::SVD::SVD | ( | InputArray | src,
|  | int | flags = `0`
| ) |  |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. initializes an empty SVD structure and then calls SVD::operator()

Parameters

  src | decomposed matrix. The depth has to be CV_32F or CV_64F.
  flags | operation flags (SVD::Flags)

## Member Function Documentation

## § backSubst() [1/3]

static void cv::SVD::backSubst | ( | InputArray | w,
|  | InputArray | u,
|  | InputArray | vt,
|  | InputArray | rhs,
|  | OutputArray | dst
| ) |  |
| static

performs back substitution

## § backSubst() [2/3]

void cv::SVD::backSubst | ( | InputArray | rhs,
|  | OutputArray | dst
| ) |  | const

performs a singular value back substitution.

The method calculates a back substitution for the specified right-hand side:

\[\texttt{x} = \texttt{vt} ^T \cdot diag( \texttt{w} )^{-1} \cdot \texttt{u} ^T \cdot \texttt{rhs} \sim \texttt{A} ^{-1} \cdot \texttt{rhs}\]

Using this technique you can either get a very accurate solution of the convenient linear system, or the best (in the least-squares terms) pseudo-solution of an overdetermined linear system.

Parameters

  rhs | right-hand side of a linear system (u*w*v')*dst = rhs to be solved, where A has been previously decomposed.
  dst | found solution of the system.

Note
  Explicit SVD with the further back substitution only makes sense if you need to solve many linear systems with the same left-hand side (for example, src ). If all you need is to solve a single system (possibly with multiple rhs immediately available), simply call solve add pass DECOMP_SVD there. It does absolutely the same thing.

## § backSubst() [3/3]

template<typename _Tp , int m, int n, int nm, int nb>

static void cv::SVD::backSubst | ( | const Matx< _Tp, nm, 1 > & | w,
|  | const Matx< _Tp, m, nm > & | u,
|  | const Matx< _Tp, n, nm > & | vt,
|  | const Matx< _Tp, m, nb > & | rhs,
|  | Matx< _Tp, n, nb > & | dst
| ) |  |
| static

Todo:
  document

## § compute() [1/4]

static void cv::SVD::compute | ( | InputArray | src,
|  | OutputArray | w,
|  | OutputArray | u,
|  | OutputArray | vt,
|  | int | flags = `0`
| ) |  |
| static

decomposes matrix and stores the results to user-provided matrices

The methods/functions perform SVD of matrix. Unlike SVD::SVD constructor and SVD::operator(), they store the results to the user-provided matrices:

Mat A, w, u, vt;
SVD::compute(A, w, u, vt);

Parameters

  src | decomposed matrix. The depth has to be CV_32F or CV_64F.
  w | calculated singular values
  u | calculated left singular vectors
  vt | transposed matrix of right singular vectors
  flags | operation flags - see SVD::Flags.

## § compute() [2/4]

static void cv::SVD::compute | ( | InputArray | src,
|  | OutputArray | w,
|  | int | flags = `0`
| ) |  |
| static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. computes singular values of a matrix

Parameters

  src | decomposed matrix. The depth has to be CV_32F or CV_64F.
  w | calculated singular values
  flags | operation flags - see SVD::Flags.

## § compute() [3/4]

template<typename _Tp , int m, int n, int nm>

static void cv::SVD::compute | ( | const Matx< _Tp, m, n > & | a,
|  | Matx< _Tp, nm, 1 > & | w,
|  | Matx< _Tp, m, nm > & | u,
|  | Matx< _Tp, n, nm > & | vt
| ) |  |
| static

Todo:
  document

## § compute() [4/4]

template<typename _Tp , int m, int n, int nm>

static void cv::SVD::compute | ( | const Matx< _Tp, m, n > & | a,
|  | Matx< _Tp, nm, 1 > & | w
| ) |  |
| static

Todo:
  document

## § operator()()

SVD& cv::SVD::operator() | ( | InputArray | src,
|  | int | flags = `0`
| ) |  |

the operator that performs SVD. The previously allocated u, w and vt are released.

The operator performs the singular value decomposition of the supplied matrix. The u,`vt` , and the vector of singular values w are stored in the structure. The same SVD structure can be reused many times with different matrices. Each time, if needed, the previous u,`vt` , and w are reclaimed and the new matrices are created, which is all handled by Mat::create.

Parameters

  src | decomposed matrix. The depth has to be CV_32F or CV_64F.
  flags | operation flags (SVD::Flags)

## § solveZ()

static void cv::SVD::solveZ | ( | InputArray | src,
|  | OutputArray | dst
| ) |  |
| static

solves an under-determined singular linear system

The method finds a unit-length solution x of a singular linear system A*x = 0. Depending on the rank of A, there can be no solutions, a single solution or an infinite number of solutions. In general, the algorithm solves the following problem:

\[dst = \arg \min _{x: \| x \| =1} \| src \cdot x \|\]

Parameters

  src | left-hand-side matrix.
  dst | found solution.

## Member Data Documentation

## § u

Mat cv::SVD::u

## § vt

Mat cv::SVD::vt

## § w

Mat cv::SVD::w

The documentation for this class was generated from the following file:

- core/include/opencv2/core.hpp