Skip to content
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

Define size for SVD #28439

Merged
merged 3 commits into from
Aug 5, 2018
Merged

Define size for SVD #28439

merged 3 commits into from
Aug 5, 2018

Conversation

mohamed82008
Copy link
Contributor

Closes #28438. And first PR!

Closes JuliaLang#28438. And first PR!
@ararslan
Copy link
Member

ararslan commented Aug 4, 2018

Welcome to Julia! Given @fredrikekre's comment in the linked issue, is this pull request still relevant? If so, it would be great if you could add a test.

@ararslan ararslan added linear algebra Linear algebra needs tests Unit tests are required for this change labels Aug 4, 2018
@mohamed82008
Copy link
Contributor Author

My motivation for this PR was:

julia> using LinearAlgebra

julia> ldiv!(zeros(3), svd(rand(3,3)), rand(3))
ERROR: MethodError: no method matching size(::SVD{Float64,Float64,Array{Float64,2}}, ::Int64)
Closest candidates are:
  size(::Any, ::Integer, ::Integer) at deprecated.jl:53
  size(::Any, ::Integer, ::Integer, ::Integer...) at deprecated.jl:53
  size(::BitArray{1}, ::Any) at bitarray.jl:74
  ...
Stacktrace:
 [1] ldiv!(::Array{Float64,1}, ::SVD{Float64,Float64,Array{Float64,2}}, ::Array{Float64,1}) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\LinearAlgebra\src\factorization.jl:101
 [2] top-level scope at none:0

The above works after defining size for SVD. So I think it's relevant yes. size is defined for QR and Cholesky factorizations but not SVD.

@Keno
Copy link
Member

Keno commented Aug 4, 2018

One of the linear algebra folks will have to comment if this makes sense, but it would be good to add the motivating failure as a test case.

@andreasnoack
Copy link
Member

This is right. For factorizations, size is the size of the factorized matrix. Iteration is just to be able to deconstruct the factorization and shouldn't generally be used.

It looks like there is some whitespace somewhere in the diff which is causing the tests to fail.

@@ -29,6 +29,8 @@ using LinearAlgebra: BlasComplex, BlasFloat, BlasReal, QRPivoted
# matrices from the factorization as expected.
@test sf1.U*Diagonal(sf1.S)*sf1.Vt' ≊ m1
@test sf2.U*Diagonal(sf2.S)*sf2.Vt' ≊ m2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation here is making CI fail, as it is superfluous. Extra white spaces are not allowed as they make diffs harder to read.

@andreasnoack andreasnoack merged commit e0876d2 into JuliaLang:master Aug 5, 2018
@ararslan
Copy link
Member

ararslan commented Aug 5, 2018

Should this be included in 0.7?

@andreasnoack
Copy link
Member

Should this be included in 0.7?

Yes, I've added the backport label.

@ararslan ararslan removed the needs tests Unit tests are required for this change label Aug 5, 2018
ararslan pushed a commit that referenced this pull request Aug 5, 2018
* Define `size` for SVD

Closes #28438. And first PR!

* add test to 3-arg `ldiv!` on `SVD` which calls `size`

* github pampering

(cherry picked from commit e0876d2)
KristofferC pushed a commit that referenced this pull request Feb 11, 2019
* Define `size` for SVD

Closes #28438. And first PR!

* add test to 3-arg `ldiv!` on `SVD` which calls `size`

* github pampering
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants