From c2b29d95b12e5b169297326a777d371951b50f17 Mon Sep 17 00:00:00 2001 From: psambit9791 Date: Mon, 27 Dec 2021 12:56:05 +0000 Subject: [PATCH] Implemented _Adaptive interface for all adaptive filters; made edits to javadoc comments --- pom.xml | 2 +- .../github/psambit9791/jdsp/filter/_FIRFilter.java | 2 +- .../github/psambit9791/jdsp/filter/adaptive/AP.java | 2 +- .../psambit9791/jdsp/filter/adaptive/GNGD.java | 12 +----------- .../github/psambit9791/jdsp/filter/adaptive/LMS.java | 12 +----------- .../psambit9791/jdsp/filter/adaptive/NLMS.java | 12 +----------- .../psambit9791/jdsp/filter/adaptive/NSSLMS.java | 12 +----------- .../github/psambit9791/jdsp/filter/adaptive/RLS.java | 12 +----------- .../psambit9791/jdsp/filter/adaptive/SSLMS.java | 12 +----------- .../psambit9791/jdsp/filter/adaptive/_Adaptive.java | 4 ++-- .../psambit9791/jdsp/signal/ComplexConvolution.java | 2 +- 11 files changed, 12 insertions(+), 72 deletions(-) diff --git a/pom.xml b/pom.xml index 2fc6cbde..5434d4ef 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.psambit9791 jdsp - 1.0.0-SNAPSHOT + 1.0.0 diff --git a/src/main/java/com/github/psambit9791/jdsp/filter/_FIRFilter.java b/src/main/java/com/github/psambit9791/jdsp/filter/_FIRFilter.java index 5ba56c9d..65701b91 100644 --- a/src/main/java/com/github/psambit9791/jdsp/filter/_FIRFilter.java +++ b/src/main/java/com/github/psambit9791/jdsp/filter/_FIRFilter.java @@ -21,7 +21,7 @@ * @author Sambit Paul * @version 1.2 */ -abstract class _FIRFilter { +public abstract class _FIRFilter { /** * FIR Filters follow the formula y_n = sum(b_i * x_(n-i)) for all coefficients i = 0 to M. diff --git a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/AP.java b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/AP.java index aeb716f1..14be8037 100644 --- a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/AP.java +++ b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/AP.java @@ -45,7 +45,7 @@ public class AP implements _Adaptive { private double[] output; /** - * This constructor initialises the prerequisites required for the LMS adaptive filter. + * This constructor initialises the prerequisites required for the AP adaptive filter. * @param order projection order to determine the memory * @param learningRate also known as step size. Determines how fast the adaptive filter changes its filter weights. * If it is too slow, the filter may have bad performance. If it is too high, the filter will diff --git a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/GNGD.java b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/GNGD.java index 82844fa9..3ccd8044 100644 --- a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/GNGD.java +++ b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/GNGD.java @@ -27,7 +27,7 @@ * @author Sambit Paul * @version 1.0 */ -public class GNGD { +public class GNGD implements _Adaptive{ private double[] weights; // Weights of the filter private double[] error; @@ -39,16 +39,6 @@ public class GNGD { private double last_e; private double[] last_x; - /** - * Dictates how the filter weights initialization should be done: - * RANDOM: filter weights get an initial random value ranging from 0 to 1 - * ZEROS: filter weights get initial value 0 - */ - public enum WeightsFillMethod { - RANDOM, - ZEROS - } - /** * This constructor initialises the prerequisites required for the GNGD adaptive filter. * @param learningRate learning rate diff --git a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/LMS.java b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/LMS.java index 6d003747..0f202004 100644 --- a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/LMS.java +++ b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/LMS.java @@ -15,23 +15,13 @@ * @author Sibo Van Gool * @version 1.0 */ -public class LMS { +public class LMS implements _Adaptive { private final double learningRate; // Learning rate (= step size) private final double leakageFactor; // Leakage factor private double[] weights; // Weights of the filter private double[] error; // Error of the filter private double[] output; // Filtered output - /** - * Dictates how the filter weights initialization should be done: - * RANDOM: filter weights get an initial random value ranging from 0 to 1 - * ZEROS: filter weights get initial value 0 - */ - public enum WeightsFillMethod { - RANDOM, - ZEROS - } - /** * This constructor initialises the prerequisites required for the LMS adaptive filter. * @param learningRate also known as step size. Determines how fast the adaptive filter changes its filter weights. diff --git a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/NLMS.java b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/NLMS.java index b65da2fa..9f3b587a 100644 --- a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/NLMS.java +++ b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/NLMS.java @@ -19,23 +19,13 @@ * @author Sibo Van Gool * @version 1.0 */ -public class NLMS { +public class NLMS implements _Adaptive { private final double learningRate; // Learning rate (= step size) private final double leakageFactor; // Leakage factor private double[] weights; // Weights of the filter private double[] error; // Error of the filter private double[] output; // Filtered output - /** - * Dictates how the filter weights initialization should be done: - * RANDOM: filter weights get an initial random value ranging from 0 to 1 - * ZEROS: filter weights get initial value 0 - */ - public enum WeightsFillMethod { - RANDOM, - ZEROS - } - /** * This constructor initialises the prerequisites required for the NLMS adaptive filter. * @param learningRate also known as step size. Determines how fast the adaptive filter changes its filter weights. diff --git a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/NSSLMS.java b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/NSSLMS.java index 53900ddb..803140d5 100644 --- a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/NSSLMS.java +++ b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/NSSLMS.java @@ -32,23 +32,13 @@ * @author Sambit Paul * @version 1.0 */ -public class NSSLMS { +public class NSSLMS implements _Adaptive{ private final double learningRate; // Learning rate (= step size) private final double leakageFactor; // Leakage factor private double[] weights; // Weights of the filter private double[] error; // Error of the filter private double[] output; // Filtered output - /** - * Dictates how the filter weights initialization should be done: - * RANDOM: filter weights get an initial random value ranging from 0 to 1 - * ZEROS: filter weights get initial value 0 - */ - public enum WeightsFillMethod { - RANDOM, - ZEROS - } - /** * Returns the sign of the input number. * @param err Value whose sign is to be determined diff --git a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/RLS.java b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/RLS.java index 22360729..2a11a39e 100644 --- a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/RLS.java +++ b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/RLS.java @@ -25,23 +25,13 @@ * @author Sambit Paul * @version 1.0 */ -public class RLS { +public class RLS implements _Adaptive{ private double[] weights; // Weights of the filter private double[] error; private double[] output; private double mu; // Forgetting factor private double[][] R; - /** - * Dictates how the filter weights initialization should be done: - * RANDOM: filter weights get an initial random value ranging from 0 to 1 - * ZEROS: filter weights get initial value 0 - */ - public enum WeightsFillMethod { - RANDOM, - ZEROS - } - /** * This constructor initialises the prerequisites required for the RLS adaptive filter. * @param mu forgetting factor. It is introduced to give exponentially less weight to older error samples. diff --git a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/SSLMS.java b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/SSLMS.java index 0eb3c717..53ed46a6 100644 --- a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/SSLMS.java +++ b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/SSLMS.java @@ -31,23 +31,13 @@ * @author Sambit Paul * @version 1.0 */ -public class SSLMS { +public class SSLMS implements _Adaptive{ private final double learningRate; // Learning rate (= step size) private final double leakageFactor; // Leakage factor private double[] weights; // Weights of the filter private double[] error; // Error of the filter private double[] output; // Filtered output - /** - * Dictates how the filter weights initialization should be done: - * RANDOM: filter weights get an initial random value ranging from 0 to 1 - * ZEROS: filter weights get initial value 0 - */ - public enum WeightsFillMethod { - RANDOM, - ZEROS - } - /** * Returns the sign of the input number. * @param err Value whose sign is to be determined diff --git a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/_Adaptive.java b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/_Adaptive.java index 9ab405bb..b6688f2f 100644 --- a/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/_Adaptive.java +++ b/src/main/java/com/github/psambit9791/jdsp/filter/adaptive/_Adaptive.java @@ -20,10 +20,10 @@ * @author Sambit Paul * @version 1.0 */ -interface _Adaptive { +public interface _Adaptive { /** - * Dictates how the filter weights initialization should be done: + * Dictates how the filter weights initialization should be done. * RANDOM: filter weights get an initial random value ranging from 0 to 1 * ZEROS: filter weights get initial value 0 */ diff --git a/src/main/java/com/github/psambit9791/jdsp/signal/ComplexConvolution.java b/src/main/java/com/github/psambit9791/jdsp/signal/ComplexConvolution.java index 5f4e41f0..ca35e070 100644 --- a/src/main/java/com/github/psambit9791/jdsp/signal/ComplexConvolution.java +++ b/src/main/java/com/github/psambit9791/jdsp/signal/ComplexConvolution.java @@ -20,7 +20,7 @@ /** *

Convolution for Complex Numbers

* The ComplexConvolution class implements different modes of convolution for a list of complex numbers. - * The window can be a list of Complex or double numbers. + * The window can be a list of Complex or real (double) numbers. *

* * @author Sambit Paul