Merge pull request #50 from thofma/master

Add arb_mat_eq/ne (and more)!
This commit is contained in:
Fredrik Johansson 2015-10-09 17:10:21 +02:00
commit 108a37f3eb
10 changed files with 287 additions and 0 deletions

View file

@ -89,6 +89,10 @@ void acb_mat_set_round_fmpz_mat(acb_mat_t dest, const fmpz_mat_t src, long prec)
void acb_mat_set_fmpq_mat(acb_mat_t dest, const fmpq_mat_t src, long prec);
void acb_mat_set_arb_mat(acb_mat_t dest, const arb_mat_t src);
void acb_mat_set_round_arb_mat(acb_mat_t dest, const arb_mat_t src, long prec);
/* Random generation */
void acb_mat_randtest(acb_mat_t mat, flint_rand_t state, long prec, long mag_bits);
@ -99,6 +103,10 @@ void acb_mat_printd(const acb_mat_t mat, long digits);
/* Comparisons */
int acb_mat_eq(const acb_mat_t mat1, const acb_mat_t mat2);
int acb_mat_ne(const acb_mat_t mat1, const acb_mat_t mat2);
int acb_mat_equal(const acb_mat_t mat1, const acb_mat_t mat2);
int acb_mat_overlaps(const acb_mat_t mat1, const acb_mat_t mat2);

44
acb_mat/eq.c Normal file
View file

@ -0,0 +1,44 @@
/*=============================================================================
This file is part of ARB.
ARB 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.
ARB 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 ARB; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2015 Tommy Hofmann
******************************************************************************/
#include "acb_mat.h"
int
acb_mat_eq(const acb_mat_t mat1, const acb_mat_t mat2)
{
long i, j;
if ((acb_mat_nrows(mat1) != acb_mat_nrows(mat2)) ||
(acb_mat_ncols(mat1) != acb_mat_ncols(mat2)))
return 0;
for (i = 0; i < acb_mat_nrows(mat1); i++)
for (j = 0; j < acb_mat_ncols(mat1); j++)
if (!acb_eq(acb_mat_entry(mat1, i, j),
acb_mat_entry(mat2, i, j)))
return 0;
return 1;
}

44
acb_mat/ne.c Normal file
View file

@ -0,0 +1,44 @@
/*=============================================================================
This file is part of ARB.
ARB 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.
ARB 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 ARB; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2015 Tommy Hofmann
******************************************************************************/
#include "acb_mat.h"
int
acb_mat_ne(const acb_mat_t mat1, const acb_mat_t mat2)
{
long i, j;
if ((acb_mat_nrows(mat1) != acb_mat_nrows(mat2)) ||
(acb_mat_ncols(mat1) != acb_mat_ncols(mat2)))
return 1;
for (i = 0; i < acb_mat_nrows(mat1); i++)
for (j = 0; j < acb_mat_ncols(mat1); j++)
if (acb_ne(acb_mat_entry(mat1, i, j),
acb_mat_entry(mat2, i, j)))
return 1;
return 0;
}

40
acb_mat/set_arb_mat.c Normal file
View file

@ -0,0 +1,40 @@
/*=============================================================================
This file is part of ARB.
ARB 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.
ARB 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 ARB; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2015 Tommy Hofmann
******************************************************************************/
#include "acb_mat.h"
void
acb_mat_set_arb_mat(acb_mat_t dest, const arb_mat_t src)
{
long i, j;
if (acb_mat_ncols(dest) != 0)
{
for (i = 0; i < acb_mat_nrows(dest); i++)
for (j = 0; j < acb_mat_ncols(dest); j++)
acb_set_arb(acb_mat_entry(dest, i, j),
arb_mat_entry(src, i, j));
}
}

View file

@ -0,0 +1,40 @@
/*=============================================================================
This file is part of ARB.
ARB 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.
ARB 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 ARB; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2015 Tommy Hofmann
******************************************************************************/
#include "acb_mat.h"
void
acb_mat_set_round_arb_mat(acb_mat_t dest, const arb_mat_t src, long prec)
{
long i, j;
if (acb_mat_ncols(dest) != 0)
{
for (i = 0; i < acb_mat_nrows(dest); i++)
for (j = 0; j < acb_mat_ncols(dest); j++)
acb_set_round_arb(acb_mat_entry(dest, i, j),
arb_mat_entry(src, i, j), prec);
}
}

