-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManhattanDistance.java
More file actions
35 lines (31 loc) · 950 Bytes
/
ManhattanDistance.java
File metadata and controls
35 lines (31 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*=============================================================================
| Assignment: Final Project - Multiple Document Summarization
| Author: Group7 - (Sampath, Ajay, Visesh)
| Grader: Walid Shalaby
|
| Course: ITCS 6190
| Instructor: Srinivas Akella
|
| Language: Java
| Version : 1.8.0_101
|
| Deficiencies: No logical errors.
*===========================================================================*/
/*
* Computes Manhattan distance between two vectors
* */
public final class ManhattanDistance implements DistanceMeasurer {
@Override
public double measureDistance(double[] set1, double[] set2) {
double sum = 0;
int length = set1.length;
for (int i = 0; i < length; i++) {
sum += Math.abs(set1[i] - set2[i]);
}
return sum;
}
@Override
public double measureDistance(DoubleVector vec1, DoubleVector vec2) {
return vec1.subtract(vec2).abs().sum();
}
}