Skip to content

Commit

Permalink
Merge pull request #2035 from albinahlback/arith_deprecate
Browse files Browse the repository at this point in the history
Touch up arith stuff
  • Loading branch information
albinahlback authored Jul 18, 2024
2 parents 7a6d852 + bd110e3 commit 886c317
Show file tree
Hide file tree
Showing 14 changed files with 454 additions and 647 deletions.
823 changes: 420 additions & 403 deletions configure.ac

Large diffs are not rendered by default.

31 changes: 0 additions & 31 deletions doc/source/arith.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@
This module implements arithmetic functions, number-theoretic and
combinatorial special number sequences and polynomials.

Primorials
--------------------------------------------------------------------------------


.. function:: void arith_primorial(fmpz_t res, slong n)

Sets ``res`` to ``n`` primorial or `n \#`, the product of all prime
numbers less than or equal to `n`.


Harmonic numbers
--------------------------------------------------------------------------------

Expand Down Expand Up @@ -343,12 +333,6 @@ Multiplicative functions
--------------------------------------------------------------------------------


.. function:: void arith_euler_phi(fmpz_t res, const fmpz_t n)
int arith_moebius_mu(const fmpz_t n)
void arith_divisor_sigma(fmpz_t res, ulong k, const fmpz_t n)

These are aliases for the functions in the fmpz module.

.. function:: void arith_divisors(fmpz_poly_t res, const fmpz_t n)

Set the coefficients of the polynomial ``res`` to the divisors of `n`,
Expand Down Expand Up @@ -409,21 +393,6 @@ Landau's function
`O(n^{3/2} / \sqrt{\log n})`.



Dedekind sums
--------------------------------------------------------------------------------


.. function:: void arith_dedekind_sum_naive(fmpq_t s, const fmpz_t h, const fmpz_t k)
double arith_dedekind_sum_coprime_d(double h, double k)
void arith_dedekind_sum_coprime_large(fmpq_t s, const fmpz_t h, const fmpz_t k)
void arith_dedekind_sum_coprime(fmpq_t s, const fmpz_t h, const fmpz_t k)
void arith_dedekind_sum(fmpq_t s, const fmpz_t h, const fmpz_t k)


These are aliases for the functions in the fmpq module.


Number of partitions
--------------------------------------------------------------------------------

