]> www.ginac.de Git - cln.git/blob - src/numtheory/cl_IF_trialdiv2.cc
* m4/param.m4: Add support for MinGW.
[cln.git] / src / numtheory / cl_IF_trialdiv2.cc
1 // cl_trialdivision().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_IF.h"
8
9
10 // Implementation.
11
12 #include "cl_low.h"
13
14 namespace cln {
15
16 uint32 cl_trialdivision (uint32 nhi, uint32 nlo, uint32 d1, uint32 d2)
17 {
18         var uintL i = cl_small_prime_table_search(d1);
19         var const uint16 * ptr = &cl_small_prime_table[i];
20         var const uint16 * ptr_limit = &cl_small_prime_table[cl_small_prime_table_search(d2+1)];
21         for ( ; ptr < ptr_limit; ptr++) {
22                 var uint32 prime = *ptr;
23                 var uint32 hi;
24                 var uint32 r;
25                 hi = nhi % prime; // or: divu_3232_3232(nhi,prime,,hi=);
26                 divu_6432_3232(hi,nlo,prime,,r=);
27                 if (r == 0)
28                         return prime;
29         }
30         return 0;
31 }
32
33 }  // namespace cln