Sub Vectors_Similarity(v1() As Float, v2() As Float) As Float
If v1.Length <> v2.Length Then Return 0.0
Dim dotProduct As Double = 0.0
Dim normA As Double = 0.0
Dim normB As Double = 0.0
For i = 0 To v1.Length - 1
dotProduct = dotProduct + v1(i) * v2(i)
normA = normA + Power(v1(i), 2)
normB = normB + Power(v2(i), 2)
Next
Dim res As Double = dotProduct / (Sqrt(normA) * Sqrt(normB))
Return res.As(Float)
End Sub