Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ julia:
- 1.1
- 1.2
- 1.3
- 1.4
- nightly

matrix:
Expand All @@ -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'
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
50 changes: 24 additions & 26 deletions src/PreallocatedLinearOperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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