diff src/samer/mds/ProximityFilter.java @ 0:bf79fb79ee13

Initial Mercurial check in.
author samer
date Tue, 17 Jan 2012 17:50:20 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/samer/mds/ProximityFilter.java	Tue Jan 17 17:50:20 2012 +0000
@@ -0,0 +1,37 @@
+package samer.mds;
+
+import samer.maths.*;
+import samer.tools.*;
+import samer.core.types.*;
+import java.util.*;
+
+/** Compute component-wise filter coefficients using a
+	a distance/proximity matrix. The filter kernel is centred on
+	one of the elements, so that the coefficients are a function
+	of the distance/proximity between each unit and the given
+	"pivot" element.
+*/
+	 
+public class ProximityFilter extends NullTask implements Observer {
+	Matrix		R;
+	VVector		F;
+	VFunction	map;		// map from proximity to coeff.
+	VInteger	i;			// centre element, num elements
+
+	public ProximityFilter(Matrix R, VVector F, VFunction map) {
+		this.R=R; this.F=F; this.map=map;
+		i=new VInteger("pivot",0);
+		i.setRange(0,R.getRowDimension()-1);
+
+		R.addObserver(this);
+		map.addObserver(this);
+		i.addObserver(this);
+	}
+	public void run() { 	map.getFunction().apply(R.getArray()[i.value],F.array()); }
+	public void update(Observable obs, Object arg) { run(); F.changed(); }
+	public void dispose() {
+		map.deleteObserver(this);
+		R.deleteObserver(this);
+		i.dispose();
+	}
+}