Expand Down
10 changes: 5 additions & 5 deletions examples/poly_roots.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,35 @@ int main(int argc, char *argv[])
}
else if (!strcmp(argv[i], "t"))
{
arith_chebyshev_t_polynomial(g, atol(argv[i+1]));
fmpz_poly_chebyshev_t(g, atol(argv[i+1]));
fmpz_poly_mul(f, f, g);
i++;
}
else if (!strcmp(argv[i], "u"))
{
arith_chebyshev_u_polynomial(g, atol(argv[i+1]));
fmpz_poly_chebyshev_u(g, atol(argv[i+1]));
fmpz_poly_mul(f, f, g);
i++;
}
else if (!strcmp(argv[i], "p"))
{
fmpq_poly_t h;
fmpq_poly_init(h);
arith_legendre_polynomial(h, atol(argv[i+1]));
fmpq_poly_legendre_p(h, atol(argv[i+1]));
fmpq_poly_get_numerator(g, h);
fmpz_poly_mul(f, f, g);
fmpq_poly_clear(h);
i++;
}
else if (!strcmp(argv[i], "c"))
{
arith_cyclotomic_polynomial(g, atol(argv[i+1]));
fmpz_poly_cyclotomic(g, atol(argv[i+1]));
fmpz_poly_mul(f, f, g);
i++;
}
else if (!strcmp(argv[i], "s"))
{
arith_swinnerton_dyer_polynomial(g, atol(argv[i+1]));
fmpz_poly_swinnerton_dyer(g, atol(argv[i+1]));
fmpz_poly_mul(f, f, g);
i++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/acb_modular/test/t-epsilon_arg.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ acb_modular_epsilon_arg_naive(fmpq_t arg, const psl2z_t g)
fmpz_mul_ui(fmpq_denref(arg), c, 12);
fmpq_canonicalise(arg);

arith_dedekind_sum(t, d, c);
fmpq_dedekind_sum(t, d, c);
fmpq_sub(arg, arg, t);

fmpq_clear(t);
Expand Down
10 changes: 5 additions & 5 deletions src/arb_fmpz_poly/test/t-complex_roots.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,20 @@ TEST_FUNCTION_START(arb_fmpz_poly_complex_roots, state)
fmpz_poly_set_coeff_ui(g, j, j+1);
break;
case 1:
arith_chebyshev_t_polynomial(g, n);
fmpz_poly_chebyshev_t(g, n);
break;
case 2:
arith_chebyshev_u_polynomial(g, n);
fmpz_poly_chebyshev_u(g, n);
break;
case 3:
arith_legendre_polynomial(h, n);
fmpq_poly_legendre_p(h, n);
fmpq_poly_get_numerator(g, h);
break;
case 4:
arith_cyclotomic_polynomial(g, n);
fmpz_poly_cyclotomic(g, n);
break;
case 5:
arith_swinnerton_dyer_polynomial(g, n % 4);
fmpz_poly_swinnerton_dyer(g, n % 4);
break;
case 6:
arith_bernoulli_polynomial(h, n);
Expand Down
2 changes: 1 addition & 1 deletion src/arb_hypgeom/test/t-legendre_p_ui_root.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ TEST_FUNCTION_START(arb_hypgeom_legendre_p_ui_root, state)

arb_poly_product_roots(pol, roots, n, prec);
/* fmpq_poly_legendre_p(pol2, n); */
arith_legendre_polynomial(pol2, n);
fmpq_poly_legendre_p(pol2, n);
arb_set_fmpz(s, pol2->coeffs + n);
arb_div_fmpz(s, s, pol2->den, prec);
arb_poly_scalar_mul(pol, pol, s, prec);
Expand Down
48 changes: 18 additions & 30 deletions src/arith.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

/* Various arithmetic functions **********************************************/

#define arith_primorial fmpz_primorial

void _arith_harmonic_number(fmpz_t num, fmpz_t den, slong n);
void arith_harmonic_number(fmpq_t x, slong n);

Expand All @@ -30,10 +28,6 @@ void arith_ramanujan_tau_series(fmpz_poly_t res, slong n);

void arith_divisors(fmpz_poly_t res, const fmpz_t n);

#define arith_divisor_sigma fmpz_divisor_sigma
#define arith_moebius_mu fmpz_moebius_mu
#define arith_euler_phi fmpz_euler_phi

/* Stirling numbers **********************************************************/

void arith_stirling_number_1u(fmpz_t s, ulong n, ulong k);
Expand Down Expand Up @@ -136,34 +130,10 @@ void arith_bernoulli_polynomial(fmpq_poly_t poly, ulong n);
void _arith_bernoulli_number_vec_multi_mod(fmpz * num, fmpz * den, slong n);
void _arith_bernoulli_number_vec_recursive(fmpz * num, fmpz * den, slong n);

/* Cyclotomic polynomials ****************************************************/

#define _arith_cyclotomic_polynomial _fmpz_poly_cyclotomic
#define arith_cyclotomic_polynomial fmpz_poly_cyclotomic

/* Hypergeometric polynomials ************************************************/

#define _arith_chebyshev_t_polynomial _fmpz_poly_chebyshev_t
#define arith_chebyshev_t_polynomial fmpz_poly_chebyshev_t
#define _arith_chebyshev_u_polynomial _fmpz_poly_chebyshev_u
#define arith_chebyshev_u_polynomial fmpz_poly_chebyshev_u

#define arith_legendre_polynomial fmpq_poly_legendre_p

/* Swinnerton-Dyer polynomials ***********************************************/

#define _arith_swinnerton_dyer_polynomial _fmpz_poly_swinnerton_dyer
#define arith_swinnerton_dyer_polynomial fmpz_poly_swinnerton_dyer

/* Landau function ***********************************************************/

void arith_landau_function_vec(fmpz * res, slong len);

/* Dedekind sums *************************************************************/

#define arith_dedekind_sum_naive fmpq_dedekind_sum_naive
#define arith_dedekind_sum fmpq_dedekind_sum

/* Exponential sums **********************************************************/

typedef struct
Expand Down Expand Up @@ -202,6 +172,24 @@ void arith_number_of_partitions(fmpz_t x, ulong n);
void arith_sum_of_squares(fmpz_t r, ulong k, const fmpz_t n);
void arith_sum_of_squares_vec(fmpz * r, ulong k, slong n);

/* to be deprecated **********************************************************/

#define arith_primorial fmpz_primorial
#define arith_divisor_sigma fmpz_divisor_sigma
#define arith_moebius_mu fmpz_moebius_mu
#define arith_euler_phi fmpz_euler_phi
#define _arith_cyclotomic_polynomial _fmpz_poly_cyclotomic
#define arith_cyclotomic_polynomial fmpz_poly_cyclotomic
#define _arith_chebyshev_t_polynomial _fmpz_poly_chebyshev_t
#define arith_chebyshev_t_polynomial fmpz_poly_chebyshev_t
#define _arith_chebyshev_u_polynomial _fmpz_poly_chebyshev_u
#define arith_chebyshev_u_polynomial fmpz_poly_chebyshev_u
#define arith_legendre_polynomial fmpq_poly_legendre_p
#define _arith_swinnerton_dyer_polynomial _fmpz_poly_swinnerton_dyer
#define arith_swinnerton_dyer_polynomial fmpz_poly_swinnerton_dyer
#define arith_dedekind_sum_naive fmpq_dedekind_sum_naive
#define arith_dedekind_sum fmpq_dedekind_sum

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/arith/bernoulli_number_vec_recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ __ramanujan_even_common_denom(fmpz * num, fmpz * den, slong start, slong n)
fmpz_init(cden);

/* Common denominator */
arith_primorial(cden, n + 1);
fmpz_primorial(cden, n + 1);

start += start % 2;

Expand Down
2 changes: 1 addition & 1 deletion src/arith/bernoulli_polynomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void arith_bernoulli_polynomial(fmpq_poly_t poly, ulong n)
}

