Can TAUCS handle negative values in the diagonal of a matrix?

48 views
Skip to first unread message

aortizb

unread,
Mar 13, 2009, 3:18:43 AM3/13/09
to matrixprogramming
I think this is a very basic question and also I guess that someone
asked the same before but I don't find the thread...

Can TAUCS handle negative values in the diagonal of a matrix? For
example, how about this?:

Matrix:
-2 1 0 0
1 -2 1 0
0 1 -2 1
0 0 1 -2

Right hand side vector:
-2
-1
-1
-2

Solution vector is:
3
4
4
3

TAUCS gives me a "generic error" when trying to solve it.

Also, has anyone tried CSPARSE? Can anyone compare TAUCS vs. CSPARSE
(pros/cons)?

Thanks,
Alejandro.

Evgenii Rudnyi

unread,
Mar 13, 2009, 4:53:12 PM3/13/09
to matrixpr...@googlegroups.com
aortizb schrieb:

> I think this is a very basic question and also I guess that someone
> asked the same before but I don't find the thread...
>
> Can TAUCS handle negative values in the diagonal of a matrix? For
> example, how about this?:

The multifrontal solvers are working only with positive definite
matrices. If you matrix is negative definite, you may just to change the
sign. Alternatively try ldlt solver in TAUCS - but it is slow.

>
> TAUCS gives me a "generic error" when trying to solve it.

If you use taucs_logfile("stdout"); then you should obtain better
description on what happens.

> Also, has anyone tried CSPARSE? Can anyone compare TAUCS vs. CSPARSE
> (pros/cons)?

Do you mean the package from Tim Davis? I have not tried it, so I do not
know.

Alejandro A. Ortiz Bernardin

unread,
Mar 13, 2009, 5:25:10 PM3/13/09
to matrixpr...@googlegroups.com
> Do you mean the package from Tim Davis? I have not tried it, so I do not
> know.

Yes, I do.


Evgenii Rudnyi

unread,
Mar 14, 2009, 2:39:15 PM3/14/09
to matrixpr...@googlegroups.com
Alejandro A. Ortiz Bernardin schrieb:

>> Do you mean the package from Tim Davis? I have not tried it, so I do not
>> know.
>
> Yes, I do.

I have browsed CSparse. I am not sure if this is the fastest code. It
better to look at other codes of Tim Davis at

http://www.cise.ufl.edu/research/sparse/

CHOLMOD should be equivalent to TAUCS but it also applicable for
positive definite matrices. For asymmetric matrices one could use
UMFPACK. For indefinite matrices there is LDL but it seems that it is
not multifrontal - therefore it should be similar to ldlt in TAUCS.

What typical dimensions of your matrices?

Evgenii Rudnyi

unread,
Mar 14, 2009, 2:57:00 PM3/14/09
to matrixpr...@googlegroups.com
aortizb schrieb:

> I think this is a very basic question and also I guess that someone
> asked the same before but I don't find the thread...
>
> Can TAUCS handle negative values in the diagonal of a matrix? For
> example, how about this?:
>
> Matrix:
> -2 1 0 0
> 1 -2 1 0
> 0 1 -2 1
> 0 0 1 -2
>
> Right hand side vector:
> -2
> -1
> -1
> -2

For simplicity I have tried this problem in SciPy (as a dense matrix).
It shows that the matrix, as one could expect, not positive definite.
However, when I negate both the matrix and the RHS I receive the right
answer

from numpy import *
from scipy.linalg import *
a = array(
[[-2, 1, 0, 0],
[1, -2, 1, 0],
[0, 1, -2, 1],
[0, 0, 1, -2]])
fac = cho_factor(-a)
print cho_solve(fac, array([2,1,1,2]))

This produces
[ 3. 4. 4. 3.]

So this should be the way to treat this problem with TAUCS. Just negate
the matrix and RHS.

Mark Hoemmen

unread,
Mar 14, 2009, 6:23:20 PM3/14/09
to matrixpr...@googlegroups.com
Evgenii Rudnyi wrote:
> Alejandro A. Ortiz Bernardin schrieb:
>>> Do you mean the package from Tim Davis? I have not tried it, so I do not
>>> know.
>> Yes, I do.
>
> I have browsed CSparse. I am not sure if this is the fastest code. It
> better to look at other codes of Tim Davis at
>
> http://www.cise.ufl.edu/research/sparse/

*nods* CSparse wasn't meant to be the fastest; it was meant to be a
readable demonstration code for algorithms used in sparse matrix
factorizations. It goes along with Tim Davis' recent SIAM Press book.

mfh


Alejandro A. Ortiz Bernardin

unread,
Mar 15, 2009, 1:33:11 PM3/15/09
to matrixpr...@googlegroups.com

> What typical dimensions of your matrices?

5000 x 5000 to 10000 x 10000

Anyway in my case all the matrices will be positive definite. That is
because the matrices are obtained from basis function obtained from a convex
optimization problem and so they will always be nonnegative basis functions.

-a

Evgenii Rudnyi

unread,
Mar 15, 2009, 2:12:17 PM3/15/09
to matrixpr...@googlegroups.com
Alejandro A. Ortiz Bernardin schrieb:
>

For such dimensions you definitely need a sparse solver. If a matrix
positive definite, then TAUCS should be okay.

I just thought that you matrices are smaller. For smaller matrices it
might well be that it will be faster to treat them as dense and run LAPACK.

Reply all
Reply to author
Forward
0 new messages