2 * Copyright © 2017 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, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
15 package org.altusmetrum.altoslib_11;
19 public class AltosTimeSeries implements Iterable<AltosTimeValue> {
21 public AltosUnits units;
22 List<AltosTimeValue> values;
24 public void add(double x, double y) {
25 values.add(new AltosTimeValue(x, y));
28 public Iterator<AltosTimeValue> iterator() {
29 return values.iterator();
32 public void integrate(AltosTimeSeries integral) {
37 for (AltosTimeValue v : values) {
50 public void differentiate(AltosTimeSeries diff) {
55 for (AltosTimeValue v: values) {
72 private int find_left(int i, double dt) {
74 double t = values.get(i).x - dt;
75 for (j = i; j > 0; j--) {
76 if (values.get(j).x < t)
83 public void filter(AltosTimeSeries out, double width) {
84 for (int i = 0; i < values.size(); i++) {
88 public AltosTimeSeries(String label, AltosUnits units) {
91 this.values = new ArrayList<AltosTimeValue>();