ALL: Add flint
This commit is contained in:
89
external/flint-2.4.3/fmpz_poly/test/t-2norm_normalised_bits.c
vendored
Normal file
89
external/flint-2.4.3/fmpz_poly/test/t-2norm_normalised_bits.c
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("2norm_normalised_bits....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t a, b, c;
|
||||
fmpz_poly_t f;
|
||||
mp_bitcnt_t b1, b2;
|
||||
|
||||
fmpz_init(a);
|
||||
fmpz_init(b);
|
||||
fmpz_init(c);
|
||||
fmpz_poly_init(f);
|
||||
do {
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100) + 1, 200);
|
||||
} while (f->length == 0);
|
||||
|
||||
fmpz_poly_2norm(a, f);
|
||||
fmpz_abs(b, fmpz_poly_lead(f));
|
||||
fmpz_fdiv_q(c, a, b);
|
||||
b1 = fmpz_bits(c);
|
||||
|
||||
b2 = _fmpz_poly_2norm_normalised_bits(f->coeffs, f->length);
|
||||
|
||||
result = (b1 == b2 || b1 + 1 == b2);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_print(a), flint_printf("\n\n");
|
||||
fmpz_print(b), flint_printf("\n\n");
|
||||
fmpz_print(c), flint_printf("\n\n");
|
||||
flint_printf("b1 = %wd, b2 = %wd\n", b1, b2);
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(a);
|
||||
fmpz_clear(b);
|
||||
fmpz_clear(c);
|
||||
fmpz_poly_clear(f);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
118
external/flint-2.4.3/fmpz_poly/test/t-CRT_ui.c
vendored
Normal file
118
external/flint-2.4.3/fmpz_poly/test/t-CRT_ui.c
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2007 William Hart and David Harvey
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "nmod_poly.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("CRT_ui....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
slong bits, prime_bits, length, num_primes, j;
|
||||
fmpz_t mod;
|
||||
fmpz_poly_t A, B, C;
|
||||
nmod_poly_t Amod;
|
||||
mp_limb_t primes[1000];
|
||||
|
||||
bits = n_randint(state, 500) + 1;
|
||||
length = n_randint(state, 30) + 1;
|
||||
prime_bits = 1 + n_randint(state, FLINT_BITS - 1);
|
||||
|
||||
fmpz_poly_init(A);
|
||||
fmpz_poly_init(B);
|
||||
fmpz_poly_init(C);
|
||||
|
||||
fmpz_poly_randtest(A, state, length, bits);
|
||||
|
||||
fmpz_init(mod);
|
||||
num_primes = 0;
|
||||
primes[0] = n_nextprime(UWORD(1) << prime_bits, 0);
|
||||
fmpz_set_ui(mod, primes[0]);
|
||||
|
||||
/* + 1 for sign */
|
||||
while (fmpz_bits(mod) <= bits + 1)
|
||||
{
|
||||
primes[num_primes + 1] = n_nextprime(primes[num_primes], 0);
|
||||
fmpz_mul_ui(mod, mod, primes[num_primes + 1]);
|
||||
num_primes++;
|
||||
}
|
||||
|
||||
num_primes++;
|
||||
|
||||
nmod_poly_init(Amod, primes[0]);
|
||||
fmpz_poly_get_nmod_poly(Amod, A);
|
||||
fmpz_poly_set_nmod_poly(B, Amod);
|
||||
fmpz_set_ui(mod, primes[0]);
|
||||
|
||||
for (j = 1; j < num_primes; j++)
|
||||
{
|
||||
nmod_poly_clear(Amod);
|
||||
nmod_poly_init(Amod, primes[j]);
|
||||
fmpz_poly_get_nmod_poly(Amod, A);
|
||||
fmpz_poly_CRT_ui(B, B, mod, Amod, 1);
|
||||
fmpz_mul_ui(mod, mod, primes[j]);
|
||||
}
|
||||
|
||||
if (!fmpz_poly_equal(B, A))
|
||||
{
|
||||
flint_printf("FAIL!\n");
|
||||
flint_printf("primes: ");
|
||||
for (j = 0; j < num_primes; j++)
|
||||
flint_printf("%wu ", primes[j]);
|
||||
flint_printf("\nA: \n");
|
||||
fmpz_poly_print(A);
|
||||
flint_printf("\nB: \n");
|
||||
fmpz_poly_print(B);
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
nmod_poly_clear(Amod);
|
||||
fmpz_poly_clear(A);
|
||||
fmpz_poly_clear(B);
|
||||
fmpz_poly_clear(C);
|
||||
fmpz_clear(mod);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
117
external/flint-2.4.3/fmpz_poly/test/t-CRT_ui_unsigned.c
vendored
Normal file
117
external/flint-2.4.3/fmpz_poly/test/t-CRT_ui_unsigned.c
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2007 William Hart and David Harvey
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "nmod_poly.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("CRT_ui_unsigned....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
slong bits, prime_bits, length, num_primes, j;
|
||||
fmpz_t mod;
|
||||
fmpz_poly_t A, B, C;
|
||||
nmod_poly_t Amod;
|
||||
mp_limb_t primes[1000];
|
||||
|
||||
bits = n_randint(state, 500) + 1;
|
||||
length = n_randint(state, 30) + 1;
|
||||
prime_bits = 1 + n_randint(state, FLINT_BITS - 1);
|
||||
|
||||
fmpz_poly_init(A);
|
||||
fmpz_poly_init(B);
|
||||
fmpz_poly_init(C);
|
||||
|
||||
fmpz_poly_randtest_unsigned(A, state, length, bits);
|
||||
|
||||
fmpz_init(mod);
|
||||
num_primes = 0;
|
||||
primes[0] = n_nextprime(UWORD(1) << prime_bits, 0);
|
||||
fmpz_set_ui(mod, primes[0]);
|
||||
|
||||
while (fmpz_bits(mod) <= bits)
|
||||
{
|
||||
primes[num_primes + 1] = n_nextprime(primes[num_primes], 0);
|
||||
fmpz_mul_ui(mod, mod, primes[num_primes + 1]);
|
||||
num_primes++;
|
||||
}
|
||||
|
||||
num_primes++;
|
||||
|
||||
nmod_poly_init(Amod, primes[0]);
|
||||
fmpz_poly_get_nmod_poly(Amod, A);
|
||||
fmpz_poly_set_nmod_poly_unsigned(B, Amod);
|
||||
fmpz_set_ui(mod, primes[0]);
|
||||
|
||||
for (j = 1; j < num_primes; j++)
|
||||
{
|
||||
nmod_poly_clear(Amod);
|
||||
nmod_poly_init(Amod, primes[j]);
|
||||
fmpz_poly_get_nmod_poly(Amod, A);
|
||||
fmpz_poly_CRT_ui(B, B, mod, Amod, 0);
|
||||
fmpz_mul_ui(mod, mod, primes[j]);
|
||||
}
|
||||
|
||||
if (!fmpz_poly_equal(B, A))
|
||||
{
|
||||
flint_printf("FAIL!\n");
|
||||
flint_printf("primes: ");
|
||||
for (j = 0; j < num_primes; j++)
|
||||
flint_printf("%wu ", primes[j]);
|
||||
flint_printf("\nA: \n");
|
||||
fmpz_poly_print(A);
|
||||
flint_printf("\nB: \n");
|
||||
fmpz_poly_print(B);
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
nmod_poly_clear(Amod);
|
||||
fmpz_poly_clear(A);
|
||||
fmpz_poly_clear(B);
|
||||
fmpz_poly_clear(C);
|
||||
fmpz_clear(mod);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
108
external/flint-2.4.3/fmpz_poly/test/t-add.c
vendored
Normal file
108
external/flint-2.4.3/fmpz_poly/test/t-add.c
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("add....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_add(c, a, b);
|
||||
fmpz_poly_add(a, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of b and c */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_add(c, a, b);
|
||||
fmpz_poly_add(b, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
206
external/flint-2.4.3/fmpz_poly/test/t-bit_pack.c
vendored
Normal file
206
external/flint-2.4.3/fmpz_poly/test/t-bit_pack.c
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("bit_pack/bit_unpack....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 2000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
|
||||
slong length = n_randint(state, 100) + 1;
|
||||
mp_bitcnt_t bits = n_randint(state, 300) + 2;
|
||||
mp_ptr arr = (mp_ptr) flint_calloc((length * bits - 1) / FLINT_BITS + 1,
|
||||
sizeof(mp_limb_t));
|
||||
int negate;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
|
||||
/* -1 bit to handle signs */
|
||||
fmpz_poly_randtest_not_zero(a, state, length, bits - 1);
|
||||
|
||||
negate = fmpz_sgn(a->coeffs + a->length - 1);
|
||||
if (negate > 0)
|
||||
negate = 0;
|
||||
|
||||
_fmpz_poly_bit_pack(arr, a->coeffs, a->length, bits, negate);
|
||||
fmpz_poly_fit_length(b, a->length);
|
||||
_fmpz_poly_bit_unpack(b->coeffs, a->length, arr, bits, negate);
|
||||
_fmpz_poly_set_length(b, a->length);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
flint_free(arr);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
for (i = 0; i < 2000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
|
||||
slong length = n_randint(state, 100) + 1;
|
||||
mp_bitcnt_t bits = n_randint(state, 300) + 1;
|
||||
mp_ptr arr = (mp_ptr) flint_calloc((length * bits - 1) / FLINT_BITS + 1,
|
||||
sizeof(mp_limb_t));
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
|
||||
do
|
||||
fmpz_poly_randtest_unsigned(a, state, length, bits);
|
||||
while (a->length == 0);
|
||||
|
||||
_fmpz_poly_bit_pack(arr, a->coeffs, a->length, bits, 0);
|
||||
fmpz_poly_fit_length(b, a->length);
|
||||
_fmpz_poly_bit_unpack_unsigned(b->coeffs, a->length, arr, bits);
|
||||
_fmpz_poly_set_length(b, a->length);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
flint_free(arr);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Test fmpz functions */
|
||||
for (i = 0; i < 2000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t f;
|
||||
fmpz_poly_t A, B;
|
||||
slong b;
|
||||
|
||||
fmpz_init(f);
|
||||
fmpz_poly_init(A);
|
||||
fmpz_poly_init(B);
|
||||
|
||||
fmpz_poly_randtest(A, state, 1+n_randint(state,100),
|
||||
1+n_randint(state,300));
|
||||
|
||||
b = FLINT_ABS(fmpz_poly_max_bits(A)) + 1;
|
||||
|
||||
fmpz_poly_bit_pack(f, A, b);
|
||||
fmpz_poly_bit_unpack(B, f, b);
|
||||
|
||||
if (!fmpz_poly_equal(A, B))
|
||||
{
|
||||
mpz_t zz;
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("BITS: %wd (signed)\n", b);
|
||||
flint_printf("INPUT: ");
|
||||
fmpz_poly_print_pretty(A, "x");
|
||||
flint_printf("\n");
|
||||
mpz_init(zz); fmpz_get_mpz(zz, f);
|
||||
flint_printf("PACKED: ");
|
||||
mpz_out_str(stdout, 2, zz);
|
||||
flint_printf("\n");
|
||||
flint_printf("OUTPUT: ");
|
||||
fmpz_poly_print_pretty(B, "x");
|
||||
flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(f);
|
||||
fmpz_poly_clear(A);
|
||||
fmpz_poly_clear(B);
|
||||
}
|
||||
|
||||
for (i = 0; i < 2000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t f;
|
||||
fmpz_poly_t A, B;
|
||||
slong b;
|
||||
|
||||
fmpz_init(f);
|
||||
fmpz_poly_init(A);
|
||||
fmpz_poly_init(B);
|
||||
|
||||
fmpz_poly_randtest_unsigned(A, state, 1+n_randint(state,100),
|
||||
1+n_randint(state,300));
|
||||
|
||||
b = FLINT_ABS(fmpz_poly_max_bits(A));
|
||||
|
||||
fmpz_poly_bit_pack(f, A, b);
|
||||
fmpz_poly_bit_unpack_unsigned(B, f, b);
|
||||
|
||||
if (!fmpz_poly_equal(A, B))
|
||||
{
|
||||
mpz_t zz;
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("BITS: %wd (unsigned)\n", b);
|
||||
flint_printf("INPUT: ");
|
||||
fmpz_poly_print_pretty(A, "x");
|
||||
flint_printf("\n");
|
||||
mpz_init(zz); fmpz_get_mpz(zz, f);
|
||||
flint_printf("PACKED: ");
|
||||
mpz_out_str(stdout, 2, zz);
|
||||
flint_printf("\n");
|
||||
flint_printf("OUTPUT: ");
|
||||
fmpz_poly_print_pretty(B, "x");
|
||||
flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(f);
|
||||
fmpz_poly_clear(A);
|
||||
fmpz_poly_clear(B);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
112
external/flint-2.4.3/fmpz_poly/test/t-bound_roots.c
vendored
Normal file
112
external/flint-2.4.3/fmpz_poly/test/t-bound_roots.c
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2012 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong iter;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("bound_roots....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (iter = 0; iter < 10000 * flint_test_multiplier(); iter++)
|
||||
{
|
||||
fmpz_poly_t f, g;
|
||||
fmpz_t t, p, q, bound, nbound;
|
||||
slong i, num_roots;
|
||||
|
||||
fmpz_init(t);
|
||||
fmpz_init(p);
|
||||
fmpz_init(q);
|
||||
fmpz_init(bound);
|
||||
fmpz_init(nbound);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
|
||||
/* start with a constant */
|
||||
fmpz_poly_randtest(f, state, 1, 1 + n_randint(state, 200));
|
||||
fmpz_zero(bound);
|
||||
|
||||
num_roots = n_randint(state, 10);
|
||||
if (fmpz_poly_is_zero(f))
|
||||
num_roots = 0;
|
||||
|
||||
for (i = 0; i < num_roots; i++)
|
||||
{
|
||||
fmpz_randtest(p, state, 1 + n_randint(state, 200));
|
||||
fmpz_randtest_not_zero(q, state, 1 + n_randint(state, 200));
|
||||
|
||||
fmpz_abs(p, p);
|
||||
fmpz_abs(q, q);
|
||||
|
||||
fmpz_cdiv_q(t, p, q);
|
||||
if (fmpz_cmp(t, bound) > 0)
|
||||
fmpz_set(bound, t);
|
||||
|
||||
if (n_randint(state, 2))
|
||||
fmpz_neg(p, p);
|
||||
|
||||
fmpz_poly_set_coeff_fmpz(g, 0, p);
|
||||
fmpz_poly_set_coeff_fmpz(g, 1, q);
|
||||
|
||||
fmpz_poly_mul(f, f, g);
|
||||
}
|
||||
|
||||
fmpz_poly_bound_roots(nbound, f);
|
||||
|
||||
if (fmpz_cmp(nbound, bound) < 0)
|
||||
{
|
||||
flint_printf("FAIL\n");
|
||||
flint_printf("f = "); fmpz_poly_print(f); flint_printf("\n\n");
|
||||
flint_printf("bound = "); fmpz_print(bound); flint_printf("\n\n");
|
||||
flint_printf("computed bound = "); fmpz_print(nbound); flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(t);
|
||||
fmpz_clear(p);
|
||||
fmpz_clear(q);
|
||||
fmpz_clear(bound);
|
||||
fmpz_clear(nbound);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
188
external/flint-2.4.3/fmpz_poly/test/t-compose.c
vendored
Normal file
188
external/flint-2.4.3/fmpz_poly/test/t-compose.c
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("compose....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Bill's bug */
|
||||
{
|
||||
fmpz_poly_t f, g, h, s, t;
|
||||
slong k;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_init(s);
|
||||
fmpz_poly_init(t);
|
||||
|
||||
fmpz_poly_set_str(g, "21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6");
|
||||
fmpz_poly_set_str(h, "8 -2411740686 -274861162464 -4294966273 -35167058005888 4261511676 -1 8589869056 -70334401183747");
|
||||
|
||||
fmpz_poly_set_ui(t, 1);
|
||||
for (k = 0; k < g->length; k++)
|
||||
{
|
||||
fmpz_poly_scalar_addmul_fmpz(s, t, g->coeffs + k);
|
||||
fmpz_poly_mul(t, t, h);
|
||||
}
|
||||
|
||||
fmpz_poly_compose(f, g, h);
|
||||
|
||||
result = (fmpz_poly_equal(f, s));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (Bill's bug):\n");
|
||||
flint_printf("g = "), fmpz_poly_print(g), flint_printf("\n\n");
|
||||
flint_printf("h = "), fmpz_poly_print(h), flint_printf("\n\n");
|
||||
flint_printf("f = "), fmpz_poly_print(f), flint_printf("\n\n");
|
||||
flint_printf("s = "), fmpz_poly_print(s), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
fmpz_poly_clear(s);
|
||||
fmpz_poly_clear(t);
|
||||
}
|
||||
|
||||
/* Check aliasing of the first argument */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
|
||||
fmpz_poly_compose(f, g, h);
|
||||
fmpz_poly_compose(g, g, h);
|
||||
|
||||
result = (fmpz_poly_equal(f, g));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing 1):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
/* Check aliasing of the second argument */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
|
||||
fmpz_poly_compose(f, g, h);
|
||||
fmpz_poly_compose(h, g, h);
|
||||
|
||||
result = (fmpz_poly_equal(f, h));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing 2):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(h), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
/* Compare with the naive method for g(h(t)) */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h, s, t;
|
||||
slong k;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_init(s);
|
||||
fmpz_poly_init(t);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
|
||||
fmpz_poly_set_ui(t, 1);
|
||||
for (k = 0; k < g->length; k++)
|
||||
{
|
||||
fmpz_poly_scalar_addmul_fmpz(s, t, g->coeffs + k);
|
||||
fmpz_poly_mul(t, t, h);
|
||||
}
|
||||
|
||||
fmpz_poly_compose(f, g, h);
|
||||
|
||||
result = (fmpz_poly_equal(f, s));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (comparison):\n");
|
||||
flint_printf("g = "), fmpz_poly_print(g), flint_printf("\n\n");
|
||||
flint_printf("h = "), fmpz_poly_print(h), flint_printf("\n\n");
|
||||
flint_printf("f = "), fmpz_poly_print(f), flint_printf("\n\n");
|
||||
flint_printf("s = "), fmpz_poly_print(s), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
fmpz_poly_clear(s);
|
||||
fmpz_poly_clear(t);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
136
external/flint-2.4.3/fmpz_poly/test/t-compose_divconquer.c
vendored
Normal file
136
external/flint-2.4.3/fmpz_poly/test/t-compose_divconquer.c
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("compose_divconquer....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of the first argument */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
|
||||
fmpz_poly_compose_divconquer(f, g, h);
|
||||
fmpz_poly_compose_divconquer(g, g, h);
|
||||
|
||||
result = (fmpz_poly_equal(f, g));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
/* Check aliasing of the second argument */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
|
||||
fmpz_poly_compose_divconquer(f, g, h);
|
||||
fmpz_poly_compose_divconquer(h, g, h);
|
||||
|
||||
result = (fmpz_poly_equal(f, h));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(h), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
/* Compare with the default method */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f1, f2, g, h;
|
||||
|
||||
fmpz_poly_init(f1);
|
||||
fmpz_poly_init(f2);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
|
||||
fmpz_poly_compose_divconquer(f1, g, h);
|
||||
fmpz_poly_compose(f2, g, h);
|
||||
|
||||
result = (fmpz_poly_equal(f1, f2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(f1), flint_printf("\n\n");
|
||||
fmpz_poly_print(f2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f1);
|
||||
fmpz_poly_clear(f2);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
136
external/flint-2.4.3/fmpz_poly/test/t-compose_horner.c
vendored
Normal file
136
external/flint-2.4.3/fmpz_poly/test/t-compose_horner.c
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("compose_horner....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of the first argument */
|
||||
for (i = 0; i < 8 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
|
||||
fmpz_poly_compose_horner(f, g, h);
|
||||
fmpz_poly_compose_horner(g, g, h);
|
||||
|
||||
result = (fmpz_poly_equal(f, g));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
/* Check aliasing of the second argument */
|
||||
for (i = 0; i < 8 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
|
||||
fmpz_poly_compose_horner(f, g, h);
|
||||
fmpz_poly_compose_horner(h, g, h);
|
||||
|
||||
result = (fmpz_poly_equal(f, h));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(h), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
/* Compare with the default method */
|
||||
for (i = 0; i < 8 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f1, f2, g, h;
|
||||
|
||||
fmpz_poly_init(f1);
|
||||
fmpz_poly_init(f2);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
|
||||
fmpz_poly_compose_horner(f1, g, h);
|
||||
fmpz_poly_compose(f2, g, h);
|
||||
|
||||
result = (fmpz_poly_equal(f1, f2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(f1), flint_printf("\n\n");
|
||||
fmpz_poly_print(f2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f1);
|
||||
fmpz_poly_clear(f2);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
152
external/flint-2.4.3/fmpz_poly/test/t-compose_series.c
vendored
Normal file
152
external/flint-2.4.3/fmpz_poly/test/t-compose_series.c
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("compose_series....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of the first argument */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
fmpz_poly_set_coeff_ui(h, 0, 0);
|
||||
n = n_randint(state, 20);
|
||||
|
||||
fmpz_poly_compose_series(f, g, h, n);
|
||||
fmpz_poly_compose_series(g, g, h, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, g));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing 1):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
/* Check aliasing of the second argument */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
fmpz_poly_set_coeff_ui(h, 0, 0);
|
||||
n = n_randint(state, 20);
|
||||
|
||||
fmpz_poly_compose_series(f, g, h, n);
|
||||
fmpz_poly_compose_series(h, g, h, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, h));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing 2):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(h), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
/* Compare with compose */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h, s, t;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_init(s);
|
||||
fmpz_poly_init(t);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
fmpz_poly_set_coeff_ui(h, 0, 0);
|
||||
n = n_randint(state, 10);
|
||||
|
||||
fmpz_poly_compose(s, g, h);
|
||||
fmpz_poly_truncate(s, n);
|
||||
fmpz_poly_compose_series(f, g, h, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, s));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (comparison):\n");
|
||||
flint_printf("n = %wd\n", n);
|
||||
flint_printf("g = "), fmpz_poly_print(g), flint_printf("\n\n");
|
||||
flint_printf("h = "), fmpz_poly_print(h), flint_printf("\n\n");
|
||||
flint_printf("f = "), fmpz_poly_print(f), flint_printf("\n\n");
|
||||
flint_printf("s = "), fmpz_poly_print(s), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
fmpz_poly_clear(s);
|
||||
fmpz_poly_clear(t);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
151
external/flint-2.4.3/fmpz_poly/test/t-compose_series_brent_kung.c
vendored
Normal file
151
external/flint-2.4.3/fmpz_poly/test/t-compose_series_brent_kung.c
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("compose_series_brent_kung....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of the first argument */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
fmpz_poly_set_coeff_ui(h, 0, 0);
|
||||
n = n_randint(state, 20);
|
||||
|
||||
fmpz_poly_compose_series_brent_kung(f, g, h, n);
|
||||
fmpz_poly_compose_series_brent_kung(g, g, h, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, g));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing 1):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
/* Check aliasing of the second argument */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
fmpz_poly_set_coeff_ui(h, 0, 0);
|
||||
n = n_randint(state, 20);
|
||||
|
||||
fmpz_poly_compose_series_brent_kung(f, g, h, n);
|
||||
fmpz_poly_compose_series_brent_kung(h, g, h, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, h));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing 2):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(h), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
/* Compare with Horner */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h, s, t;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_init(s);
|
||||
fmpz_poly_init(t);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50), n_randint(state, 100));
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 50), n_randint(state, 100));
|
||||
fmpz_poly_set_coeff_ui(h, 0, 0);
|
||||
n = n_randint(state, 50);
|
||||
|
||||
fmpz_poly_compose_series_brent_kung(s, g, h, n);
|
||||
fmpz_poly_compose_series_horner(f, g, h, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, s));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (comparison):\n");
|
||||
flint_printf("n = %wd\n", n);
|
||||
flint_printf("g = "), fmpz_poly_print(g), flint_printf("\n\n");
|
||||
flint_printf("h = "), fmpz_poly_print(h), flint_printf("\n\n");
|
||||
flint_printf("f = "), fmpz_poly_print(f), flint_printf("\n\n");
|
||||
flint_printf("s = "), fmpz_poly_print(s), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
fmpz_poly_clear(s);
|
||||
fmpz_poly_clear(t);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
152
external/flint-2.4.3/fmpz_poly/test/t-compose_series_horner.c
vendored
Normal file
152
external/flint-2.4.3/fmpz_poly/test/t-compose_series_horner.c
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("compose_series_horner....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of the first argument */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
fmpz_poly_set_coeff_ui(h, 0, 0);
|
||||
n = n_randint(state, 20);
|
||||
|
||||
fmpz_poly_compose_series_horner(f, g, h, n);
|
||||
fmpz_poly_compose_series_horner(g, g, h, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, g));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing 1):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
/* Check aliasing of the second argument */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
fmpz_poly_set_coeff_ui(h, 0, 0);
|
||||
n = n_randint(state, 20);
|
||||
|
||||
fmpz_poly_compose_series_horner(f, g, h, n);
|
||||
fmpz_poly_compose_series_horner(h, g, h, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, h));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing 2):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(h), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
/* Compare with compose */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h, s, t;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_init(s);
|
||||
fmpz_poly_init(t);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 20), 50);
|
||||
fmpz_poly_set_coeff_ui(h, 0, 0);
|
||||
n = n_randint(state, 20);
|
||||
|
||||
fmpz_poly_compose(s, g, h);
|
||||
fmpz_poly_truncate(s, n);
|
||||
fmpz_poly_compose_series_horner(f, g, h, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, s));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (comparison):\n");
|
||||
flint_printf("n = %wd\n", n);
|
||||
flint_printf("g = "), fmpz_poly_print(g), flint_printf("\n\n");
|
||||
flint_printf("h = "), fmpz_poly_print(h), flint_printf("\n\n");
|
||||
flint_printf("f = "), fmpz_poly_print(f), flint_printf("\n\n");
|
||||
flint_printf("s = "), fmpz_poly_print(s), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
fmpz_poly_clear(s);
|
||||
fmpz_poly_clear(t);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
84
external/flint-2.4.3/fmpz_poly/test/t-content.c
vendored
Normal file
84
external/flint-2.4.3/fmpz_poly/test/t-content.c
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("content....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check that content(a f) = abs(a) content(f) */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t a, c, d;
|
||||
fmpz_poly_t f;
|
||||
|
||||
fmpz_init(a);
|
||||
fmpz_init(c);
|
||||
fmpz_init(d);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100), 200);
|
||||
fmpz_randtest(a, state, 100);
|
||||
|
||||
fmpz_poly_content(c, f);
|
||||
fmpz_poly_scalar_mul_fmpz(f, f, a);
|
||||
fmpz_abs(a, a);
|
||||
fmpz_mul(c, a, c);
|
||||
fmpz_poly_content(d, f);
|
||||
|
||||
result = (fmpz_equal(c, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_print(c), flint_printf("\n\n");
|
||||
fmpz_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(a);
|
||||
fmpz_clear(c);
|
||||
fmpz_clear(d);
|
||||
fmpz_poly_clear(f);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
138
external/flint-2.4.3/fmpz_poly/test/t-derivative.c
vendored
Normal file
138
external/flint-2.4.3/fmpz_poly/test/t-derivative.c
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("derivative....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_derivative(b, a);
|
||||
fmpz_poly_derivative(a, a);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Check constants have derivative zero */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 2), 200);
|
||||
|
||||
fmpz_poly_derivative(b, a);
|
||||
|
||||
result = (b->length == UWORD(0));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Check (f g)' = f' g + f g' */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d, lhs, rhs;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_init(lhs);
|
||||
fmpz_poly_init(rhs);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_mul(lhs, a, b);
|
||||
fmpz_poly_derivative(lhs, lhs);
|
||||
fmpz_poly_derivative(c, a);
|
||||
fmpz_poly_derivative(d, b);
|
||||
fmpz_poly_mul(c, c, b);
|
||||
fmpz_poly_mul(d, a, d);
|
||||
fmpz_poly_add(rhs, c, d);
|
||||
|
||||
result = fmpz_poly_equal(lhs, rhs);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
fmpz_poly_clear(lhs);
|
||||
fmpz_poly_clear(rhs);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
143
external/flint-2.4.3/fmpz_poly/test/t-div_basecase.c
vendored
Normal file
143
external/flint-2.4.3/fmpz_poly/test/t-div_basecase.c
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("div_basecase....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with full division, no aliasing */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r, q2;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(q2);
|
||||
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, a->length + 1) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_div_basecase(q2, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(q, q2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
fmpz_poly_print(q2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(q2);
|
||||
}
|
||||
|
||||
/* Check q and a alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 50) + 1, 100);
|
||||
|
||||
fmpz_poly_div_basecase(q, a, b);
|
||||
fmpz_poly_div_basecase(a, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
/* Check q and b alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 50) + 1, 100);
|
||||
|
||||
fmpz_poly_div_basecase(q, a, b);
|
||||
fmpz_poly_div_basecase(b, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
143
external/flint-2.4.3/fmpz_poly/test/t-div_divconquer.c
vendored
Normal file
143
external/flint-2.4.3/fmpz_poly/test/t-div_divconquer.c
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("div_divconquer....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with full division, no aliasing */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r, q2;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(q2);
|
||||
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 200), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, a->length + 1) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_divconquer(q, r, a, b);
|
||||
fmpz_poly_div_divconquer(q2, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(q, q2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
fmpz_poly_print(q2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(q2);
|
||||
}
|
||||
|
||||
/* Check q and a alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 200);
|
||||
|
||||
fmpz_poly_div_divconquer(q, a, b);
|
||||
fmpz_poly_div_divconquer(a, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
/* Check q and b alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 200);
|
||||
|
||||
fmpz_poly_div_divconquer(q, a, b);
|
||||
fmpz_poly_div_divconquer(b, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
155
external/flint-2.4.3/fmpz_poly/test/t-div_preinv.c
vendored
Normal file
155
external/flint-2.4.3/fmpz_poly/test/t-div_preinv.c
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009, 2013 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("div_preinv....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with full division, no aliasing */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, b_inv, q, r, q2;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(b_inv);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(q2);
|
||||
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, a->length + 1) + 1, 100);
|
||||
fmpz_set_ui(b->coeffs + b->length - 1, 1); /* b must be monic */
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_preinvert(b_inv, b);
|
||||
fmpz_poly_div_preinv(q2, a, b, b_inv);
|
||||
|
||||
result = (fmpz_poly_equal(q, q2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
fmpz_poly_print(q2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(b_inv);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(q2);
|
||||
}
|
||||
|
||||
/* Check q and a alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, b_inv, q;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(b_inv);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 50) + 1, 100);
|
||||
fmpz_set_ui(b->coeffs + b->length - 1, 1); /* b must be monic */
|
||||
|
||||
fmpz_poly_div_basecase(q, a, b);
|
||||
fmpz_poly_preinvert(b_inv, b);
|
||||
fmpz_poly_div_preinv(a, a, b, b_inv);
|
||||
|
||||
result = (fmpz_poly_equal(a, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(b_inv);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
/* Check q and b alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, b_inv, q;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(b_inv);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 50) + 1, 100);
|
||||
fmpz_set_ui(b->coeffs + b->length - 1, 1); /* b must be monic */
|
||||
|
||||
fmpz_poly_div_basecase(q, a, b);
|
||||
fmpz_poly_preinvert(b_inv, b);
|
||||
fmpz_poly_div_preinv(b, a, b, b_inv);
|
||||
|
||||
result = (fmpz_poly_equal(b, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(b_inv);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
133
external/flint-2.4.3/fmpz_poly/test/t-div_root.c
vendored
Normal file
133
external/flint-2.4.3/fmpz_poly/test/t-div_root.c
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("div_root....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with standard divrem */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t P, Q, D, DQ;
|
||||
fmpz_t c;
|
||||
slong n, b;
|
||||
|
||||
n = n_randint(state, 100);
|
||||
b = n_randint(state, 200);
|
||||
|
||||
fmpz_init(c);
|
||||
fmpz_poly_init(P);
|
||||
fmpz_poly_init(Q);
|
||||
fmpz_poly_init(D);
|
||||
fmpz_poly_init(DQ);
|
||||
|
||||
fmpz_poly_randtest(P, state, n, b);
|
||||
fmpz_randtest(c, state, b);
|
||||
|
||||
fmpz_poly_div_root(Q, P, c);
|
||||
|
||||
fmpz_poly_set_coeff_fmpz(D, 0, c);
|
||||
fmpz_poly_neg(D, D);
|
||||
fmpz_poly_set_coeff_ui(D, 1, UWORD(1));
|
||||
|
||||
fmpz_poly_div_basecase(DQ, P, D);
|
||||
|
||||
result = fmpz_poly_equal(Q, DQ);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL!\n");
|
||||
flint_printf("P:\n"); fmpz_poly_print(P); flint_printf("\n\n");
|
||||
flint_printf("Q:\n"); fmpz_poly_print(Q); flint_printf("\n\n");
|
||||
flint_printf("D:\n"); fmpz_poly_print(D); flint_printf("\n\n");
|
||||
flint_printf("DQ:\n"); fmpz_poly_print(DQ); flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(c);
|
||||
fmpz_poly_clear(P);
|
||||
fmpz_poly_clear(Q);
|
||||
fmpz_poly_clear(D);
|
||||
fmpz_poly_clear(DQ);
|
||||
}
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t P, Q1, Q2;
|
||||
fmpz_t c;
|
||||
slong n, b;
|
||||
|
||||
n = n_randint(state, 100);
|
||||
b = n_randint(state, 200);
|
||||
|
||||
fmpz_init(c);
|
||||
fmpz_poly_init(P);
|
||||
fmpz_poly_init(Q1);
|
||||
fmpz_poly_init(Q2);
|
||||
|
||||
fmpz_randtest(c, state, b);
|
||||
fmpz_poly_randtest(P, state, n, b);
|
||||
fmpz_poly_set(Q2, P);
|
||||
|
||||
fmpz_poly_div_root(Q1, P, c);
|
||||
fmpz_poly_div_root(Q2, Q2, c);
|
||||
|
||||
result = fmpz_poly_equal(Q1, Q2);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing)!\n");
|
||||
flint_printf("P:\n"); fmpz_poly_print(P); flint_printf("\n\n");
|
||||
flint_printf("Q1:\n"); fmpz_poly_print(Q1); flint_printf("\n\n");
|
||||
flint_printf("Q2:\n"); fmpz_poly_print(Q2); flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(c);
|
||||
fmpz_poly_clear(P);
|
||||
fmpz_poly_clear(Q1);
|
||||
fmpz_poly_clear(Q2);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
150
external/flint-2.4.3/fmpz_poly/test/t-div_series.c
vendored
Normal file
150
external/flint-2.4.3/fmpz_poly/test/t-div_series.c
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("div_series....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing q and a */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q;
|
||||
slong n = n_randint(state, 50) + 1;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50) + 1, 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 50) + 1, 100);
|
||||
fmpz_poly_set_coeff_ui(b, 0, 1);
|
||||
|
||||
fmpz_poly_div_series(q, a, b, n);
|
||||
fmpz_poly_div_series(a, a, b, n);
|
||||
|
||||
result = (fmpz_poly_equal(q, a));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (alias q and a):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("q = "), fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
/* Check aliasing q and b */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q;
|
||||
slong n = n_randint(state, 50) + 1;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50) + 1, 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 50) + 1, 100);
|
||||
fmpz_poly_set_coeff_ui(b, 0, 1);
|
||||
|
||||
fmpz_poly_div_series(q, a, b, n);
|
||||
fmpz_poly_div_series(b, a, b, n);
|
||||
|
||||
result = (fmpz_poly_equal(q, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (alias q and b):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("q = "), fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
/* Check that Q * B == A */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, p, q;
|
||||
slong n = n_randint(state, 50) + 1;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(p);
|
||||
fmpz_poly_init(q);
|
||||
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50) + 1, 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 50) + 1, 100);
|
||||
fmpz_poly_set_coeff_ui(b, 0, 1);
|
||||
|
||||
fmpz_poly_div_series(q, a, b, n);
|
||||
fmpz_poly_mullow(p, q, b, n);
|
||||
|
||||
fmpz_poly_truncate(a, n);
|
||||
|
||||
result = (fmpz_poly_equal(p, a));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (check Q * B = A):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("p = "), fmpz_poly_print(p), flint_printf("\n\n");
|
||||
flint_printf("q = "), fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(p);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
173
external/flint-2.4.3/fmpz_poly/test/t-divides.c
vendored
Normal file
173
external/flint-2.4.3/fmpz_poly/test/t-divides.c
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("divides....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check that b divides a*b and that the quotient is a */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, p, q;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(p);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 200);
|
||||
fmpz_poly_mul(p, a, b);
|
||||
|
||||
result = (fmpz_poly_divides(q, p, b) && fmpz_poly_equal(q, a));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(p), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(p);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
/* Check aliasing of q with a */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, p;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(p);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 200);
|
||||
fmpz_poly_mul(p, a, b);
|
||||
|
||||
result = (fmpz_poly_divides(p, p, b) && fmpz_poly_equal(p, a));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(p), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(p);
|
||||
}
|
||||
|
||||
/* Check aliasing of q with b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, p;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(p);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 200);
|
||||
fmpz_poly_mul(p, a, b);
|
||||
|
||||
result = (fmpz_poly_divides(b, p, b) && fmpz_poly_equal(b, a));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(p), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(p);
|
||||
}
|
||||
|
||||
/* Check when not divisible */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, p, q, g, s;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(p);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(s);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
do {
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 200);
|
||||
} while (b->length < 2);
|
||||
fmpz_poly_mul(p, a, b);
|
||||
do {
|
||||
fmpz_poly_randtest_not_zero(s, state, b->length, 200);
|
||||
fmpz_poly_gcd(g, s, b);
|
||||
} while (g->length == b->length);
|
||||
fmpz_poly_add(p, p, s);
|
||||
|
||||
result = (!fmpz_poly_divides(q, p, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(p), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(p);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(s);
|
||||
fmpz_poly_clear(g);
|
||||
}
|
||||
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
208
external/flint-2.4.3/fmpz_poly/test/t-divrem_basecase.c
vendored
Normal file
208
external/flint-2.4.3/fmpz_poly/test/t-divrem_basecase.c
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("divrem_basecase....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check q*b + r = a, no aliasing */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r, prod;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(prod);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_mul(prod, q, b);
|
||||
fmpz_poly_add(prod, prod, r);
|
||||
|
||||
result = (fmpz_poly_equal(a, prod));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(prod), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(prod);
|
||||
}
|
||||
|
||||
/* Check r and a alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_divrem_basecase(q, a, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check r and b alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_divrem_basecase(q, b, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check q and a alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_divrem_basecase(a, r, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check q and b alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_divrem_basecase(b, r, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
208
external/flint-2.4.3/fmpz_poly/test/t-divrem_divconquer.c
vendored
Normal file
208
external/flint-2.4.3/fmpz_poly/test/t-divrem_divconquer.c
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("divrem_divconquer....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check q*b + r = a, no aliasing */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r, prod;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(prod);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_divconquer(q, r, a, b);
|
||||
fmpz_poly_mul(prod, q, b);
|
||||
fmpz_poly_add(prod, prod, r);
|
||||
|
||||
result = (fmpz_poly_equal(a, prod));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(prod), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(prod);
|
||||
}
|
||||
|
||||
/* Check r and a alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_divconquer(q, r, a, b);
|
||||
fmpz_poly_divrem_divconquer(q, a, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check r and b alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_divconquer(q, r, a, b);
|
||||
fmpz_poly_divrem_divconquer(q, b, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check q and a alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_divconquer(q, r, a, b);
|
||||
fmpz_poly_divrem_divconquer(a, r, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check q and b alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_divconquer(q, r, a, b);
|
||||
fmpz_poly_divrem_divconquer(b, r, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
228
external/flint-2.4.3/fmpz_poly/test/t-divrem_preinv.c
vendored
Normal file
228
external/flint-2.4.3/fmpz_poly/test/t-divrem_preinv.c
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009, 2013 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("divrem_preinv....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check q*b + r = a, no aliasing */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, b_inv, q, r, prod;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(b_inv);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(prod);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
fmpz_set_ui(b->coeffs + b->length - 1, 1); /* b must be monic */
|
||||
|
||||
fmpz_poly_preinvert(b_inv, b);
|
||||
fmpz_poly_divrem_preinv(q, r, a, b, b_inv);
|
||||
fmpz_poly_mul(prod, q, b);
|
||||
fmpz_poly_add(prod, prod, r);
|
||||
|
||||
result = (fmpz_poly_equal(a, prod));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(prod), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(b_inv);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(prod);
|
||||
}
|
||||
|
||||
/* Check r and a alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, b_inv, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(b_inv);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
fmpz_set_ui(b->coeffs + b->length - 1, 1); /* b must be monic */
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_preinvert(b_inv, b);
|
||||
fmpz_poly_divrem_preinv(q, a, a, b, b_inv);
|
||||
|
||||
result = (fmpz_poly_equal(a, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(b_inv);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check r and b alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, b_inv, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(b_inv);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
fmpz_set_ui(b->coeffs + b->length - 1, 1); /* b must be monic */
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_preinvert(b_inv, b);
|
||||
fmpz_poly_divrem_preinv(q, b, a, b, b_inv);
|
||||
|
||||
result = (fmpz_poly_equal(b, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(b_inv);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check q and a alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, b_inv, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(b_inv);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
fmpz_set_ui(b->coeffs + b->length - 1, 1); /* b must be monic */
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_preinvert(b_inv, b);
|
||||
fmpz_poly_divrem_preinv(a, r, a, b, b_inv);
|
||||
|
||||
result = (fmpz_poly_equal(a, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(b_inv);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check q and b alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, b_inv, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(b_inv);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 100);
|
||||
fmpz_set_ui(b->coeffs + b->length - 1, 1); /* b must be monic */
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_preinvert(b_inv, b);
|
||||
fmpz_poly_divrem_preinv(b, r, a, b, b_inv);
|
||||
|
||||
result = (fmpz_poly_equal(b, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(b_inv);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
82
external/flint-2.4.3/fmpz_poly/test/t-equal_fmpz.c
vendored
Normal file
82
external/flint-2.4.3/fmpz_poly/test/t-equal_fmpz.c
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("equal_fmpz....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
fmpz_t c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_init(c);
|
||||
|
||||
fmpz_randtest(c, state, 1 + n_randint(state, 200));
|
||||
fmpz_poly_set_fmpz(b, c);
|
||||
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 6),
|
||||
1 + n_randint(state, 200));
|
||||
if (n_randint(state, 2))
|
||||
fmpz_poly_set_coeff_fmpz(a, 0, c);
|
||||
|
||||
result = fmpz_poly_equal(a, b) == fmpz_poly_equal_fmpz(a, c);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
110
external/flint-2.4.3/fmpz_poly/test/t-evaluate_divconquer_fmpz.c
vendored
Normal file
110
external/flint-2.4.3/fmpz_poly/test/t-evaluate_divconquer_fmpz.c
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("evaluate_divconquer_fmpz....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t a, b;
|
||||
fmpz_poly_t f;
|
||||
|
||||
fmpz_init(a);
|
||||
fmpz_init(b);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100), 200);
|
||||
fmpz_randtest(a, state, 100);
|
||||
|
||||
fmpz_poly_evaluate_divconquer_fmpz(b, f, a);
|
||||
fmpz_poly_evaluate_divconquer_fmpz(a, f, a);
|
||||
|
||||
result = (fmpz_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (alias):\n");
|
||||
fmpz_print(a), flint_printf("\n\n");
|
||||
fmpz_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(a);
|
||||
fmpz_clear(b);
|
||||
fmpz_poly_clear(f);
|
||||
}
|
||||
|
||||
/* Check that the result agrees with Horner's method */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t a, b, c;
|
||||
fmpz_poly_t f;
|
||||
|
||||
fmpz_init(a);
|
||||
fmpz_init(b);
|
||||
fmpz_init(c);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100), 200);
|
||||
fmpz_randtest(a, state, 100);
|
||||
|
||||
fmpz_poly_evaluate_divconquer_fmpz(b, f, a);
|
||||
fmpz_poly_evaluate_horner_fmpz(c, f, a);
|
||||
|
||||
result = (fmpz_equal(b, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (cmp with Horner):\n");
|
||||
fmpz_print(a), flint_printf("\n\n");
|
||||
fmpz_print(b), flint_printf("\n\n");
|
||||
fmpz_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(a);
|
||||
fmpz_clear(b);
|
||||
fmpz_clear(c);
|
||||
fmpz_poly_clear(f);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
79
external/flint-2.4.3/fmpz_poly/test/t-evaluate_fmpz.c
vendored
Normal file
79
external/flint-2.4.3/fmpz_poly/test/t-evaluate_fmpz.c
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("evaluate_fmpz....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t a, b;
|
||||
fmpz_poly_t f;
|
||||
|
||||
fmpz_init(a);
|
||||
fmpz_init(b);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100), 200);
|
||||
fmpz_randtest(a, state, 100);
|
||||
|
||||
fmpz_poly_evaluate_fmpz(b, f, a);
|
||||
fmpz_poly_evaluate_fmpz(a, f, a);
|
||||
|
||||
result = (fmpz_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_print(a), flint_printf("\n\n");
|
||||
fmpz_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(a);
|
||||
fmpz_clear(b);
|
||||
fmpz_poly_clear(f);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
116
external/flint-2.4.3/fmpz_poly/test/t-evaluate_horner_fmpz.c
vendored
Normal file
116
external/flint-2.4.3/fmpz_poly/test/t-evaluate_horner_fmpz.c
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("evaluate_horner....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t a, b;
|
||||
fmpz_poly_t f;
|
||||
|
||||
fmpz_init(a);
|
||||
fmpz_init(b);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100), 200);
|
||||
fmpz_randtest(a, state, 100);
|
||||
|
||||
fmpz_poly_evaluate_horner_fmpz(b, f, a);
|
||||
fmpz_poly_evaluate_horner_fmpz(a, f, a);
|
||||
|
||||
result = (fmpz_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_print(a), flint_printf("\n\n");
|
||||
fmpz_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(a);
|
||||
fmpz_clear(b);
|
||||
fmpz_poly_clear(f);
|
||||
}
|
||||
|
||||
/* Check that (f+g)(a) = f(a) + g(a) */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t a, b, c;
|
||||
fmpz_poly_t f, g;
|
||||
|
||||
fmpz_init(a);
|
||||
fmpz_init(b);
|
||||
fmpz_init(c);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 100), 200);
|
||||
fmpz_randtest(a, state, 100);
|
||||
|
||||
fmpz_poly_evaluate_horner_fmpz(b, f, a);
|
||||
fmpz_poly_evaluate_horner_fmpz(c, g, a);
|
||||
fmpz_add(b, b, c);
|
||||
fmpz_poly_add(f, f, g);
|
||||
fmpz_poly_evaluate_horner_fmpz(c, f, a);
|
||||
|
||||
result = (fmpz_equal(b, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_print(b), flint_printf("\n\n");
|
||||
fmpz_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(a);
|
||||
fmpz_clear(b);
|
||||
fmpz_clear(c);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
181
external/flint-2.4.3/fmpz_poly/test/t-evaluate_horner_mpq.c
vendored
Normal file
181
external/flint-2.4.3/fmpz_poly/test/t-evaluate_horner_mpq.c
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 1509 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("evaluate_horner_mpq....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 75 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t a, b;
|
||||
mpq_t x, y;
|
||||
fmpz_poly_t f;
|
||||
|
||||
fmpz_init(a);
|
||||
fmpz_init(b);
|
||||
mpq_init(x);
|
||||
mpq_init(y);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100), 150);
|
||||
fmpz_randtest(a, state, 100);
|
||||
fmpz_randtest_not_zero(b, state, 100);
|
||||
fmpz_get_mpz(mpq_numref(x), a);
|
||||
fmpz_get_mpz(mpq_denref(x), b);
|
||||
mpq_canonicalize(x);
|
||||
|
||||
fmpz_poly_evaluate_horner_mpq(y, f, x);
|
||||
fmpz_poly_evaluate_horner_mpq(x, f, x);
|
||||
|
||||
result = (mpq_equal(x, y));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_print(a), flint_printf("\n\n");
|
||||
fmpz_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(a);
|
||||
fmpz_clear(b);
|
||||
mpq_clear(x);
|
||||
mpq_clear(y);
|
||||
fmpz_poly_clear(f);
|
||||
}
|
||||
|
||||
/* Check that (f+g)(a) = f(a) + g(a) */
|
||||
for (i = 0; i < 75 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t a, b;
|
||||
mpq_t x, y, z;
|
||||
fmpz_poly_t f, g;
|
||||
|
||||
fmpz_init(a);
|
||||
fmpz_init(b);
|
||||
mpq_init(x);
|
||||
mpq_init(y);
|
||||
mpq_init(z);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100), 150);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 100), 150);
|
||||
fmpz_randtest(a, state, 100);
|
||||
fmpz_randtest_not_zero(b, state, 100);
|
||||
fmpz_get_mpz(mpq_numref(x), a);
|
||||
fmpz_get_mpz(mpq_denref(x), b);
|
||||
mpq_canonicalize(x);
|
||||
|
||||
fmpz_poly_evaluate_horner_mpq(y, f, x);
|
||||
fmpz_poly_evaluate_horner_mpq(z, g, x);
|
||||
mpq_add(y, y, z);
|
||||
fmpz_poly_add(f, f, g);
|
||||
fmpz_poly_evaluate_horner_mpq(z, f, x);
|
||||
|
||||
result = (mpq_equal(y, z));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_print(a), flint_printf("\n\n");
|
||||
fmpz_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(a);
|
||||
fmpz_clear(b);
|
||||
mpq_clear(x);
|
||||
mpq_clear(y);
|
||||
mpq_clear(z);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
}
|
||||
|
||||
/* Check that (f*g)(a) = f(a) * g(a) */
|
||||
for (i = 0; i < 75 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t a, b;
|
||||
mpq_t x, y, z;
|
||||
fmpz_poly_t f, g;
|
||||
|
||||
fmpz_init(a);
|
||||
fmpz_init(b);
|
||||
mpq_init(x);
|
||||
mpq_init(y);
|
||||
mpq_init(z);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50), 100);
|
||||
fmpz_randtest(a, state, 100);
|
||||
fmpz_randtest_not_zero(b, state, 100);
|
||||
fmpz_get_mpz(mpq_numref(x), a);
|
||||
fmpz_get_mpz(mpq_denref(x), b);
|
||||
mpq_canonicalize(x);
|
||||
|
||||
fmpz_poly_evaluate_horner_mpq(y, f, x);
|
||||
fmpz_poly_evaluate_horner_mpq(z, g, x);
|
||||
mpq_mul(y, y, z);
|
||||
fmpz_poly_mul(f, f, g);
|
||||
fmpz_poly_evaluate_horner_mpq(z, f, x);
|
||||
|
||||
result = (mpq_equal(y, z));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_print(a), flint_printf("\n\n");
|
||||
fmpz_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(a);
|
||||
fmpz_clear(b);
|
||||
mpq_clear(x);
|
||||
mpq_clear(y);
|
||||
mpq_clear(z);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
87
external/flint-2.4.3/fmpz_poly/test/t-evaluate_mod.c
vendored
Normal file
87
external/flint-2.4.3/fmpz_poly/test/t-evaluate_mod.c
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("evaluate_mod....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with evaluation over the integers */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t b, s;
|
||||
fmpz_poly_t f;
|
||||
mp_limb_t a, n, r;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 10), 20);
|
||||
|
||||
n = n_randtest_not_zero(state);
|
||||
a = n_randint(state, n);
|
||||
|
||||
fmpz_init(b);
|
||||
fmpz_init(s);
|
||||
fmpz_set_ui(b, a);
|
||||
|
||||
r = fmpz_poly_evaluate_mod(f, a, n);
|
||||
fmpz_poly_evaluate_fmpz(s, f, b);
|
||||
|
||||
result = (r == fmpz_mod_ui(s, s, n));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
gmp_printf("a = %Mu\n\n", a);
|
||||
gmp_printf("n = %Mu\n\n", n);
|
||||
gmp_printf("r = %Mu\n\n", r);
|
||||
flint_printf("s = "), fmpz_print(s), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_clear(b);
|
||||
fmpz_clear(s);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
146
external/flint-2.4.3/fmpz_poly/test/t-gcd.c
vendored
Normal file
146
external/flint-2.4.3/fmpz_poly/test/t-gcd.c
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("gcd....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 40), 80);
|
||||
|
||||
fmpz_poly_gcd(a, b, c);
|
||||
fmpz_poly_gcd(b, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing a and b):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 40), 80);
|
||||
|
||||
fmpz_poly_gcd(a, b, c);
|
||||
fmpz_poly_gcd(c, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing a and c):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check that a divides GCD(af, ag) */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, d, f, g, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest_not_zero(a, state, n_randint(state, 24) + 1, 24);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
|
||||
fmpz_poly_mul(f, a, f);
|
||||
fmpz_poly_mul(g, a, g);
|
||||
fmpz_poly_gcd(d, f, g);
|
||||
|
||||
fmpz_poly_divrem_divconquer(q, r, d, a);
|
||||
|
||||
result = (r->length == WORD(0));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (check a | gcd(af, ag)):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n");
|
||||
fmpz_poly_print(g), flint_printf("\n");
|
||||
fmpz_poly_print(a), flint_printf("\n");
|
||||
fmpz_poly_print(d), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(d);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
235
external/flint-2.4.3/fmpz_poly/test/t-gcd_heuristic.c
vendored
Normal file
235
external/flint-2.4.3/fmpz_poly/test/t-gcd_heuristic.c
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
/*
|
||||
Tests whether the polynomial is suitably normalised for the
|
||||
result of a GCD operation, that is, whether it's leading
|
||||
coefficient is non-negative.
|
||||
*/
|
||||
static
|
||||
int _t_gcd_is_canonical(const fmpz_poly_t poly)
|
||||
{
|
||||
return fmpz_poly_is_zero(poly) || (fmpz_sgn(fmpz_poly_lead(poly)) > 0);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result, d1, d2;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("gcd_heuristic....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 40), 80);
|
||||
|
||||
d1 = fmpz_poly_gcd_heuristic(a, b, c);
|
||||
d2 = fmpz_poly_gcd_heuristic(b, b, c);
|
||||
|
||||
result = ((d1 == 0 && d2 == 0) || (fmpz_poly_equal(a, b)
|
||||
&& _t_gcd_is_canonical(a)));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing a and b):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 40), 80);
|
||||
|
||||
d1 = fmpz_poly_gcd_heuristic(a, b, c);
|
||||
d2 = fmpz_poly_gcd_heuristic(c, b, c);
|
||||
|
||||
result = ((d1 == 0 && d2 == 0) || (fmpz_poly_equal(a, c)
|
||||
&& _t_gcd_is_canonical(a)));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing a and c):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("c = "), fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check that a divides GCD(af, ag) */
|
||||
for (i = 0; i < 300 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, d, f, g, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest_not_zero(a, state, n_randint(state, 100) + 1, 40);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100), 40);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 100), 40);
|
||||
|
||||
fmpz_poly_mul(f, a, f);
|
||||
fmpz_poly_mul(g, a, g);
|
||||
d1 = fmpz_poly_gcd_heuristic(d, f, g);
|
||||
|
||||
if (d1)
|
||||
{
|
||||
fmpz_poly_divrem_divconquer(q, r, d, a);
|
||||
|
||||
result = fmpz_poly_is_zero(r) && _t_gcd_is_canonical(d);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (check a | gcd(af, ag)):\n");
|
||||
flint_printf("f = "), fmpz_poly_print(f), flint_printf("\n");
|
||||
flint_printf("g = "), fmpz_poly_print(g), flint_printf("\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n");
|
||||
flint_printf("d = "), fmpz_poly_print(d), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(d);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check that a == GCD(af, ag) when GCD(f, g) = 1 */
|
||||
for (i = 0; i < 300 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, d, f, g, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest_not_zero(a, state, n_randint(state, 100) + 1, 200);
|
||||
do {
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_gcd_heuristic(d, f, g);
|
||||
} while (!(d->length == 1 && fmpz_is_one(d->coeffs)));
|
||||
|
||||
fmpz_poly_mul(f, a, f);
|
||||
fmpz_poly_mul(g, a, g);
|
||||
d1 = fmpz_poly_gcd_heuristic(d, f, g);
|
||||
|
||||
if (d1)
|
||||
{
|
||||
if (!_t_gcd_is_canonical(a)) fmpz_poly_neg(a, a);
|
||||
|
||||
result = fmpz_poly_equal(d, a) && _t_gcd_is_canonical(d);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (check a == gcd(af, ag) when gcd(f, g) = 1):\n");
|
||||
flint_printf("f = "), fmpz_poly_print(f), flint_printf("\n");
|
||||
flint_printf("g = "), fmpz_poly_print(g), flint_printf("\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n");
|
||||
flint_printf("d = "), fmpz_poly_print(d), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(d);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Sebastian's test case */
|
||||
{
|
||||
fmpz_poly_t a, b, d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(d);
|
||||
|
||||
fmpz_poly_set_coeff_ui(b, 2, 1);
|
||||
fmpz_poly_set_coeff_si(a, 0, -32);
|
||||
fmpz_poly_set_coeff_si(a, 1, 24);
|
||||
|
||||
fmpz_poly_gcd_heuristic(d, a, b);
|
||||
|
||||
result = (d->length == 1 && fmpz_is_one(d->coeffs));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (check 1 == gcd(x^2, 24*x - 32):\n");
|
||||
fmpz_poly_print(d); flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
256
external/flint-2.4.3/fmpz_poly/test/t-gcd_modular.c
vendored
Normal file
256
external/flint-2.4.3/fmpz_poly/test/t-gcd_modular.c
vendored
Normal file
@@ -0,0 +1,256 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
/*
|
||||
Tests whether the polynomial is suitably normalised for the
|
||||
result of a GCD operation, that is, whether it's leading
|
||||
coefficient is non-negative.
|
||||
*/
|
||||
static
|
||||
int _t_gcd_is_canonical(const fmpz_poly_t poly)
|
||||
{
|
||||
return fmpz_poly_is_zero(poly) || (fmpz_sgn(fmpz_poly_lead(poly)) > 0);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("gcd_modular....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 40), 80);
|
||||
|
||||
fmpz_poly_gcd_modular(a, b, c);
|
||||
fmpz_poly_gcd_modular(b, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, b) && _t_gcd_is_canonical(a));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing a and b):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 40), 80);
|
||||
|
||||
fmpz_poly_gcd_modular(a, b, c);
|
||||
fmpz_poly_gcd_modular(c, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, c) && _t_gcd_is_canonical(a));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing a and c):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("c = "), fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check that a divides GCD(af, ag) */
|
||||
for (i = 0; i < 300 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, d, f, g, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest_not_zero(a, state, n_randint(state, 100) + 1, 40);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100), 40);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 100), 40);
|
||||
|
||||
fmpz_poly_mul(f, a, f);
|
||||
fmpz_poly_mul(g, a, g);
|
||||
fmpz_poly_gcd_modular(d, f, g);
|
||||
|
||||
fmpz_poly_divrem_divconquer(q, r, d, a);
|
||||
|
||||
result = fmpz_poly_is_zero(r) && _t_gcd_is_canonical(d);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (check a | gcd(af, ag)):\n");
|
||||
flint_printf("f = "), fmpz_poly_print(f), flint_printf("\n");
|
||||
flint_printf("g = "), fmpz_poly_print(g), flint_printf("\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n");
|
||||
flint_printf("d = "), fmpz_poly_print(d), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(d);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check that a == GCD(af, ag) when GCD(f, g) = 1 */
|
||||
for (i = 0; i < 300 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, d, f, g, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest_not_zero(a, state, n_randint(state, 100) + 1, 200);
|
||||
do {
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_gcd_heuristic(d, f, g);
|
||||
} while (!(d->length == 1 && fmpz_is_one(d->coeffs)));
|
||||
|
||||
fmpz_poly_mul(f, a, f);
|
||||
fmpz_poly_mul(g, a, g);
|
||||
fmpz_poly_gcd_modular(d, f, g);
|
||||
|
||||
if (!_t_gcd_is_canonical(a)) fmpz_poly_neg(a, a);
|
||||
|
||||
result = fmpz_poly_equal(d, a) && _t_gcd_is_canonical(d);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (check a == gcd(af, ag) when gcd(f, g) = 1):\n");
|
||||
flint_printf("f = "), fmpz_poly_print(f), flint_printf("\n");
|
||||
flint_printf("g = "), fmpz_poly_print(g), flint_printf("\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n");
|
||||
flint_printf("d = "), fmpz_poly_print(d), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(d);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Sebastian's test case */
|
||||
{
|
||||
fmpz_poly_t a, b, d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(d);
|
||||
|
||||
fmpz_poly_set_coeff_ui(b, 2, 1);
|
||||
fmpz_poly_set_coeff_si(a, 0, -32);
|
||||
fmpz_poly_set_coeff_si(a, 1, 24);
|
||||
|
||||
fmpz_poly_gcd_modular(d, a, b);
|
||||
|
||||
result = (d->length == 1 && fmpz_is_one(d->coeffs));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (check 1 == gcd(x^2, 24*x - 32):\n");
|
||||
fmpz_poly_print(d); flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
/* another test case */
|
||||
{
|
||||
fmpz_poly_t a, b, d, e;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_init(e);
|
||||
|
||||
fmpz_poly_set_str(a, "12 0 0 0 0 0 0 0 0 0 8582594367 -9297159048333985579007 33822867456");
|
||||
fmpz_poly_set_str(b, "8 0 0 -258272396248218664896 0 -2762 -549690802047 -3771028 8796059467776");
|
||||
fmpz_poly_set_str(e, "3 0 0 1");
|
||||
|
||||
fmpz_poly_gcd_modular(d, a, b);
|
||||
|
||||
result = fmpz_poly_equal(d, e);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (check special #2):\n");
|
||||
fmpz_poly_print(d); flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(d);
|
||||
fmpz_poly_clear(e);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
145
external/flint-2.4.3/fmpz_poly/test/t-gcd_subresultant.c
vendored
Normal file
145
external/flint-2.4.3/fmpz_poly/test/t-gcd_subresultant.c
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("gcd_subresultant....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 40), 80);
|
||||
|
||||
fmpz_poly_gcd_subresultant(a, b, c);
|
||||
fmpz_poly_gcd_subresultant(b, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing a and b):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 40), 80);
|
||||
|
||||
fmpz_poly_gcd_subresultant(a, b, c);
|
||||
fmpz_poly_gcd_subresultant(c, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing a and c):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check that a divides GCD(af, ag) */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, d, f, g, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest_not_zero(a, state, n_randint(state, 24) + 1, 24);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
|
||||
fmpz_poly_mul(f, a, f);
|
||||
fmpz_poly_mul(g, a, g);
|
||||
fmpz_poly_gcd_subresultant(d, f, g);
|
||||
|
||||
fmpz_poly_divrem_divconquer(q, r, d, a);
|
||||
|
||||
result = (r->length == WORD(0));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (check a | gcd(af, ag)):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n");
|
||||
fmpz_poly_print(g), flint_printf("\n");
|
||||
fmpz_poly_print(d), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(d);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
76
external/flint-2.4.3/fmpz_poly/test/t-get_coeff_ptr.c
vendored
Normal file
76
external/flint-2.4.3/fmpz_poly/test/t-get_coeff_ptr.c
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("get_coeff_ptr....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t A;
|
||||
fmpz_t a;
|
||||
slong n = n_randint(state, 100);
|
||||
|
||||
fmpz_poly_init(A);
|
||||
fmpz_poly_randtest(A, state, n_randint(state, 100), 100);
|
||||
fmpz_init(a);
|
||||
|
||||
fmpz_poly_get_coeff_fmpz(a, A, n);
|
||||
|
||||
result = n < fmpz_poly_length(A) ?
|
||||
fmpz_equal(a, fmpz_poly_get_coeff_ptr(A, n)) :
|
||||
fmpz_poly_get_coeff_ptr(A, n) == NULL;
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A = "), fmpz_poly_print(A), flint_printf("\n\n");
|
||||
flint_printf("a = "), fmpz_print(a), flint_printf("\n\n");
|
||||
flint_printf("n = %wd\n\n", n);
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(A);
|
||||
fmpz_clear(a);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
87
external/flint-2.4.3/fmpz_poly/test/t-get_nmod_poly.c
vendored
Normal file
87
external/flint-2.4.3/fmpz_poly/test/t-get_nmod_poly.c
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "nmod_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
|
||||
flint_printf("get/set_nmod_poly....");
|
||||
fflush(stdout);
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t A;
|
||||
nmod_poly_t M, M2;
|
||||
slong length;
|
||||
mp_limb_t mod;
|
||||
|
||||
length = n_randint(state, 50);
|
||||
|
||||
mod = n_randtest_prime(state, 0);
|
||||
|
||||
nmod_poly_init(M, mod);
|
||||
nmod_poly_init(M2, mod);
|
||||
fmpz_poly_init(A);
|
||||
|
||||
nmod_poly_randtest(M, state, length);
|
||||
|
||||
if (i % 2 == 0)
|
||||
fmpz_poly_set_nmod_poly(A, M);
|
||||
else
|
||||
fmpz_poly_set_nmod_poly_unsigned(A, M);
|
||||
|
||||
fmpz_poly_scalar_mul_ui(A, A, UWORD(2));
|
||||
nmod_poly_add(M, M, M);
|
||||
fmpz_poly_get_nmod_poly(M2, A);
|
||||
|
||||
if (!nmod_poly_equal(M, M2))
|
||||
{
|
||||
flint_printf("FAIL!\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(A);
|
||||
nmod_poly_clear(M);
|
||||
nmod_poly_clear(M2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
83
external/flint-2.4.3/fmpz_poly/test/t-get_set_coeff_fmpz.c
vendored
Normal file
83
external/flint-2.4.3/fmpz_poly/test/t-get_set_coeff_fmpz.c
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, j, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("get/set_coeff_fmpz....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a;
|
||||
fmpz_t x1, x2;
|
||||
slong coeff, len;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_init(x1);
|
||||
fmpz_init(x2);
|
||||
len = n_randint(state, 100) + 1;
|
||||
|
||||
for (j = 0; j < 1000; j++)
|
||||
{
|
||||
fmpz_randtest(x1, state, 200);
|
||||
coeff = n_randint(state, len);
|
||||
fmpz_poly_set_coeff_fmpz(a, coeff, x1);
|
||||
fmpz_poly_get_coeff_fmpz(x2, a, coeff);
|
||||
|
||||
result = (fmpz_equal(x1, x2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("x1 = "), fmpz_print(x1), flint_printf("\n");
|
||||
flint_printf("x2 = "), fmpz_print(x2), flint_printf("\n");
|
||||
flint_printf("coeff = %wd, length = %wd\n", coeff, len);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_clear(x1);
|
||||
fmpz_clear(x2);
|
||||
fmpz_poly_clear(a);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
90
external/flint-2.4.3/fmpz_poly/test/t-get_set_coeff_mpz.c
vendored
Normal file
90
external/flint-2.4.3/fmpz_poly/test/t-get_set_coeff_mpz.c
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, j, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("get/set_coeff_mpz....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a;
|
||||
fmpz_t x1, x2;
|
||||
mpz_t y1, y2;
|
||||
slong coeff, len;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_init(x1);
|
||||
fmpz_init(x2);
|
||||
mpz_init(y1);
|
||||
mpz_init(y2);
|
||||
len = n_randint(state, 100) + 1;
|
||||
|
||||
for (j = 0; j < 1000; j++)
|
||||
{
|
||||
fmpz_randtest(x1, state, 200);
|
||||
fmpz_get_mpz(y1, x1);
|
||||
coeff = n_randint(state, len);
|
||||
fmpz_poly_set_coeff_mpz(a, coeff, y1);
|
||||
fmpz_poly_get_coeff_mpz(y2, a, coeff);
|
||||
fmpz_set_mpz(x2, y2);
|
||||
|
||||
result = (fmpz_equal(x1, x2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("x1 = "), fmpz_print(x1), flint_printf("\n");
|
||||
flint_printf("x2 = "), fmpz_print(x2), flint_printf("\n");
|
||||
flint_printf("coeff = %wd, length = %wd\n", coeff, len);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_clear(x1);
|
||||
fmpz_clear(x2);
|
||||
mpz_clear(y1);
|
||||
mpz_clear(y2);
|
||||
fmpz_poly_clear(a);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
77
external/flint-2.4.3/fmpz_poly/test/t-get_set_coeff_si.c
vendored
Normal file
77
external/flint-2.4.3/fmpz_poly/test/t-get_set_coeff_si.c
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "long_extras.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, j, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("get/set_coeff_si....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a;
|
||||
slong coeff, len;
|
||||
slong n1, n2;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
len = n_randint(state, 100) + 1;
|
||||
|
||||
for (j = 0; j < 1000; j++)
|
||||
{
|
||||
n1 = z_randtest(state);
|
||||
coeff = n_randint(state, len);
|
||||
fmpz_poly_set_coeff_si(a, coeff, n1);
|
||||
n2 = fmpz_poly_get_coeff_si(a, coeff);
|
||||
|
||||
result = (n1 == n2);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL: n1 = %wd, n2 = %wd, coeff = %wd, length = %wd\n",
|
||||
n1, n2, coeff, len);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
76
external/flint-2.4.3/fmpz_poly/test/t-get_set_coeff_ui.c
vendored
Normal file
76
external/flint-2.4.3/fmpz_poly/test/t-get_set_coeff_ui.c
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/*============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
===============================================================================*/
|
||||
/****************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, j, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("get/set_coeff_ui....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a;
|
||||
ulong n1, n2;
|
||||
slong coeff, len;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
len = n_randint(state, 100) + 1;
|
||||
|
||||
for (j = 0; j < 1000; j++)
|
||||
{
|
||||
n1 = n_randtest(state);
|
||||
coeff = n_randint(state, len);
|
||||
fmpz_poly_set_coeff_ui(a, coeff, n1);
|
||||
n2 = fmpz_poly_get_coeff_ui(a, coeff);
|
||||
|
||||
result = (n1 == n2);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL: n1 = %wu, n2 = %wu, coeff = %wd, length = %wd\n",
|
||||
n1, n2, coeff, len);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
77
external/flint-2.4.3/fmpz_poly/test/t-get_set_str.c
vendored
Normal file
77
external/flint-2.4.3/fmpz_poly/test/t-get_set_str.c
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("get_set_str....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
char * str;
|
||||
int ans;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), n_randint(state, 200));
|
||||
|
||||
str = fmpz_poly_get_str(a);
|
||||
ans = fmpz_poly_set_str(b, str);
|
||||
|
||||
result = (ans == 0 && fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
flint_free(str);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
88
external/flint-2.4.3/fmpz_poly/test/t-get_str.c
vendored
Normal file
88
external/flint-2.4.3/fmpz_poly/test/t-get_str.c
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int result;
|
||||
char *str;
|
||||
fmpz_poly_t a;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("get_str....");
|
||||
fflush(stdout);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
|
||||
str = fmpz_poly_get_str(a);
|
||||
result = strcmp(str, "0") == 0;
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n");
|
||||
flint_printf("str(a) = {%s}\n", str);
|
||||
abort();
|
||||
}
|
||||
flint_free(str);
|
||||
|
||||
fmpz_poly_set_si(a, -2);
|
||||
str = fmpz_poly_get_str(a);
|
||||
result = strcmp(str, "1 -2") == 0;
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n");
|
||||
flint_printf("str(a) = {%s}\n", str);
|
||||
abort();
|
||||
}
|
||||
flint_free(str);
|
||||
|
||||
fmpz_poly_set_coeff_si(a, 3, 1);
|
||||
str = fmpz_poly_get_str(a);
|
||||
result = strcmp(str, "4 -2 0 0 1") == 0;
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n");
|
||||
flint_printf("str(a) = {%s}\n", str);
|
||||
abort();
|
||||
}
|
||||
flint_free(str);
|
||||
fmpz_poly_clear(a);
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
88
external/flint-2.4.3/fmpz_poly/test/t-get_str_pretty.c
vendored
Normal file
88
external/flint-2.4.3/fmpz_poly/test/t-get_str_pretty.c
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int result;
|
||||
char *str;
|
||||
fmpz_poly_t a;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("get_str_pretty....");
|
||||
fflush(stdout);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
|
||||
str = fmpz_poly_get_str_pretty(a, "t");
|
||||
result = strcmp(str, "0") == 0;
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n");
|
||||
flint_printf("str(a) = {%s}\n", str);
|
||||
abort();
|
||||
}
|
||||
flint_free(str);
|
||||
|
||||
fmpz_poly_set_si(a, -2);
|
||||
str = fmpz_poly_get_str_pretty(a, "t");
|
||||
result = strcmp(str, "-2") == 0;
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n");
|
||||
flint_printf("str(a) = {%s}\n", str);
|
||||
abort();
|
||||
}
|
||||
flint_free(str);
|
||||
|
||||
fmpz_poly_set_coeff_si(a, 3, 1);
|
||||
str = fmpz_poly_get_str_pretty(a, "t");
|
||||
result = strcmp(str, "t^3-2") == 0;
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n");
|
||||
flint_printf("str(a) = {%s}\n", str);
|
||||
abort();
|
||||
}
|
||||
flint_free(str);
|
||||
fmpz_poly_clear(a);
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
213
external/flint-2.4.3/fmpz_poly/test/t-hensel_lift.c
vendored
Normal file
213
external/flint-2.4.3/fmpz_poly/test/t-hensel_lift.c
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011 William Hart
|
||||
Copyright (C) 2011 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "nmod_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("hensel_lift....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* We check that lifting local factors of F_poly yields factors */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t F_poly, F_poly2, F_poly3, A, B, G, H,
|
||||
A_out, B_out, G_out, H_out, Prod_1, Prod_2;
|
||||
nmod_poly_t a, b, d, g, h, prod;
|
||||
fmpz_t p, p1, big_P, p1_2, big_P_2;
|
||||
slong bits, length, nbits, n, exp, part_exp;
|
||||
|
||||
bits = n_randint(state, 200) + 1;
|
||||
nbits = n_randint(state, FLINT_BITS - 6) + 6;
|
||||
|
||||
fmpz_init(p);
|
||||
fmpz_init(p1);
|
||||
fmpz_init(big_P);
|
||||
fmpz_init(p1_2);
|
||||
fmpz_init(big_P_2);
|
||||
|
||||
fmpz_poly_init(F_poly);
|
||||
fmpz_poly_init(F_poly2);
|
||||
fmpz_poly_init(F_poly3);
|
||||
|
||||
fmpz_poly_init(Prod_1);
|
||||
fmpz_poly_init(Prod_2);
|
||||
|
||||
fmpz_poly_init(A);
|
||||
fmpz_poly_init(B);
|
||||
fmpz_poly_init(G);
|
||||
fmpz_poly_init(H);
|
||||
fmpz_poly_init(A_out);
|
||||
fmpz_poly_init(B_out);
|
||||
fmpz_poly_init(G_out);
|
||||
fmpz_poly_init(H_out);
|
||||
|
||||
n = n_randprime(state, nbits, 0);
|
||||
exp = bits/(FLINT_BIT_COUNT(n) - 1) + 1;
|
||||
part_exp = n_randint(state, exp);
|
||||
|
||||
nmod_poly_init(g, n);
|
||||
nmod_poly_init(h, n);
|
||||
nmod_poly_init(a, n);
|
||||
nmod_poly_init(b, n);
|
||||
nmod_poly_init(d, n);
|
||||
nmod_poly_init(prod, n);
|
||||
|
||||
do {
|
||||
length = n_randint(state, 200) + 2;
|
||||
|
||||
do { fmpz_poly_randtest(F_poly2, state, length, bits); }
|
||||
while (F_poly2->length < 2);
|
||||
|
||||
fmpz_set_ui(F_poly2->coeffs, n_randbits(state, FLINT_MIN(bits, FLINT_BITS - 2)));
|
||||
fmpz_set_ui(F_poly2->coeffs + F_poly2->length - 1, 1);
|
||||
|
||||
length = n_randint(state, 200) + 2;
|
||||
|
||||
do { fmpz_poly_randtest(F_poly3, state, length, bits); }
|
||||
while (F_poly3->length < 2);
|
||||
|
||||
fmpz_set_ui(F_poly3->coeffs, n_randbits(state, FLINT_MIN(bits, FLINT_BITS - 2)));
|
||||
fmpz_set_ui(F_poly3->coeffs + F_poly3->length - 1, 1);
|
||||
|
||||
fmpz_poly_mul(F_poly, F_poly2, F_poly3);
|
||||
|
||||
fmpz_poly_get_nmod_poly(prod, F_poly);
|
||||
} while (!nmod_poly_is_squarefree(prod));
|
||||
|
||||
fmpz_poly_get_nmod_poly(g, F_poly2);
|
||||
fmpz_poly_get_nmod_poly(h, F_poly3);
|
||||
|
||||
nmod_poly_xgcd(d, a, b, g, h);
|
||||
nmod_poly_clear(prod);
|
||||
nmod_poly_clear(d);
|
||||
|
||||
fmpz_poly_set_nmod_poly(A, a);
|
||||
fmpz_poly_set_nmod_poly(B, b);
|
||||
fmpz_poly_set_nmod_poly(G, g);
|
||||
fmpz_poly_set_nmod_poly(H, h);
|
||||
|
||||
fmpz_set_ui(p, n);
|
||||
fmpz_set_ui(p1, n);
|
||||
fmpz_set_ui(big_P, n);
|
||||
fmpz_set_ui(p1_2, n);
|
||||
fmpz_set_ui(big_P_2, n);
|
||||
|
||||
part_exp = 1;
|
||||
|
||||
while (part_exp < exp)
|
||||
{
|
||||
fmpz_set(p, big_P);
|
||||
fmpz_set_ui(p1, n);
|
||||
fmpz_set_ui(big_P, n);
|
||||
|
||||
if (exp - part_exp <= part_exp)
|
||||
{
|
||||
fmpz_pow_ui(p1, p1, exp - part_exp);
|
||||
fmpz_pow_ui(big_P, big_P, exp);
|
||||
part_exp = exp;
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_set(p1, p);
|
||||
fmpz_pow_ui(big_P, big_P, 2*part_exp);
|
||||
part_exp = 2*part_exp;
|
||||
}
|
||||
|
||||
fmpz_poly_hensel_lift(G_out, H_out, A_out, B_out, F_poly,
|
||||
G, H, A, B, p, p1);
|
||||
|
||||
fmpz_poly_set(G, G_out);
|
||||
fmpz_poly_set(H, H_out);
|
||||
fmpz_poly_set(A, A_out);
|
||||
fmpz_poly_set(B, B_out);
|
||||
}
|
||||
|
||||
fmpz_poly_mul(Prod_1, A, G);
|
||||
fmpz_poly_mul(Prod_2, B, H);
|
||||
fmpz_poly_add(Prod_1, Prod_1, Prod_2);
|
||||
|
||||
fmpz_poly_scalar_smod_fmpz(Prod_1, Prod_1, big_P);
|
||||
|
||||
result = (Prod_1->length == 1 && fmpz_is_one(Prod_1->coeffs));
|
||||
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("length = %wd, bits = %wd, n = %wd, exp = %wd\n", length, bits, n, exp);
|
||||
fmpz_poly_print(F_poly); flint_printf("\n\n");
|
||||
fmpz_poly_print(F_poly2); flint_printf("\n\n");
|
||||
fmpz_poly_print(F_poly3); flint_printf("\n\n");
|
||||
fmpz_poly_print(Prod_1); flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
nmod_poly_clear(g);
|
||||
nmod_poly_clear(h);
|
||||
nmod_poly_clear(a);
|
||||
nmod_poly_clear(b);
|
||||
|
||||
fmpz_poly_clear(Prod_1);
|
||||
fmpz_poly_clear(Prod_2);
|
||||
|
||||
fmpz_poly_clear(A);
|
||||
fmpz_poly_clear(B);
|
||||
fmpz_poly_clear(G);
|
||||
fmpz_poly_clear(H);
|
||||
fmpz_poly_clear(A_out);
|
||||
fmpz_poly_clear(B_out);
|
||||
fmpz_poly_clear(G_out);
|
||||
fmpz_poly_clear(H_out);
|
||||
|
||||
fmpz_clear(p);
|
||||
fmpz_clear(p1);
|
||||
fmpz_clear(big_P);
|
||||
fmpz_clear(p1_2);
|
||||
fmpz_clear(big_P_2);
|
||||
|
||||
fmpz_poly_clear(F_poly3);
|
||||
fmpz_poly_clear(F_poly2);
|
||||
fmpz_poly_clear(F_poly);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
132
external/flint-2.4.3/fmpz_poly/test/t-hensel_lift_once.c
vendored
Normal file
132
external/flint-2.4.3/fmpz_poly/test/t-hensel_lift_once.c
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011 William Hart
|
||||
Copyright (C) 2011 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "nmod_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("hensel_lift_once....");
|
||||
fflush(stdout);
|
||||
|
||||
/* We check that lifting local factors of F yields factors */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t F, G, H, R;
|
||||
fmpz_poly_factor_t F_fac;
|
||||
nmod_poly_factor_t f_fac;
|
||||
slong bits, nbits, n, exp, j;
|
||||
|
||||
bits = n_randint(state, 200) + 1;
|
||||
nbits = n_randint(state, FLINT_BITS - 6) + 6;
|
||||
|
||||
fmpz_poly_init(F);
|
||||
fmpz_poly_init(G);
|
||||
fmpz_poly_init(H);
|
||||
fmpz_poly_init(R);
|
||||
nmod_poly_factor_init(f_fac);
|
||||
fmpz_poly_factor_init(F_fac);
|
||||
|
||||
n = n_randprime(state, nbits, 0);
|
||||
exp = bits / (FLINT_BIT_COUNT(n) - 1) + 1;
|
||||
|
||||
/* Produce F as the product of random G and H */
|
||||
{
|
||||
nmod_poly_t f;
|
||||
|
||||
nmod_poly_init(f, n);
|
||||
|
||||
do {
|
||||
do {
|
||||
fmpz_poly_randtest(G, state, n_randint(state, 200) + 2, bits);
|
||||
} while (G->length < 2);
|
||||
|
||||
fmpz_randtest_not_zero(G->coeffs, state, bits);
|
||||
fmpz_one(fmpz_poly_lead(G));
|
||||
|
||||
do {
|
||||
fmpz_poly_randtest(H, state, n_randint(state, 200) + 2, bits);
|
||||
} while (H->length < 2);
|
||||
|
||||
fmpz_randtest_not_zero(H->coeffs, state, bits);
|
||||
fmpz_one(fmpz_poly_lead(H));
|
||||
|
||||
fmpz_poly_mul(F, G, H);
|
||||
|
||||
fmpz_poly_get_nmod_poly(f, F);
|
||||
} while (!nmod_poly_is_squarefree(f));
|
||||
|
||||
fmpz_poly_get_nmod_poly(f, G);
|
||||
nmod_poly_factor_insert(f_fac, f, 1);
|
||||
fmpz_poly_get_nmod_poly(f, H);
|
||||
nmod_poly_factor_insert(f_fac, f, 1);
|
||||
nmod_poly_clear(f);
|
||||
}
|
||||
|
||||
fmpz_poly_hensel_lift_once(F_fac, F, f_fac, exp);
|
||||
|
||||
result = 1;
|
||||
for (j = 0; j < F_fac->num; j++)
|
||||
{
|
||||
fmpz_poly_rem(R, F, F_fac->p + j);
|
||||
result &= (R->length == 0);
|
||||
}
|
||||
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("bits = %wd, n = %wd, exp = %wd\n", bits, n, exp);
|
||||
fmpz_poly_print(F); flint_printf("\n\n");
|
||||
fmpz_poly_print(G); flint_printf("\n\n");
|
||||
fmpz_poly_print(H); flint_printf("\n\n");
|
||||
fmpz_poly_factor_print(F_fac); flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
nmod_poly_factor_clear(f_fac);
|
||||
fmpz_poly_factor_clear(F_fac);
|
||||
fmpz_poly_clear(F);
|
||||
fmpz_poly_clear(G);
|
||||
fmpz_poly_clear(H);
|
||||
fmpz_poly_clear(R);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
212
external/flint-2.4.3/fmpz_poly/test/t-hensel_lift_without_only_inverse.c
vendored
Normal file
212
external/flint-2.4.3/fmpz_poly/test/t-hensel_lift_without_only_inverse.c
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011 William Hart
|
||||
Copyright (C) 2011 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "nmod_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("hensel_lift_without_only_inverse....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* We check that lifting local factors of F_poly yields factors */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t F_poly, F_poly2, F_poly3, A, B, G, H,
|
||||
A_out, B_out, G_out, H_out, Prod_1, Prod_2;
|
||||
nmod_poly_t a, b, d, g, h, prod;
|
||||
fmpz_t p, p1, big_P, p1_2, big_P_2;
|
||||
slong bits, length, nbits, n, exp, part_exp;
|
||||
|
||||
bits = n_randint(state, 200) + 1;
|
||||
nbits = n_randint(state, FLINT_BITS - 6) + 6;
|
||||
|
||||
fmpz_init(p);
|
||||
fmpz_init(p1);
|
||||
fmpz_init(big_P);
|
||||
fmpz_init(p1_2);
|
||||
fmpz_init(big_P_2);
|
||||
|
||||
fmpz_poly_init(F_poly);
|
||||
fmpz_poly_init(F_poly2);
|
||||
fmpz_poly_init(F_poly3);
|
||||
|
||||
fmpz_poly_init(Prod_1);
|
||||
fmpz_poly_init(Prod_2);
|
||||
|
||||
fmpz_poly_init(A);
|
||||
fmpz_poly_init(B);
|
||||
fmpz_poly_init(G);
|
||||
fmpz_poly_init(H);
|
||||
fmpz_poly_init(A_out);
|
||||
fmpz_poly_init(B_out);
|
||||
fmpz_poly_init(G_out);
|
||||
fmpz_poly_init(H_out);
|
||||
|
||||
n = n_randprime(state, nbits, 0);
|
||||
exp = bits/(FLINT_BIT_COUNT(n) - 1) + 1;
|
||||
part_exp = n_randint(state, exp);
|
||||
|
||||
nmod_poly_init(g, n);
|
||||
nmod_poly_init(h, n);
|
||||
nmod_poly_init(a, n);
|
||||
nmod_poly_init(b, n);
|
||||
nmod_poly_init(d, n);
|
||||
nmod_poly_init(prod, n);
|
||||
|
||||
do
|
||||
{
|
||||
length = n_randint(state, 200) + 2;
|
||||
do { fmpz_poly_randtest(F_poly2, state, length, bits); }
|
||||
while (F_poly2->length < 2);
|
||||
fmpz_set_ui(F_poly2->coeffs, n_randbits(state, FLINT_MIN(bits, FLINT_BITS - 2)));
|
||||
fmpz_set_ui(F_poly2->coeffs + F_poly2->length - 1, 1);
|
||||
|
||||
length = n_randint(state, 200) + 2;
|
||||
do { fmpz_poly_randtest(F_poly3, state, length, bits); }
|
||||
while (F_poly3->length < 2);
|
||||
fmpz_set_ui(F_poly3->coeffs, n_randbits(state, FLINT_MIN(bits, FLINT_BITS - 2)));
|
||||
fmpz_set_ui(F_poly3->coeffs + F_poly3->length - 1, 1);
|
||||
|
||||
fmpz_poly_mul(F_poly, F_poly2, F_poly3);
|
||||
|
||||
fmpz_poly_get_nmod_poly(prod, F_poly);
|
||||
} while (!nmod_poly_is_squarefree(prod));
|
||||
|
||||
fmpz_poly_get_nmod_poly(g, F_poly2);
|
||||
fmpz_poly_get_nmod_poly(h, F_poly3);
|
||||
|
||||
nmod_poly_xgcd(d, a, b, g, h);
|
||||
nmod_poly_clear(prod);
|
||||
nmod_poly_clear(d);
|
||||
|
||||
fmpz_poly_set_nmod_poly(A, a);
|
||||
fmpz_poly_set_nmod_poly(B, b);
|
||||
fmpz_poly_set_nmod_poly(G, g);
|
||||
fmpz_poly_set_nmod_poly(H, h);
|
||||
|
||||
fmpz_set_ui(p, n);
|
||||
fmpz_set_ui(p1, n);
|
||||
fmpz_set_ui(big_P, n);
|
||||
fmpz_set_ui(p1_2, n);
|
||||
fmpz_set_ui(big_P_2, n);
|
||||
|
||||
part_exp = 1;
|
||||
|
||||
while (part_exp < exp)
|
||||
{
|
||||
fmpz_set(p, big_P);
|
||||
fmpz_set_ui(p1, n);
|
||||
fmpz_set_ui(big_P, n);
|
||||
|
||||
if (exp - part_exp <= part_exp)
|
||||
{
|
||||
fmpz_pow_ui(p1, p1, exp - part_exp);
|
||||
fmpz_pow_ui(big_P, big_P, exp);
|
||||
part_exp = exp;
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_set(p1, p);
|
||||
fmpz_pow_ui(big_P, big_P, 2*part_exp);
|
||||
part_exp = 2*part_exp;
|
||||
}
|
||||
|
||||
fmpz_poly_hensel_lift_without_inverse(G_out, H_out, F_poly,
|
||||
G, H, A, B, p, p1);
|
||||
fmpz_poly_hensel_lift_only_inverse(A_out, B_out,
|
||||
G_out, H_out, A, B, p, p1);
|
||||
|
||||
fmpz_poly_set(G, G_out);
|
||||
fmpz_poly_set(H, H_out);
|
||||
fmpz_poly_set(A, A_out);
|
||||
fmpz_poly_set(B, B_out);
|
||||
}
|
||||
|
||||
fmpz_poly_mul(Prod_1, A, G);
|
||||
fmpz_poly_mul(Prod_2, B, H);
|
||||
fmpz_poly_add(Prod_1, Prod_1, Prod_2);
|
||||
|
||||
fmpz_poly_scalar_smod_fmpz(Prod_1, Prod_1, big_P);
|
||||
|
||||
result = (Prod_1->length == 1 && fmpz_is_one(Prod_1->coeffs));
|
||||
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("length = %wd, bits = %wd, n = %wd, exp = %wd\n", length, bits, n, exp);
|
||||
fmpz_poly_print(F_poly); flint_printf("\n\n");
|
||||
fmpz_poly_print(F_poly2); flint_printf("\n\n");
|
||||
fmpz_poly_print(F_poly3); flint_printf("\n\n");
|
||||
fmpz_poly_print(Prod_1); flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
nmod_poly_clear(g);
|
||||
nmod_poly_clear(h);
|
||||
nmod_poly_clear(a);
|
||||
nmod_poly_clear(b);
|
||||
|
||||
fmpz_poly_clear(Prod_1);
|
||||
fmpz_poly_clear(Prod_2);
|
||||
|
||||
fmpz_poly_clear(A);
|
||||
fmpz_poly_clear(B);
|
||||
fmpz_poly_clear(G);
|
||||
fmpz_poly_clear(H);
|
||||
fmpz_poly_clear(A_out);
|
||||
fmpz_poly_clear(B_out);
|
||||
fmpz_poly_clear(G_out);
|
||||
fmpz_poly_clear(H_out);
|
||||
|
||||
fmpz_clear(p);
|
||||
fmpz_clear(p1);
|
||||
fmpz_clear(big_P);
|
||||
fmpz_clear(p1_2);
|
||||
fmpz_clear(big_P_2);
|
||||
|
||||
fmpz_poly_clear(F_poly3);
|
||||
fmpz_poly_clear(F_poly2);
|
||||
fmpz_poly_clear(F_poly);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
177
external/flint-2.4.3/fmpz_poly/test/t-hensel_start_continue_lift.c
vendored
Normal file
177
external/flint-2.4.3/fmpz_poly/test/t-hensel_start_continue_lift.c
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011 William Hart
|
||||
Copyright (C) 2011 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "nmod_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
#include "mpn_extras.h"
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("hensel_start_continue_lift....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* We check that lifting local factors of F yields factors */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t F, G, H, R;
|
||||
nmod_poly_factor_t f_fac;
|
||||
fmpz_poly_factor_t F_fac;
|
||||
slong bits, nbits, n, exp, j, part_exp;
|
||||
|
||||
slong r;
|
||||
fmpz_poly_t *v, *w;
|
||||
slong *link;
|
||||
slong prev_exp;
|
||||
|
||||
bits = n_randint(state, 200) + 1;
|
||||
nbits = n_randint(state, FLINT_BITS - 6) + 6;
|
||||
|
||||
fmpz_poly_init(F);
|
||||
fmpz_poly_init(G);
|
||||
fmpz_poly_init(H);
|
||||
fmpz_poly_init(R);
|
||||
nmod_poly_factor_init(f_fac);
|
||||
fmpz_poly_factor_init(F_fac);
|
||||
|
||||
n = n_randprime(state, nbits, 0);
|
||||
exp = bits / (FLINT_BIT_COUNT(n) - 1) + 1;
|
||||
part_exp = n_randint(state, exp);
|
||||
|
||||
/* Produce F as the product of random G and H */
|
||||
{
|
||||
nmod_poly_t f;
|
||||
|
||||
nmod_poly_init(f, n);
|
||||
|
||||
do {
|
||||
do {
|
||||
fmpz_poly_randtest(G, state, n_randint(state, 200) + 2, bits);
|
||||
} while (G->length < 2);
|
||||
|
||||
fmpz_randtest_not_zero(G->coeffs, state, bits);
|
||||
fmpz_one(fmpz_poly_lead(G));
|
||||
|
||||
do {
|
||||
fmpz_poly_randtest(H, state, n_randint(state, 200) + 2, bits);
|
||||
} while (H->length < 2);
|
||||
|
||||
fmpz_randtest_not_zero(H->coeffs, state, bits);
|
||||
fmpz_one(fmpz_poly_lead(H));
|
||||
|
||||
fmpz_poly_mul(F, G, H);
|
||||
|
||||
fmpz_poly_get_nmod_poly(f, F);
|
||||
} while (!nmod_poly_is_squarefree(f));
|
||||
|
||||
fmpz_poly_get_nmod_poly(f, G);
|
||||
nmod_poly_factor_insert(f_fac, f, 1);
|
||||
fmpz_poly_get_nmod_poly(f, H);
|
||||
nmod_poly_factor_insert(f_fac, f, 1);
|
||||
nmod_poly_clear(f);
|
||||
}
|
||||
|
||||
r = f_fac->num;
|
||||
v = flint_malloc((2*r - 2)*sizeof(fmpz_poly_t));
|
||||
w = flint_malloc((2*r - 2)*sizeof(fmpz_poly_t));
|
||||
link = flint_malloc((2*r - 2)*sizeof(slong));
|
||||
|
||||
for (j = 0; j < 2*r - 2; j++)
|
||||
{
|
||||
fmpz_poly_init(v[j]);
|
||||
fmpz_poly_init(w[j]);
|
||||
}
|
||||
|
||||
if (part_exp < 1)
|
||||
{
|
||||
_fmpz_poly_hensel_start_lift(F_fac, link, v, w, F, f_fac, exp);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_t nn;
|
||||
|
||||
fmpz_init_set_ui(nn, n);
|
||||
|
||||
prev_exp = _fmpz_poly_hensel_start_lift(F_fac, link, v, w,
|
||||
F, f_fac, part_exp);
|
||||
_fmpz_poly_hensel_continue_lift(F_fac, link, v, w,
|
||||
F, prev_exp, part_exp, exp, nn);
|
||||
|
||||
fmpz_clear(nn);
|
||||
}
|
||||
|
||||
result = 1;
|
||||
for (j = 0; j < F_fac->num; j++)
|
||||
{
|
||||
fmpz_poly_rem(R, F, F_fac->p + j);
|
||||
result &= (R->length == 0);
|
||||
}
|
||||
|
||||
for (j = 0; j < 2*r - 2; j++)
|
||||
{
|
||||
fmpz_poly_clear(v[j]);
|
||||
fmpz_poly_clear(w[j]);
|
||||
}
|
||||
|
||||
flint_free(link);
|
||||
flint_free(v);
|
||||
flint_free(w);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("bits = %wd, n = %wd, exp = %wd\n", bits, n, exp);
|
||||
fmpz_poly_print(F); flint_printf("\n\n");
|
||||
fmpz_poly_print(G); flint_printf("\n\n");
|
||||
fmpz_poly_print(H); flint_printf("\n\n");
|
||||
fmpz_poly_factor_print(F_fac); flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
nmod_poly_factor_clear(f_fac);
|
||||
fmpz_poly_factor_clear(F_fac);
|
||||
|
||||
fmpz_poly_clear(F);
|
||||
fmpz_poly_clear(H);
|
||||
fmpz_poly_clear(G);
|
||||
fmpz_poly_clear(R);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
74
external/flint-2.4.3/fmpz_poly/test/t-init_realloc_clear.c
vendored
Normal file
74
external/flint-2.4.3/fmpz_poly/test/t-init_realloc_clear.c
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("init/init2/realloc/clear....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a;
|
||||
|
||||
fmpz_poly_init2(a, n_randint(state, 100));
|
||||
fmpz_poly_clear(a);
|
||||
}
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a;
|
||||
|
||||
fmpz_poly_init2(a, n_randint(state, 100));
|
||||
fmpz_poly_realloc(a, n_randint(state, 100));
|
||||
fmpz_poly_clear(a);
|
||||
}
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_clear(a);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
88
external/flint-2.4.3/fmpz_poly/test/t-interpolate_fmpz_vec.c
vendored
Normal file
88
external/flint-2.4.3/fmpz_poly/test/t-interpolate_fmpz_vec.c
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("interpolate_fmpz_vec....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t P, Q;
|
||||
fmpz *x, *y;
|
||||
slong j, n, npoints, bits;
|
||||
|
||||
npoints = n_randint(state, 50);
|
||||
n = n_randint(state, npoints + 1);
|
||||
bits = n_randint(state, 100);
|
||||
|
||||
x = _fmpz_vec_init(npoints);
|
||||
y = _fmpz_vec_init(npoints);
|
||||
|
||||
fmpz_poly_init(P);
|
||||
fmpz_poly_init(Q);
|
||||
|
||||
fmpz_poly_randtest(P, state, n, bits);
|
||||
|
||||
for (j = 0; j < npoints; j++)
|
||||
fmpz_set_si(x + j, -npoints/2 + j);
|
||||
|
||||
fmpz_poly_evaluate_fmpz_vec(y, P, x, npoints);
|
||||
fmpz_poly_interpolate_fmpz_vec(Q, x, y, npoints);
|
||||
|
||||
result = (fmpz_poly_equal(P, Q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (P != Q):\n");
|
||||
fmpz_poly_print(P), flint_printf("\n\n");
|
||||
fmpz_poly_print(Q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(P);
|
||||
fmpz_poly_clear(Q);
|
||||
_fmpz_vec_clear(x, npoints);
|
||||
_fmpz_vec_clear(y, npoints);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
116
external/flint-2.4.3/fmpz_poly/test/t-inv_series_newton.c
vendored
Normal file
116
external/flint-2.4.3/fmpz_poly/test/t-inv_series_newton.c
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("inv_series_newton....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check Q^{-1} * Q is congruent 1 mod t^n */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, one;
|
||||
slong n = n_randint(state, 80) + 1;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(one);
|
||||
|
||||
fmpz_poly_randtest_not_zero(a, state, n_randint(state, 80) + 1, 100);
|
||||
fmpz_poly_set_coeff_si(a, 0, n_randint(state, 2) ? 1 : -1);
|
||||
|
||||
fmpz_poly_set_ui(one, 1);
|
||||
|
||||
fmpz_poly_inv_series_newton(b, a, n);
|
||||
fmpz_poly_mullow(c, a, b, n);
|
||||
|
||||
result = (fmpz_poly_equal(c, one));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("c = "), fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(one);
|
||||
}
|
||||
|
||||
/* Verify bug fix for the case Q = -1 mod (x) */
|
||||
{
|
||||
fmpz_poly_t a, b, c, one;
|
||||
slong n = 1;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(one);
|
||||
|
||||
fmpz_poly_set_si(a, -1);
|
||||
fmpz_poly_set_ui(one, 1);
|
||||
|
||||
fmpz_poly_inv_series_newton(b, a, n);
|
||||
fmpz_poly_mullow(c, a, b, n);
|
||||
|
||||
result = (fmpz_poly_equal(c, one));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("c = "), fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(one);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
135
external/flint-2.4.3/fmpz_poly/test/t-is_squarefree.c
vendored
Normal file
135
external/flint-2.4.3/fmpz_poly/test/t-is_squarefree.c
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("is_squarefree....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check that polynomials of degree <= 1 are square-free */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 2), 100);
|
||||
|
||||
result = (fmpz_poly_is_squarefree(f));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_debug(f), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
}
|
||||
|
||||
/* Check that a^2 f is not square-free */
|
||||
for (i = 0; i < 20 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, f;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_randtest_not_zero(a, state, n_randint(state, 20) + 1, 40);
|
||||
if (a->length < 2)
|
||||
{
|
||||
fmpz_poly_clear(a);
|
||||
continue;
|
||||
}
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_randtest_not_zero(f, state, n_randint(state, 20) + 1, 40);
|
||||
|
||||
fmpz_poly_mul(a, a, a);
|
||||
fmpz_poly_mul(f, a, f);
|
||||
|
||||
result = (!fmpz_poly_is_squarefree(f));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_debug(f), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(f);
|
||||
}
|
||||
|
||||
/* Check that f + N*(x^M + 1) is square-free, for N >> f, M > deg(f) */
|
||||
for (i = 0; i < 20 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, f;
|
||||
fmpz_t N;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_set_coeff_si(a, 0, WORD(1));
|
||||
fmpz_poly_set_coeff_si(a, n_randint(state, 20), WORD(1));
|
||||
if (a->length < 2)
|
||||
{
|
||||
fmpz_poly_clear(a);
|
||||
continue;
|
||||
}
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_randtest(f, state, a->length - 2, 40);
|
||||
|
||||
fmpz_init_set_ui(N, UWORD(1));
|
||||
fmpz_mul_2exp(N, N, 45 + a->length);
|
||||
|
||||
fmpz_poly_scalar_mul_fmpz(a, a, N);
|
||||
fmpz_poly_add(f, a, f);
|
||||
|
||||
result = fmpz_poly_is_squarefree(f);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_debug(f), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_clear(N);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
152
external/flint-2.4.3/fmpz_poly/test/t-lcm.c
vendored
Normal file
152
external/flint-2.4.3/fmpz_poly/test/t-lcm.c
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010, 2011 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("lcm....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 40), 80);
|
||||
|
||||
fmpz_poly_lcm(a, b, c);
|
||||
fmpz_poly_lcm(b, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing a and b):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 40), 80);
|
||||
|
||||
fmpz_poly_lcm(a, b, c);
|
||||
fmpz_poly_lcm(c, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing a and c):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check that GCD(f, g) LCM(f, g) == f g */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, gcd, lcm, lhs, rhs;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(gcd);
|
||||
fmpz_poly_init(lcm);
|
||||
fmpz_poly_init(lhs);
|
||||
fmpz_poly_init(rhs);
|
||||
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 40), 80);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 40), 80);
|
||||
|
||||
fmpz_poly_gcd(gcd, f, g);
|
||||
fmpz_poly_lcm(lcm, f, g);
|
||||
fmpz_poly_mul(lhs, gcd, lcm);
|
||||
fmpz_poly_mul(rhs, f, g);
|
||||
if (!fmpz_poly_is_zero(rhs) && fmpz_sgn(fmpz_poly_lead(rhs)) < 0)
|
||||
fmpz_poly_neg(rhs, rhs);
|
||||
|
||||
result = (fmpz_poly_equal(lhs, rhs));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (GCD(f, g) * LCM(f, g) == f * g):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n");
|
||||
fmpz_poly_print(g), flint_printf("\n");
|
||||
fmpz_poly_print(gcd), flint_printf("\n");
|
||||
fmpz_poly_print(lcm), flint_printf("\n");
|
||||
fmpz_poly_print(lhs), flint_printf("\n");
|
||||
fmpz_poly_print(rhs), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(gcd);
|
||||
fmpz_poly_clear(lcm);
|
||||
fmpz_poly_clear(lhs);
|
||||
fmpz_poly_clear(rhs);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
188
external/flint-2.4.3/fmpz_poly/test/t-mul.c
vendored
Normal file
188
external/flint-2.4.3/fmpz_poly/test/t-mul.c
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mul....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 500);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 500);
|
||||
|
||||
fmpz_poly_mul(a, b, c);
|
||||
fmpz_poly_mul(b, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 500);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 500);
|
||||
|
||||
fmpz_poly_mul(a, b, c);
|
||||
fmpz_poly_mul(c, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check (b*c)+(b*d) = b*(c+d) */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a1, a2, b, c, d;
|
||||
|
||||
fmpz_poly_init(a1);
|
||||
fmpz_poly_init(a2);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 100), 500);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 100), 500);
|
||||
fmpz_poly_randtest(d, state, n_randint(state, 100), 500);
|
||||
|
||||
fmpz_poly_mul(a1, b, c);
|
||||
fmpz_poly_mul(a2, b, d);
|
||||
fmpz_poly_add(a1, a1, a2);
|
||||
|
||||
fmpz_poly_add(c, c, d);
|
||||
fmpz_poly_mul(a2, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a1, a2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a1), flint_printf("\n\n");
|
||||
fmpz_poly_print(a2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a1);
|
||||
fmpz_poly_clear(a2);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
/* Check _fmpz_poly_mul directly */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
slong len1, len2;
|
||||
fmpz_poly_t a, b, out1, out2;
|
||||
|
||||
len1 = n_randint(state, 100) + 1;
|
||||
len2 = n_randint(state, 100) + 1;
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(out1);
|
||||
fmpz_poly_init(out2);
|
||||
fmpz_poly_randtest(a, state, len1, 200);
|
||||
fmpz_poly_randtest(b, state, len2, 200);
|
||||
|
||||
fmpz_poly_mul(out1, a, b);
|
||||
fmpz_poly_fit_length(a, a->alloc + n_randint(state, 10));
|
||||
fmpz_poly_fit_length(b, b->alloc + n_randint(state, 10));
|
||||
a->length = a->alloc;
|
||||
b->length = b->alloc;
|
||||
fmpz_poly_fit_length(out2, a->length + b->length - 1);
|
||||
if (a->length >= b->length)
|
||||
_fmpz_poly_mul(out2->coeffs, a->coeffs, a->length,
|
||||
b->coeffs, b->length);
|
||||
else
|
||||
_fmpz_poly_mul(out2->coeffs, b->coeffs, b->length,
|
||||
a->coeffs, a->length);
|
||||
_fmpz_poly_set_length(out2, a->length + b->length - 1);
|
||||
_fmpz_poly_normalise(out2);
|
||||
|
||||
result = (fmpz_poly_equal(out1, out2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(out1), flint_printf("\n\n");
|
||||
fmpz_poly_print(out2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(out1);
|
||||
fmpz_poly_clear(out2);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
234
external/flint-2.4.3/fmpz_poly/test/t-mul_KS.c
vendored
Normal file
234
external/flint-2.4.3/fmpz_poly/test/t-mul_KS.c
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mul_KS....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_mul_KS(a, b, c);
|
||||
fmpz_poly_mul_KS(b, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
fmpz_poly_mul_KS(a, b, c);
|
||||
fmpz_poly_mul_KS(c, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of b and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_set(c, b);
|
||||
|
||||
fmpz_poly_mul_KS(a, b, b);
|
||||
fmpz_poly_mul_KS(c, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Compare with mul_classical */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
fmpz_poly_mul_KS(a, b, c);
|
||||
fmpz_poly_mul_classical(d, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
/* Compare with mul_classical unsigned */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest_unsigned(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest_unsigned(c, state, n_randint(state, 50), 200);
|
||||
|
||||
fmpz_poly_mul_KS(a, b, c);
|
||||
fmpz_poly_mul_classical(d, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
/* Check _fmpz_poly_mul_KS directly */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
slong len1, len2;
|
||||
fmpz_poly_t a, b, out1, out2;
|
||||
|
||||
len1 = n_randint(state, 100) + 1;
|
||||
len2 = n_randint(state, 100) + 1;
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(out1);
|
||||
fmpz_poly_init(out2);
|
||||
fmpz_poly_randtest(a, state, len1, 200);
|
||||
fmpz_poly_randtest(b, state, len2, 200);
|
||||
|
||||
fmpz_poly_mul_KS(out1, a, b);
|
||||
fmpz_poly_fit_length(a, a->alloc + n_randint(state, 10));
|
||||
fmpz_poly_fit_length(b, b->alloc + n_randint(state, 10));
|
||||
a->length = a->alloc;
|
||||
b->length = b->alloc;
|
||||
fmpz_poly_fit_length(out2, a->length + b->length - 1);
|
||||
_fmpz_poly_mul_KS(out2->coeffs, a->coeffs, a->length,
|
||||
b->coeffs, b->length);
|
||||
_fmpz_poly_set_length(out2, a->length + b->length - 1);
|
||||
_fmpz_poly_normalise(out2);
|
||||
|
||||
result = (fmpz_poly_equal(out1, out2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(out1), flint_printf("\n\n");
|
||||
fmpz_poly_print(out2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(out1);
|
||||
fmpz_poly_clear(out2);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
223
external/flint-2.4.3/fmpz_poly/test/t-mul_SS.c
vendored
Normal file
223
external/flint-2.4.3/fmpz_poly/test/t-mul_SS.c
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009, 2011 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mul_SS....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_mul_SS(a, b, c);
|
||||
fmpz_poly_mul_SS(b, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
fmpz_poly_mul_SS(a, b, c);
|
||||
fmpz_poly_mul_SS(c, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of b and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_set(c, b);
|
||||
|
||||
fmpz_poly_mul_SS(a, b, b);
|
||||
fmpz_poly_mul_SS(c, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Compare with mul_KS */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 300), n_randint(state, 500) + 1);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 300), n_randint(state, 500) + 1);
|
||||
|
||||
fmpz_poly_mul_SS(a, b, c);
|
||||
fmpz_poly_mul_KS(d, b, c);
|
||||
|
||||
result = fmpz_poly_equal(a, d);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
/* Compare with mul_KS large */
|
||||
for (i = 0; i < 40 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 300), n_randint(state, 20000) + 1);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 300), n_randint(state, 20000) + 1);
|
||||
|
||||
fmpz_poly_mul_SS(a, b, c);
|
||||
fmpz_poly_mul_KS(d, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
/* Compare with mul_KS unsigned */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest_unsigned(b, state, n_randint(state, 300), n_randint(state, 500) + 1);
|
||||
fmpz_poly_randtest_unsigned(c, state, n_randint(state, 300), n_randint(state, 500) + 1);
|
||||
|
||||
fmpz_poly_mul_SS(a, b, c);
|
||||
fmpz_poly_mul_KS(d, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
184
external/flint-2.4.3/fmpz_poly/test/t-mul_classical.c
vendored
Normal file
184
external/flint-2.4.3/fmpz_poly/test/t-mul_classical.c
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mul_classical....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
fmpz_poly_mul_classical(a, b, c);
|
||||
fmpz_poly_mul_classical(b, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
fmpz_poly_mul_classical(a, b, c);
|
||||
fmpz_poly_mul_classical(c, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check (b*c)+(b*d) = b*(c+d) */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a1, a2, b, c, d;
|
||||
|
||||
fmpz_poly_init(a1);
|
||||
fmpz_poly_init(a2);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest(d, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_mul_classical(a1, b, c);
|
||||
fmpz_poly_mul_classical(a2, b, d);
|
||||
fmpz_poly_add(a1, a1, a2);
|
||||
|
||||
fmpz_poly_add(c, c, d);
|
||||
fmpz_poly_mul_classical(a2, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a1, a2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a1), flint_printf("\n\n");
|
||||
fmpz_poly_print(a2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a1);
|
||||
fmpz_poly_clear(a2);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
/* Check _fmpz_poly_mul_classical directly */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
slong len1, len2;
|
||||
fmpz_poly_t a, b, out1, out2;
|
||||
|
||||
len1 = n_randint(state, 100) + 1;
|
||||
len2 = n_randint(state, 100) + 1;
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(out1);
|
||||
fmpz_poly_init(out2);
|
||||
fmpz_poly_randtest(a, state, len1, 200);
|
||||
fmpz_poly_randtest(b, state, len2, 200);
|
||||
|
||||
fmpz_poly_mul_classical(out1, a, b);
|
||||
fmpz_poly_fit_length(a, a->alloc + n_randint(state, 10));
|
||||
fmpz_poly_fit_length(b, b->alloc + n_randint(state, 10));
|
||||
a->length = a->alloc;
|
||||
b->length = b->alloc;
|
||||
fmpz_poly_fit_length(out2, a->length + b->length - 1);
|
||||
_fmpz_poly_mul_classical(out2->coeffs, a->coeffs, a->length,
|
||||
b->coeffs, b->length);
|
||||
_fmpz_poly_set_length(out2, a->length + b->length - 1);
|
||||
_fmpz_poly_normalise(out2);
|
||||
|
||||
result = (fmpz_poly_equal(out1, out2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(out1), flint_printf("\n\n");
|
||||
fmpz_poly_print(out2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(out1);
|
||||
fmpz_poly_clear(out2);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
181
external/flint-2.4.3/fmpz_poly/test/t-mul_karatsuba.c
vendored
Normal file
181
external/flint-2.4.3/fmpz_poly/test/t-mul_karatsuba.c
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mul_karatsuba....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
fmpz_poly_mul_karatsuba(a, b, c);
|
||||
fmpz_poly_mul_karatsuba(b, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
fmpz_poly_mul_karatsuba(a, b, c);
|
||||
fmpz_poly_mul_karatsuba(c, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Compare with mul_classical */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
fmpz_poly_mul_karatsuba(a, b, c);
|
||||
fmpz_poly_mul_classical(d, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
/* Check _fmpz_poly_mul_karatsuba directly */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
slong len1, len2;
|
||||
fmpz_poly_t a, b, out1, out2;
|
||||
|
||||
len1 = n_randint(state, 100) + 1;
|
||||
len2 = n_randint(state, 100) + 1;
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(out1);
|
||||
fmpz_poly_init(out2);
|
||||
fmpz_poly_randtest(a, state, len1, 200);
|
||||
fmpz_poly_randtest(b, state, len2, 200);
|
||||
|
||||
fmpz_poly_mul_karatsuba(out1, a, b);
|
||||
fmpz_poly_fit_length(a, a->alloc + n_randint(state, 10));
|
||||
fmpz_poly_fit_length(b, b->alloc + n_randint(state, 10));
|
||||
a->length = a->alloc;
|
||||
b->length = b->alloc;
|
||||
fmpz_poly_fit_length(out2, a->length + b->length - 1);
|
||||
if (a->length >= b->length)
|
||||
_fmpz_poly_mul_karatsuba(out2->coeffs, a->coeffs, a->length,
|
||||
b->coeffs, b->length);
|
||||
else
|
||||
_fmpz_poly_mul_karatsuba(out2->coeffs, b->coeffs, b->length,
|
||||
a->coeffs, a->length);
|
||||
_fmpz_poly_set_length(out2, a->length + b->length - 1);
|
||||
_fmpz_poly_normalise(out2);
|
||||
|
||||
result = (fmpz_poly_equal(out1, out2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(out1), flint_printf("\n\n");
|
||||
fmpz_poly_print(out2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(out1);
|
||||
fmpz_poly_clear(out2);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
150
external/flint-2.4.3/fmpz_poly/test/t-mulhigh_classical.c
vendored
Normal file
150
external/flint-2.4.3/fmpz_poly/test/t-mulhigh_classical.c
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_vec.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mulhigh_classical....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong len, start;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
len = b->length + c->length - 1;
|
||||
start = (len <= 0) ? 0 : n_randint(state, b->length + c->length);
|
||||
|
||||
fmpz_poly_mulhigh_classical(a, b, c, start);
|
||||
fmpz_poly_mulhigh_classical(b, b, c, start);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong len, start;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
len = b->length + c->length - 1;
|
||||
start = (len <= 0) ? 0 : n_randint(state, b->length + c->length - 1);
|
||||
|
||||
fmpz_poly_mulhigh_classical(a, b, c, start);
|
||||
fmpz_poly_mulhigh_classical(c, b, c, start);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Compare with mul_basecase */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
slong len, start;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
len = b->length + c->length - 1;
|
||||
start = (len <= 0) ? 0 : n_randint(state, b->length + c->length - 1);
|
||||
|
||||
fmpz_poly_mul_classical(a, b, c);
|
||||
if (a->length >= start)
|
||||
_fmpz_vec_zero(a->coeffs, start);
|
||||
fmpz_poly_mulhigh_classical(d, b, c, start);
|
||||
|
||||
result = (fmpz_poly_equal(a, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
145
external/flint-2.4.3/fmpz_poly/test/t-mulhigh_karatsuba_n.c
vendored
Normal file
145
external/flint-2.4.3/fmpz_poly/test/t-mulhigh_karatsuba_n.c
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_vec.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mulhigh_karatsuba_n....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong len;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
len = n_randint(state, 50);
|
||||
fmpz_poly_randtest(b, state, len, 200);
|
||||
fmpz_poly_randtest(c, state, len, 200);
|
||||
|
||||
fmpz_poly_mulhigh_karatsuba_n(a, b, c, len);
|
||||
fmpz_poly_mulhigh_karatsuba_n(b, b, c, len);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong len;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
len = n_randint(state, 50);
|
||||
fmpz_poly_randtest(b, state, len, 200);
|
||||
fmpz_poly_randtest(c, state, len, 200);
|
||||
|
||||
fmpz_poly_mulhigh_karatsuba_n(a, b, c, len);
|
||||
fmpz_poly_mulhigh_karatsuba_n(c, b, c, len);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Compare with mul_basecase */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
slong len;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
len = n_randint(state, 50);
|
||||
fmpz_poly_randtest(b, state, len, 200);
|
||||
fmpz_poly_randtest(c, state, len, 200);
|
||||
|
||||
fmpz_poly_mul_classical(a, b, c);
|
||||
if (len)
|
||||
_fmpz_vec_zero(a->coeffs, FLINT_MIN(len - 1, a->length));
|
||||
_fmpz_poly_normalise(a);
|
||||
fmpz_poly_mulhigh_karatsuba_n(d, b, c, len);
|
||||
|
||||
result = (fmpz_poly_equal(a, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
88
external/flint-2.4.3/fmpz_poly/test/t-mulhigh_n.c
vendored
Normal file
88
external/flint-2.4.3/fmpz_poly/test/t-mulhigh_n.c
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mulhigh_n....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with left truncated product of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong j, n;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
n = n_randint(state, 50);
|
||||
fmpz_poly_randtest(b, state, n, 200);
|
||||
fmpz_poly_randtest(c, state, n, 200);
|
||||
|
||||
fmpz_poly_mulhigh_n(a, b, c, n);
|
||||
fmpz_poly_mul(b, b, c);
|
||||
for (j = 0; j + 1 < n; j++)
|
||||
{
|
||||
if (j < a->length)
|
||||
fmpz_zero(a->coeffs + j);
|
||||
if (j < b->length)
|
||||
fmpz_zero(b->coeffs + j);
|
||||
}
|
||||
_fmpz_poly_normalise(a);
|
||||
_fmpz_poly_normalise(b);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
80
external/flint-2.4.3/fmpz_poly/test/t-mullow.c
vendored
Normal file
80
external/flint-2.4.3/fmpz_poly/test/t-mullow.c
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mullow....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with truncated product of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong trunc;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
trunc = n_randint(state, 50);
|
||||
fmpz_poly_randtest(b, state, trunc, 200);
|
||||
fmpz_poly_randtest(c, state, trunc, 200);
|
||||
|
||||
fmpz_poly_mullow(a, b, c, trunc);
|
||||
fmpz_poly_mul(b, b, c);
|
||||
fmpz_poly_truncate(b, trunc);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
149
external/flint-2.4.3/fmpz_poly/test/t-mullow_KS.c
vendored
Normal file
149
external/flint-2.4.3/fmpz_poly/test/t-mullow_KS.c
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mullow_KS....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong len, trunc;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
len = b->length + c->length - 1;
|
||||
trunc = (len <= 0) ? 0 : n_randint(state, b->length + c->length);
|
||||
|
||||
fmpz_poly_mullow_KS(a, b, c, trunc);
|
||||
fmpz_poly_mullow_KS(b, b, c, trunc);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong len;
|
||||
ulong trunc;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
len = b->length + c->length - 1;
|
||||
trunc = (len <= 0) ? 0 : n_randint(state, b->length + c->length - 1);
|
||||
|
||||
fmpz_poly_mullow_KS(a, b, c, trunc);
|
||||
fmpz_poly_mullow_KS(c, b, c, trunc);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Compare with mul_basecase */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
slong len, trunc;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
len = b->length + c->length - 1;
|
||||
trunc = (len <= 0) ? 0 : n_randint(state, b->length + c->length - 1);
|
||||
|
||||
fmpz_poly_mul_KS(a, b, c);
|
||||
fmpz_poly_truncate(a, trunc);
|
||||
fmpz_poly_mullow_KS(d, b, c, trunc);
|
||||
|
||||
result = (fmpz_poly_equal(a, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
149
external/flint-2.4.3/fmpz_poly/test/t-mullow_SS.c
vendored
Normal file
149
external/flint-2.4.3/fmpz_poly/test/t-mullow_SS.c
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mullow_SS....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong len, trunc;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
len = b->length + c->length - 1;
|
||||
trunc = (len <= 0) ? 0 : n_randint(state, b->length + c->length);
|
||||
|
||||
fmpz_poly_mullow_SS(a, b, c, trunc);
|
||||
fmpz_poly_mullow_SS(b, b, c, trunc);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong len;
|
||||
ulong trunc;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
len = b->length + c->length - 1;
|
||||
trunc = (len <= 0) ? 0 : n_randint(state, b->length + c->length - 1);
|
||||
|
||||
fmpz_poly_mullow_SS(a, b, c, trunc);
|
||||
fmpz_poly_mullow_SS(c, b, c, trunc);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Compare with mul_KS */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
slong len, trunc;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
len = b->length + c->length - 1;
|
||||
trunc = (len <= 0) ? 0 : n_randint(state, b->length + c->length - 1);
|
||||
|
||||
fmpz_poly_mul_KS(a, b, c);
|
||||
fmpz_poly_truncate(a, trunc);
|
||||
fmpz_poly_mullow_SS(d, b, c, trunc);
|
||||
|
||||
result = (fmpz_poly_equal(a, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
149
external/flint-2.4.3/fmpz_poly/test/t-mullow_classical.c
vendored
Normal file
149
external/flint-2.4.3/fmpz_poly/test/t-mullow_classical.c
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mullow_classical....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong len, trunc;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
len = b->length + c->length - 1;
|
||||
trunc = (len <= 0) ? 0 : n_randint(state, b->length + c->length);
|
||||
|
||||
fmpz_poly_mullow_classical(a, b, c, trunc);
|
||||
fmpz_poly_mullow_classical(b, b, c, trunc);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong len;
|
||||
ulong trunc;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
len = b->length + c->length - 1;
|
||||
trunc = (len <= 0) ? 0 : n_randint(state, b->length + c->length - 1);
|
||||
|
||||
fmpz_poly_mullow_classical(a, b, c, trunc);
|
||||
fmpz_poly_mullow_classical(c, b, c, trunc);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Compare with mul_basecase */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
slong len, trunc;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, 50), 200);
|
||||
|
||||
len = b->length + c->length - 1;
|
||||
trunc = (len <= 0) ? 0 : n_randint(state, b->length + c->length - 1);
|
||||
|
||||
fmpz_poly_mul_classical(a, b, c);
|
||||
fmpz_poly_truncate(a, trunc);
|
||||
fmpz_poly_mullow_classical(d, b, c, trunc);
|
||||
|
||||
result = (fmpz_poly_equal(a, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
143
external/flint-2.4.3/fmpz_poly/test/t-mullow_karatsuba_n.c
vendored
Normal file
143
external/flint-2.4.3/fmpz_poly/test/t-mullow_karatsuba_n.c
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
|
||||
flint_printf("mullow_karatsuba_n....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong len;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
len = n_randint(state, 50);
|
||||
fmpz_poly_randtest(b, state, len, 200);
|
||||
fmpz_poly_randtest(c, state, len, 200);
|
||||
|
||||
fmpz_poly_mullow_karatsuba_n(a, b, c, len);
|
||||
fmpz_poly_mullow_karatsuba_n(b, b, c, len);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong len;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
len = n_randint(state, 50);
|
||||
fmpz_poly_randtest(b, state, len, 200);
|
||||
fmpz_poly_randtest(c, state, len, 200);
|
||||
|
||||
fmpz_poly_mullow_karatsuba_n(a, b, c, len);
|
||||
fmpz_poly_mullow_karatsuba_n(c, b, c, len);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Compare with mul_karatsuba */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
slong len;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
len = n_randint(state, 50);
|
||||
fmpz_poly_randtest(b, state, len, 200);
|
||||
fmpz_poly_randtest(c, state, len, 200);
|
||||
|
||||
fmpz_poly_mullow_karatsuba_n(a, b, c, len);
|
||||
fmpz_poly_mul_karatsuba(d, b, c);
|
||||
fmpz_poly_truncate(d, len);
|
||||
|
||||
result = (fmpz_poly_equal(a, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
152
external/flint-2.4.3/fmpz_poly/test/t-mulmid_classical.c
vendored
Normal file
152
external/flint-2.4.3/fmpz_poly/test/t-mulmid_classical.c
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mulmid_classical....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
if (b->length == 0)
|
||||
fmpz_poly_zero(c);
|
||||
else
|
||||
fmpz_poly_randtest(c, state, n_randint(state, b->length), 200);
|
||||
|
||||
fmpz_poly_mulmid_classical(a, b, c);
|
||||
fmpz_poly_mulmid_classical(b, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check aliasing of a and c */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
if (b->length == 0)
|
||||
fmpz_poly_zero(c);
|
||||
else
|
||||
fmpz_poly_randtest(c, state, n_randint(state, b->length), 200);
|
||||
|
||||
fmpz_poly_mulmid_classical(a, b, c);
|
||||
fmpz_poly_mulmid_classical(c, b, c);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Compare with mul_basecase */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c, d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(d);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), 200);
|
||||
fmpz_poly_randtest(c, state, n_randint(state, b->length + 1), 200);
|
||||
|
||||
fmpz_poly_mulmid_classical(d, b, c);
|
||||
if (b->length == 0 || c->length == 0)
|
||||
{
|
||||
result = (d->length == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_poly_mul_classical(a, b, c);
|
||||
fmpz_poly_truncate(a, b->length);
|
||||
fmpz_poly_shift_right(a, a, c->length - 1);
|
||||
result = (fmpz_poly_equal(a, d));
|
||||
}
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("c = "), fmpz_poly_print(c), flint_printf("\n\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("d = "), fmpz_poly_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(d);
|
||||
}
|
||||
|
||||
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
76
external/flint-2.4.3/fmpz_poly/test/t-neg.c
vendored
Normal file
76
external/flint-2.4.3/fmpz_poly/test/t-neg.c
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("neg....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_neg(b, a);
|
||||
fmpz_poly_neg(c, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
85
external/flint-2.4.3/fmpz_poly/test/t-newton_to_monomial.c
vendored
Normal file
85
external/flint-2.4.3/fmpz_poly/test/t-newton_to_monomial.c
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2012 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("newton_to_monomial....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g;
|
||||
fmpz * r;
|
||||
slong k, n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
|
||||
fmpz_poly_randtest(f, state, 1 + n_randint(state, 20),
|
||||
1 + n_randint(state, 200));
|
||||
|
||||
n = fmpz_poly_length(f);
|
||||
r = _fmpz_vec_init(n);
|
||||
|
||||
for (k = 0; k < n; k++)
|
||||
fmpz_randtest(r + k, state, n_randint(state, 200));
|
||||
|
||||
fmpz_poly_set(g, f);
|
||||
|
||||
_fmpz_poly_newton_to_monomial(g->coeffs, r, n);
|
||||
_fmpz_poly_monomial_to_newton(g->coeffs, r, n);
|
||||
|
||||
if (!fmpz_poly_equal(f, g))
|
||||
{
|
||||
flint_printf("FAIL: roundtrip\n");
|
||||
fmpz_poly_print(f); flint_printf("\n");
|
||||
fmpz_poly_print(g); flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
_fmpz_vec_clear(r, n);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
122
external/flint-2.4.3/fmpz_poly/test/t-pow.c
vendored
Normal file
122
external/flint-2.4.3/fmpz_poly/test/t-pow.c
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("pow....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
ulong exp;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 10), 100);
|
||||
|
||||
exp = n_randtest(state) % UWORD(20);
|
||||
|
||||
fmpz_poly_pow(a, b, exp);
|
||||
fmpz_poly_pow(b, b, exp);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("exp = %wu\n", exp);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Compare with repeated multiplications by the case */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
ulong exp;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 10), 100);
|
||||
|
||||
exp = n_randtest(state) % UWORD(20);
|
||||
|
||||
fmpz_poly_pow(a, b, exp);
|
||||
|
||||
if (exp == UWORD(0))
|
||||
{
|
||||
fmpz_poly_set_ui(c, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ulong j;
|
||||
fmpz_poly_set(c, b);
|
||||
|
||||
for (j = 1; j < exp; j++)
|
||||
fmpz_poly_mul(c, c, b);
|
||||
}
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("exp = %wu\n", exp);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("c = "), fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
110
external/flint-2.4.3/fmpz_poly/test/t-pow_addchains.c
vendored
Normal file
110
external/flint-2.4.3/fmpz_poly/test/t-pow_addchains.c
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
|
||||
flint_printf("pow_addchains....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
ulong exp;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 10), 100);
|
||||
|
||||
exp = n_randtest(state) % UWORD(20);
|
||||
|
||||
fmpz_poly_pow_addchains(a, b, exp);
|
||||
fmpz_poly_pow_addchains(b, b, exp);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("exp = %wu\n", exp);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Compare with fmpz_poly_pow */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
ulong exp;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 10), 100);
|
||||
|
||||
for (exp = UWORD(0); exp < UWORD(149); exp++)
|
||||
{
|
||||
fmpz_poly_pow_addchains(a, b, exp);
|
||||
fmpz_poly_pow(b, b, exp);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("exp = %wu\n", exp);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
108
external/flint-2.4.3/fmpz_poly/test/t-pow_binexp.c
vendored
Normal file
108
external/flint-2.4.3/fmpz_poly/test/t-pow_binexp.c
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("pow_binexp....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
ulong exp;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 10), 100);
|
||||
|
||||
exp = n_randtest(state) % UWORD(20);
|
||||
|
||||
fmpz_poly_pow_binexp(a, b, exp);
|
||||
fmpz_poly_pow_binexp(b, b, exp);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL(1):\n");
|
||||
flint_printf("exp = %wu\n", exp);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Compare with fmpz_poly_pow */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
ulong exp;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 10), 100);
|
||||
|
||||
exp = n_randtest(state) % UWORD(20);
|
||||
|
||||
fmpz_poly_pow_binexp(a, b, exp);
|
||||
fmpz_poly_pow(b, b, exp);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL(2):\n");
|
||||
flint_printf("exp = %wu\n", exp);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
114
external/flint-2.4.3/fmpz_poly/test/t-pow_binomial.c
vendored
Normal file
114
external/flint-2.4.3/fmpz_poly/test/t-pow_binomial.c
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("pow_binomial....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
ulong exp;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init2(b, 2);
|
||||
|
||||
fmpz_randtest(b->coeffs, state, 100);
|
||||
fmpz_randtest_not_zero(b->coeffs + 1, state, 100);
|
||||
_fmpz_poly_set_length(b, 2);
|
||||
|
||||
exp = n_randtest(state) % UWORD(100);
|
||||
|
||||
fmpz_poly_pow_binomial(a, b, exp);
|
||||
fmpz_poly_pow_binomial(b, b, exp);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL(1):\n");
|
||||
flint_printf("exp = %wu\n", exp);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Compare with fmpz_poly_pow */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
ulong exp;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init2(b, 2);
|
||||
|
||||
fmpz_randtest(b->coeffs, state, 100);
|
||||
fmpz_randtest_not_zero(b->coeffs + 1, state, 100);
|
||||
_fmpz_poly_set_length(b, 2);
|
||||
|
||||
exp = n_randtest(state) % UWORD(100);
|
||||
|
||||
fmpz_poly_pow_binomial(a, b, exp);
|
||||
fmpz_poly_pow(b, b, exp);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL(2):\n");
|
||||
flint_printf("exp = %wu\n", exp);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
109
external/flint-2.4.3/fmpz_poly/test/t-pow_multinomial.c
vendored
Normal file
109
external/flint-2.4.3/fmpz_poly/test/t-pow_multinomial.c
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
|
||||
flint_printf("pow_multinomial....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
ulong exp;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 10), 100);
|
||||
|
||||
exp = n_randtest(state) % UWORD(20);
|
||||
|
||||
fmpz_poly_pow_multinomial(a, b, exp);
|
||||
fmpz_poly_pow_multinomial(b, b, exp);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL(1):\n");
|
||||
flint_printf("exp = %wu\n", exp);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Compare with fmpz_poly_pow */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
ulong exp;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 10), 100);
|
||||
|
||||
exp = n_randtest(state) % UWORD(20);
|
||||
|
||||
fmpz_poly_pow_multinomial(a, b, exp);
|
||||
fmpz_poly_pow(b, b, exp);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL(2):\n");
|
||||
flint_printf("exp = %wu\n", exp);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
118
external/flint-2.4.3/fmpz_poly/test/t-pow_trunc.c
vendored
Normal file
118
external/flint-2.4.3/fmpz_poly/test/t-pow_trunc.c
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("pow_trunc....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
slong n;
|
||||
ulong exp;
|
||||
|
||||
n = n_randtest(state) % 10;
|
||||
exp = n_randtest(state) % 100;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 100), n);
|
||||
|
||||
fmpz_poly_pow_trunc(a, b, exp, n);
|
||||
fmpz_poly_pow_trunc(b, b, exp, n);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("n = %wd\n", n);
|
||||
flint_printf("exp = %wu\n", exp);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Compare with powering followed truncating */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong n;
|
||||
ulong exp;
|
||||
|
||||
n = n_randtest(state) % 10;
|
||||
exp = n_randtest(state) % 50;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 50), n);
|
||||
|
||||
fmpz_poly_pow(a, b, exp);
|
||||
fmpz_poly_truncate(a, n);
|
||||
fmpz_poly_pow_trunc(c, b, exp, n);
|
||||
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("n = %wd\n", n);
|
||||
flint_printf("exp = %wu\n", exp);
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("c = "), fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
106
external/flint-2.4.3/fmpz_poly/test/t-primitive_part.c
vendored
Normal file
106
external/flint-2.4.3/fmpz_poly/test/t-primitive_part.c
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("primitive_part....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_primitive_part(f, g);
|
||||
fmpz_poly_primitive_part(g, g);
|
||||
|
||||
result = (fmpz_poly_equal(f, g));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
}
|
||||
|
||||
/* Check that content(f) primitive_part(f) = sgn(lead(f)) f */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g;
|
||||
fmpz_t c;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_init(c);
|
||||
fmpz_poly_randtest_not_zero(f, state, n_randint(state, 100) + 1, 200);
|
||||
|
||||
fmpz_poly_content(c, f);
|
||||
if (fmpz_sgn(f->coeffs + f->length - 1) < 0)
|
||||
fmpz_neg(c, c);
|
||||
fmpz_poly_primitive_part(g, f);
|
||||
fmpz_poly_scalar_mul_fmpz(g, g, c);
|
||||
|
||||
result = (fmpz_poly_equal(f, g));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(c);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
269
external/flint-2.4.3/fmpz_poly/test/t-print_read.c
vendored
Normal file
269
external/flint-2.4.3/fmpz_poly/test/t-print_read.c
vendored
Normal file
@@ -0,0 +1,269 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
|
||||
#if !defined (__WIN32) || defined(__CYGWIN__)
|
||||
|
||||
/*
|
||||
The function fdopen is declared in stdio.h. It is POSIX.1 compliant,
|
||||
but not ANSI compliant. The following line enables compilation with
|
||||
the "-ansi" flag.
|
||||
*/
|
||||
extern FILE * fdopen(int fildes, const char *mode);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i, j, n = 1000, result;
|
||||
|
||||
FILE *in, *out;
|
||||
int fd[2];
|
||||
pid_t childpid;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("print/ read....");
|
||||
fflush(stdout);
|
||||
|
||||
/* Randomise n polynomials, write to and read from a pipe */
|
||||
{
|
||||
fmpz_poly_t *a;
|
||||
|
||||
a = flint_malloc(n * sizeof(fmpz_poly_t));
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
fmpz_poly_init(a[i]);
|
||||
fmpz_poly_randtest(a[i], state, 100, 100);
|
||||
}
|
||||
|
||||
if (pipe(fd))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Failed to set-up the pipe.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if((childpid = fork()) == -1)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Failed to fork the process.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if(childpid == 0) /* Child process */
|
||||
{
|
||||
int r;
|
||||
|
||||
close(fd[0]);
|
||||
out = fdopen(fd[1], "w");
|
||||
if (out == NULL)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Could not open output file at the pipe.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
for (j = 0; j < n; j++)
|
||||
{
|
||||
r = fmpz_poly_fprint(out, a[j]);
|
||||
if ((j < n - 1) && (r > 0))
|
||||
r = flint_fprintf(out, "\n");
|
||||
|
||||
if (r <= 0)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Write error.\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fclose(out);
|
||||
exit(0);
|
||||
}
|
||||
else /* Parent process */
|
||||
{
|
||||
int r;
|
||||
fmpz_poly_t t;
|
||||
|
||||
close(fd[1]);
|
||||
in = fdopen(fd[0], "r");
|
||||
if (in == NULL)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Could not open input file at the pipe.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_init(t);
|
||||
|
||||
i = 0;
|
||||
while (!feof(in))
|
||||
{
|
||||
r = fmpz_poly_fread(in, t);
|
||||
if (r <= 0)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Read error.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
result = fmpz_poly_equal(t, a[i]);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("a[i] = "), fmpz_poly_print(a[i]), flint_printf("\n");
|
||||
flint_printf("t = "), fmpz_poly_print(t), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
fmpz_poly_clear(t);
|
||||
fclose(in);
|
||||
}
|
||||
|
||||
if (i != n)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Only %d out of %d objects were processed.\n", i, n);
|
||||
abort();
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
fmpz_poly_clear(a[i]);
|
||||
flint_free(a);
|
||||
}
|
||||
|
||||
/* Write bad data to a pipe and read it */
|
||||
{
|
||||
char str[5] = {'b', 'l', 'a', 'h', '\0'};
|
||||
|
||||
if (pipe(fd))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Failed to set-up the pipe.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if((childpid = fork()) == -1)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Failed to fork the process.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if(childpid == 0) /* Child process */
|
||||
{
|
||||
int r;
|
||||
|
||||
close(fd[0]);
|
||||
out = fdopen(fd[1], "w");
|
||||
if (out == NULL)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Could not open output file at the pipe.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
r = flint_fprintf(out, "blah");
|
||||
if (r <= 0)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Write error.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fclose(out);
|
||||
exit(0);
|
||||
}
|
||||
else /* Parent process */
|
||||
{
|
||||
int r;
|
||||
fmpz_poly_t t;
|
||||
|
||||
close(fd[1]);
|
||||
in = fdopen(fd[0], "r");
|
||||
if (in == NULL)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Could not open input file at the pipe.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_init(t);
|
||||
|
||||
i = 0;
|
||||
while (!feof(in))
|
||||
{
|
||||
r = fmpz_poly_fread(in, t);
|
||||
if (r > 0)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("r = %d\n", r);
|
||||
abort();
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
fmpz_poly_clear(t);
|
||||
fclose(in);
|
||||
}
|
||||
|
||||
/* For {'b','l','a','h','\0'} we expect 5 reads */
|
||||
if (i != 5)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Carried out %d reads, but \"%s\" has only 4 characters.\n", i, str);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main(void)
|
||||
{
|
||||
flint_printf("print/ read....");
|
||||
fflush(stdout);
|
||||
flint_printf("SKIPPED\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
273
external/flint-2.4.3/fmpz_poly/test/t-print_read_pretty.c
vendored
Normal file
273
external/flint-2.4.3/fmpz_poly/test/t-print_read_pretty.c
vendored
Normal file
@@ -0,0 +1,273 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
|
||||
#if !defined (__WIN32) || defined(__CYGWIN__)
|
||||
|
||||
/*
|
||||
The function fdopen is declared in stdio.h. It is POSIX.1 compliant,
|
||||
but not ANSI compliant. The following line enables compilation with
|
||||
the "-ansi" flag.
|
||||
*/
|
||||
extern FILE * fdopen(int fildes, const char *mode);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i, j, n = 1000, result;
|
||||
|
||||
FILE *in, *out;
|
||||
int fd[2];
|
||||
pid_t childpid;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("print/ read_pretty....");
|
||||
fflush(stdout);
|
||||
|
||||
/* Randomise n polynomials, write to and read from a pipe */
|
||||
{
|
||||
fmpz_poly_t *a;
|
||||
char *var = "x";
|
||||
|
||||
a = flint_malloc(n * sizeof(fmpz_poly_t));
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
fmpz_poly_init(a[i]);
|
||||
fmpz_poly_randtest(a[i], state, 100, 100);
|
||||
}
|
||||
|
||||
if (pipe(fd))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Failed to set-up the pipe.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if((childpid = fork()) == -1)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Failed to fork the process.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if(childpid == 0) /* Child process */
|
||||
{
|
||||
int r;
|
||||
|
||||
close(fd[0]);
|
||||
out = fdopen(fd[1], "w");
|
||||
if (out == NULL)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Could not open output file at the pipe.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
for (j = 0; j < n; j++)
|
||||
{
|
||||
r = fmpz_poly_fprint_pretty(out, a[j], var);
|
||||
if ((j < n - 1) && (r > 0))
|
||||
r = flint_fprintf(out, "\n");
|
||||
|
||||
if (r <= 0)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Write error.\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fclose(out);
|
||||
exit(0);
|
||||
}
|
||||
else /* Parent process */
|
||||
{
|
||||
int r;
|
||||
fmpz_poly_t t;
|
||||
char *rvar;
|
||||
|
||||
close(fd[1]);
|
||||
in = fdopen(fd[0], "r");
|
||||
if (in == NULL)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Could not open input file at the pipe.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_init(t);
|
||||
|
||||
i = 0;
|
||||
while (!feof(in))
|
||||
{
|
||||
r = fmpz_poly_fread_pretty(in, t, &rvar);
|
||||
if (r <= 0)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Read error.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
result = fmpz_poly_equal(t, a[i]) &&
|
||||
(t->length <= 1 || (strcmp(var, rvar) == 0));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("a[i] = "), fmpz_poly_print_pretty(a[i], var), flint_printf("\n");
|
||||
flint_printf("t = "), fmpz_poly_print_pretty(t, rvar), flint_printf("\n");
|
||||
flint_printf("rvar = %s\n", rvar);
|
||||
abort();
|
||||
}
|
||||
flint_free(rvar);
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
fmpz_poly_clear(t);
|
||||
fclose(in);
|
||||
}
|
||||
|
||||
if (i != n)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Only %d out of %d objects were processed.\n", i, n);
|
||||
abort();
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
fmpz_poly_clear(a[i]);
|
||||
flint_free(a);
|
||||
}
|
||||
|
||||
/* Write "blah" to the pipe and see it read as a variable */
|
||||
{
|
||||
char str[5] = {'b', 'l', 'a', 'h', '\0'};
|
||||
|
||||
if (pipe(fd))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Failed to set-up the pipe.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if((childpid = fork()) == -1)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Failed to fork the process.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if(childpid == 0) /* Child process */
|
||||
{
|
||||
int r;
|
||||
|
||||
close(fd[0]);
|
||||
out = fdopen(fd[1], "w");
|
||||
if (out == NULL)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Could not open output file at the pipe.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
r = fputs(str, out);
|
||||
if (r == EOF)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Write error.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fclose(out);
|
||||
exit(0);
|
||||
}
|
||||
else /* Parent process */
|
||||
{
|
||||
char *rvar = NULL;
|
||||
int r;
|
||||
fmpz_poly_t t;
|
||||
|
||||
close(fd[1]);
|
||||
in = fdopen(fd[0], "r");
|
||||
if (in == NULL)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("Could not open input file at the pipe.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_init(t);
|
||||
|
||||
while (!feof(in))
|
||||
{
|
||||
r = fmpz_poly_fread_pretty(in, t, &rvar);
|
||||
result = (r > 0) && rvar && (strcmp(str, rvar) == 0) &&
|
||||
(t->length == 2) && (t->coeffs[0] == WORD(0)) &&
|
||||
(t->coeffs[1] == WORD(1));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("r = %d\n", r);
|
||||
flint_printf("str = {%s}\n", str);
|
||||
flint_printf("rvar = {%s}\n", rvar);
|
||||
flint_printf("t = "), fmpz_poly_print(t), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
if (rvar)
|
||||
flint_free(rvar);
|
||||
}
|
||||
|
||||
fmpz_poly_clear(t);
|
||||
fclose(in);
|
||||
}
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main(void)
|
||||
{
|
||||
flint_printf("print/ read....");
|
||||
fflush(stdout);
|
||||
flint_printf("SKIPPED\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
92
external/flint-2.4.3/fmpz_poly/test/t-product_roots_fmpz_vec.c
vendored
Normal file
92
external/flint-2.4.3/fmpz_poly/test/t-product_roots_fmpz_vec.c
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("product_roots_fmpz_vec....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t P, Q, tmp;
|
||||
fmpz * x;
|
||||
slong j, n, bits;
|
||||
|
||||
n = n_randint(state, 100);
|
||||
bits = n_randint(state, 10);
|
||||
|
||||
x = _fmpz_vec_init(n);
|
||||
_fmpz_vec_randtest(x, state, n, bits);
|
||||
|
||||
fmpz_poly_init(P);
|
||||
fmpz_poly_init(Q);
|
||||
fmpz_poly_init(tmp);
|
||||
|
||||
fmpz_poly_product_roots_fmpz_vec(P, x, n);
|
||||
|
||||
fmpz_poly_set_ui(Q, UWORD(1));
|
||||
for (j = 0; j < n; j++)
|
||||
{
|
||||
fmpz_poly_zero(tmp);
|
||||
fmpz_poly_set_coeff_si(tmp, 1, WORD(-1));
|
||||
fmpz_poly_set_coeff_fmpz(tmp, 0, x + j);
|
||||
fmpz_poly_neg(tmp, tmp);
|
||||
fmpz_poly_mul(Q, Q, tmp);
|
||||
}
|
||||
|
||||
result = (fmpz_poly_equal(P, Q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (P != Q):\n");
|
||||
fmpz_poly_print(P), flint_printf("\n\n");
|
||||
fmpz_poly_print(Q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(P);
|
||||
fmpz_poly_clear(Q);
|
||||
fmpz_poly_clear(tmp);
|
||||
_fmpz_vec_clear(x, n);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
147
external/flint-2.4.3/fmpz_poly/test/t-pseudo_div.c
vendored
Normal file
147
external/flint-2.4.3/fmpz_poly/test/t-pseudo_div.c
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("pseudo_div....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check r = a - q * b has small degree, no aliasing */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r, prod;
|
||||
fmpz_t p;
|
||||
ulong d;
|
||||
|
||||
fmpz_init(p);
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(prod);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_div(q, &d, a, b);
|
||||
fmpz_poly_mul(prod, q, b);
|
||||
fmpz_pow_ui(p, b->coeffs + b->length - 1, d);
|
||||
fmpz_poly_scalar_mul_fmpz(a, a, p);
|
||||
fmpz_poly_sub(r, a, prod);
|
||||
|
||||
result = (fmpz_poly_length(r) < fmpz_poly_length(b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(prod), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(p);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(prod);
|
||||
}
|
||||
|
||||
/* Check q and a alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q;
|
||||
ulong d;
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_div(q, &d, a, b);
|
||||
fmpz_poly_pseudo_div(a, &d, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
/* Check q and b alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q;
|
||||
ulong d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_div(q, &d, a, b);
|
||||
fmpz_poly_pseudo_div(b, &d, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
217
external/flint-2.4.3/fmpz_poly/test/t-pseudo_divrem_basecase.c
vendored
Normal file
217
external/flint-2.4.3/fmpz_poly/test/t-pseudo_divrem_basecase.c
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("pseudo_divrem_basecase....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check q*b + r = a, no aliasing */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r, prod;
|
||||
fmpz_t p;
|
||||
ulong d;
|
||||
|
||||
fmpz_init(p);
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(prod);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_divrem_basecase(q, r, &d, a, b);
|
||||
fmpz_poly_mul(prod, q, b);
|
||||
fmpz_poly_add(prod, prod, r);
|
||||
fmpz_pow_ui(p, b->coeffs + b->length - 1, d);
|
||||
fmpz_poly_scalar_mul_fmpz(a, a, p);
|
||||
|
||||
result = (fmpz_poly_equal(a, prod));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(prod), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(p);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(prod);
|
||||
}
|
||||
|
||||
/* Check r and a alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
ulong d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_divrem_basecase(q, r, &d, a, b);
|
||||
fmpz_poly_pseudo_divrem_basecase(q, a, &d, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check r and b alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
ulong d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_divrem_basecase(q, r, &d, a, b);
|
||||
fmpz_poly_pseudo_divrem_basecase(q, b, &d, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check q and a alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
ulong d;
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_divrem_basecase(q, r, &d, a, b);
|
||||
fmpz_poly_pseudo_divrem_basecase(a, r, &d, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check q and b alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
ulong d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_divrem_basecase(q, r, &d, a, b);
|
||||
fmpz_poly_pseudo_divrem_basecase(b, r, &d, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
217
external/flint-2.4.3/fmpz_poly/test/t-pseudo_divrem_cohen.c
vendored
Normal file
217
external/flint-2.4.3/fmpz_poly/test/t-pseudo_divrem_cohen.c
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("pseudo_divrem_cohen....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check q*b + r = a, no aliasing */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r, prod;
|
||||
slong d;
|
||||
fmpz_t p;
|
||||
|
||||
fmpz_init(p);
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(prod);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 80), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 80) + 1, 100);
|
||||
|
||||
fmpz_poly_pseudo_divrem_cohen(q, r, a, b);
|
||||
fmpz_poly_mul(prod, q, b);
|
||||
fmpz_poly_add(prod, prod, r);
|
||||
d = a->length - b->length + 1;
|
||||
d = FLINT_MAX(d, 0);
|
||||
fmpz_pow_ui(p, b->coeffs + b->length - 1, d);
|
||||
fmpz_poly_scalar_mul_fmpz(a, a, p);
|
||||
|
||||
result = (fmpz_poly_equal(a, prod));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (correctness):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("prod = "), fmpz_poly_print(prod), flint_printf("\n\n");
|
||||
flint_printf("q = "), fmpz_poly_print(q), flint_printf("\n\n");
|
||||
flint_printf("r = "), fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(p);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(prod);
|
||||
}
|
||||
|
||||
/* Check r and a alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 80), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 80) + 1, 100);
|
||||
|
||||
fmpz_poly_pseudo_divrem_cohen(q, r, a, b);
|
||||
fmpz_poly_pseudo_divrem_cohen(q, a, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing r, a):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check r and b alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 80), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 80) + 1, 100);
|
||||
|
||||
fmpz_poly_pseudo_divrem_cohen(q, r, a, b);
|
||||
fmpz_poly_pseudo_divrem_cohen(q, b, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing r, b):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check q and a alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 80), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 80) + 1, 100);
|
||||
|
||||
fmpz_poly_pseudo_divrem_cohen(q, r, a, b);
|
||||
fmpz_poly_pseudo_divrem_cohen(a, r, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing q, a):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check q and b alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 80), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 80) + 1, 100);
|
||||
|
||||
fmpz_poly_pseudo_divrem_cohen(q, r, a, b);
|
||||
fmpz_poly_pseudo_divrem_cohen(b, r, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing q, b):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
217
external/flint-2.4.3/fmpz_poly/test/t-pseudo_divrem_divconquer.c
vendored
Normal file
217
external/flint-2.4.3/fmpz_poly/test/t-pseudo_divrem_divconquer.c
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("pseudo_divrem_divconquer....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check q*b + r = l(b)^d a, no aliasing */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r, prod;
|
||||
fmpz_t p;
|
||||
ulong d;
|
||||
|
||||
fmpz_init(p);
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(prod);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 200), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_divrem_divconquer(q, r, &d, a, b);
|
||||
fmpz_poly_mul(prod, q, b);
|
||||
fmpz_poly_add(prod, prod, r);
|
||||
fmpz_pow_ui(p, b->coeffs + b->length - 1, d);
|
||||
fmpz_poly_scalar_mul_fmpz(a, a, p);
|
||||
|
||||
result = (fmpz_poly_equal(a, prod));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (check qb + r = l(b)^d a):\n");
|
||||
flint_printf("l^d a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("qb + r = "), fmpz_poly_print(prod), flint_printf("\n\n");
|
||||
flint_printf("q = "), fmpz_poly_print(q), flint_printf("\n\n");
|
||||
flint_printf("r = "), fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(p);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(prod);
|
||||
}
|
||||
|
||||
/* Check r and a alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
ulong d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_divrem_divconquer(q, r, &d, a, b);
|
||||
fmpz_poly_pseudo_divrem_divconquer(q, a, &d, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (alias r and a):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check r and b alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
ulong d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_divrem_divconquer(q, r, &d, a, b);
|
||||
fmpz_poly_pseudo_divrem_divconquer(q, b, &d, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (alias r and b):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check q and a alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
ulong d;
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_divrem_divconquer(q, r, &d, a, b);
|
||||
fmpz_poly_pseudo_divrem_divconquer(a, r, &d, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (alias q and a):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check q and b alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r;
|
||||
ulong d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_divrem_divconquer(q, r, &d, a, b);
|
||||
fmpz_poly_pseudo_divrem_divconquer(b, r, &d, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (alias q and b):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
144
external/flint-2.4.3/fmpz_poly/test/t-pseudo_rem.c
vendored
Normal file
144
external/flint-2.4.3/fmpz_poly/test/t-pseudo_rem.c
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("pseudo_rem....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with divrem */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r, r2;
|
||||
ulong d, d2;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(r2);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_divrem(q, r, &d, a, b);
|
||||
fmpz_poly_pseudo_rem(r2, &d2, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(r, r2) && d == d2);
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
fmpz_poly_print(r2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(r2);
|
||||
}
|
||||
|
||||
/* Check r and a alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, r;
|
||||
ulong d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_rem(r, &d, a, b);
|
||||
fmpz_poly_pseudo_rem(a, &d, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check r and b alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, r;
|
||||
ulong d;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 50);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 50);
|
||||
|
||||
fmpz_poly_pseudo_rem(r, &d, a, b);
|
||||
fmpz_poly_pseudo_rem(b, &d, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
139
external/flint-2.4.3/fmpz_poly/test/t-pseudo_rem_cohen.c
vendored
Normal file
139
external/flint-2.4.3/fmpz_poly/test/t-pseudo_rem_cohen.c
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("pseudo_rem_cohen....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with q*b + r = a, no aliasing */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r1, r2;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r1);
|
||||
fmpz_poly_init(r2);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 200);
|
||||
|
||||
fmpz_poly_pseudo_divrem_cohen(q, r1, a, b);
|
||||
fmpz_poly_pseudo_rem_cohen(r2, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(r1, r2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (correctness):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("r1 = "), fmpz_poly_print(r1), flint_printf("\n\n");
|
||||
flint_printf("r2 = "), fmpz_poly_print(r2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r1);
|
||||
fmpz_poly_clear(r2);
|
||||
}
|
||||
|
||||
/* Check r and a alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 200);
|
||||
|
||||
fmpz_poly_pseudo_rem_cohen(r, a, b);
|
||||
fmpz_poly_pseudo_rem_cohen(a, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing r, a):\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check r and b alias */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 100) + 1, 200);
|
||||
|
||||
fmpz_poly_pseudo_rem_cohen(r, a, b);
|
||||
fmpz_poly_pseudo_rem_cohen(b, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing r, b):\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
143
external/flint-2.4.3/fmpz_poly/test/t-rem_basecase.c
vendored
Normal file
143
external/flint-2.4.3/fmpz_poly/test/t-rem_basecase.c
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("rem_basecase....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with full division, no aliasing */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r, r2;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(r2);
|
||||
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, a->length + 1) + 1, 100);
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_rem_basecase(r2, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(r, r2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
fmpz_poly_print(r2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(r2);
|
||||
}
|
||||
|
||||
/* Check r and a alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 50) + 1, 100);
|
||||
|
||||
fmpz_poly_rem_basecase(r, a, b);
|
||||
fmpz_poly_rem_basecase(a, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(a, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
/* Check r and b alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, r;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 50) + 1, 100);
|
||||
|
||||
fmpz_poly_rem_basecase(r, a, b);
|
||||
fmpz_poly_rem_basecase(b, a, b);
|
||||
|
||||
result = (fmpz_poly_equal(b, r));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(r);
|
||||
}
|
||||
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
155
external/flint-2.4.3/fmpz_poly/test/t-rem_powers_precomp.c
vendored
Normal file
155
external/flint-2.4.3/fmpz_poly/test/t-rem_powers_precomp.c
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009, 2013 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("rem_powers_precomp....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with full division, no aliasing */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, q, r, r2;
|
||||
fmpz_poly_powers_precomp_t b_inv;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_init(r);
|
||||
fmpz_poly_init(r2);
|
||||
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, a->length + 1) + 1, 100);
|
||||
fmpz_set_ui(b->coeffs + b->length - 1, 1); /* b must be monic */
|
||||
|
||||
fmpz_poly_divrem_basecase(q, r, a, b);
|
||||
fmpz_poly_powers_precompute(b_inv, b);
|
||||
fmpz_poly_rem_powers_precomp(r2, a, b, b_inv);
|
||||
|
||||
result = (fmpz_poly_equal(r, r2));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
fmpz_poly_print(r), flint_printf("\n\n");
|
||||
fmpz_poly_print(r2), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_powers_clear(b_inv);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(q);
|
||||
fmpz_poly_clear(r);
|
||||
fmpz_poly_clear(r2);
|
||||
}
|
||||
|
||||
/* Check q and a alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, b_inv, q;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(b_inv);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 50) + 1, 100);
|
||||
fmpz_set_ui(b->coeffs + b->length - 1, 1); /* b must be monic */
|
||||
|
||||
fmpz_poly_div_basecase(q, a, b);
|
||||
fmpz_poly_preinvert(b_inv, b);
|
||||
fmpz_poly_div_preinv(a, a, b, b_inv);
|
||||
|
||||
result = (fmpz_poly_equal(a, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(b_inv);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
/* Check q and b alias */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, b_inv, q;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(b_inv);
|
||||
fmpz_poly_init(q);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest_not_zero(b, state, n_randint(state, 50) + 1, 100);
|
||||
fmpz_set_ui(b->coeffs + b->length - 1, 1); /* b must be monic */
|
||||
|
||||
fmpz_poly_div_basecase(q, a, b);
|
||||
fmpz_poly_preinvert(b_inv, b);
|
||||
fmpz_poly_div_preinv(b, a, b, b_inv);
|
||||
|
||||
result = (fmpz_poly_equal(b, q));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(q), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(b_inv);
|
||||
fmpz_poly_clear(q);
|
||||
}
|
||||
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
126
external/flint-2.4.3/fmpz_poly/test/t-resultant.c
vendored
Normal file
126
external/flint-2.4.3/fmpz_poly/test/t-resultant.c
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("resultant....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Just one specific test */
|
||||
{
|
||||
fmpz_poly_t f, g;
|
||||
fmpz_t a, b;
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_init(a);
|
||||
fmpz_init(b);
|
||||
fmpz_poly_set_str(f, "11 -15 -2 -2 17 0 0 6 0 -5 1 -1");
|
||||
fmpz_poly_set_str(g, "9 2 1 1 1 1 1 0 -1 -2");
|
||||
fmpz_poly_resultant(a, f, g);
|
||||
fmpz_set_str(b, "-44081924855067", 10);
|
||||
|
||||
result = (fmpz_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("f = "), fmpz_poly_print(f), flint_printf("\n\n");
|
||||
flint_printf("g = "), fmpz_poly_print(g), flint_printf("\n\n");
|
||||
flint_printf("res(f, h) = "), fmpz_print(a), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_clear(a);
|
||||
fmpz_clear(b);
|
||||
}
|
||||
|
||||
/* Check that R(fg, h) = R(f, h) R(g, h) */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_t a, b, c, d;
|
||||
fmpz_poly_t f, g, h, p;
|
||||
|
||||
fmpz_init(a);
|
||||
fmpz_init(b);
|
||||
fmpz_init(c);
|
||||
fmpz_init(d);
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_init(p);
|
||||
fmpz_poly_randtest(f, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50), 100);
|
||||
fmpz_poly_randtest(h, state, n_randint(state, 10), 100);
|
||||
|
||||
fmpz_poly_resultant(a, f, h);
|
||||
fmpz_poly_resultant(b, g, h);
|
||||
fmpz_mul(c, a, b);
|
||||
fmpz_poly_mul(p, f, g);
|
||||
fmpz_poly_resultant(d, p, h);
|
||||
|
||||
result = (fmpz_equal(c, d));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("f = "), fmpz_poly_print(f), flint_printf("\n\n");
|
||||
flint_printf("g = "), fmpz_poly_print(g), flint_printf("\n\n");
|
||||
flint_printf("h = "), fmpz_poly_print(h), flint_printf("\n\n");
|
||||
flint_printf("res(f, h) = "), fmpz_print(a), flint_printf("\n\n");
|
||||
flint_printf("res(g, h) = "), fmpz_print(b), flint_printf("\n\n");
|
||||
flint_printf("res(fg, h) = "), fmpz_print(d), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(a);
|
||||
fmpz_clear(b);
|
||||
fmpz_clear(c);
|
||||
fmpz_clear(d);
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
fmpz_poly_clear(p);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
115
external/flint-2.4.3/fmpz_poly/test/t-reverse.c
vendored
Normal file
115
external/flint-2.4.3/fmpz_poly/test/t-reverse.c
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("reverse....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Aliasing */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 100), 200);
|
||||
n = n_randint(state, 150);
|
||||
|
||||
fmpz_poly_reverse(a, b, n);
|
||||
fmpz_poly_reverse(b, b, n);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("n = %wd\n", n);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Correctness (?) */
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
slong j, len, n;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 100), 200);
|
||||
n = n_randint(state, 150);
|
||||
|
||||
len = FLINT_MIN(n, b->length);
|
||||
if (len)
|
||||
{
|
||||
fmpz_poly_fit_length(a, n);
|
||||
for (j = 0; j < len; j++)
|
||||
fmpz_set(a->coeffs + (n - len) + j, b->coeffs + (len - 1 - j));
|
||||
_fmpz_poly_set_length(a, n);
|
||||
_fmpz_poly_normalise(a);
|
||||
}
|
||||
|
||||
fmpz_poly_reverse(b, b, n);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("n = %wd\n", n);
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
119
external/flint-2.4.3/fmpz_poly/test/t-revert_series.c
vendored
Normal file
119
external/flint-2.4.3/fmpz_poly/test/t-revert_series.c
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("revert_series....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50),
|
||||
1+n_randint(state,100));
|
||||
fmpz_poly_set_coeff_ui(g, 0, 0);
|
||||
fmpz_poly_set_coeff_ui(g, 1, 1);
|
||||
if (n_randlimb(state) % 2)
|
||||
fmpz_poly_neg(g, g); /* get -x term */
|
||||
n = n_randint(state, 50);
|
||||
|
||||
fmpz_poly_revert_series(f, g, n);
|
||||
fmpz_poly_revert_series(g, g, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, g));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
}
|
||||
|
||||
/* Check f(f^(-1)) = id */
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50), 10);
|
||||
fmpz_poly_set_coeff_ui(g, 0, 0);
|
||||
fmpz_poly_set_coeff_ui(g, 1, 1);
|
||||
if (n_randlimb(state) % 2)
|
||||
fmpz_poly_neg(g, g); /* get -x term */
|
||||
n = n_randint(state, 50);
|
||||
|
||||
fmpz_poly_revert_series(f, g, n);
|
||||
fmpz_poly_compose_series(h, g, f, n);
|
||||
|
||||
result = ((n <= 1 && fmpz_poly_is_zero(h)) ||
|
||||
(h->length == 2 && fmpz_is_zero(h->coeffs + 0) &&
|
||||
fmpz_is_one(h->coeffs + 1)));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (comparison):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
fmpz_poly_print(h), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
119
external/flint-2.4.3/fmpz_poly/test/t-revert_series_lagrange.c
vendored
Normal file
119
external/flint-2.4.3/fmpz_poly/test/t-revert_series_lagrange.c
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("revert_series_lagrange....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50),
|
||||
1+n_randint(state,100));
|
||||
fmpz_poly_set_coeff_ui(g, 0, 0);
|
||||
fmpz_poly_set_coeff_ui(g, 1, 1);
|
||||
if (n_randlimb(state) % 2)
|
||||
fmpz_poly_neg(g, g); /* get -x term */
|
||||
n = n_randint(state, 50);
|
||||
|
||||
fmpz_poly_revert_series_lagrange(f, g, n);
|
||||
fmpz_poly_revert_series_lagrange(g, g, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, g));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
}
|
||||
|
||||
/* Check f(f^(-1)) = id */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50), 1+n_randint(state,100));
|
||||
fmpz_poly_set_coeff_ui(g, 0, 0);
|
||||
fmpz_poly_set_coeff_ui(g, 1, 1);
|
||||
if (n_randlimb(state) % 2)
|
||||
fmpz_poly_neg(g, g); /* get -x term */
|
||||
n = n_randint(state, 50);
|
||||
|
||||
fmpz_poly_revert_series_lagrange(f, g, n);
|
||||
fmpz_poly_compose_series(h, g, f, n);
|
||||
|
||||
result = ((n <= 1 && fmpz_poly_is_zero(h)) ||
|
||||
(h->length == 2 && fmpz_is_zero(h->coeffs + 0) &&
|
||||
fmpz_is_one(h->coeffs + 1)));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (comparison):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
fmpz_poly_print(h), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
119
external/flint-2.4.3/fmpz_poly/test/t-revert_series_lagrange_fast.c
vendored
Normal file
119
external/flint-2.4.3/fmpz_poly/test/t-revert_series_lagrange_fast.c
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("revert_series_lagrange_fast....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50),
|
||||
1+n_randint(state,100));
|
||||
fmpz_poly_set_coeff_ui(g, 0, 0);
|
||||
fmpz_poly_set_coeff_ui(g, 1, 1);
|
||||
if (n_randlimb(state) % 2)
|
||||
fmpz_poly_neg(g, g); /* get -x term */
|
||||
n = n_randint(state, 50);
|
||||
|
||||
fmpz_poly_revert_series_lagrange_fast(f, g, n);
|
||||
fmpz_poly_revert_series_lagrange_fast(g, g, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, g));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
}
|
||||
|
||||
/* Check f(f^(-1)) = id */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50), 1+n_randint(state,100));
|
||||
fmpz_poly_set_coeff_ui(g, 0, 0);
|
||||
fmpz_poly_set_coeff_ui(g, 1, 1);
|
||||
if (n_randlimb(state) % 2)
|
||||
fmpz_poly_neg(g, g); /* get -x term */
|
||||
n = n_randint(state, 50);
|
||||
|
||||
fmpz_poly_revert_series_lagrange_fast(f, g, n);
|
||||
fmpz_poly_compose_series(h, g, f, n);
|
||||
|
||||
result = ((n <= 1 && fmpz_poly_is_zero(h)) ||
|
||||
(h->length == 2 && fmpz_is_zero(h->coeffs + 0) &&
|
||||
fmpz_is_one(h->coeffs + 1)));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (comparison):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
fmpz_poly_print(h), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
119
external/flint-2.4.3/fmpz_poly/test/t-revert_series_newton.c
vendored
Normal file
119
external/flint-2.4.3/fmpz_poly/test/t-revert_series_newton.c
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("revert_series_newton....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50),
|
||||
1+n_randint(state,100));
|
||||
fmpz_poly_set_coeff_ui(g, 0, 0);
|
||||
fmpz_poly_set_coeff_ui(g, 1, 1);
|
||||
if (n_randlimb(state) % 2)
|
||||
fmpz_poly_neg(g, g); /* get -x term */
|
||||
n = n_randint(state, 50);
|
||||
|
||||
fmpz_poly_revert_series_newton(f, g, n);
|
||||
fmpz_poly_revert_series_newton(g, g, n);
|
||||
|
||||
result = (fmpz_poly_equal(f, g));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
}
|
||||
|
||||
/* Check f(f^(-1)) = id */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t f, g, h;
|
||||
slong n;
|
||||
|
||||
fmpz_poly_init(f);
|
||||
fmpz_poly_init(g);
|
||||
fmpz_poly_init(h);
|
||||
fmpz_poly_randtest(g, state, n_randint(state, 50), 1+n_randint(state,100));
|
||||
fmpz_poly_set_coeff_ui(g, 0, 0);
|
||||
fmpz_poly_set_coeff_ui(g, 1, 1);
|
||||
if (n_randlimb(state) % 2)
|
||||
fmpz_poly_neg(g, g); /* get -x term */
|
||||
n = n_randint(state, 50);
|
||||
|
||||
fmpz_poly_revert_series_newton(f, g, n);
|
||||
fmpz_poly_compose_series(h, g, f, n);
|
||||
|
||||
result = ((n <= 1 && fmpz_poly_is_zero(h)) ||
|
||||
(h->length == 2 && fmpz_is_zero(h->coeffs + 0) &&
|
||||
fmpz_is_one(h->coeffs + 1)));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (comparison):\n");
|
||||
fmpz_poly_print(f), flint_printf("\n\n");
|
||||
fmpz_poly_print(g), flint_printf("\n\n");
|
||||
fmpz_poly_print(h), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(f);
|
||||
fmpz_poly_clear(g);
|
||||
fmpz_poly_clear(h);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
121
external/flint-2.4.3/fmpz_poly/test/t-scalar_addmul_fmpz.c
vendored
Normal file
121
external/flint-2.4.3/fmpz_poly/test/t-scalar_addmul_fmpz.c
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("scalar_addmul_fmpz....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
fmpz_t x;
|
||||
|
||||
fmpz_init(x);
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_randtest(x, state, n_randint(state, 100));
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_set(b, a);
|
||||
fmpz_poly_set(c, a);
|
||||
|
||||
fmpz_poly_scalar_addmul_fmpz(b, a, x);
|
||||
fmpz_poly_scalar_addmul_fmpz(a, a, x);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (1):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("c = "), fmpz_poly_print(c), flint_printf("\n\n");
|
||||
flint_printf("x = "), fmpz_print(x), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(x);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check that b += x*a is the same as c = b + x*a */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
fmpz_t x;
|
||||
|
||||
fmpz_init(x);
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_randtest(x, state, n_randint(state, 100));
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_scalar_mul_fmpz(c, a, x);
|
||||
fmpz_poly_add(c, b, c);
|
||||
|
||||
fmpz_poly_scalar_addmul_fmpz(b, a, x);
|
||||
|
||||
result = (fmpz_poly_equal(b, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (2):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("c = "), fmpz_poly_print(c), flint_printf("\n\n");
|
||||
flint_printf("x = "), fmpz_print(x), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(x);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
100
external/flint-2.4.3/fmpz_poly/test/t-scalar_divexact_mpz.c
vendored
Normal file
100
external/flint-2.4.3/fmpz_poly/test/t-scalar_divexact_mpz.c
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("scalar_divexact_mpz....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with fmpz_poly_scalar_divexact_fmpz */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
fmpz_t n;
|
||||
mpz_t n1;
|
||||
|
||||
fmpz_init(n);
|
||||
mpz_init(n1);
|
||||
do {
|
||||
fmpz_randtest(n, state, 200);
|
||||
} while (fmpz_is_zero(n));
|
||||
fmpz_get_mpz(n1, n);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_scalar_mul_fmpz(a, a, n);
|
||||
|
||||
fmpz_poly_scalar_divexact_fmpz(b, a, n);
|
||||
fmpz_poly_scalar_divexact_mpz(c, a, n1);
|
||||
|
||||
result = (fmpz_poly_equal(b, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
/* aliasing */
|
||||
fmpz_poly_scalar_divexact_mpz(a, a, n1);
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
mpz_clear(n1);
|
||||
fmpz_clear(n);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
100
external/flint-2.4.3/fmpz_poly/test/t-scalar_fdiv_mpz.c
vendored
Normal file
100
external/flint-2.4.3/fmpz_poly/test/t-scalar_fdiv_mpz.c
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("scalar_fdiv_mpz....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with fmpz_poly_scalar_fdiv_fmpz */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
fmpz_t n;
|
||||
mpz_t n1;
|
||||
|
||||
fmpz_init(n);
|
||||
mpz_init(n1);
|
||||
do {
|
||||
fmpz_randtest(n, state, 200);
|
||||
} while (fmpz_is_zero(n));
|
||||
fmpz_get_mpz(n1, n);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_scalar_mul_fmpz(a, a, n);
|
||||
|
||||
fmpz_poly_scalar_fdiv_fmpz(b, a, n);
|
||||
fmpz_poly_scalar_fdiv_mpz(c, a, n1);
|
||||
|
||||
result = (fmpz_poly_equal(b, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
/* aliasing */
|
||||
fmpz_poly_scalar_fdiv_mpz(a, a, n1);
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
mpz_clear(n1);
|
||||
fmpz_clear(n);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
111
external/flint-2.4.3/fmpz_poly/test/t-scalar_mul_fmpz.c
vendored
Normal file
111
external/flint-2.4.3/fmpz_poly/test/t-scalar_mul_fmpz.c
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("scalar_mul_fmpz....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
fmpz_t n;
|
||||
fmpz_init(n);
|
||||
fmpz_randtest(n, state, 200);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_scalar_mul_fmpz(b, a, n);
|
||||
fmpz_poly_scalar_mul_fmpz(a, a, n);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(n);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Compare with fmpz_poly_scalar_mul_si */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
fmpz_t n1;
|
||||
slong n;
|
||||
fmpz_init(n1);
|
||||
n = (slong) n_randbits(state, FLINT_BITS - 1);
|
||||
if (n_randint(state, 2))
|
||||
n = -n;
|
||||
fmpz_set_si(n1, n);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_scalar_mul_fmpz(b, a, n1);
|
||||
fmpz_poly_scalar_mul_si(a, a, n);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(n1);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
97
external/flint-2.4.3/fmpz_poly/test/t-scalar_mul_mpz.c
vendored
Normal file
97
external/flint-2.4.3/fmpz_poly/test/t-scalar_mul_mpz.c
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("scalar_mul_mpz....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Compare with fmpz_poly_scalar_mul_fmpz */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
fmpz_t n;
|
||||
mpz_t n1;
|
||||
|
||||
fmpz_init(n);
|
||||
mpz_init(n1);
|
||||
fmpz_randtest(n, state, 200);
|
||||
fmpz_get_mpz(n1, n);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_scalar_mul_fmpz(b, a, n);
|
||||
fmpz_poly_scalar_mul_mpz(c, a, n1);
|
||||
|
||||
result = (fmpz_poly_equal(b, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
/* aliasing */
|
||||
fmpz_poly_scalar_mul_mpz(a, a, n1);
|
||||
result = (fmpz_poly_equal(a, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
mpz_clear(n1);
|
||||
fmpz_clear(n);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
137
external/flint-2.4.3/fmpz_poly/test/t-scalar_mul_si.c
vendored
Normal file
137
external/flint-2.4.3/fmpz_poly/test/t-scalar_mul_si.c
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "long_extras.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("scalar_mul_si....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
slong n = z_randtest(state);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_scalar_mul_si(b, a, n);
|
||||
fmpz_poly_scalar_mul_si(a, a, n);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Compare with fmpz_poly_scalar_mul_ui */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
ulong n = n_randbits(state, FLINT_BITS - 1);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_scalar_mul_ui(b, a, n);
|
||||
fmpz_poly_scalar_mul_si(a, a, n);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Check (a*n1)*n2 = a*(n1*n2) */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
slong n1 = (slong) n_randbits(state, (FLINT_BITS - 2) / 2);
|
||||
slong n2 = (slong) n_randbits(state, (FLINT_BITS - 2) / 2);
|
||||
if (n_randint(state, 2))
|
||||
n1 = -n1;
|
||||
if (n_randint(state, 2))
|
||||
n2 = -n2;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_scalar_mul_si(b, a, n1);
|
||||
fmpz_poly_scalar_mul_si(c, b, n2);
|
||||
fmpz_poly_scalar_mul_si(b, a, n1 * n2);
|
||||
|
||||
result = (fmpz_poly_equal(b, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL n1 = %wd, n2 = %wd:\n", n1, n2);
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
106
external/flint-2.4.3/fmpz_poly/test/t-scalar_mul_ui.c
vendored
Normal file
106
external/flint-2.4.3/fmpz_poly/test/t-scalar_mul_ui.c
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("scalar_mul_ui....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
ulong n = n_randtest(state);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_scalar_mul_ui(b, a, n);
|
||||
fmpz_poly_scalar_mul_ui(a, a, n);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
/* Check (a*n1)*n2 = a*(n1*n2) */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
ulong n1 = n_randbits(state, FLINT_BITS / 2);
|
||||
ulong n2 = n_randbits(state, FLINT_BITS / 2);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_scalar_mul_ui(b, a, n1);
|
||||
fmpz_poly_scalar_mul_ui(c, b, n2);
|
||||
fmpz_poly_scalar_mul_ui(b, a, n1 * n2);
|
||||
|
||||
result = (fmpz_poly_equal(b, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL n1 = %wu, n2 = %wu:\n", n1, n2);
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
fmpz_poly_print(c), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
121
external/flint-2.4.3/fmpz_poly/test/t-scalar_submul_fmpz.c
vendored
Normal file
121
external/flint-2.4.3/fmpz_poly/test/t-scalar_submul_fmpz.c
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
Copyright (C) 2010 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("scalar_submul_fmpz....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Check aliasing of a and b */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
fmpz_t x;
|
||||
|
||||
fmpz_init(x);
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_randtest(x, state, n_randint(state, 100));
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_set(b, a);
|
||||
fmpz_poly_set(c, a);
|
||||
|
||||
fmpz_poly_scalar_submul_fmpz(b, a, x);
|
||||
fmpz_poly_scalar_submul_fmpz(a, a, x);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (1):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("c = "), fmpz_poly_print(c), flint_printf("\n\n");
|
||||
flint_printf("x = "), fmpz_print(x), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(x);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
/* Check that b += x*a is the same as c = b + x*a */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b, c;
|
||||
fmpz_t x;
|
||||
|
||||
fmpz_init(x);
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(c);
|
||||
fmpz_randtest(x, state, n_randint(state, 100));
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
fmpz_poly_randtest(b, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_scalar_mul_fmpz(c, a, x);
|
||||
fmpz_poly_sub(c, b, c);
|
||||
|
||||
fmpz_poly_scalar_submul_fmpz(b, a, x);
|
||||
|
||||
result = (fmpz_poly_equal(b, c));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (2):\n");
|
||||
flint_printf("a = "), fmpz_poly_print(a), flint_printf("\n\n");
|
||||
flint_printf("b = "), fmpz_poly_print(b), flint_printf("\n\n");
|
||||
flint_printf("c = "), fmpz_poly_print(c), flint_printf("\n\n");
|
||||
flint_printf("x = "), fmpz_print(x), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(x);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(c);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
108
external/flint-2.4.3/fmpz_poly/test/t-set_equal.c
vendored
Normal file
108
external/flint-2.4.3/fmpz_poly/test/t-set_equal.c
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2009 William Hart
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i, result;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("set/equal....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* equal polynomials */
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_set(b, a);
|
||||
|
||||
result = (fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_t a, b;
|
||||
slong coeff = n_randint(state, 100);
|
||||
fmpz_t x1, x2;
|
||||
|
||||
fmpz_init(x1);
|
||||
fmpz_init(x2);
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_randtest(a, state, n_randint(state, 100), 200);
|
||||
|
||||
fmpz_poly_set(b, a);
|
||||
|
||||
fmpz_poly_get_coeff_fmpz(x2, b, coeff);
|
||||
do
|
||||
fmpz_randtest(x1, state, 200);
|
||||
while (fmpz_equal(x1, x2));
|
||||
fmpz_poly_set_coeff_fmpz(b, coeff, x1);
|
||||
|
||||
result = (!fmpz_poly_equal(a, b));
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_print(a), flint_printf("\n\n");
|
||||
fmpz_poly_print(b), flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(x1);
|
||||
fmpz_clear(x2);
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user