Skip to content

Commit d5ff57d

Browse files
authored
Fix coefficients for ProductFun (#535)
* Fix coefficients for ProductFun * Avoid inplace pad
1 parent 7b2081d commit d5ff57d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunBase"
22
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
3-
version = "0.9.3"
3+
version = "0.9.4"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/Multivariate/ProductFun.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,22 @@ end
244244

245245
coefficients(f::ProductFun)=funlist2coefficients(f.coefficients)
246246

247-
function coefficients(f::ProductFun,ox::Space,oy::Space)
247+
function coefficients(f::ProductFun, ox::Space, oy::Space)
248248
T=cfstype(f)
249249
m=size(f,1)
250-
B=Matrix{T}(m,length(f.coefficients))
250+
B = zeros(T, m, length(f.coefficients))
251251
# convert in x direction
252252
#TODO: adaptively grow in x?
253253
for k=1:length(f.coefficients)
254-
B[:,k]=pad!(coefficients(f.coefficients[k],ox),m)
254+
B[:,k] = pad(coefficients(f.coefficients[k],ox), m)
255255
end
256256

257+
sp = space(f)
258+
spf2 = factor(sp, 2)
259+
257260
# convert in y direction
258261
for k=1:size(B,1)
259-
ccfs=coefficients(vec(B[k,:]),space(f,2),oy)
262+
ccfs=coefficients(view(B,k,:), spf2, oy)
260263
if length(ccfs)>size(B,2)
261264
B=pad(B,size(B,1),length(ccfs))
262265
end
@@ -273,7 +276,7 @@ end
273276
# ProductFun does only support BivariateFunctions, this function below just does not work
274277
# (f::ProductFun)(x,y,z) = evaluate(f,x,y,z)
275278

276-
coefficients(f::ProductFun,ox::TensorSpace) = coefficients(f,ox[1],ox[2])
279+
coefficients(f::ProductFun, ox::TensorSpace) = coefficients(f, factors(ox)...)
277280

278281

279282

0 commit comments

Comments
 (0)