Mercurial > hg > jslab
comparison src/samer/mds/ProximityFilter.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bf79fb79ee13 |
---|---|
1 package samer.mds; | |
2 | |
3 import samer.maths.*; | |
4 import samer.tools.*; | |
5 import samer.core.types.*; | |
6 import java.util.*; | |
7 | |
8 /** Compute component-wise filter coefficients using a | |
9 a distance/proximity matrix. The filter kernel is centred on | |
10 one of the elements, so that the coefficients are a function | |
11 of the distance/proximity between each unit and the given | |
12 "pivot" element. | |
13 */ | |
14 | |
15 public class ProximityFilter extends NullTask implements Observer { | |
16 Matrix R; | |
17 VVector F; | |
18 VFunction map; // map from proximity to coeff. | |
19 VInteger i; // centre element, num elements | |
20 | |
21 public ProximityFilter(Matrix R, VVector F, VFunction map) { | |
22 this.R=R; this.F=F; this.map=map; | |
23 i=new VInteger("pivot",0); | |
24 i.setRange(0,R.getRowDimension()-1); | |
25 | |
26 R.addObserver(this); | |
27 map.addObserver(this); | |
28 i.addObserver(this); | |
29 } | |
30 public void run() { map.getFunction().apply(R.getArray()[i.value],F.array()); } | |
31 public void update(Observable obs, Object arg) { run(); F.changed(); } | |
32 public void dispose() { | |
33 map.deleteObserver(this); | |
34 R.deleteObserver(this); | |
35 i.dispose(); | |
36 } | |
37 } |