"git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "e7e6d852822b279b88f133395bcc2dd056eb59da"
Commit 600e0365 authored by Davis King's avatar Davis King
Browse files

work around bug in gcc 4.8

parent 869097c8
...@@ -281,12 +281,31 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de ...@@ -281,12 +281,31 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
std::vector<function_spec> specs, std::vector<function_spec> specs,
const std::chrono::nanoseconds max_runtime, const std::chrono::nanoseconds max_runtime,
const max_function_calls num, const max_function_calls num,
double solver_epsilon = 0, double solver_epsilon,
Args&& ...args Args&& ...args
) )
{ {
return find_max_global(ymult, tp, functions, std::move(specs), num, max_runtime, solver_epsilon, std::forward<Args>(args)...); return find_max_global(ymult, tp, functions, std::move(specs), num, max_runtime, solver_epsilon, std::forward<Args>(args)...);
} }
// This overload shouldn't be required but it works around a bug in gcc 4.8 which has a bug
// that makes it complain about setting a default for solver_epsilon but then following it
// by args that "isn't defaulted" according to gcc 4.8.
template <
typename funct,
typename ...Args
>
std::pair<size_t,function_evaluation> find_max_global (
double ymult,
thread_pool& tp,
std::vector<funct>& functions,
std::vector<function_spec> specs,
const std::chrono::nanoseconds max_runtime,
const max_function_calls num,
double solver_epsilon = 0
)
{
return find_max_global(ymult, tp, functions, std::move(specs), num, max_runtime, solver_epsilon);
}
// This overload allows the num argument to be skipped. // This overload allows the num argument to be skipped.
template < template <
......
...@@ -187,6 +187,16 @@ namespace ...@@ -187,6 +187,16 @@ namespace
DLIB_TEST_MSG(max(abs(true_x-result.x)) < 1e-5, max(abs(true_x-result.x))); DLIB_TEST_MSG(max(abs(true_x-result.x)) < 1e-5, max(abs(true_x-result.x)));
print_spinner(); print_spinner();
result = find_max_global(rosen, {0.1, 0.1}, {2, 2}, std::chrono::seconds(5), max_function_calls(100));
dlog << LINFO << "rosen: " << trans(result.x);
DLIB_TEST_MSG(max(abs(true_x-result.x)) < 1e-5, max(abs(true_x-result.x)));
print_spinner();
result = find_max_global(rosen, {0.1, 0.1}, {2, 2}, max_function_calls(100), std::chrono::seconds(5));
dlog << LINFO << "rosen: " << trans(result.x);
DLIB_TEST_MSG(max(abs(true_x-result.x)) < 1e-5, max(abs(true_x-result.x)));
print_spinner();
result = find_max_global(rosen, {0.1, 0.1}, {2, 2}, {false,false}, max_function_calls(100)); result = find_max_global(rosen, {0.1, 0.1}, {2, 2}, {false,false}, max_function_calls(100));
dlog << LINFO << "rosen: " << trans(result.x); dlog << LINFO << "rosen: " << trans(result.x);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment