add arb_mat_approx_inv, acb_mat_approx_inv

This commit is contained in:
fredrik 2018-11-28 11:11:13 +01:00
parent 2538a490d1
commit ea664619ee
4 changed files with 62 additions and 0 deletions

View file

@ -397,6 +397,7 @@ void acb_mat_approx_solve_tril(acb_mat_t X, const acb_mat_t L, const acb_mat_t B
int acb_mat_approx_lu(slong * P, acb_mat_t LU, const acb_mat_t A, slong prec);
void acb_mat_approx_solve_lu_precomp(acb_mat_t X, const slong * perm, const acb_mat_t A, const acb_mat_t B, slong prec);
int acb_mat_approx_solve(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec);
int acb_mat_approx_inv(acb_mat_t X, const acb_mat_t A, slong prec);
int acb_mat_inv(acb_mat_t X, const acb_mat_t A, slong prec);

30
acb_mat/approx_inv.c Normal file
View file

@ -0,0 +1,30 @@
/*
Copyright (C) 2012 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_approx_inv(acb_mat_t X, const acb_mat_t A, slong prec)
{
if (X == A)
{
int r;
acb_mat_t T;
acb_mat_init(T, acb_mat_nrows(A), acb_mat_ncols(A));
r = acb_mat_approx_inv(T, A, prec);
acb_mat_swap(T, X);
acb_mat_clear(T);
return r;
}
acb_mat_one(X);
return acb_mat_approx_solve(X, A, X, prec);
}

View file

@ -357,6 +357,7 @@ void arb_mat_approx_solve_tril(arb_mat_t X, const arb_mat_t L, const arb_mat_t B
int arb_mat_approx_lu(slong * P, arb_mat_t LU, const arb_mat_t A, slong prec);
void arb_mat_approx_solve_lu_precomp(arb_mat_t X, const slong * perm, const arb_mat_t A, const arb_mat_t B, slong prec);
int arb_mat_approx_solve(arb_mat_t X, const arb_mat_t A, const arb_mat_t B, slong prec);
int arb_mat_approx_inv(arb_mat_t X, const arb_mat_t A, slong prec);
int arb_mat_inv(arb_mat_t X, const arb_mat_t A, slong prec);

30
arb_mat/approx_inv.c Normal file
View file

@ -0,0 +1,30 @@
/*
Copyright (C) 2012 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_approx_inv(arb_mat_t X, const arb_mat_t A, slong prec)
{
if (X == A)
{
int r;
arb_mat_t T;
arb_mat_init(T, arb_mat_nrows(A), arb_mat_ncols(A));
r = arb_mat_approx_inv(T, A, prec);
arb_mat_swap(T, X);
arb_mat_clear(T);
return r;
}
arb_mat_one(X);
return arb_mat_approx_solve(X, A, X, prec);
}