Block Diagonal Operator

This operator represents a block-diagonal matrix out of given operators. One can also provide a single-operator and a number of blocks. In that case the given operator is repeated for each block. In the case of stateful operators, one can supply a method for copying the operators.

blocks = N
ops = [WeightingOp(fill(i % 2, N)) for i = 1:N]
dop = DiagOp(ops)
typeof(dop)
DiagOp{Int64, Vector{Int64}, Vector{WeightingOp{Int64, Vector{Int64}}}, OhMyThreads.Schedulers.DynamicScheduler{OhMyThreads.Schedulers.FixedCount, ChunkSplitters.Consecutive, :default}}

We can retrieve the operators:

typeof(dop.ops)
Vector{WeightingOp{Int64, Vector{Int64}}} (alias for Array{WeightingOp{Int64, Array{Int64, 1}}, 1})

And visualize the result:

fig = Figure()
plot_image(fig[1,1], image, title = "Image")
plot_image(fig[1,2], reshape(dop * vec(image), N, N), title = "Block Weighted")
resize_to_layout!(fig)
fig
Example block output

The default operator is created with a DynamicScheduler from OhMyThreads.jl. This means it will execute the multiplication of its individual blocks in parallel. To supply a different scheduler do:

using OhMyThreads
scheduler = SerialScheduler()
dop_serial = DiagOp(ops, scheduler = scheduler)
typeof(dop_serial)
DiagOp{Int64, Vector{Int64}, Vector{WeightingOp{Int64, Vector{Int64}}}, OhMyThreads.Schedulers.SerialScheduler}

This page was generated using Literate.jl.