Mantid
Loading...
Searching...
No Matches
SimpleChebfun.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2015 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 "MantidKernel/System.h"
11
12namespace Mantid {
13namespace CurveFitting {
14namespace Functions {
15
21class MANTID_CURVEFITTING_DLL SimpleChebfun {
22public:
24 SimpleChebfun(size_t n, ChebfunFunctionType fun, double start, double end);
26 SimpleChebfun(size_t n, const API::IFunction &fun, double start, double end);
28 SimpleChebfun(const ChebfunFunctionType &fun, double start, double end, double accuracy = 0.0, size_t badSize = 10);
30 SimpleChebfun(const API::IFunction &fun, double start, double end, double accuracy = 0.0, size_t badSize = 10);
32 SimpleChebfun(const std::vector<double> &x, const std::vector<double> &y);
34 size_t size() const { return m_base->size(); }
36 size_t order() const { return m_base->order(); }
38 bool isGood() const { return !m_badFit; }
40 double startX() const { return m_base->startX(); }
42 double endX() const { return m_base->endX(); }
44 double width() const { return m_base->width(); }
46 const std::vector<double> &xPoints() const { return m_base->xPoints(); }
48 const std::vector<double> &yPoints() const { return m_P; }
50 const std::vector<double> &coeffs() const;
52 double operator()(double x) const;
54 std::vector<double> operator()(const std::vector<double> &x) const;
56 std::vector<double> linspace(size_t n) const;
58 double accuracy() const;
60 SimpleChebfun derivative() const;
62 SimpleChebfun integral() const;
64 std::vector<double> roughRoots(double level = 0.0) const;
66 double integrate() const;
69
70private:
76 std::vector<double> m_P;
78 mutable std::vector<double> m_A;
79
82};
83
84} // namespace Functions
85} // namespace CurveFitting
86} // namespace Mantid
This is an interface to a fitting function - a semi-abstarct class.
Definition: IFunction.h:163
SimpleChebfun : approximates smooth 1d functions and provides methods to manipulate them.
Definition: SimpleChebfun.h:21
const std::vector< double > & yPoints() const
Get a reference to the y-points.
Definition: SimpleChebfun.h:48
ChebfunBase_sptr m_base
Underlying base that does actual job.
Definition: SimpleChebfun.h:74
std::vector< double > m_P
Function values at the chebfun x-points.
Definition: SimpleChebfun.h:76
double width() const
Get the width of the interval.
Definition: SimpleChebfun.h:44
double startX() const
Start of the interval.
Definition: SimpleChebfun.h:40
bool isGood() const
Check if approximation is good.
Definition: SimpleChebfun.h:38
std::vector< double > m_A
Chebyshev expansion coefficients.
Definition: SimpleChebfun.h:78
const std::vector< double > & xPoints() const
Get a reference to the x-points.
Definition: SimpleChebfun.h:46
double endX() const
End of the interval.
Definition: SimpleChebfun.h:42
bool m_badFit
Set in a case of a bad fit.
Definition: SimpleChebfun.h:81
size_t order() const
Order of the approximating polynomial.
Definition: SimpleChebfun.h:36
size_t size() const
Number of points in the approximation.
Definition: SimpleChebfun.h:34
MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Adds two workspaces.
std::shared_ptr< ChebfunBase > ChebfunBase_sptr
Definition: ChebfunBase.h:174
std::function< double(double)> ChebfunFunctionType
Type of the approximated function.
Definition: ChebfunBase.h:26
double integral(double func(const double, const double, const double), const double a, const double b, const double g, const double w0)
Helper class which provides the Collimation Length for SANS instruments.