Skip to content

Commit

Permalink
Split y coordinate computation in paduapoints (#226)
Browse files Browse the repository at this point in the history
* split y coordinate computation in paduapoints

* Add inbounds and tests

* Bump version to v0.15.7
  • Loading branch information
jishnub authored Aug 4, 2023
1 parent 490ce9a commit fde025f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FastTransforms"
uuid = "057dd010-8810-581a-b7be-e3fc3b93f78c"
version = "0.15.6"
version = "0.15.7"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
41 changes: 33 additions & 8 deletions src/PaduaTransform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,46 @@ function paduapoints(::Type{T}, n::Integer) where T
MM=Matrix{T}(undef,N,2)
m=0
delta=0
NN=fld(n+2,2)
@inbounds for k=n:-1:0
if isodd(n)>0
delta=mod(k,2)
NN=div(n,2)+1
# x coordinates
for k=n:-1:0
if isodd(n)
delta = Int(isodd(k))
end
x = -cospi(T(k)/n)
@inbounds for j=NN+delta:-1:1
m+=1
MM[m,1]=sinpi(T(k)/n-T(0.5))
if isodd(n-k)>0
MM[m,2]=sinpi((2j-one(T))/(n+1)-T(0.5))
MM[m,1]=x
end
end
# y coordinates
# populate the first two sets, and copy the rest
m=0
for k=n:-1:n-1
if isodd(n)
delta = Int(isodd(k))
end
for j=NN+delta:-1:1
m+=1
@inbounds if isodd(n-k)
MM[m,2]=-cospi((2j-one(T))/(n+1))
else
MM[m,2]=sinpi(T(2j-2)/(n+1)-T(0.5))
MM[m,2]=-cospi(T(2j-2)/(n+1))
end
end
end
m += 1
# number of y coordinates between k=n and k=n-2
Ny_shift = 2NN+isodd(n)
for k in n-2:-1:0
if isodd(n)
delta = Int(isodd(k))
end
for j in range(m, length=NN+delta)
@inbounds MM[j,2] = MM[j-Ny_shift,2]
end
m += NN+delta
end
return MM
end

Expand Down
13 changes: 13 additions & 0 deletions test/paduatests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,17 @@ using FastTransforms, Test
g_l=paduaeval(g_xy,x,y,l,Val{false})
@test f_xy(x,y) f_m
@test g_xy(x,y) g_l

# odd n
m=135
l=85
f_m=paduaeval(f_xy,x,y,m,Val{true})
g_l=paduaeval(g_xy,x,y,l,Val{true})
@test f_xy(x,y) f_m
@test g_xy(x,y) g_l

f_m=paduaeval(f_xy,x,y,m,Val{false})
g_l=paduaeval(g_xy,x,y,l,Val{false})
@test f_xy(x,y) f_m
@test g_xy(x,y) g_l
end

2 comments on commit fde025f

@dlfivefifty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/89013

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.15.7 -m "<description of version>" fde025f2fe3643e8673a098fed02bc0d804dc7ed
git push origin v0.15.7

Please sign in to comment.