00001 #include "cs.h" 00002 /* load a triplet matrix from a file */ 00003 cs *cs_load (FILE *f) 00004 { 00005 int i, j ; 00006 double x ; 00007 cs *T ; 00008 if (!f) return (NULL) ; /* check inputs */ 00009 T = cs_spalloc (0, 0, 1, 1, 1) ; /* allocate result */ 00010 while (fscanf (f, "%d %d %lg\n", &i, &j, &x) == 3) 00011 { 00012 if (!cs_entry (T, i, j, x)) return (cs_spfree (T)) ; 00013 } 00014 return (T) ; 00015 }