[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN internal/config.hh optimization/conjugate_...
From: |
Qi Pan |
Subject: |
[Toon-members] TooN internal/config.hh optimization/conjugate_... |
Date: |
Thu, 19 Nov 2009 18:19:02 +0000 |
CVSROOT: /sources/toon
Module name: TooN
Changes by: Qi Pan <qpan> 09/11/19 18:19:02
Modified files:
internal : config.hh
optimization : conjugate_gradient.h
Log message:
Added a minus_h variable to conjugate gradient as -h was passed to
LineSearch, which caused nan's when the temporary -h was destructed
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/config.hh?cvsroot=toon&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/TooN/optimization/conjugate_gradient.h?cvsroot=toon&r1=1.8&r2=1.9
Patches:
Index: internal/config.hh
===================================================================
RCS file: /sources/toon/TooN/internal/config.hh,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- internal/config.hh 5 Nov 2009 09:41:57 -0000 1.16
+++ internal/config.hh 19 Nov 2009 18:19:02 -0000 1.17
@@ -1 +1,14 @@
+/* internal/config.hh. Generated from config.hh.in by configure. */
+/* #undef TOON_TYPEOF_DECLTYPE */
+/* #undef TOON_TYPEOF_TYPEOF */
+
+#define TOON_TYPEOF___TYPEOF__ 1
+
+/* #undef TOON_TYPEOF_BOOST */
+
+/* #undef TOON_TYPEOF_BUILTIN */
+
+#define TOON_DEPRECATED_GCC 1
+
+#define TOON_USE_LAPACK 1
Index: optimization/conjugate_gradient.h
===================================================================
RCS file: /sources/toon/TooN/optimization/conjugate_gradient.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- optimization/conjugate_gradient.h 24 Jun 2009 14:11:36 -0000 1.8
+++ optimization/conjugate_gradient.h 19 Nov 2009 18:19:02 -0000 1.9
@@ -164,6 +164,7 @@
const int size; ///< Dimensionality of the space.
Vector<Size> g; ///< Gradient vector used by the next call to
iterate()
Vector<Size> h; ///< Conjugate vector to be searched along in the
next call to iterate()
+ Vector<Size> minus_h;///< negative of h as this is required to be
passed into a function which uses references (so can't be temporary)
Vector<Size> old_g; ///< Gradient vector used to compute $h$ in the
last call to iterate()
Vector<Size> old_h; ///< Conjugate vector searched along in the last
call to iterate()
Vector<Size> x; ///< Current position (best known point)
@@ -190,7 +191,7 @@
///@param deriv Function to compute \f$\nabla f(x)\f$
template<class Func, class Deriv> ConjugateGradient(const Vector<Size>&
start, const Func& func, const Deriv& deriv)
: size(start.size()),
- g(size),h(size),old_g(size),old_h(size),x(start),old_x(size)
+
g(size),h(size),minus_h(size),old_g(size),old_h(size),x(start),old_x(size)
{
init(start, func(start), deriv(start));
}
@@ -201,7 +202,7 @@
///@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)
+
g(size),h(size),minus_h(size),old_g(size),old_h(size),x(start),old_x(size)
{
init(start, func(start), deriv);
}
@@ -220,6 +221,7 @@
//the gradient
g = deriv;
h = g;
+ minus_h=-h;
y = func;
old_y = y;
@@ -255,7 +257,7 @@
/// @param func Functor returning the function value at a given point.
template<class Func> void find_next_point(const Func& func)
{
- Internal::LineSearch<Size, Precision, Func> line(x, -h, func);
+ Internal::LineSearch<Size, Precision, Func> line(x, minus_h,
func);
//Always search in the conjugate direction (h)
//First bracket a minimum.
@@ -318,6 +320,7 @@
//Precision gamma = (g * g - oldg*g)/(oldg * oldg);
Precision gamma = (g * g - old_g*g)/(old_g * old_g);
h = g + gamma * old_h;
+ minus_h=-h;
}
///Use this function to iterate over the optimization. Note that after
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Toon-members] TooN internal/config.hh optimization/conjugate_...,
Qi Pan <=