Skip to content

Commit

Permalink
Renamed a variable in computeDistanceMatrix:
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Kubanek committed Apr 26, 2012
1 parent 35abbdf commit c7757b9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Sources/DBScan.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,29 +117,29 @@ - (void)merge:(NSMutableArray *)currentNeighbors:(NSArray *)newNeighbors {
- (NSArray *)computeDistanceMatrix:(NSArray *)points {
int numberOfPoints = points.count;

NSMutableArray *distanceM = [NSMutableArray arrayWithCapacity:numberOfPoints];
NSMutableArray *distanceMatrix = [NSMutableArray arrayWithCapacity:numberOfPoints];

for (int index = 0; index < numberOfPoints; index++) {
[distanceM insertObject:[NSMutableArray arrayWithCapacity:numberOfPoints] atIndex:index];
[distanceMatrix insertObject:[NSMutableArray arrayWithCapacity:numberOfPoints] atIndex:index];
}

for (int row = 0; row < numberOfPoints; row++) {
for (int col = row; col < numberOfPoints; col++) {
if (col == row) {
[[distanceM objectAtIndex:row] insertObject:[[NSNumber alloc] initWithFloat:.0f] atIndex:col];
[[distanceMatrix objectAtIndex:row] insertObject:[[NSNumber alloc] initWithFloat:.0f] atIndex:col];
}
else {
float distance = [_distanceFunction calculate:[points objectAtIndex:row]:[points objectAtIndex:col]];

NSNumber *number = [[NSNumber alloc] initWithFloat:distance];

[[distanceM objectAtIndex:row] insertObject:number atIndex:col];
[[distanceM objectAtIndex:col] insertObject:number atIndex:row];
[[distanceMatrix objectAtIndex:row] insertObject:number atIndex:col];
[[distanceMatrix objectAtIndex:col] insertObject:number atIndex:row];
}
}
}

return [NSArray arrayWithArray:distanceM]; // return immutable array
return [NSArray arrayWithArray:distanceMatrix]; // return immutable array
}

@end

0 comments on commit c7757b9

Please sign in to comment.