flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
gsl_multimin_fminimizer.cpp
Go to the documentation of this file.
1// ====================================================================
2// This file is part of FlexibleSUSY.
3//
4// FlexibleSUSY is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published
6// by the Free Software Foundation, either version 3 of the License,
7// or (at your option) any later version.
8//
9// FlexibleSUSY is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with FlexibleSUSY. If not, see
16// <http://www.gnu.org/licenses/>.
17// ====================================================================
18
20#include "logger.hpp"
21#include "error.hpp"
22#include <string>
23
24namespace flexiblesusy {
25
27 const gsl_multimin_fminimizer_type* type, std::size_t dim,
28 gsl_multimin_function* f, const GSL_vector& start,
29 const GSL_vector& step_size)
30{
31 solver = gsl_multimin_fminimizer_alloc(type, dim);
32
33 if (!solver) {
34 throw OutOfMemoryError(
35 std::string("Cannot allocate gsl_multimin_fminimizer ") +
36 gsl_multimin_fminimizer_name(solver));
37 }
38
39 gsl_multimin_fminimizer_set(solver, f, start.raw(), step_size.raw());
40}
41
43{
44 gsl_multimin_fminimizer_free(solver);
45}
46
48{
49 return solver->x;
50}
51
53{
54 return solver->fval;
55}
56
58{
59 return gsl_multimin_fminimizer_iterate(solver);
60}
61
62void GSL_multimin_fminimizer::print_state(std::size_t iteration) const
63{
64 VERBOSE_MSG("\t\t\tIteration " << iteration
65 << ": x = " << GSL_vector(solver->x)
66 << ", f(x) = " << solver->fval);
67}
68
69int GSL_multimin_fminimizer::test_residual(double precision) const noexcept
70{
71 const double size = gsl_multimin_fminimizer_size(solver);
72 return gsl_multimin_test_size(size, precision);
73}
74
75} // namespace flexiblesusy
int test_residual(double precision) const noexcept
GSL_multimin_fminimizer(const gsl_multimin_fminimizer_type *type, std::size_t dim, gsl_multimin_function *f, const GSL_vector &start, const GSL_vector &step_size)
void print_state(std::size_t iteration) const
const gsl_vector * raw() const noexcept
get raw pointer
Definition: gsl_vector.cpp:191
Not enough memory.
Definition: error.hpp:194
#define VERBOSE_MSG(msg)
Definition: logger.hpp:57
std::complex< double > f(double tau) noexcept