Lattice Microbes 2.5
This is for whole cell modeling
Loading...
Searching...
No Matches
Math.h
Go to the documentation of this file.
1/*
2 * University of Illinois Open Source License
3 * Copyright 2008-2018 Luthey-Schulten Group,
4 * All rights reserved.
5 *
6 * Developed by: Luthey-Schulten Group
7 * University of Illinois at Urbana-Champaign
8 * http://www.scs.uiuc.edu/~schulten
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy of
11 * this software and associated documentation files (the Software), to deal with
12 * the Software without restriction, including without limitation the rights to
13 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14 * of the Software, and to permit persons to whom the Software is furnished to
15 * do so, subject to the following conditions:
16 *
17 * - Redistributions of source code must retain the above copyright notice,
18 * this list of conditions and the following disclaimers.
19 *
20 * - Redistributions in binary form must reproduce the above copyright notice,
21 * this list of conditions and the following disclaimers in the documentation
22 * and/or other materials provided with the distribution.
23 *
24 * - Neither the names of the Luthey-Schulten Group, University of Illinois at
25 * Urbana-Champaign, nor the names of its contributors may be used to endorse or
26 * promote products derived from this Software without specific prior written
27 * permission.
28 *
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
32 * THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
33 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
34 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35 * OTHER DEALINGS WITH THE SOFTWARE.
36 *
37 * Author(s): Elijah Roberts
38 */
39
40#ifndef LM_MATH_H_
41#define LM_MATH_H_
42
43#include <algorithm>
44#include <cmath>
45
46#define TWOPI 6.283185307179586476925287
47#define PI 3.141592653589793238462643
48#define PID2 1.570796326794896619231322
49#define PID4 0.7853981634
50#define PIOVER180 0.0174532925
51#define NA 6.02214179e23
52#define EPS 1e-12
53
54
55
56inline bool isPower2(unsigned int x)
57{
58 return !(x&(x - 1)) && x;
59}
60
61inline bool isPower2(unsigned long x)
62{
63 return !(x&(x - 1)) && x;
64}
65
66inline bool isPower2(unsigned long long x)
67{
68 return !(x&(x - 1)) && x;
69}
70
71inline unsigned int log2(unsigned int x)
72{
73 unsigned int r = 0;
74 while (x>>=1)
75 r++;
76 return r;
77}
78
79inline unsigned int log2(unsigned long x)
80{
81 unsigned int r = 0;
82 while (x>>=1)
83 r++;
84 return r;
85}
86
87inline unsigned int log2(unsigned long long x)
88{
89 unsigned int r = 0;
90 while (x>>=1)
91 r++;
92 return r;
93}
94
95
96#ifndef __cuda_cuda_h__
97using std::min;
98using std::max;
99/*
100template <class T> inline T min(T x, T y) {return x<y?x:y;}
101template <class T> inline T min(T x, T y, T z) {return x<y?(x<z?x:z):(y<z?y:z);}
102template <class T> inline T max(T x, T y) {return x>y?x:y;}
103template <class T> inline T max(Tt x, T y, T z) {return x>y?(x>z?x:z):(y>z?y:z);}
104*/
105#endif
106
107#endif
bool isPower2(unsigned int x)
Definition Math.h:56
unsigned int log2(unsigned int x)
Definition Math.h:71