拉格朗日插值拟合
来源:互联网 发布:应聘淘宝客服的简历 编辑:程序博客网 时间:2024/04/30 09:48
pre define
typedef struct Operators{std::vector<float> Operatos;}Operators;// 定义一个点class PointF{public:PointF(){X = Y = 0.0f;}PointF(IN const PointF &point){X = point.X;Y = point.Y;}PointF(IN float x,IN float y){X = x;Y = y;}PointF operator+(IN const PointF& point) const{return PointF(X + point.X,Y + point.Y);}PointF operator-(IN const PointF& point) const{return PointF(X - point.X,Y - point.Y);}BOOL Equals(IN const PointF& point){return (X == point.X) && (Y == point.Y);}public:float X;float Y;};
fit lagrange
void CWinaTVWaveformDlg::fitLagrange(std::vector<PointF> pointList){std::vector<Operators> OpList;// result std::vector<float> Xs;std::vector<float> Ys;try{if (pointList.size() > 0){//compute lagrange operator for each X coordinatefor (int x = 1; x < 2000; x++){//list of float to hold the Lagrange operators, Init the list with 1'sstd::vector<float> L(pointList.size(), 1); for (int i = 0; i < L.size(); i++){for (int k = 0; k < pointList.size(); k++){if (i != k)L[i] *= (float)(x - pointList[k].X) / (pointList[i].X - pointList[k].X);}}Operators o;o.Operatos = L;OpList.push_back(o);Xs.push_back(x);}//Computing the Polynomial P(x) which is y in our curvestd::vector<Operators>::iterator iter;for ( iter = OpList.begin(); iter != OpList.end(); iter++){float y = 0;for (int i = 0; i < pointList.size(); i++){y += iter->Operatos[i] * pointList[i].Y;}Ys.push_back(y); }//Drawing the curve in the simplest way}else{AfxMessageBox(_T("Lagrange curve fitting, add some points"));}}catch (CException* e){return;}}
0 0
- 拉格朗日插值拟合
- 拟合
- 拟合
- 拟合
- 拉格朗日插值多项式 ,用于离散数据的拟合
- 1.拉格朗日插值多项式 ,用于离散数据的拟合
- 拟合算法
- 最小二乘法拟合
- 多项式拟合
- 拟合方法
- 过拟合
- 多项式拟合
- 直线拟合
- 拟合曲线
- 直线拟合
- 数据拟合
- 过拟合
- 最小二乘法拟合
- HDU 1723 Distribute Message(DP)
- 破解圣经之滚瓜烂熟篇
- 数据结构实验之链表三:链表的逆置
- 3 Sum
- 【Sublime Text 3】Sublime Text 3 - cracked 3086
- 拉格朗日插值拟合
- HDU 1087 Super Jumping! Jumping! Jumping!(DP)
- snort 命令解析
- POJ2241——The Tower of Babylon
- 什么是 Office 相关应用程序?
- [Leetcode] Palindrome Partitioning II
- iOS8的入侵与防御:1.在iphone6运行hello world
- Merge Intervals
- remove duplicate from sorted list(keep only 1 per element)