@Namespace(value="cv") @NoOffset @Properties(inherit=opencv_core.class) public class SVD extends Pointer
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.
invert, solve, eigen, determinant
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Modifier and Type | Field and Description |
---|---|
static int |
FULL_UV
enum cv::SVD::Flags
|
static int |
MODIFY_A
enum cv::SVD::Flags
|
static int |
NO_UV
enum cv::SVD::Flags
|
Constructor and Description |
---|
SVD()
\brief the default constructor
|
SVD(GpuMat src) |
SVD(GpuMat src,
int flags) |
SVD(long size)
Native array allocator.
|
SVD(Mat src) |
SVD(Mat src,
int flags)
\overload
initializes an empty SVD structure and then calls SVD::operator()
|
SVD(Pointer p)
Pointer cast constructor.
|
SVD(UMat src) |
SVD(UMat src,
int flags) |
Modifier and Type | Method and Description |
---|---|
SVD |
apply(GpuMat src) |
SVD |
apply(GpuMat src,
int flags) |
SVD |
apply(Mat src) |
SVD |
apply(Mat src,
int flags)
\brief the operator that performs SVD.
|
SVD |
apply(UMat src) |
SVD |
apply(UMat src,
int flags) |
void |
backSubst(GpuMat rhs,
GpuMat dst) |
static void |
backSubst(GpuMat w,
GpuMat u,
GpuMat vt,
GpuMat rhs,
GpuMat dst) |
void |
backSubst(Mat rhs,
Mat dst)
\brief performs a singular value back substitution.
|
static void |
backSubst(Mat w,
Mat u,
Mat vt,
Mat rhs,
Mat dst)
\brief performs back substitution
|
void |
backSubst(UMat rhs,
UMat dst) |
static void |
backSubst(UMat w,
UMat u,
UMat vt,
UMat rhs,
UMat dst) |
static void |
compute(GpuMat src,
GpuMat w) |
static void |
compute(GpuMat src,
GpuMat w,
GpuMat u,
GpuMat vt) |
static void |
compute(GpuMat src,
GpuMat w,
GpuMat u,
GpuMat vt,
int flags) |
static void |
compute(GpuMat src,
GpuMat w,
int flags) |
static void |
compute(Mat src,
Mat w) |
static void |
compute(Mat src,
Mat w,
int flags)
\overload
computes singular values of a matrix
|
static void |
compute(Mat src,
Mat w,
Mat u,
Mat vt) |
static void |
compute(Mat src,
Mat w,
Mat u,
Mat vt,
int flags)
\brief decomposes matrix and stores the results to user-provided matrices
|
static void |
compute(UMat src,
UMat w) |
static void |
compute(UMat src,
UMat w,
int flags) |
static void |
compute(UMat src,
UMat w,
UMat u,
UMat vt) |
static void |
compute(UMat src,
UMat w,
UMat u,
UMat vt,
int flags) |
SVD |
getPointer(long i) |
SVD |
position(long position) |
static void |
solveZ(GpuMat src,
GpuMat dst) |
static void |
solveZ(Mat src,
Mat dst)
\brief solves an under-determined singular linear system
|
static void |
solveZ(UMat src,
UMat dst) |
Mat |
u()
\todo document
|
SVD |
u(Mat setter) |
Mat |
vt() |
SVD |
vt(Mat setter) |
Mat |
w() |
SVD |
w(Mat setter) |
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
public static final int MODIFY_A
public static final int NO_UV
public static final int FULL_UV
public SVD(Pointer p)
Pointer(Pointer)
.public SVD(long size)
Pointer.position(long)
.public SVD()
initializes an empty SVD structure
public SVD(@ByVal Mat src, int flags)
src
- decomposed matrix. The depth has to be CV_32F or CV_64F.flags
- operation flags (SVD::Flags)public SVD getPointer(long i)
getPointer
in class Pointer
@ByRef @Name(value="operator ()") public SVD apply(@ByVal Mat src, int flags)
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.
src
- decomposed matrix. The depth has to be CV_32F or CV_64F.flags
- operation flags (SVD::Flags)public static void compute(@ByVal Mat src, @ByVal Mat w, @ByVal Mat u, @ByVal Mat vt, int flags)
The methods/functions perform SVD of matrix. Unlike SVD::SVD constructor and SVD::operator(), they store the results to the user-provided matrices:
{.cpp}
Mat A, w, u, vt;
SVD::compute(A, w, u, vt);
src
- decomposed matrix. The depth has to be CV_32F or CV_64F.w
- calculated singular valuesu
- calculated left singular vectorsvt
- transposed matrix of right singular vectorsflags
- operation flags - see SVD::Flags.public static void compute(@ByVal UMat src, @ByVal UMat w, @ByVal UMat u, @ByVal UMat vt, int flags)
public static void compute(@ByVal GpuMat src, @ByVal GpuMat w, @ByVal GpuMat u, @ByVal GpuMat vt, int flags)
public static void compute(@ByVal GpuMat src, @ByVal GpuMat w, @ByVal GpuMat u, @ByVal GpuMat vt)
public static void compute(@ByVal Mat src, @ByVal Mat w, int flags)
src
- decomposed matrix. The depth has to be CV_32F or CV_64F.w
- calculated singular valuesflags
- operation flags - see SVD::Flags.public static void backSubst(@ByVal Mat w, @ByVal Mat u, @ByVal Mat vt, @ByVal Mat rhs, @ByVal Mat dst)
public static void backSubst(@ByVal UMat w, @ByVal UMat u, @ByVal UMat vt, @ByVal UMat rhs, @ByVal UMat dst)
public static void backSubst(@ByVal GpuMat w, @ByVal GpuMat u, @ByVal GpuMat vt, @ByVal GpuMat rhs, @ByVal GpuMat dst)
public static void solveZ(@ByVal Mat src, @ByVal Mat dst)
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 \|\]
src
- left-hand-side matrix.dst
- found solution.public void backSubst(@ByVal Mat rhs, @ByVal Mat dst)
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.
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.
Copyright © 2024. All rights reserved.