Mercurial > hg > jslab
view src/samer/mds/Minkowski.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.core.types.*; import samer.maths.*; /** Minkowski metric */ public class Minkowski implements MDS.Metric { VDouble exponent=new VDouble("exponent",1); public Minkowski(double p) { exponent.set(p); } public double d(double [] x, double [] y, double [] r) { Mathx.sub(r,y,x); double q=0, p=exponent.value; for (int i=0; i<r.length; i++) q+=Math.pow(r[i],p); return Math.pow(q,1/p); } }