11import Base: == , * , / , + , - , Broadcast
22import SparseArrays: sparse
3+ import FastExpm: fastExpm
34
45const SparseOpPureType{BL,BR} = Operator{BL,BR,<: SparseMatrixCSC }
56const SparseOpAdjType{BL,BR} = Operator{BL,BR,<: Adjoint{<:Number,<:SparseMatrixCSC} }
@@ -45,6 +46,21 @@ function expect(op::SparseOpPureType{B1,B2}, state::Operator{B2,B2}) where {B1,B
4546 result
4647end
4748
49+ """
50+ exp(op::SparseOpType; opts...)
51+
52+ Operator exponential used, for example, to calculate displacement operators.
53+ Uses [`FastExpm.jl.jl`](https://github.com/fmentink/FastExpm.jl) which will return a sparse
54+ or dense operator depending on which is more efficient.
55+ All optional arguments are passed to `fastExpm` and can be used to specify tolerances.
56+
57+ If you only need the result of the exponential acting on a vector,
58+ consider using much faster implicit methods that do not calculate the entire exponential.
59+ """
60+ function exp (op:: T ; opts... ) where {B,T<: SparseOpType{B,B} }
61+ return SparseOperator (op. basis_l, op. basis_r, fastExpm (op. data; opts... ))
62+ end
63+
4864function permutesystems (rho:: SparseOpPureType{B1,B2} , perm) where {B1<: CompositeBasis ,B2<: CompositeBasis }
4965 @assert length (rho. basis_l. bases) == length (rho. basis_r. bases) == length (perm)
5066 @assert isperm (perm)
@@ -99,4 +115,4 @@ mul!(result::Bra{B2},b::Bra{B1},M::SparseOpPureType{B1,B2},alpha,beta) where {B1
99115/ (op:: EyeOpType ,a:: T ) where {T<: Number } = sparse (op)/ a
100116tensor (a:: EyeOpType , b:: SparseOpType ) = tensor (sparse (a),b)
101117tensor (a:: SparseOpType , b:: EyeOpType ) = tensor (a,sparse (b))
102- tensor (a:: EyeOpType , b:: EyeOpType ) = tensor (sparse (a),sparse (b))
118+ tensor (a:: EyeOpType , b:: EyeOpType ) = tensor (sparse (a),sparse (b))
0 commit comments