Debian Codegraph @

debian/external_deps/fetk/punc/src/cgcode/scbfix.c

raw
1 /* ./src_f77/scbfix.f -- translated by f2c (version 20030320).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include <punc/vf2c.h>
7
8 /* Table of constant values */
9
10 static integer c__1 = 1;
11 static integer c__0 = 0;
12
13 /* Subroutine */ int scbfix_(S_fp matvec, S_fp pcondl, real *a, integer *ia,
14 real *c__, integer *ic, integer *ipc, real *aa, real *bb, integer *
15 nsteps, real *b, real *x, real *r__, real *dx, real *work, integer *n)
16 {
17 /* System generated locals */
18 integer i__1, i__2;
19
20 /* Local variables */
21 static real d__;
22 static integer i__;
23 static real c2, p1, p2;
24 static integer istep;
25 extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *,
26 integer *);
27 static real recipd, wdummy;
28
29 /* ***BEGIN PROLOGUE SCBFIX */
30 /* ***REFER TO SPPCG,SCGCHB */
31 /* ***ROUTINES CALLED SAXPY,SCOPY,SSCAL */
32 /* ***REVISION DATE 870501 (YYMMDD) */
33 /* ***END PROLOGUE SCBFIX */
34
35 /* THIS SUBROUTINE PERFORMS NSTEPS STEPS OF THE CHEBYSHEV ITERATION */
36 /* (BASED ON THE INTERVAL [AA,BB]) ON THE LINEAR SYSTEM AX=B. THE */
37 /* INITIAL GUESS X0 IS ASSUMED TO BE THE ZERO VECTOR. R AND DX ARE */
38 /* WORK ARRAYS OF LENGTH .GE. N. IF PRECONDITIONING IS REQUESTED */
39 /* (IPC .NE. 0), AN ADDITIONAL WORK ARRAY, WORK, MUST BE PASSED. */
40 /* IN THIS CASE THE PROBLEM SOLVED IS C*AX = B. */
41
42 /* *** DECLARATIONS *** */
43 /* CCCCCIMPLICIT DOUBLE PRECISION(A-H,O-Z) */
44
45 /* ***FIRST EXECUTABLE STATEMENT SCBFIX */
46 /* Parameter adjustments */
47 --work;
48 --dx;
49 --r__;
50 --x;
51 --b;
52
53 /* Function Body */
54 /* L1: */
55
56 /* *** CHECK FOR NSTEPS .LE. 0 *** */
57 if (*nsteps <= 0) {
58 /* *** RETURN X=B *** */
59 scopy_(n, &b[1], &c__1, &x[1], &c__1);
60 return 0;
61 }
62
63 /* *** INITIALIZE ITERATION PARAMETERS *** */
64 d__ = (*bb + *aa) * .5f;
65 c2 = (*bb - *aa) * .25f * (*bb - *aa);
66 p1 = 2.f / d__;
67 p2 = 0.f;
68
69 /* *** EXECUTE STEP ONE OF THE ITERATION *** */
70 recipd = 1.f / d__;
71 i__1 = *n;
72 for (i__ = 1; i__ <= i__1; ++i__) {
73 dx[i__] = recipd * b[i__];
74 x[i__] = dx[i__];
75 /* L10: */
76 }
77
78 /* *** MAIN LOOP OF THE CHEBYSHEV ITERATION *** */
79 i__1 = *nsteps;
80 for (istep = 2; istep <= i__1; ++istep) {
81
82 /* *** COMPUTE MATRIX TIMES X *** */
83 if (*ipc == 0) {
84 (*matvec)(&c__0, a, ia, &wdummy, &x[1], &r__[1], n);
85 } else {
86 (*matvec)(&c__0, a, ia, &wdummy, &x[1], &work[1], n);
87 (*pcondl)(&c__0, c__, ic, &wdummy, &work[1], &r__[1], n);
88 }
89
90 /* *** COMPUTE NEW DX AND X *** */
91 p2 = c2 * p1 / (d__ * 4.f - c2 * p1);
92 p1 = (p2 + 1.f) / d__;
93 i__2 = *n;
94 for (i__ = 1; i__ <= i__2; ++i__) {
95 dx[i__] = p2 * dx[i__] + p1 * (b[i__] - r__[i__]);
96 x[i__] += dx[i__];
97 /* L30: */
98 }
99
100 /* L40: */
101 }
102
103 return 0;
104 } /* scbfix_ */
105