LinearAlgebra.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 
40 #ifndef _LINEAR_ALGEBRA_H_
41 #define _LINEAR_ALGEBRA_H_
42 
43 // ****************************************************************************
44 // Forward declarations
45 // ****************************************************************************
46 
47 class CFloatMatrix;
48 class CFloatVector;
49 class CDoubleMatrix;
50 class CDoubleVector;
51 struct Mat3d;
52 struct Vec2d;
53 
54 
55 
56 // ****************************************************************************
57 // LinearAlgebra
58 // ****************************************************************************
59 
64 namespace LinearAlgebra
65 {
66  // operating on CFloatMatrix and CFloatVector
67  void Zero(CFloatMatrix *pMatrix);
68  void Zero(CFloatVector *pVector);
69 
70  void SelfProduct(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix, bool AAT = false);
71  void MulMatMat(const CFloatMatrix *A, const CFloatMatrix *B, CFloatMatrix *pResultMatrix, bool bTransposeB = false);
72  void Transpose(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix);
73 
74  void MulMatVec(const CFloatMatrix *pMatrix, const CFloatVector *pVector, CFloatVector *pResultVector);
75  void MulMatVec(const CFloatMatrix *pMatrix, const CFloatVector *pVector1, const CFloatVector *pVector2, CFloatVector *pResultVector);
76 
77  void AddMatMat(const CFloatMatrix *pMatrix1, const CFloatMatrix *pMatrix2, CFloatMatrix *pResultMatrix);
78  void SubtractMatMat(const CFloatMatrix *pMatrix1, const CFloatMatrix *pMatrix2, CFloatMatrix *pResultMatrix);
79  void AddVecVec(const CFloatVector *pVector1, const CFloatVector *pVector2, CFloatVector *pResultVector);
80  void SubtractVecVec(const CFloatVector *pVector1, const CFloatVector *pVector2, CFloatVector *pResultVector);
81 
82  void AddToMat(CFloatMatrix *pMatrix, const CFloatMatrix *pMatrixToAdd);
83  void SubtractFromMat(CFloatMatrix *pMatrix, const CFloatMatrix *pMatrixToSubtract);
84  void AddToVec(CFloatVector *pVector, const CFloatVector *pVectorToAdd);
85  void SubtractFromVec(CFloatVector *pVector, const CFloatVector *pVectorToSubtract);
86 
87  void SubtractMeanFromColumns(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix);
88  void SubtractMeanFromRows(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix);
89 
90  extern void SVD(const CFloatMatrix *A, CFloatMatrix *W, CFloatMatrix *U = 0, CFloatMatrix *V = 0,
91  bool bAllowModifyA = false, bool bReturnUTransposed = false, bool bReturnVTransposed = false);
92 
93  // linear least squares
97 
98  // calculation of pseudoinverse
99  void CalculatePseudoInverseSVD(const CFloatMatrix *pInputMatrix, CFloatMatrix *pOutputMatrix);
100  bool CalculatePseudoInverseSimple(const CFloatMatrix *pInputMatrix, CFloatMatrix *pResultMatrix);
101 
102  // calculation of inverse
103  bool Invert(const CFloatMatrix *pInputMatrix, CFloatMatrix *pResultMatrix);
104 
105  // PCA
106  void PCA(const CFloatMatrix *pData, CFloatMatrix *pTransformationMatrix, CFloatMatrix *pTransformedData, int nTargetDimension);
107  void PCA(const CFloatMatrix *pData, CFloatMatrix *pTransformationMatrix, CFloatMatrix *pEigenValues);
108 
109 
110  // operating on CDoubleMatrix and CDoubleVector
111  void Zero(CDoubleMatrix *pMatrix);
112  void Zero(CDoubleVector *pVector);
113 
114  void SelfProduct(const CDoubleMatrix *pMatrix, CDoubleMatrix *pResultMatrix, bool AAT = false);
115  void MulMatMat(const CDoubleMatrix *pMatrix1, const CDoubleMatrix *pMatrix2, CDoubleMatrix *pResultMatrix, bool bTransposeB = false);
116  void Transpose(const CDoubleMatrix *pMatrix, CDoubleMatrix *pResultMatrix);
117 
118  void MulMatVec(const CDoubleMatrix *pMatrix, const CDoubleVector *pVector, CDoubleVector *pResultVector);
119  void MulMatVec(const CDoubleMatrix *pMatrix, const CDoubleVector *pVector1, const CDoubleVector *pVector2, CDoubleVector *pResultVector);
120 
121  void AddMatMat(const CDoubleMatrix *pMatrix1, const CDoubleMatrix *pMatrix2, CDoubleMatrix *pResultMatrix);
122  void SubtractMatMat(const CDoubleMatrix *pMatrix1, const CDoubleMatrix *pMatrix2, CDoubleMatrix *pResultMatrix);
123  void AddVecVec(const CDoubleVector *pVector1, const CDoubleVector *pVector2, CDoubleVector *pResultVector);
124  void SubtractVecVec(const CDoubleVector *pVector1, const CDoubleVector *pVector2, CDoubleVector *pResultVector);
125 
126  void AddToMat(CDoubleMatrix *pMatrix, const CDoubleMatrix *pMatrixToAdd);
127  void SubtractFromMat(CDoubleMatrix *pMatrix, const CDoubleMatrix *pMatrixToSubtract);
128  void AddToVec(CDoubleVector *pVector, const CDoubleVector *pVectorToAdd);
129  void SubtractFromVec(CDoubleVector *pVector, const CDoubleVector *pVectorToSubtract);
130 
131  void SubtractMeanFromColumns(const CDoubleMatrix *pMatrix, CDoubleMatrix *pResultMatrix);
132  void SubtractMeanFromRows(const CDoubleMatrix *pMatrix, CDoubleMatrix *pResultMatrix);
133 
134  extern void SVD(const CDoubleMatrix *A, CDoubleMatrix *W, CDoubleMatrix *U = 0, CDoubleMatrix *V = 0,
135  bool bAllowModifyA = false, bool bReturnUTransposed = false, bool bReturnVTransposed = false);
136 
137  // linear least squares
141 
142  // calculation of pseudoinverse
143  void CalculatePseudoInverseSVD(const CDoubleMatrix *pInputMatrix, CDoubleMatrix *pOutputMatrix);
144  bool CalculatePseudoInverseSimple(const CDoubleMatrix *pInputMatrix, CDoubleMatrix *pResultMatrix);
145 
146  // calculation of inverse
147  bool Invert(const CDoubleMatrix *pInputMatrix, CDoubleMatrix *pResultMatrix);
148 
149 
150 
151  // 2d homographies
152 
180  bool DetermineAffineTransformation(const Vec2d *pSourcePoints, const Vec2d *pTargetPoints, int nPoints, Mat3d &A, bool bUseSVD = false);
181 
209  bool DetermineHomography(const Vec2d *pSourcePoints, const Vec2d *pTargetPoints, int nPoints, Mat3d &A, bool bUseSVD = false);
210 }
211 
212 
213 
214 #endif /* _LINEAR_ALGEBRA_H_ */
void SubtractFromMat(CFloatMatrix *pMatrix, const CFloatMatrix *pMatrixToSubtract)
bool DetermineHomography(const Vec2d *pSourcePoints, const Vec2d *pTargetPoints, int nPoints, Mat3d &A, bool bUseSVD=false)
Determines a homography based on a set of 2d-2d point correspondences.
void AddToMat(CFloatMatrix *pMatrix, const CFloatMatrix *pMatrixToAdd)
void SolveLinearLeastSquaresHomogeneousSVD(const CFloatMatrix *A, CFloatVector *x)
bool CalculatePseudoInverseSimple(const CFloatMatrix *pInputMatrix, CFloatMatrix *pResultMatrix)
void SolveLinearLeastSquaresSVD(const CFloatMatrix *A, const CFloatVector *b, CFloatVector *x)
Data structure for the representation of a vector of values of the data type double.
Definition: DoubleVector.h:54
void PCA(const CFloatMatrix *pData, CFloatMatrix *pTransformationMatrix, CFloatMatrix *pTransformedData, int nTargetDimension)
void SubtractFromVec(CFloatVector *pVector, const CFloatVector *pVectorToSubtract)
void AddVecVec(const CFloatVector *pVector1, const CFloatVector *pVector2, CFloatVector *pResultVector)
void SVD(const CFloatMatrix *A, CFloatMatrix *W, CFloatMatrix *U=0, CFloatMatrix *V=0, bool bAllowModifyA=false, bool bReturnUTransposed=false, bool bReturnVTransposed=false)
Definition: SVD.cpp:1660
GLenum GLint x
Definition: glext.h:3125
bool DetermineAffineTransformation(const Vec2d *pSourcePoints, const Vec2d *pTargetPoints, int nPoints, Mat3d &A, bool bUseSVD=false)
Determines an affine transformation based on a set of 2d-2d point correspondences.
Data structure for the representation of a matrix of values of the data type float.
Definition: FloatMatrix.h:56
void SubtractMeanFromRows(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix)
void AddMatMat(const CFloatMatrix *pMatrix1, const CFloatMatrix *pMatrix2, CFloatMatrix *pResultMatrix)
void SubtractMeanFromColumns(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix)
void MulMatVec(const CFloatMatrix *pMatrix, const CFloatVector *pVector, CFloatVector *pResultVector)
Mathematic functions operating on the data types CFloatMatrix, CFloatVector, CDoubleMatrix, and CDoubleVector.
Definition: LinearAlgebra.h:64
bool Invert(const CFloatMatrix *pInputMatrix, CFloatMatrix *pResultMatrix)
void MulMatMat(const CFloatMatrix *A, const CFloatMatrix *B, CFloatMatrix *pResultMatrix, bool bTransposeB=false)
GLubyte GLubyte b
Definition: glext.h:5166
void Zero(CFloatMatrix *pMatrix)
void CalculatePseudoInverseSVD(const CFloatMatrix *pInputMatrix, CFloatMatrix *pOutputMatrix)
Data structure for the representation of a vector of values of the data type float.
Definition: FloatVector.h:53
bool SolveLinearLeastSquaresSimple(const CFloatMatrix *A, const CFloatVector *b, CFloatVector *x)
Data structure for the representation of a 2D vector.
Definition: Math2d.h:82
void SelfProduct(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix, bool AAT=false)
Data structure for the representation of a matrix of values of the data type double.
Definition: DoubleMatrix.h:54
void Transpose(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix)
void SubtractMatMat(const CFloatMatrix *pMatrix1, const CFloatMatrix *pMatrix2, CFloatMatrix *pResultMatrix)
void AddToVec(CFloatVector *pVector, const CFloatVector *pVectorToAdd)
void SubtractVecVec(const CFloatVector *pVector1, const CFloatVector *pVector2, CFloatVector *pResultVector)
Data structure for the representation of a 3x3 matrix.
Definition: Math3d.h:93


asr_ivt
Author(s): Allgeyer Tobias, Hutmacher Robin, Kleinert Daniel, Meißner Pascal, Scholz Jonas, Stöckle Patrick
autogenerated on Mon Dec 2 2019 03:47:28