Skip to content

Commit

Permalink
Use float in cosine metric final calculation in default vectorization…
Browse files Browse the repository at this point in the history
… provider (#358)

Makes the implementation consistent with Panama and native vectorization providers, which use float. Removes one of the sources of potentially different results for different providers.

Fixes #357
  • Loading branch information
k-jamroz authored Sep 19, 2024
1 parent f3650c6 commit 17b1ce2
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public float cosine(VectorFloat<?> av, VectorFloat<?> bv) {
norm1 += elem1 * elem1;
norm2 += elem2 * elem2;
}
return (float) (sum / Math.sqrt((double) norm1 * (double) norm2));
return (float) (sum / Math.sqrt(norm1 * norm2));
}

@Override
Expand All @@ -152,7 +152,7 @@ public float cosine(VectorFloat<?> av, int aoffset, VectorFloat<?> bv, int boffs
norm1 += elem1 * elem1;
norm2 += elem2 * elem2;
}
return (float) (sum / Math.sqrt((double) norm1 * (double) norm2));
return (float) (sum / Math.sqrt(norm1 * norm2));
}

@Override
Expand Down

0 comments on commit 17b1ce2

Please sign in to comment.