Пример #1
0
def _fftconv(a, b, axes=(0, 1)):
    """Patched version of :func:`sporco.linalg.fftconv`."""

    if cp.isrealobj(a) and cp.isrealobj(b):
        fft = cp.fft.rfftn
        ifft = cp.fft.irfftn
    else:
        fft = cp.fft.fftn
        ifft = cp.fft.ifftn
    dims = cp.maximum(cp.asarray([a.shape[i] for i in axes]),
                      cp.asarray([b.shape[i] for i in axes]))
    dims = [int(d) for d in dims]
    af = fft(a, dims, axes)
    bf = fft(b, dims, axes)
    return ifft(af * bf, dims, axes)
Пример #2
0
def _fftconv(a, b, axes=(0, 1)):
    """Patched version of :func:`sporco.linalg.fftconv`."""

    if cp.isrealobj(a) and cp.isrealobj(b):
        fft = cp.fft.rfftn
        ifft = cp.fft.irfftn
    else:
        fft = cp.fft.fftn
        ifft = cp.fft.ifftn
    dims = cp.maximum(cp.asarray([a.shape[i] for i in axes]),
                      cp.asarray([b.shape[i] for i in axes]))
    dims = [int(d) for d in dims]
    af = fft(a, dims, axes)
    bf = fft(b, dims, axes)
    return ifft(af * bf, dims, axes)
Пример #3
0
    def adj_lam(self, data, theta):
        """Adjoint Laminography transform (L^*)"""
        res = cp.zeros([self.n2, self.n1, self.n0], dtype='complex64')

        data_gpu = cp.asarray(data.astype('complex64'))
        theta_gpu = cp.asarray(theta)

        # C++ wrapper, send pointers to GPU arrays
        self.adj(res.data.ptr, data_gpu.data.ptr, theta_gpu.data.ptr)

        if (cp.isrealobj(data)):
            res = res.real
        if (isinstance(data, np.ndarray)):
            res = res.get()
        return res