PLaSK library
Loading...
Searching...
No Matches
costb1.c
Go to the documentation of this file.
1/* costb1.f -- translated by f2c (version 20100827).
2 You must link the resulting object file with libf2c:
3 on Microsoft Windows system, link with libf2c.lib;
4 on Linux or Unix systems, link with .../path/to/libf2c.a -lm
5 or, if you install libf2c.a in a standard place, with -lf2c -lm
6 -- in that order, at the end of the command line, as in
7 cc *.o -lf2c -lm
8 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
9
10 http://www.netlib.org/f2c/libf2c.zip
11*/
12
13#include "f2c.h"
14
15/* Table of constant values */
16
17static integer c_n5 = -5;
18
19/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
20/* * * */
21/* * copyright (c) 2011 by UCAR * */
22/* * * */
23/* * University Corporation for Atmospheric Research * */
24/* * * */
25/* * all rights reserved * */
26/* * * */
27/* * FFTPACK version 5.1 * */
28/* * * */
29/* * A Fortran Package of Fast Fourier * */
30/* * * */
31/* * Subroutines and Example Programs * */
32/* * * */
33/* * by * */
34/* * * */
35/* * Paul Swarztrauber and Dick Valent * */
36/* * * */
37/* * of * */
38/* * * */
39/* * the National Center for Atmospheric Research * */
40/* * * */
41/* * Boulder, Colorado (80307) U.S.A. * */
42/* * * */
43/* * which is sponsored by * */
44/* * * */
45/* * the National Science Foundation * */
46/* * * */
47/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
48
49/* Subroutine */ int costb1_(integer *n, integer *inc, doublereal *x,
50 doublereal *wsave, doublereal *work, integer *ier)
51{
52 /* System generated locals */
53 integer x_dim1, x_offset, i__1;
54
55 /* Builtin functions */
56 double log(doublereal);
57
58 /* Local variables */
59 integer i__, k;
60 doublereal t1, t2, x2;
61 integer kc;
62 doublereal xi;
63 integer nm1, np1;
64 doublereal x1h;
65 integer ns2;
66 doublereal x1p3;
67 integer ier1, modn, lenx;
68 doublereal dsum;
69 integer lnwk, lnsv;
70 doublereal fnm1s2, fnm1s4;
71 extern /* Subroutine */ int rfft1f_(integer *, integer *, doublereal *,
73 integer *), xerfft_(char *, integer *, ftnlen);
74
75 /* Parameter adjustments */
76 x_dim1 = *inc;
77 x_offset = 1 + x_dim1;
78 x -= x_offset;
79 --wsave;
80
81 /* Function Body */
82 *ier = 0;
83 nm1 = *n - 1;
84 np1 = *n + 1;
85 ns2 = *n / 2;
86 if ((i__1 = *n - 2) < 0) {
87 goto L106;
88 } else if (i__1 == 0) {
89 goto L101;
90 } else {
91 goto L102;
92 }
93L101:
94 x1h = x[x_dim1 + 1] + x[(x_dim1 << 1) + 1];
95 x[(x_dim1 << 1) + 1] = x[x_dim1 + 1] - x[(x_dim1 << 1) + 1];
96 x[x_dim1 + 1] = x1h;
97 return 0;
98L102:
99 if (*n > 3) {
100 goto L103;
101 }
102 x1p3 = x[x_dim1 + 1] + x[x_dim1 * 3 + 1];
103 x2 = x[(x_dim1 << 1) + 1];
104 x[(x_dim1 << 1) + 1] = x[x_dim1 + 1] - x[x_dim1 * 3 + 1];
105 x[x_dim1 + 1] = x1p3 + x2;
106 x[x_dim1 * 3 + 1] = x1p3 - x2;
107 return 0;
108L103:
109 x[x_dim1 + 1] += x[x_dim1 + 1];
110 x[*n * x_dim1 + 1] += x[*n * x_dim1 + 1];
111 dsum = x[x_dim1 + 1] - x[*n * x_dim1 + 1];
112 x[x_dim1 + 1] += x[*n * x_dim1 + 1];
113 i__1 = ns2;
114 for (k = 2; k <= i__1; ++k) {
115 kc = np1 - k;
116 t1 = x[k * x_dim1 + 1] + x[kc * x_dim1 + 1];
117 t2 = x[k * x_dim1 + 1] - x[kc * x_dim1 + 1];
118 dsum += wsave[kc] * t2;
119 t2 = wsave[k] * t2;
120 x[k * x_dim1 + 1] = t1 - t2;
121 x[kc * x_dim1 + 1] = t1 + t2;
122/* L104: */
123 }
124 modn = *n % 2;
125 if (modn == 0) {
126 goto L124;
127 }
128 x[(ns2 + 1) * x_dim1 + 1] += x[(ns2 + 1) * x_dim1 + 1];
129L124:
130 lenx = *inc * (nm1 - 1) + 1;
131 lnsv = nm1 + (integer) (log((doublereal) nm1) / log(2.)) + 4;
132 lnwk = nm1;
133
134 rfft1f_(&nm1, inc, &x[x_offset], &lenx, &wsave[*n + 1], &lnsv, work, &
135 lnwk, &ier1);
136 if (ier1 != 0) {
137 *ier = 20;
138 xerfft_("COSTB1", &c_n5, (ftnlen)6);
139 return 0;
140 }
141
142 fnm1s2 = (doublereal) nm1 / 2.;
143 dsum *= .5;
144 x[x_dim1 + 1] = fnm1s2 * x[x_dim1 + 1];
145 if (nm1 % 2 != 0) {
146 goto L30;
147 }
148 x[nm1 * x_dim1 + 1] += x[nm1 * x_dim1 + 1];
149L30:
150 fnm1s4 = (doublereal) nm1 / 4.;
151 i__1 = *n;
152 for (i__ = 3; i__ <= i__1; i__ += 2) {
153 xi = fnm1s4 * x[i__ * x_dim1 + 1];
154 x[i__ * x_dim1 + 1] = fnm1s4 * x[(i__ - 1) * x_dim1 + 1];
155 x[(i__ - 1) * x_dim1 + 1] = dsum;
156 dsum += xi;
157/* L105: */
158 }
159 if (modn != 0) {
160 return 0;
161 }
162 x[*n * x_dim1 + 1] = dsum;
163L106:
164 return 0;
165} /* costb1_ */
166