EVSL  1.1.0
EigenValues Slicing Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
cs_load.c
Go to the documentation of this file.
1 #include "cs.h"
2 /* load a triplet matrix from a file */
3 cs *cs_load (FILE *f)
4 {
5  double i, j ; /* use double for integers to avoid csi conflicts */
6  double x ;
7 #ifdef CS_COMPLEX
8  double xi ;
9 #endif
10  cs *T ;
11  if (!f) return (NULL) ; /* check inputs */
12  T = cs_spalloc (0, 0, 1, 1, 1) ; /* allocate result */
13 #ifdef CS_COMPLEX
14  while (fscanf (f, "%lg %lg %lg %lg\n", &i, &j, &x, &xi) == 4)
15 #else
16  while (fscanf (f, "%lg %lg %lg\n", &i, &j, &x) == 3)
17 #endif
18  {
19 #ifdef CS_COMPLEX
20  if (!cs_entry (T, (CS_INT) i, (CS_INT) j, x + xi*I)) return (cs_spfree (T)) ;
21 #else
22  if (!cs_entry (T, (CS_INT) i, (CS_INT) j, x)) return (cs_spfree (T)) ;
23 #endif
24  }
25  return (T) ;
26 }
#define cs
Definition: cs.h:637
cs * cs_spfree(cs *A)
Definition: cs_util.c:33
cs * cs_spalloc(CS_INT m, CS_INT n, CS_INT nzmax, CS_INT values, CS_INT triplet)
Definition: cs_util.c:3
#define CS_INT
Definition: cs.h:627
cs * cs_load(FILE *f)
Definition: cs_load.c:3
CS_INT cs_entry(cs *T, CS_INT i, CS_INT j, CS_ENTRY x)
Definition: cs_entry.c:3