@@ -14,32 +14,31 @@ _sprepost(A::AbstractMatrix, B::AbstractMatrix) = kron(transpose(sparse(B)), spa
1414_sprepost (A:: AbstractMatrix , B:: AbstractSparseMatrix ) = kron (transpose (B), sparse (A))
1515_sprepost (A:: AbstractSparseMatrix , B:: AbstractMatrix ) = kron (transpose (sparse (B)), A)
1616_sprepost (A:: AbstractSparseMatrix , B:: AbstractSparseMatrix ) = kron (transpose (B), A)
17+ function _sprepost (A, B) # for any other input types
18+ Id_cache = I (size (A, 1 ))
19+ return _spre (A, Id_cache) * _spost (B, Id_cache)
20+ end
1721
1822# # if input is AbstractSciMLOperator
1923# # some of them are optimized to speed things up
2024# # the rest of the SciMLOperators will just use lazy tensor (and prompt a warning)
2125_spre (A:: MatrixOperator , Id:: AbstractMatrix ) = MatrixOperator (_spre (A. A, Id))
2226_spre (A:: ScaledOperator , Id:: AbstractMatrix ) = ScaledOperator (A. λ, _spre (A. L, Id))
2327_spre (A:: AddedOperator , Id:: AbstractMatrix ) = AddedOperator (map (op -> _spre (op, Id), A. ops))
24- function _spre (A:: AbstractSciMLOperator , Id:: Union{ AbstractMatrix,AbstractSciMLOperator} )
28+ function _spre (A:: AbstractSciMLOperator , Id:: AbstractMatrix )
2529 _lazy_tensor_warning (Id, A)
2630 return kron (Id, A)
2731end
2832
2933_spost (B:: MatrixOperator , Id:: AbstractMatrix ) = MatrixOperator (_spost (B. A, Id))
3034_spost (B:: ScaledOperator , Id:: AbstractMatrix ) = ScaledOperator (B. λ, _spost (B. L, Id))
3135_spost (B:: AddedOperator , Id:: AbstractMatrix ) = AddedOperator (map (op -> _spost (op, Id), B. ops))
32- function _spost (B:: AbstractSciMLOperator , Id:: Union{ AbstractMatrix,AbstractSciMLOperator} )
36+ function _spost (B:: AbstractSciMLOperator , Id:: AbstractMatrix )
3337 B_T = transpose (B)
3438 _lazy_tensor_warning (B_T, Id)
3539 return kron (B_T, Id)
3640end
3741
38- function _sprepost (A:: AbstractSciMLOperator , B:: AbstractSciMLOperator )
39- Id_cache = IdentityOperator (size (A, 1 ))
40- return _spre (A, Id_cache) * _spost (B, Id_cache)
41- end
42-
4342# # intrinsic liouvillian
4443_liouvillian (H:: MT , Id:: AbstractMatrix ) where {MT<: Union{AbstractMatrix,AbstractSciMLOperator} } =
4544 - 1im * (_spre (H, Id) - _spost (H, Id))
0 commit comments