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

Error during perform isposdef on own Matrix type at Julia 1.6 #55404

Closed
AnzhiZhang opened this issue Aug 7, 2024 · 1 comment
Closed

Error during perform isposdef on own Matrix type at Julia 1.6 #55404

AnzhiZhang opened this issue Aug 7, 2024 · 1 comment
Labels
linear algebra Linear algebra

Comments

@AnzhiZhang
Copy link

AnzhiZhang commented Aug 7, 2024

Version

The julia is installed via winget, and 1.6 installed by juliaup.

julia> versioninfo()
Julia Version 1.6.7
Commit 3b76b25b64 (2022-07-19 15:11 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 11th Gen Intel(R) Core(TM) i5-11320H @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, tigerlake)

MRE

using LinearAlgebra
import Base: getindex, size

struct TestMatrix{T} <: AbstractMatrix{T}
    n::Int
end

size(A::TestMatrix) = (A.n, A.n)

getindex(A::TestMatrix{T}, i::Int, j::Int) where {T} = T(i + j)

m = TestMatrix{Int}(5)

isposdef(m)

Output

julia> isposdef(m)
ERROR: MethodError: no method matching cholesky(::Hermitian{Int64, TestMatrix{Int64}}; check=false)
Closest candidates are:
  cholesky(::Number) at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\cholesky.jl:406 got unsupported keyword argument "check"
  cholesky(::Number, ::Symbol) at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\cholesky.jl:406 got unsupported keyword argument "check"    
  cholesky(::Diagonal) at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\diagonal.jl:725 got unsupported keyword argument "check"
  ...
Stacktrace:
 [1] isposdef(A::TestMatrix{Int64})
   @ LinearAlgebra C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\dense.jl:91
 [2] top-level scope
   @ REPL[19]:1

Related Code

1.10

julia> @which cholesky(Hermitian(TestMatrix{Int}(5)))
cholesky(A::AbstractMatrix; ...)
     @ LinearAlgebra ~\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\share\julia\stdlib\v1.10\LinearAlgebra\src\cholesky.jl:401
cholesky(A::AbstractMatrix, ::RowMaximum; tol = 0.0, check::Bool = true) =
    cholesky!(cholcopy(A), RowMaximum(); tol, check)
@deprecate cholesky(A::Union{StridedMatrix,RealHermSymComplexHerm{<:Real,<:StridedMatrix}}, ::Val{true}; tol = 0.0, check::Bool = true) cholesky(A, RowMaximum(); tol, check) false

1.6

julia> @which cholesky(Hermitian(TestMatrix{Int}(5)))
ERROR: no unique matching method found for the specified argument types
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:33
 [2] which(tt::Type)
   @ Base .\reflection.jl:1249
 [3] which(f::Any, t::Any)
   @ Base .\reflection.jl:1238
 [4] top-level scope
   @ REPL[21]:1

julia> @which cholesky(Matrix(Hermitian(TestMatrix{Int}(5))))
cholesky(A::Union{Union{Hermitian{Complex{var"#s809"}, var"#s808"}, Hermitian{var"#s809", var"#s808"}, Symmetric{var"#s809", var"#s808"}} where {var"#s809"<:Real, var"#s808"<:(StridedMatrix{T} where T)}, StridedMatrix{T} where T}) in LinearAlgebra at C:\Users\andya\.julia\juliaup\julia-1.6.7+0.x64.w64.mingw32\share\julia\stdlib\v1.6\LinearAlgebra\src\cholesky.jl:378
cholesky(A::Union{StridedMatrix,RealHermSymComplexHerm{<:Real,<:StridedMatrix}},
    ::Val{false}=Val(false); check::Bool = true) = cholesky!(cholcopy(A); check = check)

There is no method accepts AbstractMatrix in Julia 1.6, so this will raise the above error.

@dkarrasch
Copy link
Member

Yes, relaxing many LinearAlgebra methods to AbstractMatrix was a big step somewhere between v1.6 and v1.10. The necessary changes were non-trivial, and very likely built on progressive changes. So I'd say that this is definitely not going to be fixed (backported to) in v1.6.x. Recommendation: upgrade to v1.10+.

@dkarrasch dkarrasch closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2024
AnzhiZhang added a commit to TypedMatrices/TypedMatrices.jl that referenced this issue Aug 7, 2024
not testing `isposdef` and `inv` before v1.10

See-Also: JuliaLang/julia#55404
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

No branches or pull requests

2 participants