-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
WIP. Norm cleanup. #5545
WIP. Norm cleanup. #5545
Conversation
I actually like having p-norms that are not true vector norms. There are actually genuine use cases for |
@jiahao +1 We all know that these are no "true" norms but in the CS field they are used a lot. This is programming. Every true mathematician has serious problems with statements like |
No problem. I had to introduce some promotion for handling negative I have updated the pull request with the changes. |
return dx * (sum(absx.^p).^(1/p)) | ||
end | ||
n == 0 && return zero(T) | ||
p == 1 && return BLAS.asum(n, x, 1) |
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 should be BLAS.asum(n, x, stride(x, 1))
. As it now accepts strided vector, the stride may not always be 1.
This alsp applies to BLAS.nrm2
below.
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.
A test case should be added to ensure it works for sub(x, 1:2:n)
.
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.
@lindahua Thanks. I forgot the BLAS allows that.
I'll add some tests for the norm
s. Actually there are no specific tests for norm at all. Much testing is still needed for SubArrays
in the BLAS and LAPACK code as the stride
is not always calculated correct. I guess it hasn't been a problem because sub
has been so slow, but this will probably change when people start to use fast views.
Please ignore the QR commits. They have their own PR. I had to rebase on that branch to get the new promotion rules I made there. I have added tests for the norm function and it revealed that the 1 norm was not a norm for |
This one is ready for review. @StefanKarpinski I have tried to measure the cost of using |
So |
No |
So they would differ for a vector |
Everything else looks good. |
looks ready to merge. |
Code review on an empty stomach is clearly not my specialty. |
Devectorize norm calculation and avoid code dublication. Remove negative infinity norm because it violates the triangle inequality.