cs_print.c
Go to the documentation of this file.
00001 #include "cs.h"
00002 /* print a sparse matrix */
00003 int cs_print (const cs *A, int brief)
00004 {
00005     int p, j, m, n, nzmax, nz, *Ap, *Ai ;
00006     double *Ax ;
00007     if (!A) { printf ("(null)\n") ; return (0) ; }
00008     m = A->m ; n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ;
00009     nzmax = A->nzmax ; nz = A->nz ;
00010     printf ("CSparse Version %d.%d.%d, %s.  %s\n", CS_VER, CS_SUBVER,
00011         CS_SUBSUB, CS_DATE, CS_COPYRIGHT) ;
00012     if (nz < 0)
00013     {
00014         printf ("%d-by-%d, nzmax: %d nnz: %d, 1-norm: %g\n", m, n, nzmax,
00015                 Ap [n], cs_norm (A)) ;
00016         for (j = 0 ; j < n ; j++)
00017         {
00018             printf ("    col %d : locations %d to %d\n", j, Ap [j], Ap [j+1]-1);
00019             for (p = Ap [j] ; p < Ap [j+1] ; p++)
00020             {
00021                 printf ("      %d : %g\n", Ai [p], Ax ? Ax [p] : 1) ;
00022                 if (brief && p > 20) { printf ("  ...\n") ; return (1) ; }
00023             }
00024         }
00025     }
00026     else
00027     {
00028         printf ("triplet: %d-by-%d, nzmax: %d nnz: %d\n", m, n, nzmax, nz) ;
00029         for (p = 0 ; p < nz ; p++)
00030         {
00031             printf ("    %d %d : %g\n", Ai [p], Ap [p], Ax ? Ax [p] : 1) ;
00032             if (brief && p > 20) { printf ("  ...\n") ; return (1) ; }
00033         }
00034     }
00035     return (1) ;
00036 }


hogman_minimal
Author(s): Maintained by Juergen Sturm
autogenerated on Mon Oct 6 2014 00:06:58