SGTY 2 hónapja
szülő
commit
e79d786f1e
1 módosított fájl, 15 hozzáadás és 0 törlés
  1. 15 0
      utils/vector_distance.py

+ 15 - 0
utils/vector_distance.py

@@ -0,0 +1,15 @@
+import math
+
+class VectorDistance:
+    @staticmethod
+    def calculate_distance(vector1, vector2):
+        if len(vector1) != len(vector2):
+            raise ValueError("Vectors must have the same dimensionality")
+        
+        squared_sum = sum((v1 - v2) ** 2 for v1, v2 in zip(vector1, vector2))
+        return math.sqrt(squared_sum)
+
+if __name__ == '__main__':
+    v1 = [1, 2, 3]
+    v2 = [4, 5, 6]
+    print(VectorDistance.calculate_distance(v1, v2))