Skip to content

Commit

Permalink
Unify arith tests
Browse files Browse the repository at this point in the history
  • Loading branch information
albinahlback committed Oct 18, 2023
1 parent 24ce62b commit 2f13edc
Show file tree
Hide file tree
Showing 23 changed files with 142 additions and 184 deletions.
69 changes: 69 additions & 0 deletions src/arith/test/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright (C) 2023 Albin Ahlbäck
This file is part of FLINT.
FLINT 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 <https://www.gnu.org/licenses/>.
*/

#include <string.h>

/* Include functions *********************************************************/

#include "t-bell_number.c"
#include "t-bell_number_multi_mod.c"
#include "t-bell_number_nmod.c"
#include "t-bell_number_nmod_vec.c"
#include "t-bell_number_vec.c"
#include "t-bernoulli_number.c"
#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"
#include "t-euler_polynomial.c"
#include "t-harmonic_number.c"
#include "t-landau_function_vec.c"
#include "t-number_of_partitions_vec.c"
#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 ***************************************************/

test_struct tests[] =
{
TEST_FUNCTION(arith_bell_number),
TEST_FUNCTION(arith_bell_number_multi_mod),
TEST_FUNCTION(arith_bell_number_nmod),
TEST_FUNCTION(arith_bell_number_nmod_vec),
TEST_FUNCTION(arith_bell_number_vec),
TEST_FUNCTION(arith_bernoulli_number),
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),
TEST_FUNCTION(arith_euler_polynomial),
TEST_FUNCTION(arith_harmonic_number),
TEST_FUNCTION(arith_landau_function_vec),
TEST_FUNCTION(arith_number_of_partitions_vec),
TEST_FUNCTION(arith_ramanujan_tau),
TEST_FUNCTION(arith_stirling),
TEST_FUNCTION(arith_sum_of_squares),
TEST_FUNCTION(arith_swinnerton_dyer_polynomial)
};

/* main function *************************************************************/

TEST_MAIN(tests)
13 changes: 3 additions & 10 deletions src/arith/test/t-bell_number.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "test_helpers.h"
#include "nmod.h"
#include "nmod_vec.h"
#include "fmpz.h"
Expand All @@ -25,13 +26,8 @@
#define MAXN_VEC 500
#endif

int main(void)
TEST_FUNCTION_START(arith_bell_number, state)
{
FLINT_TEST_INIT(state);

flint_printf("bell_number....");
fflush(stdout);

{
slong len, prev_len;
fmpz * vb1, * vb2;
Expand Down Expand Up @@ -147,8 +143,5 @@ int main(void)
fmpz_clear(b);
}

FLINT_TEST_CLEANUP(state);

flint_printf("PASS\n");
return 0;
TEST_FUNCTION_END(state);
}
13 changes: 3 additions & 10 deletions src/arith/test/t-bell_number_multi_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "test_helpers.h"
#include "fmpz.h"
#include "arith.h"

int main(void)
TEST_FUNCTION_START(arith_bell_number_multi_mod, state)
{
slong i;

FLINT_TEST_INIT(state);

flint_printf("bell_number_multi_mod....");
fflush(stdout);

for (i = 0; i < 100; i++)
{
slong n;
Expand All @@ -46,8 +42,5 @@ int main(void)
fmpz_clear(b2);
}

FLINT_TEST_CLEANUP(state);

flint_printf("PASS\n");
return 0;
TEST_FUNCTION_END(state);
}
13 changes: 3 additions & 10 deletions src/arith/test/t-bell_number_nmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "test_helpers.h"
#include "nmod.h"
#include "nmod_vec.h"
#include "arith.h"

int main(void)
TEST_FUNCTION_START(arith_bell_number_nmod, state)
{
slong i, j, iter;

FLINT_TEST_INIT(state);

flint_printf("bell_number_nmod....");
fflush(stdout);

for (i = 0; i < 100 * flint_test_multiplier(); i++)
{
mp_ptr b;
Expand Down Expand Up @@ -56,8 +52,5 @@ int main(void)
_nmod_vec_clear(b);
}

FLINT_TEST_CLEANUP(state);

flint_printf("PASS\n");
return 0;
TEST_FUNCTION_END(state);
}
12 changes: 3 additions & 9 deletions src/arith/test/t-bell_number_nmod_vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,18 @@
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "test_helpers.h"
#include "nmod.h"
#include "nmod_vec.h"
#include "arith.h"

int main(void)
TEST_FUNCTION_START(arith_bell_number_nmod_vec, state)
{
mp_ptr b1, b2, b3;
slong n;

const slong maxn = 3000;

FLINT_TEST_INIT(state);

flint_printf("bell_number_nmod_vec....");
fflush(stdout);

b1 = _nmod_vec_init(maxn);
b2 = _nmod_vec_init(maxn);
Expand Down Expand Up @@ -66,8 +63,5 @@ int main(void)
_nmod_vec_clear(b2);
_nmod_vec_clear(b3);

FLINT_TEST_CLEANUP(state);

flint_printf("PASS\n");
return 0;
TEST_FUNCTION_END(state);
}
11 changes: 3 additions & 8 deletions src/arith/test/t-bell_number_vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,18 @@
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "test_helpers.h"
#include "fmpz_vec.h"
#include "arith.h"

