private static Recursive2ndOrderFilter makeFilter( double b0, double b1, double b2, double a1, double a2) { return new Recursive2ndOrderFilter( (float)b0,(float)b1,(float)b2,(float)a1,(float)a2); }
/** * Applies this filter along the 1st dimension in the forward and * reverse directions. * Input and output arrays must be distinct regular arrays. * Lengths of the input and output arrays must be equal. * @param x the input array. * @param y the output array. */ public void apply1ForwardReverse(float[][][] x, float[][][] y) { scale(_c*_g,x,y); for (int i2=0; i2<_n2; i2+=2) { _f2[i2 ].accumulate1Forward(x,y); _f2[i2+1].accumulate1Reverse(x,y); } }
void applyXN(int nd, float[][] x, float[][] y) { checkArrays(x,y); if (sameArrays(x,y)) x = copy(x); _g[nd][0][0].apply2Forward(x,y); _g[nd][0][1].accumulate2Reverse(x,y); _g[nd][1][0].accumulate2Forward(x,y); _g[nd][1][1].accumulate2Reverse(x,y); }
/** * Applies this filter in 1st dimension in the forward direction. * <p> * Input and output arrays may be the same array, but must be * regular and have equal lengths. * @param x the input array. * @param y the output array. */ public void apply1Forward(float[][][] x, float[][][] y) { checkArrays(x,y); int n3 = y.length; for (int i3=0; i3<n3; ++i3) { apply1Forward(x[i3],y[i3]); } }
/** * Accumulates output in 1st dimension in the reverse direction. * This method filters the input, and adds the result to the output; it * is most useful when implementing parallel forms of recursive filters. * <p> * Input and output arrays may be the same array, but must be * regular and have equal lengths. * @param x the input array. * @param y the output array. */ public void accumulate1Reverse(float[][] x, float[][] y) { checkArrays(x,y); int n2 = y.length; for (int i2=0; i2<n2; ++i2) { accumulateReverse(x[i2],y[i2]); } }
/** * Accumulates output in 2nd dimension in the reverse direction. * This method filters the input, and adds the result to the output; it * is most useful when implementing parallel forms of recursive filters. * <p> * Input and output arrays may be the same array, but must be * regular and have equal lengths. * @param x the input array. * @param y the output array. */ public void accumulate2Reverse(float[][][] x, float[][][] y) { checkArrays(x,y); int n3 = y.length; for (int i3=0; i3<n3; ++i3) { accumulate2Reverse(x[i3],y[i3]); } }
float[][][] x,y1,y2; x = randfloat(n,n,n); Recursive2ndOrderFilter rf = new Recursive2ndOrderFilter(b0,b1,b2,a1,a2); rf.apply1Forward(y1,y1); rf.accumulate1Forward(y1,y1); rf.apply2Forward(y2,y2); rf.accumulate2Forward(y2,y2); y2 = transpose12(y2); assertEqual(y1,y2); rf.apply3Forward(y2,y2); rf.accumulate3Forward(y2,y2); y2 = transpose13(y2); assertEqual(y1,y2); rf.apply1Reverse(y1,y1); rf.accumulate1Reverse(y1,y1); rf.apply2Reverse(y2,y2); rf.accumulate2Reverse(y2,y2); y2 = transpose12(y2); assertEqual(y1,y2); rf.apply3Reverse(y2,y2); rf.accumulate3Reverse(y2,y2); y2 = transpose13(y2); assertEqual(y1,y2);
public void test2(float b0, float b1, float b2, float a1, float a2) { int n = 20; float[][] x,y1,y2; x = randfloat(n,n); Recursive2ndOrderFilter rf = new Recursive2ndOrderFilter(b0,b1,b2,a1,a2); y1 = copy(x); rf.apply1Forward(y1,y1); rf.accumulate1Forward(y1,y1); y2 = transpose(x); rf.apply2Forward(y2,y2); rf.accumulate2Forward(y2,y2); y2 = transpose(y2); assertEqual(y1,y2); y1 = copy(x); rf.apply1Reverse(y1,y1); rf.accumulate1Reverse(y1,y1); y2 = transpose(x); rf.apply2Reverse(y2,y2); rf.accumulate2Reverse(y2,y2); y2 = transpose(y2); assertEqual(y1,y2); }
public void test1(float b0, float b1, float b2, float a1, float a2) { int n = 100; float[] x,y1,y2; x = randfloat(n); Recursive2ndOrderFilter rf = new Recursive2ndOrderFilter(b0,b1,b2,a1,a2); y1 = copy(x); rf.applyForward(y1,y1); y2 = reverse(x); rf.applyReverse(y2,y2); y2 = reverse(y2); assertEqual(y1,y2); rf.accumulateForward(y1,y1); y2 = reverse(y2); rf.accumulateReverse(y2,y2); y2 = reverse(y2); assertEqual(y1,y2); }
void applyN(int nd, float[] x, float[] y) { checkArrays(x,y); if (sameArrays(x,y)) x = copy(x); _g[nd][0][0].applyForward(x,y); _g[nd][0][1].accumulateReverse(x,y); _g[nd][1][0].accumulateForward(x,y); _g[nd][1][1].accumulateReverse(x,y); }
/** * Applies this filter along the 2nd dimension in the forward and * reverse directions. * Input and output arrays must be distinct regular arrays. * Lengths of the input and output arrays must be equal. * @param x the input array. * @param y the output array. */ public void apply2ForwardReverse(float[][] x, float[][] y) { scale(_c*_g,x,y); for (int i2=0; i2<_n2; i2+=2) { _f2[i2 ].accumulate2Forward(x,y); _f2[i2+1].accumulate2Reverse(x,y); } }
/** * Applies this filter along the 3rd dimension in the forward and * reverse directions. * Input and output arrays must be distinct regular arrays. * Lengths of the input and output arrays must be equal. * @param x the input array. * @param y the output array. */ public void apply3ForwardReverse(float[][][] x, float[][][] y) { scale(_c*_g,x,y); for (int i2=0; i2<_n2; i2+=2) { _f2[i2 ].accumulate3Forward(x,y); _f2[i2+1].accumulate3Reverse(x,y); } }
/** * Applies this filter in the forward and reverse directions. * Note that this method does not simply call the methods * {@link #applyForward(float[],float[])} and * {@link #applyReverse(float[],float[])} in sequence. * Input and output arrays must be distinct arrays. * Lengths of the input and output arrays must be equal. * @param x the input array. * @param y the output array. */ public void applyForwardReverse(float[] x, float[] y) { scale(_c*_g,x,y); for (int i2=0; i2<_n2; i2+=2) { _f2[i2 ].accumulateForward(x,y); _f2[i2+1].accumulateReverse(x,y); } }
/** * Accumulates output in 1st dimension in the reverse direction. * This method filters the input, and adds the result to the output; it * is most useful when implementing parallel forms of recursive filters. * <p> * Input and output arrays may be the same array, but must be * regular and have equal lengths. * @param x the input array. * @param y the output array. */ public void accumulate1Reverse(float[][][] x, float[][][] y) { checkArrays(x,y); int n3 = y.length; for (int i3=0; i3<n3; ++i3) { accumulate1Reverse(x[i3],y[i3]); } }
/** * Accumulates output in 1st dimension in the forward direction. * This method filters the input, and adds the result to the output; it * is most useful when implementing parallel forms of recursive filters. * <p> * Input and output arrays may be the same array, but must be * regular and have equal lengths. * @param x the input array. * @param y the output array. */ public void accumulate1Forward(float[][][] x, float[][][] y) { checkArrays(x,y); int n3 = y.length; for (int i3=0; i3<n3; ++i3) { accumulate1Forward(x[i3],y[i3]); } }
/** * Accumulates output in 1st dimension in the forward direction. * This method filters the input, and adds the result to the output; it * is most useful when implementing parallel forms of recursive filters. * <p> * Input and output arrays may be the same array, but must be * regular and have equal lengths. * @param x the input array. * @param y the output array. */ public void accumulate1Forward(float[][] x, float[][] y) { checkArrays(x,y); int n2 = y.length; for (int i2=0; i2<n2; ++i2) { accumulateForward(x[i2],y[i2]); } }
/** * Accumulates output in 2nd dimension in the forward direction. * This method filters the input, and adds the result to the output; it * is most useful when implementing parallel forms of recursive filters. * <p> * Input and output arrays may be the same array, but must be * regular and have equal lengths. * @param x the input array. * @param y the output array. */ public void accumulate2Forward(float[][][] x, float[][][] y) { checkArrays(x,y); int n3 = y.length; for (int i3=0; i3<n3; ++i3) { accumulate2Forward(x[i3],y[i3]); } }
/** * Applies this filter along the 2nd dimension in the forward direction. * Input and output arrays must be distinct regular arrays. * Lengths of the input and output arrays must be equal. * @param x the input array. * @param y the output array. */ public void apply2Forward(float[][] x, float[][] y) { scale(_c,x,y); for (int i1=0; i1<_n1; ++i1) _f1[i1].accumulate2Forward(x,y); }
/** * For experimental use only. * @param x array of x-coordinates. * @param y array of y-coordinates. */ public void applyFrr(float[] x, float[] y) { scale(_c*_g,x,y); for (int i2=0; i2<_n2; i2+=2) { //_f2[i2 ].accumulateForward(x,y); _f2[i2+1].accumulateReverse(x,y); } }
/** * Applies this filter along the 1st dimension in the forward direction. * Input and output arrays must be distinct regular arrays. * Lengths of the input and output arrays must be equal. * @param x the input array. * @param y the output array. */ public void apply1Forward(float[][] x, float[][] y) { scale(_c,x,y); for (int i1=0; i1<_n1; ++i1) _f1[i1].accumulate1Forward(x,y); }