Last change
on this file since 1308 was
1308,
checked in by rkrimmel, 11 years ago
|
Introducing The Substitution Matrix Interface, Implemented it with a simple difference substitution matrix.
|
File size:
873 bytes
|
Line | |
---|
1 | /** |
---|
2 | * |
---|
3 | */ |
---|
4 | package de.ugoe.cs.autoquest.plugin.alignment; |
---|
5 | |
---|
6 | /** |
---|
7 | * @author Ralph Krimmel |
---|
8 | * |
---|
9 | */ |
---|
10 | public class DifferenceSubstitutionMatrix implements SubstitutionMatrix { |
---|
11 | |
---|
12 | private int[] input1; |
---|
13 | private int[] input2; |
---|
14 | private int maxValue; |
---|
15 | |
---|
16 | public DifferenceSubstitutionMatrix(int[] input1,int[] input2) { |
---|
17 | this.input1 = input1; |
---|
18 | this.input2 = input2; |
---|
19 | this.maxValue = getMaxValue(); |
---|
20 | } |
---|
21 | |
---|
22 | /* (non-Javadoc) |
---|
23 | * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int) |
---|
24 | */ |
---|
25 | public int getDistance(int pos1, int pos2) { |
---|
26 | return maxValue - (input1[pos1] - input2[pos2]); |
---|
27 | } |
---|
28 | |
---|
29 | private int getMaxValue() { |
---|
30 | int max = input1[0]; |
---|
31 | for (int i=0; i < input1.length; i++) { |
---|
32 | if(input1[i] > max) { |
---|
33 | max = input1[i]; |
---|
34 | } |
---|
35 | } |
---|
36 | for (int j=0; j < input2.length; j++) { |
---|
37 | if(input2[j] > max) { |
---|
38 | max = input2[j]; |
---|
39 | } |
---|
40 | } |
---|
41 | return max; |
---|
42 | } |
---|
43 | |
---|
44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.