def __rdiv__(self,other): """Divides an array by a scalar or an array:: x = n / self """ if isinstance(other, GPUArray): if not self.flags.forc or not other.flags.forc: raise RuntimeError("only contiguous arrays may " "be used as arguments to this operation") result = self._new_like_me(_get_common_dtype(self, other)) func = elementwise.get_divide_kernel() func.prepared_async_call(self._grid, self._block, None, other.gpudata, self.gpudata, result.gpudata, self.mem_size) return result else: if other == 1: return self else: # create a new array for the result result = self._new_like_me() return self._rdiv_scalar(other, result)
def __rdiv__(self, other): """Divides an array by a scalar or an array:: x = n / self """ if isinstance(other, GPUArray): if not self.flags.forc or not other.flags.forc: raise RuntimeError("only contiguous arrays may " "be used as arguments to this operation") result = self._new_like_me(_get_common_dtype(self, other)) func = elementwise.get_divide_kernel() func.prepared_async_call(self._grid, self._block, None, other.gpudata, self.gpudata, result.gpudata, self.mem_size) return result else: if other == 1: return self else: # create a new array for the result result = self._new_like_me() return self._rdiv_scalar(other, result)
def _div(self, other, out, stream=None): """Divides an array by another array.""" assert self.shape == other.shape func = elementwise.get_divide_kernel(self.dtype, other.dtype, out.dtype) func.set_block_shape(*self._block) func.prepared_async_call(self._grid, stream, self.gpudata, other.gpudata, out.gpudata, self.mem_size) return out
def __rdiv__(self,other): """Divides an array by a scalar or an array:: x = n / self """ if isinstance(other, GPUArray): result = self._new_like_me(_get_common_dtype(self, other)) func = elementwise.get_divide_kernel() func.set_block_shape(*self._block) func.prepared_async_call(self._grid, None, other.gpudata, self.gpudata, result.gpudata, self.mem_size) return result else: if other == 1: return self else: # create a new array for the result result = self._new_like_me() return self._rdiv_scalar(other, result)