-
Notifications
You must be signed in to change notification settings - Fork 43
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
Fixes to adddiag
#186
Fixes to adddiag
#186
Conversation
Codecov ReportAll modified lines are covered by tests ✅
📢 Thoughts on this report? Let us know!. |
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 add a test with an example that would be fixed by the PR? In its current form it's difficult to tell what the PR improves.
Generally, we would like to use _adddiag!
here since _adddiag
would lead to additional undesired allocations.
Yes, but Here is a piece of code that shows the problem: # PR version
my_add_1(a::PDiagMat, b::AbstractPDMat) = PDMat(PDMats._adddiag(Matrix(b), a.diag))
# alternative version
my_add_2(a::PDiagMat, b::AbstractPDMat) = PDMat(PDMats._adddiag!(Matrix(b), a.diag, 1))
# current version
my_add_3(a::PDiagMat, b::AbstractPDMat) = PDMat(PDMats._adddiag!(Matrix(b), a.diag))
a = PDiagMat([1, 2])
A = randn(2, 2)
M = PDMat(A * A')
my_add_1(a, M) # works (with _adddiag)
my_add_2(a, M) # works (with _adddiag!)
my_add_3(a, M) # fails
I guess your point is that one should use |
Yes, my point is that we should rather use something like Can you change the PR to that version and add a currently failing example to the tests? |
Thank you! I added an additional fix and tests in d10d1a7. I'll merge and release when tests pass. |
No description provided.