From ecf9f368e85c11a717d96eda4dd28d15cf77a179 Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Tue, 24 Mar 2020 14:34:17 -0400 Subject: [PATCH 1/2] Add a kwarg for PreallocatedLinearOperators --- src/PreallocatedLinearOperators.jl | 50 ++++++++++++++---------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/PreallocatedLinearOperators.jl b/src/PreallocatedLinearOperators.jl index 84778c8a..9b6926dd 100644 --- a/src/PreallocatedLinearOperators.jl +++ b/src/PreallocatedLinearOperators.jl @@ -61,9 +61,8 @@ for `M * v` and `Mtu` as storage space for `transpose(M) * u` and `Maw` to store `adjoint(M) * w`. Use the optional keyword arguments to indicate whether the operator is symmetric and/or hermitian. """ -function PreallocatedLinearOperator(Mv :: Vector{T}, Mtu :: Vector{T}, Maw :: Vector{T}, - M :: AbstractMatrix{T}; - symmetric=false, hermitian=false) where T +function PreallocatedLinearOperator(Mv :: AbstractVector{T}, Mtu :: AbstractVector{T}, Maw :: AbstractVector{T}, + M :: AbstractMatrix{T}; symmetric=false, hermitian=false) where T nrow, ncol = size(M) @assert length(Mv) == nrow @assert length(Mtu) == ncol @@ -80,33 +79,32 @@ end Construct a linear operator from a symmetric real square matrix `M` with preallocation using `Mv` as storage space. """ -PreallocatedLinearOperator(Mv :: Vector{T}, M :: Union{SymTridiagonal{T},Symmetric{T}}) where T <: Real = +PreallocatedLinearOperator(Mv :: AbstractVector{T}, M :: Union{SymTridiagonal{T},Symmetric{T}}) where T <: Real = PreallocatedLinearOperator(Mv, Mv, Mv, M, symmetric=true, hermitian=true) -function PreallocatedLinearOperator(M :: AbstractMatrix{T}; - symmetric=false, hermitian=false) where T +function PreallocatedLinearOperator(M :: AbstractMatrix{T}; storagetype=Vector{T}, symmetric=false, hermitian=false) where T nrow, ncol = size(M) local Mv, Mtu, Maw if T <: Real if symmetric - Maw = Mtu = Mv = Vector{T}(undef, nrow) + Maw = Mtu = Mv = storagetype(undef, nrow) else - Mv = Vector{T}(undef, nrow) - Maw = Mtu = Vector{T}(undef, ncol) + Mv = storagetype(undef, nrow) + Maw = Mtu = storagetype(undef, ncol) end else if symmetric && hermitian # Actually real, but T is not - Maw = Mtu = Mv = Vector{T}(undef, nrow) + Maw = Mtu = Mv = storagetype(undef, nrow) elseif symmetric - Mtu = Mv = Vector{T}(undef, nrow) - Maw = Vector{T}(undef, ncol) + Mtu = Mv = storagetype(undef, nrow) + Maw = storagetype(undef, ncol) elseif hermitian - Mv = Vector{T}(undef, nrow) - Maw = Mtu = Vector{T}(undef, ncol) + Mv = storagetype(undef, nrow) + Maw = Mtu = storagetype(undef, ncol) else - Mv = Vector{T}(undef, nrow) - Mtu = Vector{T}(undef, ncol) - Maw = Vector{T}(undef, ncol) + Mv = storagetype(undef, nrow) + Mtu = storagetype(undef, ncol) + Maw = storagetype(undef, ncol) end end PreallocatedLinearOperator(Mv, Mtu, Maw, M, symmetric=symmetric, hermitian=hermitian) @@ -119,11 +117,11 @@ Constructs a linear operator from a symmetric tridiagonal matrix. If its elements are real, it is also Hermitian, otherwise complex symmetric. """ -function PreallocatedLinearOperator(M :: SymTridiagonal{T}) where T +function PreallocatedLinearOperator(M :: SymTridiagonal{T}; storagetype=Vector{T}) where T nrow, ncol = size(M) - Mv = Vector{T}(undef, nrow) + Mv = storagetype(undef, nrow) hermitian = eltype(M) <: Real - Maw = hermitian ? Mv : Vector{T}(undef, ncol) + Maw = hermitian ? Mv : storagetype(undef, ncol) PreallocatedLinearOperator(Mv, Mv, Maw, M, symmetric=true, hermitian=hermitian) end @@ -134,11 +132,11 @@ Constructs a linear operator from a symmetric matrix. If its elements are real, it is also Hermitian, otherwise complex symmetric. """ -function PreallocatedLinearOperator(M :: Symmetric{T}) where T +function PreallocatedLinearOperator(M :: Symmetric{T}; storagetype=Vector{T}) where T nrow, ncol = size(M) - Mv = Vector{T}(undef, nrow) + Mv = storagetype(undef, nrow) hermitian = eltype(M) <: Real - Maw = hermitian ? Mv : Vector{T}(undef, ncol) + Maw = hermitian ? Mv : storagetype(undef, ncol) PreallocatedLinearOperator(Mv, Mv, Maw, M, symmetric=true, hermitian=hermitian) end @@ -148,10 +146,10 @@ end Constructs a linear operator from a Hermitian matrix. If its elements are real, it is also symmetric. """ -function PreallocatedLinearOperator(M :: Hermitian{T}) where T +function PreallocatedLinearOperator(M :: Hermitian{T}; storagetype=Vector{T}) where T nrow, ncol = size(M) - Mv = Vector{T}(undef, nrow) + Mv = storagetype(undef, nrow) symmetric = eltype(M) <: Real - Mtu = symmetric ? Mv : Vector{T}(undef, ncol) + Mtu = symmetric ? Mv : storagetype(undef, ncol) PreallocatedLinearOperator(Mv, Mtu, Mv, M, symmetric=symmetric, hermitian=true) end From 0cc7b85ad350bdc03b317ec460d13ec8138a8cb5 Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Tue, 24 Mar 2020 14:45:35 -0400 Subject: [PATCH 2/2] Update CI builds for Julia 1.4 --- .cirrus.yml | 1 + .travis.yml | 7 ++++--- appveyor.yml | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 94e17242..54c354d3 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -8,6 +8,7 @@ task: - JULIA_VERSION: 1.1 - JULIA_VERSION: 1.2 - JULIA_VERSION: 1.3 + - JULIA_VERSION: 1.4 - JULIA_VERSION: nightly allow_failures: $JULIA_VERSION == 'nightly' install_script: diff --git a/.travis.yml b/.travis.yml index 4bbcbaaa..123ffcea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ julia: - 1.1 - 1.2 - 1.3 + - 1.4 - nightly matrix: @@ -30,14 +31,14 @@ branches: jobs: include: - stage: Documentation - julia: 1.3 + julia: 1.4 os: linux script: - - julia --project=docs -e 'using Pkg; Pkg.instantiate(); Pkg.add(PackageSpec(path=pwd()))' + - julia --project=docs -e 'using Pkg; Pkg.instantiate(); Pkg.develop(PackageSpec(path=pwd()))' - julia --project=docs docs/make.jl after_success: skip after_success: - - julia -e 'if Sys.islinux() && string(VERSION)[1:3] == "1.3" + - julia -e 'if Sys.islinux() && string(VERSION)[1:3] == "1.4" using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder()); Codecov.submit(process_folder()) end' diff --git a/appveyor.yml b/appveyor.yml index b946b2dc..1e05d572 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,7 @@ environment: - julia_version: 1.1 - julia_version: 1.2 - julia_version: 1.3 + - julia_version: 1.4 - julia_version: nightly platform: