luchangli03 / BFGS-Optimization-for-curve-fitting

use BFGS optimization algorithm to solve problems like curve fitting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BFGS-Optimization-for-curve-fitting C++

use BFGS optimization algorithm to solve problems like curve fitting the codes contain two part: a BFGS optimizer and some curve fitting example. I also uploaded a code file to verify these codes.

the codes are very simple to use, just as shown below

#include <iostream>
using namespace std;

#include "CurveFitting.h"


int main()
{
#define DataLen	10
float x[DataLen] = { 0,1,2,3,4,5,6,7,8,9 };
float y[DataLen] = { 0.601981941401637,1.26297128454014,2.65407909847678,3.68921450314001,4.74815159282371,5.45054159850250,6.08382137799693,7.22897696871682,8.91333736150167,9.15237801896922 };

#define DataArrayNum		2

float *DataArray[DataArrayNum] = { x,y };


BFGSOptimizer_TypeDef< float, DataArrayNum, 2, 5, 11>BFGSOptimizer(LineOrder1_PreFitting, LineOrder1_TargerF);

BFGSOptimizer.BFGSOptimize(DataArray, DataLen);

BFGSOptimizer.PrintfFitPara();

return 0;
}

About

use BFGS optimization algorithm to solve problems like curve fitting


Languages

Language:C++ 100.0%