Skip to content

Commit 1e5a7a9

Browse files
authored
Julia 1.0 update (#4)
* begin 0.7 transition: updated linearoperators * updated travis and appveyor * fixed LBFGS * fixed LBFGS * fixing linear calculus * fixed warnings linear calc * fixed nonlinear ops * enabled syntax tests - deprecated (.*) with DiagOp * nonlinear calculus working! all test passing 🎉 * updated readme and REQUIRE * removed some commented code * updated README and last 0.6 removals
1 parent 632f179 commit 1e5a7a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+955
-962
lines changed

.travis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
8+
- 1.0
89
- nightly
910
matrix:
1011
allow_failures:
@@ -14,7 +15,7 @@ notifications:
1415
# script:
1516
# - julia -e 'Pkg.clone(pwd()); Pkg.build("AbstractOperators"); Pkg.test("AbstractOperators"; coverage=true)'
1617
after_success:
17-
- julia -e 'cd(Pkg.dir("AbstractOperators")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())'
18-
- julia -e 'cd(Pkg.dir("AbstractOperators")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
19-
- julia -e 'Pkg.add("Documenter")'
20-
- julia -e 'cd(Pkg.dir("AbstractOperators")); include(joinpath("docs", "make.jl"))'
18+
- julia -e 'using Pkg; cd(Pkg.dir("AbstractOperators")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())'
19+
- julia -e 'using Pkg; cd(Pkg.dir("AbstractOperators")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
20+
- julia -e 'using Pkg; Pkg.add("Documenter")'
21+
- julia -e 'using Pkg; cd(Pkg.dir("AbstractOperators")); include(joinpath("docs", "make.jl"))'

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@ This is particularly useful in iterative algorithms and in first order large-sca
1414

1515
## Installation
1616

17-
To install the package, use the following in the Julia command line
17+
To install the package, hit `]` from the Julia command line to enter the package manager, then
1818

1919
```julia
20-
Pkg.add("AbstractOperators")
20+
pkg> add AbstractOperators
2121
```
2222

23-
Remember to `Pkg.update()` to keep the package up to date.
24-
2523
## Usage
2624

27-
With `using AbstractOperators` the package imports several methods like multiplication `*` and transposition `'` (and their in-place methods `A_mul_B!`, `Ac_mul_B!`).
25+
With `using AbstractOperators` the package imports several methods like multiplication `*` and adjoint transposition `'` (and their in-place methods `mul!`).
2826

2927
For example, one can create a 2-D Discrete Fourier Transform as follows:
3028

@@ -45,13 +43,13 @@ julia> y = A*x
4543
-0.905575+1.98446im 0.441199-0.913338im 0.315788+3.29666im 0.174273+0.318065im
4644
-0.905575-1.98446im 0.174273-0.318065im 0.315788-3.29666im 0.441199+0.913338im
4745

48-
julia> A_mul_B!(y,A,x) == A*x #in-place evaluation
46+
julia> mul!(y, A, x) == A*x #in-place evaluation
4947
true
5048

5149
julia> all(A'*y - *(size(x)...)*x .< 1e-12)
5250
true
5351

54-
julia> Ac_mul_B!(x,A,y) #in-place evaluation
52+
julia> mul!(x, A',y) #in-place evaluation
5553
3×4 Array{Float64,2}:
5654
-2.99091 9.45611 -19.799 1.6327
5755
-11.1841 11.2365 -26.3614 11.7261
@@ -97,6 +95,11 @@ julia> V*ones(3,3)
9795

9896
A list of the available `AbstractOperators` and calculus rules can be found in the [documentation](https://kul-forbes.github.io/AbstractOperators.jl/latest).
9997

98+
## Related packages
99+
100+
* [ProximalOperators.jl](https://github.com/kul-forbes/ProximalOperators.jl)
101+
* [ProximalAlgorithms.jl](https://github.com/kul-forbes/ProximalAlgorithms.jl)
102+
* [StructuredOptimization.jl](https://github.com/kul-forbes/StructuredOptimization.jl)
100103

101104
## Credits
102105

REQUIRE

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
julia 0.6
1+
julia 0.7
2+
AbstractFFTs v0.3.2
3+
FFTW 0.2.4
4+
DSP 0.5.1

appveyor.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
4-
# - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
3+
- julia_version: 0.7
4+
- julia_version: 1
5+
- julia_version: nightly
6+
7+
platform:
8+
# - x86 # 32-bit
9+
- x64 # 64-bit
10+
11+
matrix:
12+
allow_failures:
13+
- julia_version: 1
14+
- julia_version: nightly
515

616
branches:
717
only:
@@ -15,19 +25,18 @@ notifications:
1525
on_build_status_changed: false
1626

1727
install:
18-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
19-
# Download most recent Julia Windows binary
20-
- ps: (new-object net.webclient).DownloadFile(
21-
$env:JULIA_URL,
22-
"C:\projects\julia-binary.exe")
23-
# Run installer silently, output to C:\projects\julia
24-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
28+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
2529

2630
build_script:
27-
# Need to convert from shallow to complete for Pkg.clone to work
28-
- IF EXIST .git\shallow (git fetch --unshallow)
29-
- C:\projects\julia\bin\julia -e "versioninfo();
30-
Pkg.clone(pwd(), \"AbstractOperators\"); Pkg.build(\"AbstractOperators\")"
31+
- echo "%JL_BUILD_SCRIPT%"
32+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
3133

3234
test_script:
33-
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"AbstractOperators\")"
35+
- echo "%JL_TEST_SCRIPT%"
36+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
37+
38+
# # Uncomment to support code coverage upload. Should only be enabled for packages
39+
# # which would have coverage gaps without running on Windows
40+
# on_success:
41+
# - echo "%JL_CODECOV_SCRIPT%"
42+
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"

docs/src/index.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ This is particularly useful in iterative algorithms and in first order large-sca
77

88
## Installation
99

10-
To install the package, use the following in the Julia command line
10+
To install the package, hit `]` from the Julia command line to enter the package manager, then
1111

1212
```julia
13-
Pkg.add("AbstractOperators")
13+
pkg> add AbstractOperators
1414
```
1515

16-
Remember to `Pkg.update()` to keep the package up to date.
17-
1816
## Usage
1917

20-
With `using AbstractOperators` the package imports several methods like multiplication `*` and transposition `'` (and their in-place methods `A_mul_B!`, `Ac_mul_B!`).
18+
With `using AbstractOperators` the package imports several methods like multiplication `*` and adjoint transposition `'` (and their in-place methods `mul!`).
2119

2220
For example, one can create a 2-D Discrete Fourier Transform as follows:
2321

@@ -38,13 +36,13 @@ julia> y = A*x
3836
-0.905575+1.98446im 0.441199-0.913338im 0.315788+3.29666im 0.174273+0.318065im
3937
-0.905575-1.98446im 0.174273-0.318065im 0.315788-3.29666im 0.441199+0.913338im
4038

41-
julia> A_mul_B!(y,A,x) == A*x #in-place evaluation
39+
julia> mul!(y, A, x) == A*x #in-place evaluation
4240
true
4341

4442
julia> all(A'*y - *(size(x)...)*x .< 1e-12)
4543
true
4644

47-
julia> Ac_mul_B!(x,A,y) #in-place evaluation
45+
julia> mul!(x, A',y) #in-place evaluation
4846
3×4 Array{Float64,2}:
4947
-2.99091 9.45611 -19.799 1.6327
5048
-11.1841 11.2365 -26.3614 11.7261
@@ -90,6 +88,11 @@ julia> V*ones(3,3)
9088

9189
A list of the available `AbstractOperators` and calculus rules can be found in the [documentation](https://kul-forbes.github.io/AbstractOperators.jl/latest).
9290

91+
## Related packages
92+
93+
* [ProximalOperators.jl](https://github.com/kul-forbes/ProximalOperators.jl)
94+
* [ProximalAlgorithms.jl](https://github.com/kul-forbes/ProximalAlgorithms.jl)
95+
* [StructuredOptimization.jl](https://github.com/kul-forbes/StructuredOptimization.jl)
9396

9497
## Credits
9598

src/AbstractOperators.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ __precompile__()
22

33
module AbstractOperators
44

5+
using LinearAlgebra, AbstractFFTs, DSP, FFTW
6+
57
# Block stuff
68
include("utilities/block.jl")
79
using AbstractOperators.BlockArrays
@@ -11,7 +13,7 @@ abstract type AbstractOperator end
1113
abstract type LinearOperator <: AbstractOperator end
1214
abstract type NonLinearOperator <: AbstractOperator end
1315

14-
import Base: A_mul_B!, Ac_mul_B!
16+
import LinearAlgebra: mul!
1517

1618
export LinearOperator,
1719
NonLinearOperator,
@@ -21,7 +23,9 @@ export LinearOperator,
2123

2224
include("properties.jl")
2325

24-
# Linear operators
26+
include("calculus/AdjointOperator.jl")
27+
28+
## Linear operators
2529

2630
include("linearoperators/MyLinOp.jl")
2731
include("linearoperators/Zeros.jl")
@@ -30,7 +34,7 @@ include("linearoperators/Eye.jl")
3034
include("linearoperators/DiagOp.jl")
3135
include("linearoperators/GetIndex.jl")
3236
include("linearoperators/MatrixOp.jl")
33-
include("linearoperators/MatrixMul.jl")
37+
include("linearoperators/LMatrixOp.jl")
3438
include("linearoperators/DFT.jl")
3539
include("linearoperators/RDFT.jl")
3640
include("linearoperators/IRDFT.jl")
@@ -53,7 +57,6 @@ include("calculus/Compose.jl")
5357
include("calculus/Reshape.jl")
5458
include("calculus/BroadCast.jl")
5559
include("calculus/Sum.jl")
56-
include("calculus/Transpose.jl")
5760
include("calculus/AffineAdd.jl")
5861
include("calculus/Jacobian.jl")
5962
include("calculus/NonLinearCompose.jl")

src/calculus/AdjointOperator.jl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
export AdjointOperator
2+
3+
"""
4+
`AdjointOperator(A::AbstractOperator)`
5+
6+
Shorthand constructor:
7+
8+
`'(A::AbstractOperator)`
9+
10+
Returns the adjoint operator of `A`.
11+
12+
```julia
13+
julia> AdjointOperator(DFT(10))
14+
ℱᵃ ℂ^10 -> ℝ^10
15+
16+
julia> [DFT(10); DCT(10)]'
17+
[ℱ;ℱc]ᵃ ℂ^10 ℝ^10 -> ℝ^10
18+
```
19+
"""
20+
struct AdjointOperator{T <: AbstractOperator} <: AbstractOperator
21+
A::T
22+
function AdjointOperator(A::T) where {T<:AbstractOperator}
23+
is_linear(A) == false && error("Cannot transpose a nonlinear operator. You might use `jacobian`")
24+
new{T}(A)
25+
end
26+
end
27+
28+
# Constructors
29+
30+
AdjointOperator(L::AdjointOperator) = L.A
31+
32+
# Properties
33+
34+
size(L::AdjointOperator) = size(L.A,2), size(L.A,1)
35+
36+
domainType(L::AdjointOperator) = codomainType(L.A)
37+
codomainType(L::AdjointOperator) = domainType(L.A)
38+
39+
fun_name(L::AdjointOperator) = fun_name(L.A)*""
40+
41+
is_linear(L::AdjointOperator) = is_linear(L.A)
42+
is_null(L::AdjointOperator) = is_null(L.A)
43+
is_eye(L::AdjointOperator) = is_eye(L.A)
44+
is_diagonal(L::AdjointOperator) = is_diagonal(L.A)
45+
is_AcA_diagonal(L::AdjointOperator) = is_AAc_diagonal(L.A)
46+
is_AAc_diagonal(L::AdjointOperator) = is_AcA_diagonal(L.A)
47+
is_orthogonal(L::AdjointOperator) = is_orthogonal(L.A)
48+
is_invertible(L::AdjointOperator) = is_invertible(L.A)
49+
is_full_row_rank(L::AdjointOperator) = is_full_column_rank(L.A)
50+
is_full_column_rank(L::AdjointOperator) = is_full_row_rank(L.A)
51+
52+
diag(L::AdjointOperator) = diag(L.A)
53+
diag_AcA(L::AdjointOperator) = diag_AAc(L.A)
54+
diag_AAc(L::AdjointOperator) = diag_AcA(L.A)

src/calculus/AffineAdd.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ end
4646

4747
# Mappings
4848
# array
49-
function A_mul_B!(y::DD, T::AffineAdd{L, D, true}, x) where {L <: AbstractOperator, DD, D}
50-
A_mul_B!(y,T.A,x)
49+
function mul!(y::DD, T::AffineAdd{L, D, true}, x) where {L <: AbstractOperator, DD, D}
50+
mul!(y,T.A,x)
5151
y .+= T.d
5252
end
5353

54-
function A_mul_B!(y::DD, T::AffineAdd{L, D, false}, x) where {L <: AbstractOperator, DD, D}
55-
A_mul_B!(y,T.A,x)
54+
function mul!(y::DD, T::AffineAdd{L, D, false}, x) where {L <: AbstractOperator, DD, D}
55+
mul!(y,T.A,x)
5656
y .-= T.d
5757
end
5858

59-
Ac_mul_B!(y, T::AffineAdd{L, D}, x) where {L <: AbstractOperator, D} = Ac_mul_B!(y,T.A,x)
59+
mul!(y, T::AdjointOperator{AffineAdd{L, D, S}}, x) where {L <: AbstractOperator, D, S} = mul!(y,T.A.A',x)
6060

6161
# Properties
6262

@@ -93,7 +93,7 @@ function permute(T::AffineAdd{L,D,S}, p::AbstractVector{Int}) where {L,D,S}
9393
return AffineAdd(A,T.d,S)
9494
end
9595

96-
displacement(A::AffineAdd{L,D,true}) where {L,D} = A.d+displacement(A.A)
97-
displacement(A::AffineAdd{L,D,false}) where {L,D} = -A.d+displacement(A.A)
96+
displacement(A::AffineAdd{L,D,true}) where {L,D} = A.d .+ displacement(A.A)
97+
displacement(A::AffineAdd{L,D,false}) where {L,D} = -A.d .+ displacement(A.A)
9898

9999
remove_displacement(A::AffineAdd) = remove_displacement(A.A)

0 commit comments

Comments
 (0)