38 #define CPUTIME ((double) (clock ( )) / CLOCKS_PER_SEC) 43 cholmod_dense *x, *b, *r ;
45 double one [2] = {1,0}, m1 [2] = {-1,0} ;
48 A = cholmod_read_sparse (stdin, &c) ;
49 cholmod_print_sparse (A,
"A", &c) ;
50 if (A == NULL || A->stype == 0)
52 cholmod_free_sparse (&A, &c) ;
56 b = cholmod_ones (A->nrow, 1, A->xtype, &c) ;
58 L = cholmod_analyze (A, &c) ;
59 cholmod_factorize (A, L, &c) ;
60 x = cholmod_solve (CHOLMOD_A, L, b, &c) ;
62 printf(
"Time: %12.4f \n", t1-t0);
63 r = cholmod_copy_dense (b, &c) ;
64 cholmod_sdmult (A, 0, m1, one, x, r, &c) ;
65 printf (
"norm(b-Ax) %8.1e\n",
66 cholmod_norm_dense (r, 0, &c)) ;
67 cholmod_free_factor (&L, &c) ;
68 cholmod_free_sparse (&A, &c) ;
69 cholmod_free_dense (&r, &c) ;
70 cholmod_free_dense (&x, &c) ;
71 cholmod_free_dense (&b, &c) ;