File: cs_load.c

package info (click to toggle)
suitesparse 1%3A3.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 40,788 kB
  • sloc: ansic: 106,134; cpp: 13,129; makefile: 6,679; fortran: 4,591; csh: 763; ruby: 603; perl: 236; sed: 164; awk: 29; sh: 8
file content (15 lines) | stat: -rw-r--r-- 422 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "cs.h"
/* load a triplet matrix from a file */
cs *cs_load (FILE *f)
{
    int i, j ;
    double x ;
    cs *T ;
    if (!f) return (NULL) ;                             /* check inputs */
    T = cs_spalloc (0, 0, 1, 1, 1) ;                    /* allocate result */
    while (fscanf (f, "%d %d %lg\n", &i, &j, &x) == 3)
    {
        if (!cs_entry (T, i, j, x)) return (cs_spfree (T)) ;
    }
    return (T) ;
}