@@ -158,7 +158,7 @@ struct IChebyshevTransformPlan{T,kind,K,inplace,N,R} <: ChebyshevPlan{T}
158
158
IChebyshevTransformPlan {T,kind,K,inplace,N,R} () where {T,kind,K,inplace,N,R} = new {T,kind,K,inplace,N,R} ()
159
159
end
160
160
161
- IChebyshevTransformPlan {T,kind,K} (F:: FFTW.r2rFFTWPlan{T,K,inplace,N,R} ) where {T,kind,K,inplace,N,R} =
161
+ IChebyshevTransformPlan {T,kind,K} (F:: FFTW.r2rFFTWPlan{T,K,inplace,N,R} ) where {T,kind,K,inplace,N,R} =
162
162
IChebyshevTransformPlan {T,kind,K,inplace,N,R} (F)
163
163
164
164
size (P:: IChebyshevTransformPlan ) = isdefined (P, :plan ) ? size (P. plan) : (0 ,)
@@ -202,45 +202,69 @@ end
202
202
plan_ichebyshevtransform! (x:: AbstractArray , dims... ; kws... ) = plan_ichebyshevtransform! (x, Val (1 ), dims... ; kws... )
203
203
plan_ichebyshevtransform (x:: AbstractArray , dims... ; kws... ) = plan_ichebyshevtransform (x, Val (1 ), dims... ; kws... )
204
204
205
+ _icheb1_prerescale! (_, x:: AbstractVector ) = (x[1 ] *= 2 )
206
+ _icheb1_postrescale! (_, x:: AbstractVector ) = (x[1 ] /= 2 )
207
+ function _icheb1_prerescale! (d:: Number , x:: AbstractVector )
208
+ lmul! (2 , isone (d) ? view (x,:,1 ) : view (x,1 ,:))
209
+ x
210
+ end
211
+ function _icheb1_postrescale! (_, x:: AbstractVector )
212
+ ldiv (2 , isone (d) ? view (x,:,1 ) : view (x,1 ,:))
213
+ x
214
+ end
205
215
206
216
function * (P:: IChebyshevTransformPlan{T,1,K,true} , x:: AbstractVector{T} ) where {T<: fftwNumber ,K}
207
217
n = length (x)
208
218
n == 0 && return x
209
219
210
- x[ 1 ] *= 2
211
- x = lmul! ( one (T) / 2 , P. plan* x)
220
+ _icheb1_prerescale! (P . plan . region, x)
221
+ x = ldiv! ( 2 ^ length (P . plan . region) , P. plan* x)
212
222
x
213
- end
223
+ end
214
224
215
225
function mul! (y:: AbstractVector{T} , P:: IChebyshevTransformPlan{T,1,K,false} , x:: AbstractVector{T} ) where {T<: fftwNumber ,K}
216
226
n = length (x)
217
227
length (y) == n || throw (DimensionMismatch (" output must match dimension" ))
218
228
n == 0 && return y
219
229
220
- x[ 1 ] *= 2 # Todo: don't mutate x
230
+ _icheb1_prerescale! (P . plan . region, x) # Todo: don't mutate x
221
231
_plan_mul! (y, P. plan, x)
222
- x[1 ] /= 2
223
- lmul! (one (T)/ 2 , y)
224
- end
232
+ _icheb1_postrescale! (P. plan. region, x)
233
+ ldiv! (2 ^ length (P. plan. region), y)
234
+ end
235
+
236
+ _icheb2_prerescale! (_, x:: AbstractVector ) = (x[1 ] *= 2 ; x[end ] *= 2 )
237
+ _icheb2_postrescale! (_, x:: AbstractVector ) = (x[1 ] /= 2 ; x[end ] /= 2 )
238
+ function _icheb2_rescale! (d, y:: AbstractVector )
239
+ _icheb2_prerescale! (d, y)
240
+ lmul! (convert (T, prod (size (y) .- 1 ))/ 2 , y)
241
+ y
242
+ end
243
+ function _icheb2_prerescale! (d:: Number , x:: AbstractVector )
244
+ lmul! (2 , isone (d) ? view (x,:,1 ) : view (x,1 ,:))
245
+ x
246
+ end
247
+ function _icheb2_postrescale! (_, x:: AbstractVector )
248
+ ldiv (2 , isone (d) ? view (x,:,1 ) : view (x,1 ,:))
249
+ x
250
+ end
225
251
226
252
function * (P:: IChebyshevTransformPlan{T,2,K, true} , x:: AbstractVector{T} ) where {T<: fftwNumber ,K}
227
253
n = length (x)
228
254
229
- x[ 1 ] *= 2 ; x[ end ] *= 2
255
+ _icheb2_prerescale! (P . plan . region, x)
230
256
x = inv (P)* x
231
- x[1 ] *= 2 ; x[end ] *= 2
232
- lmul! (convert (T,n- 1 )/ 2 ,x)
257
+ _icheb2_rescale! (P. plan. region, x)
233
258
end
234
259
235
260
function mul! (y:: AbstractVector{T} , P:: IChebyshevTransformPlan{T,2,K,false} , x:: AbstractVector{T} ) where {T<: fftwNumber ,K}
236
261
n = length (x)
237
262
length (y) == n || throw (DimensionMismatch (" output must match dimension" ))
238
263
239
- x[ 1 ] *= 2 ; x[ end ] *= 2
264
+ _icheb2_prerescale! (P . plan . region, x)
240
265
_plan_mul! (y, inv (P), x)
241
- x[1 ] /= 2 ; x[end ] /= 2
242
- y[1 ] *= 2 ; y[end ] *= 2
243
- lmul! (convert (T,(n- 1 ))/ 2 ,y)
266
+ _icheb2_postrescale! (P. plan. region, x)
267
+ _icheb2_rescale! (P. plan. region, y)
244
268
end
245
269
246
270
* (P:: IChebyshevTransformPlan{T,kind,K,false} ,x:: AbstractVector{T} ) where {T,kind,K} = mul! (similar (x), P, convert (Array,x))
@@ -256,10 +280,10 @@ struct ChebyshevUTransformPlan{T,kind,inplace,P} <: ChebyshevPlan{T}
256
280
ChebyshevUTransformPlan {T,kind,inplace,P} () where {T,kind,inplace,P} = new {T,kind,inplace,P} ()
257
281
end
258
282
259
- ChebyshevUTransformPlan {T,kind,inplace} (plan:: FFTW.r2rFFTWPlan{T,P} ) where {T,kind,inplace,P} =
283
+ ChebyshevUTransformPlan {T,kind,inplace} (plan:: FFTW.r2rFFTWPlan{T,P} ) where {T,kind,inplace,P} =
260
284
ChebyshevUTransformPlan {T,kind,inplace,P} (plan)
261
285
262
- ChebyshevUTransformPlan {T,kind,inplace} (plan:: ChebyshevUTransformPlan{T,kind,inp,P} ) where {T,kind,inplace,inp,P} =
286
+ ChebyshevUTransformPlan {T,kind,inplace} (plan:: ChebyshevUTransformPlan{T,kind,inp,P} ) where {T,kind,inplace,inp,P} =
263
287
ChebyshevUTransformPlan {T,kind,inplace,P} (plan. plan)
264
288
265
289
@@ -336,10 +360,10 @@ struct IChebyshevUTransformPlan{T,kind,inplace,P} <: ChebyshevPlan{T}
336
360
IChebyshevUTransformPlan {T,kind,inplace,P} () where {T,kind,inplace,P} = new {T,kind,inplace,P} ()
337
361
end
338
362
339
- IChebyshevUTransformPlan {T,kind,inplace} (F:: FFTW.r2rFFTWPlan{T,P} ) where {T,kind,inplace,P} =
363
+ IChebyshevUTransformPlan {T,kind,inplace} (F:: FFTW.r2rFFTWPlan{T,P} ) where {T,kind,inplace,P} =
340
364
IChebyshevUTransformPlan {T,kind,inplace,P} (F)
341
365
342
- IChebyshevUTransformPlan {T,kind,true} (F:: IChebyshevUTransformPlan{T,kind,false,P} ) where {T,kind,P} =
366
+ IChebyshevUTransformPlan {T,kind,true} (F:: IChebyshevUTransformPlan{T,kind,false,P} ) where {T,kind,P} =
343
367
IChebyshevUTransformPlan {T,kind,true,P} (F. plan)
344
368
345
369
function plan_ichebyshevutransform! (x:: AbstractVector{T} , :: Val{1} ) where T<: fftwNumber
@@ -401,7 +425,7 @@ ichebyshevutransform!(x::AbstractVector{T}, kind=Val(1)) where {T<:fftwNumber} =
401
425
402
426
ichebyshevutransform (x, kind= Val (1 )) = ichebyshevutransform! (Array (x), kind)
403
427
404
- * (P:: IChebyshevUTransformPlan{T,k,false} ,x:: AbstractVector{T} ) where {T,k} =
428
+ * (P:: IChebyshevUTransformPlan{T,k,false} ,x:: AbstractVector{T} ) where {T,k} =
405
429
IChebyshevUTransformPlan {T,k,true} (P)* Array (x)
406
430
407
431
0 commit comments