Skip to content

Commit

Permalink
npbackend: Added type-conversion on norm().
Browse files Browse the repository at this point in the history
  • Loading branch information
safl committed Apr 18, 2015
1 parent 88ce4f1 commit 41c74d7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bridge/npbackend/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,9 @@ def norm(x, ord=None, axis=None):
if axis != None:
raise NotImplementedError("Unsupported value of param ord=%s" % axis)

return np.sqrt(np.sum(x*x))
r = np.sum(x*x)
if issubclass(np.dtype(r.dtype).type, np.integer):
r_f32 = np.empty(r.shape, dtype=np.float32)
r_f32[:] = r
r = r_f32
return np.sqrt(r)

0 comments on commit 41c74d7

Please sign in to comment.