toon-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Toon-members] TooN/optimization conjugate_gradient.h


From: Paul McIlroy
Subject: [Toon-members] TooN/optimization conjugate_gradient.h
Date: Wed, 20 May 2009 14:53:11 +0000

CVSROOT:        /sources/toon
Module name:    TooN
Changes by:     Paul McIlroy <paulmcilroy>      09/05/20 14:53:11

Modified files:
        optimization   : conjugate_gradient.h 

Log message:
        Make a constructor consistent with the previous change.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/optimization/conjugate_gradient.h?cvsroot=toon&r1=1.4&r2=1.5

Patches:
Index: conjugate_gradient.h
===================================================================
RCS file: /sources/toon/TooN/optimization/conjugate_gradient.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- conjugate_gradient.h        20 May 2009 14:42:33 -0000      1.4
+++ conjugate_gradient.h        20 May 2009 14:53:11 -0000      1.5
@@ -187,16 +187,36 @@
        : size(start.size()),
          g(size),h(size),old_g(size),old_h(size),x(start),old_x(size)
        {
-               using std::numeric_limits;
+               init(start, func(start), deriv(start));
+       }       
+
+       ///Initialize the ConjugateGradient class with sensible values.
+       ///@param start Starting point, \e x
+       ///@param func  Function \e f  to compute \f$f(x)\f$
+       ///@param deriv  \f$\nabla f(x)\f$
+       template<class Func> ConjugateGradient(const Vector<Size>& start, const 
Func& func, const Vector<Size>& deriv)
+       : size(start.size()),
+         g(size),h(size),old_g(size),old_h(size),x(start),old_x(size)
+       {
+               init(start, func(start), deriv);
+       }       
+
+       ///Initialize the ConjugateGradient class with sensible values. Used 
internally.
+       ///@param start Starting point, \e x
+       ///@param func  \f$f(x)\f$
+       ///@param deriv  \f$\nabla f(x)\f$
+       void init(const Vector<Size>& start, const Precision& func, const 
Vector<Size>& deriv)
+       {
 
+               using std::numeric_limits;
                x = start;
 
                //Start with the conjugate direction aligned with
                //the gradient
-               g = deriv(x);
+               g = deriv;
                h = g;
 
-               y = func(x);
+               y = func;
                old_y = y;
 
                tolerance = sqrt(numeric_limits<Precision>::epsilon());




reply via email to

[Prev in Thread] Current Thread [Next in Thread]