/* Convert to common denominator */
arith_primorial(poly->den, n + 2);
fmpz_primorial(poly->den, n + 2);
for (k = 0; k <= n; k++)
{
fmpz_mul(poly->coeffs + k, poly->coeffs+k, poly->den);
Expand Down
4 changes: 2 additions & 2 deletions src/arith/sum_of_squares.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ sum_of_four_squares(fmpz_t r, const fmpz_t n)

if (v == 0)
{
arith_divisor_sigma(r, 1, n);
fmpz_divisor_sigma(r, 1, n);
fmpz_mul_ui(r, r, 8);
}
else
{
fmpz_tdiv_q_2exp(r, n, v);
arith_divisor_sigma(r, 1, r);
fmpz_divisor_sigma(r, 1, r);
fmpz_mul_ui(r, r, 24);
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/arith/test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include "t-bernoulli_number_denom.c"
#include "t-bernoulli_number_vec.c"
#include "t-bernoulli_polynomial.c"
#include "t-chebyshev_t_polynomial.c"
#include "t-chebyshev_u_polynomial.c"
#include "t-divisors.c"
#include "t-euler_number_vec.c"
#include "t-euler_number_zeta.c"
Expand All @@ -34,7 +32,6 @@
#include "t-ramanujan_tau.c"
#include "t-stirling.c"
#include "t-sum_of_squares.c"
#include "t-swinnerton_dyer_polynomial.c"

/* Array of test functions ***************************************************/

Expand All @@ -49,8 +46,6 @@ test_struct tests[] =
TEST_FUNCTION(arith_bernoulli_number_denom),
TEST_FUNCTION(arith_bernoulli_number_vec),
TEST_FUNCTION(arith_bernoulli_polynomial),
TEST_FUNCTION(arith_chebyshev_t_polynomial),
TEST_FUNCTION(arith_chebyshev_u_polynomial),
TEST_FUNCTION(arith_divisors),
TEST_FUNCTION(arith_euler_number_vec),
TEST_FUNCTION(arith_euler_number_zeta),
Expand All @@ -61,7 +56,6 @@ test_struct tests[] =
TEST_FUNCTION(arith_ramanujan_tau),
TEST_FUNCTION(arith_stirling),
TEST_FUNCTION(arith_sum_of_squares),
TEST_FUNCTION(arith_swinnerton_dyer_polynomial)
};

/* main function *************************************************************/
Expand Down
58 changes: 0 additions & 58 deletions src/arith/test/t-chebyshev_t_polynomial.c

This file was deleted.

48 changes: 0 additions & 48 deletions src/arith/test/t-chebyshev_u_polynomial.c

This file was deleted.

Loading

0 comments on commit 886c317

Please sign in to comment.