Ice Sheet System Model
4.18
Code documentation
src
c
shared
Bamg
BigPrimeNumber.cpp
Go to the documentation of this file.
1
#include "
./Abs.h
"
2
#include "
./extrema.h
"
3
4
namespace
bamg
{
5
6
long
BigPrimeNumber
(
long
n){
7
/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/AGoodNumberPrimeWith)*/
8
9
/*list of big prime numbers*/
10
const
long
BigPrimeNumber
[] ={ 567890359L,
11
567890431L, 567890437L, 567890461L, 567890471L,
12
567890483L, 567890489L, 567890497L, 567890507L,
13
567890591L, 567890599L, 567890621L, 567890629L , 0};
14
15
/*initialize o and pi*/
16
long
o = 0;
17
long
pi =
BigPrimeNumber
[1];
18
19
/*loop until BigPrimeNumber[i]==0 (end of BigPrimeNumber)*/
20
for
(
int
i=0;
BigPrimeNumber
[i]; i++){
21
22
/*compute r, remainder of the division of BigPrimeNumber[i] by n*/
23
long
r =
BigPrimeNumber
[i] % n;
24
25
/*compute oo = min ( r , n-r , |n - 2r|, |n-3r|)*/
26
long
oo =
Min
(
Min
(r,n-r),
Min
(
Abs
(n-2*r),
Abs
(n-3*r)));
27
if
(o < oo){
28
o = oo;
29
pi =
BigPrimeNumber
[i];
30
}
31
}
32
return
pi;
33
}
34
}
extrema.h
Abs.h
bamg
Definition:
AdjacentTriangle.cpp:9
bamg::BigPrimeNumber
long BigPrimeNumber(long n)
Definition:
BigPrimeNumber.cpp:6
bamg::Abs
T Abs(const T &a)
Definition:
Abs.h:5
bamg::Min
T Min(const T &a, const T &b)
Definition:
extrema.h:6
Generated on Thu Jul 2 2020 08:09:19 for Ice Sheet System Model by
1.8.19