~logan/ubuntu/trusty/suitesparse/4.2.1-3ubuntu1

« back to all changes in this revision

Viewing changes to CXSparse/Demo/cs_ci_demo.c

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2007-05-29 09:36:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529093629-zowquo0b7slkk6nc
Tags: 3.0.0-2
* suitesparse builds properly twice in a row
* Bug fix: "suitesparse - FTBFS: Broken build depens: libgfortran1-dev",
  thanks to Bastian Blank (Closes: #426349).
* Bug fix: "suitesparse_3.0.0-1: FTBFS: build-depends on
  libgfortran1-dev", thanks to Steve Langasek (Closes: #426354).

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
}
20
20
 
21
21
/* true for off-diagonal entries */
22
 
static int dropdiag (int i, int j, double _Complex aij, void *other) { return (i != j) ;}
 
22
static int dropdiag (int i, int j, cs_complex_t aij, void *other) { return (i != j) ;}
23
23
 
24
24
/* C = A + triu(A,1)' */
25
25
static cs_ci *make_sym (cs_ci *A)
33
33
}
34
34
 
35
35
/* create a right-hand side */
36
 
static void rhs (double _Complex *x, double _Complex *b, int m)
 
36
static void rhs (cs_complex_t *x, cs_complex_t *b, int m)
37
37
{
38
38
    int i ;
39
39
    for (i = 0 ; i < m ; i++) b [i] = 1 + ((double) i) / m ;
41
41
}
42
42
 
43
43
/* infinity-norm of x */
44
 
static double norm (double _Complex *x, int n)
 
44
static double norm (cs_complex_t *x, int n)
45
45
{
46
46
    int i ;
47
47
    double normx = 0 ;
50
50
}
51
51
 
52
52
/* compute residual, norm(A*x-b,inf) / (norm(A,1)*norm(x,inf) + norm(b,inf)) */
53
 
static void print_resid (int ok, cs_ci *A, double _Complex *x, double _Complex *b, double _Complex *resid)
 
53
static void print_resid (int ok, cs_ci *A, cs_complex_t *x, cs_complex_t *b, cs_complex_t *resid)
54
54
{
55
55
    int i, m, n ;
56
56
    if (!ok) { printf ("    (failed)\n") ; return ; }
100
100
            m, n, A->p [n], sym, sym ? C->p [n] : 0, cs_ci_norm (C)) ;
101
101
    if (nz1 != nz2) printf ("zero entries dropped: %d\n", nz1 - nz2) ;
102
102
    if (nz2 != A->p [n]) printf ("tiny entries dropped: %d\n", nz2 - A->p [n]) ;
103
 
    Prob->b = cs_ci_malloc (mn, sizeof (double _Complex)) ;
104
 
    Prob->x = cs_ci_malloc (mn, sizeof (double _Complex)) ;
105
 
    Prob->resid = cs_ci_malloc (mn, sizeof (double _Complex)) ;
 
103
    Prob->b = cs_ci_malloc (mn, sizeof (cs_complex_t)) ;
 
104
    Prob->x = cs_ci_malloc (mn, sizeof (cs_complex_t)) ;
 
105
    Prob->resid = cs_ci_malloc (mn, sizeof (cs_complex_t)) ;
106
106
    return ((!Prob->b || !Prob->x || !Prob->resid) ? free_problem (Prob) : Prob) ;
107
107
}
108
108
 
122
122
int demo2 (problem *Prob)
123
123
{
124
124
    cs_ci *A, *C ;
125
 
    double _Complex *b, *x, *resid ;
 
125
    cs_complex_t *b, *x, *resid ;
126
126
    double t, tol ;
127
127
    int k, m, n, ok, order, nb, ns, *r, *s, *rr, sprank ;
128
128
    cs_cid *D ;
179
179
180
180
 
181
181
/* free workspace for demo3 */
182
 
static int done3 (int ok, cs_cis *S, cs_cin *N, double _Complex *y, cs_ci *W, cs_ci *E, int *p)
 
182
static int done3 (int ok, cs_cis *S, cs_cin *N, cs_complex_t *y, cs_ci *W, cs_ci *E, int *p)
183
183
{
184
184
    cs_ci_sfree (S) ;
185
185
    cs_ci_nfree (N) ;
195
195
{
196
196
    cs_ci *A, *C, *W = NULL, *WW, *WT, *E = NULL, *W2 ;
197
197
    int n, k, *Li, *Lp, *Wi, *Wp, p1, p2, *p = NULL, ok ;
198
 
    double _Complex *b, *x, *resid, *y = NULL, *Lx, *Wx, s ;
 
198
    cs_complex_t *b, *x, *resid, *y = NULL, *Lx, *Wx, s ;
199
199
    double t, t1 ;
200
200
    cs_cis *S = NULL ;
201
201
    cs_cin *N = NULL ;
206
206
    rhs (x, b, n) ;                             /* compute right-hand side */
207
207
    printf ("\nchol then update/downdate ") ;
208
208
    print_order (1) ;
209
 
    y = cs_ci_malloc (n, sizeof (double _Complex)) ;
 
209
    y = cs_ci_malloc (n, sizeof (cs_complex_t)) ;
210
210
    t = tic () ;
211
211
    S = cs_ci_schol (1, C) ;                    /* symbolic Chol, amd(A+A') */
212
212
    printf ("\nsymbolic chol time %8.2f\n", toc (t)) ;