9#ifndef _CLASS_BERNSTEIN
10#define _CLASS_BERNSTEIN
26inline unsigned int bin(
const unsigned int n,
const unsigned int k) {
28 throw std::runtime_error(
"binomial coefficient higher than degree");
30 if (k > n / 2)
return bin(n, n - k);
31 return n * bin(n - 1, k - 1) / k;
37template <
typename Numeric =
double>
40 Bern(
const unsigned int m,
const unsigned int i)
49 if (!(u >= 0. && u <= 1.)) {
50 throw std::invalid_argument(
"u needs to be betwen 0 and 1.");
67 virtual bool operator!=(
const Bern& other)
const {
return !(*
this == other); }
76 friend class boost::serialization::access;
77 template <
class Archive>
78 void serialize(Archive& ar,
const unsigned int version) {
82 ar& boost::serialization::make_nvp(
"m_minus_i",
m_minus_i);
83 ar& boost::serialization::make_nvp(
"i",
i_);
84 ar& boost::serialization::make_nvp(
"bin_m_i",
bin_m_i_);
90template <
typename Numeric>
92 std::vector<Bern<Numeric> > res;
93 for (
unsigned int i = 0; i <= n; ++i) {
#define DEFINE_CLASS_TEMPLATE_VERSION(Template, Type)
Definition archive.hpp:27
std::vector< Bern< Numeric > > makeBernstein(const unsigned int n)
Computes all Bernstein polynomes for a certain degree.
Definition bernstein.h:91
interface for a Curve of arbitrary dimension.
Definition bernstein.h:20
bool isApprox(const T a, const T b, const T eps=1e-6)
Definition curve_abc.h:25
Definition bernstein.h:38
Bern()
Definition bernstein.h:39
Numeric operator()(const Numeric u) const
Evaluation of Bernstein polynomial at value u.
Definition bernstein.h:48
Numeric i_
Definition bernstein.h:71
virtual bool operator==(const Bern &other) const
Check if actual Bernstein polynomial and other are approximately equal.
Definition bernstein.h:58
Bern(const unsigned int m, const unsigned int i)
Definition bernstein.h:40
Numeric bin_m_i_
Definition bernstein.h:72
virtual ~Bern()
Definition bernstein.h:43
void serialize(Archive &ar, const unsigned int version)
Definition bernstein.h:78
Numeric m_minus_i
Definition bernstein.h:70
virtual bool operator!=(const Bern &other) const
Check if actual Bernstein polynomial and other are different.
Definition bernstein.h:67