-
Notifications
You must be signed in to change notification settings - Fork 15
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
Attribute functions operating on Qobj
#155
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #155 +/- ##
==========================================
+ Coverage 92.68% 92.89% +0.21%
==========================================
Files 26 27 +1
Lines 1913 1956 +43
==========================================
+ Hits 1773 1817 +44
+ Misses 140 139 -1 ☔ View full report in Codecov by Sentry. |
docs/src/api.md
Outdated
LinearAlgebra.normalize! | ||
LinearAlgebra.inv | ||
LinearAlgebra.diag | ||
sinm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you convert also sinm
and cosm to
LinearAlgebra.sinand
LinearAlgebra.cosand them put
sinmand
cosm` as synonyms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, I didn't notice that there is also matrix sin
and cos
in LinearAlgebra
.
Will implement it right away !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be more efficient compared to the original way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I don’t think that it will work with the LinearAlgebra functions, because we have sparse matrices, and (at least at the time) there wasn’t an implementation for such functions. That’s why I implemented the exp
function by myself. When SparseArrays will export their exp
sin
cos
functions, we can delete our definition of exp
function.
What I mean here is to do the same as the exp
case also for sin
and cos
, and then define sinm
and cosm
as synonyms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, just to make sure I understand correctly, you mean:
LinearAlgebra.sin(A::QuantumObject) = (exp(1im * A) - exp(-1im * A)) / 2im
sinm(A::QuantumObject) = sin(A)
docs/src/api.md
Outdated
tidyup | ||
tidyup! | ||
get_data | ||
get_coherence | ||
partial_transpose | ||
``` | ||
|
||
## [Synonyms for Qobj attribute functions](@id doc-API:Synonyms-for-Qobj-attribute-functions) | ||
```@docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that also isherm
should be moved here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, thanks for the reminder
close #148
This PR supports most of the attribute functions in Python
qutip.Qobj
class.Summary of this PR:
@doc raw
in front of each docstirings.LinearAlgebra
functionsDimensionMismatch
exception ifA.dims != B.dims
isherm
(same asLinearAlgebra.ishermitian
)LinearAlgebra.dot(i, A, j)
: returnsA
is in the type ofOperator
,i
andj
need to beKet
A
is in the type ofSuperOperator
,i
andj
need to beOperatorKet
matrix_element(i, A, j)
(same asLinearAlgebra.dot(i, A, j)
)trans
(same asLinearAlgebra.transpose
)dag
(same asLinearAlgebra.adjoint
)unit
(same asLinearAlgebra.normalize
)normalize(A, p)
andnormalize!(A, p)
to normalize theQuantumObject
so thatp
-norm ofA
equals to unity. Support for the following types ofQuantumObject
:A
isKet
orBra
, defaultp = 2
A
isOperator
, defaultp = 1
expm
(same asLinearAlgebra.exp
)LinearAlgebra.sin
andLinearAlgebra.cos
exp
,expm
,sin
,sinm
,cos
,cosm
forOperator
andSuperOperator
types ofQuantumObject
as inputLinearAlgebra.diag
LinearAlgebra.log
andlogm
(same asLinearAlgebra.log
)purity
:proj
: the projector of aKet
orBra