deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11: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: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2015 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#include <deal.II/base/config.h>
14
19
20#include <boost/math/constants/constants.hpp>
21#include <boost/math/special_functions/binomial.hpp>
22#include <boost/math/tools/precision.hpp>
23
24#include <Kokkos_Macros.hpp>
25
26#include <cmath>
27#include <string>
28#include <vector>
29
31
32namespace
33{
34 template <typename number>
35 std::vector<number>
36 get_bernstein_coefficients(const unsigned int k, const unsigned int n)
37 {
38 Assert(n > 0,
39 ExcMessage("Bernstein polynomial needs to be of degree > 0."));
40 AssertIndexRange(k, n + 1);
41 std::vector<number> coeff(n + 1, number(0.0));
42 for (unsigned int i = k; i < n + 1; ++i)
43 {
44 coeff[i] = ((i - k) % 2 == 0 ? 1 : -1) *
45 boost::math::binomial_coefficient<number>(n, i) *
46 boost::math::binomial_coefficient<number>(i, k);
47 }
48 return coeff;
49 }
50} // namespace
51
52template <typename number>
54 const unsigned int degree)
55 : Polynomials::Polynomial<number>(
56 get_bernstein_coefficients<number>(index, degree))
57{}
58
59
60template class ::PolynomialsBernstein<double>;
61
62
PolynomialsBernstein(const unsigned int index, const unsigned int degree)
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define Assert(cond, exc)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcMessage(std::string arg1)