Skip to content

Commit 309a61a

Browse files
committed
Add RadonOp test
1 parent 82d41a3 commit 309a61a

File tree

3 files changed

+47
-28
lines changed

3 files changed

+47
-28
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
3434
RadonKA = "86de8297-835b-47df-b249-c04e8db91db5"
3535

3636
[targets]
37-
test = ["Test", "FFTW", "Wavelets", "NFFT", "JLArrays"]
37+
test = ["Test", "FFTW", "Wavelets", "NFFT", "JLArrays", "RadonKA"]
3838

3939
[extensions]
4040
LinearOperatorNFFTExt = ["NFFT", "FFTW"]

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using LinearAlgebra
55
using FFTW
66
using Wavelets
77
using NFFT
8+
using RadonKA
89
using JLArrays
910

1011
arrayTypes = [Array, JLArray]

test/testOperators.jl

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ end
316316
function testDiagOp(N=32,K=2;arrayType = Array)
317317
x = arrayType(rand(ComplexF64, K*N))
318318
block = arrayType(rand(ComplexF64, N, N))
319-
319+
320320
F = arrayType(zeros(ComplexF64, K*N, K*N))
321321
for k = 1:K
322322
start = (k-1)*N + 1
@@ -377,36 +377,54 @@ function testDiagOp(N=32,K=2;arrayType = Array)
377377
true
378378
end
379379

380-
# TODO RadonOp
380+
function testRadonOp(N=32;arrayType = Array)
381+
x = arrayType(rand(N, N))
382+
xop = vec(x)
383+
geom = RadonParallelCircle(N, -(N-1)÷2:(N-1)÷2)
384+
angles = collect(range(0, pi, 100))
385+
386+
op = RadonOp(eltype(x); shape = (N, N), angles, geometry = geom, S = typeof(xop))
387+
388+
y = Array(radon(x, angles; geometry = geom))
389+
y1 = reshape(Array(op * xop), size(y)...)
390+
@test y y1 rtol = 1e-2
391+
392+
xtmp = Array(backproject(arrayType(y), angles; geometry = geom))
393+
x2 = reshape(Array(adjoint(op) * arrayType(vec(y1))), size(xtmp)...)
394+
@test xtmp x2 rtol = 1e-2
395+
true
396+
end
381397

382398
@testset "Linear Operators" begin
383399
@testset for arrayType in arrayTypes
384-
#@info "test DCT-II and DCT-IV Ops: $arrayType"
385-
#for N in [2,8,16,32]
386-
# @test testDCT1d(N;arrayType) skip = arrayType != Array # Not implemented for GPUs
387-
#end
388-
#@info "test FFTOp: $arrayType"
389-
#for N in [8,16,32]
390-
# @test testFFT1d(N,false;arrayType)
391-
# @test testFFT1d(N,true;arrayType)
392-
# @test testFFT2d(N,false;arrayType)
393-
# @test testFFT2d(N,true;arrayType)
394-
#end
395-
#@info "test WeightingOp: $arrayType"
396-
#@test testWeighting(512;arrayType)
397-
#@info "test GradientOp: $arrayType"
398-
#@test testGradOp1d(512;arrayType)
399-
#@test testGradOp2d(64;arrayType)
400-
#@test testDirectionalGradOp(64;arrayType)
401-
#@info "test SamplingOp: $arrayType"
402-
#@test testSampling(64;arrayType)
403-
#@info "test WaveletOp: $arrayType"
404-
#@test testWavelet(64,64;arrayType)
405-
#@test testWavelet(64,60;arrayType)
406-
#@info "test NFFTOp: $arrayType"
407-
#@test testNFFT2d(;arrayType) skip = arrayType == JLArray # JLArray does not have a NFFTPlan
408-
#@test testNFFT3d(;arrayType) skip = arrayType == JLArray # JLArray does not have a NFFTPlan
400+
@info "test DCT-II and DCT-IV Ops: $arrayType"
401+
for N in [2,8,16,32]
402+
@test testDCT1d(N;arrayType) skip = arrayType != Array # Not implemented for GPUs
403+
end
404+
@info "test FFTOp: $arrayType"
405+
for N in [8,16,32]
406+
@test testFFT1d(N,false;arrayType)
407+
@test testFFT1d(N,true;arrayType)
408+
@test testFFT2d(N,false;arrayType)
409+
@test testFFT2d(N,true;arrayType)
410+
end
411+
@info "test WeightingOp: $arrayType"
412+
@test testWeighting(512;arrayType)
413+
@info "test GradientOp: $arrayType"
414+
@test testGradOp1d(512;arrayType)
415+
@test testGradOp2d(64;arrayType)
416+
@test testDirectionalGradOp(64;arrayType)
417+
@info "test SamplingOp: $arrayType"
418+
@test testSampling(64;arrayType)
419+
@info "test WaveletOp: $arrayType"
420+
@test testWavelet(64,64;arrayType)
421+
@test testWavelet(64,60;arrayType)
422+
@info "test NFFTOp: $arrayType"
423+
@test testNFFT2d(;arrayType) skip = arrayType == JLArray # JLArray does not have a NFFTPlan
424+
@test testNFFT3d(;arrayType) skip = arrayType == JLArray # JLArray does not have a NFFTPlan
409425
@info "test DiagOp: $arrayType"
410426
@test testDiagOp(;arrayType)
427+
@info "test RadonOp: $arrayType"
428+
@test testRadonOp(;arrayType) skip = arrayType == JLArray # Stackoverflow for kernelabstraction
411429
end
412430
end

0 commit comments

Comments
 (0)