Skip to content
Merged
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
*.bbl
*.blg
*.log
*.DS_Store


docs/build/
docs/site/
docs/Manifest.toml
15 changes: 12 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ os:
- linux
- osx
julia:
- 0.7
- 1.0
- 1.1
- nightly
matrix:
allow_failures:
Expand All @@ -17,5 +17,14 @@ notifications:
after_success:
- julia -e 'using Pkg; cd(Pkg.dir("AbstractOperators")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())'
- julia -e 'using Pkg; cd(Pkg.dir("AbstractOperators")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
- julia -e 'using Pkg; Pkg.add("Documenter")'
- julia -e 'using Pkg; cd(Pkg.dir("AbstractOperators")); include(joinpath("docs", "make.jl"))'

jobs:
include:
- stage: "Documentation"
julia: 1.1
os: linux
script:
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd()));
Pkg.instantiate()'
- julia --project=docs/ docs/make.jl
after_success: skip
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,19 @@ julia> H = [A B]

In this case `H` has a domain of dimensions `size(H,2) = ((3, 4), (3, 4))` and type `domainType(H) = (Float64, Complex{Float64})`.

When an `AbstractOperators` have multiple domains, this must be multiplied using a `Tuple`s of `AbstractArray`s with corresponding `size(H,2)` and `domainType(H)`, for example:
When an `AbstractOperators` have multiple domains, this must be multiplied using an `ArrayPartition` (see [RecursiveArrayTools](https://github.com/JuliaDiffEq/RecursiveArrayTools.jl/]) with corresponding size and domain, for example:

```julia
julia> H*(x, complex(x))
julia> using RecursiveArrayTools

julia> H*ArrayPartition(x, complex(x))
3×4 Array{Complex{Float64},2}:
-16.3603+0.0im 52.4946-8.69342im -129.014+0.0im 44.6712+8.69342im
-22.051+23.8135im 16.5309-10.9601im -22.5719+39.5599im 13.8174+3.81678im
-5.81874-23.8135im 9.70679-3.81678im -2.21552-39.5599im 11.5502+10.9601im
```

Similarly, when an `AbstractOperators` have multiple codomains, this will return a `Tuple` of `AbstractArray`s with corresponding `size(H,1)` and `codomainType(H)`, for example:
Similarly, when an `AbstractOperators` have multiple codomains, this will return an `ArrayPartition`, for example:
```julia
julia> V = VCAT(Eye(3,3),FiniteDiff((3,3)))
[I;δx] ℝ^(3, 3) -> ℝ^(3, 3) ℝ^(2, 3)
Expand Down
9 changes: 5 additions & 4 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
julia 0.7
AbstractFFTs v0.3.2
FFTW 0.2.4
DSP 0.5.1
julia 1.0
AbstractFFTs v0.3
FFTW 0.2
DSP 0.5
RecursiveArrayTools 0.18
5 changes: 2 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
matrix:
- julia_version: 0.7
- julia_version: 1
- julia_version: 1.0
- julia_version: 1.1
- julia_version: nightly

platform:
Expand All @@ -10,7 +10,6 @@ platform:

matrix:
allow_failures:
- julia_version: 1
- julia_version: nightly

branches:
Expand Down
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
8 changes: 2 additions & 6 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ using Documenter, AbstractOperators

makedocs(
modules = [AbstractOperators],
format = :html,
format = Documenter.HTML(),
sitename = "AbstractOperators.jl",
authors = "Niccolò Antonello and Lorenzo Stella",
pages = Any[
pages = [
"Home" => "index.md",
"Abstract Operators" => "operators.md",
"Calculus rules" => "calculus.md",
Expand All @@ -15,9 +15,5 @@ makedocs(

deploydocs(
repo = "github.com/kul-forbes/AbstractOperators.jl.git",
julia = "0.6",
osname = "linux",
target = "build",
deps = nothing,
make = nothing,
)
15 changes: 12 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# AbstractOperators.jl

[![Build Status](https://travis-ci.org/kul-forbes/AbstractOperators.jl.svg?branch=master)](https://travis-ci.org/kul-forbes/AbstractOperators.jl)
[![Build status](https://ci.appveyor.com/api/projects/status/lfrmkg2s1awyxtk8/branch/master?svg=true)](https://ci.appveyor.com/project/nantonel/abstractoperators-jl/branch/master)
[![codecov](https://codecov.io/gh/kul-forbes/AbstractOperators.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/kul-forbes/AbstractOperators.jl)

[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://kul-forbes.github.io/AbstractOperators.jl/stable)
[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://kul-forbes.github.io/AbstractOperators.jl/latest)

## Description

Abstract operators extend the syntax typically used for matrices to linear mappings of arbitrary dimensions and nonlinear functions. Unlike matrices however, abstract operators apply the mappings with specific efficient algorithms that minimize memory requirements.
Expand Down Expand Up @@ -66,17 +73,19 @@ julia> H = [A B]

In this case `H` has a domain of dimensions `size(H,2) = ((3, 4), (3, 4))` and type `domainType(H) = (Float64, Complex{Float64})`.

When an `AbstractOperators` have multiple domains, this must be multiplied using a `Tuple`s of `AbstractArray`s with corresponding `size(H,2)` and `domainType(H)`, for example:
When an `AbstractOperators` have multiple domains, this must be multiplied using an `ArrayPartition` (see [RecursiveArrayTools](https://github.com/JuliaDiffEq/RecursiveArrayTools.jl/]) with corresponding size and domain, for example:

```julia
julia> H*(x, complex(x))
julia> using RecursiveArrayTools

julia> H*ArrayPartition(x, complex(x))
3×4 Array{Complex{Float64},2}:
-16.3603+0.0im 52.4946-8.69342im -129.014+0.0im 44.6712+8.69342im
-22.051+23.8135im 16.5309-10.9601im -22.5719+39.5599im 13.8174+3.81678im
-5.81874-23.8135im 9.70679-3.81678im -2.21552-39.5599im 11.5502+10.9601im
```

Similarly, when an `AbstractOperators` have multiple codomains, this will return a `Tuple` of `AbstractArray`s with corresponding `size(H,1)` and `codomainType(H)`, for example:
Similarly, when an `AbstractOperators` have multiple codomains, this will return an `ArrayPartition`, for example:
```julia
julia> V = VCAT(Eye(3,3),FiniteDiff((3,3)))
[I;δx] ℝ^(3, 3) -> ℝ^(3, 3) ℝ^(2, 3)
Expand Down
8 changes: 3 additions & 5 deletions src/AbstractOperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ __precompile__()

module AbstractOperators

using LinearAlgebra, AbstractFFTs, DSP, FFTW
using LinearAlgebra, AbstractFFTs, DSP, FFTW, RecursiveArrayTools

# Block stuff
include("utilities/block.jl")
using AbstractOperators.BlockArrays

const RealOrComplex{R} = Union{R, Complex{R}}
abstract type AbstractOperator end

abstract type LinearOperator <: AbstractOperator end
Expand All @@ -18,11 +16,11 @@ import LinearAlgebra: mul!
export LinearOperator,
NonLinearOperator,
AbstractOperator
export mul!

# Predicates and properties

include("properties.jl")

include("calculus/AdjointOperator.jl")

## Linear operators
Expand Down
26 changes: 16 additions & 10 deletions src/calculus/DCAT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ DCAT ℝ^10 ℝ^10 ℝ^(4, 4) -> ℝ^10 ℝ^10 ℝ^(3, 4)
To evaluate `DCAT` operators multiply them with a `Tuple` of `AbstractArray` of the correct domain size and type. The output will consist as well of a `Tuple` with the codomain type and size of the `DCAT`.

```julia
julia> D*(ones(2),ones(2),ones(3))
julia> D*ArrayPartition(ones(2),ones(2),ones(3))
([2.0, 2.0], Complex{Float64}[3.0+0.0im, 0.0+0.0im, 0.0+0.0im])

```
Expand Down Expand Up @@ -62,9 +62,12 @@ function DCAT(A::Vararg{AbstractOperator})
end

# Mappings
@generated function mul!(y, H::DCAT{N,L,P1,P2}, b) where {N,L,P1,P2}
@generated function mul!(yy::ArrayPartition,
H::DCAT{N,L,P1,P2},
bb::ArrayPartition) where {N,L,P1,P2}

ex = :()
# extract stuff
ex = :(y = yy.x; b = bb.x )

for i = 1:N

Expand All @@ -76,7 +79,7 @@ end
# stacked operator
# build mul!(( y[H.idxC[i][1]], y[H.idxC[i][2]] ... ), H.A[i], b)
yy = [ :(y[H.idxC[$i][$ii]]) for ii in eachindex(fieldnames(fieldtype(P2,i)))]
yy = :( tuple( $(yy...) ) )
yy = :( ArrayPartition( $(yy...) ) )
end

if fieldtype(P1,i) <: Int
Expand All @@ -87,7 +90,7 @@ end
# stacked operator
# build mul!(H.buf, H.A[i],( b[H.idxD[i][1]], b[H.idxD[i][2]] ... ))
bb = [ :(b[H.idxD[$i][$ii]]) for ii in eachindex(fieldnames(fieldtype(P1,i))) ]
bb = :( tuple( $(bb...) ) )
bb = :( ArrayPartition( $(bb...) ) )
end

ex = :($ex; mul!($yy,H.A[$i],$bb))
Expand All @@ -98,9 +101,12 @@ end

end

@generated function mul!(y, A::AdjointOperator{DCAT{N,L,P1,P2}}, b) where {N,L,P1,P2}
@generated function mul!(yy::ArrayPartition,
A::AdjointOperator{DCAT{N,L,P1,P2}},
bb::ArrayPartition) where {N,L,P1,P2}

ex = :(H = A.A)
# extract stuff
ex = :(H = A.A; y = yy.x; b = bb.x )

for i = 1:N

Expand All @@ -112,7 +118,7 @@ end
# stacked operator
# build mul!(( y[H.idxD[i][1]], y[H.idxD[i][2]] ... ), H.A[i]', b)
yy = [ :(y[H.idxD[$i][$ii]]) for ii in eachindex(fieldnames(fieldtype(P1,i)))]
yy = :( tuple( $(yy...) ))
yy = :( ArrayPartition( $(yy...) ))
end

if fieldtype(P2,i) <: Int
Expand All @@ -123,7 +129,7 @@ end
# stacked operator
# build mul!(H.buf, H.A[i]',( b[H.idxC[i][1]], b[H.idxC[i][2]] ... ))
bb = [ :(b[H.idxC[$i][$ii]]) for ii in eachindex(fieldnames(fieldtype(P2,i)))]
bb = :( tuple( $(bb...) ) )
bb = :( ArrayPartition( $(bb...) ) )
end

ex = :($ex; mul!($yy,H.A[$i]',$bb))
Expand Down Expand Up @@ -196,7 +202,7 @@ remove_displacement(D::DCAT) = DCAT(remove_displacement.(D.A), D.idxD, D.idxC)

# special cases
# Eye constructor
Eye(x::A) where {N, A <: NTuple{N,AbstractArray}} = DCAT(Eye.(x)...)
Eye(x::ArrayPartition) = DCAT(Eye.(x.x)...)
diag(L::DCAT{N,NTuple{N,E}}) where {N, E <: Eye} = 1.
diag_AAc(L::DCAT{N,NTuple{N,E}}) where {N, E <: Eye} = 1.
diag_AcA(L::DCAT{N,NTuple{N,E}}) where {N, E <: Eye} = 1.
Loading