# [petsc-users] Pseudoinverse of a large matrix

Chetan Jhurani chetan.jhurani at gmail.com
Mon Dec 19 13:35:27 CST 2011

```I'm assuming below that the matrix is either badly conditioned or is rank-deficient

with unknown null-space which made you choose SVD.  If none of these assumptions

is true, better methods exist that can use the null-space information.

Anyway.  It is faster to use Rank-Revealing QR instead of SVD for pseudoinverse.

You can use the attached Matlab script, which computes pseudoinverse and left and right

null-spaces using RRQR, and compare the time with Matlab's SVD based pinv.  Note

that it computes the full pseudoinverse matrix instead of solving for a specific right hand

side (which would be faster and not frowned upon).

Couple of optimizations not there currently.

1.   It can be changed to use sparse RRQR factorization for sparse input matrix.

2.   It can be further optimized using the Woodbury identity for two cases -

rank <= size or rank >= size to reduce the size of auxiliary internal Cholesky solve.

Chetan

From: petsc-users-bounces at mcs.anl.gov [mailto:petsc-users-bounces at mcs.anl.gov] On Behalf Of Modhurita Mitra
Sent: Monday, December 19, 2011 11:01 AM
To: PETSc users list
Subject: Re: [petsc-users] Pseudoinverse of a large matrix

I am trying to express the radiation pattern of an antenna in terms of spherical harmonic basis functions. I have radiation pattern
data at N=324360 points. Therefore, my matrix is spherical harmonic basis functions evaluated till order sqrt(N) (which makes up at
total of N elements), evaluated at N data points. So this is a linear least squares problem, and I have been trying to solve it by
finding its pseudoinverse which uses SVD. The elements of the matrix are complex, and the matrix is non-sparse. I have solved it in
MATLAB using a subsample of the data, but MATLAB runs out of memory while calculating the SVD at input matrix size 2500 X 2500. I
need to solve this problem using the entire data.

I was thinking of using SLEPc because I found a ready-to-use code which computes the SVD of a complex-valued matrix (
http://www.grycap.upv.es/slepc/documentation/current/src/svd/examples/tutorials/ex14.c.html ). I don't know how to use either PETSc
or SLEPc (or Elemental) yet, so I am trying to figure out where to start and what I should learn.

Thanks,
Modhurita

On Mon, Dec 19, 2011 at 12:31 PM, Matthew Knepley <knepley at gmail.com> wrote:

On Mon, Dec 19, 2011 at 12:21 PM, Modhurita Mitra <modhurita at gmail.com> wrote:

Hi,

I have to compute the pseudoinverse of a 324360 X 324360 matrix. Can PETSc compute the SVD of this matrix without parallelization?
If parallelization is needed, do I need to use SLEPc?

With enough memory, yes. However, I am not sure you want to wait. I am not sure how SLEPc would help here.

>From the very very little detail you have given, you would need parallel linear algebra, like Elemental. However,

I would start out from a more fundamental viewpoint. Such as replacing "compute the psuedoinverse" with

"solve a least-squares problem" if that is indeed the case.

Matt

Thanks,
Modhurita

--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to
-- Norbert Wiener

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111219/517299e8/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pinv_rrqr.m
Type: application/mathematica
Size: 1724 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111219/517299e8/attachment.nb>
```