Honeycomb  0.1
Component-Model Framework
Bisect.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 
4 #include "Honey/Math/Alge/Alge.h"
5 
6 namespace honey
7 {
8 
10 
14 template<class Real>
15 class Bisect
16 {
17  typedef Alge_<Real> Alge;
18 
19 public:
20  typedef function<Real (Real)> Func;
21 
26  Bisect(Real tol = Real_::zeroTol, int iterMax = 30) : _tol(tol), _iterMax(iterMax) {}
27 
29 
39  tuple<bool,Real,Real> bracket(const Func& func, Real min, Real max);
40 
42 
51  tuple<bool, Real> root(const Func& func, Real min, Real max);
52 
53 private:
54  Real _tol;
55  int _iterMax;
56 };
57 
58 extern template class Bisect<Float>;
59 extern template class Bisect<Double>;
60 extern template class Bisect<Quad>;
61 
62 }
63 
Algebra.
Definition: Alge.h:13
Find the root of a function by the bisection method. ie. Finds where function returns 0...
Definition: Bisect.h:15
Bisect(Real tol=Real_::zeroTol, int iterMax=30)
Definition: Bisect.h:26
function< Real(Real)> Func
Definition: Bisect.h:20
float Real
Real number type. See Real_ for real number operations and constants.
Definition: Real.h:21
tuple< bool, Real > root(const Func &func, Real min, Real max)
Find the root of a function within bounds [min,max].
Definition: Bisect.cpp:35
Global Honeycomb namespace.
tuple< bool, Real, Real > bracket(const Func &func, Real min, Real max)
Find the lower and upper bounds of the root of a function. ie. Estimate bounds where somewhere within...
Definition: Bisect.cpp:9