# CosineSimilarity

```
public class CosineSimilarity
```

*** ** * ** ***

Utility class for computing cosine similarity between `Embedding` objects.

## Summary

| ### Public methods |
|---|---|
| `static double` | `compute(Embedding u, Embedding v)` Computes [cosine similarity](https://en.wikipedia.org/wiki/Cosine_similarity) between two `Embedding` objects. |

## Public methods

### compute

```
public static double compute(Embedding u, Embedding v)
```

Computes [cosine similarity](https://en.wikipedia.org/wiki/Cosine_similarity) between two `Embedding` objects.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if the embeddings are of different types (float vs. quantized), have different sizes, or have an L2-norm of 0. |