Skip to content

Commit 062e03f

Browse files
committed
WIP of extension implementation
1 parent 85b129f commit 062e03f

File tree

10 files changed

+64
-14
lines changed

10 files changed

+64
-14
lines changed

Project.toml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,29 @@ authors = ["Tobias Knopp <[email protected]> and contributors"]
44
version = "1.0.0"
55

66
[deps]
7-
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
87
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
98
LinearOperators = "5c8ed15e-5a4c-59e4-a42b-c7e8811fb125"
109
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1110
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1211
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
12+
13+
[weakdeps]
1314
Wavelets = "29a6e085-ba6d-5f35-a997-948ac2efa89a"
15+
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
16+
17+
[extensions]
18+
LinearOperatorWaveletExt = "Wavelets"
19+
LinearOperatorFFTWExt = "FFTW"
1420

1521
[compat]
1622
julia = "1.6"
17-
FFTW = "0.2, 1.0"
23+
FFTW = "1.0"
1824
LinearOperators = "2.3.3"
19-
Reexport = "0.2, 1.0"
20-
Wavelets = "0.8, 0.9"
25+
Reexport = "1.0"
26+
Wavelets = "0.9"
2127

2228
[extras]
2329
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2430

2531
[targets]
26-
test = ["Test"]
32+
test = ["Test", "FFTW", "Wavelets"]

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,22 @@
22

33
[![Build Status](https://github.com/JuliaImageRecon/LinearOperatorCollection.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaImageRecon/LinearOperatorCollection.jl/actions/workflows/CI.yml?query=branch%3Amain)
44

5-
[![codecov.io](http://codecov.io/JuliaImageRecon/LinearOperatorCollection.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaImageRecon/LinearOperatorCollection.jl?branch=master)
5+
[![codecov.io](http://codecov.io/JuliaImageRecon/LinearOperatorCollection.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaImageRecon/LinearOperatorCollection.jl?branch=master)
6+
7+
## Purpose
8+
9+
This package contains a collection of linear operators that are in particular useful for multi-dimensional signal and image processing tasks. All operators are build using the LinearOperators.jl base type and derive from `AbstractLinearOperator`. For example this package
10+
provides operators for the FFT (Fast Fourier Transform) and its non-equidistant variant (NFFT), the DCT (Discrete Cosine Transform), and the Wavelet transform. This package, however, does not implement
11+
these transformation itself but uses established libraries for them. So in fact, LinearOperatorCollection's main purpose is to add a wrapper around low-level libraries like
12+
FFTW.jl and NFFT.jl, which allows to use the transformation as if they would be linear operators, i.e. implement `Op * x`, `adjoint(Op) * x` and the `mul!` based in-place variants of the former.
13+
14+
## Installation
15+
16+
Within Julia, use the package manager to install this package:
17+
```julia
18+
using Pkg
19+
Pkg.add("LinearOperatorCollection")
20+
```
21+
22+
## Usage
23+
...
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module LinearOperatorFFTWExt
2+
3+
include("FFTOp.jl")
4+
include("DCTOp.jl")
5+
include("DSTOp.jl")
6+
7+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module LinearOperatorWaveletExt
2+
3+
include("WaveletOp.jl")
4+
5+
end

src/WaveletOp.jl renamed to ext/LinearOperatorWaveletExt/WaveletOp.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
export WaveletOp
22

3+
import LinearOperatorCollection: constructLinearOperator
4+
5+
function constructLinearOperator(::Type{Op}; eltype::Type, shape::Tuple, wt=wavelet(WT.db2)) where Op <: WaveletOp{T} where T <: Number
6+
return WaveletOpImpl(eltype, shape, wt)
7+
end
8+
39
"""
410
WaveletOp(shape, wt=wavelet(WT.db2))
511
@@ -11,7 +17,7 @@ a given input array.
1117
* `shape` - size of the Array to transform
1218
* (`wt=wavelet(WT.db2)`) - Wavelet to apply
1319
"""
14-
function WaveletOp(T::Type, shape, wt=wavelet(WT.db2))
20+
function WaveletOpImpl(T::Type, shape, wt=wavelet(WT.db2))
1521
return LinearOperator(T, prod(shape), prod(shape), false, false
1622
, (res,x)->dwt!(reshape(res,shape), reshape(x,shape), wt)
1723
, nothing

src/LinearOperatorCollection.jl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ using Random
1111
using Reexport
1212
@reexport using Reexport
1313
@reexport using LinearOperators
14-
@reexport using FFTW
15-
@reexport using Wavelets
1614

1715
LinearOperators.use_prod5!(op::opEye) = false
1816
LinearOperators.has_args5(op::opEye) = false
@@ -33,18 +31,27 @@ function wrapProd(prod::Function)
3331
return λ
3432
end
3533

36-
include("FFTOp.jl")
37-
include("DCTOp.jl")
38-
include("DSTOp.jl")
39-
include("WaveletOp.jl")
4034
include("GradientOp.jl")
4135
include("SamplingOp.jl")
4236
include("WeightingOp.jl")
4337
include("NormalOp.jl")
4438

4539
export linearOperator, linearOperatorList
4640

47-
linearOperator(op::Nothing,shape,T::Type=ComplexF32) = nothing
41+
export constructLinearOperator
42+
export AbstractLinearOperatorFromCollection, WaveletOp, FFTOp, DCTOp, DSTOp
43+
44+
abstract type AbstractLinearOperatorFromCollection{T} <: AbstractLinearOperator{T} end
45+
abstract type WaveletOp{T} <: AbstractLinearOperatorFromCollection{T} end
46+
abstract type FFTOp{T} <: AbstractLinearOperatorFromCollection{T} end
47+
abstract type DCTOp{T} <: AbstractLinearOperatorFromCollection{T} end
48+
abstract type DSTOp{T} <: AbstractLinearOperatorFromCollection{T} end
49+
50+
function constructLinearOperator(::Type{<:AbstractLinearOperatorFromCollection}, args...; kargs...)
51+
error("Operator can't be constructed. You need to load another package!")
52+
end
53+
54+
linearOperator(op::Nothing, shape, T::Type=ComplexF32) = nothing
4855

4956
"""
5057
returns a list of currently implemented `LinearOperator`s

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ using Test
33
using Random
44
using LinearAlgebra
55
using FFTW
6+
using Wavelets
67

78
include("testNormalOp.jl")
89
include("testOperators.jl")

0 commit comments

Comments
 (0)