Open
Conversation
Author
|
I'm puzzled why the test is failing, it works for me locally... |
devmotion
reviewed
Oct 2, 2024
|
|
||
| ### dot product | ||
|
|
||
| function LinearAlgebra.dot(x::AbstractVector, a::PDiagMat, y::AbstractVector) |
Member
There was a problem hiding this comment.
Should we restrict this to
Suggested change
| function LinearAlgebra.dot(x::AbstractVector, a::PDiagMat, y::AbstractVector) | |
| function LinearAlgebra.dot(x::AbstractVector{<:Real}, a::PDiagMat, y::AbstractVector{<:Real}) |
?
| end | ||
|
|
||
| ### dot product | ||
|
|
Member
There was a problem hiding this comment.
This has to be put behind a version check:
Suggested change
| # https://github.com/JuliaLang/julia/commit/2425ae760fb5151c5c7dd0554e87c5fc9e24de73 | |
| if VERSION >= v"1.4.0-DEV.92" |
| function LinearAlgebra.dot(x::AbstractVector, a::PDiagMat, y::AbstractVector) | ||
| dot(x, Diagonal(a.diag), y) | ||
| end | ||
|
|
| end | ||
|
|
||
| ### dot product | ||
|
|
Member
There was a problem hiding this comment.
Same here:
Suggested change
| # https://github.com/JuliaLang/julia/commit/2425ae760fb5151c5c7dd0554e87c5fc9e24de73 | |
| if VERSION >= v"1.4.0-DEV.92" |
|
|
||
| ### dot product | ||
|
|
||
| function LinearAlgebra.dot(x::AbstractVector, a::ScalMat, y::AbstractVector) |
Member
There was a problem hiding this comment.
We should check that the dimensions match:
Suggested change
| function LinearAlgebra.dot(x::AbstractVector, a::ScalMat, y::AbstractVector) | |
| function LinearAlgebra.dot(x::AbstractVector, a::ScalMat, y::AbstractVector) | |
| @check_argdims LinearAlgebra.checksquare(a) == length(x) == length(y) |
| ### dot product | ||
|
|
||
| function LinearAlgebra.dot(x::AbstractVector, a::ScalMat, y::AbstractVector) | ||
| dot(x, UniformScaling(a.value), y) |
Member
There was a problem hiding this comment.
I guess even simpler would be
Suggested change
| dot(x, UniformScaling(a.value), y) | |
| a.value * dot(x, y) |
?
|
|
||
| function LinearAlgebra.dot(x::AbstractVector, a::ScalMat, y::AbstractVector) | ||
| dot(x, UniformScaling(a.value), y) | ||
| end |
| @test isposdef(PDMat([1.0 0.0; 0.0 1.0])) | ||
| @test isposdef(PDiagMat([1.0, 1.0])) | ||
| @test isposdef(ScalMat(2, 3.0)) | ||
|
|
Member
There was a problem hiding this comment.
Suggested change
| # https://github.com/JuliaLang/julia/commit/2425ae760fb5151c5c7dd0554e87c5fc9e24de73 | |
| if VERSION >= v"1.4.0-DEV.92" |
|
|
||
| @test dot(x, pm1, y) ≈ dot(x, Matrix(pm1), y) | ||
| @test dot(x, pm2, y) ≈ dot(x, Matrix(pm2), y) | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, calling
LinearAlgebra.dot(x, A, y)for anAbstractPDMatAfalls back to the default implementation forA::AbstractMatrix. Especially forA::PDiagMatandA::ScalMatthat is pretty wasteful, so I implemented the three-argumentdotfunction in terms ofLinearAlgebra.DiagonalandLinearAlgebra.UniformScaling, respectively.Does it make sense to implement a special case for
A::PDMatas well? Something similar to thequadfunction?Also, is the test I added at a suitable location?