ALL: Add flint
This commit is contained in:
42
external/flint-2.4.3/fmpz_poly_mat/add.c
vendored
Normal file
42
external/flint-2.4.3/fmpz_poly_mat/add.c
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_add(fmpz_poly_mat_t C,
|
||||
const fmpz_poly_mat_t A, const fmpz_poly_mat_t B)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
for (j = 0; j < A->c; j++)
|
||||
fmpz_poly_add(fmpz_poly_mat_entry(C, i, j),
|
||||
fmpz_poly_mat_entry(A, i, j),
|
||||
fmpz_poly_mat_entry(B, i, j));
|
||||
}
|
||||
44
external/flint-2.4.3/fmpz_poly_mat/clear.c
vendored
Normal file
44
external/flint-2.4.3/fmpz_poly_mat/clear.c
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_clear(fmpz_poly_mat_t A)
|
||||
{
|
||||
if (A->entries)
|
||||
{
|
||||
slong i;
|
||||
|
||||
for (i = 0; i < A->r * A->c; i++)
|
||||
fmpz_poly_clear(A->entries + i);
|
||||
|
||||
flint_free(A->entries);
|
||||
flint_free(A->rows);
|
||||
}
|
||||
}
|
||||
63
external/flint-2.4.3/fmpz_poly_mat/det.c
vendored
Normal file
63
external/flint-2.4.3/fmpz_poly_mat/det.c
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_det(fmpz_poly_t det, const fmpz_poly_mat_t A)
|
||||
{
|
||||
slong n = A->r;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
fmpz_poly_set_ui(det, UWORD(1));
|
||||
}
|
||||
else if (n == 1)
|
||||
{
|
||||
fmpz_poly_set(det, fmpz_poly_mat_entry(A, 0, 0));
|
||||
}
|
||||
else if (n == 2)
|
||||
{
|
||||
fmpz_poly_t tmp;
|
||||
fmpz_poly_init(tmp);
|
||||
fmpz_poly_mul(det, fmpz_poly_mat_entry(A, 0, 0),
|
||||
fmpz_poly_mat_entry(A, 1, 1));
|
||||
fmpz_poly_mul(tmp, fmpz_poly_mat_entry(A, 0, 1),
|
||||
fmpz_poly_mat_entry(A, 1, 0));
|
||||
fmpz_poly_sub(det, det, tmp);
|
||||
fmpz_poly_clear(tmp);
|
||||
}
|
||||
else if (n < 15) /* should be entry sensitive too */
|
||||
{
|
||||
fmpz_poly_mat_det_fflu(det, A);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_poly_mat_det_interpolate(det, A);
|
||||
}
|
||||
}
|
||||
53
external/flint-2.4.3/fmpz_poly_mat/det_fflu.c
vendored
Normal file
53
external/flint-2.4.3/fmpz_poly_mat/det_fflu.c
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
#include "perm.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_det_fflu(fmpz_poly_t det, const fmpz_poly_mat_t A)
|
||||
{
|
||||
slong n = fmpz_poly_mat_nrows(A);
|
||||
|
||||
if (n == 0)
|
||||
fmpz_poly_one(det);
|
||||
else
|
||||
{
|
||||
fmpz_poly_mat_t tmp;
|
||||
slong * perm;
|
||||
fmpz_poly_mat_init_set(tmp, A);
|
||||
perm = _perm_init(n);
|
||||
|
||||
fmpz_poly_mat_fflu(tmp, det, perm, tmp, 1);
|
||||
if (_perm_parity(perm, n))
|
||||
fmpz_poly_neg(det, det);
|
||||
|
||||
_perm_clear(perm);
|
||||
fmpz_poly_mat_clear(tmp);
|
||||
}
|
||||
}
|
||||
75
external/flint-2.4.3/fmpz_poly_mat/det_interpolate.c
vendored
Normal file
75
external/flint-2.4.3/fmpz_poly_mat/det_interpolate.c
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_det_interpolate(fmpz_poly_t det, const fmpz_poly_mat_t A)
|
||||
{
|
||||
slong i, l, n, len;
|
||||
|
||||
fmpz_mat_t X;
|
||||
fmpz * x;
|
||||
fmpz * d;
|
||||
|
||||
n = A->r;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
fmpz_poly_one(det);
|
||||
return;
|
||||
}
|
||||
|
||||
l = fmpz_poly_mat_max_length(A);
|
||||
|
||||
if (l == 0)
|
||||
{
|
||||
fmpz_poly_zero(det);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Bound degree based on Laplace expansion */
|
||||
len = n*(l - 1) + 1;
|
||||
|
||||
x = _fmpz_vec_init(len);
|
||||
d = _fmpz_vec_init(len);
|
||||
fmpz_mat_init(X, n, n);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
fmpz_set_si(x + i, -len/2 + i);
|
||||
fmpz_poly_mat_evaluate_fmpz(X, A, x + i);
|
||||
fmpz_mat_det(d + i, X);
|
||||
}
|
||||
|
||||
fmpz_poly_interpolate_fmpz_vec(det, x, d, len);
|
||||
|
||||
_fmpz_vec_clear(x, len);
|
||||
_fmpz_vec_clear(d, len);
|
||||
fmpz_mat_clear(X);
|
||||
}
|
||||
500
external/flint-2.4.3/fmpz_poly_mat/doc/fmpz_poly_mat.txt
vendored
Normal file
500
external/flint-2.4.3/fmpz_poly_mat/doc/fmpz_poly_mat.txt
vendored
Normal file
@@ -0,0 +1,500 @@
|
||||
/*=============================================================================
|
||||
|
||||
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
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Memory management
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
void fmpz_poly_mat_init(fmpz_poly_mat_t mat, slong rows, slong cols)
|
||||
|
||||
Initialises a matrix with the given number of rows and columns for use.
|
||||
|
||||
void fmpz_poly_mat_init_set(fmpz_poly_mat_t mat, const fmpz_poly_mat_t src)
|
||||
|
||||
Initialises a matrix \code{mat} of the same dimensions as \code{src},
|
||||
and sets it to a copy of \code{src}.
|
||||
|
||||
void fmpz_poly_mat_clear(fmpz_poly_mat_t mat)
|
||||
|
||||
Frees all memory associated with the matrix. The matrix must be
|
||||
reinitialised if it is to be used again.
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Basic properties
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
slong fmpz_poly_mat_nrows(const fmpz_poly_mat_t mat)
|
||||
|
||||
Returns the number of rows in \code{mat}.
|
||||
|
||||
slong fmpz_poly_mat_ncols(const fmpz_poly_mat_t mat)
|
||||
|
||||
Returns the number of columns in \code{mat}.
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Basic assignment and manipulation
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
MACRO fmpz_poly_mat_entry(mat,i,j)
|
||||
|
||||
Gives a reference to the entry at row \code{i} and column \code{j}.
|
||||
The reference can be passed as an input or output variable to any
|
||||
\code{fmpz_poly} function for direct manipulation of the matrix element.
|
||||
No bounds checking is performed.
|
||||
|
||||
void fmpz_poly_mat_set(fmpz_poly_mat_t mat1, const fmpz_poly_mat_t mat2)
|
||||
|
||||
Sets \code{mat1} to a copy of \code{mat2}.
|
||||
|
||||
void fmpz_poly_mat_swap(fmpz_poly_mat_t mat1, fmpz_poly_mat_t mat2)
|
||||
|
||||
Swaps \code{mat1} and \code{mat2} efficiently.
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Input and output
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
void fmpz_poly_mat_print(const fmpz_poly_mat_t mat, const char * x)
|
||||
|
||||
Prints the matrix \code{mat} to standard output, using the
|
||||
variable \code{x}.
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Random matrix generation
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
void fmpz_poly_mat_randtest(fmpz_poly_mat_t mat, flint_rand_t state,
|
||||
slong len, mp_bitcnt_t bits)
|
||||
|
||||
This is equivalent to applying \code{fmpz_poly_randtest} to all entries
|
||||
in the matrix.
|
||||
|
||||
void fmpz_poly_mat_randtest_unsigned(fmpz_poly_mat_t mat, flint_rand_t state,
|
||||
slong len, mp_bitcnt_t bits)
|
||||
|
||||
This is equivalent to applying \code{fmpz_poly_randtest_unsigned} to
|
||||
all entries in the matrix.
|
||||
|
||||
void fmpz_poly_mat_randtest_sparse(fmpz_poly_mat_t A, flint_rand_t state,
|
||||
slong len, mp_bitcnt_t bits, float density)
|
||||
|
||||
Creates a random matrix with the amount of nonzero entries given
|
||||
approximately by the \code{density} variable, which should be a fraction
|
||||
between 0 (most sparse) and 1 (most dense).
|
||||
|
||||
The nonzero entries will have random lengths between 1 and \code{len}.
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Special matrices
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
void fmpz_poly_mat_zero(fmpz_poly_mat_t mat)
|
||||
|
||||
Sets \code{mat} to the zero matrix.
|
||||
|
||||
void fmpz_poly_mat_one(fmpz_poly_mat_t mat)
|
||||
|
||||
Sets \code{mat} to the unit or identity matrix of given shape,
|
||||
having the element 1 on the main diagonal and zeros elsewhere.
|
||||
If \code{mat} is nonsquare, it is set to the truncation of a unit matrix.
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Basic comparison and properties
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
int fmpz_poly_mat_equal(const fmpz_poly_mat_t mat1, const fmpz_poly_mat_t mat2)
|
||||
|
||||
Returns nonzero if \code{mat1} and \code{mat2} have the same shape and
|
||||
all their entries agree, and returns zero otherwise.
|
||||
|
||||
int fmpz_poly_mat_is_zero(const fmpz_poly_mat_t mat)
|
||||
|
||||
Returns nonzero if all entries in \code{mat} are zero, and returns
|
||||
zero otherwise.
|
||||
|
||||
int fmpz_poly_mat_is_one(const fmpz_poly_mat_t mat)
|
||||
|
||||
Returns nonzero if all entry of \code{mat} on the main diagonal
|
||||
are the constant polynomial 1 and all remaining entries are zero,
|
||||
and returns zero otherwise. The matrix need not be square.
|
||||
|
||||
int fmpz_poly_mat_is_empty(const fmpz_poly_mat_t mat)
|
||||
|
||||
Returns a non-zero value if the number of rows or the number of
|
||||
columns in \code{mat} is zero, and otherwise returns
|
||||
zero.
|
||||
|
||||
int fmpz_poly_mat_is_square(const fmpz_poly_mat_t mat)
|
||||
|
||||
Returns a non-zero value if the number of rows is equal to the
|
||||
number of columns in \code{mat}, and otherwise returns zero.
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Norms
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
slong fmpz_poly_mat_max_bits(const fmpz_poly_mat_t A)
|
||||
|
||||
Returns the maximum number of bits among the coefficients of the
|
||||
entries in \code{A}, or the negative of that value if any
|
||||
coefficient is negative.
|
||||
|
||||
slong fmpz_poly_mat_max_length(const fmpz_poly_mat_t A)
|
||||
|
||||
Returns the maximum polynomial length among all the entries in \code{A}.
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Transpose
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
void fmpz_poly_mat_transpose(fmpz_poly_mat_t B, const fmpz_poly_mat_t A)
|
||||
|
||||
Sets $B$ to $A^t$.
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Evaluation
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
void fmpz_poly_mat_evaluate_fmpz(fmpz_mat_t B, const fmpz_poly_mat_t A,
|
||||
const fmpz_t x)
|
||||
|
||||
Sets the \code{fmpz_mat_t} \code{B} to \code{A} evaluated entrywise
|
||||
at the point \code{x}.
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Arithmetic
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
void fmpz_poly_mat_scalar_mul_fmpz_poly(fmpz_poly_mat_t B,
|
||||
const fmpz_poly_mat_t A, const fmpz_poly_t c)
|
||||
|
||||
Sets \code{B} to \code{A} multiplied entrywise by the polynomial \code{c}.
|
||||
|
||||
void fmpz_poly_mat_scalar_mul_fmpz(fmpz_poly_mat_t B,
|
||||
const fmpz_poly_mat_t A, const fmpz_t c)
|
||||
|
||||
Sets \code{B} to \code{A} multiplied entrywise by the integer \code{c}.
|
||||
|
||||
void fmpz_poly_mat_add(fmpz_poly_mat_t C, const fmpz_poly_mat_t A,
|
||||
const fmpz_poly_mat_t B)
|
||||
|
||||
Sets \code{C} to the sum of \code{A} and \code{B}.
|
||||
All matrices must have the same shape. Aliasing is allowed.
|
||||
|
||||
void fmpz_poly_mat_sub(fmpz_poly_mat_t C, const fmpz_poly_mat_t A,
|
||||
const fmpz_poly_mat_t B)
|
||||
|
||||
Sets \code{C} to the sum of \code{A} and \code{B}.
|
||||
All matrices must have the same shape. Aliasing is allowed.
|
||||
|
||||
void fmpz_poly_mat_neg(fmpz_poly_mat_t B, const fmpz_poly_mat_t A)
|
||||
|
||||
Sets \code{B} to the negation of \code{A}.
|
||||
The matrices must have the same shape. Aliasing is allowed.
|
||||
|
||||
void fmpz_poly_mat_mul(fmpz_poly_mat_t C, const fmpz_poly_mat_t A,
|
||||
const fmpz_poly_mat_t B)
|
||||
|
||||
Sets \code{C} to the matrix product of \code{A} and \code{B}.
|
||||
The matrices must have compatible dimensions for matrix multiplication.
|
||||
Aliasing is allowed. This function automatically chooses between
|
||||
classical and KS multiplication.
|
||||
|
||||
void fmpz_poly_mat_mul_classical(fmpz_poly_mat_t C, const fmpz_poly_mat_t A,
|
||||
const fmpz_poly_mat_t B)
|
||||
|
||||
Sets \code{C} to the matrix product of \code{A} and \code{B},
|
||||
computed using the classical algorithm. The matrices must have
|
||||
compatible dimensions for matrix multiplication. Aliasing is allowed.
|
||||
|
||||
void fmpz_poly_mat_mul_KS(fmpz_poly_mat_t C, const fmpz_poly_mat_t A,
|
||||
const fmpz_poly_mat_t B)
|
||||
|
||||
Sets \code{C} to the matrix product of \code{A} and \code{B},
|
||||
computed using Kronecker segmentation. The matrices must have
|
||||
compatible dimensions for matrix multiplication. Aliasing is allowed.
|
||||
|
||||
void fmpz_poly_mat_mullow(fmpz_poly_mat_t C, const fmpz_poly_mat_t A,
|
||||
const fmpz_poly_mat_t B, slong len)
|
||||
|
||||
Sets \code{C} to the matrix product of \code{A} and \code{B},
|
||||
truncating each entry in the result to length \code{len}.
|
||||
Uses classical matrix multiplication. The matrices must have
|
||||
compatible dimensions for matrix multiplication. Aliasing is allowed.
|
||||
|
||||
void fmpz_poly_mat_sqr(fmpz_poly_mat_t B, const fmpz_poly_mat_t A)
|
||||
|
||||
Sets \code{B} to the square of \code{A}, which must be a square matrix.
|
||||
Aliasing is allowed. This function automatically chooses between
|
||||
classical and KS squaring.
|
||||
|
||||
void fmpz_poly_mat_sqr_classical(fmpz_poly_mat_t B, const fmpz_poly_mat_t A)
|
||||
|
||||
Sets \code{B} to the square of \code{A}, which must be a square matrix.
|
||||
Aliasing is allowed. This function uses direct formulas for very small
|
||||
matrices, and otherwise classical matrix multiplication.
|
||||
|
||||
void fmpz_poly_mat_sqr_KS(fmpz_poly_mat_t B, const fmpz_poly_mat_t A)
|
||||
|
||||
Sets \code{B} to the square of \code{A}, which must be a square matrix.
|
||||
Aliasing is allowed. This function uses Kronecker segmentation.
|
||||
|
||||
void fmpz_poly_mat_sqrlow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A,
|
||||
slong len)
|
||||
|
||||
Sets \code{B} to the square of \code{A}, which must be a square matrix,
|
||||
truncating all entries to length \code{len}.
|
||||
Aliasing is allowed. This function uses direct formulas for very small
|
||||
matrices, and otherwise classical matrix multiplication.
|
||||
|
||||
void fmpz_poly_mat_pow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, ulong exp)
|
||||
|
||||
Sets \code{B} to \code{A} raised to the power \code{exp}, where \code{A}
|
||||
is a square matrix. Uses exponentiation by squaring. Aliasing is allowed.
|
||||
|
||||
void
|
||||
fmpz_poly_mat_pow_trunc(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, ulong exp,
|
||||
slong len)
|
||||
|
||||
Sets \code{B} to \code{A} raised to the power \code{exp}, truncating
|
||||
all entries to length \code{len}, where \code{A} is a square matrix.
|
||||
Uses exponentiation by squaring. Aliasing is allowed.
|
||||
|
||||
void fmpz_poly_mat_prod(fmpz_poly_mat_t res,
|
||||
fmpz_poly_mat_t * const factors, slong n)
|
||||
|
||||
Sets \code{res} to the product of the \code{n} matrices given in
|
||||
the vector \code{factors}, all of which must be square and of the
|
||||
same size. Uses binary splitting.
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Row reduction
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
slong fmpz_poly_mat_find_pivot_any(const fmpz_poly_mat_t mat,
|
||||
slong start_row, slong end_row, slong c)
|
||||
|
||||
Attempts to find a pivot entry for row reduction.
|
||||
Returns a row index $r$ between \code{start_row} (inclusive) and
|
||||
\code{stop_row} (exclusive) such that column $c$ in \code{mat} has
|
||||
a nonzero entry on row $r$, or returns -1 if no such entry exists.
|
||||
|
||||
This implementation simply chooses the first nonzero entry from
|
||||
it encounters. This is likely to be a nearly optimal choice if all
|
||||
entries in the matrix have roughly the same size, but can lead to
|
||||
unnecessary coefficient growth if the entries vary in size.
|
||||
|
||||
slong fmpz_poly_mat_find_pivot_partial(const fmpz_poly_mat_t mat,
|
||||
slong start_row, slong end_row, slong c)
|
||||
|
||||
Attempts to find a pivot entry for row reduction.
|
||||
Returns a row index $r$ between \code{start_row} (inclusive) and
|
||||
\code{stop_row} (exclusive) such that column $c$ in \code{mat} has
|
||||
a nonzero entry on row $r$, or returns -1 if no such entry exists.
|
||||
|
||||
This implementation searches all the rows in the column and
|
||||
chooses the nonzero entry of smallest degree. If there are several
|
||||
entries with the same minimal degree, it chooses the entry with
|
||||
the smallest coefficient bit bound. This heuristic typically reduces
|
||||
coefficient growth when the matrix entries vary in size.
|
||||
|
||||
slong fmpz_poly_mat_fflu(fmpz_poly_mat_t B, fmpz_poly_t den, slong * perm,
|
||||
const fmpz_poly_mat_t A, int rank_check)
|
||||
|
||||
Uses fraction-free Gaussian elimination to set (\code{B}, \code{den}) to a
|
||||
fraction-free LU decomposition of \code{A} and returns the
|
||||
rank of \code{A}. Aliasing of \code{A} and \code{B} is allowed.
|
||||
|
||||
Pivot elements are chosen with \code{fmpz_poly_mat_find_pivot_partial}.
|
||||
If \code{perm} is non-\code{NULL}, the permutation of
|
||||
rows in the matrix will also be applied to \code{perm}.
|
||||
|
||||
If \code{rank_check} is set, the function aborts and returns 0 if the
|
||||
matrix is detected not to have full rank without completing the
|
||||
elimination.
|
||||
|
||||
The denominator \code{den} is set to $\pm \operatorname{det}(A)$, where
|
||||
the sign is decided by the parity of the permutation. Note that the
|
||||
determinant is not generally the minimal denominator.
|
||||
|
||||
slong fmpz_poly_mat_rref(fmpz_poly_mat_t B, fmpz_poly_t den,
|
||||
const fmpz_poly_mat_t A)
|
||||
|
||||
Sets (\code{B}, \code{den}) to the reduced row echelon form of
|
||||
\code{A} and returns the rank of \code{A}. Aliasing of \code{A} and
|
||||
\code{B} is allowed.
|
||||
|
||||
The denominator \code{den} is set to $\pm \operatorname{det}(A)$.
|
||||
Note that the determinant is not generally the minimal denominator.
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Trace
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
void fmpz_poly_mat_trace(fmpz_poly_t trace, const fmpz_poly_mat_t mat)
|
||||
|
||||
Computes the trace of the matrix, i.e. the sum of the entries on
|
||||
the main diagonal. The matrix is required to be square.
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Determinant and rank
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
void fmpz_poly_mat_det(fmpz_poly_t det, const fmpz_poly_mat_t A)
|
||||
|
||||
Sets \code{det} to the determinant of the square matrix \code{A}. Uses
|
||||
a direct formula, fraction-free LU decomposition, or interpolation,
|
||||
depending on the size of the matrix.
|
||||
|
||||
void fmpz_poly_mat_det_fflu(fmpz_poly_t det, const fmpz_poly_mat_t A)
|
||||
|
||||
Sets \code{det} to the determinant of the square matrix \code{A}.
|
||||
The determinant is computed by performing a fraction-free LU
|
||||
decomposition on a copy of \code{A}.
|
||||
|
||||
void fmpz_poly_mat_det_interpolate(fmpz_poly_t det, const fmpz_poly_mat_t A)
|
||||
|
||||
Sets \code{det} to the determinant of the square matrix \code{A}.
|
||||
The determinant is computed by determing a bound $n$ for its length,
|
||||
evaluating the matrix at $n$ distinct points, computing the determinant
|
||||
of each integer matrix, and forming the interpolating polynomial.
|
||||
|
||||
slong fmpz_poly_mat_rank(const fmpz_poly_mat_t A)
|
||||
|
||||
Returns the rank of \code{A}. Performs fraction-free LU decomposition
|
||||
on a copy of \code{A}.
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Inverse
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
int fmpz_poly_mat_inv(fmpz_poly_mat_t Ainv, fmpz_poly_t den,
|
||||
const fmpz_poly_mat_t A)
|
||||
|
||||
Sets (\code{Ainv}, \code{den}) to the inverse matrix of \code{A}.
|
||||
Returns 1 if \code{A} is nonsingular and 0 if \code{A} is singular.
|
||||
Aliasing of \code{Ainv} and \code{A} is allowed.
|
||||
|
||||
More precisely, \code{det} will be set to the determinant of \code{A}
|
||||
and \code{Ainv} will be set to the adjugate matrix of \code{A}.
|
||||
Note that the determinant is not necessarily the minimal denominator.
|
||||
|
||||
Uses fraction-free LU decomposition, followed by solving for
|
||||
the identity matrix.
|
||||
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Nullspace
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
slong fmpz_poly_mat_nullspace(fmpz_poly_mat_t res, const fmpz_poly_mat_t mat)
|
||||
|
||||
Computes the right rational nullspace of the matrix \code{mat} and
|
||||
returns the nullity.
|
||||
|
||||
More precisely, assume that \code{mat} has rank $r$ and nullity $n$.
|
||||
Then this function sets the first $n$ columns of \code{res}
|
||||
to linearly independent vectors spanning the nullspace of \code{mat}.
|
||||
As a result, we always have rank(\code{res}) $= n$, and
|
||||
\code{mat} $\times$ \code{res} is the zero matrix.
|
||||
|
||||
The computed basis vectors will not generally be in a reduced form.
|
||||
In general, the polynomials in each column vector in the result
|
||||
will have a nontrivial common GCD.
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
Solving
|
||||
|
||||
*******************************************************************************
|
||||
|
||||
int fmpz_poly_mat_solve(fmpz_poly_mat_t X, fmpz_poly_t den,
|
||||
const fmpz_poly_mat_t A, const fmpz_poly_mat_t B)
|
||||
|
||||
Solves the equation $AX = B$ for nonsingular $A$. More precisely, computes
|
||||
(\code{X}, \code{den}) such that $AX = B \times \operatorname{den}$.
|
||||
Returns 1 if $A$ is nonsingular and 0 if $A$ is singular.
|
||||
The computed denominator will not generally be minimal.
|
||||
|
||||
Uses fraction-free LU decomposition followed by fraction-free
|
||||
forward and back substitution.
|
||||
|
||||
int fmpz_poly_mat_solve_fflu(fmpz_poly_mat_t X, fmpz_poly_t den,
|
||||
const fmpz_poly_mat_t A, const fmpz_poly_mat_t B);
|
||||
|
||||
Solves the equation $AX = B$ for nonsingular $A$. More precisely, computes
|
||||
(\code{X}, \code{den}) such that $AX = B \times \operatorname{den}$.
|
||||
Returns 1 if $A$ is nonsingular and 0 if $A$ is singular.
|
||||
The computed denominator will not generally be minimal.
|
||||
|
||||
Uses fraction-free LU decomposition followed by fraction-free
|
||||
forward and back substitution.
|
||||
|
||||
void fmpz_poly_mat_solve_fflu_precomp(fmpz_poly_mat_t X,
|
||||
const slong * perm,
|
||||
const fmpz_poly_mat_t FFLU, const fmpz_poly_mat_t B);
|
||||
|
||||
Performs fraction-free forward and back substitution given a precomputed
|
||||
fraction-free LU decomposition and corresponding permutation.
|
||||
45
external/flint-2.4.3/fmpz_poly_mat/equal.c
vendored
Normal file
45
external/flint-2.4.3/fmpz_poly_mat/equal.c
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
fmpz_poly_mat_equal(const fmpz_poly_mat_t A, const fmpz_poly_mat_t B)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
if (A->r != B->r || A->c != B->c)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
for (j = 0; j < A->c; j++)
|
||||
if (!fmpz_poly_equal(fmpz_poly_mat_entry(A, i, j),
|
||||
fmpz_poly_mat_entry(B, i, j)))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
41
external/flint-2.4.3/fmpz_poly_mat/evaluate_fmpz.c
vendored
Normal file
41
external/flint-2.4.3/fmpz_poly_mat/evaluate_fmpz.c
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_mat.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_evaluate_fmpz(fmpz_mat_t B, const fmpz_poly_mat_t A, const fmpz_t x)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
for (j = 0; j < A->c; j++)
|
||||
fmpz_poly_evaluate_fmpz(fmpz_mat_entry(B, i, j),
|
||||
fmpz_poly_mat_entry(A, i, j), x);
|
||||
}
|
||||
112
external/flint-2.4.3/fmpz_poly_mat/fflu.c
vendored
Normal file
112
external/flint-2.4.3/fmpz_poly_mat/fflu.c
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
#define E(j,k) fmpz_poly_mat_entry(B,j,k)
|
||||
|
||||
static __inline__ void
|
||||
fmpz_poly_mat_swap_rows(fmpz_poly_mat_t mat, slong * perm, slong r, slong s)
|
||||
{
|
||||
if (r != s)
|
||||
{
|
||||
fmpz_poly_struct * u;
|
||||
slong t;
|
||||
|
||||
if (perm)
|
||||
{
|
||||
t = perm[s];
|
||||
perm[s] = perm[r];
|
||||
perm[r] = t;
|
||||
}
|
||||
|
||||
u = mat->rows[s];
|
||||
mat->rows[s] = mat->rows[r];
|
||||
mat->rows[r] = u;
|
||||
}
|
||||
}
|
||||
|
||||
slong
|
||||
fmpz_poly_mat_fflu(fmpz_poly_mat_t B, fmpz_poly_t den, slong * perm,
|
||||
const fmpz_poly_mat_t A, int rank_check)
|
||||
{
|
||||
fmpz_poly_t t;
|
||||
slong m, n, j, k, rank, r, pivot_row, pivot_col;
|
||||
|
||||
if (fmpz_poly_mat_is_empty(A))
|
||||
{
|
||||
fmpz_poly_one(den);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fmpz_poly_mat_set(B, A);
|
||||
m = B->r;
|
||||
n = B->c;
|
||||
rank = pivot_row = pivot_col = 0;
|
||||
|
||||
fmpz_poly_init(t);
|
||||
|
||||
while (pivot_row < m && pivot_col < n)
|
||||
{
|
||||
r = fmpz_poly_mat_find_pivot_partial(B, pivot_row, m, pivot_col);
|
||||
|
||||
if (r == -1)
|
||||
{
|
||||
if (rank_check)
|
||||
{
|
||||
fmpz_poly_zero(den);
|
||||
rank = 0;
|
||||
break;
|
||||
}
|
||||
pivot_col++;
|
||||
continue;
|
||||
}
|
||||
else if (r != pivot_row)
|
||||
fmpz_poly_mat_swap_rows(B, perm, pivot_row, r);
|
||||
|
||||
rank++;
|
||||
|
||||
for (j = pivot_row + 1; j < m; j++)
|
||||
{
|
||||
for (k = pivot_col + 1; k < n; k++)
|
||||
{
|
||||
fmpz_poly_mul(E(j, k), E(j, k), E(pivot_row, pivot_col));
|
||||
fmpz_poly_mul(t, E(j, pivot_col), E(pivot_row, k));
|
||||
fmpz_poly_sub(E(j, k), E(j, k), t);
|
||||
if (pivot_row > 0)
|
||||
fmpz_poly_div(E(j, k), E(j, k), den);
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_poly_set(den, E(pivot_row, pivot_col));
|
||||
pivot_row++;
|
||||
pivot_col++;
|
||||
}
|
||||
|
||||
fmpz_poly_clear(t);
|
||||
return rank;
|
||||
}
|
||||
44
external/flint-2.4.3/fmpz_poly_mat/find_pivot_any.c
vendored
Normal file
44
external/flint-2.4.3/fmpz_poly_mat/find_pivot_any.c
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
slong
|
||||
fmpz_poly_mat_find_pivot_any(const fmpz_poly_mat_t mat,
|
||||
slong start_row, slong end_row, slong c)
|
||||
{
|
||||
slong r;
|
||||
|
||||
for (r = start_row; r < end_row; r++)
|
||||
{
|
||||
if (!fmpz_poly_is_zero(fmpz_poly_mat_entry(mat, r, c)))
|
||||
return r;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
67
external/flint-2.4.3/fmpz_poly_mat/find_pivot_partial.c
vendored
Normal file
67
external/flint-2.4.3/fmpz_poly_mat/find_pivot_partial.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) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
slong
|
||||
fmpz_poly_mat_find_pivot_partial(const fmpz_poly_mat_t mat,
|
||||
slong start_row, slong end_row, slong c)
|
||||
{
|
||||
slong best_row, best_length, best_bits, i;
|
||||
|
||||
best_row = start_row;
|
||||
best_length = fmpz_poly_length(fmpz_poly_mat_entry(mat, start_row, c));
|
||||
|
||||
best_bits = fmpz_poly_max_bits(fmpz_poly_mat_entry(mat, start_row, c));
|
||||
best_bits = FLINT_ABS(best_bits);
|
||||
|
||||
for (i = start_row + 1; i < end_row; i++)
|
||||
{
|
||||
slong b, l;
|
||||
|
||||
l = fmpz_poly_length(fmpz_poly_mat_entry(mat, i, c));
|
||||
|
||||
if (l != 0 && (best_length == 0 || l <= best_length))
|
||||
{
|
||||
b = fmpz_poly_max_bits(fmpz_poly_mat_entry(mat, i, c));
|
||||
b = FLINT_ABS(b);
|
||||
|
||||
if (best_length == 0 || l < best_length || b < best_bits)
|
||||
{
|
||||
best_row = i;
|
||||
best_length = l;
|
||||
best_bits = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (best_length == 0)
|
||||
return -1;
|
||||
|
||||
return best_row;
|
||||
}
|
||||
52
external/flint-2.4.3/fmpz_poly_mat/init.c
vendored
Normal file
52
external/flint-2.4.3/fmpz_poly_mat/init.c
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_init(fmpz_poly_mat_t A, slong rows, slong cols)
|
||||
{
|
||||
if (rows && cols)
|
||||
{
|
||||
slong i;
|
||||
|
||||
A->entries = (fmpz_poly_struct *) flint_malloc(rows * cols * sizeof(fmpz_poly_struct));
|
||||
A->rows = (fmpz_poly_struct **) flint_malloc(rows * sizeof(fmpz_poly_struct *));
|
||||
|
||||
for (i = 0; i < rows * cols; i++)
|
||||
fmpz_poly_init(A->entries + i);
|
||||
|
||||
for (i = 0; i < rows; i++)
|
||||
A->rows[i] = A->entries + i * cols;
|
||||
}
|
||||
else
|
||||
A->entries = NULL;
|
||||
|
||||
A->r = rows;
|
||||
A->c = cols;
|
||||
}
|
||||
36
external/flint-2.4.3/fmpz_poly_mat/init_set.c
vendored
Normal file
36
external/flint-2.4.3/fmpz_poly_mat/init_set.c
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_init_set(fmpz_poly_mat_t A, const fmpz_poly_mat_t B)
|
||||
{
|
||||
fmpz_poly_mat_init(A, B->r, B->c);
|
||||
fmpz_poly_mat_set(A, B);
|
||||
}
|
||||
105
external/flint-2.4.3/fmpz_poly_mat/inv.c
vendored
Normal file
105
external/flint-2.4.3/fmpz_poly_mat/inv.c
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
#include "perm.h"
|
||||
|
||||
#define E fmpz_poly_mat_entry
|
||||
|
||||
int
|
||||
fmpz_poly_mat_inv(fmpz_poly_mat_t Ainv, fmpz_poly_t den,
|
||||
const fmpz_poly_mat_t A)
|
||||
{
|
||||
slong n = fmpz_poly_mat_nrows(A);
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
fmpz_poly_one(den);
|
||||
return 1;
|
||||
}
|
||||
else if (n == 1)
|
||||
{
|
||||
fmpz_poly_set(den, E(A, 0, 0));
|
||||
fmpz_poly_one(E(Ainv, 0, 0));
|
||||
return !fmpz_poly_is_zero(den);
|
||||
}
|
||||
else if (n == 2)
|
||||
{
|
||||
fmpz_poly_mat_det(den, A);
|
||||
if (fmpz_poly_is_zero(den))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (Ainv == A)
|
||||
{
|
||||
fmpz_poly_swap(E(A, 0, 0), E(A, 1, 1));
|
||||
fmpz_poly_neg(E(A, 0, 1), E(A, 0, 1));
|
||||
fmpz_poly_neg(E(A, 1, 0), E(A, 1, 0));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_poly_set(E(Ainv, 0, 0), E(A, 1, 1));
|
||||
fmpz_poly_set(E(Ainv, 1, 1), E(A, 0, 0));
|
||||
fmpz_poly_neg(E(Ainv, 0, 1), E(A, 0, 1));
|
||||
fmpz_poly_neg(E(Ainv, 1, 0), E(A, 1, 0));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_poly_mat_t LU, I;
|
||||
slong * perm;
|
||||
int result;
|
||||
|
||||
perm = _perm_init(n);
|
||||
fmpz_poly_mat_init_set(LU, A);
|
||||
result = (fmpz_poly_mat_fflu(LU, den, perm, LU, 1) == n);
|
||||
|
||||
if (result)
|
||||
{
|
||||
fmpz_poly_mat_init(I, n, n);
|
||||
fmpz_poly_mat_one(I);
|
||||
fmpz_poly_mat_solve_fflu_precomp(Ainv, perm, LU, I);
|
||||
fmpz_poly_mat_clear(I);
|
||||
}
|
||||
else
|
||||
fmpz_poly_zero(den);
|
||||
|
||||
if (_perm_parity(perm, n))
|
||||
{
|
||||
fmpz_poly_mat_neg(Ainv, Ainv);
|
||||
fmpz_poly_neg(den, den);
|
||||
}
|
||||
|
||||
_perm_clear(perm);
|
||||
fmpz_poly_mat_clear(LU);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
57
external/flint-2.4.3/fmpz_poly_mat/is_one.c
vendored
Normal file
57
external/flint-2.4.3/fmpz_poly_mat/is_one.c
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
fmpz_poly_mat_is_one(const fmpz_poly_mat_t A)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
if (A->r == 0 || A->c == 0)
|
||||
return 1;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
{
|
||||
for (j = 0; j < A->c; j++)
|
||||
{
|
||||
if (i == j)
|
||||
{
|
||||
if (!fmpz_poly_is_one(fmpz_poly_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!fmpz_poly_is_zero(fmpz_poly_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
45
external/flint-2.4.3/fmpz_poly_mat/is_zero.c
vendored
Normal file
45
external/flint-2.4.3/fmpz_poly_mat/is_zero.c
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
int
|
||||
fmpz_poly_mat_is_zero(const fmpz_poly_mat_t A)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
if (A->r == 0 || A->c == 0)
|
||||
return 1;
|
||||
|
||||
for (i = 0; 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;
|
||||
|
||||
return 1;
|
||||
}
|
||||
57
external/flint-2.4.3/fmpz_poly_mat/max_bits.c
vendored
Normal file
57
external/flint-2.4.3/fmpz_poly_mat/max_bits.c
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
slong
|
||||
fmpz_poly_mat_max_bits(const fmpz_poly_mat_t A)
|
||||
{
|
||||
slong i, j, bits, max;
|
||||
int sign;
|
||||
|
||||
max = 0;
|
||||
sign = 0;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
{
|
||||
for (j = 0; j < A->c; j++)
|
||||
{
|
||||
bits = fmpz_poly_max_bits(fmpz_poly_mat_entry(A, i, j));
|
||||
|
||||
if (bits < 0)
|
||||
{
|
||||
sign = 1;
|
||||
max = FLINT_MAX(max, -bits);
|
||||
}
|
||||
else
|
||||
max = FLINT_MAX(max, bits);
|
||||
}
|
||||
}
|
||||
|
||||
return sign ? -max : max;
|
||||
}
|
||||
48
external/flint-2.4.3/fmpz_poly_mat/max_length.c
vendored
Normal file
48
external/flint-2.4.3/fmpz_poly_mat/max_length.c
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
slong
|
||||
fmpz_poly_mat_max_length(const fmpz_poly_mat_t A)
|
||||
{
|
||||
slong i, j, len, max;
|
||||
|
||||
max = 0;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
{
|
||||
for (j = 0; j < A->c; j++)
|
||||
{
|
||||
len = fmpz_poly_length(fmpz_poly_mat_entry(A, i, j));
|
||||
max = FLINT_MAX(len, max);
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
43
external/flint-2.4.3/fmpz_poly_mat/mul.c
vendored
Normal file
43
external/flint-2.4.3/fmpz_poly_mat/mul.c
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_mul(fmpz_poly_mat_t C, const fmpz_poly_mat_t A,
|
||||
const fmpz_poly_mat_t B)
|
||||
{
|
||||
if (A->r < 8 || B->r < 8 || B->c < 8)
|
||||
{
|
||||
fmpz_poly_mat_mul_classical(C, A, B);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_poly_mat_mul_KS(C, A, B);
|
||||
}
|
||||
}
|
||||
95
external/flint-2.4.3/fmpz_poly_mat/mul_KS.c
vendored
Normal file
95
external/flint-2.4.3/fmpz_poly_mat/mul_KS.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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
#include "fmpz_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_mul_KS(fmpz_poly_mat_t C, const fmpz_poly_mat_t A,
|
||||
const fmpz_poly_mat_t B)
|
||||
{
|
||||
slong i, j;
|
||||
slong A_len, B_len;
|
||||
int signs;
|
||||
slong A_bits, B_bits, bit_size;
|
||||
|
||||
fmpz_mat_t AA, BB, CC;
|
||||
|
||||
if (B->r == 0)
|
||||
{
|
||||
fmpz_poly_mat_zero(C);
|
||||
return;
|
||||
}
|
||||
|
||||
A_len = fmpz_poly_mat_max_length(A);
|
||||
B_len = fmpz_poly_mat_max_length(B);
|
||||
|
||||
A_bits = fmpz_poly_mat_max_bits(A);
|
||||
B_bits = fmpz_poly_mat_max_bits(B);
|
||||
|
||||
signs = (A_bits < 0 || B_bits < 0);
|
||||
|
||||
bit_size = FLINT_ABS(A_bits) + FLINT_ABS(B_bits) + signs;
|
||||
bit_size += FLINT_BIT_COUNT(FLINT_MIN(A_len, B_len));
|
||||
bit_size += FLINT_BIT_COUNT(B->r);
|
||||
|
||||
/*
|
||||
flint_printf("A: BITS %wd LEN %wd\n", A_bits, A_len);
|
||||
flint_printf("B: BITS %wd LEN %wd\n", B_bits, B_len);
|
||||
flint_printf("bit_size: %wd\n", bit_size);
|
||||
*/
|
||||
|
||||
fmpz_mat_init(AA, A->r, A->c);
|
||||
fmpz_mat_init(BB, B->r, B->c);
|
||||
fmpz_mat_init(CC, C->r, C->c);
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
for (j = 0; j < A->c; j++)
|
||||
fmpz_poly_bit_pack(fmpz_mat_entry(AA, i, j),
|
||||
fmpz_poly_mat_entry(A, i, j), bit_size);
|
||||
|
||||
for (i = 0; i < B->r; i++)
|
||||
for (j = 0; j < B->c; j++)
|
||||
fmpz_poly_bit_pack(fmpz_mat_entry(BB, i, j),
|
||||
fmpz_poly_mat_entry(B, i, j), bit_size);
|
||||
|
||||
fmpz_mat_mul(CC, AA, BB);
|
||||
|
||||
for (i = 0; i < C->r; i++)
|
||||
for (j = 0; j < C->c; j++)
|
||||
if (signs)
|
||||
fmpz_poly_bit_unpack(fmpz_poly_mat_entry(C, i, j),
|
||||
fmpz_mat_entry(CC, i, j), bit_size);
|
||||
else
|
||||
fmpz_poly_bit_unpack_unsigned(fmpz_poly_mat_entry(C, i, j),
|
||||
fmpz_mat_entry(CC, i, j), bit_size);
|
||||
|
||||
fmpz_mat_clear(AA);
|
||||
fmpz_mat_clear(BB);
|
||||
fmpz_mat_clear(CC);
|
||||
}
|
||||
81
external/flint-2.4.3/fmpz_poly_mat/mul_classical.c
vendored
Normal file
81
external/flint-2.4.3/fmpz_poly_mat/mul_classical.c
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_mul_classical(fmpz_poly_mat_t C, const fmpz_poly_mat_t A,
|
||||
const fmpz_poly_mat_t B)
|
||||
{
|
||||
slong ar, bc, br;
|
||||
slong i, j, k;
|
||||
fmpz_poly_t t;
|
||||
|
||||
ar = A->r;
|
||||
br = B->r;
|
||||
bc = B->c;
|
||||
|
||||
if (br == 0)
|
||||
{
|
||||
fmpz_poly_mat_zero(C);
|
||||
return;
|
||||
}
|
||||
|
||||
if (C == A || C == B)
|
||||
{
|
||||
fmpz_poly_mat_t T;
|
||||
fmpz_poly_mat_init(T, ar, bc);
|
||||
fmpz_poly_mat_mul_classical(T, A, B);
|
||||
fmpz_poly_mat_swap(C, T);
|
||||
fmpz_poly_mat_clear(T);
|
||||
return;
|
||||
}
|
||||
|
||||
fmpz_poly_init(t);
|
||||
|
||||
for (i = 0; i < ar; i++)
|
||||
{
|
||||
for (j = 0; j < bc; j++)
|
||||
{
|
||||
fmpz_poly_mul(fmpz_poly_mat_entry(C, i, j),
|
||||
fmpz_poly_mat_entry(A, i, 0),
|
||||
fmpz_poly_mat_entry(B, 0, j));
|
||||
|
||||
for (k = 1; k < br; k++)
|
||||
{
|
||||
fmpz_poly_mul(t, fmpz_poly_mat_entry(A, i, k),
|
||||
fmpz_poly_mat_entry(B, k, j));
|
||||
|
||||
fmpz_poly_add(fmpz_poly_mat_entry(C, i, j),
|
||||
fmpz_poly_mat_entry(C, i, j), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_poly_clear(t);
|
||||
}
|
||||
81
external/flint-2.4.3/fmpz_poly_mat/mullow.c
vendored
Normal file
81
external/flint-2.4.3/fmpz_poly_mat/mullow.c
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_mullow(fmpz_poly_mat_t C, const fmpz_poly_mat_t A,
|
||||
const fmpz_poly_mat_t B, slong len)
|
||||
{
|
||||
slong ar, bc, br;
|
||||
slong i, j, k;
|
||||
fmpz_poly_t t;
|
||||
|
||||
ar = A->r;
|
||||
br = B->r;
|
||||
bc = B->c;
|
||||
|
||||
if (br == 0 || len < 1)
|
||||
{
|
||||
fmpz_poly_mat_zero(C);
|
||||
return;
|
||||
}
|
||||
|
||||
if (C == A || C == B)
|
||||
{
|
||||
fmpz_poly_mat_t T;
|
||||
fmpz_poly_mat_init(T, ar, bc);
|
||||
fmpz_poly_mat_mullow(T, A, B, len);
|
||||
fmpz_poly_mat_swap(C, T);
|
||||
fmpz_poly_mat_clear(T);
|
||||
return;
|
||||
}
|
||||
|
||||
fmpz_poly_init(t);
|
||||
|
||||
for (i = 0; i < ar; i++)
|
||||
{
|
||||
for (j = 0; j < bc; j++)
|
||||
{
|
||||
fmpz_poly_mullow(fmpz_poly_mat_entry(C, i, j),
|
||||
fmpz_poly_mat_entry(A, i, 0),
|
||||
fmpz_poly_mat_entry(B, 0, j), len);
|
||||
|
||||
for (k = 1; k < br; k++)
|
||||
{
|
||||
fmpz_poly_mullow(t, fmpz_poly_mat_entry(A, i, k),
|
||||
fmpz_poly_mat_entry(B, k, j), len);
|
||||
|
||||
fmpz_poly_add(fmpz_poly_mat_entry(C, i, j),
|
||||
fmpz_poly_mat_entry(C, i, j), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_poly_clear(t);
|
||||
}
|
||||
40
external/flint-2.4.3/fmpz_poly_mat/neg.c
vendored
Normal file
40
external/flint-2.4.3/fmpz_poly_mat/neg.c
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_neg(fmpz_poly_mat_t B, const fmpz_poly_mat_t A)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
for (j = 0; j < A->c; j++)
|
||||
fmpz_poly_neg(fmpz_poly_mat_entry(B, i, j),
|
||||
fmpz_poly_mat_entry(A, i, j));
|
||||
}
|
||||
95
external/flint-2.4.3/fmpz_poly_mat/nullspace.c
vendored
Normal file
95
external/flint-2.4.3/fmpz_poly_mat/nullspace.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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
slong
|
||||
fmpz_poly_mat_nullspace(fmpz_poly_mat_t res, const fmpz_poly_mat_t mat)
|
||||
{
|
||||
slong i, j, k, n, rank, nullity;
|
||||
slong * pivots;
|
||||
slong * nonpivots;
|
||||
fmpz_poly_mat_t tmp;
|
||||
fmpz_poly_t den;
|
||||
|
||||
n = mat->c;
|
||||
|
||||
fmpz_poly_init(den);
|
||||
fmpz_poly_mat_init_set(tmp, mat);
|
||||
rank = fmpz_poly_mat_rref(tmp, den, tmp);
|
||||
nullity = n - rank;
|
||||
|
||||
fmpz_poly_mat_zero(res);
|
||||
|
||||
if (rank == 0)
|
||||
{
|
||||
for (i = 0; i < nullity; i++)
|
||||
fmpz_poly_set_ui(res->rows[i] + i, UWORD(1));
|
||||
}
|
||||
else if (nullity)
|
||||
{
|
||||
pivots = flint_malloc(rank * sizeof(slong));
|
||||
nonpivots = flint_malloc(nullity * sizeof(slong));
|
||||
|
||||
for (i = j = k = 0; i < rank; i++)
|
||||
{
|
||||
while (fmpz_poly_is_zero(tmp->rows[i] + j))
|
||||
{
|
||||
nonpivots[k] = j;
|
||||
k++;
|
||||
j++;
|
||||
}
|
||||
pivots[i] = j;
|
||||
j++;
|
||||
}
|
||||
while (k < nullity)
|
||||
{
|
||||
nonpivots[k] = j;
|
||||
k++;
|
||||
j++;
|
||||
}
|
||||
|
||||
fmpz_poly_set(den, tmp->rows[0] + pivots[0]);
|
||||
|
||||
for (i = 0; i < nullity; i++)
|
||||
{
|
||||
for (j = 0; j < rank; j++)
|
||||
fmpz_poly_set(res->rows[pivots[j]] + i,
|
||||
tmp->rows[j] + nonpivots[i]);
|
||||
fmpz_poly_neg(res->rows[nonpivots[i]] + i, den);
|
||||
}
|
||||
|
||||
flint_free(pivots);
|
||||
flint_free(nonpivots);
|
||||
}
|
||||
|
||||
fmpz_poly_clear(den);
|
||||
fmpz_poly_mat_clear(tmp);
|
||||
return nullity;
|
||||
}
|
||||
41
external/flint-2.4.3/fmpz_poly_mat/one.c
vendored
Normal file
41
external/flint-2.4.3/fmpz_poly_mat/one.c
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_one(fmpz_poly_mat_t A)
|
||||
{
|
||||
slong i, n;
|
||||
|
||||
fmpz_poly_mat_zero(A);
|
||||
n = FLINT_MIN(A->r, A->c);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
fmpz_poly_one(fmpz_poly_mat_entry(A, i, i));
|
||||
}
|
||||
75
external/flint-2.4.3/fmpz_poly_mat/pow.c
vendored
Normal file
75
external/flint-2.4.3/fmpz_poly_mat/pow.c
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_pow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, ulong exp)
|
||||
{
|
||||
slong d = fmpz_poly_mat_nrows(A);
|
||||
|
||||
if (exp == 0 || d == 0)
|
||||
{
|
||||
fmpz_poly_mat_one(B);
|
||||
}
|
||||
else if (exp == 1)
|
||||
{
|
||||
fmpz_poly_mat_set(B, A);
|
||||
}
|
||||
else if (exp == 2)
|
||||
{
|
||||
fmpz_poly_mat_sqr(B, A);
|
||||
}
|
||||
else if (d == 1)
|
||||
{
|
||||
fmpz_poly_pow(fmpz_poly_mat_entry(B, 0, 0),
|
||||
fmpz_poly_mat_entry(A, 0, 0), exp);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_poly_mat_t T, U;
|
||||
slong i;
|
||||
|
||||
fmpz_poly_mat_init_set(T, A);
|
||||
fmpz_poly_mat_init(U, d, d);
|
||||
|
||||
for (i = ((slong) FLINT_BIT_COUNT(exp)) - 2; i >= 0; i--)
|
||||
{
|
||||
fmpz_poly_mat_sqr(U, T);
|
||||
|
||||
if (exp & (WORD(1) << i))
|
||||
fmpz_poly_mat_mul(T, U, A);
|
||||
else
|
||||
fmpz_poly_mat_swap(T, U);
|
||||
}
|
||||
|
||||
fmpz_poly_mat_swap(B, T);
|
||||
fmpz_poly_mat_clear(T);
|
||||
fmpz_poly_mat_clear(U);
|
||||
}
|
||||
}
|
||||
82
external/flint-2.4.3/fmpz_poly_mat/pow_trunc.c
vendored
Normal file
82
external/flint-2.4.3/fmpz_poly_mat/pow_trunc.c
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_pow_trunc(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, ulong exp,
|
||||
slong len)
|
||||
{
|
||||
slong d = fmpz_poly_mat_nrows(A);
|
||||
|
||||
if (len < 1)
|
||||
{
|
||||
fmpz_poly_mat_zero(B);
|
||||
}
|
||||
else if (exp == 0 || d == 0)
|
||||
{
|
||||
fmpz_poly_mat_one(B);
|
||||
}
|
||||
else if (exp == 1)
|
||||
{
|
||||
fmpz_poly_mat_set(B, A);
|
||||
fmpz_poly_mat_truncate(B, len);
|
||||
}
|
||||
else if (exp == 2)
|
||||
{
|
||||
fmpz_poly_mat_sqrlow(B, A, len);
|
||||
}
|
||||
else if (d == 1)
|
||||
{
|
||||
fmpz_poly_pow_trunc(fmpz_poly_mat_entry(B, 0, 0),
|
||||
fmpz_poly_mat_entry(A, 0, 0), exp, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_poly_mat_t T, U;
|
||||
slong i;
|
||||
|
||||
fmpz_poly_mat_init_set(T, A);
|
||||
fmpz_poly_mat_truncate(T, len);
|
||||
fmpz_poly_mat_init(U, d, d);
|
||||
|
||||
for (i = ((slong) FLINT_BIT_COUNT(exp)) - 2; i >= 0; i--)
|
||||
{
|
||||
fmpz_poly_mat_sqrlow(U, T, len);
|
||||
|
||||
if (exp & (WORD(1) << i))
|
||||
fmpz_poly_mat_mullow(T, U, A, len);
|
||||
else
|
||||
fmpz_poly_mat_swap(T, U);
|
||||
}
|
||||
|
||||
fmpz_poly_mat_swap(B, T);
|
||||
fmpz_poly_mat_clear(T);
|
||||
fmpz_poly_mat_clear(U);
|
||||
}
|
||||
}
|
||||
50
external/flint-2.4.3/fmpz_poly_mat/print.c
vendored
Normal file
50
external/flint-2.4.3/fmpz_poly_mat/print.c
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_print(const fmpz_poly_mat_t A, const char * x)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
flint_printf("<%wd x %wd matrix over Z[%s]>\n", A->r, A->c, x);
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
{
|
||||
flint_printf("[");
|
||||
for (j = 0; j < A->c; j++)
|
||||
{
|
||||
fmpz_poly_print_pretty(fmpz_poly_mat_entry(A, i, j), x);
|
||||
if (j + 1 < A->c)
|
||||
flint_printf(", ");
|
||||
}
|
||||
flint_printf("]\n");
|
||||
}
|
||||
flint_printf("\n");
|
||||
}
|
||||
70
external/flint-2.4.3/fmpz_poly_mat/prod.c
vendored
Normal file
70
external/flint-2.4.3/fmpz_poly_mat/prod.c
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
static void
|
||||
binary_splitting(fmpz_poly_mat_t P, fmpz_poly_mat_t * const factors,
|
||||
slong n1, slong n2)
|
||||
{
|
||||
if (n2 - n1 <= 0)
|
||||
{
|
||||
fmpz_poly_mat_one(P);
|
||||
}
|
||||
else if (n2 - n1 == 1)
|
||||
{
|
||||
fmpz_poly_mat_set(P, factors[n1]);
|
||||
}
|
||||
else if (n2 - n1 == 2)
|
||||
{
|
||||
fmpz_poly_mat_mul(P, factors[n1], factors[n1 + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_poly_mat_t P1, P2;
|
||||
slong m = (n1 + n2) / 2;
|
||||
|
||||
fmpz_poly_mat_init(P1, P->r, P->c);
|
||||
fmpz_poly_mat_init(P2, P->r, P->c);
|
||||
|
||||
binary_splitting(P1, factors, n1, m);
|
||||
binary_splitting(P2, factors, m, n2);
|
||||
|
||||
fmpz_poly_mat_mul(P, P1, P2);
|
||||
|
||||
fmpz_poly_mat_clear(P1);
|
||||
fmpz_poly_mat_clear(P2);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fmpz_poly_mat_prod(fmpz_poly_mat_t res,
|
||||
fmpz_poly_mat_t * const factors, slong n)
|
||||
{
|
||||
binary_splitting(res, factors, 0, n);
|
||||
}
|
||||
39
external/flint-2.4.3/fmpz_poly_mat/randtest.c
vendored
Normal file
39
external/flint-2.4.3/fmpz_poly_mat/randtest.c
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_randtest(fmpz_poly_mat_t A, flint_rand_t state, slong len, mp_bitcnt_t bits)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
for (j = 0; j < A->c; j++)
|
||||
fmpz_poly_randtest(fmpz_poly_mat_entry(A, i, j), state, len, bits);
|
||||
}
|
||||
55
external/flint-2.4.3/fmpz_poly_mat/randtest_sparse.c
vendored
Normal file
55
external/flint-2.4.3/fmpz_poly_mat/randtest_sparse.c
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
#include "ulong_extras.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_randtest_sparse(fmpz_poly_mat_t A, flint_rand_t state, slong len,
|
||||
mp_bitcnt_t bits, float density)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
{
|
||||
for (j = 0; j < A->c; j++)
|
||||
{
|
||||
if (n_randint(state, 1000) < density * 1000)
|
||||
{
|
||||
slong l = n_randint(state, len + 1);
|
||||
l = FLINT_MAX(l, 1);
|
||||
fmpz_poly_randtest_not_zero(fmpz_poly_mat_entry(A, i, j),
|
||||
state, l, bits);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmpz_poly_zero(fmpz_poly_mat_entry(A, i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
39
external/flint-2.4.3/fmpz_poly_mat/randtest_unsigned.c
vendored
Normal file
39
external/flint-2.4.3/fmpz_poly_mat/randtest_unsigned.c
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_randtest_unsigned(fmpz_poly_mat_t A, flint_rand_t state, slong len, mp_bitcnt_t bits)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
for (j = 0; j < A->c; j++)
|
||||
fmpz_poly_randtest_unsigned(fmpz_poly_mat_entry(A, i, j), state, len, bits);
|
||||
}
|
||||
49
external/flint-2.4.3/fmpz_poly_mat/rank.c
vendored
Normal file
49
external/flint-2.4.3/fmpz_poly_mat/rank.c
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
|
||||
slong
|
||||
fmpz_poly_mat_rank(const fmpz_poly_mat_t A)
|
||||
{
|
||||
fmpz_poly_mat_t tmp;
|
||||
fmpz_poly_t den;
|
||||
slong rank;
|
||||
|
||||
if (fmpz_poly_mat_is_empty(A))
|
||||
return 0;
|
||||
|
||||
fmpz_poly_mat_init_set(tmp, A);
|
||||
fmpz_poly_init(den);
|
||||
rank = fmpz_poly_mat_fflu(tmp, den, NULL, tmp, 0);
|
||||
fmpz_poly_mat_clear(tmp);
|
||||
fmpz_poly_clear(den);
|
||||
return rank;
|
||||
}
|
||||
111
external/flint-2.4.3/fmpz_poly_mat/rref.c
vendored
Normal file
111
external/flint-2.4.3/fmpz_poly_mat/rref.c
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011-2012 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
slong
|
||||
fmpz_poly_mat_rref(fmpz_poly_mat_t R, fmpz_poly_t den, const fmpz_poly_mat_t A)
|
||||
{
|
||||
slong i, j, k, m, n, rank;
|
||||
slong *pivots, *nonpivots;
|
||||
|
||||
rank = fmpz_poly_mat_fflu(R, den, NULL, A, 0);
|
||||
m = fmpz_poly_mat_nrows(R);
|
||||
n = fmpz_poly_mat_ncols(R);
|
||||
|
||||
/* clear bottom */
|
||||
for (i = rank; i < m; i++)
|
||||
for (j = 0; j < n; j++)
|
||||
fmpz_poly_zero(fmpz_poly_mat_entry(R, i, j));
|
||||
|
||||
/* Convert row echelon form to reduced row echelon form */
|
||||
if (rank > 1)
|
||||
{
|
||||
fmpz_poly_t tmp, tmp2;
|
||||
fmpz_poly_init(tmp);
|
||||
fmpz_poly_init(tmp2);
|
||||
|
||||
pivots = flint_malloc(sizeof(slong) * n);
|
||||
nonpivots = pivots + rank;
|
||||
|
||||
/* find pivot positions */
|
||||
for (i = j = k = 0; i < rank; i++)
|
||||
{
|
||||
while (fmpz_poly_is_zero(fmpz_poly_mat_entry(R, i, j)))
|
||||
{
|
||||
nonpivots[k] = j;
|
||||
k++;
|
||||
j++;
|
||||
}
|
||||
pivots[i] = j;
|
||||
j++;
|
||||
}
|
||||
while (k < n - rank)
|
||||
{
|
||||
nonpivots[k] = j;
|
||||
k++;
|
||||
j++;
|
||||
}
|
||||
|
||||
for (k = 0; k < n - rank; k++)
|
||||
{
|
||||
for (i = rank - 2; i >= 0; i--)
|
||||
{
|
||||
fmpz_poly_mul(tmp, den, fmpz_poly_mat_entry(R, i, nonpivots[k]));
|
||||
|
||||
for (j = i + 1; j < rank; j++)
|
||||
{
|
||||
fmpz_poly_mul(tmp2, fmpz_poly_mat_entry(R, i, pivots[j]),
|
||||
fmpz_poly_mat_entry(R, j, nonpivots[k]));
|
||||
fmpz_poly_sub(tmp, tmp, tmp2);
|
||||
}
|
||||
|
||||
fmpz_poly_div(fmpz_poly_mat_entry(R, i, nonpivots[k]),
|
||||
tmp, fmpz_poly_mat_entry(R, i, pivots[i]));
|
||||
}
|
||||
}
|
||||
|
||||
/* clear pivot columns */
|
||||
for (i = 0; i < rank; i++)
|
||||
{
|
||||
for (j = 0; j < rank; j++)
|
||||
{
|
||||
if (i == j)
|
||||
fmpz_poly_set(fmpz_poly_mat_entry(R, j, pivots[i]), den);
|
||||
else
|
||||
fmpz_poly_zero(fmpz_poly_mat_entry(R, j, pivots[i]));
|
||||
}
|
||||
}
|
||||
|
||||
flint_free(pivots);
|
||||
fmpz_poly_clear(tmp);
|
||||
fmpz_poly_clear(tmp2);
|
||||
}
|
||||
|
||||
return rank;
|
||||
}
|
||||
|
||||
42
external/flint-2.4.3/fmpz_poly_mat/scalar_mul_fmpz.c
vendored
Normal file
42
external/flint-2.4.3/fmpz_poly_mat/scalar_mul_fmpz.c
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_scalar_mul_fmpz(fmpz_poly_mat_t B, const fmpz_poly_mat_t A,
|
||||
const fmpz_t c)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
for (i = 0; i < fmpz_poly_mat_nrows(B); i++)
|
||||
for (j = 0; j < fmpz_poly_mat_ncols(B); j++)
|
||||
fmpz_poly_scalar_mul_fmpz(fmpz_poly_mat_entry(B, i, j),
|
||||
fmpz_poly_mat_entry(A, i, j), c);
|
||||
}
|
||||
42
external/flint-2.4.3/fmpz_poly_mat/scalar_mul_fmpz_poly.c
vendored
Normal file
42
external/flint-2.4.3/fmpz_poly_mat/scalar_mul_fmpz_poly.c
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_scalar_mul_fmpz_poly(fmpz_poly_mat_t B, const fmpz_poly_mat_t A,
|
||||
const fmpz_poly_t c)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
for (i = 0; i < fmpz_poly_mat_nrows(B); i++)
|
||||
for (j = 0; j < fmpz_poly_mat_ncols(B); j++)
|
||||
fmpz_poly_mul(fmpz_poly_mat_entry(B, i, j),
|
||||
fmpz_poly_mat_entry(A, i, j), c);
|
||||
}
|
||||
43
external/flint-2.4.3/fmpz_poly_mat/set.c
vendored
Normal file
43
external/flint-2.4.3/fmpz_poly_mat/set.c
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_set(fmpz_poly_mat_t B, const fmpz_poly_mat_t A)
|
||||
{
|
||||
if (A != B)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
for (j = 0; j < A->c; j++)
|
||||
fmpz_poly_set(fmpz_poly_mat_entry(B, i, j),
|
||||
fmpz_poly_mat_entry(A, i, j));
|
||||
}
|
||||
}
|
||||
38
external/flint-2.4.3/fmpz_poly_mat/solve.c
vendored
Normal file
38
external/flint-2.4.3/fmpz_poly_mat/solve.c
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
#include "perm.h"
|
||||
|
||||
int
|
||||
fmpz_poly_mat_solve(fmpz_poly_mat_t X, fmpz_poly_t den,
|
||||
const fmpz_poly_mat_t A, const fmpz_poly_mat_t B)
|
||||
{
|
||||
return fmpz_poly_mat_solve_fflu(X, den, A, B);
|
||||
}
|
||||
60
external/flint-2.4.3/fmpz_poly_mat/solve_fflu.c
vendored
Normal file
60
external/flint-2.4.3/fmpz_poly_mat/solve_fflu.c
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
#include "perm.h"
|
||||
|
||||
int
|
||||
fmpz_poly_mat_solve_fflu(fmpz_poly_mat_t X, fmpz_poly_t den,
|
||||
const fmpz_poly_mat_t A, const fmpz_poly_mat_t B)
|
||||
{
|
||||
fmpz_poly_mat_t LU;
|
||||
slong dim, *perm;
|
||||
int result;
|
||||
|
||||
if (fmpz_poly_mat_is_empty(B))
|
||||
{
|
||||
fmpz_poly_one(den);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dim = fmpz_poly_mat_nrows(A);
|
||||
perm = _perm_init(dim);
|
||||
fmpz_poly_mat_init_set(LU, A);
|
||||
result = (fmpz_poly_mat_fflu(LU, den, perm, LU, 1) == dim);
|
||||
|
||||
if (result)
|
||||
fmpz_poly_mat_solve_fflu_precomp(X, perm, LU, B);
|
||||
else
|
||||
fmpz_poly_zero(den);
|
||||
|
||||
_perm_clear(perm);
|
||||
fmpz_poly_mat_clear(LU);
|
||||
return result;
|
||||
}
|
||||
103
external/flint-2.4.3/fmpz_poly_mat/solve_fflu_precomp.c
vendored
Normal file
103
external/flint-2.4.3/fmpz_poly_mat/solve_fflu_precomp.c
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
#include "perm.h"
|
||||
|
||||
#define XX(ii,jj) fmpz_poly_mat_entry(X,(ii),(jj))
|
||||
#define BB(ii,jj) fmpz_poly_mat_entry(B,(ii),(jj))
|
||||
#define LU(ii,jj) fmpz_poly_mat_entry(FFLU,(ii),(jj))
|
||||
|
||||
void
|
||||
fmpz_poly_mat_set_perm(fmpz_poly_mat_t X, const slong * perm,
|
||||
const fmpz_poly_mat_t B)
|
||||
{
|
||||
if (X == B)
|
||||
{
|
||||
/* Not implemented */
|
||||
abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
if (perm == NULL)
|
||||
abort();
|
||||
|
||||
for (i = 0; i < fmpz_poly_mat_nrows(B); i++)
|
||||
for (j = 0; j < fmpz_poly_mat_ncols(B); j++)
|
||||
fmpz_poly_set(fmpz_poly_mat_entry(X, i, j),
|
||||
fmpz_poly_mat_entry(B, perm[i], j));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fmpz_poly_mat_solve_fflu_precomp(fmpz_poly_mat_t X,
|
||||
const slong * perm,
|
||||
const fmpz_poly_mat_t FFLU, const fmpz_poly_mat_t B)
|
||||
{
|
||||
fmpz_poly_t T;
|
||||
slong i, j, k, m, n;
|
||||
|
||||
n = X->r;
|
||||
m = X->c;
|
||||
|
||||
fmpz_poly_init(T);
|
||||
fmpz_poly_mat_set_perm(X, perm, B);
|
||||
|
||||
for (k = 0; k < m; k++)
|
||||
{
|
||||
/* Fraction-free forward substitution */
|
||||
for (i = 0; i < n - 1; i++)
|
||||
{
|
||||
for (j = i + 1; j < n; j++)
|
||||
{
|
||||
fmpz_poly_mul(XX(j, k), XX(j, k), LU(i, i));
|
||||
fmpz_poly_mul(T, LU(j, i), XX(i, k));
|
||||
fmpz_poly_sub(XX(j, k), XX(j, k), T);
|
||||
if (i > 0)
|
||||
fmpz_poly_div(XX(j, k), XX(j, k), LU(i-1, i-1));
|
||||
}
|
||||
}
|
||||
|
||||
/* Fraction-free back substitution */
|
||||
for (i = n - 2; i >= 0; i--)
|
||||
{
|
||||
fmpz_poly_mul(XX(i, k), XX(i, k), LU(n-1, n-1));
|
||||
for (j = i + 1; j < n; j++)
|
||||
{
|
||||
fmpz_poly_mul(T, XX(j, k), LU(i, j));
|
||||
fmpz_poly_sub(XX(i, k), XX(i, k), T);
|
||||
}
|
||||
fmpz_poly_div(XX(i, k), XX(i, k), LU(i, i));
|
||||
}
|
||||
}
|
||||
|
||||
fmpz_poly_clear(T);
|
||||
}
|
||||
38
external/flint-2.4.3/fmpz_poly_mat/sqr.c
vendored
Normal file
38
external/flint-2.4.3/fmpz_poly_mat/sqr.c
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_sqr(fmpz_poly_mat_t B, const fmpz_poly_mat_t A)
|
||||
{
|
||||
if (A->r < 8)
|
||||
fmpz_poly_mat_sqr_classical(B, A);
|
||||
else
|
||||
fmpz_poly_mat_sqr_KS(B, A);
|
||||
}
|
||||
80
external/flint-2.4.3/fmpz_poly_mat/sqr_KS.c
vendored
Normal file
80
external/flint-2.4.3/fmpz_poly_mat/sqr_KS.c
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/*=============================================================================
|
||||
|
||||
This file is part of FLINT.
|
||||
|
||||
FLINT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FLINT is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FLINT; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
=============================================================================*/
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 2011 Fredrik Johansson
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
#include "fmpz_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_sqr_KS(fmpz_poly_mat_t B, const fmpz_poly_mat_t A)
|
||||
{
|
||||
fmpz_mat_t AA, BB;
|
||||
slong i, j, n;
|
||||
slong A_len;
|
||||
int signs;
|
||||
slong A_bits, bit_size;
|
||||
|
||||
n = A->r;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
fmpz_poly_mat_zero(B);
|
||||
return;
|
||||
}
|
||||
|
||||
A_len = fmpz_poly_mat_max_length(A);
|
||||
A_bits = fmpz_poly_mat_max_bits(A);
|
||||
|
||||
signs = A_bits < 0;
|
||||
|
||||
bit_size = 2 * FLINT_ABS(A_bits) + signs;
|
||||
bit_size += FLINT_BIT_COUNT(A_len);
|
||||
bit_size += FLINT_BIT_COUNT(n);
|
||||
|
||||
fmpz_mat_init(AA, n, n);
|
||||
fmpz_mat_init(BB, n, n);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = 0; j < n; j++)
|
||||
fmpz_poly_bit_pack(fmpz_mat_entry(AA, i, j),
|
||||
fmpz_poly_mat_entry(A, i, j), bit_size);
|
||||
|
||||
/* Should use fmpz_mat_sqr */
|
||||
fmpz_mat_mul(BB, AA, AA);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = 0; j < n; j++)
|
||||
if (signs)
|
||||
fmpz_poly_bit_unpack(fmpz_poly_mat_entry(B, i, j),
|
||||
fmpz_mat_entry(BB, i, j), bit_size);
|
||||
else
|
||||
fmpz_poly_bit_unpack_unsigned(fmpz_poly_mat_entry(B, i, j),
|
||||
fmpz_mat_entry(BB, i, j), bit_size);
|
||||
|
||||
fmpz_mat_clear(AA);
|
||||
fmpz_mat_clear(BB);
|
||||
}
|
||||
72
external/flint-2.4.3/fmpz_poly_mat/sqr_classical.c
vendored
Normal file
72
external/flint-2.4.3/fmpz_poly_mat/sqr_classical.c
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
#define E fmpz_poly_mat_entry
|
||||
|
||||
void
|
||||
fmpz_poly_mat_sqr_classical(fmpz_poly_mat_t B, const fmpz_poly_mat_t A)
|
||||
{
|
||||
slong n = A->r;
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
if (n == 1)
|
||||
{
|
||||
fmpz_poly_sqr(E(B, 0, 0), E(A, 0, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
if (n == 2)
|
||||
{
|
||||
fmpz_poly_t t, u;
|
||||
|
||||
fmpz_poly_init(t);
|
||||
fmpz_poly_init(u);
|
||||
|
||||
fmpz_poly_add(t, E(A, 0, 0), E(A, 1, 1));
|
||||
fmpz_poly_mul(u, E(A, 0, 1), E(A, 1, 0));
|
||||
|
||||
fmpz_poly_sqr(E(B, 0, 0), E(A, 0, 0));
|
||||
fmpz_poly_add(E(B, 0, 0), E(B, 0, 0), u);
|
||||
|
||||
fmpz_poly_sqr(E(B, 1, 1), E(A, 1, 1));
|
||||
fmpz_poly_add(E(B, 1, 1), E(B, 1, 1), u);
|
||||
|
||||
fmpz_poly_mul(E(B, 0, 1), E(A, 0, 1), t);
|
||||
fmpz_poly_mul(E(B, 1, 0), E(A, 1, 0), t);
|
||||
|
||||
fmpz_poly_clear(t);
|
||||
fmpz_poly_clear(u);
|
||||
return;
|
||||
}
|
||||
|
||||
fmpz_poly_mat_mul_classical(B, A, A);
|
||||
}
|
||||
86
external/flint-2.4.3/fmpz_poly_mat/sqrlow.c
vendored
Normal file
86
external/flint-2.4.3/fmpz_poly_mat/sqrlow.c
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
#define E fmpz_poly_mat_entry
|
||||
|
||||
static __inline__ void
|
||||
fmpz_poly_addlow(fmpz_poly_t c, const fmpz_poly_t a,
|
||||
const fmpz_poly_t b, slong len)
|
||||
{
|
||||
fmpz_poly_add(c, a, b);
|
||||
fmpz_poly_truncate(c, len);
|
||||
}
|
||||
|
||||
void
|
||||
fmpz_poly_mat_sqrlow(fmpz_poly_mat_t B, const fmpz_poly_mat_t A, slong len)
|
||||
{
|
||||
slong n = A->r;
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
if (len < 1)
|
||||
{
|
||||
fmpz_poly_mat_zero(B);
|
||||
return;
|
||||
}
|
||||
|
||||
if (n == 1)
|
||||
{
|
||||
fmpz_poly_sqrlow(E(B, 0, 0), E(A, 0, 0), len);
|
||||
return;
|
||||
}
|
||||
|
||||
if (n == 2)
|
||||
{
|
||||
fmpz_poly_t t, u;
|
||||
|
||||
fmpz_poly_init(t);
|
||||
fmpz_poly_init(u);
|
||||
|
||||
fmpz_poly_addlow(t, E(A, 0, 0), E(A, 1, 1), len);
|
||||
fmpz_poly_mullow(u, E(A, 0, 1), E(A, 1, 0), len);
|
||||
|
||||
fmpz_poly_sqrlow(E(B, 0, 0), E(A, 0, 0), len);
|
||||
fmpz_poly_addlow(E(B, 0, 0), E(B, 0, 0), u, len);
|
||||
|
||||
fmpz_poly_sqrlow(E(B, 1, 1), E(A, 1, 1), len);
|
||||
fmpz_poly_addlow(E(B, 1, 1), E(B, 1, 1), u, len);
|
||||
|
||||
fmpz_poly_mullow(E(B, 0, 1), E(A, 0, 1), t, len);
|
||||
fmpz_poly_mullow(E(B, 1, 0), E(A, 1, 0), t, len);
|
||||
|
||||
fmpz_poly_clear(t);
|
||||
fmpz_poly_clear(u);
|
||||
return;
|
||||
}
|
||||
|
||||
fmpz_poly_mat_mullow(B, A, A, len);
|
||||
}
|
||||
42
external/flint-2.4.3/fmpz_poly_mat/sub.c
vendored
Normal file
42
external/flint-2.4.3/fmpz_poly_mat/sub.c
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_sub(fmpz_poly_mat_t C,
|
||||
const fmpz_poly_mat_t A, const fmpz_poly_mat_t B)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
for (j = 0; j < A->c; j++)
|
||||
fmpz_poly_sub(fmpz_poly_mat_entry(C, i, j),
|
||||
fmpz_poly_mat_entry(A, i, j),
|
||||
fmpz_poly_mat_entry(B, i, j));
|
||||
}
|
||||
42
external/flint-2.4.3/fmpz_poly_mat/swap.c
vendored
Normal file
42
external/flint-2.4.3/fmpz_poly_mat/swap.c
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_swap(fmpz_poly_mat_t A, fmpz_poly_mat_t B)
|
||||
{
|
||||
if (A != B)
|
||||
{
|
||||
fmpz_poly_mat_struct tmp;
|
||||
|
||||
tmp = *A;
|
||||
*A = *B;
|
||||
*B = tmp;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
43
external/flint-2.4.3/fmpz_poly_mat/trace.c
vendored
Normal file
43
external/flint-2.4.3/fmpz_poly_mat/trace.c
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_trace(fmpz_poly_t trace, const fmpz_poly_mat_t mat)
|
||||
{
|
||||
slong i, n = fmpz_poly_mat_nrows(mat);
|
||||
|
||||
if (n == 0)
|
||||
fmpz_poly_zero(trace);
|
||||
else
|
||||
{
|
||||
fmpz_poly_set(trace, fmpz_poly_mat_entry(mat, 0, 0));
|
||||
for (i = 1; i < n; i++)
|
||||
fmpz_poly_add(trace, trace, fmpz_poly_mat_entry(mat, i, i));
|
||||
}
|
||||
}
|
||||
55
external/flint-2.4.3/fmpz_poly_mat/transpose.c
vendored
Normal file
55
external/flint-2.4.3/fmpz_poly_mat/transpose.c
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 Fredrik Johansson
|
||||
Copyright (C) 2012 Sebastian Pancratz
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_transpose(fmpz_poly_mat_t B, const fmpz_poly_mat_t A)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
if (B->r != A->c || B->c != A->r)
|
||||
{
|
||||
flint_printf("Exception (fmpz_poly_mat_transpose). Incompatible dimensions.\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if (A == B) /* In-place, guaranteed to be square */
|
||||
{
|
||||
for (i = 0; i < A->r - 1; i++)
|
||||
for (j = i + 1; j < A->c; j++)
|
||||
fmpz_poly_swap(fmpz_poly_mat_entry(B, i, j),
|
||||
fmpz_poly_mat_entry(B, j, i));
|
||||
}
|
||||
else /* Not aliased; general case */
|
||||
{
|
||||
for (i = 0; i < B->r; i++)
|
||||
for (j = 0; j < B->c; j++)
|
||||
fmpz_poly_set(fmpz_poly_mat_entry(B, i, j),
|
||||
fmpz_poly_mat_entry(A, j, i));
|
||||
}
|
||||
}
|
||||
39
external/flint-2.4.3/fmpz_poly_mat/truncate.c
vendored
Normal file
39
external/flint-2.4.3/fmpz_poly_mat/truncate.c
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_truncate(fmpz_poly_mat_t A, slong len)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
for (i = 0; i < fmpz_poly_mat_nrows(A); i++)
|
||||
for (j = 0; j < fmpz_poly_mat_ncols(A); j++)
|
||||
fmpz_poly_truncate(fmpz_poly_mat_entry(A, i, j), len);
|
||||
}
|
||||
39
external/flint-2.4.3/fmpz_poly_mat/zero.c
vendored
Normal file
39
external/flint-2.4.3/fmpz_poly_mat/zero.c
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/*=============================================================================
|
||||
|
||||
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 <stdlib.h>
|
||||
#include "flint.h"
|
||||
#include "fmpz_poly.h"
|
||||
#include "fmpz_poly_mat.h"
|
||||
|
||||
void
|
||||
fmpz_poly_mat_zero(fmpz_poly_mat_t A)
|
||||
{
|
||||
slong i, j;
|
||||
|
||||
for (i = 0; i < A->r; i++)
|
||||
for (j = 0; j < A->c; j++)
|
||||
fmpz_poly_zero(fmpz_poly_mat_entry(A, i, j));
|
||||
}
|
||||
Reference in New Issue
Block a user