コード例 #1
0
ファイル: gpuarray.py プロジェクト: spatel81/pycuda
    def imag(self):
        dtype = self.dtype
        if issubclass(self.dtype.type, np.complexfloating):
            from pytools import match_precision
            real_dtype = match_precision(np.dtype(np.float64), dtype)

            result = self._new_like_me(dtype=real_dtype)

            func = elementwise.get_imag_kernel(dtype, real_dtype)
            func.set_block_shape(*self._block)
            func.prepared_async_call(self._grid, None, self.gpudata,
                                     result.gpudata, self.mem_size)

            return result
        else:
            return zeros_like(self)
コード例 #2
0
ファイル: gpuarray.py プロジェクト: minrk/PyCUDA
    def imag(self):
        dtype = self.dtype
        if issubclass(self.dtype.type, numpy.complexfloating):
            from pytools import match_precision
            real_dtype = match_precision(numpy.dtype(numpy.float64), dtype)

            result = self._new_like_me(dtype=real_dtype)

            func = elementwise.get_imag_kernel(dtype, real_dtype)
            func.set_block_shape(*self._block)
            func.prepared_async_call(self._grid, None,
                    self.gpudata, result.gpudata,
                    self.mem_size)

            return result
        else:
            return zeros_like(self)
コード例 #3
0
ファイル: gpuarray.py プロジェクト: abergeron/pycuda
    def imag(self):
        dtype = self.dtype
        if issubclass(self.dtype.type, np.complexfloating):
            if not self.flags.forc:
                raise RuntimeError("only contiguous arrays may " "be used as arguments to this operation")

            from pytools import match_precision

            real_dtype = match_precision(np.dtype(np.float64), dtype)

            result = self._new_like_me(dtype=real_dtype)

            func = elementwise.get_imag_kernel(dtype, real_dtype)
            func.prepared_async_call(self._grid, self._block, None, self.gpudata, result.gpudata, self.mem_size)

            return result
        else:
            return zeros_like(self)
コード例 #4
0
    def imag(self):
        dtype = self.dtype
        if issubclass(self.dtype.type, np.complexfloating):
            if not self.flags.forc:
                raise RuntimeError("only contiguous arrays may "
                        "be used as arguments to this operation")

            from pytools import match_precision
            real_dtype = match_precision(np.dtype(np.float64), dtype)

            result = self._new_like_me(dtype=real_dtype)

            func = elementwise.get_imag_kernel(dtype, real_dtype)
            func.prepared_async_call(self._grid, self._block, None,
                    self.gpudata, result.gpudata,
                    self.mem_size)

            return result
        else:
            return zeros_like(self)