The Python sum function may return a float64 array even if the arguments are float32, so we need to force the result's dtype.

Adding more explicit error messages.
Merge pull request #9 from peter17/master

Fix problem with dtypes