2 * Copyright © 2009 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 struct cc_perioddata *
23 cc_period_make(struct cc_timedata *td, double start_time, double stop_time)
25 int len = stop_time - start_time + 1;
26 struct cc_perioddata *pd;
30 pd = calloc(1, sizeof (struct cc_perioddata));
31 pd->start = start_time;
34 pd->data = calloc(len, sizeof(double));
36 for (i = 0; i < pd->num; i++) {
37 t = start_time + i * pd->step;
38 while (j < td->num - 1 && fabs(t - td->data[j].time) >= fabs(t - td->data[j+1].time))
40 pd->data[i] = td->data[j].value;
45 struct cc_perioddata *
46 cc_period_low_pass(struct cc_perioddata *raw, double omega_pass, double omega_stop, double error)
48 struct cc_perioddata *filtered;
50 filtered = calloc (1, sizeof (struct cc_perioddata));
51 filtered->start = raw->start;
52 filtered->step = raw->step;
53 filtered->num = raw->num;
54 filtered->data = cc_low_pass(raw->data, raw->num, omega_pass, omega_stop, error);