public static int Distance(LocalPatternMatch p0, LocalPatternMatch p1, int length, int w) { double k = (Math.Abs(p0.AmplitudeDelta - p1.AmplitudeDelta)); var d = (int) (k*k*AMP_WEIGHT); var t = (int) (g(GapX(p0, p1, length, w)) + g(GapY(p0, p1, length, w))); return t + d; }
public static LocalPatternMatch CreateFrom(LocalPattern p0, LocalPattern p1) { var match = new LocalPatternMatch(); match.Dist = p0.DistanceTo(p1); match.X = p0.Position; match.Y = p1.Position; match.PositionDelta = p1.Position - p0.Position; match.AmplitudeDelta = p1.Amplitude - p0.Amplitude; match.TempScaleDelta = p1.TemporalScale - p0.TemporalScale; match.AmpScaleDelta = p1.AmplitudeScale - p0.AmplitudeScale; return match; }
public static double GapY(LocalPatternMatch p0, LocalPatternMatch p1, int length, int w) { if (p1.Y > p0.Y) return Math.Max((p1.Y - p0.Y)*length - w, 1); return Spade.INF_COST; }
public static double GapX(LocalPatternMatch p0, LocalPatternMatch p1, int length, float w) { if (p1.X > p0.X) return Math.Max((p1.X - p0.X)*length - w, 1); return Spade.INF_COST; }
public static int DistanceToPs(LocalPatternMatch p, int length, int w) { return (int) (g(p.X*length - w/2) + g(p.Y*length - w/2)); }