Merge pull request #308 from dawgfoto/numeric

flag findRoot delegates as scope
This commit is contained in:
David Simcha 2011-10-30 13:46:26 -07:00
commit c62c4d0ec1

View file

@ -691,7 +691,7 @@ public:
* www.netlib.org,www.netlib.org) as algorithm TOMS478. * www.netlib.org,www.netlib.org) as algorithm TOMS478.
* *
*/ */
T findRoot(T, R)(R delegate(T) f, T a, T b) T findRoot(T, R)(scope R delegate(T) f, T a, T b)
{ {
auto r = findRoot(f, a, b, f(a), f(b), (T lo, T hi){ return false; }); auto r = findRoot(f, a, b, f(a), f(b), (T lo, T hi){ return false; });
// Return the first value if it is smaller or NaN // Return the first value if it is smaller or NaN
@ -731,8 +731,8 @@ T findRoot(T, R)(R delegate(T) f, T a, T b)
* root was found, both of the first two elements will contain the * root was found, both of the first two elements will contain the
* root, and the second pair of elements will be 0. * root, and the second pair of elements will be 0.
*/ */
Tuple!(T, T, R, R) findRoot(T,R)(R delegate(T) f, T ax, T bx, R fax, R fbx, Tuple!(T, T, R, R) findRoot(T,R)(scope R delegate(T) f, T ax, T bx, R fax, R fbx,
bool delegate(T lo, T hi) tolerance) scope bool delegate(T lo, T hi) tolerance)
in { in {
assert(ax<>=0 && bx<>=0, "Limits must not be NaN"); assert(ax<>=0 && bx<>=0, "Limits must not be NaN");
assert(signbit(fax) != signbit(fbx), "Parameters must bracket the root."); assert(signbit(fax) != signbit(fbx), "Parameters must bracket the root.");