Skip to content

Commit

Permalink
expmv now supports any linear operator for A
Browse files Browse the repository at this point in the history
  • Loading branch information
matteoacrossi committed Sep 3, 2018
1 parent afd3d4a commit de10520
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/expmv_fun.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ function expmv(t::Number, A, b::VecOrMat; M = nothing,
precision = "double", shift = false, full_term = false)
n = size(A, 1)

if shift == true && !hasmethod(tr, typeof(A))
shift = false
@warn "Shift set to false as $(typeof(A)) doesn't support tr"
end

mu = 0.
if shift
mu = tr(A)/n
A = A - mu*I
Expand Down
13 changes: 10 additions & 3 deletions src/expmv_tspan.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
using LinearAlgebra
using SparseArrays

function expmv(t::StepRangeLen, A::SparseMatrixCSC, b::Vector;
M = nothing, precision = "double", shift = true)
function expmv(t::StepRangeLen, A, b::Vector;
M = nothing, precision = "double", shift = false)

t0 = Float64(t.ref)
tmax = Float64(t.ref + (t.len - 1.) * t.step)
q = t.len - 1
n = size(A, 1)

force_estm = false; temp = (tmax -t0)*norm(A, 1);
if shift == true && !hasmethod(tr, typeof(A))
shift = false
@warn "Shift set to false as $(typeof(A)) doesn't support tr"
end

force_estm = !hasmethod(opnorm, Tuple{typeof(A), typeof(1)})
temp = (tmax - t0) * normAm(A, 1);

if (precision == "single" || precision == "half" && temp > 85.496) || ( precision == "double" && temp > 63.152)
force_estm = true;
end
Expand Down

0 comments on commit de10520

Please sign in to comment.