Closed prasant94 closed 10 years ago
All looks sensible to me. Will do the new vectorz release now
Hmmm you need the element sum stuff for this right? So that should be in the next release 0.38.0
Can do this later today if you can make sure the Vectorz changes are fully tested etc.
Okay, I'll let you know when I've done that
I've just sent a new PR with more tests for norm. Hopefully, we should be good to release vectorz after that.
OK great. You want any stuff in core.matrix itself by the way? Going to do a core.matrix release today as well
Oh I somehow missed this message. No, nothing in core.matrix. Just ping me when you do the vectorz release. Thanks!
OK new vectorz release should be available now
This should now be good to merge. I slightly changed the PNorm function to handle the infinity norm case.
This line looks suspicious to me:
:else (Math/pow (.elementAbsPowSum m 2) (/ 1 2))))
Seems to do the 2-norm on any other input - why is this? Shouldn't it throw an error if it gets passed a string like "Hedgehog"?
I thought we should perform the default operation when p has an unexpected value.
Do we need to have another case for (norm M :frobenius)
? Won't (norm M 2)
or just (norm M)
cover that?
I prefer errors when we get an unexpected values! Otherwise it is likely to result in undetected bugs in user code.
I don't see any need to support a :frobenius
keyword when 2
will do the trick.
This is the norm function in the current release. It has :frobenius
has the default value of p
. The protocol was probably updated after the release.
(defn norm
"Computes norm of matrix or vector X. p argument specifies p norm.
By default calculates 2 norm for vector and Frobenius norm for matrix.
Special cases of p argument:
Double/POSITIVE_INFINITY - Infinity norm
:frobenius - Frobenius norm
Intended usage: (let [n (norm v 1)] ....)
(let [n (norm v Double/POSITIVE_INFINITY)] ....)
(let [n (norm v)] ....)"
([m]
(cond
(vec? m) (norm m 2)
(matrix? m) (norm m :frobenius)))
([m p]
(cond
(vec? m)(mp/vector-norm m p)
(matrix? m) (mp/matrix-norm m p))))
So this will have to wait till the next core.matrix release is out.
Right so I think worth updating core.matrix to use 2 instead of :frobenius?
The build should pass as soon as there is a new vectorz release.