Row-Block Operator

This operator stacks operators vertically: all of them act on the same input, and each one fills its own rows of the output. The rows of a block need not be contiguous. Block-iterative and ordered-subset methods (e.g. SART, OS-EM) use such a split of a system matrix into blocks of rows; as a whole the operator works like any other.

A matrix split into three blocks of interleaved rows (every third row), :contiguous and :random are the other modes:

A = rand(12, N * N)
rop = RowBlockOp(A, 3)
typeof(rop)
RowBlockOp{Float64, Vector{Float64}, Vector{Matrix{Float64}}, Vector{StepRange{Int64, Int64}}, Vector{Vector{Float64}}, OhMyThreads.Schedulers.DynamicScheduler{OhMyThreads.Schedulers.FixedCount, ChunkSplitters.Consecutive, :default}}

The blocks with the indices of their rows:

[(size(op), rows) for (op, rows) in rowblocks(rop)]
3-element Vector{Tuple{Tuple{Int64, Int64}, StepRange{Int64, Int64}}}:
 ((4, 65536), 1:3:10)
 ((4, 65536), 2:3:11)
 ((4, 65536), 3:3:12)

Applied as a whole, the operator equals the matrix, and so do its adjoint and its normal operator:

x = vec(image)
rop * x ≈ A * x
true
adjoint(rop) * (A * x) ≈ adjoint(A) * (A * x)
true

Any operators with the same number of columns can be blocks, with their rows given explicitly. Here two weighting operators fill the even and the odd entries of the output:

ops = [WeightingOp(fill(1.0, N * N)), WeightingOp(fill(2.0, N * N))]
rop2 = RowBlockOp(ops, [1:2:2N*N, 2:2:2N*N])
(rop2 * x)[1:4] ≈ [x[1], 2x[1], x[2], 2x[2]]
true

Blocks with contiguous rows work on views of the data; for other rows the data of a block is gathered into a buffer. The products of the blocks run in parallel with a scheduler of OhMyThreads.jl, as for the DiagOp:

using OhMyThreads
rop_serial = RowBlockOp(A, 3; scheduler = SerialScheduler())
typeof(rop_serial)
RowBlockOp{Float64, Vector{Float64}, Vector{Matrix{Float64}}, Vector{StepRange{Int64, Int64}}, Vector{Vector{Float64}}, OhMyThreads.Schedulers.SerialScheduler}

This page was generated using Literate.jl.