Mercurial > hg > jslab
view 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 source
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(); } }