EVSL  1.1.0
EigenValues Slicing Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
cs_print.c
Go to the documentation of this file.
1 #include "cs.h"
2 /* print a sparse matrix; use %g for integers to avoid differences with CS_INT */
3 CS_INT cs_print (const cs *A, CS_INT brief)
4 {
5  CS_INT p, j, m, n, nzmax, nz, *Ap, *Ai ;
6  CS_ENTRY *Ax ;
7  if (!A) { printf ("(null)\n") ; return (0) ; }
8  m = A->m ; n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ;
9  nzmax = A->nzmax ; nz = A->nz ;
10  printf ("CXSparse Version %d.%d.%d, %s. %s\n", CS_VER, CS_SUBVER,
12  if (nz < 0)
13  {
14  printf ("%g-by-%g, nzmax: %g nnz: %g, 1-norm: %g\n", (double) m,
15  (double) n, (double) nzmax, (double) (Ap [n]), cs_norm (A)) ;
16  for (j = 0 ; j < n ; j++)
17  {
18  printf (" col %g : locations %g to %g\n", (double) j,
19  (double) (Ap [j]), (double) (Ap [j+1]-1)) ;
20  for (p = Ap [j] ; p < Ap [j+1] ; p++)
21  {
22  printf (" %g : ", (double) (Ai [p])) ;
23 #ifdef CS_COMPLEX
24  printf ("(%g, %g)\n",
25  Ax ? CS_REAL (Ax [p]) : 1, Ax ? CS_IMAG (Ax [p]) : 0) ;
26 #else
27  printf ("%g\n", Ax ? Ax [p] : 1) ;
28 #endif
29  if (brief && p > 20) { printf (" ...\n") ; return (1) ; }
30  }
31  }
32  }
33  else
34  {
35  printf ("triplet: %g-by-%g, nzmax: %g nnz: %g\n", (double) m,
36  (double) n, (double) nzmax, (double) nz) ;
37  for (p = 0 ; p < nz ; p++)
38  {
39 
40  printf (" %g %g : ", (double) (Ai [p]), (double) (Ap [p])) ;
41 #ifdef CS_COMPLEX
42  printf ("(%g, %g)\n",
43  Ax ? CS_REAL (Ax [p]) : 1, Ax ? CS_IMAG (Ax [p]) : 0) ;
44 #else
45  printf ("%g\n", Ax ? Ax [p] : 1) ;
46 #endif
47  if (brief && p > 20) { printf (" ...\n") ; return (1) ; }
48  }
49  }
50  return (1) ;
51 }
#define cs
Definition: cs.h:637
#define CS_ENTRY
Definition: cs.h:635
#define CS_SUBSUB
Definition: cs.h:47
#define CS_REAL(x)
Definition: cs.h:647
double cs_norm(const cs *A)
Definition: cs_norm.c:3
#define CS_VER
Definition: cs.h:45
#define CS_SUBVER
Definition: cs.h:46
#define CS_COPYRIGHT
Definition: cs.h:49
#define CS_INT
Definition: cs.h:627
CS_INT cs_print(const cs *A, CS_INT brief)
Definition: cs_print.c:3
#define CS_IMAG(x)
Definition: cs.h:648
#define CS_DATE
Definition: cs.h:48