mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
extended MinProblemSolver::Function to 1) report the space dimensionality, 2) compute gradient if needed
This commit is contained in:
@@ -68,11 +68,13 @@ static void mytest(cv::Ptr<cv::DownhillSolver> solver,cv::Ptr<cv::MinProblemSolv
|
||||
|
||||
class SphereF:public cv::MinProblemSolver::Function{
|
||||
public:
|
||||
int getDims() const { return 2; }
|
||||
double calc(const double* x)const{
|
||||
return x[0]*x[0]+x[1]*x[1];
|
||||
}
|
||||
};
|
||||
class RosenbrockF:public cv::MinProblemSolver::Function{
|
||||
int getDims() const { return 2; }
|
||||
double calc(const double* x)const{
|
||||
return 100*(x[1]-x[0]*x[0])*(x[1]-x[0]*x[0])+(1-x[0])*(1-x[0]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user