Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
CTM.h
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MoDELib is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef model_CTM_H_
9#define model_CTM_H_
10
11//#include <Factorial.h>
12
13namespace model
14{
15
16 /*\brief A structure which wraps compile-time math functions
17 */
18 struct CTM
19 {
20 static constexpr int binomial(int N, int k)
21 {/*\brief A compile-time implementation of binomial coefficients
22 */
23 return factorial(N) / (factorial(N-k) * factorial(k));
24 }
25
26 static constexpr int factorial(int n)
27 {
28 return n <= 1? 1 : (n * factorial(n - 1));
29 }
30
31
32 static constexpr size_t gcd(size_t A, size_t B)
33 {
35 return B==0? A : gcd(B, A % B );
36 }
37
40 static constexpr int pow(int x, int n)
41 {
42 return n==0? 1 : x * pow(x,n-1);
43 }
44
45 };
46
47}
48
49#endif
initial point of the source segment B
function infiniteDisplacement syms Ax Ay Az Bx By Bz qx qy qz u L x y z real A
x
Definition int_R.m:12
static constexpr int pow(int x, int n)
A compile-time implementation of the power function.
Definition CTM.h:40
static constexpr int binomial(int N, int k)
Definition CTM.h:20
static constexpr size_t gcd(size_t A, size_t B)
Definition CTM.h:32
static constexpr int factorial(int n)
Definition CTM.h:26
int k