Closed amitjamadagni closed 9 years ago
Thanks for your contribution! It's a good start. Accidentally I thought that adding norms would be a natural next step ...
Regarding your code I have some comments (mostly because we don't have an explicit guide how such functions for QuArrays should work, but I have many implicit ideas ;-)
Base.norm
on the container, which computes the "p-norm". However, for (Hilbert space) operators it is more common to use the Frobenius norm, which you would get via Base.vecnorm
. For vectors this doesn't matter, but for N>1
we should probably use the latter. Note that we need a different norm (i.e. trace
) for density matrices though.norm(qa::QuArray)
(and probably also for CTranspose
).Base.scale!
and then implement multiplication and division in terms of that. You will need a copy
function first (@jrevels Could you add copy
for QuArray
and CTranspose
?).normalize!
function actually makes a copy of the coefficient array.coeffs
was replaced by rawcoeffs
in one of the latest commit?Sorry for the long list of comments. Maybe the more general points should go into some "guideline issue".
@acroy I have worked on the commit. Here are the details :
norm
function which takes QuArray
as a parameter.QuArray
and CTranspose
.normalize
, normalize!
implemented.WIP :
Doubts :
Nice! The point of using rawcoeffs
is that you can use it for QuArrays and CTranspose, i.e., norm
could take qa::Union(QuArray,CTranspose)
and you can simply call rawcoeffs(qa)
.
If you use rawcoeffs
and bases
instead of accessing the fields (qa.coeffs
) you can replace the arguments qa::QuArray
by qa::Union(QuArray,CTranspose)
(I think). Don't forget to add norm
to the import at the top of arraymath.jl. For the test you can basically use the same approach as Jarrett.
@acroy is this good to go ?? Any comments would be helpful.
Looks good now. Thanks! Just one minor point: could you squash your commits into a single one? It's not really necessary but makes the history more readable.
@acroy done. Thanks for all the help.
This is my first attempt at contributing. Though not that significant, please do comment. Thanks.