def rsub(self, other):
"""
substract other by self
inplace
"""
if isinstance(other, PitchArray):
if self.shape != other.shape:
raise ValueError("array dimension misaligned")
dtype = _get_inplace_dtype(self, other)
if self.size:
if self.M == 1:
func = pu.get_subarray_function(
other.dtype, self.dtype, self.dtype, pitch = False)
func.prepared_call(
self._grid, self._block, self.gpudata,
other.gpudata, self.gpudata, self.size)
else:
func = pu.get_subarray_function(
other.dtype, self.dtype, self.dtype, pitch = True)
func.prepared_call(
self._grid, self._block, self.M, self.N,
self.gpudata, self.ld, other.gpudata,
other.ld, self.gpudata, self.ld)
return self
elif issubclass(type(other), (float, int, complex, np.integer,
np.floating, np.complexfloating)):
dtype = _get_inplace_dtype_with_scalar(other, self)
if self.size:
if self.M == 1:
func = pu.get_scalarsub_function(
self.dtype, self.dtype, pitch = False)
func.prepared_call(
self._grid, self._block, self.gpudata,
self.gpudata, other, self.size)
else:
func = pu.get_scalarsub_function(
self.dtype, 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
else:
raise TypeError("type of object to substract from"
"is not supported")
评论列表
文章目录