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 when using svd on a matrix #1277

Open
AntonioMoralesPerez opened this issue Sep 17, 2024 · 4 comments
Open

Error when using svd on a matrix #1277

AntonioMoralesPerez opened this issue Sep 17, 2024 · 4 comments

Comments

@AntonioMoralesPerez
Copy link

Hi,

I'm seeing the following error on my laptop (versioninfo below):

julia> using StaticArrays
julia> A = @SMatrix rand(3,3)
julia> StaticArrays.svd(A)
 ERROR: MethodError: no method matching unsafe_convert(::Type{Ptr{Int32}}, ::Base.RefValue{Int64})

Closest candidates are:
  unsafe_convert(::Type{Ptr{T}}, ::SubArray{T, N, P, <:Tuple{Vararg{Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8, AbstractRange{<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}}}}}}) where {T, N, P}
   @ Base subarray.jl:471
  unsafe_convert(::Type{Ptr{T}}, ::SubArray{T, N, P, <:Tuple{Vararg{Union{AbstractRange{<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}}, Base.ReshapedArray{T, N, A, Tuple{}} where {T, N, A<:AbstractUnitRange}, Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}}}}) where {T, N, P}
   @ Base reshapedarray.jl:310
  unsafe_convert(::Type{T}, ::T) where T<:Ptr
   @ Base essentials.jl:547
  ...

Stacktrace:
 [1] _svd(A::SMatrix{3, 3, Float64, 9}, full::Val{false})
   @ StaticArrays ~/.julia/packages/StaticArrays/MSJcA/src/blas.jl:108
 [2] svd(A::SMatrix{3, 3, Float64, 9})
   @ StaticArrays ~/.julia/packages/StaticArrays/MSJcA/src/svd.jl:36
 [3] top-level scope
   @ REPL[11]:1

I am wondering if this could be related to #1259.

It does work if I pin the version to [email protected]

Version info:

julia> versioninfo()
 Julia Version 1.10.5
Commit 6f3fdf7b36 (2024-08-27 14:19 UTC)
Build Info:
  Built by Homebrew (v1.10.5)

    Note: This is an unofficial build, please report bugs to the project
    responsible for this build and not to the Julia project unless you can
    reproduce the issue using official builds available at https://julialang.org/downloads

Platform Info:
  OS: macOS (arm64-apple-darwin23.4.0)
  CPU: 8 × Apple M2
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

Cc. @ronisbr & @thchr.

@ronisbr
Copy link
Contributor

ronisbr commented Sep 17, 2024

Hi @AntonioMoralesPerez !

I have no clue! It is working perfectly here:

julia> using StaticArrays

julia> A = @SMatrix rand(3,3)
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 0.341047  0.0916404  0.150692
 0.835556  0.34313    0.35069
 0.592661  0.315842   0.396501

julia> StaticArrays.svd(A)
StaticArrays.SVD{Float64, SMatrix{3, 3, Float64, 9}, SVector{3, Float64}, SMatrix{3, 3, Float64, 9}}([-0.29344199829684536 -0.32156522093331963 -0.900270849423472; -0.7462705141168243 -0.5115129374711869 0.42595168101488756; -0.5974714331207518 0.7968377020985536 -0.08987526422176448], [1.2956166466484553, 0.11892665553001668, 0.04175903739656561], [-0.8318247838263677 -0.36404705141675087 -0.41897168563876275; -0.5449739256390875 0.39259973336737813 0.7408568483407479; -0.10521857909009702 0.8445917319715089 -0.5249703390665303])

I am also using Apple's M-series.

@ronisbr
Copy link
Contributor

ronisbr commented Sep 17, 2024

Btw, is it possible to try downloading Julia using the official tarball or installing using juliaup instead using the version by Homebrew?

@AntonioMoralesPerez
Copy link
Author

Hi @ronisbr ,

Surprisingly enough it seems to work using the official Julia tarball:

julia> using StaticArrays

julia> A = @SMatrix rand(3,3)
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 0.512645  0.953802   0.629615
 0.995764  0.0287175  0.729227
 0.731023  0.494506   0.157342

julia> StaticArrays.svd(A)
StaticArrays.SVD{Float64, SMatrix{3, 3, Float64, 9}, SVector{3, Float64}, SMatrix{3, 3, Float64, 9}}([-0.6380683278085035 0.6566767714075241 -0.40205027912121855; -0.6120520471716466 -0.7493802928543407 -0.2526291120091635; -0.4671842255477555 0.08488106134663963 0.880076192624259], [1.7937586409797588, 0.743925985198128, 0.3546712794328673], [-0.7125174398131923 -0.4778752328355803 -0.5137646930301784; -0.4671348450108683 0.8694323848515718 -0.16084888792894964; 0.5235493620841549 0.12538975242677453 -0.8427179097703019])

Maybe there is some sort of trouble with the Hombrew version? I will stick for now with the official tarball.

New version info:

julia> versioninfo()
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M2
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

@ronisbr
Copy link
Contributor

ronisbr commented Sep 17, 2024

My guess is that they are building some required library (like openblas) with an option that is triggering the error. Can you please open an issue in homebrew?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants