Mantid
Loading...
Searching...
No Matches
GSLFunctions.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
10#include "MantidAPI/IFunction.h"
13#include <gsl/gsl_blas.h>
14#include <gsl/gsl_multifit_nlin.h>
15#include <gsl/gsl_multimin.h>
16#include <gsl/gsl_statistics.h>
17
18namespace Mantid {
19namespace CurveFitting {
30 GSL_FitData(const std::shared_ptr<CostFunctions::CostFuncLeastSquares> &cf);
34 size_t n;
36 size_t p;
39 std::shared_ptr<CostFunctions::CostFuncLeastSquares> costFunction;
41 gsl_vector *initFuncParams;
44
45 // this is presently commented out in the implementation
46 // gsl_matrix *holdCalculatedJacobian; ///< cache of the calculated jacobian
47};
48
49int gsl_f(const gsl_vector *x, void *params, gsl_vector *f);
50int gsl_df(const gsl_vector *x, void *params, gsl_matrix *J);
51int gsl_fdf(const gsl_vector *x, void *params, gsl_vector *f, gsl_matrix *J);
52
54inline gsl_vector_view getGSLVectorView(vec_map_type &v) { return gsl_vector_view_array(v.data(), v.size()); }
56inline gsl_matrix_view getGSLMatrixView(map_type &tr) { return gsl_matrix_view_array(tr.data(), tr.cols(), tr.rows()); }
57
59inline gsl_vector_const_view const getGSLVectorView_const(const vec_map_type v) {
60 return gsl_vector_const_view_array(v.data(), v.size());
61}
63inline gsl_matrix_const_view const getGSLMatrixView_const(const map_type m) {
64 return gsl_matrix_const_view_array(m.data(), m.cols(), m.rows());
65}
66
67} // namespace CurveFitting
68} // namespace Mantid
The implementation of Jacobian.
Definition: EigenJacobian.h:85
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition: IFunction.h:732
int gsl_fdf(const gsl_vector *x, void *params, gsl_vector *f, gsl_matrix *J)
Fit derivatives and function GSL wrapper.
Eigen::Map< Eigen::VectorXd, 0, dynamic_stride > vec_map_type
gsl_vector_view getGSLVectorView(vec_map_type &v)
take data from Eigen Vector and take a gsl view
Definition: GSLFunctions.h:54
int gsl_f(const gsl_vector *x, void *params, gsl_vector *f)
Fit GSL function wrapper.
gsl_matrix_const_view const getGSLMatrixView_const(const map_type m)
take data from a constEigen Matrix and return a transposed gsl view.
Definition: GSLFunctions.h:63
Eigen::Map< Eigen::MatrixXd, 0, dynamic_stride > map_type
gsl_matrix_view getGSLMatrixView(map_type &tr)
take data from an Eigen Matrix and return a transposed a gsl view.
Definition: GSLFunctions.h:56
int gsl_df(const gsl_vector *x, void *params, gsl_matrix *J)
Fit GSL derivative function wrapper.
gsl_vector_const_view const getGSLVectorView_const(const vec_map_type v)
take const data from Eigen Vector and take a gsl view
Definition: GSLFunctions.h:59
Helper class which provides the Collimation Length for SANS instruments.
Various GSL specific functions used GSL specific minimizers.
Definition: GSLFunctions.h:28
size_t n
number of points to be fitted (size of X, Y and sqrtWeightData arrays)
Definition: GSLFunctions.h:34
std::shared_ptr< CostFunctions::CostFuncLeastSquares > costFunction
Definition: GSLFunctions.h:39
API::IFunction_sptr function
Pointer to the function.
Definition: GSLFunctions.h:38
size_t p
number of (active) fit parameters
Definition: GSLFunctions.h:36
JacobianImpl1< EigenMatrix > J
Jacobi matrix interface.
Definition: GSLFunctions.h:43
gsl_vector * initFuncParams
Initial function parameters.
Definition: GSLFunctions.h:41