DUNE PDELab (2.7)

gcd.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GCD_HH
4#define DUNE_GCD_HH
5
6namespace Dune
7{
17#ifndef DOXYGEN
21 template<long a, long b, bool bo>
22 struct GcdHelper
23 {};
24
25
26 template<long a, long b>
27 struct GcdHelper<a,b,true>
28 {
32 static void conceptCheck()
33 {
34 static_assert(b<a, "b<a must hold!");
35 static_assert(0<b, "b must be positive");
36 }
37
38
42 const static long gcd = GcdHelper<b,a%b,true>::gcd;
43 };
44
45 template<long a, long b>
46 struct GcdHelper<a,b,false>
47 {
51 const static long gcd = GcdHelper<b,a,true>::gcd;
52 };
53 template<long a>
54 struct GcdHelper<a,0,true>
55 {
56 const static long gcd=a;
57 };
58
59#endif
60
64 template<long a, long b>
65 struct Gcd
66 {
69 const static long value = GcdHelper<a,b,(a>b)>::gcd;
70 };
71
75}
76
77#endif
Dune namespace.
Definition: alignedallocator.hh:14
Calculator of the greatest common divisor.
Definition: gcd.hh:66
static const long value
The greatest common divisior of a and b.
Definition: gcd.hh:69
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)