Bembel
Pascal.hpp
1 // This file is part of Bembel, the higher order C++ boundary element library.
2 //
3 // Copyright (C) 2022 see <http://www.bembel.eu>
4 //
5 // It was written as part of a cooperation of J. Doelz, H. Harbrecht, S. Kurz,
6 // M. Multerer, S. Schoeps, and F. Wolf at Technische Universitaet Darmstadt,
7 // Universitaet Basel, and Universita della Svizzera italiana, Lugano. This
8 // source code is subject to the GNU General Public License version 3 and
9 // provided WITHOUT ANY WARRANTY, see <http://www.bembel.eu> for further
10 // information.
11 #ifndef BEMBEL_SRC_SPLINE_PASCAL_HPP_
12 #define BEMBEL_SRC_SPLINE_PASCAL_HPP_
13 
14 namespace Bembel {
15 
22 template <bool condition>
24 template <>
25 struct static_assertKlessseqN<true> {
26  enum { YOU_CALLED_BINOMIAL_WITH_KgtrN_OR_NEGATIVE_VALUES = 1 };
27 };
28 
29 template <int K, int N>
30 struct Binomial {
31  enum {
32  value = static_assertKlessseqN<(K >= 0 && N >= 0 && K <= N)>::
33  YOU_CALLED_BINOMIAL_WITH_KgtrN_OR_NEGATIVE_VALUES
34  ? Binomial<K - 1, N - 1>::value + Binomial<K, N - 1>::value
35  : 0
36  };
37 };
38 template <>
39 struct Binomial<0, 0> {
40  enum { value = 1 };
41 };
42 template <int N>
43 struct Binomial<N, N> {
44  enum { value = 1 };
45 };
46 template <int N>
47 struct Binomial<0, N> {
48  enum { value = 1 };
49 };
50 
51 } // namespace Bembel
52 #endif // BEMBEL_SRC_SPLINE_PASCAL_HPP_
Routines for the evalutation of pointwise errors.
Definition: AnsatzSpace.hpp:14
Here we hardcode the binomial coefficients through template recursion and perform bounds checking,...
Definition: Pascal.hpp:23