refactoring

This commit is contained in:
Roy Han 2024-07-03 11:20:55 -07:00
parent a5f23d766e
commit a413014aaf

View File

@ -482,14 +482,9 @@ func normalize(vec []float32) []float32 {
sum += float64(v * v)
}
sum = math.Sqrt(sum)
var norm float32
norm := float32(0.0)
if sum > 0 {
norm = float32(1.0 / sum)
} else {
norm = 0.0
norm = float32(1.0 / math.Sqrt(sum))
}
for i := range vec {