You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWATI/Include/iAlg/iAlgMath/zxAlgMatrixPsInvNew.h

45 lines
896 B
C++

#pragma once
#include "Defines.h"
#include "iAlgMath_global.h"
// 矩阵伪逆求解方法之一:稳定性有待进一步测试验证
// 作者:地大学生 wangjr
//无法计算奇异矩阵
//6*7规模计算误差平均约1.0
//100*90规模计算误差平均约0.3
//200*90规模计算误差平均约为0.015
class I_ALGMATH_EXPORT zxAlgMatrixPsInvNew
{
public:
zxAlgMatrixPsInvNew();
~zxAlgMatrixPsInvNew();
#ifdef QT_DEBUG
void test();
#endif
public:
// 计算伪逆矩阵
VVecDouble pseudoInverse(VVecDouble& A);
private:
// 计算矩阵的转置
void transpose(const VVecDouble& src, VVecDouble& dst);
// 计算矩阵乘法 result = A * B
void matrixMultiply(const VVecDouble& A, const VVecDouble& B, \
VVecDouble& result);
// 计算矩阵的逆(仅限方阵,且假定可逆)
bool matrixInverse(const VVecDouble& src, VVecDouble& dst);
// 打印矩阵
void printMatrix(const VVecDouble& matrix);
};