奇異值分解。 更多...
#include <opencv2/core.hpp>
|
| 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 | backSubst (InputArray w, InputArray u, InputArray vt, InputArray rhs, OutputArray dst) |
| | 執行回代
|
| |
| template<typename _Tp , int m, int n, int nm> |
| static void | compute (const Matx< _Tp, m, n > &a, Matx< _Tp, nm, 1 > &w) |
| |
| 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) |
| |
| static void | compute (InputArray src, OutputArray w, int flags=0) |
| |
| static void | compute (InputArray src, OutputArray w, OutputArray u, OutputArray vt, int flags=0) |
| | 分解矩陣並將結果儲存到使用者提供的矩陣中
|
| |
| static void | solveZ (InputArray src, OutputArray dst) |
| | 求解欠定奇異線性系統
|
| |
奇異值分解。
用於計算浮點矩陣的奇異值分解的類。奇異值分解用於解決最小二乘問題、欠定線性系統、矩陣求逆、計算條件數等。
如果您想計算矩陣的條件數或其行列式的絕對值,則不需要 u 和 vt。您可以傳遞 flags=SVD::NO_UV|...。另一個標誌 SVD::FULL_UV 表示必須計算全尺寸的 u 和 vt,但這在大多數情況下並非必要。
- 另請參見
- invert、solve、eigen、determinant
◆ 標誌
| 列舉器 |
|---|
| MODIFY_A | 允許演算法修改已分解的矩陣;這可以節省空間並加快處理速度。當前已忽略。
|
| NO_UV | 指示只處理奇異值向量 w,而 u 和 vt 將設定為空矩陣。
|
| FULL_UV | 當矩陣不是方陣時,預設情況下演算法會生成足夠大的 u 和 vt 矩陣以用於後續的 A 重構;但是,如果指定了 FULL_UV 標誌,u 和 vt 將是全尺寸的方正交矩陣。
|
◆ SVD() [1/2]
◆ SVD() [2/2]
這是一個過載成員函式,為方便起見而提供。它與上述函式的唯一區別在於它接受的引數。初始化一個空的 SVD 結構,然後呼叫 SVD::operator()
- 引數
-
| src | 已分解的矩陣。深度必須是 CV_32F 或 CV_64F。 |
| flags | 操作標誌 (SVD::Flags) |
◆ backSubst() [1/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 |
◆ backSubst() [2/3]
執行奇異值回代。
該方法為指定的右側計算回代
\[\texttt{x} = \texttt{vt} ^T \cdot diag( \texttt{w} )^{-1} \cdot \texttt{u} ^T \cdot \texttt{rhs} \sim \texttt{A} ^{-1} \cdot \texttt{rhs}\]
使用這種技術,您可以獲得一個方便的線性系統的非常精確的解,或者一個超定線性系統的最佳(在最小二乘意義上)偽解。
- 引數
-
| rhs | 待求解線性系統 (u*w*v')*dst = rhs 的右側,其中 A 已被先前分解。 |
| dst | 找到的系統解。 |
- 注意
- 顯式 SVD 以及進一步的回代僅在需要求解許多具有相同左側(例如 src)的線性系統時才有意義。如果您只需要求解一個系統(可能立即有多個 rhs 可用),只需呼叫 solve 並傳入 DECOMP_SVD 即可。它們的作用完全相同。
◆ backSubst() [3/3]
◆ compute() [1/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 |
◆ compute() [2/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 |
◆ compute() [3/4]
這是一個過載成員函式,為方便起見而提供。它與上述函式的唯一區別在於它接受的引數。計算矩陣的奇異值
- 引數
-
| src | 已分解的矩陣。深度必須是 CV_32F 或 CV_64F。 |
| w | 計算得到的奇異值 |
| flags | 操作標誌 - 參見 SVD::Flags。 |
◆ compute() [4/4]
分解矩陣並將結果儲存到使用者提供的矩陣中
這些方法/函式執行矩陣的 SVD。與 SVD::SVD 建構函式和 SVD::operator() 不同,它們將結果儲存到使用者提供的矩陣中
static void compute(InputArray src, OutputArray w, OutputArray u, OutputArray vt, int flags=0)
分解矩陣並將結果儲存到使用者提供的矩陣中
- 引數
-
| src | 已分解的矩陣。深度必須是 CV_32F 或 CV_64F。 |
| w | 計算得到的奇異值 |
| u | 計算得到的左奇異向量 |
| vt | 右奇異向量的轉置矩陣 |
| flags | 操作標誌 - 參見 SVD::Flags。 |
◆ operator()()
執行 SVD 的運算子。先前分配的 u、w 和 vt 被釋放。
該運算子執行給定矩陣的奇異值分解。u、vt 以及奇異值向量 w 都儲存在該結構中。相同的 SVD 結構可以多次與不同的矩陣一起重複使用。每次需要時,都會回收先前的 u、vt 和 w,並建立新的矩陣,所有這些都由 Mat::create 處理。
- 引數
-
| src | 已分解的矩陣。深度必須是 CV_32F 或 CV_64F。 |
| flags | 操作標誌 (SVD::Flags) |
◆ solveZ()
求解欠定奇異線性系統
該方法找到奇異線性系統 A*x = 0 的單位長度解 x。根據 A 的秩,可能沒有解、單個解或無限多個解。通常,該演算法解決以下問題
\[dst = \arg \min _{x: \| x \| =1} \| src \cdot x \|\]
- 引數
-
◆ vt
此類的文件由以下檔案生成