From e6abf47bea87edd16e581ceaf1c73e059bed5c28 Mon Sep 17 00:00:00 2001 From: Lucas Teixeira Date: Wed, 8 Jul 2026 16:45:12 +0200 Subject: [PATCH 1/4] feat: add keops full matrix multiplication --- src/pyGroupedTransforms/GroupedTransform.py | 118 +++++++++++++++----- src/pyGroupedTransforms/NFFTtools.py | 75 ------------- 2 files changed, 89 insertions(+), 104 deletions(-) diff --git a/src/pyGroupedTransforms/GroupedTransform.py b/src/pyGroupedTransforms/GroupedTransform.py index 76ed90d..57bf99a 100644 --- a/src/pyGroupedTransforms/GroupedTransform.py +++ b/src/pyGroupedTransforms/GroupedTransform.py @@ -1,6 +1,12 @@ import numpy as np +import torch from pyGroupedTransforms import * +from .NFFTtools import index_set_without_zeros + +import pykeops +from pykeops.torch import LazyTensor + # All code that is linked to NFMTtools or to system = "mixed" is not tested yet.... @@ -266,24 +272,87 @@ def __init__( bandwidths=s.bandwidths, X=np.copy(X[:, u], order="C") ) elif algorithm == "keops": - self.matrix = np.empty((0,0), dtype=object) + self.matrix = np.empty((0,0), dtype=object) + + self.transforms = [ + DeferredLinearOperator() + for _ in range(len(self.settings)) + ] + + D = X.shape[1] - self.transforms = [ - DeferredLinearOperator() - for _ in range(len(self.settings)) - ] + freq_list = [] - for idx, s in enumerate(self.settings): + for s in self.settings: - if len(s.bandwidths) == 0: - u = (0,) - else: - u = s.u + if len(s.bandwidths) == 0: + full = np.zeros((1, D), dtype=np.int32) + + + else: + local = index_set_without_zeros( + np.array(s.bandwidths, dtype=np.int32) + ).T + + full = np.zeros((local.shape[0], D), dtype=np.int32) + + for i, dim in enumerate(s.u): + full[:, dim] = local[:, i] + + freq_list.append(full) + + freq = np.vstack(freq_list) + + X_torch = torch.tensor(X, dtype=torch.float64, device="cuda") + I_torch = torch.tensor( + freq, + dtype=torch.float64, + device="cuda" + ) + + def trafo(fhat): + X_i = LazyTensor(X_torch[:, None, :].contiguous()) + K_j = LazyTensor(I_torch[None, :, :].contiguous()) + phase_fwd = (X_i * K_j).sum(-1) + two_pi_phase = -2 * torch.pi * phase_fwd + kernel_fwd = two_pi_phase.cos() + 1j * two_pi_phase.sin() + fhat_torch = torch.tensor(fhat, dtype=torch.complex128, device="cuda") + fhat_j = LazyTensor(fhat_torch[None, :, None].contiguous()) + + try: + result = (kernel_fwd * fhat_j).sum(dim=1) + torch.cuda.synchronize() + result = result.squeeze().cpu().numpy() + return result + except Exception as e: + print("Error in KeOps trafo:", e) + return None + + def adjoint(f): + f_torch = torch.tensor(f, dtype=torch.complex128, device="cuda").contiguous() + + X_i = LazyTensor(X_torch[None, :, :].contiguous()) + K_j = LazyTensor(I_torch[:, None, :].contiguous()) - self.transforms[idx] = s.mode.get_transform_keops( - bandwidths=s.bandwidths, - X=np.copy(X[:,u], order="C") - ) + phase = (K_j * X_i).sum(-1) + kernel = (-2*torch.pi*phase).cos() - 1j*(-2*torch.pi*phase).sin() + + f_i = LazyTensor(f_torch[None, :, None].contiguous()) + + try: + result = (kernel * f_i).sum(dim=1) + torch.cuda.synchronize() + result = result.squeeze().cpu().numpy() + + return result + except Exception as e: + print("Error in KeOps adjoint:", e) + return None + + self.transforms = [DeferredLinearOperator( + dtype=np.complex128, shape=(X.shape[0], len(freq)), mfunc=trafo, rmfunc=adjoint + )] + else: self.transforms = [] s1 = self.settings[0] @@ -363,14 +432,10 @@ def adjoint_worker(i): adjoint_worker(i) return fhat + elif self.algorithm == "keops": - fhat = GroupedCoefficients(self.settings) - - for i in range(len(self.transforms)): - adjoint_result = self.transforms[i].H @ other - fhat[self.settings[i].u] = adjoint_result - - return fhat + return GroupedCoefficients(self.settings, self.transforms[0].H @ other) + elif self.algorithm == "direct": return GroupedCoefficients( self.settings, (self.matrix.conj()).T @ other @@ -403,15 +468,10 @@ def worker(i): worker(i) return sum(results) + elif self.algorithm == "keops": - results = [] - - for i in range(len(self.transforms)): - u = self.settings[i].u - result = self.transforms[i] @ other[u] - results.append(result) - - return sum(results) + return self.transforms[0] @ other.data + elif self.algorithm == "direct": return self.matrix @ other.data else: diff --git a/src/pyGroupedTransforms/NFFTtools.py b/src/pyGroupedTransforms/NFFTtools.py index 10872ae..d0b02c6 100644 --- a/src/pyGroupedTransforms/NFFTtools.py +++ b/src/pyGroupedTransforms/NFFTtools.py @@ -172,81 +172,6 @@ def adjoint(f): # function adjoint(f::Vector{ComplexF64})::Vector{ComplexF64} return DeferredLinearOperator( dtype=np.complex128, shape=(M, N), mfunc=trafo, rmfunc=adjoint ) - -def get_transform_keops( - bandwidths: np.array, X: np.array -): - if bandwidths.ndim > 1 or bandwidths.dtype != "int32": - return "Please use an zero or one-dimensional numpy.array with dtype 'int32' as input" - - M, d = np.shape(X) - - if len(bandwidths) == 0: - return DeferredLinearOperator( - dtype=np.complex128, - shape=(M, 1), - mfunc=lambda fhat: np.full(M, fhat[0]), - rmfunc=lambda f: np.array([np.sum(f)]), - ) - - X_torch = torch.tensor(X, dtype=torch.float64, device="cuda") - freq = index_set_without_zeros( - np.array(bandwidths, dtype=np.int32) - ).T - - I_torch = torch.tensor( - freq, - dtype=torch.float64, - device="cuda" - ) - - - def trafo(fhat): - X_i = LazyTensor(X_torch[:, None, :].contiguous()) - K_j = LazyTensor(I_torch[None, :, :].contiguous()) - phase_fwd = (X_i * K_j).sum(-1) - two_pi_phase = -2 * torch.pi * phase_fwd - kernel_fwd = two_pi_phase.cos() + 1j * two_pi_phase.sin() - fhat_torch = torch.tensor(fhat, dtype=torch.complex128, device="cuda") - fhat_j = LazyTensor(fhat_torch[None, :, None].contiguous()) - - try: - result = (kernel_fwd * fhat_j).sum(dim=1) - torch.cuda.synchronize() - result = result.squeeze().cpu().numpy() - return result - except Exception as e: - print("Error in KeOps trafo:", e) - return None - - def adjoint(f): - f_torch = torch.tensor(f, dtype=torch.complex128, device="cuda").contiguous() - - X_i = LazyTensor(X_torch[None, :, :].contiguous()) - K_j = LazyTensor(I_torch[:, None, :].contiguous()) - - phase = (K_j * X_i).sum(-1) - kernel = (-2*torch.pi*phase).cos() - 1j*(-2*torch.pi*phase).sin() - - f_i = LazyTensor(f_torch[None, :, None].contiguous()) - - try: - result = (kernel * f_i).sum(dim=1) - torch.cuda.synchronize() - result = result.squeeze().cpu().numpy() - - return result - except Exception as e: - print("Error in KeOps adjoint:", e) - return None - - - Ncoeffs = np.prod(bandwidths - 1) - - return DeferredLinearOperator( - dtype=np.complex128, shape=(M, Ncoeffs), mfunc=trafo, rmfunc=adjoint - ) - def get_matrix( bandwidths, X From c73da22c90df0ac716087f59b9684d06b83b0250 Mon Sep 17 00:00:00 2001 From: Lucas Teixeira Date: Tue, 14 Jul 2026 16:37:54 +0200 Subject: [PATCH 2/4] feat: NFCT equivalent using KeOps --- src/pyGroupedTransforms/GroupedTransform.py | 140 ++++++++++++++------ 1 file changed, 103 insertions(+), 37 deletions(-) diff --git a/src/pyGroupedTransforms/GroupedTransform.py b/src/pyGroupedTransforms/GroupedTransform.py index 57bf99a..b1d883b 100644 --- a/src/pyGroupedTransforms/GroupedTransform.py +++ b/src/pyGroupedTransforms/GroupedTransform.py @@ -288,8 +288,20 @@ def __init__( if len(s.bandwidths) == 0: full = np.zeros((1, D), dtype=np.int32) + elif self.system == "cos": - else: + local = np.atleast_2d( + s.mode.index_set_without_zeros( + np.array(s.bandwidths, dtype=np.int32) + ) + ).T + + full = np.zeros((local.shape[0], D), dtype=np.int32) + + for i, dim in enumerate(s.u): + full[:, dim] = local[:, i] + + else: local = index_set_without_zeros( np.array(s.bandwidths, dtype=np.int32) ).T @@ -309,48 +321,102 @@ def __init__( dtype=torch.float64, device="cuda" ) - - def trafo(fhat): - X_i = LazyTensor(X_torch[:, None, :].contiguous()) - K_j = LazyTensor(I_torch[None, :, :].contiguous()) - phase_fwd = (X_i * K_j).sum(-1) - two_pi_phase = -2 * torch.pi * phase_fwd - kernel_fwd = two_pi_phase.cos() + 1j * two_pi_phase.sin() - fhat_torch = torch.tensor(fhat, dtype=torch.complex128, device="cuda") - fhat_j = LazyTensor(fhat_torch[None, :, None].contiguous()) - - try: - result = (kernel_fwd * fhat_j).sum(dim=1) - torch.cuda.synchronize() - result = result.squeeze().cpu().numpy() - return result - except Exception as e: - print("Error in KeOps trafo:", e) - return None - + + def trafo(fhat): + if self.system == "cos" or self.system == "cheb": + mult = np.sqrt(2.0) ** np.count_nonzero(freq, axis=1) + mult_torch = torch.tensor(mult, dtype=torch.float64, device="cuda") + + kernel = 1.0 + for i in range(D): + Xi = LazyTensor(X_torch[:, None, i:i+1].contiguous()) + Ki = LazyTensor(I_torch[None, :, i:i+1].contiguous()) + kernel = kernel * (2 * torch.pi * Xi * Ki).cos() + + fhat_torch = ( + torch.as_tensor(fhat, dtype=torch.float64, device="cuda") + * mult_torch + ) + fhat_j = LazyTensor(fhat_torch[None, :, None].contiguous()) + + try: + result = (kernel * fhat_j).sum(dim=1) + torch.cuda.synchronize() + return result.squeeze().cpu().numpy() + except Exception as e: + print("Error in KeOps trafo:", e) + return None + else: + X_i = LazyTensor(X_torch[:, None, :].contiguous()) + K_j = LazyTensor(I_torch[None, :, :].contiguous()) + + phase_fwd = (X_i * K_j).sum(-1) + two_pi_phase = -2 * torch.pi * phase_fwd + kernel = two_pi_phase.cos() + 1j * two_pi_phase.sin() + + fhat_torch = torch.tensor(fhat, dtype=torch.complex128, device="cuda") + fhat_j = LazyTensor(fhat_torch[None, :, None].contiguous()) + + try: + result = (kernel * fhat_j).sum(dim=1) + torch.cuda.synchronize() + result = result.squeeze().cpu().numpy() + return result + except Exception as e: + print("Error in KeOps trafo:", e) + return None + def adjoint(f): - f_torch = torch.tensor(f, dtype=torch.complex128, device="cuda").contiguous() - - X_i = LazyTensor(X_torch[None, :, :].contiguous()) - K_j = LazyTensor(I_torch[:, None, :].contiguous()) + if self.system == "cos" or self.system == "cheb": + mult = np.sqrt(2.0) ** np.count_nonzero(freq, axis=1) + mult_torch = torch.tensor(mult, dtype=torch.float64, device="cuda") + + f_torch = ( + torch.as_tensor(f, dtype=torch.float64, device="cuda") + * mult_torch + ).contiguous() + + kernel = 1.0 + for i in range(D): + Ki = LazyTensor(I_torch[:, None, i:i+1].contiguous()) + Xi = LazyTensor(X_torch[None, :, i:i+1].contiguous()) + kernel = kernel * (2 * torch.pi * Xi * Ki).cos() + + f_i = LazyTensor(f_torch[None, :, None].contiguous()) + + try: + result = (kernel * f_i).sum(dim=1) + torch.cuda.synchronize() + result = result.squeeze().cpu().numpy() + return result + except Exception as e: + print("Error in KeOps adjoint:", e) + return None + else: + f_torch = torch.tensor(f, dtype=torch.complex128, device="cuda").contiguous() - phase = (K_j * X_i).sum(-1) - kernel = (-2*torch.pi*phase).cos() - 1j*(-2*torch.pi*phase).sin() + X_i = LazyTensor(X_torch[None, :, :].contiguous()) + K_j = LazyTensor(I_torch[:, None, :].contiguous()) - f_i = LazyTensor(f_torch[None, :, None].contiguous()) + phase = (K_j * X_i).sum(-1) + two_pi_phase = 2 * torch.pi * phase + kernel = two_pi_phase.cos() + 1j * two_pi_phase.sin() - try: - result = (kernel * f_i).sum(dim=1) - torch.cuda.synchronize() - result = result.squeeze().cpu().numpy() - - return result - except Exception as e: - print("Error in KeOps adjoint:", e) - return None + f_i = LazyTensor(f_torch[None, :, None].contiguous()) + + try: + result = (kernel * f_i).sum(dim=1) + torch.cuda.synchronize() + result = result.squeeze().cpu().numpy() + + return result + except Exception as e: + print("Error in KeOps adjoint:", e) + return None + keops_dtype = np.float64 if self.system == "cos" else np.complex128 self.transforms = [DeferredLinearOperator( - dtype=np.complex128, shape=(X.shape[0], len(freq)), mfunc=trafo, rmfunc=adjoint + dtype=keops_dtype, shape=(X.shape[0], len(freq)), mfunc=trafo, rmfunc=adjoint )] else: From ee04cee21b5befbdfb6965154c60b17037596183 Mon Sep 17 00:00:00 2001 From: Lucas Teixeira Date: Thu, 16 Jul 2026 12:55:19 +0200 Subject: [PATCH 3/4] feat: dynamic device selection and indexing --- src/pyGroupedTransforms/GroupedTransform.py | 54 +++++++++------------ 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/src/pyGroupedTransforms/GroupedTransform.py b/src/pyGroupedTransforms/GroupedTransform.py index b1d883b..2587a89 100644 --- a/src/pyGroupedTransforms/GroupedTransform.py +++ b/src/pyGroupedTransforms/GroupedTransform.py @@ -274,6 +274,13 @@ def __init__( elif algorithm == "keops": self.matrix = np.empty((0,0), dtype=object) + if torch.cuda.is_available(): + device = "cuda" + elif torch.mps.is_available(): + device = "mps" + else: + device = "cpu" + self.transforms = [ DeferredLinearOperator() for _ in range(len(self.settings)) @@ -288,44 +295,33 @@ def __init__( if len(s.bandwidths) == 0: full = np.zeros((1, D), dtype=np.int32) - elif self.system == "cos": - - local = np.atleast_2d( - s.mode.index_set_without_zeros( - np.array(s.bandwidths, dtype=np.int32) - ) - ).T - - full = np.zeros((local.shape[0], D), dtype=np.int32) - - for i, dim in enumerate(s.u): - full[:, dim] = local[:, i] - - else: - local = index_set_without_zeros( + + local = np.atleast_2d( + s.mode.index_set_without_zeros( np.array(s.bandwidths, dtype=np.int32) - ).T + ) + ).T - full = np.zeros((local.shape[0], D), dtype=np.int32) + full = np.zeros((local.shape[0], D), dtype=np.int32) - for i, dim in enumerate(s.u): - full[:, dim] = local[:, i] + for i, dim in enumerate(s.u): + full[:, dim] = local[:, i] freq_list.append(full) freq = np.vstack(freq_list) - X_torch = torch.tensor(X, dtype=torch.float64, device="cuda") + X_torch = torch.tensor(X, dtype=torch.float64, device=device) I_torch = torch.tensor( freq, dtype=torch.float64, - device="cuda" + device=device ) def trafo(fhat): if self.system == "cos" or self.system == "cheb": mult = np.sqrt(2.0) ** np.count_nonzero(freq, axis=1) - mult_torch = torch.tensor(mult, dtype=torch.float64, device="cuda") + mult_torch = torch.tensor(mult, dtype=torch.float64, device=device) kernel = 1.0 for i in range(D): @@ -334,7 +330,7 @@ def trafo(fhat): kernel = kernel * (2 * torch.pi * Xi * Ki).cos() fhat_torch = ( - torch.as_tensor(fhat, dtype=torch.float64, device="cuda") + torch.as_tensor(fhat, dtype=torch.float64, device=device) * mult_torch ) fhat_j = LazyTensor(fhat_torch[None, :, None].contiguous()) @@ -354,7 +350,7 @@ def trafo(fhat): two_pi_phase = -2 * torch.pi * phase_fwd kernel = two_pi_phase.cos() + 1j * two_pi_phase.sin() - fhat_torch = torch.tensor(fhat, dtype=torch.complex128, device="cuda") + fhat_torch = torch.tensor(fhat, dtype=torch.complex128, device=device) fhat_j = LazyTensor(fhat_torch[None, :, None].contiguous()) try: @@ -369,11 +365,9 @@ def trafo(fhat): def adjoint(f): if self.system == "cos" or self.system == "cheb": mult = np.sqrt(2.0) ** np.count_nonzero(freq, axis=1) - mult_torch = torch.tensor(mult, dtype=torch.float64, device="cuda") - f_torch = ( - torch.as_tensor(f, dtype=torch.float64, device="cuda") - * mult_torch + f_torch = torch.as_tensor( + f, dtype=torch.float64, device=device ).contiguous() kernel = 1.0 @@ -388,12 +382,12 @@ def adjoint(f): result = (kernel * f_i).sum(dim=1) torch.cuda.synchronize() result = result.squeeze().cpu().numpy() - return result + return result * mult except Exception as e: print("Error in KeOps adjoint:", e) return None else: - f_torch = torch.tensor(f, dtype=torch.complex128, device="cuda").contiguous() + f_torch = torch.tensor(f, dtype=torch.complex128, device=device).contiguous() X_i = LazyTensor(X_torch[None, :, :].contiguous()) K_j = LazyTensor(I_torch[:, None, :].contiguous()) From 88ec956339669537820ceab522ae86899fed6fd8 Mon Sep 17 00:00:00 2001 From: texlucas Date: Thu, 16 Jul 2026 10:55:42 +0000 Subject: [PATCH 4/4] Auto code format --- src/pyGroupedTransforms/GroupedTransform.py | 72 +++++++++++---------- src/pyGroupedTransforms/NFFTtools.py | 8 +-- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/pyGroupedTransforms/GroupedTransform.py b/src/pyGroupedTransforms/GroupedTransform.py index 2587a89..8453da4 100644 --- a/src/pyGroupedTransforms/GroupedTransform.py +++ b/src/pyGroupedTransforms/GroupedTransform.py @@ -1,12 +1,11 @@ import numpy as np +import pykeops import torch +from pykeops.torch import LazyTensor from pyGroupedTransforms import * -from .NFFTtools import index_set_without_zeros - -import pykeops -from pykeops.torch import LazyTensor +from .NFFTtools import index_set_without_zeros # All code that is linked to NFMTtools or to system = "mixed" is not tested yet.... @@ -272,20 +271,19 @@ def __init__( bandwidths=s.bandwidths, X=np.copy(X[:, u], order="C") ) elif algorithm == "keops": - self.matrix = np.empty((0,0), dtype=object) - + self.matrix = np.empty((0, 0), dtype=object) + if torch.cuda.is_available(): device = "cuda" elif torch.mps.is_available(): device = "mps" else: device = "cpu" - + self.transforms = [ - DeferredLinearOperator() - for _ in range(len(self.settings)) + DeferredLinearOperator() for _ in range(len(self.settings)) ] - + D = X.shape[1] freq_list = [] @@ -294,8 +292,7 @@ def __init__( if len(s.bandwidths) == 0: full = np.zeros((1, D), dtype=np.int32) - - + local = np.atleast_2d( s.mode.index_set_without_zeros( np.array(s.bandwidths, dtype=np.int32) @@ -310,13 +307,9 @@ def __init__( freq_list.append(full) freq = np.vstack(freq_list) - + X_torch = torch.tensor(X, dtype=torch.float64, device=device) - I_torch = torch.tensor( - freq, - dtype=torch.float64, - device=device - ) + I_torch = torch.tensor(freq, dtype=torch.float64, device=device) def trafo(fhat): if self.system == "cos" or self.system == "cheb": @@ -325,8 +318,8 @@ def trafo(fhat): kernel = 1.0 for i in range(D): - Xi = LazyTensor(X_torch[:, None, i:i+1].contiguous()) - Ki = LazyTensor(I_torch[None, :, i:i+1].contiguous()) + Xi = LazyTensor(X_torch[:, None, i : i + 1].contiguous()) + Ki = LazyTensor(I_torch[None, :, i : i + 1].contiguous()) kernel = kernel * (2 * torch.pi * Xi * Ki).cos() fhat_torch = ( @@ -350,7 +343,9 @@ def trafo(fhat): two_pi_phase = -2 * torch.pi * phase_fwd kernel = two_pi_phase.cos() + 1j * two_pi_phase.sin() - fhat_torch = torch.tensor(fhat, dtype=torch.complex128, device=device) + fhat_torch = torch.tensor( + fhat, dtype=torch.complex128, device=device + ) fhat_j = LazyTensor(fhat_torch[None, :, None].contiguous()) try: @@ -365,15 +360,15 @@ def trafo(fhat): def adjoint(f): if self.system == "cos" or self.system == "cheb": mult = np.sqrt(2.0) ** np.count_nonzero(freq, axis=1) - + f_torch = torch.as_tensor( f, dtype=torch.float64, device=device ).contiguous() kernel = 1.0 for i in range(D): - Ki = LazyTensor(I_torch[:, None, i:i+1].contiguous()) - Xi = LazyTensor(X_torch[None, :, i:i+1].contiguous()) + Ki = LazyTensor(I_torch[:, None, i : i + 1].contiguous()) + Xi = LazyTensor(X_torch[None, :, i : i + 1].contiguous()) kernel = kernel * (2 * torch.pi * Xi * Ki).cos() f_i = LazyTensor(f_torch[None, :, None].contiguous()) @@ -387,7 +382,9 @@ def adjoint(f): print("Error in KeOps adjoint:", e) return None else: - f_torch = torch.tensor(f, dtype=torch.complex128, device=device).contiguous() + f_torch = torch.tensor( + f, dtype=torch.complex128, device=device + ).contiguous() X_i = LazyTensor(X_torch[None, :, :].contiguous()) K_j = LazyTensor(I_torch[:, None, :].contiguous()) @@ -409,10 +406,15 @@ def adjoint(f): return None keops_dtype = np.float64 if self.system == "cos" else np.complex128 - self.transforms = [DeferredLinearOperator( - dtype=keops_dtype, shape=(X.shape[0], len(freq)), mfunc=trafo, rmfunc=adjoint - )] - + self.transforms = [ + DeferredLinearOperator( + dtype=keops_dtype, + shape=(X.shape[0], len(freq)), + mfunc=trafo, + rmfunc=adjoint, + ) + ] + else: self.transforms = [] s1 = self.settings[0] @@ -492,15 +494,15 @@ def adjoint_worker(i): adjoint_worker(i) return fhat - + elif self.algorithm == "keops": - return GroupedCoefficients(self.settings, self.transforms[0].H @ other) - + return GroupedCoefficients(self.settings, self.transforms[0].H @ other) + elif self.algorithm == "direct": return GroupedCoefficients( self.settings, (self.matrix.conj()).T @ other ) - + elif isinstance(other, GC): # `f = F*fhat` (fhat = other) if self.settings != other.settings: raise ValueError( @@ -528,10 +530,10 @@ def worker(i): worker(i) return sum(results) - + elif self.algorithm == "keops": return self.transforms[0] @ other.data - + elif self.algorithm == "direct": return self.matrix @ other.data else: diff --git a/src/pyGroupedTransforms/NFFTtools.py b/src/pyGroupedTransforms/NFFTtools.py index d0b02c6..432ac47 100644 --- a/src/pyGroupedTransforms/NFFTtools.py +++ b/src/pyGroupedTransforms/NFFTtools.py @@ -1,11 +1,10 @@ import numpy as np - -from pyGroupedTransforms import * - -import torch import pykeops +import torch from pykeops.torch import LazyTensor +from pyGroupedTransforms import * + def datalength( bandwidths: np.ndarray, @@ -173,6 +172,7 @@ def adjoint(f): # function adjoint(f::Vector{ComplexF64})::Vector{ComplexF64} dtype=np.complex128, shape=(M, N), mfunc=trafo, rmfunc=adjoint ) + def get_matrix( bandwidths, X ): # get_matrix(bandwidths::Vector{Int}, X::Array{Float64})::Array{ComplexF64}