Skip to content

Commit 9f7ddd8

Browse files
committed
Standardize usage to be
P=plan_paduatransform(v) P*v == paduatransform(v)
1 parent abadf3e commit 9f7ddd8

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/PaduaTransform.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ end
1818
"""
1919
Inverse Padua Transform maps the 2D Chebyshev coefficients to the values of the interpolation polynomial at the Padua points.
2020
"""
21-
function ipaduatransform{T}(P::IPaduaTransformPlan,v::AbstractVector{T})
21+
function *{T}(P::IPaduaTransformPlan,v::AbstractVector{T})
2222
cfsmat=trianglecfsmat(P,v)
2323
n,m=size(cfsmat)
2424
scale!(view(cfsmat,:,2:m-1),0.5)
@@ -28,6 +28,8 @@ function ipaduatransform{T}(P::IPaduaTransformPlan,v::AbstractVector{T})
2828
return paduavals
2929
end
3030

31+
ipaduatransform(v::AbstractVector) = plan_ipaduatransform(v)*v
32+
3133
"""
3234
Creates (n+2)x(n+1) Chebyshev coefficient matrix from triangle coefficients.
3335
"""
@@ -89,7 +91,7 @@ end
8991
"""
9092
Padua Transform maps from interpolant values at the Padua points to the 2D Chebyshev coefficients.
9193
"""
92-
function paduatransform{T}(P::PaduaTransformPlan,v::AbstractVector{T})
94+
function *{T}(P::PaduaTransformPlan,v::AbstractVector{T})
9395
N=length(v)
9496
n=Int(cld(-3+sqrt(1+8N),2))
9597
vals=paduavalsmat(P,v)
@@ -104,6 +106,8 @@ function paduatransform{T}(P::PaduaTransformPlan,v::AbstractVector{T})
104106
return cfs
105107
end
106108

109+
paduatransform(v::AbstractVector) = plan_paduatransform(v)*v
110+
107111
"""
108112
Creates (n+2)x(n+1) matrix of interpolant values on the tensor grid at the (n+1)(n+2)/2 Padua points.
109113
"""

test/runtests.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,14 @@ N=div((n+1)*(n+2),2)
213213
v=rand(N) #Length of v is the no. of Padua points
214214
Pl=plan_paduatransform(v)
215215
IPl=plan_ipaduatransform(v)
216-
@test_approx_eq paduatransform(Pl,ipaduatransform(IPl,v)) v
217-
@test_approx_eq ipaduatransform(IPl,paduatransform(Pl,v)) v
216+
@test_approx_eq Pl*(IPl*v) v
217+
@test_approx_eq IPl*(Pl*v) v
218+
@test_approx_eq Pl*v paduatransform(v)
219+
@test_approx_eq IPl*v ipaduatransform(v)
218220

219221
println("Testing runtimes for (I)Padua Transforms")
220-
@time paduatransform(Pl,v)
221-
@time ipaduatransform(IPl,v)
222+
@time Pl*v
223+
@time IPl*v
222224

223225
println("Accuracy of 2d function interpolation at a point")
224226
function trianglecfsmat{T}(cfs::AbstractVector{T})
@@ -250,8 +252,7 @@ function paduaeval(f::Function,x::AbstractFloat,y::AbstractFloat,m::Integer)
250252
pvals=Array(T,M)
251253
p=paduapoints(T,m)
252254
map!(f,pvals,p[:,1],p[:,2])
253-
plan=plan_paduatransform(pvals)
254-
coeffs=paduatransform(plan,pvals)
255+
coeffs=paduatransform(pvals)
255256
cfs_mat=trianglecfsmat(coeffs)
256257
f_x=sum([cfs_mat[k,j]*cos((j-1)*acos(x))*cos((k-1)*acos(y)) for k=1:m+1, j=1:m+1])
257258
return f_x

0 commit comments

Comments
 (0)