Skip to content

Commit

Permalink
Improve the dot(). But it will change the original SparseBooleanVecto…
Browse files Browse the repository at this point in the history
…r to make is unuseful.
  • Loading branch information
fcyu committed May 22, 2017
1 parent 11782d9 commit 659819a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/proteomics/Types/SparseBooleanVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ public void put(int idx) {
return sparse_vector.size();
}

public double dot(SparseVector other) {
public double dot(SparseVector other) { // caution: it will change the original Sparse Boolean Vector.
double output = 0;
Map<Integer, Float> other_vector = other.getVectorMap();
Set<Integer> intersectedKeys = new HashSet<>(sparse_vector);
intersectedKeys.retainAll(other_vector.keySet());
for (int i : intersectedKeys) {
output += other_vector.get(i);
sparse_vector.retainAll(other.getIdxSet());
for (int i : sparse_vector) {
output += other.get(i);
}
return output;
}
Expand Down

0 comments on commit 659819a

Please sign in to comment.