mirror of
https://github.com/vale981/arb
synced 2025-03-04 17:01:40 -05:00
more public matrix helpers: is_zero, is_finite, is_triu, is_tril, is_diag, diag_prod
This commit is contained in:
parent
40026fd69d
commit
101a95cd25
21 changed files with 442 additions and 177 deletions
14
acb_mat.h
14
acb_mat.h
|
@ -136,6 +136,17 @@ acb_mat_is_square(const acb_mat_t mat)
|
|||
return (mat->r == mat->c);
|
||||
}
|
||||
|
||||
int acb_mat_is_zero(const acb_mat_t mat);
|
||||
int acb_mat_is_finite(const acb_mat_t mat);
|
||||
int acb_mat_is_triu(const acb_mat_t mat);
|
||||
int acb_mat_is_tril(const acb_mat_t mat);
|
||||
|
||||
ACB_MAT_INLINE int
|
||||
acb_mat_is_diag(const acb_mat_t mat)
|
||||
{
|
||||
return acb_mat_is_tril(mat) && acb_mat_is_triu(mat);
|
||||
}
|
||||
|
||||
/* Radius and interval operations */
|
||||
|
||||
ACB_MAT_INLINE void
|
||||
|
@ -439,6 +450,9 @@ void acb_mat_companion(acb_mat_t mat, const acb_poly_t poly, slong prec);
|
|||
|
||||
void acb_mat_trace(acb_t trace, const acb_mat_t mat, slong prec);
|
||||
|
||||
void _acb_mat_diag_prod(acb_t res, const acb_mat_t A, slong a, slong b, slong prec);
|
||||
void acb_mat_diag_prod(acb_t res, const acb_mat_t A, slong prec);
|
||||
|
||||
ACB_MAT_INLINE slong
|
||||
acb_mat_allocated_bytes(const acb_mat_t x)
|
||||
{
|
||||
|
|
|
@ -39,79 +39,6 @@ _acb_mat_det_cofactor_3x3(acb_t t, const acb_mat_t A, slong prec)
|
|||
acb_clear(a);
|
||||
}
|
||||
|
||||
int
|
||||
acb_mat_is_finite(const acb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = acb_mat_nrows(A);
|
||||
m = acb_mat_ncols(A);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = 0; j < m; j++)
|
||||
if (!acb_is_finite(acb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
acb_mat_is_triu(const acb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = acb_mat_nrows(A);
|
||||
m = acb_mat_ncols(A);
|
||||
|
||||
for (i = 1; i < n; i++)
|
||||
for (j = 0; j < FLINT_MIN(i, m); j++)
|
||||
if (!acb_is_zero(acb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
acb_mat_is_tril(const acb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = acb_mat_nrows(A);
|
||||
m = acb_mat_ncols(A);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = i + 1; j < m; j++)
|
||||
if (!acb_is_zero(acb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
acb_mat_diag_prod(acb_t res, const acb_mat_t A, slong a, slong b, slong prec)
|
||||
{
|
||||
if (b - a == 0)
|
||||
acb_one(res);
|
||||
else if (b - a == 1)
|
||||
acb_set_round(res, acb_mat_entry(A, a, a), prec);
|
||||
else if (b - a == 2)
|
||||
acb_mul(res, acb_mat_entry(A, a, a), acb_mat_entry(A, a + 1, a + 1), prec);
|
||||
else if (b - a == 3)
|
||||
{
|
||||
acb_mul(res, acb_mat_entry(A, a, a), acb_mat_entry(A, a + 1, a + 1), prec);
|
||||
acb_mul(res, res, acb_mat_entry(A, a + 2, a + 2), prec);
|
||||
}
|
||||
else
|
||||
{
|
||||
acb_t t;
|
||||
acb_init(t);
|
||||
acb_mat_diag_prod(t, A, a, a + (b - a) / 2, prec);
|
||||
acb_mat_diag_prod(res, A, a + (b - a) / 2, b, prec);
|
||||
acb_mul(res, res, t, prec);
|
||||
acb_clear(t);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
acb_mat_det(acb_t det, const acb_mat_t A, slong prec)
|
||||
{
|
||||
|
@ -143,7 +70,7 @@ acb_mat_det(acb_t det, const acb_mat_t A, slong prec)
|
|||
}
|
||||
else if (acb_mat_is_tril(A) || acb_mat_is_triu(A))
|
||||
{
|
||||
acb_mat_diag_prod(det, A, 0, n, prec);
|
||||
acb_mat_diag_prod(det, A, prec);
|
||||
}
|
||||
else if (n == 3)
|
||||
{
|
||||
|
@ -158,4 +85,3 @@ acb_mat_det(acb_t det, const acb_mat_t A, slong prec)
|
|||
acb_mat_det_precond(det, A, prec);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,9 +78,6 @@ acb_vec_get_arf_2norm_squared_bound(arf_t s, acb_srcptr vec, slong len, slong pr
|
|||
arf_clear(t);
|
||||
}
|
||||
|
||||
void
|
||||
acb_mat_diag_prod(acb_t res, const acb_mat_t A, slong a, slong b, slong prec);
|
||||
|
||||
void
|
||||
acb_mat_det_lu_inplace(acb_t det, acb_mat_t A, slong prec)
|
||||
{
|
||||
|
@ -92,7 +89,7 @@ acb_mat_det_lu_inplace(acb_t det, acb_mat_t A, slong prec)
|
|||
sign = (rank < 0) ? -1 : 1;
|
||||
rank = FLINT_ABS(rank);
|
||||
|
||||
acb_mat_diag_prod(det, A, 0, rank, prec);
|
||||
_acb_mat_diag_prod(det, A, 0, rank, prec);
|
||||
acb_mul_si(det, det, sign, prec);
|
||||
|
||||
/* bound unreduced part using Hadamard's inequality */
|
||||
|
|
|
@ -74,9 +74,6 @@ acb_mat_det_one_gershgorin(acb_t det, const acb_mat_t A)
|
|||
mag_clear(f);
|
||||
}
|
||||
|
||||
void
|
||||
acb_mat_diag_prod(acb_t res, const acb_mat_t A, slong a, slong b, slong prec);
|
||||
|
||||
void
|
||||
acb_mat_det_precond(acb_t det, const acb_mat_t A, slong prec)
|
||||
{
|
||||
|
@ -113,7 +110,7 @@ acb_mat_det_precond(acb_t det, const acb_mat_t A, slong prec)
|
|||
acb_mat_one(Uinv);
|
||||
acb_mat_approx_solve_triu(Uinv, LU, Uinv, 0, prec);
|
||||
|
||||
acb_mat_diag_prod(detU, Uinv, 0, n, prec);
|
||||
acb_mat_diag_prod(detU, Uinv, prec);
|
||||
|
||||
acb_mat_mul(LU, A, Uinv, prec);
|
||||
_apply_permutation(LU, P, n);
|
||||
|
@ -158,4 +155,3 @@ acb_mat_det_precond(acb_t det, const acb_mat_t A, slong prec)
|
|||
_perm_clear(P);
|
||||
acb_mat_clear(LU);
|
||||
}
|
||||
|
||||
|
|
48
acb_mat/diag_prod.c
Normal file
48
acb_mat/diag_prod.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
Copyright (C) 2018 Fredrik Johansson
|
||||
|
||||
This file is part of Arb.
|
||||
|
||||
Arb is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||
by the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "acb_mat.h"
|
||||
|
||||
void
|
||||
_acb_mat_diag_prod(acb_t res, const acb_mat_t A, slong a, slong b, slong prec)
|
||||
{
|
||||
if (b - a == 0)
|
||||
acb_one(res);
|
||||
else if (b - a == 1)
|
||||
acb_set_round(res, acb_mat_entry(A, a, a), prec);
|
||||
else if (b - a == 2)
|
||||
acb_mul(res, acb_mat_entry(A, a, a), acb_mat_entry(A, a + 1, a + 1), prec);
|
||||
else if (b - a == 3)
|
||||
{
|
||||
acb_mul(res, acb_mat_entry(A, a, a), acb_mat_entry(A, a + 1, a + 1), prec);
|
||||
acb_mul(res, res, acb_mat_entry(A, a + 2, a + 2), prec);
|
||||
}
|
||||
else
|
||||
{
|
||||
acb_t t;
|
||||
acb_init(t);
|
||||
_acb_mat_diag_prod(t, A, a, a + (b - a) / 2, prec);
|
||||
_acb_mat_diag_prod(res, A, a + (b - a) / 2, b, prec);
|
||||
acb_mul(res, res, t, prec);
|
||||
acb_clear(t);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
acb_mat_diag_prod(acb_t res, const acb_mat_t A, slong prec)
|
||||
{
|
||||
slong m, n;
|
||||
|
||||
m = acb_mat_nrows(A);
|
||||
n = acb_mat_nrows(A);
|
||||
|
||||
_acb_mat_diag_prod(res, A, 0, FLINT_MIN(m, n), prec);
|
||||
}
|
28
acb_mat/is_finite.c
Normal file
28
acb_mat/is_finite.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Copyright (C) 2018 Fredrik Johansson
|
||||
|
||||
This file is part of Arb.
|
||||
|
||||
Arb is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||
by the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "acb_mat.h"
|
||||
|
||||
int
|
||||
acb_mat_is_finite(const acb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = acb_mat_nrows(A);
|
||||
m = acb_mat_ncols(A);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = 0; j < m; j++)
|
||||
if (!acb_is_finite(acb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
28
acb_mat/is_tril.c
Normal file
28
acb_mat/is_tril.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Copyright (C) 2018 Fredrik Johansson
|
||||
|
||||
This file is part of Arb.
|
||||
|
||||
Arb is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||
by the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "acb_mat.h"
|
||||
|
||||
int
|
||||
acb_mat_is_tril(const acb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = acb_mat_nrows(A);
|
||||
m = acb_mat_ncols(A);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = i + 1; j < m; j++)
|
||||
if (!acb_is_zero(acb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
28
acb_mat/is_triu.c
Normal file
28
acb_mat/is_triu.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Copyright (C) 2018 Fredrik Johansson
|
||||
|
||||
This file is part of Arb.
|
||||
|
||||
Arb is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||
by the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "acb_mat.h"
|
||||
|
||||
int
|
||||
acb_mat_is_triu(const acb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = acb_mat_nrows(A);
|
||||
m = acb_mat_ncols(A);
|
||||
|
||||
for (i = 1; i < n; i++)
|
||||
for (j = 0; j < FLINT_MIN(i, m); j++)
|
||||
if (!acb_is_zero(acb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
28
acb_mat/is_zero.c
Normal file
28
acb_mat/is_zero.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Copyright (C) 2018 Fredrik Johansson
|
||||
|
||||
This file is part of Arb.
|
||||
|
||||
Arb is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||
by the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "acb_mat.h"
|
||||
|
||||
int
|
||||
acb_mat_is_zero(const acb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = acb_mat_nrows(A);
|
||||
m = acb_mat_ncols(A);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = 0; j < m; j++)
|
||||
if (!acb_is_zero(acb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
14
arb_mat.h
14
arb_mat.h
|
@ -126,6 +126,17 @@ arb_mat_is_square(const arb_mat_t mat)
|
|||
return (mat->r == mat->c);
|
||||
}
|
||||
|
||||
int arb_mat_is_zero(const arb_mat_t mat);
|
||||
int arb_mat_is_finite(const arb_mat_t mat);
|
||||
int arb_mat_is_triu(const arb_mat_t mat);
|
||||
int arb_mat_is_tril(const arb_mat_t mat);
|
||||
|
||||
ARB_MAT_INLINE int
|
||||
arb_mat_is_diag(const arb_mat_t mat)
|
||||
{
|
||||
return arb_mat_is_tril(mat) && arb_mat_is_triu(mat);
|
||||
}
|
||||
|
||||
/* Radius and interval operations */
|
||||
|
||||
ARB_MAT_INLINE void
|
||||
|
@ -404,6 +415,9 @@ void arb_mat_companion(arb_mat_t mat, const arb_poly_t poly, slong prec);
|
|||
|
||||
void arb_mat_trace(arb_t trace, const arb_mat_t mat, slong prec);
|
||||
|
||||
void _arb_mat_diag_prod(arb_t res, const arb_mat_t A, slong a, slong b, slong prec);
|
||||
void arb_mat_diag_prod(arb_t res, const arb_mat_t A, slong prec);
|
||||
|
||||
/* Sparsity structure */
|
||||
|
||||
void arb_mat_entrywise_is_zero(fmpz_mat_t dest, const arb_mat_t src);
|
||||
|
|
|
@ -39,54 +39,6 @@ _arb_mat_det_cofactor_3x3(arb_t t, const arb_mat_t A, slong prec)
|
|||
arb_clear(a);
|
||||
}
|
||||
|
||||
int
|
||||
arb_mat_is_finite(const arb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = arb_mat_nrows(A);
|
||||
m = arb_mat_ncols(A);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = 0; j < m; j++)
|
||||
if (!arb_is_finite(arb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
arb_mat_is_triu(const arb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = arb_mat_nrows(A);
|
||||
m = arb_mat_ncols(A);
|
||||
|
||||
for (i = 1; i < n; i++)
|
||||
for (j = 0; j < FLINT_MIN(i, m); j++)
|
||||
if (!arb_is_zero(arb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
arb_mat_is_tril(const arb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = arb_mat_nrows(A);
|
||||
m = arb_mat_ncols(A);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = i + 1; j < m; j++)
|
||||
if (!arb_is_zero(arb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
arb_mat_det(arb_t det, const arb_mat_t A, slong prec)
|
||||
{
|
||||
|
@ -118,9 +70,7 @@ arb_mat_det(arb_t det, const arb_mat_t A, slong prec)
|
|||
}
|
||||
else if (arb_mat_is_tril(A) || arb_mat_is_triu(A))
|
||||
{
|
||||
arb_set(det, arb_mat_entry(A, 0, 0));
|
||||
for (k = 1; k < n; k++)
|
||||
arb_mul(det, det, arb_mat_entry(A, k, k), prec);
|
||||
arb_mat_diag_prod(det, A, prec);
|
||||
}
|
||||
else if (n == 3)
|
||||
{
|
||||
|
|
|
@ -140,4 +140,3 @@ arb_mat_det_lu(arb_t det, const arb_mat_t A, slong prec)
|
|||
arb_mat_clear(T);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ arb_mat_det_precond(arb_t det, const arb_mat_t A, slong prec)
|
|||
{
|
||||
arb_mat_t LU, Linv, Uinv;
|
||||
arb_t detU;
|
||||
slong i, n;
|
||||
slong n;
|
||||
slong *P;
|
||||
|
||||
n = arb_mat_nrows(A);
|
||||
|
@ -109,9 +109,7 @@ arb_mat_det_precond(arb_t det, const arb_mat_t A, slong prec)
|
|||
arb_mat_one(Uinv);
|
||||
arb_mat_approx_solve_triu(Uinv, LU, Uinv, 0, prec);
|
||||
|
||||
arb_set(detU, arb_mat_entry(Uinv, 0, 0));
|
||||
for (i = 1; i < n; i++)
|
||||
arb_mul(detU, detU, arb_mat_entry(Uinv, i, i), prec);
|
||||
arb_mat_diag_prod(detU, Uinv, prec);
|
||||
|
||||
arb_mat_mul(LU, A, Uinv, prec);
|
||||
_apply_permutation(LU, P, n);
|
||||
|
@ -141,4 +139,3 @@ arb_mat_det_precond(arb_t det, const arb_mat_t A, slong prec)
|
|||
_perm_clear(P);
|
||||
arb_mat_clear(LU);
|
||||
}
|
||||
|
||||
|
|
55
arb_mat/diag_prod.c
Normal file
55
arb_mat/diag_prod.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
Copyright (C) 2018 Fredrik Johansson
|
||||
|
||||
This file is part of Arb.
|
||||
|
||||
Arb is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||
by the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "arb_mat.h"
|
||||
|
||||
void
|
||||
_arb_mat_diag_prod(arb_t res, const arb_mat_t A, slong a, slong b, slong prec)
|
||||
{
|
||||
if (b - a == 0)
|
||||
{
|
||||
arb_one(res);
|
||||
}
|
||||
else if (b - a == 1)
|
||||
{
|
||||
arb_set_round(res, arb_mat_entry(A, a, a), prec);
|
||||
}
|
||||
else
|
||||
{
|
||||
slong i;
|
||||
|
||||
arb_mul(res, arb_mat_entry(A, a, a), arb_mat_entry(A, a + 1, a + 1), prec);
|
||||
for (i = a + 2; i < b; i++)
|
||||
arb_mul(res, res, arb_mat_entry(A, i, i), prec);
|
||||
|
||||
/* no advantage? */
|
||||
|
||||
/*
|
||||
arb_t t;
|
||||
arb_init(t);
|
||||
_arb_mat_diag_prod(t, A, a, a + (b - a) / 2, prec);
|
||||
_arb_mat_diag_prod(res, A, a + (b - a) / 2, b, prec);
|
||||
arb_mul(res, res, t, prec);
|
||||
arb_clear(t);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
arb_mat_diag_prod(arb_t res, const arb_mat_t A, slong prec)
|
||||
{
|
||||
slong m, n;
|
||||
|
||||
m = arb_mat_nrows(A);
|
||||
n = arb_mat_nrows(A);
|
||||
|
||||
_arb_mat_diag_prod(res, A, 0, FLINT_MIN(m, n), prec);
|
||||
}
|
28
arb_mat/is_finite.c
Normal file
28
arb_mat/is_finite.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Copyright (C) 2018 Fredrik Johansson
|
||||
|
||||
This file is part of Arb.
|
||||
|
||||
Arb is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||
by the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "arb_mat.h"
|
||||
|
||||
int
|
||||
arb_mat_is_finite(const arb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = arb_mat_nrows(A);
|
||||
m = arb_mat_ncols(A);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = 0; j < m; j++)
|
||||
if (!arb_is_finite(arb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
28
arb_mat/is_tril.c
Normal file
28
arb_mat/is_tril.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Copyright (C) 2018 Fredrik Johansson
|
||||
|
||||
This file is part of Arb.
|
||||
|
||||
Arb is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||
by the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "arb_mat.h"
|
||||
|
||||
int
|
||||
arb_mat_is_tril(const arb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = arb_mat_nrows(A);
|
||||
m = arb_mat_ncols(A);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = i + 1; j < m; j++)
|
||||
if (!arb_is_zero(arb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
28
arb_mat/is_triu.c
Normal file
28
arb_mat/is_triu.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Copyright (C) 2018 Fredrik Johansson
|
||||
|
||||
This file is part of Arb.
|
||||
|
||||
Arb is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||
by the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "arb_mat.h"
|
||||
|
||||
int
|
||||
arb_mat_is_triu(const arb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = arb_mat_nrows(A);
|
||||
m = arb_mat_ncols(A);
|
||||
|
||||
for (i = 1; i < n; i++)
|
||||
for (j = 0; j < FLINT_MIN(i, m); j++)
|
||||
if (!arb_is_zero(arb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
28
arb_mat/is_zero.c
Normal file
28
arb_mat/is_zero.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Copyright (C) 2018 Fredrik Johansson
|
||||
|
||||
This file is part of Arb.
|
||||
|
||||
Arb is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License (LGPL) as published
|
||||
by the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version. See <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "arb_mat.h"
|
||||
|
||||
int
|
||||
arb_mat_is_zero(const arb_mat_t A)
|
||||
{
|
||||
slong i, j, n, m;
|
||||
|
||||
n = arb_mat_nrows(A);
|
||||
m = arb_mat_ncols(A);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = 0; j < m; j++)
|
||||
if (!arb_is_zero(arb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -30,25 +30,6 @@ int arb_mat_is_lagom(const arb_mat_t A)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int arb_mat_is_zero(const arb_mat_t A)
|
||||
{
|
||||
slong i, j, M, N;
|
||||
|
||||
M = arb_mat_nrows(A);
|
||||
N = arb_mat_ncols(A);
|
||||
|
||||
for (i = 0; i < M; i++)
|
||||
{
|
||||
for (j = 0; j < N; j++)
|
||||
{
|
||||
if (!arb_is_zero(arb_mat_entry(A, i, j)))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* allow changing this from the test code */
|
||||
ARB_DLL slong arb_mat_mul_block_min_block_size = 0;
|
||||
|
||||
|
|
|
@ -126,14 +126,16 @@ Input and output
|
|||
Comparisons
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Predicate methods return 1 if the property certainly holds and 0 otherwise.
|
||||
|
||||
.. function:: int acb_mat_equal(const acb_mat_t mat1, const acb_mat_t mat2)
|
||||
|
||||
Returns nonzero iff the matrices have the same dimensions
|
||||
and identical entries.
|
||||
Returns whether the matrices have the same dimensions and identical
|
||||
intervals as entries.
|
||||
|
||||
.. function:: int acb_mat_overlaps(const acb_mat_t mat1, const acb_mat_t mat2)
|
||||
|
||||
Returns nonzero iff the matrices have the same dimensions
|
||||
Returns whether the matrices have the same dimensions
|
||||
and each entry in *mat1* overlaps with the corresponding entry in *mat2*.
|
||||
|
||||
.. function:: int acb_mat_contains(const acb_mat_t mat1, const acb_mat_t mat2)
|
||||
|
@ -142,29 +144,51 @@ Comparisons
|
|||
|
||||
.. function:: int acb_mat_contains_fmpq_mat(const acb_mat_t mat1, const fmpq_mat_t mat2)
|
||||
|
||||
Returns nonzero iff the matrices have the same dimensions and each entry
|
||||
Returns whether 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.
|
||||
Returns whether *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.
|
||||
Returns whether *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.
|
||||
Returns whether all entries in *mat* have zero imaginary part.
|
||||
|
||||
.. function:: int acb_mat_is_empty(const acb_mat_t mat)
|
||||
|
||||
Returns nonzero iff the number of rows or the number of columns in *mat* is zero.
|
||||
Returns whether the number of rows or the number of columns in *mat* is zero.
|
||||
|
||||
.. function:: int acb_mat_is_square(const acb_mat_t mat)
|
||||
|
||||
Returns nonzero iff the number of rows is equal to the number of columns in *mat*.
|
||||
Returns whether the number of rows is equal to the number of columns in *mat*.
|
||||
|
||||
.. function:: int acb_mat_is_zero(const acb_mat_t mat)
|
||||
|
||||
Returns whether all entries in *mat* are exactly zero.
|
||||
|
||||
.. function:: int acb_mat_is_finite(const acb_mat_t mat)
|
||||
|
||||
Returns whether all entries in *mat* are finite.
|
||||
|
||||
.. function:: int acb_mat_is_triu(const acb_mat_t mat)
|
||||
|
||||
Returns whether *mat* is upper triangular; that is, all entries
|
||||
below the main diagonal are exactly zero.
|
||||
|
||||
.. function:: int acb_mat_is_tril(const acb_mat_t mat)
|
||||
|
||||
Returns whether *mat* is lower triangular; that is, all entries
|
||||
above the main diagonal are exactly zero.
|
||||
|
||||
.. function:: int acb_mat_is_diag(const acb_mat_t mat)
|
||||
|
||||
Returns whether *mat* is a diagonal matrix; that is, all entries
|
||||
off the main diagonal are exactly zero.
|
||||
|
||||
Special matrices
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -529,6 +553,13 @@ Special functions
|
|||
Sets *trace* to the trace of the matrix, i.e. the sum of entries on the
|
||||
main diagonal of *mat*. The matrix is required to be square.
|
||||
|
||||
.. function:: void _acb_mat_diag_prod(acb_t res, const acb_mat_t mat, slong a, slong b, slong prec)
|
||||
|
||||
.. function:: void acb_mat_diag_prod(acb_t res, const acb_mat_t mat, slong prec)
|
||||
|
||||
Sets *res* to the product of the entries on the main diagonal of *mat*.
|
||||
The underscore method computes the product of the entries between
|
||||
index *a* inclusive and *b* exclusive (the indices must be in range).
|
||||
|
||||
Component and error operations
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
|
@ -115,14 +115,16 @@ Input and output
|
|||
Comparisons
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Predicate methods return 1 if the property certainly holds and 0 otherwise.
|
||||
|
||||
.. function:: int arb_mat_equal(const arb_mat_t mat1, const arb_mat_t mat2)
|
||||
|
||||
Returns nonzero iff the matrices have the same dimensions
|
||||
and identical entries.
|
||||
Returns whether the matrices have the same dimensions
|
||||
and identical intervals as entries.
|
||||
|
||||
.. function:: int arb_mat_overlaps(const arb_mat_t mat1, const arb_mat_t mat2)
|
||||
|
||||
Returns nonzero iff the matrices have the same dimensions
|
||||
Returns whether the matrices have the same dimensions
|
||||
and each entry in *mat1* overlaps with the corresponding entry in *mat2*.
|
||||
|
||||
.. function:: int arb_mat_contains(const arb_mat_t mat1, const arb_mat_t mat2)
|
||||
|
@ -131,24 +133,47 @@ Comparisons
|
|||
|
||||
.. function:: int arb_mat_contains_fmpq_mat(const arb_mat_t mat1, const fmpq_mat_t mat2)
|
||||
|
||||
Returns nonzero iff the matrices have the same dimensions and each entry
|
||||
Returns whether 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.
|
||||
Returns whether *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.
|
||||
Returns whether *mat1* and *mat2* certainly do not represent the same matrix.
|
||||
|
||||
.. function:: int arb_mat_is_empty(const arb_mat_t mat)
|
||||
|
||||
Returns nonzero iff the number of rows or the number of columns in *mat* is zero.
|
||||
Returns whether the number of rows or the number of columns in *mat* is zero.
|
||||
|
||||
.. function:: int arb_mat_is_square(const arb_mat_t mat)
|
||||
|
||||
Returns nonzero iff the number of rows is equal to the number of columns in *mat*.
|
||||
Returns whether the number of rows is equal to the number of columns in *mat*.
|
||||
|
||||
.. function:: int arb_mat_is_zero(const arb_mat_t mat)
|
||||
|
||||
Returns whether all entries in *mat* are exactly zero.
|
||||
|
||||
.. function:: int arb_mat_is_finite(const arb_mat_t mat)
|
||||
|
||||
Returns whether all entries in *mat* are finite.
|
||||
|
||||
.. function:: int arb_mat_is_triu(const arb_mat_t mat)
|
||||
|
||||
Returns whether *mat* is upper triangular; that is, all entries
|
||||
below the main diagonal are exactly zero.
|
||||
|
||||
.. function:: int arb_mat_is_tril(const arb_mat_t mat)
|
||||
|
||||
Returns whether *mat* is lower triangular; that is, all entries
|
||||
above the main diagonal are exactly zero.
|
||||
|
||||
.. function:: int arb_mat_is_diag(const arb_mat_t mat)
|
||||
|
||||
Returns whether *mat* is a diagonal matrix; that is, all entries
|
||||
off the main diagonal are exactly zero.
|
||||
|
||||
Special matrices
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -677,6 +702,14 @@ Special functions
|
|||
Sets *trace* to the trace of the matrix, i.e. the sum of entries on the
|
||||
main diagonal of *mat*. The matrix is required to be square.
|
||||
|
||||
.. function:: void _arb_mat_diag_prod(arb_t res, const arb_mat_t mat, slong a, slong b, slong prec)
|
||||
|
||||
.. function:: void arb_mat_diag_prod(arb_t res, const arb_mat_t mat, slong prec)
|
||||
|
||||
Sets *res* to the product of the entries on the main diagonal of *mat*.
|
||||
The underscore method computes the product of the entries between
|
||||
index *a* inclusive and *b* exclusive (the indices must be in range).
|
||||
|
||||
Sparsity structure
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue