Skip to content

Commit be2e05e

Browse files
committed
initial commit
1 parent 6417e8a commit be2e05e

File tree

3 files changed

+107
-6
lines changed

3 files changed

+107
-6
lines changed

Project.toml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,21 @@ uuid = "a4a2c56f-fead-462a-a3ab-85921a5f2575"
33
authors = ["Tobias Knopp <[email protected]> and contributors"]
44
version = "1.0.0-DEV"
55

6+
[deps]
7+
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
8+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
9+
LinearOperators = "5c8ed15e-5a4c-59e4-a42b-c7e8811fb125"
10+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
11+
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
12+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
13+
Wavelets = "29a6e085-ba6d-5f35-a997-948ac2efa89a"
14+
615
[compat]
7-
julia = "1"
16+
julia = "1.6"
17+
FFTW = "0.2, 1.0"
18+
LinearOperators = "2.3.3"
19+
Reexport = "0.2, 1.0"
20+
Wavelets = "0.8, 0.9"
821

922
[extras]
1023
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

src/LinearOperatorCollection.jl

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,91 @@
11
module LinearOperatorCollection
22

3-
# Write your package code here.
3+
import Base: length, iterate, \
4+
using LinearAlgebra
5+
import LinearAlgebra.BLAS: gemv, gemv!
6+
import LinearAlgebra: BlasFloat, normalize!, norm, rmul!, lmul!
7+
using SparseArrays
8+
using Random
9+
#using CUDA
10+
11+
using Reexport
12+
@reexport using Reexport
13+
@reexport using LinearOperators
14+
@reexport using FFTW
15+
@reexport using Wavelets
16+
17+
LinearOperators.use_prod5!(op::opEye) = false
18+
LinearOperators.has_args5(op::opEye) = false
19+
20+
21+
const Trafo = Union{AbstractMatrix, AbstractLinearOperator, Nothing}
22+
const FuncOrNothing = Union{Function, Nothing}
23+
24+
# Helper function to wrap a prod into a 5-args mul
25+
function wrapProd(prod::Function)
26+
λ = (res, x, α, β) -> begin
27+
if β == zero(β)
28+
res .= prod(x) .* α
29+
else
30+
res .= prod(x) .* α .+ β .* res
31+
end
32+
end
33+
return λ
34+
end
35+
36+
include("FFTOp.jl")
37+
include("DCTOp.jl")
38+
include("DSTOp.jl")
39+
include("WaveletOp.jl")
40+
include("GradientOp.jl")
41+
include("SamplingOp.jl")
42+
include("WeightingOp.jl")
43+
include("NormalOp.jl")
44+
45+
export linearOperator, linearOperatorList
46+
47+
linearOperator(op::Nothing,shape,T::Type=ComplexF32) = nothing
48+
49+
"""
50+
returns a list of currently implemented `LinearOperator`s
51+
"""
52+
function linearOperatorList()
53+
return ["DCT-II", "DCT-IV", "FFT", "DST", "Wavelet", "Gradient"]
54+
end
55+
56+
"""
57+
linearOperator(op::AbstractString, shape)
58+
59+
returns the `LinearOperator` with name `op`.
60+
61+
# valid names
62+
* `"FFT"`
63+
* `"DCT-II"`
64+
* `"DCT-IV"`
65+
* `"DST"`
66+
* `"Wavelet"`
67+
* `"Gradient"`
68+
"""
69+
function linearOperator(op::AbstractString, shape, T::Type=ComplexF32)
70+
shape_ = tuple(shape...)
71+
if op == "FFT"
72+
trafo = FFTOp(T, shape_, false) #FFTOperator(shape)
73+
elseif op == "DCT-II"
74+
shape_ = tuple(shape[shape .!= 1]...)
75+
trafo = DCTOp(T, shape_, 2)
76+
elseif op == "DCT-IV"
77+
shape_ = tuple(shape[shape .!= 1]...)
78+
trafo = DCTOp(T, shape_, 4)
79+
elseif op == "DST"
80+
trafo = DSTOp(T, shape_)
81+
elseif op == "Wavelet"
82+
trafo = WaveletOp(T,shape_)
83+
elseif op=="Gradient"
84+
trafo = GradientOp(T,shape_)
85+
else
86+
error("Unknown transformation")
87+
end
88+
trafo
89+
end
490

591
end

test/runtests.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using LinearOperatorCollection
1+
using SparsityOperators
22
using Test
3+
using Random
4+
using LinearAlgebra
5+
using FFTW
36

4-
@testset "LinearOperatorCollection.jl" begin
5-
# Write your tests here.
6-
end
7+
include("testNormalOp.jl")
8+
include("testOperators.jl")

0 commit comments

Comments
 (0)