Cleanup the java a little bit

Code was producing whole rotation of values and just throwing
away half of them
This commit is contained in:
2024-10-24 23:42:28 -05:00
parent 4385d68361
commit 119e0fcf51

View File

@@ -2105,8 +2105,8 @@ public class ecgApplet implements AdjustmentListener{
double df;//,dw1,dw2; double df;//,dw1,dw2;
double[] w, Hw, Sw, ph0, ph, SwC; double[] w, Hw, Sw, ph0, ph, SwC;
w = new double[n+1]; w = new double[n/2+1];
Hw = new double[n+1]; Hw = new double[n/2+1];
Sw = new double[n+1]; Sw = new double[n+1];
ph0= new double[(int)(n/2-1 +1)]; ph0= new double[(int)(n/2-1 +1)];
ph = new double[n+1]; ph = new double[n+1];
@@ -2122,14 +2122,14 @@ public class ecgApplet implements AdjustmentListener{
rrstd = 60.0*hrstd/(hrmean*hrmean); rrstd = 60.0*hrstd/(hrmean*hrmean);
df = sf/(double)n; df = sf/(double)n;
for(i=1; i<=n; i++) for(i=1; i<=n/2; i++)
w[i] = (i-1)*2.0*PI*df; w[i] = (i-1)*2.0*PI*df;
for(i=1; i<=n; i++){ for(i=1; i<=n/2; i++){
//dw1 = w[i]-w1; final var dw1 = w[i]-w1;
//dw2 = w[i]-w2; final var dw2 = w[i]-w2;
Hw[i] = (sig1*Math.exp(-0.5*(Math.pow(w[i]-w1,2)/Math.pow(c1,2))) / Math.sqrt(2*PI*c1*c1)) Hw[i] = (sig1*Math.exp(-dw1*dw1/(2.0*c1*c1)) / Math.sqrt(2*PI*c1*c1))
+ (sig2*Math.exp(-0.5*(Math.pow(w[i]-w2,2)/Math.pow(c2,2))) / Math.sqrt(2*PI*c2*c2)); + (sig2*Math.exp(-dw2*dw2/(2.0*c2*c2)) / Math.sqrt(2*PI*c2*c2));
} }
for(i=1; i<=n/2; i++) for(i=1; i<=n/2; i++)
@@ -2157,8 +2157,8 @@ public class ecgApplet implements AdjustmentListener{
for(i=1; i<=n; i++) for(i=1; i<=n; i++)
SwC[2*i] = Sw[i]* Math.sin(ph[i]); SwC[2*i] = Sw[i]* Math.sin(ph[i]);
/* calculate inverse fft */ /* calculate inverse fft, note Numerical Recipes uses opposite sign convention */
ifft(SwC,n,-1); ifft(SwC,n,1);
/* extract real part */ /* extract real part */
for(i=1; i<=n; i++) for(i=1; i<=n; i++)