title: Represent a sparse matrix in C using the CSparse Library
body: <p>I can't understand how can easily represent a sparse matrix in C using the CSparese Library.</p>
  
  <p>That's what I want</p>
  
  <pre><code>    | 6.0 0.0 2.0 |
  A = | 3.0 8.0 0.0 |
      | 6.0 0.0 1.0 |
  with
  
      | 40.0 |
  b = | 50.0 |
      | 30.0 |
  </code></pre>
  
  <p>The cs Struct of the csparse  is this</p>
  
  <pre><code>typedef struct cs_sparse    /* matrix in compressed-column or triplet form */
  {
      csi nzmax ;     /* maximum number of entries */
      csi m ;         /* number of rows */
      csi n ;         /* number of columns */
      csi *p ;        /* column pointers (size n+1) or col indices (size nzmax) */
      csi *i ;        /* row indices, size nzmax */
      double *x ;     /* numerical values, size nzmax */
      csi nz ;        /* # of entries in triplet matrix, -1 for compressed-col */
  } cs ;
  </code></pre>
  
  <p>That's what I do</p>
  
  <pre><code>int main(int argc, const char * argv[])
  {
  
      cs A;
      int  N = 3;
      double b[]={1,2,3};
      double data[]={1,1,1};
      csi columnIndices[]={0,1,2};
      csi rowIndices[]={0,1,2};
      A.nzmax =3;
      A.m = N;
      A.n = N;
      A.p = &amp;columnIndices[0];
      A.i = &amp;rowIndices[0];
      A.x = &amp;data[0];
      A.nz = 3;
  
      cs *B = cs_compress(&amp;A);
      int status =  cs_cholsol(0,B,&amp;b[0]);
  
  
  
      printf("status=%d",status);   // status always returns 0, which means error
      return 0;
  </code></pre>
  
  <p>What I ask, is how can I populate my matrix with my data and which method I must use to solve it.</p>
  
  <p>Thanks</p>