mpz_export to file?
Paul.Zimmermann at inria.fr
Wed Dec 9 09:10:20 UTC 2015
mpz_export() exports an integer to some allocated array. For saving huge
integers to a file, this is not optimal since one has first to allocate a
huge array in memory, "export" the mpz_t to that array, and then copy that
array to memory.
Would it be possible to have a function that exports directly to a file
(and of course the corresponding import function)?
void mpz_export_file (FILE *f, mpz_t op);
void mpz_import_file (mpz_t op, FILE *f);
One could imagine a format where several numbers can be exported in the same
f = fopen ("toto", "w");
mpz_export_file (f, a);
mpz_export_file (f, b);
mpz_export_file (f, c);
f = fopen ("toto", "r");
mpz_import_file (a, f);
mpz_import_file (b, f);
mpz_import_file (c, f);
More information about the gmp-devel