-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Should L1 and L∞ Norms of Integer Vectors/Matrices be Integers? #575
Comments
I am against. Can't we put the special cases into I think this new feature would not even be breaking. Same story would apply to Rational. And the type stability is still a concern: Relying on constant propagation for source code literals is nice, but who knows how people / macros will structure their code. |
I agree that relying on constant propagation seems a bit iffy here. Perhaps introduce a new |
Why? I don't see why relying on constant propagation would be a big problem here. It's pretty unlikely that the norm wouldn't be constant. Preserving the type is actual the more natural thing in the implementation and we only changed the one and infinity cases for type stability.
We are generally trying to get reduce the number of |
Ok, I guess let's have a PR and see how it goes. |
I completely agree. The reason I proposed this is because both are imho conceptually different things: Can we at least keep the old behavior for Otherwise, any no-inline function / package that passes on a parameter |
@chethega's proposal to keep a floating-point result for |
That's why I proposed Next typing problem: What about a vector of, say, And do we check for overflows? This is also relevant for the
|
👎 on |
I'm not sure how we could do that but, before trying harder, I'd like to challenge the importance of having such an escape hatch. First of all, type stability is always with respect to some input types and the proposed
are true. I would expect both cases to be pretty rare. Do you have some examples where |
would need to become
In other words, all algorithms that accept a I am not so much worrying about real users needing to compute If |
I think this is a crucial observation: constant propagation type stability is limited to cases where the compiler can "see through" all of the code in question. If any code that needs to know that |
What if we went the other way and just made |
What about doing something like this: |
or we could just expose |
What's the advantage of |
This thread is coming back around to JuliaLang/julia#1875. |
One simple alternative would be to point users toward |
It appears
norm()
returns floats for L1 and L∞ norms of integer arrays and matrices. Is this desired behavior? For reference, Python's SymPy returns integers in these cases.Example:
Output:
The text was updated successfully, but these errors were encountered: