Factorization of the mympz type

This commit is contained in:
Patrick Pelissier committed 2018-02-21 22:06:45 +01:00
1 parent 2ed95bfe16
commit ff3964e2eb
3 files changed
+42 -37

No files matched your search

+3 -31
View File
@@ -21,41 +21,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <gmp.h>
#include "mympz.h"
#include "m-array.h"
static void my_mpz_out_str(FILE *f, const mpz_t z)
{
mpz_out_str (f, 10, z);
}
static bool my_mpz_in_str(mpz_t z, FILE *f)
{
return mpz_inp_str (z, f, 10) > 0;
}
static bool my_mpz_equal_p(const mpz_t z1, const mpz_t z2)
{
return mpz_cmp (z1, z2) == 0;
}
#include "m-string.h"
static void my_mpz_str(string_t str, const mpz_t z, bool append)
{
char *s = mpz_get_str(NULL, 10, z);
assert (s != NULL);
if (append) string_cat_str (str, s);
else string_set_str (str, s);
free(s);
}
#include "coverage.h"
START_COVERAGE
ARRAY_DEF(array_uint, unsigned int)
ARRAY_DEF(array_mpz, mpz_t,
(INIT(mpz_init), INIT_SET(mpz_init_set), SET(mpz_set), CLEAR(mpz_clear), \
OUT_STR(my_mpz_out_str), IN_STR(my_mpz_in_str), EQUAL(my_mpz_equal_p), \
GET_STR(my_mpz_str) ))
ARRAY_DEF(array_mpz, mpz_t, MYMPZ_OPLIST)
END_COVERAGE
#define ARRAY_UINT_OPLIST ARRAY_OPLIST(array_uint)