TAUCS_ERROR_NOMEM error!

104 views
Skip to first unread message

Kye Wong

unread,
Dec 15, 2009, 1:33:46 AM12/15/09
to matrixprogramming
Hi all:

I found the "TAUCS_ERROR_NOMEM" error when I want to use taucs to
solve a simple linear equation:

2, -1, 0 10
-1, 2, -1 * x= 2
0, -1, 2 3

The code is as follows:

double value[7];
int colptr[4];
int rowind[7];
double RHS[3];

// create CCS matrix structure using vector class
value[0]=2.0;
value[1]=-1.0;
value[2]=-1.0;
value[3]=2.0;
value[4]=-1.0;
value[5]=-1.0;
value[6]=2.0;

colptr[0]=0;
colptr[1]=2;
colptr[2]=5;
colptr[3]=7;

rowind[0]=0;
rowind[1]=0;
rowind[2]=1;
rowind[3]=1;
rowind[4]=1;
rowind[5]=2;
rowind[6]=2;

// create right-hand size vector object
RHS[0] = 10.0;
RHS[1] = 2.0;
RHS[2] = 3.0;

// resize vectors.
int dim = 3;

// create TAUCS matrix from vector objects an, jn and ia
taucs_ccs_matrix A; // a matrix to solve Ax=b in CCS format
A.n = dim;
A.m = dim;
A.flags = (TAUCS_DOUBLE | TAUCS_SYMMETRIC);
A.colptr = colptr;
A.rowind = rowind;
A.values.d = value;

// allocate TAUCS solution vector
double x[3];

// solve the linear system
void* F = NULL;
char* options[] = {"taucs.factor.LLT=true", NULL};
void* opt_arg[] = { NULL };

int i = taucs_linsolve(&A, &F, 1, x, RHS, options, opt_arg);

if (i != TAUCS_SUCCESS)
{
cout << "Solution error." << endl;
if (i==TAUCS_ERROR)
cout << "Generic error." << endl;

if (i==TAUCS_ERROR_NOMEM)
cout << "NOMEM error." << endl;

if (i==TAUCS_ERROR_BADARGS)
cout << "BADARGS error." << endl;

if (i==TAUCS_ERROR_MAXDEPTH)
cout << "MAXDEPTH error." << endl;

if (i==TAUCS_ERROR_INDEFINITE)
cout << "NOT POSITIVE DEFINITE error." << endl;
}
else
{
cout << "Solution success." << endl;

for (unsigned j = 0; j < 4; j++)
cout << x[j] << endl;
}

// deallocate the factorization
taucs_linsolve(NULL, &F, 0, NULL, NULL, NULL, NULL);

However, I always get a TAUCS_ERROR_NOMEM error!

Could you pls tell me where the problem is?
Thank you very much!

Mark Hoemmen

unread,
Dec 15, 2009, 1:02:33 PM12/15/09
to matrixpr...@googlegroups.com
Those are column indices, not row indices, in your rowind array.

mfh

Mark Hoemmen

unread,
Dec 15, 2009, 1:06:39 PM12/15/09
to matrixpr...@googlegroups.com
On Mon, Dec 14, 2009 at 23:33, Kye Wong <wang...@gmail.com> wrote:
> I found the "TAUCS_ERROR_NOMEM" error when I want to use taucs to
> solve a simple linear equation:

Also, if you're posting code to the e-mail list, you may find it
easier to use a pastebin service, like

http://pastebin.com/

That saves the e-mail list from trying to read a lot of code, whose
formatting may have been messed up by either your e-mail client or
ours. Such services can also do syntax highlighting and automatic
indentation of your code, which also helps both you and us read it
more easily.

Best,
mfh

Evgenii Rudnyi

unread,
Dec 15, 2009, 1:46:32 PM12/15/09
to matrixpr...@googlegroups.com
Mark Hoemmen wrote:
> On Mon, Dec 14, 2009 at 23:33, Kye Wong <wang...@gmail.com> wrote:
>> I found the "TAUCS_ERROR_NOMEM" error when I want to use taucs to
>> solve a simple linear equation:
>>

...


>
> Those are column indices, not row indices, in your rowind array.
>
> mfh

Here you will find examples how to run TAUCS

http://matrixprogramming.com/TAUCS/src/

I have also a driver that reads the matrix in the Matrix Market format
but then just uses the matrix vector multiply in TAUCS

http://matrixprogramming.com/benchmark/run_taucs_mult.cpp

You can modify it to solve the linear system. Then it will be error-prone.

I remember that someone has reported the problems with taucs_linsolve
when it was necessary first to factor the matrix and then to use back
substitution. I would recommend you just to use the low-level functions.
The example is here

http://matrixprogramming.com/TAUCS/src/test_taucs_lowlevel.cpp

Kye Wong

unread,
Dec 15, 2009, 9:08:03 PM12/15/09
to matrixpr...@googlegroups.com
Thanks for the help guys!

So,Mark, would you pls tell me how I should represent the matrix in TAUCS pls?
I tried:

    rowind[0]=0;
    rowind[1]=1;
    rowind[2]=0;
    rowind[3]=1;
    rowind[4]=2;
    rowind[5]=1;
    rowind[6]=2;

It also returns the TAUCS_ERROR_NOMEM error!

I'm really confused on the representation of a sparse matrix in TAUCS! Could anyone give me a detailed example pls(The existing example in our discussion group is a low triangle matrix, which is different from my example here)?

Thank you very much for your instructions!


--

You received this message because you are subscribed to the Google Groups "matrixprogramming" group.
To post to this group, send email to matrixpr...@googlegroups.com.
To unsubscribe from this group, send email to matrixprogramm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/matrixprogramming?hl=en.





