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

Some * fails because of eltype #181

Open
hyrodium opened this issue Nov 1, 2021 · 3 comments
Open

Some * fails because of eltype #181

hyrodium opened this issue Nov 1, 2021 · 3 comments
Labels

Comments

@hyrodium
Copy link
Collaborator

hyrodium commented Nov 1, 2021

Sample code to produce the issue

julia> r = AngleAxis(1,1,0,0)
3×3 AngleAxis{Int64} with indices SOneTo(3)×SOneTo(3)(1, 1, 0, 0):
 1.0  0.0        0.0
 0.0  0.540302  -0.841471
 0.0  0.841471   0.540302

julia> eltype(r)
Int64

julia> r*[1,2,3]
ERROR: InexactError: Int64(-1.44380834268741)
Stacktrace:
 [1] Int64
   @ ./float.jl:723 [inlined]
 [2] convert
   @ ./number.jl:7 [inlined]
 [3] macro expansion
   @ ~/.julia/packages/StaticArrays/vxjOO/src/util.jl:11 [inlined]
 [4] convert_ntuple
   @ ~/.julia/packages/StaticArrays/vxjOO/src/util.jl:7 [inlined]
 [5] StaticArrays.SVector{3, Int64}(x::Tuple{Float64, Float64, Float64})
   @ StaticArrays ~/.julia/packages/StaticArrays/vxjOO/src/SArray.jl:28
 [6] macro expansion
   @ ~/.julia/packages/StaticArrays/vxjOO/src/matrix_multiply.jl:85 [inlined]
 [7] _mul
   @ ~/.julia/packages/StaticArrays/vxjOO/src/matrix_multiply.jl:67 [inlined]
 [8] *(A::AngleAxis{Int64}, B::Vector{Int64})
   @ StaticArrays ~/.julia/packages/StaticArrays/vxjOO/src/matrix_multiply.jl:8
 [9] top-level scope
   @ REPL[12]:1

How to fix this

#132 is related, but I think it's better to distinguish the type of parameters of rotation and the type of matrix.

@andyferris
Copy link
Contributor

andyferris commented Nov 1, 2021

Hmm, I kinda feel if the input type is Integer we should just call float on it?

@andyferris
Copy link
Contributor

If someone creates AngleAxis{Int} explicitly and it fails, it's not a big problem, it's just not supported. But if someone goes AngleAxis(...) we should give them a compatible type by default. (We need to maintain compatibility with dual numbers, etc).

@hyrodium
Copy link
Collaborator Author

hyrodium commented Nov 1, 2021

Hmm, I kinda feel if the input type is Integer we should just call float on it?

Okay, I'll open a PR to do that.

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

No branches or pull requests

2 participants