add matrix infinity norm functions

This commit is contained in:
Fredrik Johansson 2013-11-11 18:21:55 +01:00
parent 5a3439de89
commit 7ce5df8690
6 changed files with 151 additions and 0 deletions

View file

@ -108,6 +108,16 @@ Special matrices
and all other entries to zero.
Norms
-------------------------------------------------------------------------------
.. function:: void fmpcb_mat_bound_inf_norm(fmpr_t b, const fmpcb_mat_t A, long prec)
Sets *b* to an upper bound for the infinity norm (i.e. the largest
absolute value row sum) of *A*, computed using floating-point arithmetic
at *prec* bits with all operations rounded up.
Arithmetic
-------------------------------------------------------------------------------

View file

@ -108,6 +108,15 @@ Special matrices
and all other entries to zero.
Norms
-------------------------------------------------------------------------------
.. function:: void fmprb_mat_bound_inf_norm(fmpr_t b, const fmprb_mat_t A, long prec)
Sets *b* to an upper bound for the infinity norm (i.e. the largest
absolute value row sum) of *A*, computed using floating-point arithmetic
at *prec* bits with all operations rounded up.
Arithmetic
-------------------------------------------------------------------------------

View file

@ -97,6 +97,10 @@ void fmpcb_mat_zero(fmpcb_mat_t mat);
void fmpcb_mat_one(fmpcb_mat_t mat);
/* Norms */
void fmpcb_mat_bound_inf_norm(fmpr_t b, const fmpcb_mat_t A, long prec);
/* Arithmetic */
void fmpcb_mat_neg(fmpcb_mat_t dest, const fmpcb_mat_t src);

View file

@ -0,0 +1,62 @@
/*=============================================================================
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) 2013 Fredrik Johansson
******************************************************************************/
#include "fmpcb_mat.h"
void
fmpcb_mat_bound_inf_norm(fmpr_t b, const fmpcb_mat_t A, long prec)
{
long i, j, r, c;
fmpr_t s, t;
r = fmpcb_mat_nrows(A);
c = fmpcb_mat_ncols(A);
fmpr_zero(b);
if (r == 0 || c == 0)
return;
fmpr_init(s);
fmpr_init(t);
for (i = 0; i < r; i++)
{
fmpr_zero(s);
for (j = 0; j < c; j++)
{
fmpcb_get_abs_ubound_fmpr(t, fmpcb_mat_entry(A, i, j), prec);
fmpr_add(s, s, t, prec, FMPR_RND_UP);
}
fmpr_max(b, b, s);
}
fmpr_clear(s);
fmpr_clear(t);
}

View file

@ -95,6 +95,10 @@ void fmprb_mat_zero(fmprb_mat_t mat);
void fmprb_mat_one(fmprb_mat_t mat);
/* Norms */
void fmprb_mat_bound_inf_norm(fmpr_t b, const fmprb_mat_t A, long prec);
/* Arithmetic */
void fmprb_mat_neg(fmprb_mat_t dest, const fmprb_mat_t src);

View file

@ -0,0 +1,62 @@
/*=============================================================================
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) 2013 Fredrik Johansson
******************************************************************************/
#include "fmprb_mat.h"
void
fmprb_mat_bound_inf_norm(fmpr_t b, const fmprb_mat_t A, long prec)
{
long i, j, r, c;
fmpr_t s, t;
r = fmprb_mat_nrows(A);
c = fmprb_mat_ncols(A);
fmpr_zero(b);
if (r == 0 || c == 0)
return;
fmpr_init(s);
fmpr_init(t);
for (i = 0; i < r; i++)
{
fmpr_zero(s);
for (j = 0; j < c; j++)
{
fmprb_get_abs_ubound_fmpr(t, fmprb_mat_entry(A, i, j), prec);
fmpr_add(s, s, t, prec, FMPR_RND_UP);
}
fmpr_max(b, b, s);
}
fmpr_clear(s);
fmpr_clear(t);
}