refactoring
This commit is contained in:
parent
a5f23d766e
commit
a413014aaf
@ -482,14 +482,9 @@ func normalize(vec []float32) []float32 {
|
|||||||
sum += float64(v * v)
|
sum += float64(v * v)
|
||||||
}
|
}
|
||||||
|
|
||||||
sum = math.Sqrt(sum)
|
norm := float32(0.0)
|
||||||
|
|
||||||
var norm float32
|
|
||||||
|
|
||||||
if sum > 0 {
|
if sum > 0 {
|
||||||
norm = float32(1.0 / sum)
|
norm = float32(1.0 / math.Sqrt(sum))
|
||||||
} else {
|
|
||||||
norm = 0.0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range vec {
|
for i := range vec {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user