Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
polynomials_bernstein.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
17 
18 #include <boost/math/special_functions/binomial.hpp>
19 
20 #include <vector>
21 
23 
24 namespace
25 {
26  template <typename number>
27  std::vector<number>
28  get_bernstein_coefficients(const unsigned int k, const unsigned int n)
29  {
30  Assert(n > 0,
31  ExcMessage("Bernstein polynomial needs to be of degree > 0."));
32  AssertIndexRange(k, n + 1);
33  std::vector<number> coeff(n + 1, number(0.0));
34  for (unsigned int i = k; i < n + 1; ++i)
35  {
36  coeff[i] = ((i - k) % 2 == 0 ? 1 : -1) *
37  boost::math::binomial_coefficient<number>(n, i) *
38  boost::math::binomial_coefficient<number>(i, k);
39  }
40  return coeff;
41  }
42 } // namespace
43 
44 template <typename number>
46  const unsigned int degree)
47  : Polynomials::Polynomial<number>(
48  get_bernstein_coefficients<number>(index, degree))
49 {}
50 
51 
52 #include "polynomials_bernstein.inst"
53 
Polynomials
Definition: polynomial.h:41
AssertIndexRange
#define AssertIndexRange(index, range)
Definition: exceptions.h:1649
StandardExceptions::ExcMessage
static ::ExceptionBase & ExcMessage(std::string arg1)
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
PolynomialsBernstein::PolynomialsBernstein
PolynomialsBernstein(const unsigned int index, const unsigned int degree)
Definition: polynomials_bernstein.cc:45
polynomials_bernstein.h
Assert
#define Assert(cond, exc)
Definition: exceptions.h:1419
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359