carl
24.04
Computer ARithmetic Library
Chebyshev.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "../UnivariatePolynomial.h"
4
#include <
carl-arith/core/Variable.h
>
5
6
namespace
carl
{
7
8
/**
9
* Implements a generator for Chebyshev polynomials.
10
*/
11
template
<
typename
Number>
12
struct
Chebyshev
{
13
Variable
mVar
;
14
explicit
Chebyshev
(
Variable
v):
mVar
(v) {}
15
16
UnivariatePolynomial<Number>
operator()
(std::size_t n)
const
{
17
UnivariatePolynomial<Number>
t0(
mVar
, Number(1), 0);
18
if
(n == 0)
return
t0;
19
UnivariatePolynomial<Number>
t1(
mVar
, Number(1), 1);
20
if
(n == 1)
return
t1;
21
UnivariatePolynomial<Number>
twox(
mVar
, Number(2), 1);
22
while
(n >= 2) {
23
UnivariatePolynomial<Number>
tn = twox * t1 - t0;
24
if
(n == 2)
return
tn;
25
t0 = t1;
26
t1 = tn;
27
--n;
28
}
29
assert(
false
);
30
return
t0;
31
}
32
};
33
34
}
Variable.h
carl
carl is the main namespace for the library.
carl::Variable
A Variable represents an algebraic variable that can be used throughout carl.
Definition:
Variable.h:85
carl::UnivariatePolynomial< Number >
carl::Chebyshev
Implements a generator for Chebyshev polynomials.
Definition:
Chebyshev.h:12
carl::Chebyshev::operator()
UnivariatePolynomial< Number > operator()(std::size_t n) const
Definition:
Chebyshev.h:16
carl::Chebyshev::mVar
Variable mVar
Definition:
Chebyshev.h:13
carl::Chebyshev::Chebyshev
Chebyshev(Variable v)
Definition:
Chebyshev.h:14
carl-arith
poly
umvpoly
functions
Chebyshev.h
Generated by
1.9.1