@@ -19,21 +19,22 @@ x = range(start=-L/2, stop=L/2-dx, length=n) |> Array
1919u = @. sin(5x)cos(7x);
2020du = @. 5cos(5x)cos(7x) - 7sin(5x)sin(7x);
2121
22- k = rfftfreq(n, 2π*n/L) |> Array
23- m = length(k)
24- transform = plan_rfft(x)
22+ k = rfftfreq(n, 2π*n/L) |> Array
23+ m = length(k)
24+ P = plan_rfft(x)
25+
26+ F = FunctionOperator(fwd, x, im*k;
27+ T=ComplexF64,
2528
26- T = FunctionOperator((du,u,p,t) -> mul!(du, transform, u), x, im*k;
27- isinplace=true ,
28- T=ComplexF64 ,
29+ op_adjoint = bwd,
30+ op_inverse = bwd ,
31+ op_adjoint_inverse = fwd ,
2932
30- op_adjoint = (du,u,p,t) -> ldiv!(du, transform, u),
31- op_inverse = (du,u,p,t) -> ldiv!(du, transform, u),
32- op_adjoint_inverse = (du,u,p,t) -> ldiv!(du, transform, u),
33- )
33+ islinear=true,
34+ )
3435
3536ik = im * DiagonalOperator(k)
36- Dx = T \ ik * T
37+ Dx = F \ ik * F
3738
3839Dx = cache_operator(Dx, x)
3940
@@ -79,18 +80,17 @@ Now we are ready to define our wrapper for the FFT object. To `FunctionOperator`
7980pass the in-place forward application of the transform,
8081` (du,u,p,t) -> mul!(du, transform, u) ` , its inverse application,
8182` (du,u,p,t) -> ldiv!(du, transform, u) ` , as well as input and output prototype vectors.
82- We also set the flag ` isinplace ` to ` true ` to signal that we intend to use the operator
83- in a non-allocating way, and pass in the element-type and size of the operator.
8483
8584```
86- T = FunctionOperator((du,u,p,t) -> mul!(du, transform, u), x, im*k;
87- isinplace=true,
88- T=ComplexF64,
89-
90- op_adjoint = (du,u,p,t) -> ldiv!(du, transform, u),
91- op_inverse = (du,u,p,t) -> ldiv!(du, transform, u),
92- op_adjoint_inverse = (du,u,p,t) -> ldiv!(du, transform, u),
93- )
85+ F = FunctionOperator(fwd, x, im*k;
86+ T=ComplexF64,
87+
88+ op_adjoint = bwd,
89+ op_inverse = bwd,
90+ op_adjoint_inverse = fwd,
91+
92+ islinear=true,
93+ )
9494```
9595
9696After wrapping the FFT with ` FunctionOperator ` , we are ready to compose it with other
@@ -100,7 +100,7 @@ both in-place, and out-of-place by comparing its output to the analytical deriva
100100
101101```
102102ik = im * DiagonalOperator(k)
103- Dx = T \ ik * T
103+ Dx = F \ ik * F
104104
105105@show ≈(Dx * u, du; atol=1e-8)
106106@show ≈(mul!(copy(u), Dx, u), du; atol=1e-8)
0 commit comments