HALCON Reference Manual 10.0.2
Table of Contents / Matrix / Decomposition ClassesClassesClasses | | | Operators

svd_matrixsvd_matrixsvd_matrixSvdMatrixSvdMatrix (Operator)

Name

svd_matrixsvd_matrixsvd_matrixSvdMatrixSvdMatrix — Compute the singular value decomposition of a matrix.

Signature

svd_matrix( : : MatrixID, SVDType, ComputeSingularVectors : MatrixUID, MatrixSID, MatrixVID)

Herror svd_matrix(const Hlong MatrixID, const char* SVDType, const char* ComputeSingularVectors, Hlong* MatrixUID, Hlong* MatrixSID, Hlong* MatrixVID)

Herror T_svd_matrix(const Htuple MatrixID, const Htuple SVDType, const Htuple ComputeSingularVectors, Htuple* MatrixUID, Htuple* MatrixSID, Htuple* MatrixVID)

Herror svd_matrix(const HTuple& MatrixID, const HTuple& SVDType, const HTuple& ComputeSingularVectors, Hlong* MatrixUID, Hlong* MatrixSID, Hlong* MatrixVID)

HMatrix HMatrix::SvdMatrix(const HTuple& SVDType, const HTuple& ComputeSingularVectors, HMatrix* MatrixSID, HMatrix* MatrixVID) const

void HOperatorSetX.SvdMatrix(
[in] VARIANT MatrixID, [in] VARIANT SVDType, [in] VARIANT ComputeSingularVectors, [out] VARIANT* MatrixUID, [out] VARIANT* MatrixSID, [out] VARIANT* MatrixVID)

IHMatrixX* HMatrixX.SvdMatrix(
[in] BSTR SVDType, [in] BSTR ComputeSingularVectors, [out] IHMatrixX*MatrixSID, [out] IHMatrixX*MatrixVID)

static void HOperatorSet.SvdMatrix(HTuple matrixID, HTuple SVDType, HTuple computeSingularVectors, out HTuple matrixUID, out HTuple matrixSID, out HTuple matrixVID)

HMatrix HMatrix.SvdMatrix(string SVDType, string computeSingularVectors, out HMatrix matrixSID, out HMatrix matrixVID)

Description

The operator svd_matrixsvd_matrixsvd_matrixSvdMatrixSvdMatrix computes a full or reduced singular value decomposition (SVD) of the MatrixMatrixMatrixMatrixmatrix defined by the matrix handle MatrixIDMatrixIDMatrixIDMatrixIDmatrixID. The operator returns the matrix handle MatrixSIDMatrixSIDMatrixSIDMatrixSIDmatrixSID of the matrix MatrixSMatrixSMatrixSMatrixSmatrixS with singular values in descending order. Optionally, the matrices MatrixUMatrixUMatrixUMatrixUmatrixU with the left and MatrixVMatrixVMatrixVMatrixVmatrixV with the right singular vectors are computed and the matrix handles MatrixUIDMatrixUIDMatrixUIDMatrixUIDmatrixUID and MatrixVIDMatrixVIDMatrixVIDMatrixVIDmatrixVID are returned. Access to the elements of the matrices is possible e.g. with the operator get_full_matrixget_full_matrixget_full_matrixGetFullMatrixGetFullMatrix. The SVD is written

  Matrix = MatrixU * MatrixS * MatrixV^T.

For SVDTypeSVDTypeSVDTypeSVDTypeSVDType = 'full'"full""full""full""full", a full SVD is computed.

Example:


           /  6.0  -5.0  \
  Matrix = | 10.0   4.0  |
           \ -3.0   5.0  /

  SVDType = 'full'     ComputeSingularVectors = 'both'

               / -0.5228   0.5691   0.6346 \              / 12.0547   0    \
  -> MatrixU = | -0.8070  -0.5702  -0.1535 |    MatrixS = |    0    8.1046 |
               \  0.2745  -0.5924   0.7574 /              \    0      0    /

               / -0.9980  -0.0629 \
     MatrixV = \  0.0629  -0.9980 /

For SVDTypeSVDTypeSVDTypeSVDTypeSVDType = 'reduced'"reduced""reduced""reduced""reduced", a reduced SVD is computed.

