?? rootleastsquaregeneralizedinverse1.cpp
字號(hào):
//RootLeastSquareGeneralizedInverse1.cpp
//非線性方程組最小二乘解的廣義逆法示例1
#include <iostream> //輸入輸出流頭文件
#include "LinearEquation.h" //線性方程組求解頭文件
#include "NonLinearEquation.h" //非線性方程(組)求解頭文件
using namespace std; //名字空間
void main(void)
{
int m(2), i, ka(3);
double eps1(FLOATERROR), eps2(FLOATERROR);
valarray<double> x(2);
x[0] = 0.5;
x[1] = -1.0;
cout << "RootLeastSquareGeneralizedInverse1()" << endl;
i = RootLeastSquareGeneralizedInverse(m, eps1, eps2, x, ka);
cout << endl;
cout << "i= " << i << endl << endl;
for (int it=0; it < 2; it++)
cout << "x(" << it << ") = " << x[it] << endl;
cout<<endl;
}
//計(jì)算非線性方程組左邊函數(shù)值
template <class _Ty>
void FunctionValueRLSGI(valarray<_Ty>& x,valarray<_Ty>& d)
{
d[0] = x[0] * x[0] + 10.0 * x[0] * x[1] + 4.0 * x[1] * x[1] + 0.7401006;
d[1] = x[0] * x[0] - 3.0 * x[0] * x[1] + 2.0 * x[1] * x[1] - 1.0201228;
}
//計(jì)算雅可比矩陣
template <class _Ty>
void JacobiMatrix(valarray<_Ty>& x, matrix<_Ty>& p)
{
p(0,0) = 2.0 * x[0] + 10.0 * x[1];
p(0,1) = 10.0 * x[0] + 8.0 * x[1];
p(1,0) = 2.0 * x[0] - 3.0 * x[1];
p(1,1) = -3.0 * x[0] + 4.0 * x[1];
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -