IVT
LinearAlgebraCV.h
Go to the documentation of this file.
1 // ****************************************************************************
2 // This file is part of the Integrating Vision Toolkit (IVT).
3 //
4 // The IVT is maintained by the Karlsruhe Institute of Technology (KIT)
5 // (www.kit.edu) in cooperation with the company Keyetech (www.keyetech.de).
6 //
7 // Copyright (C) 2014 Karlsruhe Institute of Technology (KIT).
8 // All rights reserved.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are met:
12 //
13 // 1. Redistributions of source code must retain the above copyright
14 // notice, this list of conditions and the following disclaimer.
15 //
16 // 2. Redistributions in binary form must reproduce the above copyright
17 // notice, this list of conditions and the following disclaimer in the
18 // documentation and/or other materials provided with the distribution.
19 //
20 // 3. Neither the name of the KIT nor the names of its contributors may be
21 // used to endorse or promote products derived from this software
22 // without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE KIT AND CONTRIBUTORS “AS IS” AND ANY
25 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 // DISCLAIMED. IN NO EVENT SHALL THE KIT OR CONTRIBUTORS BE LIABLE FOR ANY
28 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 // ****************************************************************************
35 // ****************************************************************************
36 // Filename: LinearAlgebraCV.h
37 // Author: Pedram Azad
38 // Date: 2005
39 // ****************************************************************************
40 
41 
42 #ifndef _LINEAR_ALGEBRA_CV_H_
43 #define _LINEAR_ALGEBRA_CV_H_
44 
45 
46 // ****************************************************************************
47 // Forward declarations
48 // ****************************************************************************
49 
50 class CFloatMatrix;
51 class CFloatVector;
52 class CDoubleMatrix;
53 class CDoubleVector;
54 struct Mat3d;
55 struct Vec2d;
56 
57 
58 
59 // ****************************************************************************
60 // LinearAlgebraCV
61 // ****************************************************************************
62 
67 namespace LinearAlgebraCV
68 {
69  // operating on CFloatMatrix and CFloatVector
70 
71  // singular value decomposition
72  void SVD(const CFloatMatrix *A, CFloatMatrix *W, CFloatMatrix *U = 0, CFloatMatrix *V = 0,
73  bool bAllowModifyA = false, bool bReturnUTransposed = false, bool bReturnVTransposed = false);
74 
75  // linear least squares
79 
80  // calculation of pseudoinverse
81  void CalculatePseudoInverseSVD(const CFloatMatrix *pInputMatrix, CFloatMatrix *pOutputMatrix);
82  void CalculatePseudoInverseSimple(const CFloatMatrix *pInputMatrix, CFloatMatrix *pResultMatrix);
83 
84  // basic operations on matrices
85  void Multiply(const CFloatMatrix *A, const CFloatMatrix *B, CFloatMatrix *pResultMatrix, bool bTransposeB = false);
86  void Invert(const CFloatMatrix *A, const CFloatMatrix *pResultMatrix);
87  void Transpose(const CFloatMatrix *A, const CFloatMatrix *pResultMatrix);
88  void SelfProduct(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix, bool bTransposeSecond = false);
89 
90  // 2d homographies
91  bool DetermineAffineTransformation(const Vec2d *pSourcePoints, const Vec2d *pTargetPoints, int nPoints, Mat3d &A, bool bUseSVD = false);
92  bool DetermineHomography(const Vec2d *pSourcePoints, const Vec2d *pTargetPoints, int nPoints, Mat3d &A, bool bUseSVD = false);
93 
94  // covariance matrix
95  void CalculateCovarianceMatrix(const CFloatMatrix *pMatrix, CFloatMatrix *pCovarianceMatrix);
96 
97  // PCA
98  void PCA(const CFloatMatrix *pData, CFloatMatrix *pTransformationMatrix, CFloatMatrix *pTransformedData, int nTargetDimension);
99  void PCA(const CFloatMatrix *pData, CFloatMatrix *pTransformationMatrix, CFloatMatrix *pEigenValues);
100 
101 
102 
103  // operating on CDoubleMatrix and CDoubleVector
104 
105  // singular value decomposition
106  void SVD(const CDoubleMatrix *A, CDoubleMatrix *W, CDoubleMatrix *U = 0, CDoubleMatrix *V = 0,
107  bool bAllowModifyA = false, bool bReturnUTransposed = false, bool bReturnVTransposed = false);
108 
109  // linear least squares
113 
114  // calculation of pseudoinverse
115  void CalculatePseudoInverseSVD(const CDoubleMatrix *pInputMatrix, CDoubleMatrix *pOutputMatrix);
116  void CalculatePseudoInverseSimple(const CDoubleMatrix *pInputMatrix, CDoubleMatrix *pResultMatrix);
117 
118  // basic operations on matrices
119  void Multiply(const CDoubleMatrix *A, const CDoubleMatrix *B, CDoubleMatrix *pResultMatrix, bool bTransposeB = false);
120  void Invert(const CDoubleMatrix *A, const CDoubleMatrix *pResultMatrix);
121  void Transpose(const CDoubleMatrix *A, const CDoubleMatrix *pResultMatrix);
122 }
123 
124 
125 
126 #endif /* _LINEAR_ALGEBRA_CV_H_ */
void SVD(const CFloatMatrix *A, CFloatMatrix *W, CFloatMatrix *U=0, CFloatMatrix *V=0, bool bAllowModifyA=false, bool bReturnUTransposed=false, bool bReturnVTransposed=false)
bool DetermineAffineTransformation(const Vec2d *pSourcePoints, const Vec2d *pTargetPoints, int nPoints, Mat3d &A, bool bUseSVD=false)
Data structure for the representation of a 2D vector.
Definition: Math2d.h:82
void SolveLinearLeastSquaresSimple(const CFloatMatrix *A, const CFloatVector *b, CFloatVector *x)
Data structure for the representation of a matrix of values of the data type double.
Definition: DoubleMatrix.h:54
void PCA(const CFloatMatrix *pData, CFloatMatrix *pTransformationMatrix, CFloatMatrix *pTransformedData, int nTargetDimension)
Data structure for the representation of a vector of values of the data type double.
Definition: DoubleVector.h:54
void SolveLinearLeastSquaresSVD(const CFloatMatrix *A, const CFloatVector *b, CFloatVector *x)
void CalculatePseudoInverseSVD(const CFloatMatrix *pInputMatrix, CFloatMatrix *pOutputMatrix)
bool DetermineHomography(const Vec2d *pSourcePoints, const Vec2d *pTargetPoints, int nPoints, Mat3d &A, bool bUseSVD=false)
void SelfProduct(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix, bool bTransposeSecond=false)
Data structure for the representation of a matrix of values of the data type float.
Definition: FloatMatrix.h:56
void SolveLinearLeastSquaresHomogeneousSVD(const CFloatMatrix *A, CFloatVector *x)
void CalculatePseudoInverseSimple(const CFloatMatrix *pInputMatrix, CFloatMatrix *pResultMatrix)
Data structure for the representation of a vector of values of the data type float.
Definition: FloatVector.h:53
Data structure for the representation of a 3x3 matrix.
Definition: Math3d.h:93
void Invert(const CFloatMatrix *A, const CFloatMatrix *pResultMatrix)
void Multiply(const CFloatMatrix *A, const CFloatMatrix *B, CFloatMatrix *pResultMatrix, bool bTransposeB=false)
void CalculateCovarianceMatrix(const CFloatMatrix *pMatrix, CFloatMatrix *pCovarianceMatrix)
void Transpose(const CFloatMatrix *A, const CFloatMatrix *pResultMatrix)