?? le_linearleastsquaregeneralizedinverse.cpp
字號:
//LE_LinearLeastSquareGeneralizedInverse.cpp
//求解線性最小二乘問題的廣義逆法
#include <iostream> //輸入輸出流頭文件
#include "LinearEquation.h" //線性方程(組)求解頭文件
void main()
{
int i;
double a[4][3] =
{
{ 1.0, 1.0, -1.0},
{ 2.0, 1.0, 0.0},
{ 1.0, -1.0, 0.0},
{-1.0, 2.0, 1.0}
};
matrix<double> ta(&a[0][0], 4, 3);
double b[4] = {2.0, -3.0, 1.0, 4.0};
valarray<double> bb(b, 4);
valarray<double> xx(3);
matrix<double> taa(3, 4);
matrix<double> uu(4, 4);
matrix<double> vv(3, 3);
double eps = FLOATERROR;
i = LE_LinearLeastSquareGeneralizedInverse(ta, bb, xx, taa, eps, uu, vv);
cout.setf(ios::fixed); //輸出數據為定點法
cout.precision(6); //精度6位
if (i>0)
{
for(i = 0; i < 3; i ++)
{
cout << "x(" << i << ") = " << xx[i] << endl;
}
cout << endl;
cout << "MAT A+ : " << endl;
MatrixLinePrint(taa);
cout << endl;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -