1

In the library FLINT, we have the function fmpz_poly_clear to clear a fmpz_poly polynomial from the memory. But I am using the C++ interface of this library, so, my polynomials are of the type fmpz_polyxx or fmpz_mod_polyxx.

I would like to know how to clear these polynomials. I already searched on the FLINT's documentation, but I found nothing.

For instance, the following program creates a polynomial with seven million coefficients. On my machine, it uses about 1GB of RAM. After exiting the for loop, I try to delete the polynomial.

I am reading a integer after just to make the program wait before terminating the execution.

#include <iostream>
#include "flint/fmpzxx.h"
#include "flint/fmpz_mod_polyxx.h"
#include "flint/fmpz_mod_poly_factorxx.h"

using namespace flint;

int main(int argc, char *argv[])
{
    // q  (273-bit prime)
    fmpzxx q("15177100720513508366558296147058741458143803430094840009779784451085189728165691397");

    fmpz_mod_polyxx* myPoly = new fmpz_mod_polyxx(q); 
    for (int i = 0; i < 7000000; i++){
        myPoly->set_coeff(i, q - fmpzxx(i));
    }
    delete myPoly;             // <-- this line does not work
//  fmpz_poly_clear(myPoly);  // <-- this line does not work
//  fmpz_mod_polyxx_clear(myPoly); // <-- this one neither
    int a;
    std::cin >> a; // wait 
    return EXIT_SUCCESS;
}

Does someone know how to do it?

0 Answers0