-
-
Notifications
You must be signed in to change notification settings - Fork 35
type stability of left division #1475
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1475 +/- ##
==========================================
- Coverage 93.90% 93.90% -0.01%
==========================================
Files 34 34
Lines 15930 15937 +7
==========================================
+ Hits 14959 14965 +6
- Misses 971 972 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I assume that the |
|
Sorry, no, they always copy. I'm just reusing the implementations of |
src/generic.jl
Outdated
| return UpperTriangular(A) \ B | ||
| end | ||
| return lu(A) \ B | ||
| return _lu(_lucopy(A, T)) \ B |
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.
I think the idea of this generic method is to dispatch to an optimized lu method for a custom AbstractArray, if one exists. Using the internal _lu here would bypass such dispatches. E.g.: SparseMatrixCSC has an optimized lu implementation.
We may add special cases for StridedMatrixes, if this helps with type stability.
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.
I see. What's the solution, though? lu(copy_similar(A, T))? That would create yet another copy.
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.
I can just do a hack maybecopy(A, ::Type{T}) where {T} = eltype(A) <: T ? A : copy_similar(A, T), but surely there must be a better way to do it.
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.
Can you change the UpperTriangular case instead?
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.
Why? That case is working correctly.
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.
Ok, I've used a slightly better version of the hack, I think it's fine, it doesn't affect the dispatch, and only copies when necessary.
|
I've also fixed the specialized vector methods, because even though they were not type unstable they were returning an answer of the incorrect type. Luckily this involved less copying, not more. |
Closes #930