Permalink
Browse files

updated __abs__ so that it returns the correct dtype for int dtypes a…

…nd does not promote to float
  • Loading branch information...
1 parent 3f890ca commit 1bbc9d6017ec4fae9e98a433f4f88815d0f3b590 @ahnitz ahnitz committed with Aug 22, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 pycuda/gpuarray.py
View
@@ -564,9 +564,12 @@ def __abs__(self):
else:
fname = "abs"
- from pytools import match_precision
- out_dtype = match_precision(np.dtype(np.float64), self.dtype)
- result = self._new_like_me(out_dtype)
+ if issubclass(self.dtype.type, np.complexfloating):
+ from pytools import match_precision
+ out_dtype = match_precision(np.dtype(np.float64), self.dtype)
+ result = self._new_like_me(out_dtype)
+ else:
+ out_dtype = self.dtype
func = elementwise.get_unary_func_kernel(fname, self.dtype,
out_dtype=out_dtype)

0 comments on commit 1bbc9d6

Please sign in to comment.