📄 fitcurveleastsquares.cpp
字号:
//FitCurveLeastSquares.cpp
//最小二乘曲线拟合
#include <iostream> //模板类输入输出流标准头文件
#include "FittingApproximation.h" //拟合与逼近头文件
using namespace std; //名字空间
void main(void)
{
valarray<double> x(20), y(20), da(6), dt(3);
for(int i=0; i<20; i++)
{
x[i] = 0.1 * i;
y[i] = x[i] - exp(-x[i]);
}
cout.setf(ios::fixed); //输出数据为定点法
cout.precision(14); //精度14位
FitCurveLeastSquares(x,y,da,dt);
for (i=0; i<6; i++)
cout << "da[" << i << "] = " << da[i] << endl;
cout << endl;
for (i=0; i<3; i++)
cout << "dt[" << i << "] = " << dt[i] << endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -