Lines Matching refs:src
44 #define isEven(src) (!((src) & 0x1))
45 #define hasFactor(src,n) ( (((src)!=(n)) && ((src)%(n) == 0)) )
46 #define BitIsSet(src,b) ( ((src) & (1<<(b))) != 0 )
142 static unsigned int numberOfBits(unsigned int src)
146 if (src == 0)
150 if (BitIsSet(src,b))
158 static int isWitness(unsigned int witness, unsigned int src)
160 unsigned int bitNum = numberOfBits(src-1)-1;
168 d = u64_mulmod(d,d,src);
170 if (d == 1 && x != 1 && x != src-1)
173 if (BitIsSet(src-1,i))
174 d = u64_mulmod(d,witness,src);
181 static int isMillerRabinPrime(unsigned int src)
187 unsigned int witness = Random(src-1);
189 if (isWitness(witness,src))
201 static int hasEasyFactors(unsigned int src)
203 return hasFactor(src, 3)
204 || hasFactor(src, 5)
205 || hasFactor(src, 7)
206 || hasFactor(src, 11)
207 || hasFactor(src, 13);
211 static int isPrime(unsigned int src)
213 if (hasEasyFactors(src))
216 return isMillerRabinPrime(src);
224 unsigned int bdd_prime_gte(unsigned int src)
226 if (isEven(src))
227 --src;
229 while (!isPrime(src))
230 src -= 2;
232 return src;
236 unsigned int bdd_prime_lte(unsigned int src)
238 if (isEven(src))
239 --src;
241 while (!isPrime(src))
242 src -= 2;
244 return src;