PLaSK library
Loading...
Searching...
No Matches
costf1.c
Go to the documentation of this file.
1/* costf1.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 costf1_(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;
61 integer kc;
62 doublereal xi;
63 integer nm1, np1;
64 doublereal x1h;
65 integer ns2;
66 doublereal tx2, x1p3;
67 integer ier1;
68 doublereal snm1;
69 integer modn, lenx;
70 doublereal dsum;
71 integer lnwk, lnsv;
72 extern /* Subroutine */ int rfft1f_(integer *, integer *, doublereal *,
74 integer *), xerfft_(char *, integer *, ftnlen);
75
76 /* Parameter adjustments */
77 x_dim1 = *inc;
78 x_offset = 1 + x_dim1;
79 x -= x_offset;
80 --wsave;
81
82 /* Function Body */
83 *ier = 0;
84 nm1 = *n - 1;
85 np1 = *n + 1;
86 ns2 = *n / 2;
87 if ((i__1 = *n - 2) < 0) {
88 goto L200;
89 } else if (i__1 == 0) {
90 goto L101;
91 } else {
92 goto L102;
93 }
94L101:
95 x1h = x[x_dim1 + 1] + x[(x_dim1 << 1) + 1];
96 x[(x_dim1 << 1) + 1] = (x[x_dim1 + 1] - x[(x_dim1 << 1) + 1]) * .5;
97 x[x_dim1 + 1] = x1h * .5;
98 goto L200;
99L102:
100 if (*n > 3) {
101 goto L103;
102 }
103 x1p3 = x[x_dim1 + 1] + x[x_dim1 * 3 + 1];
104 tx2 = x[(x_dim1 << 1) + 1] + x[(x_dim1 << 1) + 1];
105 x[(x_dim1 << 1) + 1] = (x[x_dim1 + 1] - x[x_dim1 * 3 + 1]) * .5;
106 x[x_dim1 + 1] = (x1p3 + tx2) * .25;
107 x[x_dim1 * 3 + 1] = (x1p3 - tx2) * .25;
108 goto L200;
109L103:
110 dsum = x[x_dim1 + 1] - x[*n * x_dim1 + 1];
111 x[x_dim1 + 1] += x[*n * x_dim1 + 1];
112 i__1 = ns2;
113 for (k = 2; k <= i__1; ++k) {
114 kc = np1 - k;
115 t1 = x[k * x_dim1 + 1] + x[kc * x_dim1 + 1];
116 t2 = x[k * x_dim1 + 1] - x[kc * x_dim1 + 1];
117 dsum += wsave[kc] * t2;
118 t2 = wsave[k] * t2;
119 x[k * x_dim1 + 1] = t1 - t2;
120 x[kc * x_dim1 + 1] = t1 + t2;
121/* L104: */
122 }
123 modn = *n % 2;
124 if (modn == 0) {
125 goto L124;
126 }
127 x[(ns2 + 1) * x_dim1 + 1] += x[(ns2 + 1) * x_dim1 + 1];
128L124:
129 lenx = *inc * (nm1 - 1) + 1;
130 lnsv = nm1 + (integer) (log((doublereal) nm1) / log(2.)) + 4;
131 lnwk = nm1;
132
133 rfft1f_(&nm1, inc, &x[x_offset], &lenx, &wsave[*n + 1], &lnsv, work, &
134 lnwk, &ier1);
135 if (ier1 != 0) {
136 *ier = 20;
137 xerfft_("COSTF1", &c_n5, (ftnlen)6);
138 goto L200;
139 }
140
141 snm1 = 1. / (doublereal) nm1;
142 dsum = snm1 * dsum;
143 if (nm1 % 2 != 0) {
144 goto L30;
145 }
146 x[nm1 * x_dim1 + 1] += x[nm1 * x_dim1 + 1];
147L30:
148 i__1 = *n;
149 for (i__ = 3; i__ <= i__1; i__ += 2) {
150 xi = x[i__ * x_dim1 + 1] * .5;
151 x[i__ * x_dim1 + 1] = x[(i__ - 1) * x_dim1 + 1] * .5;
152 x[(i__ - 1) * x_dim1 + 1] = dsum;
153 dsum += xi;
154/* L105: */
155 }
156 if (modn != 0) {
157 goto L117;
158 }
159 x[*n * x_dim1 + 1] = dsum;
160L117:
161 x[x_dim1 + 1] *= .5;
162 x[*n * x_dim1 + 1] *= .5;
163L200:
164 return 0;
165} /* costf1_ */
166