Example:


           /  6.0  -5.0  \
  Matrix = | 10.0   4.0  |
           \ -3.0   5.0  /

  SVDType = 'reduced'     ComputeSingularVectors = 'both'

               / -0.5228   0.5691 \              / 12.0547   0    \
  -> MatrixU = | -0.8070  -0.5702 |    MatrixS = \    0    8.1046 /
               \  0.2745  -0.5924 /

               / -0.9980  -0.0629 \
     MatrixV = \  0.0629  -0.9980 /

For ComputeSingularVectorsComputeSingularVectorsComputeSingularVectorsComputeSingularVectorscomputeSingularVectors = 'left'"left""left""left""left", the matrix MatrixUMatrixUMatrixUMatrixUmatrixU with the left singular vectors is computed. For ComputeSingularVectorsComputeSingularVectorsComputeSingularVectorsComputeSingularVectorscomputeSingularVectors = 'right'"right""right""right""right", the matrix MatrixVMatrixVMatrixVMatrixVmatrixV with the right singular vectors is computed. For ComputeSingularVectorsComputeSingularVectorsComputeSingularVectorsComputeSingularVectorscomputeSingularVectors = 'both'"both""both""both""both", the matrices MatrixUMatrixUMatrixUMatrixUmatrixU and MatrixVMatrixVMatrixVMatrixVmatrixV with the left and right singular vectors are computed.

For ComputeSingularVectorsComputeSingularVectorsComputeSingularVectorsComputeSingularVectorscomputeSingularVectors = 'none'"none""none""none""none", no matrices with the singular vectors are computed. The matrix MatrixSMatrixSMatrixSMatrixSmatrixS is a matrix with n rows and one columns, where the number n = min(number of rows of the input MatrixMatrixMatrixMatrixmatrix, number of columns of the input MatrixMatrixMatrixMatrixmatrix).

Example:


           /  6.0  -5.0  \
  Matrix = | 10.0   4.0  |
           \ -3.0   5.0  /

  SVDType = 'reduced' or 'full'     ComputeSingularVectors = 'none'

               / 12.0547 \
  -> MatrixS = \  8.1046 /

It should be noted that in the examples there are differences in the meaning of the values of the output matrices: If a value is shown as an integer number, e.g., 0 or 1, the value of this element is per definition this certain value. If the number is shown as a floating point number, e.g., 0.0 or 1.0, the value is computed by the operator.

Parallelization

Parameters

MatrixIDMatrixIDMatrixIDMatrixIDmatrixID (input_control)  matrix HMatrix, HTupleHMatrix, HTupleHMatrixX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong)

Matrix handle of the input matrix.

SVDTypeSVDTypeSVDTypeSVDTypeSVDType (input_control)  string HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Type of computation.

Default value: 'full' "full" "full" "full" "full"

List of values: 'full'"full""full""full""full", 'reduced'"reduced""reduced""reduced""reduced"

ComputeSingularVectorsComputeSingularVectorsComputeSingularVectorsComputeSingularVectorscomputeSingularVectors (input_control)  string HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Computation of singular values.

Default value: 'both' "both" "both" "both" "both"

List of values: 'none'"none""none""none""none", 'left'"left""left""left""left", 'right'"right""right""right""right", 'both'"both""both""both""both"

MatrixUIDMatrixUIDMatrixUIDMatrixUIDmatrixUID (output_control)  matrix HMatrix, HTupleHMatrix, HTupleHMatrixX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong)

Matrix handle with the left singular vectors.

MatrixSIDMatrixSIDMatrixSIDMatrixSIDmatrixSID (output_control)  matrix HMatrix, HTupleHMatrix, HTupleHMatrixX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong)

Matrix handle with singular values.

MatrixVIDMatrixVIDMatrixVIDMatrixVIDmatrixVID (output_control)  matrix HMatrix, HTupleHMatrix, HTupleHMatrixX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong)

Matrix handle with the right singular vectors.

Result

If the parameters are valid, the operator svd_matrixsvd_matrixsvd_matrixSvdMatrixSvdMatrix returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Possible Predecessors

create_matrixcreate_matrixcreate_matrixCreateMatrixCreateMatrix

Possible Successors

get_full_matrixget_full_matrixget_full_matrixGetFullMatrixGetFullMatrix, get_value_matrixget_value_matrixget_value_matrixGetValueMatrixGetValueMatrix

References

David Poole: “Linear Algebra: A Modern Introduction”; Thomson; Belmont; 2006.
Gene H. Golub, Charles F. van Loan: “Matrix Computations”; The Johns Hopkins University Press; Baltimore and London; 1996.

Module

Foundation


Table of Contents / Matrix / Decomposition ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH