LinearAlgebra.h
Go to the documentation of this file.
00001 // ****************************************************************************
00002 // This file is part of the Integrating Vision Toolkit (IVT).
00003 //
00004 // The IVT is maintained by the Karlsruhe Institute of Technology (KIT)
00005 // (www.kit.edu) in cooperation with the company Keyetech (www.keyetech.de).
00006 //
00007 // Copyright (C) 2014 Karlsruhe Institute of Technology (KIT).
00008 // All rights reserved.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are met:
00012 //
00013 // 1. Redistributions of source code must retain the above copyright
00014 //    notice, this list of conditions and the following disclaimer.
00015 //
00016 // 2. Redistributions in binary form must reproduce the above copyright
00017 //    notice, this list of conditions and the following disclaimer in the
00018 //    documentation and/or other materials provided with the distribution.
00019 //
00020 // 3. Neither the name of the KIT nor the names of its contributors may be
00021 //    used to endorse or promote products derived from this software
00022 //    without specific prior written permission.
00023 //
00024 // THIS SOFTWARE IS PROVIDED BY THE KIT AND CONTRIBUTORS “AS IS” AND ANY
00025 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00026 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027 // DISCLAIMED. IN NO EVENT SHALL THE KIT OR CONTRIBUTORS BE LIABLE FOR ANY
00028 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00029 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00031 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00033 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 // ****************************************************************************
00035 
00036 
00040 #ifndef _LINEAR_ALGEBRA_H_
00041 #define _LINEAR_ALGEBRA_H_
00042 
00043 // ****************************************************************************
00044 // Forward declarations
00045 // ****************************************************************************
00046 
00047 class CFloatMatrix;
00048 class CFloatVector;
00049 class CDoubleMatrix;
00050 class CDoubleVector;
00051 struct Mat3d;
00052 struct Vec2d;
00053 
00054 
00055 
00056 // ****************************************************************************
00057 // LinearAlgebra
00058 // ****************************************************************************
00059 
00064 namespace LinearAlgebra
00065 {
00066         // operating on CFloatMatrix and CFloatVector
00067         void Zero(CFloatMatrix *pMatrix);
00068         void Zero(CFloatVector *pVector);
00069         
00070         void SelfProduct(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix, bool AAT = false);
00071         void MulMatMat(const CFloatMatrix *A, const CFloatMatrix *B, CFloatMatrix *pResultMatrix, bool bTransposeB = false);
00072         void Transpose(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix);
00073 
00074         void MulMatVec(const CFloatMatrix *pMatrix, const CFloatVector *pVector, CFloatVector *pResultVector);
00075         void MulMatVec(const CFloatMatrix *pMatrix, const CFloatVector *pVector1, const CFloatVector *pVector2, CFloatVector *pResultVector);
00076 
00077         void AddMatMat(const CFloatMatrix *pMatrix1, const CFloatMatrix *pMatrix2, CFloatMatrix *pResultMatrix);
00078         void SubtractMatMat(const CFloatMatrix *pMatrix1, const CFloatMatrix *pMatrix2, CFloatMatrix *pResultMatrix);
00079         void AddVecVec(const CFloatVector *pVector1, const CFloatVector *pVector2, CFloatVector *pResultVector);
00080         void SubtractVecVec(const CFloatVector *pVector1, const CFloatVector *pVector2, CFloatVector *pResultVector);
00081         
00082         void AddToMat(CFloatMatrix *pMatrix, const CFloatMatrix *pMatrixToAdd);
00083         void SubtractFromMat(CFloatMatrix *pMatrix, const CFloatMatrix *pMatrixToSubtract);
00084         void AddToVec(CFloatVector *pVector, const CFloatVector *pVectorToAdd);
00085         void SubtractFromVec(CFloatVector *pVector, const CFloatVector *pVectorToSubtract);
00086         
00087         void SubtractMeanFromColumns(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix);
00088         void SubtractMeanFromRows(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix);
00089 
00090         extern void SVD(const CFloatMatrix *A, CFloatMatrix *W, CFloatMatrix *U = 0, CFloatMatrix *V = 0,
00091                 bool bAllowModifyA = false, bool bReturnUTransposed = false, bool bReturnVTransposed = false);
00092 
00093         // linear least squares
00094         bool SolveLinearLeastSquaresSimple(const CFloatMatrix *A, const CFloatVector *b, CFloatVector *x);
00095         void SolveLinearLeastSquaresSVD(const CFloatMatrix *A, const CFloatVector *b, CFloatVector *x);
00096         void SolveLinearLeastSquaresHomogeneousSVD(const CFloatMatrix *A, CFloatVector *x);
00097                 
00098         // calculation of pseudoinverse
00099         void CalculatePseudoInverseSVD(const CFloatMatrix *pInputMatrix, CFloatMatrix *pOutputMatrix);
00100         bool CalculatePseudoInverseSimple(const CFloatMatrix *pInputMatrix, CFloatMatrix *pResultMatrix);
00101 
00102         // calculation of inverse
00103         bool Invert(const CFloatMatrix *pInputMatrix, CFloatMatrix *pResultMatrix);
00104 
00105         // PCA
00106         void PCA(const CFloatMatrix *pData, CFloatMatrix *pTransformationMatrix, CFloatMatrix *pTransformedData, int nTargetDimension);
00107         void PCA(const CFloatMatrix *pData, CFloatMatrix *pTransformationMatrix, CFloatMatrix *pEigenValues);
00108 
00109 
00110         // operating on CDoubleMatrix and CDoubleVector
00111         void Zero(CDoubleMatrix *pMatrix);
00112         void Zero(CDoubleVector *pVector);
00113         
00114         void SelfProduct(const CDoubleMatrix *pMatrix, CDoubleMatrix *pResultMatrix, bool AAT = false);
00115         void MulMatMat(const CDoubleMatrix *pMatrix1, const CDoubleMatrix *pMatrix2, CDoubleMatrix *pResultMatrix, bool bTransposeB = false);
00116         void Transpose(const CDoubleMatrix *pMatrix, CDoubleMatrix *pResultMatrix);
00117 
00118         void MulMatVec(const CDoubleMatrix *pMatrix, const CDoubleVector *pVector, CDoubleVector *pResultVector);
00119         void MulMatVec(const CDoubleMatrix *pMatrix, const CDoubleVector *pVector1, const CDoubleVector *pVector2, CDoubleVector *pResultVector);
00120 
00121         void AddMatMat(const CDoubleMatrix *pMatrix1, const CDoubleMatrix *pMatrix2, CDoubleMatrix *pResultMatrix);
00122         void SubtractMatMat(const CDoubleMatrix *pMatrix1, const CDoubleMatrix *pMatrix2, CDoubleMatrix *pResultMatrix);
00123         void AddVecVec(const CDoubleVector *pVector1, const CDoubleVector *pVector2, CDoubleVector *pResultVector);
00124         void SubtractVecVec(const CDoubleVector *pVector1, const CDoubleVector *pVector2, CDoubleVector *pResultVector);
00125         
00126         void AddToMat(CDoubleMatrix *pMatrix, const CDoubleMatrix *pMatrixToAdd);
00127         void SubtractFromMat(CDoubleMatrix *pMatrix, const CDoubleMatrix *pMatrixToSubtract);
00128         void AddToVec(CDoubleVector *pVector, const CDoubleVector *pVectorToAdd);
00129         void SubtractFromVec(CDoubleVector *pVector, const CDoubleVector *pVectorToSubtract);
00130         
00131         void SubtractMeanFromColumns(const CDoubleMatrix *pMatrix, CDoubleMatrix *pResultMatrix);
00132         void SubtractMeanFromRows(const CDoubleMatrix *pMatrix, CDoubleMatrix *pResultMatrix);
00133 
00134         extern void SVD(const CDoubleMatrix *A, CDoubleMatrix *W, CDoubleMatrix *U = 0, CDoubleMatrix *V = 0,
00135                 bool bAllowModifyA = false, bool bReturnUTransposed = false, bool bReturnVTransposed = false);
00136 
00137         // linear least squares
00138         bool SolveLinearLeastSquaresSimple(const CDoubleMatrix *A, const CDoubleVector *b, CDoubleVector *x);
00139         void SolveLinearLeastSquaresSVD(const CDoubleMatrix *A, const CDoubleVector *b, CDoubleVector *x);
00140         void SolveLinearLeastSquaresHomogeneousSVD(const CDoubleMatrix *A, CDoubleVector *x);
00141                 
00142         // calculation of pseudoinverse
00143         void CalculatePseudoInverseSVD(const CDoubleMatrix *pInputMatrix, CDoubleMatrix *pOutputMatrix);
00144         bool CalculatePseudoInverseSimple(const CDoubleMatrix *pInputMatrix, CDoubleMatrix *pResultMatrix);
00145 
00146         // calculation of inverse
00147         bool Invert(const CDoubleMatrix *pInputMatrix, CDoubleMatrix *pResultMatrix);
00148 
00149 
00150 
00151         // 2d homographies
00152 
00180         bool DetermineAffineTransformation(const Vec2d *pSourcePoints, const Vec2d *pTargetPoints, int nPoints, Mat3d &A, bool bUseSVD = false);
00181 
00209         bool DetermineHomography(const Vec2d *pSourcePoints, const Vec2d *pTargetPoints, int nPoints, Mat3d &A, bool bUseSVD = false);
00210 }
00211 
00212 
00213 
00214 #endif /* _LINEAR_ALGEBRA_H_ */


asr_ivt
Author(s): Allgeyer Tobias, Hutmacher Robin, Kleinert Daniel, Meißner Pascal, Scholz Jonas, Stöckle Patrick
autogenerated on Thu Jun 6 2019 21:46:57