I am trying to multiply the exponential of a matrix (available as a function which linearly maps the input vector to an output vector), to a given vector, using expv from ExponentialUtilities.jl
using MKL
using LinearAlgebra
using ExponentialUtilities
function matmap(x,aa,bb)
Nx = size(x,1);
y = zeros(eltype(x), Nx);
for gh = 1:Nx
@views y[gh] += aa*x[gh];
if gh>1 && gh<Nx
@views y[gh] += -bb*x[gh-1]-bb*x[gh+1];
end
@views y[1] += -bb*x[2];
@views y[Nx] += -bb*x[Nx-1];
end
return y
end
dt = 0.01;
aa = 0.9; bb = 0.5;
Nx = 1000;
xin = rand(ComplexF64, Nx);
expv(-im*dt,x->matmap(x,aa,bb),xin);
I am getting the error
MethodError: no method matching size(::var"#7#8", ::Int64)
The function `size` exists, but no method is defined for this combination of argument types.
Any ideas on how to implement it correctly? In reality I deal with massive matrices, which I must apply with the function above as they are very sparse. So I cannot use the actual matrices. The example provided here is only a representative case, not the actual matrix I use.