1
- doc"""
1
+
2
+ # lex indicates if its lexigraphical (i.e., x, y) or reverse (y, x)
3
+ """
2
4
Pre-plan an Inverse Padua Transform.
3
5
"""
4
- # lex indicates if its lexigraphical (i.e., x, y) or reverse (y, x)
5
6
struct IPaduaTransformPlan{lex,IDCTPLAN,T}
6
7
cfsmat:: Matrix{T}
7
8
idctplan:: IDCTPLAN
10
11
IPaduaTransformPlan (cfsmat:: Matrix{T} ,idctplan,:: Type{Val{lex}} ) where {T,lex} =
11
12
IPaduaTransformPlan {lex,typeof(idctplan),T} (cfsmat,idctplan)
12
13
13
- doc """
14
+ """
14
15
Pre-plan an Inverse Padua Transform.
15
16
"""
16
17
function plan_ipaduatransform! (:: Type{T} ,N:: Integer ,lex) where T
17
18
n= Int (cld (- 3 + sqrt (1 + 8 N),2 ))
18
19
if N ≠ div ((n+ 1 )* (n+ 2 ),2 )
19
20
error (" Padua transforms can only be applied to vectors of length (n+1)*(n+2)/2." )
20
21
end
21
- IPaduaTransformPlan (Array {T} (n+ 2 ,n+ 1 ),FFTW. plan_r2r! (Array {T} (n+ 2 ,n+ 1 ),FFTW. REDFT00),lex)
22
+ IPaduaTransformPlan (Array {T} (undef, n+ 2 ,n+ 1 ),FFTW. plan_r2r! (Array {T} (undef, n+ 2 ,n+ 1 ),FFTW. REDFT00),lex)
22
23
end
23
24
24
25
25
26
plan_ipaduatransform! (:: Type{T} ,N:: Integer ) where {T} = plan_ipaduatransform! (T,N,Val{true })
26
27
plan_ipaduatransform! (v:: AbstractVector{T} ,lex... ) where {T} = plan_ipaduatransform! (eltype (v),length (v),lex... )
27
28
29
+
28
30
function * (P:: IPaduaTransformPlan ,v:: AbstractVector{T} ) where T
29
31
cfsmat= trianglecfsmat (P,v)
30
32
n,m= size (cfsmat)
31
- scale ! (view (cfsmat,:,2 : m- 1 ),0.5 )
32
- scale ! (view (cfsmat,2 : n- 1 ,:),0.5 )
33
+ rmul ! (view (cfsmat,:,2 : m- 1 ),0.5 )
34
+ rmul ! (view (cfsmat,2 : n- 1 ,:),0.5 )
33
35
tensorvals= P. idctplan* cfsmat
34
36
paduavec! (v,P,tensorvals)
35
37
end
36
38
37
39
ipaduatransform! (v:: AbstractVector ,lex... ) = plan_ipaduatransform! (v,lex... )* v
38
- doc """
40
+ """
39
41
Inverse Padua Transform maps the 2D Chebyshev coefficients to the values of the interpolation polynomial at the Padua points.
40
42
"""
41
43
ipaduatransform (v:: AbstractVector ,lex... ) = plan_ipaduatransform! (v,lex... )* copy (v)
42
44
43
- doc """
45
+ """
44
46
Creates ``(n+2)x(n+1)`` Chebyshev coefficient matrix from triangle coefficients.
45
47
"""
46
48
function trianglecfsmat (P:: IPaduaTransformPlan{true} ,cfs:: AbstractVector )
@@ -81,7 +83,7 @@ function trianglecfsmat(P::IPaduaTransformPlan{false},cfs::AbstractVector)
81
83
return cfsmat
82
84
end
83
85
84
- doc """
86
+ """
85
87
Vectorizes the function values at the Padua points.
86
88
"""
87
89
function paduavec! (v,P:: IPaduaTransformPlan ,padmat:: Matrix )
@@ -100,7 +102,7 @@ function paduavec!(v,P::IPaduaTransformPlan,padmat::Matrix)
100
102
return v
101
103
end
102
104
103
- doc """
105
+ """
104
106
Pre-plan a Padua Transform.
105
107
"""
106
108
struct PaduaTransformPlan{lex,DCTPLAN,T}
@@ -111,15 +113,15 @@ end
111
113
PaduaTransformPlan (vals:: Matrix{T} ,dctplan,:: Type{Val{lex}} ) where {T,lex} =
112
114
PaduaTransformPlan {lex,typeof(dctplan),T} (vals,dctplan)
113
115
114
- doc """
116
+ """
115
117
Pre-plan a Padua Transform.
116
118
"""
117
119
function plan_paduatransform! (:: Type{T} ,N:: Integer ,lex) where T
118
120
n= Int (cld (- 3 + sqrt (1 + 8 N),2 ))
119
121
if N ≠ ((n+ 1 )* (n+ 2 ))÷ 2
120
122
error (" Padua transforms can only be applied to vectors of length (n+1)*(n+2)/2." )
121
123
end
122
- PaduaTransformPlan (Array {T} (n+ 2 ,n+ 1 ),FFTW. plan_r2r! (Array {T} (n+ 2 ,n+ 1 ),FFTW. REDFT00),lex)
124
+ PaduaTransformPlan (Array {T} (undef, n+ 2 ,n+ 1 ),FFTW. plan_r2r! (Array {T} (undef, n+ 2 ,n+ 1 ),FFTW. REDFT00),lex)
123
125
end
124
126
125
127
plan_paduatransform! (:: Type{T} ,N:: Integer ) where {T} = plan_paduatransform! (T,N,Val{true })
@@ -131,21 +133,21 @@ function *(P::PaduaTransformPlan,v::AbstractVector{T}) where T
131
133
vals= paduavalsmat (P,v)
132
134
tensorcfs= P. dctplan* vals
133
135
m,l= size (tensorcfs)
134
- scale ! (tensorcfs,T (2 )/ (n* (n+ 1 )))
135
- scale ! (view (tensorcfs,1 ,:),0.5 )
136
- scale ! (view (tensorcfs,:,1 ),0.5 )
137
- scale ! (view (tensorcfs,m,:),0.5 )
138
- scale ! (view (tensorcfs,:,l),0.5 )
136
+ rmul ! (tensorcfs,T (2 )/ (n* (n+ 1 )))
137
+ rmul ! (view (tensorcfs,1 ,:),0.5 )
138
+ rmul ! (view (tensorcfs,:,1 ),0.5 )
139
+ rmul ! (view (tensorcfs,m,:),0.5 )
140
+ rmul ! (view (tensorcfs,:,l),0.5 )
139
141
trianglecfsvec! (v,P,tensorcfs)
140
142
end
141
143
142
144
paduatransform! (v:: AbstractVector ,lex... ) = plan_paduatransform! (v,lex... )* v
143
- doc """
145
+ """
144
146
Padua Transform maps from interpolant values at the Padua points to the 2D Chebyshev coefficients.
145
147
"""
146
148
paduatransform (v:: AbstractVector ,lex... ) = plan_paduatransform! (v,lex... )* copy (v)
147
149
148
- doc """
150
+ """
149
151
Creates ``(n+2)x(n+1)`` matrix of interpolant values on the tensor grid at the ``(n+1)(n+2)/2`` Padua points.
150
152
"""
151
153
function paduavalsmat (P:: PaduaTransformPlan ,v:: AbstractVector )
@@ -165,7 +167,7 @@ function paduavalsmat(P::PaduaTransformPlan,v::AbstractVector)
165
167
return vals
166
168
end
167
169
168
- doc """
170
+ """
169
171
Creates length ``(n+1)(n+2)/2`` vector from matrix of triangle Chebyshev coefficients.
170
172
"""
171
173
function trianglecfsvec! (v,P:: PaduaTransformPlan{true} ,cfs:: Matrix )
@@ -194,12 +196,12 @@ function trianglecfsvec!(v,P::PaduaTransformPlan{false},cfs::Matrix)
194
196
return v
195
197
end
196
198
197
- doc """
199
+ """
198
200
Returns coordinates of the ``(n+1)(n+2)/2`` Padua points.
199
201
"""
200
- function paduapoints (:: Type{T} ,n:: Integer ) where T
202
+ function paduapoints (:: Type{T} , n:: Integer ) where T
201
203
N= div ((n+ 1 )* (n+ 2 ),2 )
202
- MM= Matrix {T} (N,2 )
204
+ MM= Matrix {T} (undef, N,2 )
203
205
m= 0
204
206
delta= 0
205
207
NN= fld (n+ 2 ,2 )
0 commit comments