matrix inverse

81 views
Skip to first unread message

aortizb

unread,
Sep 15, 2009, 4:45:48 PM9/15/09
to matrixprogramming
Hi there,

Is there any way I can compute the inverse of a matrix direclty in
TAUCS? The matrix is not too large (say between 10x10 and 20x20). I
need the inverse explicitly.

Thanks,
Alejandro.

aortizb

unread,
Sep 15, 2009, 5:04:22 PM9/15/09
to matrixprogramming
I mean, I don´t what to use the Identity matrix to solve n systems of
nxn linear equations. Is there any other way to use TAUCS?

Alejandro.

Mark Hoemmen

unread,
Sep 15, 2009, 5:25:58 PM9/15/09
to matrixpr...@googlegroups.com
On Tue, Sep 15, 2009 at 13:45, aortizb <aor...@gmail.com> wrote:
> Is there any way I can compute the inverse of a matrix direclty in
> TAUCS? The matrix is not too large (say between 10x10 and 20x20). I
> need the inverse explicitly.

1. If the matrix is that small, it will be both faster and easier just
to use LAPACK to compute the inverse.

2. Usually the inverse of a sparse matrix is dense.

3. If you're doing quantum mechanical calculations, for which you
might need only some of the diagonal or off-diagonal entries of the
inverse, there are faster ways to compute the entries you want
(without computing the whole inverse).

mfh

aortizb

unread,
Sep 16, 2009, 12:03:45 AM9/16/09
to matrixprogramming
Thanks Mark.

1) Do you have an example code using LAPACK with C++?

2) Also, what is the most appropriate library to perform matrix-vector
multiplication? I remember to have heard about BLAS, but I am not
sure. I also need to do it in C++. I guess TAUCS can manage matrix-
vector multiplication when the matrix is sparse.

3) Is LAPACK++ suitable for 2)?

Thanks again,
Alejandro.


On Sep 15, 2:25 pm, Mark Hoemmen <mark.hoem...@gmail.com> wrote:

Mark Hoemmen

unread,
Sep 16, 2009, 1:11:27 AM9/16/09
to matrixpr...@googlegroups.com
On Tue, Sep 15, 2009 at 21:03, aortizb <aor...@gmail.com> wrote:
> 1) Do you have an example code using LAPACK with C++?

There are language bindings like LAPACK++ and CLAPACK to help you with
that. Usually I just call LAPACK from Fortran (not 77, 2003).
Otherwise you'll have to observe the conventions that your particular
compiler follows regarding calling Fortran from C(++).

The LAPACK routine you want is xGETRI. Replace "x" in the routine
name with a letter corresponding to your data type: "S" for float,
"D" for double, "C" for complex float, "Z" for complex double.

In this archives of this mailing list are several examples for calling
LAPACK routines from C(++), as well as a link to an excellently
written tutorial.

> 2) Also, what is the most appropriate library to perform matrix-vector
> multiplication? I remember to have heard about BLAS, but I am not
> sure. I also need to do it in C++. I guess TAUCS can manage matrix-
> vector multiplication when the matrix is sparse.

It depends on what you mean by "appropriate." Do you mean "easy to
use," or "fast for typical workstations," or "fast for my more exotic
computing platform"? Does the sparse matrix-vector multiplication
dominate the cost of your computation?

> 3) Is LAPACK++ suitable for 2)?

LAPACK does not supply sparse routines. The BLAS does have a dense
matrix-vector multiply (xGEMV, where "x" again is a letter
corresponding to the data type).

mfh

Alejandro A. Ortiz Bernardin

unread,
Sep 16, 2009, 1:36:20 AM9/16/09
to matrixpr...@googlegroups.com

> 2) Also, what is the most appropriate library to perform matrix-vector
> multiplication? I remember to have heard about BLAS, but I am not
> sure. I also need to do it in C++. I guess TAUCS can manage matrix-
> vector multiplication when the matrix is sparse.

> It depends on what you mean by "appropriate." Do you mean "easy to
> use," or "fast for typical workstations," or "fast for my more exotic
> computing platform"? Does the sparse matrix-vector multiplication
> dominate the cost of your computation?

Fast for typical workstations. No, it does not dominate. Even though, I
would like to know for both cases: a) when it does dominate and b) when it
does not dominate.

Thanks,
-a


Mark Hoemmen

unread,
Sep 16, 2009, 10:56:44 PM9/16/09
to matrixpr...@googlegroups.com

Let me suggest, then, a library written by our research group:

http://bebop.cs.berkeley.edu/oski/

Note, however, that I am not responsible for maintaining this library,
so questions should be directed to the appropriate e-mail list. (It
_is_ being maintained, however, and pretty soon some neat features
like an automatically tuned shared-memory parallel A*x will be going
into it.)

You may also like to try the reference implementation of the Sparse
BLAS standard:

http://math.nist.gov/spblas/

Note that it is a reference implementation, which means it won't be
tuned. However, it will still give you a sparse matrix-vector
multiply which requires only O(n+nnz) operations, where the matrix is
n by n and has nnz nonzeros.

Even if the sparse matrix-vector multiplications don't dominate your
application, you still want to make sure that they respect the storage
format used by your sparse matrix and don't do silly things like
converting it to dense.

Best,
mfh

Reply all
Reply to author
Forward
0 new messages