Skip to content

Commit cec6a02

Browse files
committed
feat: add keops algorithm
1 parent 75e9f47 commit cec6a02

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/pyANOVAapprox/approx.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def __init__(
8484
basis="cos",
8585
classification=False,
8686
basis_vect=[],
87-
fastmult=None,
87+
algorithm="direct",
8888
parallel=True,
8989
ds=None,
9090
lam={0.0},
@@ -95,12 +95,12 @@ def __init__(
9595

9696
if (
9797
U == None or len(U) == 0
98-
): # setting U #approx(X::Matrix{Float64}, y::Union{Vector{ComplexF64},Vector{Float64}}, ds::Int, N::Vector{Int}, basis::String = "cos"; classification::Bool = false, basis_vect::Vector{String} = Vector{String}([]), fastmult::Bool = classification ? true : false,)
98+
): # setting U #approx(X::Matrix{Float64}, y::Union{Vector{ComplexF64},Vector{Float64}}, ds::Int, N::Vector{Int}, basis::String = "cos"; classification::Bool = false, basis_vect::Vector{String} = Vector{String}([]), algorithm::String = classification ? true : false,)
9999
U = get_superposition_set(parent.X.shape[1], ds)
100100

101101
if N is not None and not isinstance(
102102
N[0], tuple
103-
): # setting N #approx( X::Matrix{Float64}, y::Union{Vector{ComplexF64},Vector{Float64}}, U::Vector{Vector{Int}}, N::Vector{Int}, basis::String = "cos"; classification::Bool = false, basis_vect::Vector{String} = Vector{String}([]), fastmult::Bool = classification ? true : false,)
103+
): # setting N #approx( X::Matrix{Float64}, y::Union{Vector{ComplexF64},Vector{Float64}}, U::Vector{Vector{Int}}, N::Vector{Int}, basis::String = "cos"; classification::Bool = false, basis_vect::Vector{String} = Vector{String}([]), algorithm::String = classification ? true : false,)
104104
ds = max(len(u) for u in U)
105105

106106
if len(N) != len(U) and len(N) != ds:
@@ -126,8 +126,10 @@ def __init__(
126126

127127
if basis_vect is None:
128128
basis_vect = []
129-
if fastmult is None:
130-
fastmult = False if classification else True
129+
if algorithm == "direct":
130+
algorithm = "direct" if classification else "nfft"
131+
if algorithm != "nfft":
132+
parallel = False
131133
if basis not in bases:
132134
raise ValueError("Basis not found.")
133135
# if y[0].dtype != vtypes[basis]:
@@ -146,7 +148,7 @@ def __init__(
146148
self.N = N
147149
self.classification = classification
148150
self.basis_vect = basis_vect
149-
self.fastmult = fastmult
151+
self.algorithm = algorithm
150152
self.parallel = parallel
151153
self.lam = lam
152154
self.parent = parent
@@ -181,7 +183,7 @@ def __init__(
181183
basis="cos",
182184
classification=False,
183185
basis_vect=[],
184-
fastmult=None,
186+
algorithm="direct",
185187
parallel=True,
186188
ds=None,
187189
lam={0.0},
@@ -204,7 +206,7 @@ def __init__(
204206
basis=basis,
205207
classification=classification,
206208
basis_vect=basis_vect,
207-
fastmult=fastmult,
209+
algorithm=algorithm,
208210
parallel=parallel,
209211
ds=ds,
210212
lam=lam,
@@ -270,7 +272,7 @@ def addTrafo(self, settingnr=None):
270272
U=setting.U,
271273
N=setting.N,
272274
X=transformX(self.X, setting.basis),
273-
fastmult=setting.fastmult,
275+
algorithm=setting.algorithm,
274276
parallel=setting.parallel,
275277
basis_vect=setting.basis_vect,
276278
)

0 commit comments

Comments
 (0)