diff options
Diffstat (limited to 'math/goldenSectionSearch.cpp')
| -rw-r--r-- | math/goldenSectionSearch.cpp | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/math/goldenSectionSearch.cpp b/math/goldenSectionSearch.cpp deleted file mode 100644 index 20b15e8..0000000 --- a/math/goldenSectionSearch.cpp +++ /dev/null @@ -1,15 +0,0 @@ -ld gss(ld l, ld r, function<ld(ld)> f) { - ld inv = (sqrt(5.0l) - 1) / 2; - ld x1 = r - inv*(r-l), x2 = l + inv*(r-l); - ld f1 = f(x1), f2 = f(x2); - for (int i = 0; i < 200; i++) { - if (f1 < f2) { //change to > to find maximum - u = x2; x2 = x1; f2 = f1; - x1 = r - inv*(r-l); f1 = f(x1); - } else { - l = x1; x1 = x2; f1 = f2; - x2 = l + inv*(r-l); f2 = f(x2); - } - } - return l; -} |
