Struct SVD

Source
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

Source

pub fn default() -> Result<SVD>

the default constructor

initializes an empty SVD structure

Source

pub fn new(src: &impl ToInputArray, flags: i32) -> Result<SVD>

the default constructor

initializes an empty SVD structure

§Overloaded parameters

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)
§C++ default parameters
  • flags: 0
Source

pub fn new_def(src: &impl ToInputArray) -> Result<SVD>

@overload 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)
§Note

This alternative version of [new] function uses the following default values for its arguments:

  • flags: 0
Source

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
Source

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
Source

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
Source

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
Source

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

Source

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: block formula

§Parameters
  • src: left-hand-side matrix.
  • dst: found solution.

Trait Implementations§

Source§

impl Boxed for SVD

Source§

unsafe fn from_raw(ptr: <SVD as OpenCVFromExtern>::ExternReceive) -> Self

Wrap the specified raw pointer Read more
Source§

fn into_raw(self) -> <SVD as OpenCVTypeExternContainer>::ExternSendMut

Return the underlying raw pointer while consuming this wrapper. Read more
Source§

fn as_raw(&self) -> <SVD as OpenCVTypeExternContainer>::ExternSend

Return the underlying raw pointer. Read more
Source§

fn as_raw_mut(&mut self) -> <SVD as OpenCVTypeExternContainer>::ExternSendMut

Return the underlying mutable raw pointer Read more
Source§

impl Debug for SVD

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for SVD

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl SVDTrait for SVD

Source§

fn as_raw_mut_SVD(&mut self) -> *mut c_void

Source§

fn set_u(&mut self, val: Mat)

Source§

fn set_w(&mut self, val: Mat)

Source§

fn set_vt(&mut self, val: Mat)

Source§

fn apply(&mut self, src: &impl ToInputArray, flags: i32) -> Result<SVD>

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

fn apply_def(&mut self, src: &impl ToInputArray) -> Result<SVD>

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

impl SVDTraitConst for SVD

Source§

fn as_raw_SVD(&self) -> *const c_void

Source§

fn u(&self) -> Mat

Source§

fn w(&self) -> Mat

Source§

fn vt(&self) -> Mat

Source§

fn back_subst( &self, rhs: &impl ToInputArray, dst: &mut impl ToOutputArray, ) -> Result<()>

performs a singular value back substitution. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Mat> ModifyInplace for Mat
where Mat: Boxed,

Source§

unsafe fn modify_inplace<Res>( &mut self, f: impl FnOnce(&Mat, &mut Mat) -> Res, ) -> Res

Helper function to call OpenCV functions that allow in-place modification of a 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.