mirror of
https://github.com/vale981/arb
synced 2025-03-05 17:31:38 -05:00
de-inline some more arb and acb methods
This commit is contained in:
parent
067831e0e2
commit
0be7de5ec4
7 changed files with 182 additions and 115 deletions
22
acb.h
22
acb.h
|
@ -50,26 +50,8 @@ acb_init(acb_t x)
|
||||||
|
|
||||||
void acb_clear(acb_t x);
|
void acb_clear(acb_t x);
|
||||||
|
|
||||||
ACB_INLINE acb_ptr
|
acb_ptr _acb_vec_init(slong n);
|
||||||
_acb_vec_init(slong n)
|
void _acb_vec_clear(acb_ptr v, slong n);
|
||||||
{
|
|
||||||
slong i;
|
|
||||||
acb_ptr v = (acb_ptr) flint_malloc(sizeof(acb_struct) * n);
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
acb_init(v + i);
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
ACB_INLINE void
|
|
||||||
_acb_vec_clear(acb_ptr v, slong n)
|
|
||||||
{
|
|
||||||
slong i;
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
acb_clear(v + i);
|
|
||||||
flint_free(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
ACB_INLINE arb_ptr acb_real_ptr(acb_t z) { return acb_realref(z); }
|
ACB_INLINE arb_ptr acb_real_ptr(acb_t z) { return acb_realref(z); }
|
||||||
ACB_INLINE arb_ptr acb_imag_ptr(acb_t z) { return acb_imagref(z); }
|
ACB_INLINE arb_ptr acb_imag_ptr(acb_t z) { return acb_imagref(z); }
|
||||||
|
|
21
acb/vec_clear.c
Normal file
21
acb/vec_clear.c
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2014 Fredrik Johansson
|
||||||
|
|
||||||
|
This file is part of Arb.
|
||||||
|
|
||||||
|
Arb is free software: you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||||
|
by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "acb.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
_acb_vec_clear(acb_ptr v, slong n)
|
||||||
|
{
|
||||||
|
slong i;
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
acb_clear(v + i);
|
||||||
|
flint_free(v);
|
||||||
|
}
|
24
acb/vec_init.c
Normal file
24
acb/vec_init.c
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2014 Fredrik Johansson
|
||||||
|
|
||||||
|
This file is part of Arb.
|
||||||
|
|
||||||
|
Arb is free software: you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||||
|
by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "acb.h"
|
||||||
|
|
||||||
|
acb_ptr
|
||||||
|
_acb_vec_init(slong n)
|
||||||
|
{
|
||||||
|
slong i;
|
||||||
|
acb_ptr v = (acb_ptr) flint_malloc(sizeof(acb_struct) * n);
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
acb_init(v + i);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
109
arb.h
109
arb.h
|
@ -56,26 +56,8 @@ arb_init(arb_t x)
|
||||||
|
|
||||||
void arb_clear(arb_t x);
|
void arb_clear(arb_t x);
|
||||||
|
|
||||||
ARB_INLINE arb_ptr
|
arb_ptr _arb_vec_init(slong n);
|
||||||
_arb_vec_init(slong n)
|
void _arb_vec_clear(arb_ptr v, slong n);
|
||||||
{
|
|
||||||
slong i;
|
|
||||||
arb_ptr v = (arb_ptr) flint_malloc(sizeof(arb_struct) * n);
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
arb_init(v + i);
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
ARB_INLINE void
|
|
||||||
_arb_vec_clear(arb_ptr v, slong n)
|
|
||||||
{
|
|
||||||
slong i;
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
arb_clear(v + i);
|
|
||||||
flint_free(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
ARB_INLINE arf_ptr arb_mid_ptr(arb_t z) { return arb_midref(z); }
|
ARB_INLINE arf_ptr arb_mid_ptr(arb_t z) { return arb_midref(z); }
|
||||||
ARB_INLINE mag_ptr arb_rad_ptr(arb_t z) { return arb_radref(z); }
|
ARB_INLINE mag_ptr arb_rad_ptr(arb_t z) { return arb_radref(z); }
|
||||||
|
@ -99,6 +81,7 @@ arb_equal_si(const arb_t x, slong y)
|
||||||
return arf_equal_si(arb_midref(x), y) && mag_is_zero(arb_radref(x));
|
return arf_equal_si(arb_midref(x), y) && mag_is_zero(arb_radref(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* implementations are in arb/richcmp.c */
|
||||||
int arb_eq(const arb_t x, const arb_t y);
|
int arb_eq(const arb_t x, const arb_t y);
|
||||||
int arb_ne(const arb_t x, const arb_t y);
|
int arb_ne(const arb_t x, const arb_t y);
|
||||||
int arb_lt(const arb_t x, const arb_t y);
|
int arb_lt(const arb_t x, const arb_t y);
|
||||||
|
@ -292,81 +275,17 @@ arb_is_int_2exp_si(const arb_t x, slong e)
|
||||||
arf_is_int_2exp_si(arb_midref(x), e);
|
arf_is_int_2exp_si(arb_midref(x), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
ARB_INLINE int
|
/* implementations are in arb/richcmp.c */
|
||||||
arb_contains_zero(const arb_t x)
|
int arb_contains_zero(const arb_t x);
|
||||||
{
|
int arb_is_nonzero(const arb_t x);
|
||||||
return arf_cmpabs_mag(arb_midref(x), arb_radref(x)) <= 0;
|
int arb_is_positive(const arb_t x);
|
||||||
}
|
int arb_is_nonnegative(const arb_t x);
|
||||||
|
int arb_is_negative(const arb_t x);
|
||||||
ARB_INLINE int
|
int arb_is_nonpositive(const arb_t x);
|
||||||
arb_is_nonzero(const arb_t x)
|
int arb_contains_negative(const arb_t x);
|
||||||
{
|
int arb_contains_nonpositive(const arb_t x);
|
||||||
return !arb_contains_zero(x);
|
int arb_contains_positive(const arb_t x);
|
||||||
}
|
int arb_contains_nonnegative(const arb_t x);
|
||||||
|
|
||||||
ARB_INLINE int
|
|
||||||
arb_is_positive(const arb_t x)
|
|
||||||
{
|
|
||||||
return (arf_sgn(arb_midref(x)) > 0) &&
|
|
||||||
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) < 0) &&
|
|
||||||
!arf_is_nan(arb_midref(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
ARB_INLINE int
|
|
||||||
arb_is_nonnegative(const arb_t x)
|
|
||||||
{
|
|
||||||
return (arf_sgn(arb_midref(x)) >= 0) &&
|
|
||||||
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) <= 0) &&
|
|
||||||
!arf_is_nan(arb_midref(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
ARB_INLINE int
|
|
||||||
arb_is_negative(const arb_t x)
|
|
||||||
{
|
|
||||||
return (arf_sgn(arb_midref(x)) < 0) &&
|
|
||||||
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) < 0) &&
|
|
||||||
!arf_is_nan(arb_midref(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
ARB_INLINE int
|
|
||||||
arb_is_nonpositive(const arb_t x)
|
|
||||||
{
|
|
||||||
return (arf_sgn(arb_midref(x)) <= 0) &&
|
|
||||||
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) <= 0) &&
|
|
||||||
!arf_is_nan(arb_midref(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
ARB_INLINE int
|
|
||||||
arb_contains_negative(const arb_t x)
|
|
||||||
{
|
|
||||||
return (arf_sgn(arb_midref(x)) < 0) ||
|
|
||||||
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) > 0)
|
|
||||||
|| arf_is_nan(arb_midref(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
ARB_INLINE int
|
|
||||||
arb_contains_nonpositive(const arb_t x)
|
|
||||||
{
|
|
||||||
return (arf_sgn(arb_midref(x)) <= 0) ||
|
|
||||||
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) >= 0)
|
|
||||||
|| arf_is_nan(arb_midref(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
ARB_INLINE int
|
|
||||||
arb_contains_positive(const arb_t x)
|
|
||||||
{
|
|
||||||
return (arf_sgn(arb_midref(x)) > 0) ||
|
|
||||||
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) > 0)
|
|
||||||
|| arf_is_nan(arb_midref(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
ARB_INLINE int
|
|
||||||
arb_contains_nonnegative(const arb_t x)
|
|
||||||
{
|
|
||||||
return (arf_sgn(arb_midref(x)) >= 0) ||
|
|
||||||
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) >= 0)
|
|
||||||
|| arf_is_nan(arb_midref(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
void arb_get_mag_lower(mag_t z, const arb_t x);
|
void arb_get_mag_lower(mag_t z, const arb_t x);
|
||||||
|
|
||||||
|
|
|
@ -163,3 +163,79 @@ int arb_ge(const arb_t x, const arb_t y)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
arb_contains_zero(const arb_t x)
|
||||||
|
{
|
||||||
|
return arf_cmpabs_mag(arb_midref(x), arb_radref(x)) <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
arb_is_nonzero(const arb_t x)
|
||||||
|
{
|
||||||
|
return !arb_contains_zero(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
arb_is_positive(const arb_t x)
|
||||||
|
{
|
||||||
|
return (arf_sgn(arb_midref(x)) > 0) &&
|
||||||
|
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) < 0) &&
|
||||||
|
!arf_is_nan(arb_midref(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
arb_is_nonnegative(const arb_t x)
|
||||||
|
{
|
||||||
|
return (arf_sgn(arb_midref(x)) >= 0) &&
|
||||||
|
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) <= 0) &&
|
||||||
|
!arf_is_nan(arb_midref(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
arb_is_negative(const arb_t x)
|
||||||
|
{
|
||||||
|
return (arf_sgn(arb_midref(x)) < 0) &&
|
||||||
|
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) < 0) &&
|
||||||
|
!arf_is_nan(arb_midref(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
arb_is_nonpositive(const arb_t x)
|
||||||
|
{
|
||||||
|
return (arf_sgn(arb_midref(x)) <= 0) &&
|
||||||
|
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) <= 0) &&
|
||||||
|
!arf_is_nan(arb_midref(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
arb_contains_negative(const arb_t x)
|
||||||
|
{
|
||||||
|
return (arf_sgn(arb_midref(x)) < 0) ||
|
||||||
|
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) > 0)
|
||||||
|
|| arf_is_nan(arb_midref(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
arb_contains_nonpositive(const arb_t x)
|
||||||
|
{
|
||||||
|
return (arf_sgn(arb_midref(x)) <= 0) ||
|
||||||
|
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) >= 0)
|
||||||
|
|| arf_is_nan(arb_midref(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
arb_contains_positive(const arb_t x)
|
||||||
|
{
|
||||||
|
return (arf_sgn(arb_midref(x)) > 0) ||
|
||||||
|
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) > 0)
|
||||||
|
|| arf_is_nan(arb_midref(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
arb_contains_nonnegative(const arb_t x)
|
||||||
|
{
|
||||||
|
return (arf_sgn(arb_midref(x)) >= 0) ||
|
||||||
|
(arf_mag_cmpabs(arb_radref(x), arb_midref(x)) >= 0)
|
||||||
|
|| arf_is_nan(arb_midref(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
21
arb/vec_clear.c
Normal file
21
arb/vec_clear.c
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2014 Fredrik Johansson
|
||||||
|
|
||||||
|
This file is part of Arb.
|
||||||
|
|
||||||
|
Arb is free software: you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||||
|
by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "arb.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
_arb_vec_clear(arb_ptr v, slong n)
|
||||||
|
{
|
||||||
|
slong i;
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
arb_clear(v + i);
|
||||||
|
flint_free(v);
|
||||||
|
}
|
24
arb/vec_init.c
Normal file
24
arb/vec_init.c
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2014 Fredrik Johansson
|
||||||
|
|
||||||
|
This file is part of Arb.
|
||||||
|
|
||||||
|
Arb is free software: you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||||
|
by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "arb.h"
|
||||||
|
|
||||||
|
arb_ptr
|
||||||
|
_arb_vec_init(slong n)
|
||||||
|
{
|
||||||
|
slong i;
|
||||||
|
arb_ptr v = (arb_ptr) flint_malloc(sizeof(arb_struct) * n);
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
arb_init(v + i);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue