Ejemplo n.º 1
0
int main(void)
{
    flint_rand_t state;

    fmpz_t p;
    fmpz * v;

    long i;

    printf("number_of_partitions....");
    fflush(stdout);

    flint_randinit(state);

    fmpz_init(p);
    v = _fmpz_vec_init(3000);

    number_of_partitions_vec(v, 3000);

    for (i = 0; i < 3000; i++)
    {
        number_of_partitions(p, i);
        if (!fmpz_equal(p, v + i))
        {
            printf("FAIL:\n");
            printf("p(%ld) does not agree with power series\n", i);
            printf("Computed p(%ld): ", i); fmpz_print(p); printf("\n");
            printf("Expected: "); fmpz_print(v + i); printf("\n");
            abort();
        }
    }

    _fmpz_vec_clear(v, 3000);

    for (i = 0; testdata[i][0] != 0; i++)
    {
        number_of_partitions(p, testdata[i][0]);

        if (fmpz_fdiv_ui(p, 1000000000) != testdata[i][1])
        {
            printf("FAIL:\n");
            printf("p(%ld) does not agree with known value mod 10^9\n",
                testdata[i][0]);
            printf("Computed: %lu\n", fmpz_fdiv_ui(p, 1000000000));
            printf("Expected: %lu\n", testdata[i][1]);
            abort();
        }
    }

    fmpz_clear(p);

    flint_randclear(state);
    mpfr_free_cache();
    _fmpz_cleanup();
    printf("PASS\n");
    return 0;
}
Ejemplo n.º 2
0
    bool const run_reduce_task(unsigned const partition, results &result)
    {
        bool success = true;

        auto const start_time(std::chrono::system_clock::now());
        try
        {
            reduce_task_runner runner(
                specification_.output_filespec,
                partition,
                number_of_partitions(),
                intermediate_store_,
                result);
            runner.reduce();
        }
        catch (std::exception &e)
        {
            std::cerr << "\nError: " << e.what() << "\n";
            ++result.counters.reduce_key_errors;
            success = false;
        }

        result.reduce_times.push_back(std::chrono::system_clock::now() - start_time);

        return success;
    }
Ejemplo n.º 3
0
int
main(int argc, char * argv[])
{
    fmpz_t x;
    ulong n;

    if (argc != 2)
    {
        printf("usage: partitions n\n");
        return 1;
    }

    sscanf(argv[1], "%lu", &n);

    printf("p(%lu) = \n", n);

    fmpz_init(x);
    number_of_partitions(x, n);
    fmpz_print(x);
    printf("\n");
    fmpz_clear(x);

    return 0;
}