0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 /*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 indent ltf_plan.c && \
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 gcc -g -O9 -ffast-math -Wconversion -Wall -W -o ltf_plan ltf_plan.c -lm && \
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 ./ltf_plan > plan.tex
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 #include <stdio.h>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 #include <stdlib.h>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 #include <math.h>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 #include <assert.h>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 #include <complex.h>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 #define TEX 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 struct ltf_plan_one_t
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 double f; /* frequency at bin center [Hz] */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 double fres; /* frequency resolution (bin width) [Hz] */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 double bin; /* bin number (possibly non-integer) */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 unsigned dftlen; /* length of one DFT segment */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 unsigned nseg; /* number of DFT segments */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 unsigned *segstart; /* starting position of each of the nseg segments */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 };
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 typedef struct ltf_plan_one_t ltf_plan_one;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 struct ltf_plan_t
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 /* copy of input data */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 unsigned ndata; /* total number of input data */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 double fsamp; /* sampling frequency [Hz] */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 double ovlap; /* window overlap in % */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 double binmin; /* smallest bin-number to use */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 unsigned mindftlen; /* minimum length of one segment */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 unsigned freqdes; /* desired number of frequencies */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 unsigned avgdes; /* desired number of averages */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 /* scheduler results */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 unsigned nfreq; /* final number of frequencies */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 unsigned maxdftlen; /* maximal length of one DFT segment */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 unsigned maxnseg; /* maximal number of averages */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 ltf_plan_one *fplan; /* detailed plan for each of nfreq frequencies */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 };
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 typedef struct ltf_plan_t ltf_plan;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 void
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 gerror (const char *err)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 fprintf (stderr, "\n*** Error: %s\n", err);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 exit (1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 int
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 myround (double x)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 return ((int) (floor (x + 0.5)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 void
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 ltf_plan_alloc (ltf_plan * p, unsigned size)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 char err[160];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 p->fplan = realloc (p->fplan, size * sizeof (ltf_plan_one));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 if (p->fplan == NULL)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 sprintf (err,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 "ltf_plan: error in allocating %u*%u=%u bytes for p.fplan",
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 size, sizeof (ltf_plan_one), size * sizeof (ltf_plan_one));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 gerror (err);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 ltf_plan
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 plan (unsigned ndata, double fsamp, double ovlap, double binmin,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 unsigned mindftlen, unsigned freqdes, unsigned avgdes,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 unsigned getsegstart)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 ltf_plan p;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 ltf_plan_one *p1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 double fmin, fmax, fres, f;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 unsigned j, k, dftlen, segstartpos;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 double bin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 unsigned nseg;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 double xov;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 double freslim, fresmin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 unsigned nalloc;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 char err[160];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 double logfact;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 unsigned nsegstart; /* number of segstart entries */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 unsigned *segstartmemory; /* begin of segstart entries */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 double segincr;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 if (ndata < 500)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 sprintf (err, "ltf_plan: illegal value for ndata: %u<500", ndata);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 gerror (err);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 if (ndata < 500)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 sprintf (err, "ltf_plan: illegal value for ndata: %u<500", ndata);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 gerror (err);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 if (fsamp <= 0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 sprintf (err, "ltf_plan: illegal value for fsamp: %g<=0", fsamp);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 gerror (err);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 if (binmin < 0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 sprintf (err, "ltf_plan: illegal value for binmin: %g<0", binmin);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 gerror (err);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 if (ovlap < 0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 sprintf (err, "ltf_plan: illegal value for ovlap: %g<=0", ovlap);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 gerror (err);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 if (ovlap > 99)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 sprintf (err, "ltf_plan: illegal value for ovlap: %g>99%%", ovlap);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 gerror (err);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 if (freqdes < 3)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 sprintf (err, "ltf_plan: illegal value for freqdes: %u<3", freqdes);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 gerror (err);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 if (freqdes > ndata / 2)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 sprintf (err, "ltf_plan: illegal value for freqdes: %u>%u", freqdes,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 ndata / 2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 gerror (err);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 /* copy input data */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 p.ndata = ndata;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 p.fsamp = fsamp;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 p.ovlap = ovlap;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 if (binmin < 1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 binmin = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 p.binmin = binmin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 p.mindftlen = mindftlen;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 p.freqdes = freqdes;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 p.avgdes = avgdes;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 p.maxdftlen = p.maxnseg = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 nsegstart = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 xov = (1. - ovlap / 100.);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 fmin = fsamp / ndata * binmin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 fmax = fsamp / 2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 fresmin = fsamp / (double) ndata; /* absolute minimal allowed frequency resolution */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 freslim = fresmin * (1 + xov * (avgdes - 1)); /* limit above which fres leads to desired number of averages */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 logfact = (pow (ndata / 2., 1. / freqdes) - 1.);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 /* initial allocation */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 p.fplan = NULL;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 nalloc = freqdes;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 ltf_plan_alloc (&p, nalloc);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 for (j = 0, f = fmin; f < fmax; j++)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 if (j >= nalloc)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 /* enlarge allocation */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 nalloc *= 2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 ltf_plan_alloc (&p, nalloc);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 p1 = &(p.fplan[j]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 fres = f * logfact;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 fres = (fres > freslim) ? fres : sqrt (fres * freslim);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 if (fres < fresmin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 fres = fresmin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 bin = (f / fres);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 if (bin < binmin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 bin = binmin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 fres = f / bin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 dftlen = myround (fsamp / fres);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 if (dftlen > ndata)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 dftlen = ndata;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 if (dftlen < mindftlen)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 dftlen = mindftlen;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 nseg = myround (((double) (ndata - dftlen) /
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 (xov * (double) dftlen)) + 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 if (nseg == 1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 dftlen = ndata;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 fres = fsamp / dftlen;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 bin = f / fres;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 p1->f = f;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 p1->fres = fres;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 p1->bin = bin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 p1->dftlen = dftlen;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 p1->nseg = nseg;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 if (nseg > p.maxnseg)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 p.maxnseg = nseg;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 nsegstart += nseg;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 if (dftlen > p.maxdftlen)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 p.maxdftlen = dftlen;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 f += fres;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 p.nfreq = j;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 /* allocation shrink to fit */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 nalloc = p.nfreq;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 ltf_plan_alloc (&p, nalloc);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 /* determine starting indices of DFT segments */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 if (!getsegstart)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 for (j = 0; j < p.nfreq; j++)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 p.fplan[j].segstart = NULL;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 segstartmemory = malloc (nsegstart * sizeof (unsigned));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 if (segstartmemory == NULL)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 sprintf (err,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 "ltf_plan: error allocating %u bytes for segment start indices",
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 nsegstart * sizeof (unsigned));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 gerror (err);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 segstartpos = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 for (j = 0; j < p.nfreq; j++)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 p1 = &(p.fplan[j]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 p1->segstart = &(segstartmemory[segstartpos]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 p1->segstart[0] = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 if (p1->nseg > 1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 segincr =
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 (double) (ndata - p1->dftlen) / (double) (p1->nseg - 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 for (k = 1; k < p1->nseg - 1; k++)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 p1->segstart[k] = myround ((double) k * segincr);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 p1->segstart[p1->nseg - 1] = ndata - p1->dftlen;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 segstartpos += p1->nseg;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 return p;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 void
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 ltf_plan_free (ltf_plan p)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 if ((p.fplan[0]).segstart != NULL)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 free ((p.fplan[0]).segstart);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 free (p.fplan);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 void
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 fprint (double f, char *s)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 if (f < 1e-5)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 sprintf (s, "%.3f$\\mu$", 1e6 * f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 else if (f < 1e-4)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 sprintf (s, "%.2f$\\mu$", 1e6 * f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 else if (f < 1e-3)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 sprintf (s, "%.1f$\\mu$", 1e6 * f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 else if (f < 1e-2)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 sprintf (s, "%.3fm", 1e3 * f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 else if (f < 1e-1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 sprintf (s, "%.2fm", 1e3 * f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 else if (f < 1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 sprintf (s, "%.1fm", 1e3 * f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 sprintf (s, "%.3f", f);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 int
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 main (void)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 ltf_plan p;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 ltf_plan_one *p1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 unsigned ndata = 1000000;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 double fsamp = 10.;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295 double ovlap = 75;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 double binmin = 5.3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 unsigned mindftlen = 100;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 unsigned freqdes = 200;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 unsigned avgdes = 100;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 unsigned j, k;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 double eq1, eq2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 double dfdown, dfup;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 double logfact, logres;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305 logfact = (pow (ndata / 2., 1. / freqdes) - 1.);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 p = plan (ndata, fsamp, ovlap, binmin, mindftlen, freqdes, avgdes, 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 if (TEX)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312 printf ("\\section{Sample output}\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 printf
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 ("As reference for other implementations, here are the results for the case\\\\\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 printf ("$N_{\\rm data}$ ({\\tt ndata}) $=%d$\\\\\n", ndata);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316 printf ("$f_{\\rm samp}$ ({\\tt fsamp}) $=%g$\\,Hz\\\\\n", fsamp);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 printf ("$\\xi_{\\rm ovlap}$ ({\\tt ovlap}) $=%g$\\,\\%%\\\\\n", ovlap);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318 printf ("$b_{\\rm min}$ ({\\tt binmin}) $=%g$\\\\\n", binmin);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 printf ("$L_{\\rm min}$ ({\\tt mindftlen}) $=%d$\\\\\n", mindftlen);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 printf ("$J_{\\rm des}$ ({\\tt freqdes}) $=%d$\\\\\n", freqdes);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 printf ("$K_{\\rm des}$ ({\\tt avgdes}) $=%d$\n", avgdes);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322 printf ("\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 printf
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 ("Usually, $J_{\\rm des}$ ({\\tt freqdes}) will be chosen higher (1000\
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325 is a typical value); %d has been chosen here to save space in the\
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 printed table.\n",
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327 freqdes);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 printf ("\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 printf
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330 ("Targets that are not met are printed {\\bfseries \\slshape like this}\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 printf ("\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 printf ("\\small{\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 printf
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 ("\\tablehead{$j$ & $f_j$ & $r_j$ & $b_j$ & $K_j$ & $L_j$ & $\\frac{f_j-f_{j-1}}{r_j}$ & $\\frac{f_{j+1}-f_j}{r_j}$ & $\\frac{r_j}{c\\cdot f_j}$ & $q_k^{(j)}$\\\\\\hline}\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 printf ("\\begin{supertabular}{|r|r|r|r|r|r|r|r|r|l|}\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 for (j = 0; j < p.nfreq; j++)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 p1 = &(p.fplan[j]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343 /* check required relations */
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344 eq1 = p1->f - p1->fres * p1->bin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 assert (fabs (eq1 / p1->f) < 1e-10);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 eq2 = p.fsamp - p1->fres * p1->dftlen;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 assert (fabs (eq2 / p.fsamp) < 1e-10);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 if (j > 0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 dfdown = p.fplan[j].f - p.fplan[j - 1].f;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 dfdown = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 if (j < p.nfreq - 1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 dfup = p.fplan[j + 1].f - p.fplan[j].f;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 dfup = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 logres = p1->fres / (p1->f * logfact);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 if (TEX)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 char sf[80], sfres[80], snseg[80], sdown[80], sup[80], slogres[80];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 fprint (p1->f, sf);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 fprint (p1->fres, sfres);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364 if (p1->nseg < avgdes)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 sprintf (snseg, "{\\bfseries \\slshape %7d}", p1->nseg);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367 sprintf (snseg, "%7d", p1->nseg);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 if (j > 0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 sprintf (sdown, "%.3f", dfdown / p1->fres);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 sprintf (sdown, "---");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 if (j < p.nfreq - 1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 sprintf (sup, "%.3f", dfup / p1->fres);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375 sprintf (sup, "---");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 if (logres < .995 || logres > 1.005)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 sprintf (slogres, "{\\bfseries \\slshape %.3f}", logres);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379 sprintf (slogres, "%.3f", logres);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 printf
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381 ("%4d & %s & %s & %.2f & %s & %7d & %s & %s & %s & ",
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 j, sf, sfres, p1->bin, snseg, p1->dftlen, sdown, sup, slogres);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 printf ("%4d %20.20f %20.20f %20.20f %20d %20d %20.20f %20.20f %20.20f ", j,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387 p1->f, p1->fres, p1->bin, p1->nseg, p1->dftlen,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388 dfdown / p1->fres, dfup / p1->fres, logres);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390 if (p1->segstart != NULL)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392 // if (p1->nseg < 5)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 // {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394 // for (k = 0; k < p1->nseg; k++)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395 // printf ("%u ", p1->segstart[k]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396 // printf ("\\\\\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 // }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398 // else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 // {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400 // printf ("%u %u %u ... %u\\\\\n",
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401 // p1->segstart[0],
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402 // p1->segstart[1], p1->segstart[2],
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 // p1->segstart[p1->nseg - 1]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404 // }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 printf("\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406 assert (p1->segstart[p1->nseg - 1] + p1->dftlen == ndata);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409 printf (" (NULL)\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 if (TEX)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 {
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413 printf ("\\end{supertabular}}\n");
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 }
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415 // else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416 // printf ("% max. %u segments %u dftlen\n", p.maxnseg, p.maxdftlen);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 ltf_plan_free (p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418 return 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 }
|