Exemplo n.º 1
0
 def rdiv(self, other):
     """
     divide other by self
     inplace if possible
     """
     if isinstance(other, PitchArray):
         if self.shape != other.shape:
             raise ValueError("array dimension misaligned")
         dtype = _get_common_dtype(self, other)
         if self.dtype == dtype:
             result = self
         else:
             result = self._new_like_me(dtype = dtype)
             
         if self.size:
             if self.M == 1:
                 func = pu.get_divarray_function(other.dtype, self.dtype, result.dtype, pitch = False)
                 func.prepared_call(self._grid, self._block, result.gpudata, other.gpudata, self.gpudata, self.size)
             else:
                 func = pu.get_divarray_function(other.dtype, self.dtype, result.dtype, pitch = True)
                 func.prepared_call(self._grid, self._block, self.M, self.N, result.gpudata, result.ld, other.gpudata, other.ld, self.gpudata, self.ld)
         return result
     else:
         if other == 0:
             return self
         else:
             if self.size:
                 if self.M == 1:
                     func = pu.get_scalardiv_function(self.dtype, pitch = False)
                     func.prepared_call(self._grid, self._block, self.gpudata, self.gpudata, other, self.size)
                 else:
                     func = pu.get_scalardiv_function(self.dtype, pitch = True)
                     func.prepared_call(self._grid, self._block, self.M, self.N, self.gpudata, self.ld, self.gpudata, self.ld, other)
             return self
Exemplo n.º 2
0
 def __rdiv__(self, other):
     if isinstance(other, PitchArray):
         if self.shape != other.shape:
             raise ValueError("array dimension misaligned")
         result = self._new_like_me(_get_common_dtype(self, other))
         if self.size:
             if self.M == 1:
                 func = pu.get_divarray_function(other.dtype, self.dtype, result.dtype, pitch = False)
                 func.prepared_call(self._grid, self._block, result.gpudata, other.gpudata, self.gpudata, self.size)
             else:
                 func = pu.get_divarray_function(other.dtype, self.dtype, result.dtype, pitch = True)
                 func.prepared_call(self._grid, self._block, self.M, self.N, result.gpudata, result.ld, other.gpudata, other.ld, self.gpudata, self.ld)
         return result
     else:
         if other == 1.0:
             return self.copy()
         else:
             result = self._new_like_me()
             if self.size:
                 if self.M == 1:
                     func = pu.get_scalardiv_function(self.dtype, pitch = False)
                     func.prepared_call(self._grid, self._block, result.gpudata, self.gpudata, other, self.size)
                 else:
                     func = pu.get_scalardiv_function(self.dtype, pitch = True)
                     func.prepared_call(self._grid, self._block, self.M, self.N, result.gpudata, result.ld, self.gpudata, self.ld, other)
             return result