blob: 38c1916c2cccfed5828501b05190e66f1977a970 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
//$Id$
package Fir;
import java.io.FileInputStream;
import java.io.DataInputStream;
public class CachedIOFirTester extends PerformanceMeter {
public CachedIOFirTester(String sampleFileName,
int sampleNum,
String coeffFileName,
int coeffNum,
int cycle) throws java.io.IOException {
FileInputStream ifile = new FileInputStream(sampleFileName);
DataInputStream dataStream = new DataInputStream(ifile);
this.mSample = new double[sampleNum];
for (int i = 0; i < sampleNum; i++)
this.mSample[i] = dataStream.readDouble();
ifile = new FileInputStream(coeffFileName);
dataStream = new DataInputStream(ifile);
this.mCoefficient = new double[coeffNum];
for (int i = 0; i < this.mCoefficient.length; i++)
this.mCoefficient[i] = dataStream.readDouble();
this.mQueue = new SampleQueue(sampleNum);
this.mFir = new Fir(this.mCoefficient, this.mQueue);
this.mCycle = cycle;
}
protected void Run() {
for (int c = 0; c < this.mCycle; c++) {
for (int n = 0; n < this.mSample.length; n++) {
this.mQueue.AddItem(this.mSample[n]);
this.mSample[n] = this.mFir.Filter();
}
}
}
private double mCoefficient[];
private double mSample[];
private Fir mFir;
private SampleQueue mQueue;
private int mCycle;
}
|