Honeycomb  0.1
Component-Model Framework
MinimizeN.h
Go to the documentation of this file.
1 // Honeycomb, Copyright (C) 2015 NewGamePlus Inc. Distributed under the Boost Software License v1.0.
2 #pragma once
3 
5 
6 namespace honey
7 {
8 
10 template<class Real, int Dim>
11 class MinimizeN
12 {
13  typedef typename Numeral<Real>::Real_ Real_;
14  typedef Alge_<Real> Alge;
15 
16 public:
18  typedef function<Real (Vec)> Func;
19 
20  static const int dim = Dim;
21 
28  MinimizeN(Real tol = Real_::zeroTol, int iterMax = 30, int levelMax = 30, int bracketMax = 30)
29  : _tol(tol), _iterMax(iterMax), _minimize(tol, levelMax, bracketMax) {}
30 
32 
46  tuple<Vec,Real> calc(const Func& func, const Vec& min, const Vec& max, const Vec& init);
47 
48 private:
49  // Algorithm is adapted from the Wild Magic lib
50 
52 
59  static tuple<Real, Real> calcDomain(const Vec& v, const Vec& dir, const Vec& min, const Vec& max);
60 
61  Real _tol;
62  int _iterMax;
63  Minimize<Real> _minimize;
64 };
65 
66 extern template class MinimizeN<Float, 2>;
67 extern template class MinimizeN<Float, 3>;
68 extern template class MinimizeN<Double, 2>;
69 extern template class MinimizeN<Double, 3>;
70 
71 }
72 
Algebra.
Definition: Alge.h:13
Find a local minimum of a 1-dimensional function using "Brent's method" – bisection and inverse quad...
Definition: Minimize.h:11
static const int dim
Definition: MinimizeN.h:20
Vec< Dim, Real > Vec
Definition: MinimizeN.h:17
MinimizeN(Real tol=Real_::zeroTol, int iterMax=30, int levelMax=30, int bracketMax=30)
Definition: MinimizeN.h:28
tuple< Vec, Real > calc(const Func &func, const Vec &min, const Vec &max, const Vec &init)
Find the minimum of a function within bounds [min,max] using init as an initial guess.
Definition: MinimizeN.cpp:9
float Real
Real number type. See Real_ for real number operations and constants.
Definition: Real.h:21
Numeric type information, use numeral() to get instance safely from a static context.
Definition: Numeral.h:17
Find a local minimum of an n-dimensional function using "Powell's conjugate gradient descent method"...
Definition: MinimizeN.h:11
function< Real(Vec)> Func
Definition: MinimizeN.h:18
Global Honeycomb namespace.