Added test case for nthroot aliasing and fixed code.
This commit is contained in:
parent
37fa4fd80b
commit
11327b1554
@ -60,7 +60,7 @@ mpz_nthroot (mpz_ptr root, mpz_srcptr u, mpir_ui nth)
|
||||
|
||||
if (root == u)
|
||||
{
|
||||
MPZ_TMP_INIT(tmp_u, rootn);
|
||||
MPZ_TMP_INIT(tmp_u, ABS(u->_mp_size));
|
||||
mpz_set(tmp_u, u);
|
||||
u = tmp_u;
|
||||
}
|
||||
|
@ -252,6 +252,32 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* test case reported by Alex Dyachenko */
|
||||
{
|
||||
mpz_t a, cube;
|
||||
|
||||
mpz_init_set_str(a, "8984948281360922385394772450147012613851354303", 10);
|
||||
|
||||
mpz_init(cube);
|
||||
mpz_mul(cube, a, a);
|
||||
mpz_mul(cube, cube, a);
|
||||
|
||||
mpz_set(root1, cube);
|
||||
mpz_nthroot(root1, root1, 3);
|
||||
|
||||
mpz_nthroot(root2, cube, 3);
|
||||
|
||||
if (mpz_cmp(root1, root2) != 0)
|
||||
{
|
||||
printf("nthroot aliasing failed\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
mpz_clear(cube);
|
||||
mpz_clear(a);
|
||||
}
|
||||
|
||||
mpz_clear (bs);
|
||||
mpz_clear (x2);
|
||||
mpz_clear (root1);
|
||||
|
Loading…
Reference in New Issue
Block a user