Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dagger(operator)^2 does not work #106

Closed
Krastanov opened this issue Jun 17, 2023 · 2 comments · Fixed by #107
Closed

dagger(operator)^2 does not work #106

Krastanov opened this issue Jun 17, 2023 · 2 comments · Fixed by #107

Comments

@Krastanov
Copy link
Collaborator

julia> function gen()
           b_fock = FockBasis(10)
           a = destroy(b_fock)
           return dagger(a)^2
       end
gen (generic function with 1 method)

julia> gen()
ERROR: MethodError: Cannot `convert` an object of type 
  Operator{FockBasis{Int64{}},FockBasis{Int64{}},LinearAlgebra.Adjoint{ComplexF64, SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}} to an object of type 
  Operator{FockBasis{Int64{}},FockBasis{Int64{}},SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}
@Krastanov
Copy link
Collaborator Author

julia> a = destroy(FockBasis(5));

julia> Base.power_by_squaring(a', 2)
ERROR: MethodError: Cannot `convert` an object of type 
  Operator{FockBasis{Int64{}},FockBasis{Int64{}},LinearAlgebra.Adjoint{ComplexF64, SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}} to an object of type 
  Operator{FockBasis{Int64{}},FockBasis{Int64{}},SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}

Closest candidates are:
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:64
  Operator{BL, BR, T}(::BL, ::BR, ::T) where {BL, BR, T}
   @ QuantumOpticsBase ~/Documents/ScratchSpace/quantumjulia/QuantumOpticsBase.jl/src/operators_dense.jl:15

Stacktrace:
 [1] to_power_type(x::Operator{FockBasis{Int64}, FockBasis{Int64}, LinearAlgebra.Adjoint{ComplexF64, SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}})
   @ Base ./intfuncs.jl:248
 [2] power_by_squaring(x_::Operator{FockBasis{Int64}, FockBasis{Int64}, LinearAlgebra.Adjoint{ComplexF64, SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}}, p::Int64)
   @ Base ./intfuncs.jl:263
 [3] top-level scope
   @ REPL[37]:1

julia> Base.to_power_type(a')
ERROR: MethodError: Cannot `convert` an object of type 
  Operator{FockBasis{Int64{}},FockBasis{Int64{}},LinearAlgebra.Adjoint{ComplexF64, SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}} to an object of type 
  Operator{FockBasis{Int64{}},FockBasis{Int64{}},SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}

Closest candidates are:
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:64
  Operator{BL, BR, T}(::BL, ::BR, ::T) where {BL, BR, T}
   @ QuantumOpticsBase ~/Documents/ScratchSpace/quantumjulia/QuantumOpticsBase.jl/src/operators_dense.jl:15

Stacktrace:
 [1] to_power_type(x::Operator{FockBasis{Int64}, FockBasis{Int64}, LinearAlgebra.Adjoint{ComplexF64, SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}})
   @ Base ./intfuncs.jl:248
 [2] top-level scope
   @ REPL[38]:1

@Krastanov
Copy link
Collaborator Author

Here is the underlying error:

julia> a = destroy(FockBasis(5));

julia> convert(Base._return_type(*, Tuple{typeof(a.data'), typeof(a.data')}), a.data')
6×6 SparseArrays.SparseMatrixCSC{ComplexF64, Int64} with 5 stored entries:
     ⋅              ⋅              ⋅          ⋅              ⋅          ⋅    
 1.0-0.0im          ⋅              ⋅          ⋅              ⋅          ⋅    
     ⋅      1.41421-0.0im          ⋅          ⋅              ⋅          ⋅    
     ⋅              ⋅      1.73205-0.0im      ⋅              ⋅          ⋅    
     ⋅              ⋅              ⋅      2.0-0.0im          ⋅          ⋅    
     ⋅              ⋅              ⋅          ⋅      2.23607-0.0im      ⋅    

julia> convert(Base._return_type(*, Tuple{typeof(a'), typeof(a')}), a')
ERROR: MethodError: Cannot `convert` an object of type 
  Operator{FockBasis{Int64{}},FockBasis{Int64{}},LinearAlgebra.Adjoint{ComplexF64, SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}} to an object of type 
  Operator{FockBasis{Int64{}},FockBasis{Int64{}},SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant