csparse error while solving sparse system of equations

I have a task in which I have to solve a system of linear equations Ax =B, where A is a sparse matrix of the order of 10000. I am using csparse to solve it. In my initial implementation, for demo purposes A is 3*3 order identity matrix and B ={1,2,3}. Below is the code snippet, which is returning 0 in the status which means there is some error in my implementation. What is that I am doing wrong ?

    cs A;
    int  N = 3;
    double b[]={1,2,3};
    double data[]={1,1,1};
    int columnIndices[]={0,1,2};
    int rowIndices[]={0,1,2};
    A.nzmax =3;
    A.m = N;
    A.n = N;
    A.p = &columnIndices[0];
    A.i = &rowIndices[0];
    A.x = &data[0];
    A.nz = 3;
    int status =  cs_cholsol(0,&A,&b[0]);
    NSLog(@"status=%d",status);   // status always returns 0, which means error

Answers


You have to convert your input matrix to CSC. The solver functions check for the matrix format and return 0 if it's coordinate form. Btw. with a similar example I couldn't get "cholsol" to work, but "lsolve" works fine (after conversion to CSC).


Need Your Help

Numeric type as DependencyProperty

c# .net wpf dependency-properties

How to register custom property which based on numeric type?

Is there a Symfony helper for getting the current action URL and changing one or more of the query parameters?

php symfony1

What I'd like to do is take the route for the current action along with any and all of the route and query string parameters, and change a single query string parameter to something else. If the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.