View file

@ -97,6 +97,10 @@ void arb_mat_printd(const arb_mat_t mat, long digits);
/* Comparisons */
int arb_mat_eq(const arb_mat_t mat1, const arb_mat_t mat2);
int arb_mat_ne(const arb_mat_t mat1, const arb_mat_t mat2);
int arb_mat_equal(const arb_mat_t mat1, const arb_mat_t mat2);
int arb_mat_overlaps(const arb_mat_t mat1, const arb_mat_t mat2);

44
arb_mat/eq.c Normal file
View file

@ -0,0 +1,44 @@
/*=============================================================================
This file is part of ARB.
ARB 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.
ARB 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 ARB; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2015 Tommy Hofmann
******************************************************************************/
#include "arb_mat.h"
int
arb_mat_eq(const arb_mat_t mat1, const arb_mat_t mat2)
{
long i, j;
if ((arb_mat_nrows(mat1) != arb_mat_nrows(mat2)) ||
(arb_mat_ncols(mat1) != arb_mat_ncols(mat2)))
return 0;
for (i = 0; i < arb_mat_nrows(mat1); i++)
for (j = 0; j < arb_mat_ncols(mat1); j++)
if (!arb_eq(arb_mat_entry(mat1, i, j),
arb_mat_entry(mat2, i, j)))
return 0;
return 1;
}

44
arb_mat/ne.c Normal file
View file

@ -0,0 +1,44 @@
/*=============================================================================
This file is part of ARB.
ARB 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.
ARB 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 ARB; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2015 Tommy Hofmann
******************************************************************************/
#include "arb_mat.h"
int
arb_mat_ne(const arb_mat_t mat1, const arb_mat_t mat2)
{
long i, j;
if ((arb_mat_nrows(mat1) != arb_mat_nrows(mat2)) ||
(arb_mat_ncols(mat1) != arb_mat_ncols(mat2)))
return 1;
for (i = 0; i < arb_mat_nrows(mat1); i++)
for (j = 0; j < arb_mat_ncols(mat1); j++)
if (arb_ne(arb_mat_entry(mat1, i, j),
arb_mat_entry(mat2, i, j)))
return 1;
return 0;
}

View file

@ -64,6 +64,10 @@ Conversions
.. function:: void acb_mat_set_fmpq_mat(acb_mat_t dest, const fmpq_mat_t src, long prec)
.. function:: void acb_mat_set_arb_mat(acb_mat_t dest, const arb_mat_t src)
.. function:: void acb_mat_set_round_arb_mat(acb_mat_t dest, const arb_mat_t src, long prec)
Sets *dest* to *src*. The operands must have identical dimensions.
Random generation
@ -103,6 +107,14 @@ Comparisons
Returns nonzero iff the matrices have the same dimensions and each entry
in *mat2* is contained in the corresponding entry in *mat1*.
.. function:: int acb_mat_eq(const acb_mat_t mat1, const acb_mat_t mat2)
Returns nonzero iff *mat1* and *mat2* certainly represent the same matrix.
.. function:: int acb_mat_ne(const acb_mat_t mat1, const acb_mat_t mat2)
Returns nonzero iff *mat1* and *mat2* certainly do not represent the same matrix.
.. function:: int acb_mat_is_real(const acb_mat_t mat)
Returns nonzero iff all entries in *mat* have zero imaginary part.

View file

@ -103,6 +103,13 @@ Comparisons
Returns nonzero iff the matrices have the same dimensions and each entry
in *mat2* is contained in the corresponding entry in *mat1*.
.. function:: int arb_mat_eq(const arb_mat_t mat1, const arb_mat_t mat2)
Returns nonzero iff *mat1* and *mat2* certainly represent the same matrix.
.. function:: int arb_mat_ne(const arb_mat_t mat1, const arb_mat_t mat2)
Returns nonzero iff *mat1* and *mat2* certainly do not represent the same matrix.
Special matrices
-------------------------------------------------------------------------------