int main(void)
TEST_FUNCTION_START(arith_bell_number_vec, state)
{
fmpz * b1;
fmpz * b2;
slong n;

const slong maxn = 1000;

FLINT_TEST_INIT(state);

flint_printf("bell_number_vec....");
fflush(stdout);

b1 = _fmpz_vec_init(maxn);
b2 = _fmpz_vec_init(maxn);
Expand All @@ -45,7 +42,5 @@ int main(void)
_fmpz_vec_clear(b1, maxn);
_fmpz_vec_clear(b2, maxn);

FLINT_TEST_CLEANUP(state);
flint_printf("PASS\n");
return 0;
TEST_FUNCTION_END(state);
}
11 changes: 3 additions & 8 deletions src/arith/test/t-bernoulli_number.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "test_helpers.h"
#include "fmpz.h"
#include "fmpz_vec.h"
#include "fmpq.h"
#include "arith.h"

int main(void)
TEST_FUNCTION_START(arith_bernoulli_number, state)
{
fmpz * num1;
fmpz * den1;
fmpz_t num2;
fmpz_t den2;
slong n, N;

FLINT_TEST_INIT(state);

flint_printf("bernoulli_number....");
fflush(stdout);

N = 4000;

Expand Down Expand Up @@ -96,7 +93,5 @@ int main(void)
fmpz_clear(num2);
fmpz_clear(den2);

FLINT_TEST_CLEANUP(state);
flint_printf("PASS\n");
return 0;
TEST_FUNCTION_END(state);
}
11 changes: 3 additions & 8 deletions src/arith/test/t-bernoulli_number_denom.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "test_helpers.h"
#include "ulong_extras.h"
#include "fmpz.h"
#include "arith.h"

int main(void)
TEST_FUNCTION_START(arith_bernoulli_number_denom, state)
{
fmpz_t s, t;
slong n;

FLINT_TEST_INIT(state);

flint_printf("bernoulli_number_denom....");
fflush(stdout);

fmpz_init(s);
fmpz_init(t);
Expand All @@ -44,7 +41,5 @@ int main(void)
fmpz_clear(s);
fmpz_clear(t);

FLINT_TEST_CLEANUP(state);
flint_printf("PASS\n");
return 0;
TEST_FUNCTION_END(state);
}
11 changes: 3 additions & 8 deletions src/arith/test/t-bernoulli_number_vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "test_helpers.h"
#include "fmpz.h"
#include "fmpz_vec.h"
#include "arith.h"

int main(void)
TEST_FUNCTION_START(arith_bernoulli_number_vec, state)
{
fmpz * num1;
fmpz * num2;
fmpz * den1;
fmpz * den2;
slong i, n, N;

FLINT_TEST_INIT(state);

flint_printf("bernoulli_number_vec....");
fflush(stdout);

N = 2000;

Expand Down Expand Up @@ -65,7 +62,5 @@ int main(void)
_fmpz_vec_clear(den1, N);
_fmpz_vec_clear(den2, N);

FLINT_TEST_CLEANUP(state);
flint_printf("PASS\n");
return 0;
TEST_FUNCTION_END(state);
}
11 changes: 3 additions & 8 deletions src/arith/test/t-bernoulli_polynomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,18 @@
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "test_helpers.h"
#include "fmpz.h"
#include "fmpq_poly.h"
#include "arith.h"

int main(void)
TEST_FUNCTION_START(arith_bernoulli_polynomial, state)
{
fmpq_poly_t P, Q;
fmpz_t t;

slong k, n;

FLINT_TEST_INIT(state);

flint_printf("bernoulli_polynomial....");
fflush(stdout);

for (n = 0; n <= 100; n++)
{
Expand Down Expand Up @@ -62,7 +59,5 @@ int main(void)
fmpq_poly_clear(Q);
}

FLINT_TEST_CLEANUP(state);
flint_printf("PASS\n");
return 0;
TEST_FUNCTION_END(state);
}
11 changes: 3 additions & 8 deletions src/arith/test/t-chebyshev_t_polynomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "test_helpers.h"
#include "fmpz_poly.h"
#include "arith.h"

int main(void)
TEST_FUNCTION_START(arith_chebyshev_t_polynomial, state)
{
fmpz_poly_t T0, T1, T2, t;
slong n;

FLINT_TEST_INIT(state);

flint_printf("chebyshev_t_polynomial....");
fflush(stdout);

fmpz_poly_init(T0);
fmpz_poly_init(T1);
Expand Down Expand Up @@ -57,7 +54,5 @@ int main(void)
fmpz_poly_clear(T2);
fmpz_poly_clear(t);

FLINT_TEST_CLEANUP(state);
flint_printf("PASS\n");
return 0;
TEST_FUNCTION_END(state);
}
Loading

0 comments on commit 2f13edc

Please sign in to comment.