yat  0.21pre
df.h
1 #ifndef theplu_yat_utility_multivariable_df
2 #define theplu_yat_utility_multivariable_df
3 
4 // $Id: df.h 4252 2022-11-18 02:54:04Z peter $
5 
6 /*
7  Copyright (C) 2022 Peter Johansson
8 
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <https://www.gnu.org/licenses/>.
23 */
24 
25 #include "f.h"
26 
27 #include <yat/utility/VectorConstView.h>
28 #include <yat/utility/VectorView.h>
29 
30 #include <gsl/gsl_vector.h>
31 
32 namespace theplu {
33 namespace yat {
34 namespace utility {
35 
36  namespace multivariable
37  {
38  template<class FUNC>
39  void df(const gsl_vector* gsl_x, void* params, gsl_vector* gradient)
40  {
41  FUNC* func = static_cast<FUNC*>(params);
42  yat::utility::VectorConstView x(gsl_x);
43  yat::utility::VectorView g(gradient);
44  (*func)(x, g);
45  }
46 
47 
48  template<class FUNC>
49  void fdf(const gsl_vector* x, void* params,
50  double* y, gsl_vector* gradient)
51  {
52  *y = f<FUNC>(x, params);
53  df<FUNC>(x, params, gradient);
54  }
55  } // end namespace multivariable
56 
57 }}} // end namespaces utility, yat and theplu
58 #endif
The Department of Theoretical Physics namespace as we define it.

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14