pub struct SVD { /* private fields */ }
Expand 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
Implementations§
Source§impl SVD
impl SVD
Sourcepub fn new_def(src: &impl ToInputArray) -> Result<SVD>
pub fn new_def(src: &impl ToInputArray) -> Result<SVD>
Sourcepub fn compute_ext(
src: &impl ToInputArray,
w: &mut impl ToOutputArray,
u: &mut impl ToOutputArray,
vt: &mut impl ToOutputArray,
flags: i32,
) -> Result<()>
pub fn compute_ext( src: &impl ToInputArray, w: &mut impl ToOutputArray, u: &mut impl ToOutputArray, vt: &mut impl ToOutputArray, flags: i32, ) -> Result<()>
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.
§C++ default parameters
- flags: 0
Sourcepub fn compute_ext_def(
src: &impl ToInputArray,
w: &mut impl ToOutputArray,
u: &mut impl ToOutputArray,
vt: &mut impl ToOutputArray,
) -> Result<()>
pub fn compute_ext_def( src: &impl ToInputArray, w: &mut impl ToOutputArray, u: &mut impl ToOutputArray, vt: &mut impl ToOutputArray, ) -> Result<()>
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.
§Note
This alternative version of SVD::compute_ext function uses the following default values for its arguments:
- flags: 0
Sourcepub fn compute(
src: &impl ToInputArray,
w: &mut impl ToOutputArray,
flags: i32,
) -> Result<()>
pub fn compute( src: &impl ToInputArray, w: &mut impl ToOutputArray, flags: i32, ) -> Result<()>
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.
§Overloaded parameters
computes singular values of a matrix
- src: decomposed matrix. The depth has to be CV_32F or CV_64F.
- w: calculated singular values
- flags: operation flags - see SVD::Flags.
§C++ default parameters
- flags: 0
Sourcepub fn compute_def(
src: &impl ToInputArray,
w: &mut impl ToOutputArray,
) -> Result<()>
pub fn compute_def( src: &impl ToInputArray, w: &mut impl ToOutputArray, ) -> Result<()>
@overload 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.
§Note
This alternative version of SVD::compute function uses the following default values for its arguments:
- flags: 0
Sourcepub fn back_subst_multi(
w: &impl ToInputArray,
u: &impl ToInputArray,
vt: &impl ToInputArray,
rhs: &impl ToInputArray,
dst: &mut impl ToOutputArray,
) -> Result<()>
pub fn back_subst_multi( w: &impl ToInputArray, u: &impl ToInputArray, vt: &impl ToInputArray, rhs: &impl ToInputArray, dst: &mut impl ToOutputArray, ) -> Result<()>
performs back substitution
Sourcepub fn solve_z(
src: &impl ToInputArray,
dst: &mut impl ToOutputArray,
) -> Result<()>
pub fn solve_z( src: &impl ToInputArray, dst: &mut impl ToOutputArray, ) -> Result<()>
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:
§Parameters
- src: left-hand-side matrix.
- dst: found solution.
Trait Implementations§
Source§impl Boxed for SVD
impl Boxed for SVD
Source§unsafe fn from_raw(ptr: <SVD as OpenCVFromExtern>::ExternReceive) -> Self
unsafe fn from_raw(ptr: <SVD as OpenCVFromExtern>::ExternReceive) -> Self
Source§fn into_raw(self) -> <SVD as OpenCVTypeExternContainer>::ExternSendMut
fn into_raw(self) -> <SVD as OpenCVTypeExternContainer>::ExternSendMut
Source§fn as_raw(&self) -> <SVD as OpenCVTypeExternContainer>::ExternSend
fn as_raw(&self) -> <SVD as OpenCVTypeExternContainer>::ExternSend
Source§fn as_raw_mut(&mut self) -> <SVD as OpenCVTypeExternContainer>::ExternSendMut
fn as_raw_mut(&mut self) -> <SVD as OpenCVTypeExternContainer>::ExternSendMut
Source§impl SVDTrait for SVD
impl SVDTrait for SVD
fn as_raw_mut_SVD(&mut self) -> *mut c_void
fn set_u(&mut self, val: Mat)
fn set_w(&mut self, val: Mat)
fn set_vt(&mut self, val: Mat)
Source§impl SVDTraitConst for SVD
impl SVDTraitConst for SVD
impl Send for SVD
Auto Trait Implementations§
impl Freeze for SVD
impl RefUnwindSafe for SVD
impl !Sync for SVD
impl Unpin for SVD
impl UnwindSafe for SVD
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
Source§unsafe fn modify_inplace<Res>(
&mut self,
f: impl FnOnce(&Mat, &mut Mat) -> Res,
) -> Res
unsafe fn modify_inplace<Res>( &mut self, f: impl FnOnce(&Mat, &mut Mat) -> Res, ) -> Res
Mat
or another similar object. By passing
a mutable reference to the Mat
to this function your closure will get called with the read reference and a write references
to the same Mat
. This is unsafe in a general case as it leads to having non-exclusive mutable access to the internal data,
but it can be useful for some performance sensitive operations. One example of an OpenCV function that allows such in-place
modification is imgproc::threshold
. Read more