Math Math functions for the AtomicEmbeddings package. cosine_distance(a, b) Cosine distance of two vectors. Source code in src/elementembeddings/utils/math.py 21 22 23 24 25 26def cosine_distance( a: list[int | float], b: list[int | float], ) -> int | float: """Cosine distance of two vectors.""" return 1 - cosine_similarity(a, b) cosine_similarity(a, b) Cosine similarity of two vectors. Source code in src/elementembeddings/utils/math.py 13 14 15 16 17 18def cosine_similarity( a: list[int | float], b: list[int | float], ) -> int | float: """Cosine similarity of two vectors.""" return dot(a, b) / ((dot(a, a) ** 0.5) * (dot(b, b) ** 0.5)) dot(a, b) Dot product of two vectors. Source code in src/elementembeddings/utils/math.py 8 9 10def dot(a: list[int | float], b: list[int | float]) -> int | float: """Dot product of two vectors.""" return sum(map(operator.mul, a, b))