Mercurial > hg > jslab
view src/samer/mds/MDSBase.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.core.*; import samer.core.types.*; import samer.maths.*; import samer.tools.*; /** MDS base class. Manages a NxE matrix of object positions, an array of links (end point object indices and a distance per link), a stress value and a learning rate, and a buffer which for accumulating the "force" on each object. Client code or subclass must set up link array and implement the actual adaptation algorithm. */ public class MDSBase extends Viewable implements Task { int N, M, E; // points, links, dimensions Matrix P; // object positions VDouble S, rate; // stress, learning rate double[] D; // input distances short [] l1, l2; // arrays of link end points double [][] F; // object 'forces' double [] f; // force buffer public MDSBase(Matrix p) { super("mds"); P=p; Shell.push(node); N = p.getRowDimension(); E = p.getColumnDimension(); Shell.print("MDS: "+N+" objects"); Shell.print("MDS: space is "+E+" dimensional"); rate = new VDouble("rate",0.001); S = new VDouble("stress"); Shell.pop(); F = new double[N][P.getColumnDimension()]; f = new double[P.getColumnDimension()]; M=0; D = new double[M]; } /** optimises only first E columns of P E must be less than width of original P */ public void setDimensionality(int e) { E=e; } /** link each object to all the others , returns distance array */ public void clearLinks(double [] D) { M=D.length; Shell.print("MDS: creating "+M+" links."); l1 = new short[M]; l2 = new short[M]; this.D = D; } /** the kth link joint objects i and j */ public void setLink(int k, int i, int j) { l1[k]=(short)i; l2[k]=(short)j; } public double [] getLinkArray() { return D; } public void dispose() { S.dispose(); rate.dispose(); } public void starting() {} public void stopping() {} public void run() {} }