Example #1
0
void tst_prime_generator() {
    unsynch_mpz_manager m;
    scoped_mpz sqrt_p(m);

    prime_generator gen;
    for (unsigned i = 0; i < 10000; i++) {
        uint64 p = gen(i);
        std::cout << p << ", ";
        if (i % 11 == 0) std::cout << "\n";
        std::cout.flush();
        if (p == 2)
            continue;
        m.set(sqrt_p, p);
        m.root(sqrt_p, 2);
        uint64 k = m.get_uint64(sqrt_p);
        for (uint64 i = 2; i <= k; i++) {
            SASSERT(p % i != 0);
        }
    }
    std::cout << std::endl;
}
Example #2
0
File: math.c Project: liuyang1/test
/** Euclidean distance function */
double hypot(double x, double y) {
    return sqrt_p(square(x) + square(y));
}