--
Kye Wong

Mark Hoemmen

unread,
Dec 15, 2009, 9:39:36 PM12/15/09
to matrixpr...@googlegroups.com
On Tue, Dec 15, 2009 at 19:08, Kye Wong <wang...@gmail.com> wrote:
> Thanks for the help guys!
>
> So,Mark, would you pls tell me how I should represent the matrix in TAUCS
> pls?
> I tried:
>
>     rowind[0]=0;
>     rowind[1]=1;
>     rowind[2]=0;
>     rowind[3]=1;
>     rowind[4]=2;
>     rowind[5]=1;
>     rowind[6]=2;

That's the correct CCS format, assuming that TAUCS is set up to take
zero-based indices.

> I'm really confused on the representation of a sparse matrix in TAUCS! Could
> anyone give me a detailed example pls(The existing example in our discussion
> group is a low triangle matrix, which is different from my example here)?

Ph.D. Thesis: Automatic Performance Tuning of Sparse Matrix Kernels
(Computer Science Division, U.C. Berkeley, December 2003)
Richard Vuduc.
http://bebop.cs.berkeley.edu/pubs/vuduc2003-dissertation.pdf
pp. 28 or so, Figure 2.8 ("CSC" there is "CCS" in the above discussion).

mfh

Kye Wong

unread,
Dec 15, 2009, 9:49:21 PM12/15/09
to matrixprogramming
Thank you for the explanation Mark!
The modified rowind is correct, so for me the problem now is
taucs_linsolve still returns the TAUCS_ERROR_NOMEM error. And Taucs IS
zero-based indices. I don't know where the problem lies. Could you pls
help me find it ?

Thanks again for your kindly help!

On 12月16日, 上午10时39分, Mark Hoemmen <mark.hoem...@gmail.com> wrote:
> On Tue, Dec 15, 2009 at 19:08, Kye Wong <wangk0...@gmail.com> wrote:
> > Thanks for the help guys!
>
> > So,Mark, would you pls tell me how I should represent the matrix in TAUCS
> > pls?
> > I tried:
>
> > rowind[0]=0;
> > rowind[1]=1;
> > rowind[2]=0;
> > rowind[3]=1;
> > rowind[4]=2;
> > rowind[5]=1;
> > rowind[6]=2;
>
> That's the correct CCS format, assuming that TAUCS is set up to take
> zero-based indices.
>
> > I'm really confused on the representation of a sparse matrix in TAUCS! Could
> > anyone give me a detailed example pls(The existing example in our discussion
> > group is a low triangle matrix, which is different from my example here)?
>
> Ph.D. Thesis: Automatic Performance Tuning of Sparse Matrix Kernels
> (Computer Science Division, U.C. Berkeley, December 2003)
> Richard Vuduc.http://bebop.cs.berkeley.edu/pubs/vuduc2003-dissertation.pdf

Evgenii Rudnyi

unread,
Dec 16, 2009, 2:37:37 PM12/16/09
to matrixpr...@googlegroups.com
Kye Wong schrieb:
> Thank you for the explanation Mark!
> The modified rowind is correct, so for me the problem now is
> taucs_linsolve still returns the TAUCS_ERROR_NOMEM error. And Taucs IS
> zero-based indices. I don't know where the problem lies. Could you pls
> help me find it ?

First run the examples that I have referenced yesterday. They are
working. Then try to compare the codes or modify the example to treat
your matrix. Unfortunately this week I am short on time. Sorry.

Also a good idea to try the low-level functions. This way you exclude
the bugs in taucs_linsolve.

Evgenii

Evgenii Rudnyi

unread,
Dec 18, 2009, 5:10:55 PM12/18/09
to matrixpr...@googlegroups.com
> Thank you for the explanation Mark!
> The modified rowind is correct, so for me the problem now is
> taucs_linsolve still returns the TAUCS_ERROR_NOMEM error. And Taucs IS
> zero-based indices. I don't know where the problem lies. Could you pls
> help me find it ?

I have modified run_taucs_mult.cpp to solve a system of linear equations
with TAUCS. Please have a look at

http://matrixprogramming.com/benchmark/run_taucs.cpp

When I compile it, then

$ ./run_taucs 3x3.mtx 3x1.mtx

is working just fine and produces the correct answer (9.25, 8.5, 5.75).
3x3.mtx and 3x1.mtx are your matrices in the Matrix Market format and
you will find them at

http://matrixprogramming.com/benchmark/

Please just first compile my code (you need to compile auxiliary.cpp as
well, see makefile) and try with your matrices to check that everything
is okay with your libraries. Then you can be back to your original code
to find a mistake. I have forgotten to mention that

taucs_logfile("stdout");

will add debugging output from TAUCS. It may help you to find the
problem. In any case by me TAUCS solves the system.

Kye Wong

unread,
Dec 20, 2009, 8:50:59 PM12/20/09
to matrixpr...@googlegroups.com
Thank you Evgenii and Mark!
I don't know why this email was thrown into the Spam, so the reply is late. I'm sorry for that.
I've found the problem in my program: I stored all the elements in the sparse matrix, but in fact, only half(upper or lower) should be stored and TAUCS_LOWER or TAUCS_UPPER must be specified. After I  stored the lower triangle part of the symmetric matrix, it works.

Thanks very much for your help!

--

You received this message because you are subscribed to the Google Groups "matrixprogramming" group.
To post to this group, send email to matrixpr...@googlegroups.com.
To unsubscribe from this group, send email to matrixprogramm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/matrixprogramming?hl=en.





--
Kye Wong
Reply all
Reply to author
Forward
0 new messages