acroy / Expokit.jl

Julia implementation of EXPOKIT routines
Other
26 stars 11 forks source link

Cannot exponentiate complex matrices #3

Closed marcusps closed 9 years ago

marcusps commented 9 years ago

In Julia v0.3.5 I get:

In[41]: expmv(π/4,[0 -1im; 1im 0]|>sparse,[1.;0.])
InexactError()
while loading In[41], in expression starting on line 1

 in setindex! at array.jl:307
 in A_mul_B! at linalg/sparse.jl:24
 in expmv! at /home/msilva/.julia/v0.3/Expokit/src/Expokit.jl:71
 in expmv! at /home/msilva/.julia/v0.3/Expokit/src/Expokit.jl:20
acroy commented 9 years ago

I think expmv(π/4,[0 -1im; 1im 0]|>sparse, complex([1.;0.])) should work. The problem is that we don't promote the output vector(s) to the have right element type (in this case Complex128).

acroy commented 9 years ago

I guess for the mutating versions expmv! one has to rely on the user to provide appropriate vectors as input. But expmv should try to construct the output vector with elements of type promote_type(promote_type(eltype(A),eltype(vec)), typeof(tau)) or such.

marcusps commented 9 years ago

I'll submit a patch.