ALL: Add flint
This commit is contained in:
186
external/flint-2.4.3/fmpz_poly_mat/test/t-add.c
vendored
Normal file
186
external/flint-2.4.3/fmpz_poly_mat/test/t-add.c
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("add....");
|
||||
fflush(stdout);
|
||||
|
||||
/* Check evaluation homomorphism */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
fmpz_mat_t a, b, c, d;
|
||||
fmpz_t x;
|
||||
slong m, n, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, m, n);
|
||||
fmpz_poly_mat_init(C, m, n);
|
||||
|
||||
fmpz_mat_init(a, m, n);
|
||||
fmpz_mat_init(b, m, n);
|
||||
fmpz_mat_init(c, m, n);
|
||||
fmpz_mat_init(d, m, n);
|
||||
|
||||
fmpz_init(x);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
fmpz_poly_mat_add(C, A, B);
|
||||
|
||||
fmpz_randtest(x, state, 1 + n_randint(state, 100));
|
||||
|
||||
fmpz_poly_mat_evaluate_fmpz(a, A, x);
|
||||
fmpz_poly_mat_evaluate_fmpz(b, B, x);
|
||||
fmpz_poly_mat_evaluate_fmpz(d, C, x);
|
||||
fmpz_mat_add(c, a, b);
|
||||
|
||||
if (!fmpz_mat_equal(c, d))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
|
||||
fmpz_mat_clear(a);
|
||||
fmpz_mat_clear(b);
|
||||
fmpz_mat_clear(c);
|
||||
fmpz_mat_clear(d);
|
||||
|
||||
fmpz_clear(x);
|
||||
}
|
||||
|
||||
/* Check aliasing C and A */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong m, n, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, m, n);
|
||||
fmpz_poly_mat_init(C, m, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_add(C, A, B);
|
||||
fmpz_poly_mat_add(A, A, B);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, A))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
/* Check aliasing C and B */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong m, n, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, m, n);
|
||||
fmpz_poly_mat_init(C, m, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_add(C, A, B);
|
||||
fmpz_poly_mat_add(B, A, B);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, B))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
109
external/flint-2.4.3/fmpz_poly_mat/test/t-det.c
vendored
Normal file
109
external/flint-2.4.3/fmpz_poly_mat/test/t-det.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) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("det....");
|
||||
fflush(stdout);
|
||||
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
fmpz_poly_t a, b, ab, c;
|
||||
slong n, bits, deg;
|
||||
float density;
|
||||
|
||||
n = n_randint(state, 10);
|
||||
deg = 1 + n_randint(state, 5);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
density = n_randint(state, 100) * 0.01;
|
||||
|
||||
fmpz_poly_mat_init(A, n, n);
|
||||
fmpz_poly_mat_init(B, n, n);
|
||||
fmpz_poly_mat_init(C, n, n);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
fmpz_poly_init(ab);
|
||||
fmpz_poly_init(c);
|
||||
|
||||
fmpz_poly_mat_randtest_sparse(A, state, deg, bits, density);
|
||||
fmpz_poly_mat_randtest_sparse(B, state, deg, bits, density);
|
||||
fmpz_poly_mat_mul(C, A, B);
|
||||
|
||||
fmpz_poly_mat_det(a, A);
|
||||
fmpz_poly_mat_det(b, B);
|
||||
fmpz_poly_mat_det(c, C);
|
||||
fmpz_poly_mul(ab, a, b);
|
||||
|
||||
if (!fmpz_poly_equal(c, ab))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("determinants don't agree!\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("det(A):\n");
|
||||
fmpz_poly_print_pretty(a, "x");
|
||||
flint_printf("\ndet(B):\n");
|
||||
fmpz_poly_print_pretty(b, "x");
|
||||
flint_printf("\ndet(C):\n");
|
||||
fmpz_poly_print_pretty(c, "x");
|
||||
flint_printf("\ndet(A)*det(B):\n");
|
||||
fmpz_poly_print_pretty(ab, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
fmpz_poly_clear(ab);
|
||||
fmpz_poly_clear(c);
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
87
external/flint-2.4.3/fmpz_poly_mat/test/t-det_interpolate.c
vendored
Normal file
87
external/flint-2.4.3/fmpz_poly_mat/test/t-det_interpolate.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 "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("det_interpolate....");
|
||||
fflush(stdout);
|
||||
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A;
|
||||
fmpz_poly_t a, b;
|
||||
slong n, bits, deg;
|
||||
|
||||
n = n_randint(state, 10);
|
||||
deg = 1 + n_randint(state, 5);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, n, n);
|
||||
|
||||
fmpz_poly_init(a);
|
||||
fmpz_poly_init(b);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_det(a, A);
|
||||
fmpz_poly_mat_det_interpolate(b, A);
|
||||
|
||||
if (!fmpz_poly_equal(a, b))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("determinants don't agree!\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("det(A):\n");
|
||||
fmpz_poly_print_pretty(a, "x");
|
||||
flint_printf("\ndet_interpolate(A):\n");
|
||||
fmpz_poly_print_pretty(b, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(a);
|
||||
fmpz_poly_clear(b);
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
67
external/flint-2.4.3/fmpz_poly_mat/test/t-init_clear.c
vendored
Normal file
67
external/flint-2.4.3/fmpz_poly_mat/test/t-init_clear.c
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/*=============================================================================
|
||||
|
||||
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
|
||||
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 "fmpz_poly_mat.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int i;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
|
||||
flint_printf("init/clear....");
|
||||
fflush(stdout);
|
||||
|
||||
for (i = 0; i < 1000 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t a;
|
||||
slong j, k;
|
||||
slong rows = n_randint(state, 100);
|
||||
slong cols = n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(a, rows, cols);
|
||||
|
||||
for (j = 0; j < rows; j++)
|
||||
for (k = 0; k < cols; k++)
|
||||
fmpz_poly_zero(fmpz_poly_mat_entry(a, j, k));
|
||||
|
||||
fmpz_poly_mat_clear(a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
163
external/flint-2.4.3/fmpz_poly_mat/test/t-inv.c
vendored
Normal file
163
external/flint-2.4.3/fmpz_poly_mat/test/t-inv.c
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("inv....");
|
||||
fflush(stdout);
|
||||
|
||||
/* Test aliasing */
|
||||
for (i = 0; i < 40 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, Ainv;
|
||||
fmpz_poly_t den1, den2;
|
||||
slong n, bits, deg;
|
||||
float density;
|
||||
int ns1, ns2;
|
||||
int result;
|
||||
|
||||
n = n_randint(state, 8);
|
||||
deg = 1 + n_randint(state, 5);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
density = n_randint(state, 100) * 0.01;
|
||||
|
||||
fmpz_poly_mat_init(A, n, n);
|
||||
fmpz_poly_mat_init(Ainv, n, n);
|
||||
fmpz_poly_init(den1);
|
||||
fmpz_poly_init(den2);
|
||||
|
||||
fmpz_poly_mat_randtest_sparse(A, state, deg, bits, density);
|
||||
|
||||
ns1 = fmpz_poly_mat_inv(Ainv, den1, A);
|
||||
ns2 = fmpz_poly_mat_inv(A, den2, A);
|
||||
|
||||
result = ns1 == ns2;
|
||||
|
||||
if (result && ns1 != 0)
|
||||
{
|
||||
result = fmpz_poly_equal(den1, den2) &&
|
||||
fmpz_poly_mat_equal(A, Ainv);
|
||||
}
|
||||
|
||||
if (!result)
|
||||
{
|
||||
flint_printf("FAIL (aliasing)!\n");
|
||||
fmpz_poly_mat_print(A, "x"); flint_printf("\n");
|
||||
fmpz_poly_mat_print(Ainv, "x"); flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(Ainv);
|
||||
fmpz_poly_clear(den1);
|
||||
fmpz_poly_clear(den2);
|
||||
}
|
||||
|
||||
/* Check A^(-1) = A = 1 */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, Ainv, B, Iden;
|
||||
fmpz_poly_t den, det;
|
||||
slong n, bits, deg;
|
||||
float density;
|
||||
int nonsingular;
|
||||
|
||||
n = n_randint(state, 10);
|
||||
deg = 1 + n_randint(state, 5);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
density = n_randint(state, 100) * 0.01;
|
||||
|
||||
fmpz_poly_mat_init(A, n, n);
|
||||
fmpz_poly_mat_init(Ainv, n, n);
|
||||
fmpz_poly_mat_init(B, n, n);
|
||||
fmpz_poly_mat_init(Iden, n, n);
|
||||
fmpz_poly_init(den);
|
||||
fmpz_poly_init(det);
|
||||
|
||||
fmpz_poly_mat_randtest_sparse(A, state, deg, bits, density);
|
||||
nonsingular = fmpz_poly_mat_inv(Ainv, den, A);
|
||||
fmpz_poly_mat_det_interpolate(det, A);
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
if (nonsingular == 0 || !fmpz_poly_is_one(den))
|
||||
{
|
||||
flint_printf("FAIL: expected empty matrix to pass\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!fmpz_poly_equal(den, det))
|
||||
{
|
||||
fmpz_poly_neg(det, det);
|
||||
flint_printf("FAIL: den != det(A)\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_mul(B, Ainv, A);
|
||||
fmpz_poly_mat_one(Iden);
|
||||
fmpz_poly_mat_scalar_mul_fmpz_poly(Iden, Iden, den);
|
||||
|
||||
if (!fmpz_poly_mat_equal(B, Iden))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("Ainv:\n");
|
||||
fmpz_poly_mat_print(Ainv, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("den:\n");
|
||||
fmpz_poly_print_pretty(den, "x");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_poly_clear(den);
|
||||
fmpz_poly_clear(det);
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(Ainv);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(Iden);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
191
external/flint-2.4.3/fmpz_poly_mat/test/t-mul.c
vendored
Normal file
191
external/flint-2.4.3/fmpz_poly_mat/test/t-mul.c
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mul....");
|
||||
fflush(stdout);
|
||||
|
||||
/* Check evaluation homomorphism */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
fmpz_mat_t a, b, c, d;
|
||||
fmpz_t x;
|
||||
slong m, n, k, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
k = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, n, k);
|
||||
fmpz_poly_mat_init(C, m, k);
|
||||
|
||||
fmpz_mat_init(a, m, n);
|
||||
fmpz_mat_init(b, n, k);
|
||||
fmpz_mat_init(c, m, k);
|
||||
fmpz_mat_init(d, m, k);
|
||||
|
||||
fmpz_init(x);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits); /* noise in output */
|
||||
|
||||
fmpz_poly_mat_mul(C, A, B);
|
||||
|
||||
fmpz_randtest(x, state, 1 + n_randint(state, 100));
|
||||
|
||||
fmpz_poly_mat_evaluate_fmpz(a, A, x);
|
||||
fmpz_poly_mat_evaluate_fmpz(b, B, x);
|
||||
fmpz_poly_mat_evaluate_fmpz(d, C, x);
|
||||
fmpz_mat_mul(c, a, b);
|
||||
|
||||
if (!fmpz_mat_equal(c, d))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
|
||||
fmpz_mat_clear(a);
|
||||
fmpz_mat_clear(b);
|
||||
fmpz_mat_clear(c);
|
||||
fmpz_mat_clear(d);
|
||||
|
||||
fmpz_clear(x);
|
||||
}
|
||||
|
||||
/* Check aliasing C and A */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong m, n, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, n, n);
|
||||
fmpz_poly_mat_init(C, m, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits); /* noise in output */
|
||||
|
||||
fmpz_poly_mat_mul(C, A, B);
|
||||
fmpz_poly_mat_mul(A, A, B);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, A))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
/* Check aliasing C and B */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong m, n, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, m);
|
||||
fmpz_poly_mat_init(B, m, n);
|
||||
fmpz_poly_mat_init(C, m, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits); /* noise in output */
|
||||
|
||||
fmpz_poly_mat_mul(C, A, B);
|
||||
fmpz_poly_mat_mul(B, A, B);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, B))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
182
external/flint-2.4.3/fmpz_poly_mat/test/t-mul_KS.c
vendored
Normal file
182
external/flint-2.4.3/fmpz_poly_mat/test/t-mul_KS.c
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mul_KS....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C, D;
|
||||
slong m, n, k, bits, deg;
|
||||
|
||||
m = n_randint(state, 15);
|
||||
n = n_randint(state, 15);
|
||||
k = n_randint(state, 15);
|
||||
deg = 1 + n_randint(state, 15);
|
||||
bits = 1 + n_randint(state, 150);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, n, k);
|
||||
fmpz_poly_mat_init(C, m, k);
|
||||
fmpz_poly_mat_init(D, m, k);
|
||||
|
||||
if (n_randint(state, 2))
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
else
|
||||
fmpz_poly_mat_randtest_unsigned(A, state, deg, bits);
|
||||
|
||||
if (n_randint(state, 2))
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
else
|
||||
fmpz_poly_mat_randtest_unsigned(B, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits); /* noise in output */
|
||||
|
||||
fmpz_poly_mat_mul_classical(C, A, B);
|
||||
fmpz_poly_mat_mul_KS(D, A, B);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, D))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("products don't agree!\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("D:\n");
|
||||
fmpz_poly_mat_print(D, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
fmpz_poly_mat_clear(D);
|
||||
}
|
||||
|
||||
/* Check aliasing C and A */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong m, n, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, n, n);
|
||||
fmpz_poly_mat_init(C, m, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits); /* noise in output */
|
||||
|
||||
fmpz_poly_mat_mul_KS(C, A, B);
|
||||
fmpz_poly_mat_mul_KS(A, A, B);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, A))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
/* Check aliasing C and B */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong m, n, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, m);
|
||||
fmpz_poly_mat_init(B, m, n);
|
||||
fmpz_poly_mat_init(C, m, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits); /* noise in output */
|
||||
|
||||
fmpz_poly_mat_mul_KS(C, A, B);
|
||||
fmpz_poly_mat_mul_KS(B, A, B);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, B))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
178
external/flint-2.4.3/fmpz_poly_mat/test/t-mullow.c
vendored
Normal file
178
external/flint-2.4.3/fmpz_poly_mat/test/t-mullow.c
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("mullow....");
|
||||
fflush(stdout);
|
||||
|
||||
/* Compare with mul */
|
||||
for (i = 0; i < 30 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C, D;
|
||||
slong m, n, k, bits, deg, len;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
k = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
len = n_randint(state, 10);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, n, k);
|
||||
fmpz_poly_mat_init(C, m, k);
|
||||
fmpz_poly_mat_init(D, m, k);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits); /* noise in output */
|
||||
fmpz_poly_mat_randtest(D, state, deg, bits); /* noise in output */
|
||||
|
||||
fmpz_poly_mat_mullow(C, A, B, len);
|
||||
fmpz_poly_mat_mul(D, A, B);
|
||||
fmpz_poly_mat_truncate(D, len);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, D))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("D:\n");
|
||||
fmpz_poly_mat_print(D, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
fmpz_poly_mat_clear(D);
|
||||
}
|
||||
|
||||
/* Check aliasing C and A */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong m, n, bits, deg, len;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
len = n_randint(state, 10);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, n, n);
|
||||
fmpz_poly_mat_init(C, m, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits); /* noise in output */
|
||||
|
||||
fmpz_poly_mat_mullow(C, A, B, len);
|
||||
fmpz_poly_mat_mullow(A, A, B, len);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, A))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
/* Check aliasing C and B */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong m, n, bits, deg, len;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
len = n_randint(state, 10);
|
||||
|
||||
fmpz_poly_mat_init(A, m, m);
|
||||
fmpz_poly_mat_init(B, m, n);
|
||||
fmpz_poly_mat_init(C, m, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits); /* noise in output */
|
||||
|
||||
fmpz_poly_mat_mullow(C, A, B, len);
|
||||
fmpz_poly_mat_mullow(B, A, B, len);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, B))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
134
external/flint-2.4.3/fmpz_poly_mat/test/t-neg.c
vendored
Normal file
134
external/flint-2.4.3/fmpz_poly_mat/test/t-neg.c
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("neg....");
|
||||
fflush(stdout);
|
||||
|
||||
/* Check evaluation homomorphism */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B;
|
||||
fmpz_mat_t a, b, c;
|
||||
fmpz_t x;
|
||||
slong m, n, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, m, n);
|
||||
|
||||
fmpz_mat_init(a, m, n);
|
||||
fmpz_mat_init(b, m, n);
|
||||
fmpz_mat_init(c, m, n);
|
||||
|
||||
fmpz_init(x);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_neg(B, A);
|
||||
|
||||
fmpz_randtest(x, state, 1 + n_randint(state, 100));
|
||||
|
||||
fmpz_poly_mat_evaluate_fmpz(a, A, x);
|
||||
fmpz_poly_mat_evaluate_fmpz(b, B, x);
|
||||
fmpz_mat_neg(c, a);
|
||||
|
||||
if (!fmpz_mat_equal(b, c))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
|
||||
fmpz_mat_clear(a);
|
||||
fmpz_mat_clear(b);
|
||||
fmpz_mat_clear(c);
|
||||
|
||||
fmpz_clear(x);
|
||||
}
|
||||
|
||||
/* Check aliasing B and A */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B;
|
||||
slong m, n, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, m, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_neg(B, A);
|
||||
fmpz_poly_mat_neg(A, A);
|
||||
|
||||
if (!fmpz_poly_mat_equal(B, A))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
101
external/flint-2.4.3/fmpz_poly_mat/test/t-nullspace.c
vendored
Normal file
101
external/flint-2.4.3/fmpz_poly_mat/test/t-nullspace.c
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("nullspace....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, N, AN;
|
||||
slong n, m, bits, deg, rank, nullity;
|
||||
float density;
|
||||
|
||||
m = n_randint(state, 13);
|
||||
n = n_randint(state, 13);
|
||||
deg = 1 + n_randint(state, 5);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
density = n_randint(state, 100) * 0.01;
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(N, n, n);
|
||||
fmpz_poly_mat_init(AN, m, n);
|
||||
|
||||
fmpz_poly_mat_randtest_sparse(A, state, deg, bits, density);
|
||||
|
||||
rank = fmpz_poly_mat_rank(A);
|
||||
nullity = fmpz_poly_mat_nullspace(N, A);
|
||||
|
||||
if (nullity + rank != n)
|
||||
{
|
||||
flint_printf("FAIL: wrong nullity!\n");
|
||||
flint_printf("rank = %wd\n", rank);
|
||||
flint_printf("nullity = %wd\n", nullity);
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("\n");
|
||||
fmpz_poly_mat_print(N, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if (fmpz_poly_mat_rank(N) != nullity)
|
||||
{
|
||||
flint_printf("FAIL: wrong rank(N) != nullity!\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_mul(AN, A, N);
|
||||
|
||||
if (!fmpz_poly_mat_is_zero(AN))
|
||||
{
|
||||
flint_printf("FAIL: A * N != 0\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(N);
|
||||
fmpz_poly_mat_clear(AN);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
90
external/flint-2.4.3/fmpz_poly_mat/test/t-one.c
vendored
Normal file
90
external/flint-2.4.3/fmpz_poly_mat/test/t-one.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) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int iter;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("one/is_one....");
|
||||
fflush(stdout);
|
||||
|
||||
for (iter = 0; iter < 100 * flint_test_multiplier(); iter++)
|
||||
{
|
||||
fmpz_poly_mat_t A;
|
||||
slong m, n;
|
||||
|
||||
m = n_randint(state, 10);
|
||||
n = n_randint(state, 10);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_randtest(A, state, n_randint(state, 5),
|
||||
n_randint(state, 100));
|
||||
fmpz_poly_mat_one(A);
|
||||
|
||||
if (!fmpz_poly_mat_is_one(A))
|
||||
{
|
||||
flint_printf("FAIL: expected matrix to be one\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if (m > 0 && n > 0)
|
||||
{
|
||||
m = n_randint(state, m);
|
||||
n = n_randint(state, n);
|
||||
|
||||
if (m != n)
|
||||
fmpz_poly_randtest_not_zero(fmpz_poly_mat_entry(A, m, n),
|
||||
state, 5, 5);
|
||||
else
|
||||
do { fmpz_poly_randtest_not_zero(fmpz_poly_mat_entry(A, m, n),
|
||||
state, 5, 5); }
|
||||
while (fmpz_poly_is_one(fmpz_poly_mat_entry(A, m, n)));
|
||||
|
||||
if (fmpz_poly_mat_is_one(A))
|
||||
{
|
||||
flint_printf("FAIL: expected matrix not to be one\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
124
external/flint-2.4.3/fmpz_poly_mat/test/t-pow.c
vendored
Normal file
124
external/flint-2.4.3/fmpz_poly_mat/test/t-pow.c
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("pow....");
|
||||
fflush(stdout);
|
||||
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong m, j, exp, bits, deg;
|
||||
|
||||
m = n_randint(state, 6);
|
||||
deg = 1 + n_randint(state, 6);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
exp = n_randint(state, 20);
|
||||
|
||||
fmpz_poly_mat_init(A, m, m);
|
||||
fmpz_poly_mat_init(B, m, m);
|
||||
fmpz_poly_mat_init(C, m, m);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_pow(B, A, exp);
|
||||
|
||||
fmpz_poly_mat_one(C);
|
||||
for (j = 0; j < exp; j++)
|
||||
fmpz_poly_mat_mul(C, C, A);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, B))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("exp = %wd\n", exp);
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
/* Check aliasing B and A */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B;
|
||||
slong m, exp, bits, deg;
|
||||
|
||||
m = n_randint(state, 6);
|
||||
deg = 1 + n_randint(state, 6);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
exp = n_randint(state, 20);
|
||||
|
||||
fmpz_poly_mat_init(A, m, m);
|
||||
fmpz_poly_mat_init(B, m, m);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_pow(B, A, exp);
|
||||
fmpz_poly_mat_pow(A, A, exp);
|
||||
|
||||
if (!fmpz_poly_mat_equal(A, B))
|
||||
{
|
||||
flint_printf("FAIL (aliasing)\n");
|
||||
flint_printf("exp = %wd\n", exp);
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
126
external/flint-2.4.3/fmpz_poly_mat/test/t-pow_trunc.c
vendored
Normal file
126
external/flint-2.4.3/fmpz_poly_mat/test/t-pow_trunc.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) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("pow_trunc....");
|
||||
fflush(stdout);
|
||||
|
||||
/* Compare with pow */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong n, exp, bits, deg, len;
|
||||
|
||||
n = n_randint(state, 10);
|
||||
exp = n_randint(state, 15);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
len = n_randint(state, 10);
|
||||
|
||||
fmpz_poly_mat_init(A, n, n);
|
||||
fmpz_poly_mat_init(B, n, n);
|
||||
fmpz_poly_mat_init(C, n, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits); /* noise in output */
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits); /* noise in output */
|
||||
|
||||
fmpz_poly_mat_pow_trunc(B, A, exp, len);
|
||||
fmpz_poly_mat_pow(C, A, exp);
|
||||
fmpz_poly_mat_truncate(C, len);
|
||||
|
||||
if (!fmpz_poly_mat_equal(B, C))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B;
|
||||
slong n, exp, bits, deg, len;
|
||||
|
||||
n = n_randint(state, 10);
|
||||
exp = n_randint(state, 15);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
len = n_randint(state, 10);
|
||||
|
||||
fmpz_poly_mat_init(A, n, n);
|
||||
fmpz_poly_mat_init(B, n, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_pow_trunc(B, A, exp, len);
|
||||
fmpz_poly_mat_pow_trunc(A, A, exp, len);
|
||||
|
||||
if (!fmpz_poly_mat_equal(B, A))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
94
external/flint-2.4.3/fmpz_poly_mat/test/t-prod.c
vendored
Normal file
94
external/flint-2.4.3/fmpz_poly_mat/test/t-prod.c
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("prod....");
|
||||
fflush(stdout);
|
||||
|
||||
for (i = 0; i < 50 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, *V;
|
||||
slong m, j, count, bits, deg;
|
||||
float density;
|
||||
|
||||
m = n_randint(state, 6);
|
||||
deg = 1 + n_randint(state, 6);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
count = n_randint(state, 20);
|
||||
density = n_randint(state, 100) * 0.01;
|
||||
|
||||
fmpz_poly_mat_init(A, m, m);
|
||||
fmpz_poly_mat_init(B, m, m);
|
||||
|
||||
V = flint_malloc(sizeof(fmpz_poly_mat_t) * count);
|
||||
for (j = 0; j < count; j++)
|
||||
{
|
||||
fmpz_poly_mat_init(V[j], m, m);
|
||||
fmpz_poly_mat_randtest_sparse(V[j], state, deg, bits, density);
|
||||
}
|
||||
|
||||
fmpz_poly_mat_prod(A, V, count);
|
||||
|
||||
fmpz_poly_mat_one(B);
|
||||
for (j = 0; j < count; j++)
|
||||
fmpz_poly_mat_mul(B, B, V[j]);
|
||||
|
||||
if (!fmpz_poly_mat_equal(A, B))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("count = %wd\n", count);
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
for (j = 0; j < count; j++)
|
||||
fmpz_poly_mat_clear(V[j]);
|
||||
flint_free(V);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
95
external/flint-2.4.3/fmpz_poly_mat/test/t-rank.c
vendored
Normal file
95
external/flint-2.4.3/fmpz_poly_mat/test/t-rank.c
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("rank....");
|
||||
fflush(stdout);
|
||||
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A;
|
||||
fmpz_mat_t Ax;
|
||||
fmpz_t x;
|
||||
slong j, m, n, bits, deg, rank, zrank;
|
||||
float density;
|
||||
|
||||
m = n_randint(state, 15);
|
||||
n = n_randint(state, 15);
|
||||
deg = 1 + n_randint(state, 5);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
density = n_randint(state, 100) * 0.01;
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_mat_init(Ax, m, n);
|
||||
fmpz_init(x);
|
||||
|
||||
fmpz_poly_mat_randtest_sparse(A, state, deg, bits, density);
|
||||
|
||||
/* Probabilistic rank computation */
|
||||
zrank = 0;
|
||||
for (j = 0; j < 5; j++)
|
||||
{
|
||||
slong r;
|
||||
fmpz_randbits(x, state, 15);
|
||||
fmpz_poly_mat_evaluate_fmpz(Ax, A, x);
|
||||
r = fmpz_mat_rank(Ax);
|
||||
zrank = FLINT_MAX(zrank, r);
|
||||
}
|
||||
|
||||
rank = fmpz_poly_mat_rank(A);
|
||||
|
||||
if (rank != zrank)
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("Computed rank: %wd (zrank = %wd)\n", rank, zrank);
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_clear(x);
|
||||
fmpz_mat_clear(Ax);
|
||||
fmpz_poly_mat_clear(A);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
179
external/flint-2.4.3/fmpz_poly_mat/test/t-rref.c
vendored
Normal file
179
external/flint-2.4.3/fmpz_poly_mat/test/t-rref.c
vendored
Normal file
@@ -0,0 +1,179 @@
|
||||
/*=============================================================================
|
||||
|
||||
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-2012 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmp.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
#include "perm.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
/* checks that the rref has the right form */
|
||||
int check_rref(const fmpz_poly_mat_t A, const fmpz_poly_t den, slong rank)
|
||||
{
|
||||
slong i, j, k, prev_pivot;
|
||||
|
||||
/* bottom should be zero */
|
||||
for (i = rank; i < A->r; i++)
|
||||
for (j = 0; j < A->c; j++)
|
||||
if (!fmpz_poly_is_zero(fmpz_poly_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
prev_pivot = -1;
|
||||
|
||||
for (i = 0; i < rank; i++)
|
||||
{
|
||||
for (j = 0; j < A->c; j++)
|
||||
{
|
||||
if (!fmpz_poly_is_zero(fmpz_poly_mat_entry(A, i, j)))
|
||||
{
|
||||
/* pivot should have a higher column index than previous */
|
||||
if (j <= prev_pivot)
|
||||
return 0;
|
||||
|
||||
/* column should be 0 ... 0 1 0 ... 0 */
|
||||
for (k = 0; k < rank; k++)
|
||||
{
|
||||
if (i == k && !fmpz_poly_equal(fmpz_poly_mat_entry(A, k, j), den))
|
||||
return 0;
|
||||
if (i != k && !fmpz_poly_is_zero(fmpz_poly_mat_entry(A, k, j)))
|
||||
return 0;
|
||||
}
|
||||
|
||||
prev_pivot = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong iter;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("rref....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
for (iter = 0; iter < 200 * flint_test_multiplier(); iter++)
|
||||
{
|
||||
fmpz_poly_mat_t A, R, B, R2;
|
||||
fmpz_poly_t den, c, den2;
|
||||
slong j, k, m, n, deg, bits, rank1, rank2;
|
||||
slong *perm;
|
||||
float density;
|
||||
int equal;
|
||||
|
||||
m = n_randint(state, 10);
|
||||
n = n_randint(state, 10);
|
||||
deg = 1 + n_randint(state, 5);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
density = n_randint(state, 100) * 0.01;
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(R, m, n);
|
||||
fmpz_poly_mat_init(B, 2 * m, n);
|
||||
fmpz_poly_mat_init(R2, 2 * m, n);
|
||||
|
||||
fmpz_poly_init(c);
|
||||
fmpz_poly_init(den);
|
||||
fmpz_poly_init(den2);
|
||||
|
||||
perm = _perm_init(2 * m);
|
||||
|
||||
fmpz_poly_mat_randtest_sparse(A, state, deg, bits, density);
|
||||
|
||||
rank1 = fmpz_poly_mat_rref(R, den, A);
|
||||
|
||||
check_rref(R, den, rank1);
|
||||
|
||||
/* Concatenate the original matrix with the rref, scramble the rows,
|
||||
and check that the rref is the same */
|
||||
_perm_randtest(perm, 2 * m, state);
|
||||
|
||||
for (j = 0; j < m; j++)
|
||||
{
|
||||
fmpz_poly_randtest_not_zero(c, state, deg, bits);
|
||||
for (k = 0; k < n; k++)
|
||||
fmpz_poly_mul(fmpz_poly_mat_entry(B, perm[j], k), fmpz_poly_mat_entry(A, j, k), c);
|
||||
}
|
||||
|
||||
for (j = 0; j < m; j++)
|
||||
{
|
||||
fmpz_poly_randtest_not_zero(c, state, deg, bits);
|
||||
for (k = 0; k < n; k++)
|
||||
fmpz_poly_mul(fmpz_poly_mat_entry(B, perm[m + j], k), fmpz_poly_mat_entry(R, j, k), c);
|
||||
}
|
||||
|
||||
rank2 = fmpz_poly_mat_rref(R2, den2, B);
|
||||
equal = (rank1 == rank2);
|
||||
|
||||
if (equal)
|
||||
{
|
||||
fmpz_poly_mat_scalar_mul_fmpz_poly(R, R, den2);
|
||||
fmpz_poly_mat_scalar_mul_fmpz_poly(R2, R2, den);
|
||||
|
||||
for (j = 0; j < rank2; j++)
|
||||
for (k = 0; k < n; k++)
|
||||
equal = equal &&
|
||||
fmpz_poly_equal(fmpz_poly_mat_entry(R, j, k), fmpz_poly_mat_entry(R2, j, k));
|
||||
for (j = rank2; j < 2 * rank2; j++)
|
||||
for (k = 0; k < n; k++)
|
||||
equal = equal && fmpz_poly_is_zero(fmpz_poly_mat_entry(R2, j, k));
|
||||
}
|
||||
|
||||
if (!equal)
|
||||
{
|
||||
flint_printf("FAIL (rank1 = %wd, rank2 = %wd)!\n", rank1, rank2);
|
||||
fmpz_poly_mat_print(A, "x"); flint_printf("\n\n");
|
||||
fmpz_poly_mat_print(R, "x"); flint_printf("\n\n");
|
||||
fmpz_poly_mat_print(R2, "x"); flint_printf("\n\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(c);
|
||||
fmpz_poly_clear(den);
|
||||
fmpz_poly_clear(den2);
|
||||
|
||||
_perm_clear(perm);
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(R);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(R2);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
141
external/flint-2.4.3/fmpz_poly_mat/test/t-solve_fflu.c
vendored
Normal file
141
external/flint-2.4.3/fmpz_poly_mat/test/t-solve_fflu.c
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("solve_fflu....");
|
||||
fflush(stdout);
|
||||
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, X, B, AX, Bden;
|
||||
fmpz_poly_t den, det;
|
||||
slong n, m, bits, deg;
|
||||
float density;
|
||||
int solved;
|
||||
|
||||
n = n_randint(state, 15);
|
||||
m = n_randint(state, 5);
|
||||
deg = 1 + n_randint(state, 5);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
density = n_randint(state, 100) * 0.01;
|
||||
|
||||
fmpz_poly_mat_init(A, n, n);
|
||||
fmpz_poly_mat_init(B, n, m);
|
||||
fmpz_poly_mat_init(X, n, m);
|
||||
fmpz_poly_mat_init(AX, n, m);
|
||||
fmpz_poly_mat_init(Bden, n, m);
|
||||
fmpz_poly_init(den);
|
||||
fmpz_poly_init(det);
|
||||
|
||||
fmpz_poly_mat_randtest_sparse(A, state, deg, bits, density);
|
||||
fmpz_poly_mat_randtest_sparse(B, state, deg, bits, density);
|
||||
|
||||
solved = fmpz_poly_mat_solve_fflu(X, den, A, B);
|
||||
fmpz_poly_mat_det_interpolate(det, A);
|
||||
|
||||
if (m == 0 || n == 0)
|
||||
{
|
||||
if (solved == 0)
|
||||
{
|
||||
flint_printf("FAIL: expected empty system to pass\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!fmpz_poly_equal(den, det))
|
||||
{
|
||||
fmpz_poly_neg(det, det);
|
||||
if (!fmpz_poly_equal(den, det))
|
||||
{
|
||||
fmpz_poly_neg(det, det);
|
||||
flint_printf("FAIL: den != +/- det(A)\n");
|
||||
flint_printf("den:\n"); fmpz_poly_print_pretty(den, "x");
|
||||
flint_printf("\n\n");
|
||||
flint_printf("det:\n"); fmpz_poly_print_pretty(det, "x");
|
||||
flint_printf("\n\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("X:\n");
|
||||
fmpz_poly_mat_print(X, "x");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (solved != !fmpz_poly_is_zero(den))
|
||||
{
|
||||
flint_printf("FAIL: return value does not match denominator\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_mul(AX, A, X);
|
||||
fmpz_poly_mat_scalar_mul_fmpz_poly(Bden, B, den);
|
||||
|
||||
if (!fmpz_poly_mat_equal(AX, Bden))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("X:\n");
|
||||
fmpz_poly_mat_print(X, "x");
|
||||
flint_printf("AX:\n");
|
||||
fmpz_poly_mat_print(AX, "x");
|
||||
flint_printf("Bden:\n");
|
||||
fmpz_poly_mat_print(Bden, "x");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_clear(den);
|
||||
fmpz_poly_clear(det);
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(X);
|
||||
fmpz_poly_mat_clear(AX);
|
||||
fmpz_poly_mat_clear(Bden);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
135
external/flint-2.4.3/fmpz_poly_mat/test/t-sqr.c
vendored
Normal file
135
external/flint-2.4.3/fmpz_poly_mat/test/t-sqr.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) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("sqr....");
|
||||
fflush(stdout);
|
||||
|
||||
/* Check evaluation homomorphism */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, C;
|
||||
fmpz_mat_t a, c, d;
|
||||
fmpz_t x;
|
||||
slong m, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, m);
|
||||
fmpz_poly_mat_init(C, m, m);
|
||||
|
||||
fmpz_mat_init(a, m, m);
|
||||
fmpz_mat_init(c, m, m);
|
||||
fmpz_mat_init(d, m, m);
|
||||
|
||||
fmpz_init(x);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_sqr(C, A);
|
||||
|
||||
fmpz_randtest(x, state, 1 + n_randint(state, 100));
|
||||
|
||||
fmpz_poly_mat_evaluate_fmpz(a, A, x);
|
||||
fmpz_poly_mat_evaluate_fmpz(d, C, x);
|
||||
fmpz_mat_mul(c, a, a);
|
||||
|
||||
if (!fmpz_mat_equal(c, d))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(C);
|
||||
|
||||
fmpz_mat_clear(a);
|
||||
fmpz_mat_clear(c);
|
||||
fmpz_mat_clear(d);
|
||||
|
||||
fmpz_clear(x);
|
||||
}
|
||||
|
||||
/* Check aliasing B and A */
|
||||
for (i = 0; i < 1000; i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B;
|
||||
slong m, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, m);
|
||||
fmpz_poly_mat_init(B, m, m);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_sqr(B, A);
|
||||
fmpz_poly_mat_sqr(A, A);
|
||||
|
||||
if (!fmpz_poly_mat_equal(B, A))
|
||||
{
|
||||
flint_printf("FAIL (aliasing):\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
123
external/flint-2.4.3/fmpz_poly_mat/test/t-sqr_KS.c
vendored
Normal file
123
external/flint-2.4.3/fmpz_poly_mat/test/t-sqr_KS.c
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("sqr_KS....");
|
||||
fflush(stdout);
|
||||
|
||||
for (i = 0; i < 200 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, C, D;
|
||||
slong m, bits, deg;
|
||||
|
||||
/* TODO: add separate unsigned tests */
|
||||
m = n_randint(state, 15);
|
||||
deg = 1 + n_randint(state, 15);
|
||||
bits = 1 + n_randint(state, 150);
|
||||
|
||||
fmpz_poly_mat_init(A, m, m);
|
||||
fmpz_poly_mat_init(C, m, m);
|
||||
fmpz_poly_mat_init(D, m, m);
|
||||
|
||||
if (n_randint(state, 2))
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
else
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits); /* noise in output */
|
||||
|
||||
fmpz_poly_mat_sqr_classical(C, A);
|
||||
fmpz_poly_mat_sqr_KS(D, A);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, D))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("products don't agree!\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("D:\n");
|
||||
fmpz_poly_mat_print(D, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(C);
|
||||
fmpz_poly_mat_clear(D);
|
||||
}
|
||||
|
||||
/* Check aliasing B and A */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B;
|
||||
slong m, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, m);
|
||||
fmpz_poly_mat_init(B, m, m);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_sqr_KS(B, A);
|
||||
fmpz_poly_mat_sqr_KS(A, A);
|
||||
|
||||
if (!fmpz_poly_mat_equal(B, A))
|
||||
{
|
||||
flint_printf("FAIL (aliasing):\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
124
external/flint-2.4.3/fmpz_poly_mat/test/t-sqrlow.c
vendored
Normal file
124
external/flint-2.4.3/fmpz_poly_mat/test/t-sqrlow.c
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("sqrlow....");
|
||||
fflush(stdout);
|
||||
|
||||
/* Compare with sqr */
|
||||
for (i = 0; i < 30 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong n, bits, deg, len;
|
||||
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
len = n_randint(state, 10);
|
||||
|
||||
fmpz_poly_mat_init(A, n, n);
|
||||
fmpz_poly_mat_init(B, n, n);
|
||||
fmpz_poly_mat_init(C, n, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits); /* noise in output */
|
||||
fmpz_poly_mat_randtest(C, state, deg, bits); /* noise in output */
|
||||
|
||||
fmpz_poly_mat_sqrlow(B, A, len);
|
||||
fmpz_poly_mat_sqr(C, A);
|
||||
fmpz_poly_mat_truncate(C, len);
|
||||
|
||||
if (!fmpz_poly_mat_equal(B, C))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
/* Check aliasing */
|
||||
for (i = 0; i < 10 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B;
|
||||
slong n, bits, deg, len;
|
||||
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
len = n_randint(state, 10);
|
||||
|
||||
fmpz_poly_mat_init(A, n, n);
|
||||
fmpz_poly_mat_init(B, n, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_sqrlow(B, A, len);
|
||||
fmpz_poly_mat_sqrlow(A, A, len);
|
||||
|
||||
if (!fmpz_poly_mat_equal(B, A))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
186
external/flint-2.4.3/fmpz_poly_mat/test/t-sub.c
vendored
Normal file
186
external/flint-2.4.3/fmpz_poly_mat/test/t-sub.c
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("sub....");
|
||||
fflush(stdout);
|
||||
|
||||
/* Check evaluation homomorphism */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
fmpz_mat_t a, b, c, d;
|
||||
fmpz_t x;
|
||||
slong m, n, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, m, n);
|
||||
fmpz_poly_mat_init(C, m, n);
|
||||
|
||||
fmpz_mat_init(a, m, n);
|
||||
fmpz_mat_init(b, m, n);
|
||||
fmpz_mat_init(c, m, n);
|
||||
fmpz_mat_init(d, m, n);
|
||||
|
||||
fmpz_init(x);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
fmpz_poly_mat_sub(C, A, B);
|
||||
|
||||
fmpz_randtest(x, state, 1 + n_randint(state, 100));
|
||||
|
||||
fmpz_poly_mat_evaluate_fmpz(a, A, x);
|
||||
fmpz_poly_mat_evaluate_fmpz(b, B, x);
|
||||
fmpz_poly_mat_evaluate_fmpz(d, C, x);
|
||||
fmpz_mat_sub(c, a, b);
|
||||
|
||||
if (!fmpz_mat_equal(c, d))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
|
||||
fmpz_mat_clear(a);
|
||||
fmpz_mat_clear(b);
|
||||
fmpz_mat_clear(c);
|
||||
fmpz_mat_clear(d);
|
||||
|
||||
fmpz_clear(x);
|
||||
}
|
||||
|
||||
/* Check aliasing C and A */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong m, n, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, m, n);
|
||||
fmpz_poly_mat_init(C, m, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_sub(C, A, B);
|
||||
fmpz_poly_mat_sub(A, A, B);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, A))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
/* Check aliasing C and B */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, C;
|
||||
slong m, n, bits, deg;
|
||||
|
||||
m = n_randint(state, 20);
|
||||
n = n_randint(state, 20);
|
||||
deg = 1 + n_randint(state, 10);
|
||||
bits = 1 + n_randint(state, 100);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, m, n);
|
||||
fmpz_poly_mat_init(C, m, n);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, deg, bits);
|
||||
fmpz_poly_mat_randtest(B, state, deg, bits);
|
||||
|
||||
fmpz_poly_mat_sub(C, A, B);
|
||||
fmpz_poly_mat_sub(B, A, B);
|
||||
|
||||
if (!fmpz_poly_mat_equal(C, B))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
flint_printf("A:\n");
|
||||
fmpz_poly_mat_print(A, "x");
|
||||
flint_printf("B:\n");
|
||||
fmpz_poly_mat_print(B, "x");
|
||||
flint_printf("C:\n");
|
||||
fmpz_poly_mat_print(C, "x");
|
||||
flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(C);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
99
external/flint-2.4.3/fmpz_poly_mat/test/t-trace.c
vendored
Normal file
99
external/flint-2.4.3/fmpz_poly_mat/test/t-trace.c
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "fmpz_poly_mat.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
slong i;
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("trace....");
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
|
||||
/* Test trace(AB) = trace(BA) */
|
||||
for (i = 0; i < 100 * flint_test_multiplier(); i++)
|
||||
{
|
||||
fmpz_poly_mat_t A, B, AB, BA;
|
||||
fmpz_poly_t trab, trba;
|
||||
slong m, n;
|
||||
|
||||
m = n_randint(state, 10);
|
||||
n = n_randint(state, 10);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_init(B, n, m);
|
||||
fmpz_poly_mat_init(AB, m, m);
|
||||
fmpz_poly_mat_init(BA, n, n);
|
||||
|
||||
fmpz_poly_init(trab);
|
||||
fmpz_poly_init(trba);
|
||||
|
||||
fmpz_poly_mat_randtest(A, state, 1 + n_randint(state, 10),
|
||||
1 + n_randint(state, 100));
|
||||
fmpz_poly_mat_randtest(B, state, 1 + n_randint(state, 10),
|
||||
1 + n_randint(state, 100));
|
||||
|
||||
fmpz_poly_mat_mul(AB, A, B);
|
||||
fmpz_poly_mat_mul(BA, B, A);
|
||||
|
||||
fmpz_poly_mat_trace(trab, AB);
|
||||
fmpz_poly_mat_trace(trba, BA);
|
||||
|
||||
if (!fmpz_poly_equal(trab, trba))
|
||||
{
|
||||
flint_printf("FAIL:\n");
|
||||
fmpz_poly_mat_print(A, "x"), flint_printf("\n");
|
||||
fmpz_poly_mat_print(B, "x"), flint_printf("\n");
|
||||
fmpz_poly_mat_print(AB, "x"), flint_printf("\n");
|
||||
fmpz_poly_mat_print(BA, "x"), flint_printf("\n");
|
||||
flint_printf("tr(AB): "), fmpz_poly_print(trab), flint_printf("\n");
|
||||
flint_printf("tr(BA): "), fmpz_poly_print(trba), flint_printf("\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
fmpz_poly_mat_clear(B);
|
||||
fmpz_poly_mat_clear(AB);
|
||||
fmpz_poly_mat_clear(BA);
|
||||
fmpz_poly_clear(trab);
|
||||
fmpz_poly_clear(trba);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
84
external/flint-2.4.3/fmpz_poly_mat/test/t-zero.c
vendored
Normal file
84
external/flint-2.4.3/fmpz_poly_mat/test/t-zero.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) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int iter;
|
||||
|
||||
FLINT_TEST_INIT(state);
|
||||
|
||||
flint_printf("zero/is_zero....");
|
||||
fflush(stdout);
|
||||
|
||||
for (iter = 0; iter < 100 * flint_test_multiplier(); iter++)
|
||||
{
|
||||
fmpz_poly_mat_t A;
|
||||
slong m, n;
|
||||
|
||||
m = n_randint(state, 10);
|
||||
n = n_randint(state, 10);
|
||||
|
||||
fmpz_poly_mat_init(A, m, n);
|
||||
fmpz_poly_mat_randtest(A, state, n_randint(state, 5),
|
||||
n_randint(state, 100));
|
||||
fmpz_poly_mat_zero(A);
|
||||
|
||||
if (!fmpz_poly_mat_is_zero(A))
|
||||
{
|
||||
flint_printf("FAIL: expected matrix to be zero\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if (m > 0 && n > 0)
|
||||
{
|
||||
m = n_randint(state, m);
|
||||
n = n_randint(state, n);
|
||||
fmpz_poly_randtest_not_zero(fmpz_poly_mat_entry(A, m, n),
|
||||
state, 5, 5);
|
||||
|
||||
if (fmpz_poly_mat_is_zero(A))
|
||||
{
|
||||
flint_printf("FAIL: expected matrix not to be zero\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_poly_mat_clear(A);
|
||||
}
|
||||
|
||||
FLINT_TEST_CLEANUP(state);
|
||||
|
||||
flint_printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user