Reference documentation for deal.II version GIT relicensing-1054-gedd46abbd6 2024-07-12 01:20:01+00:00
\(\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\}}\)
Loading...
Searching...
No Matches
polynomials_bernstein.cc
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2015 - 2018 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
16
17#include <boost/math/special_functions/binomial.hpp>
18
19#include <vector>
20
22
23namespace
24{
25 template <typename number>
26 std::vector<number>
27 get_bernstein_coefficients(const unsigned int k, const unsigned int n)
28 {
29 Assert(n > 0,
30 ExcMessage("Bernstein polynomial needs to be of degree > 0."));
31 AssertIndexRange(k, n + 1);
32 std::vector<number> coeff(n + 1, number(0.0));
33 for (unsigned int i = k; i < n + 1; ++i)
34 {
35 coeff[i] = ((i - k) % 2 == 0 ? 1 : -1) *
36 boost::math::binomial_coefficient<number>(n, i) *
37 boost::math::binomial_coefficient<number>(i, k);
38 }
39 return coeff;
40 }
41} // namespace
42
43template <typename number>
45 const unsigned int degree)
46 : Polynomials::Polynomial<number>(
47 get_bernstein_coefficients<number>(index, degree))
48{}
49
50
51#include "polynomials_bernstein.inst"
52
PolynomialsBernstein(const unsigned int index, const unsigned int degree)
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
#define Assert(cond, exc)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcMessage(std::string arg1)