Just installed release 3.2.1. Thanks to the Vector.map2 I can now write
So would it make sense to include a Vector.fold2 function in the next release?
Regards
Wolfgang
let kld a b = Vector.map2 (fun p q -> if p = 0.0 || q = 0.0 then 0.0 else log(p / q) * p) a b |> Vector.sum
But then I realized that Vector.fold2 would be even better. Here's the Array version: let kld a b = Array.fold2 (fun acc p q -> if p = 0.0 || q = 0.0 then acc else acc + log(p / q) * p) a b
In my tests, Array.fold2 is faster than Array.map2 |> Array.sumSo would it make sense to include a Vector.fold2 function in the next release?
Regards
Wolfgang