From b1f029ccc55adb4597751e4aeaf67122046482c3 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Tue, 20 Aug 2013 17:54:14 +0800 Subject: [PATCH] Removed trailing spaces This caused warnings. --- modules/optim/doc/downhill_simplex_method.rst | 6 ++-- modules/optim/src/simplex.cpp | 50 +++++++++++++-------------- modules/optim/test/test_downhill_simplex.cpp | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/modules/optim/doc/downhill_simplex_method.rst b/modules/optim/doc/downhill_simplex_method.rst index 8bb9be8..5661a5c 100644 --- a/modules/optim/doc/downhill_simplex_method.rst +++ b/modules/optim/doc/downhill_simplex_method.rst @@ -32,7 +32,7 @@ positive integer ``termcrit.maxCount`` and positive non-integer ``termcrit.epsil public: virtual ~Function() {} //! ndim - dimensionality - virtual double calc(const double* x) const = 0; + virtual double calc(const double* x) const = 0; }; virtual Ptr getFunction() const = 0; @@ -64,7 +64,7 @@ algorithms in the ``optim`` module. optim::DownhillSolver::getFunction -------------------------------------------- -Getter for the optimized function. The optimized function is represented by ``Solver::Function`` interface, which requires +Getter for the optimized function. The optimized function is represented by ``Solver::Function`` interface, which requires derivatives to implement the sole method ``calc(double*)`` to evaluate the function. .. ocv:function:: Ptr optim::DownhillSolver::getFunction() @@ -134,7 +134,7 @@ of projection is treated to be vector given by :math:`s_i:=e_i\cdot\left& p, + Mat_& p, Mat_& y, - Mat_& coord_sum, + Mat_& coord_sum, const Ptr& f, - int ihi, + int ihi, double fac, Mat_& ptry ) @@ -40,24 +40,24 @@ namespace cv{namespace optim{ int ndim=p.cols; int j; double fac1,fac2,ytry; - + fac1=(1.0-fac)/ndim; fac2=fac1-fac; - for (j=0;jcalc((double*)ptry.data); - if (ytry < y(ihi)) + if (ytry < y(ihi)) { y(ihi)=ytry; - for (j=0;j& p, + double DownhillSolverImpl::inner_downhill_simplex( + cv::Mat_& p, double MinRange, double MinError, int& nfunk, @@ -84,32 +84,32 @@ namespace cv{namespace optim{ Mat_ coord_sum(1,ndim,0.0),buf(1,ndim,0.0),y(1,ndim,0.0); nfunk = 0; - + for(i=0;icalc(p[i]); } nfunk = ndim+1; - + compute_coord_sum(p,coord_sum); - - for (;;) + + for (;;) { ilo=0; /* find highest (worst), next-to-worst, and lowest (best) points by going through all of them. */ ihi = y(0)>y(1) ? (inhi=1,0) : (inhi=0,1); - for (i=0;i y(ihi)) + if (y(i) > y(ihi)) { inhi=ihi; ihi=i; - } - else if (y(i) > y(inhi) && i != ihi) + } + else if (y(i) > y(inhi) && i != ihi) inhi=i; } @@ -130,10 +130,10 @@ namespace cv{namespace optim{ if(range < d) range = d; } - if(range <= MinRange || error <= MinError) + if(range <= MinRange || error <= MinError) { /* Put best point and value in first slot. */ std::swap(y(0),y(ilo)); - for (i=0;i= y(inhi)) + else if (ytry >= y(inhi)) { /* The new point is worse than the second-highest, but better than the worst so do not go so far in that direction */ ysave = y(ihi); ytry = try_new_point(p,y,coord_sum,f,ihi,0.5,buf); - if (ytry >= ysave) + if (ytry >= ysave) { /* Can't seem to improve things. Contract the simplex to good point in hope to find a simplex landscape. */ - for (i=0;i #include -static void mytest(cv::Ptr solver,cv::Ptr ptr_F,cv::Mat& x,cv::Mat& step, +static void mytest(cv::Ptr solver,cv::Ptr ptr_F,cv::Mat& x,cv::Mat& step, cv::Mat& etalon_x,double etalon_res){ solver->setFunction(ptr_F); int ndim=MAX(step.cols,step.rows); -- 2.7.4