Mantid
Loading...
Searching...
No Matches
Framework
Kernel
src
Math
Distributions
ChebyshevSeries.cpp
Go to the documentation of this file.
1
// Mantid Repository : https://github.com/mantidproject/mantid
2
//
3
// Copyright © 2018 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
//-----------------------------------------------------------------------------
8
// Includes
9
//-----------------------------------------------------------------------------
10
#include "
MantidKernel/Math/Distributions/ChebyshevSeries.h
"
11
#include <algorithm>
12
#include <cassert>
13
14
//-----------------------------------------------------------------------------
15
// Anonmouys static helpers
16
//-----------------------------------------------------------------------------
17
18
namespace
Mantid::Kernel
{
19
20
//-----------------------------------------------------------------------------
21
// Public members
22
//-----------------------------------------------------------------------------
28
ChebyshevSeries::ChebyshevSeries
(
const
size_t
degree) : m_bk(degree + 3, 0.0) {
29
// The algorithm requires computing upto n+2 terms so space is
30
// reserved for (n+1)+2 values.
31
}
32
42
double
ChebyshevSeries::operator()
(
const
std::vector<double> &c,
const
double
x
) {
43
const
size_t
degree(
m_bk
.size() - 3);
44
assert(c.size() >= degree + 1);
45
46
m_bk
.resize(degree + 3);
47
std::fill(
m_bk
.begin(),
m_bk
.end(), 0.0);
48
for
(
size_t
i = 0; i <= degree; ++i) {
49
const
size_t
k = degree - i;
50
m_bk
[k] = c[k] + 2. *
x
*
m_bk
[k + 1] -
m_bk
[k + 2];
51
}
52
return
m_bk
[0] -
x
*
m_bk
[1];
53
}
54
55
}
// namespace Mantid::Kernel
ChebyshevSeries.h
Mantid::Kernel::ChebyshevSeries::m_bk
std::vector< double > m_bk
Definition
ChebyshevSeries.h:32
Mantid::Kernel::ChebyshevSeries::operator()
double operator()(const std::vector< double > &c, const double x)
Definition
ChebyshevSeries.cpp:42
Mantid::Kernel::ChebyshevSeries::ChebyshevSeries
ChebyshevSeries(const size_t degree)
Constructor for an n-th order polynomial.
Definition
ChebyshevSeries.cpp:28
Mantid::Geometry::x
I a m x
Definition
SpaceGroupFactory.cpp:674
Mantid::Kernel
Definition
AnnularRingAbsorption.h:15
Generated by
1.9.8