-
Notifications
You must be signed in to change notification settings - Fork 6
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
Added Normalize to QuArray. #15
Conversation
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 ;-)
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 :
WIP :
Doubts :
|
|
||
function norm(qarr::QuArray) | ||
if ndims(rawcoeffs(qarr)) == 1 | ||
return norm(rawcoeffs(qarr)) |
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.
You can always use vecnorm
. For N=1
this is the same as norm
(sum of absolute values squared of all elements and square root of that).
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.
My bad !!! Sorry for this. Done editing.
Nice! The point of using |
return QuArray(num*qarr.coeffs, qarr.bases) | ||
end | ||
|
||
function norm(qarr::QuArray) |
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.
You have to use function Base.norm
or import Base: norm
otherwise norm
will only be visible within the module.
If you use |
e23cc47
to
97364c1
Compare
@acroy is this good to go ?? Any comments would be helpful. |
@@ -1,12 +1,13 @@ | |||
import Base: * | |||
import Base: norm, scale, scale! |
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.
Those imports you can just add to the line above.
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. |
Add norm, normalize(!), copy and scale(!) for QuArrays including tests.
This is my first attempt at contributing. Though not that significant, please do comment. Thanks.