1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
/* ========================================================================== */
/* === Tcov/cmread ========================================================== */
/* ========================================================================== */
/* -----------------------------------------------------------------------------
* CHOLMOD/Tcov Module. Version 1.0. Copyright (C) 2005, Timothy A. Davis
* The CHOLMOD/Tcov Module is licensed under Version 2.0 of the GNU
* General Public License. See gpl.txt for a text of the license.
* CHOLMOD is also available under other licenses; contact authors for details.
* http://www.cise.ufl.edu/research/sparse
* -------------------------------------------------------------------------- */
/* Read in a matrix from a file and print it out.
*
* Usage:
* cmread matrixfile
* cmread < matrixfile
*/
#include "cholmod.h"
int main (int argc, char **argv)
{
cholmod_sparse *A ;
FILE *f ;
cholmod_common Common, *cm ;
/* ---------------------------------------------------------------------- */
/* get the file containing the input matrix */
/* ---------------------------------------------------------------------- */
if (argc > 1)
{
if ((f = fopen (argv [1], "r")) == NULL)
{
printf ("cannot open file: %s\n", argv [1]) ;
return (0) ;
}
}
else
{
f = stdin ;
}
/* ---------------------------------------------------------------------- */
/* start CHOLMOD, read the matrix, print it, and free it */
/* ---------------------------------------------------------------------- */
#ifdef DLONG
cm = &Common ;
cholmod_l_start (cm) ;
cm->print = 5 ;
A = cholmod_l_read_sparse (f, cm) ;
if (argc > 1) fclose (f) ;
cholmod_l_print_sparse (A, "A", cm) ;
cholmod_l_free_sparse (&A, cm) ;
cholmod_l_finish (cm) ;
#else
cm = &Common ;
cholmod_start (cm) ;
cm->print = 5 ;
A = cholmod_read_sparse (f, cm) ;
if (argc > 1) fclose (f) ;
cholmod_print_sparse (A, "A", cm) ;
cholmod_free_sparse (&A, cm) ;
cholmod_finish (cm) ;
#endif
return (0) ;
}
|