Mercurial > hg > jslab
view src/samer/mds/ProximityFilter.java @ 8:5e3cbbf173aa tip
Reorganise some more
author | samer |
---|---|
date | Fri, 05 Apr 2019 22:41:58 +0100 |
parents | bf79fb79ee13 |
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(); } }