Skip to content

Commit

Permalink
Fix some 0.7 dependency warnings in function signatures
Browse files Browse the repository at this point in the history
Fix 0.7 depwarns in function signatures.
  • Loading branch information
mforets authored and acroy committed Aug 11, 2018
1 parent 5faa89c commit 1e462ba
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
15 changes: 11 additions & 4 deletions src/Expokit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ R.B. Sidje, ACM Trans. Math. Softw., 24(1):130-156, 1998 (or its
"""
module Expokit

using Compat
import Compat.view
using Compat, Compat.LinearAlgebra
import Compat:view, String
const LinearAlgebra = Compat.LinearAlgebra

const axpy! = Base.LinAlg.axpy!
const expm! = Base.LinAlg.expm!
if VERSION < v"0.7-"
nothing
else
using LinearAlgebra, SparseArrays
end

const axpy! = LinearAlgebra.axpy!
const expm! = LinearAlgebra.expm!

include("expmv.jl")
include("padm.jl")
Expand Down
12 changes: 6 additions & 6 deletions src/chbv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,28 @@ Calculate matrix exponential acting on some vector using the Chebyshev method.
This Julia implementation is based on Expokit's CHBV Matlab code by
Roger B. Sidje, see below.
---
---
y = chbv( H, x )
CHBV computes the direct action of the matrix exponential on
a vector: y = exp(H) * x. It uses the partial fraction expansion of
the uniform rational Chebyshev approximation of type (14,14).
About 14-digit accuracy is expected if the matrix H is symmetric
About 14-digit accuracy is expected if the matrix H is symmetric
negative definite. The algorithm may behave poorly otherwise.
See also PADM, EXPOKIT.
Roger B. Sidje (rbs@maths.uq.edu.au)
EXPOKIT: Software Package for Computing Matrix Exponentials.
ACM - Transactions On Mathematical Software, 24(1):130-156, 1998
"""
function chbv{T}(A, vec::Vector{T})
function chbv(A, vec::Vector{T}) where {T}
result = convert(Vector{promote_type(eltype(A), T)}, copy(vec))
return chbv!(result, A, vec)
end

chbv!{T}(A, vec::Vector{T}) = chbv!(vec, A, copy(vec))
chbv!(A, vec::Vector{T}) where {T} = chbv!(vec, A, copy(vec))

function chbv!{T<:Real}(w::Vector{T}, A, vec::Vector{T})
function chbv!(w::Vector{T}, A, vec::Vector{T}) where {T<:Real}
p = min(length(θ), length(α))
scale!(copy!(w, vec), α0)
@inbounds for i = 1:p
Expand All @@ -84,7 +84,7 @@ function chbv!{T<:Real}(w::Vector{T}, A, vec::Vector{T})
return w
end

function chbv!{T<:Complex}(w::Vector{T}, A, vec::Vector{T})
function chbv!(w::Vector{T}, A, vec::Vector{T}) where {T<:Complex}
p = min(length(θ), length(α))
scale!(copy!(w, vec), α0)
t = [θ; θconj]
Expand Down
17 changes: 9 additions & 8 deletions src/expmv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,25 @@ using the Krylov subspace approximation.
See R.B. Sidje, ACM Trans. Math. Softw., 24(1):130-156, 1998
and http://www.maths.uq.edu.au/expokit
"""
function expmv{T}( t::Number,
function expmv( t::Number,
A, vec::Vector{T};
tol::Real=1e-7,
m::Int=min(30, size(A, 1)),
norm=Base.norm, anorm=default_anorm(A))
norm=Base.norm, anorm=default_anorm(A)) where {T}

result = convert(Vector{promote_type(eltype(A), T, typeof(t))}, copy(vec))
expmv!(t, A, result; tol=tol, m=m, norm=norm, anorm=anorm)
return result
end

expmv!{T}( t::Number,
expmv!( t::Number,
A, vec::Vector{T};
tol::Real=1e-7,
m::Int=min(30,size(A,1)),
norm=Base.norm, anorm=default_anorm(A)) = expmv!(vec, t, A, vec; tol=tol, m=m, norm=norm, anorm=anorm)
norm=Base.norm, anorm=default_anorm(A)) where {T} = expmv!(vec, t, A, vec; tol=tol, m=m, norm=norm, anorm=anorm)

function expmv!{T}(w::Vector{T}, t::Number, A, vec::Vector{T};
tol::Real=1e-7, m::Int=min(30,size(A,1)), norm=Base.norm, anorm=default_anorm(A))
function expmv!(w::Vector{T}, t::Number, A, vec::Vector{T};
tol::Real=1e-7, m::Int=min(30,size(A,1)), norm=Base.norm, anorm=default_anorm(A)) where {T}

if size(vec,1) != size(A,2)
error("dimension mismatch")
Expand All @@ -59,8 +60,8 @@ function expmv!{T}(w::Vector{T}, t::Number, A, vec::Vector{T};
# estimate first time-step and round to two significant digits
beta = norm(vec)
r = 1/m
fact = (((m+1)/exp(1.))^(m+1))*sqrt(2.*pi*(m+1))
tau = (1./anorm)*((fact*tol)/(4.*beta*anorm))^r
fact = (((m+1)/exp(1.0))^(m+1))*sqrt(2.0*pi*(m+1))
tau = (1.0/anorm)*((fact*tol)/(4.0*beta*anorm))^r
tau = signif(tau, 2)

# storage for Krylov subspace vectors
Expand Down
18 changes: 10 additions & 8 deletions src/phimv.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export phimv, phimv!

"""
phimv{T}(t, A, u, vec; [tol], [m], [norm])
phimv{T}(t, A, u, vec; [tol], [m], [norm], [anorm])
Calculate the solution of a nonhomogeneous linear ODE problem with constant input
``w = e^{tA}v + tφ(tA)u`` using the Krylov subspace approximation.
Expand Down Expand Up @@ -31,24 +31,26 @@ Calculate the solution of a nonhomogeneous linear ODE problem with constant inpu
EXPOKIT: Software Package for Computing Matrix Exponentials.
ACM - Transactions On Mathematical Software, 24(1):130-156, 1998
"""
function phimv{T}( t::Number,

function phimv( t::Number,
A, u::Vector{T}, vec::Vector{T};
tol::Real=1e-7,
m::Int=min(30, size(A, 1)),
norm=Base.norm, anorm=default_anorm(A))
norm=Base.norm, anorm=default_anorm(A)) where {T}

result = convert(Vector{promote_type(eltype(A), T, typeof(t))}, copy(vec))
phimv!(t, A, u, result; tol=tol, m=m, norm=norm, anorm=anorm)
return result
end

phimv!{T}( t::Number,
phimv!( t::Number,
A, u::Vector{T}, vec::Vector{T};
tol::Real=1e-7,
m::Int=min(30, size(A, 1)),
norm=Base.norm, anorm=default_anorm(A)) = phimv!(vec, t, A, u, vec; tol=tol, m=m, norm=norm, anorm=anorm)
norm=Base.norm, anorm=default_anorm(A)) where {T} = phimv!(vec, t, A, u, vec; tol=tol, m=m, norm=norm, anorm=anorm)

function phimv!{T}( w::Vector{T}, t::Number, A, u::Vector{T}, vec::Vector{T};
tol::Real=1e-7, m::Int=min(30, size(A, 1)), norm=Base.norm, anorm=default_anorm(A))
function phimv!( w::Vector{T}, t::Number, A, u::Vector{T}, vec::Vector{T};
tol::Real=1e-7, m::Int=min(30, size(A, 1)), norm=Base.norm, anorm=default_anorm(A)) where {T}

if size(vec, 1) != size(A, 2)
error("dimension mismatch")
Expand All @@ -67,7 +69,7 @@ function phimv!{T}( w::Vector{T}, t::Number, A, u::Vector{T}, vec::Vector{T};
beta = norm(A*vec + u)
r = 1/m
fact = (((m+1)/exp(1))^(m+1))*sqrt(2*pi*(m+1))
tau = (1./anorm)*((fact*tol)/(4.*beta*anorm))^r
tau = (1.0/anorm)*((fact*tol)/(4.0*beta*anorm))^r
tau = signif(tau, 2)

# storage for Krylov subspace vectors
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Expokit
using Base.Test
using Compat.Test

struct LinearOp
m
Expand Down

0 comments on commit 1e462ba

Please sign in to comment.