mirror of
https://github.com/vale981/arb
synced 2025-03-04 08:51:40 -05:00
mag_pow_fmpz: allow negative exponents
This commit is contained in:
parent
2746f165a3
commit
56c6b4de2e
5 changed files with 15 additions and 6 deletions
|
@ -378,13 +378,13 @@ Powers and logarithms
|
|||
|
||||
.. function:: void mag_pow_fmpz(mag_t res, const mag_t x, const fmpz_t e)
|
||||
|
||||
Sets *res* to an upper bound for `x^e`. Requires `e \ge 0`.
|
||||
Sets *res* to an upper bound for `x^e`.
|
||||
|
||||
.. function:: void mag_pow_ui_lower(mag_t res, const mag_t x, ulong e)
|
||||
|
||||
.. function:: void mag_pow_fmpz_lower(mag_t res, const mag_t x, const fmpz_t e)
|
||||
|
||||
Sets *res* to a lower bound for `x^e`. Requires `e \ge 0`.
|
||||
Sets *res* to a lower bound for `x^e`.
|
||||
|
||||
.. function:: void mag_sqrt(mag_t res, const mag_t x)
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ fmpr_pow_sloppy_fmpz(fmpr_t y, const fmpr_t b, const fmpz_t e,
|
|||
? FMPR_RND_UP : FMPR_RND_DOWN);
|
||||
fmpr_ui_div(y, UWORD(1), y, prec, rnd);
|
||||
fmpz_clear(f);
|
||||
return;
|
||||
}
|
||||
|
||||
if (y == b)
|
||||
|
|
|
@ -16,7 +16,12 @@ mag_pow_fmpz(mag_t z, const mag_t x, const fmpz_t e)
|
|||
{
|
||||
if (fmpz_sgn(e) < 0)
|
||||
{
|
||||
flint_abort();
|
||||
fmpz_t t;
|
||||
fmpz_init(t);
|
||||
fmpz_neg(t, e);
|
||||
mag_inv(z, x);
|
||||
mag_pow_fmpz(z, z, t);
|
||||
fmpz_clear(t);
|
||||
}
|
||||
else if (!COEFF_IS_MPZ(*e))
|
||||
{
|
||||
|
@ -50,7 +55,12 @@ mag_pow_fmpz_lower(mag_t z, const mag_t x, const fmpz_t e)
|
|||
{
|
||||
if (fmpz_sgn(e) < 0)
|
||||
{
|
||||
flint_abort();
|
||||
fmpz_t t;
|
||||
fmpz_init(t);
|
||||
fmpz_neg(t, e);
|
||||
mag_inv_lower(z, x);
|
||||
mag_pow_fmpz_lower(z, z, t);
|
||||
fmpz_clear(t);
|
||||
}
|
||||
else if (!COEFF_IS_MPZ(*e))
|
||||
{
|
||||
|
|
|
@ -38,7 +38,6 @@ int main()
|
|||
mag_randtest_special(xb, state, 80);
|
||||
mag_randtest_special(yb, state, 80);
|
||||
fmpz_randtest(e, state, 200);
|
||||
fmpz_abs(e, e);
|
||||
|
||||
mag_get_fmpr(x, xb);
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ int main()
|
|||
mag_randtest_special(xb, state, 80);
|
||||
mag_randtest_special(yb, state, 80);
|
||||
fmpz_randtest(e, state, 200);
|
||||
fmpz_abs(e, e);
|
||||
|
||||
mag_get_fmpr(x, xb);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue