-
Notifications
You must be signed in to change notification settings - Fork 44
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
Julia 0.6 support / updates to match StaticArrays 0.4.0 #25
Changes from 12 commits
385fbf1
2630fc4
f87aa09
52d109e
43343c9
bd15ab9
f24f6f1
e2aa085
8c067e7
955fbbf
1eb9545
aae8f8f
0dbaee9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
julia 0.5 | ||
StaticArrays 0.3.0 | ||
julia 0.6- | ||
StaticArrays 0.4.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module SimpleSymbolic | ||
|
||
immutable S | ||
struct S | ||
x::Any | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
""" | ||
abstract Rotation{N,T} <: StaticMatrix{T} | ||
abstract type Rotation{N,T} <: StaticMatrix{T} | ||
|
||
An abstract type representing `N`-dimensional rotations. More abstractly, they represent | ||
unitary (orthogonal) `N`×`N` matrices. | ||
""" | ||
abstract Rotation{N,T} <: StaticMatrix{T} | ||
abstract type Rotation{N,T} <: StaticMatrix{T} end | ||
|
||
Base.@pure StaticArrays.Size{N}(::Type{Rotation{N}}) = Size(N,N) | ||
Base.@pure StaticArrays.Size{N,T}(::Type{Rotation{N,T}}) = Size(N,N) | ||
|
@@ -67,15 +67,17 @@ end | |
################################################################################ | ||
################################################################################ | ||
""" | ||
immutable RotMatrix{N,T} <: Rotation{N,T} | ||
struct RotMatrix{N,T} <: Rotation{N,T} | ||
|
||
A statically-sized, N×N unitary (orthogonal) matrix. | ||
|
||
Note: the orthonormality of the input matrix is *not* checked by the constructor. | ||
""" | ||
immutable RotMatrix{N,T,L} <: Rotation{N,T} # which is <: AbstractMatrix{T} | ||
struct RotMatrix{N,T,L} <: Rotation{N,T} # which is <: AbstractMatrix{T} | ||
mat::SMatrix{N, N, T, L} # The final parameter to SMatrix is the "length" of the matrix, 3 × 3 = 9 | ||
RotMatrix{N,T,L}(x::AbstractArray) where {N,T,L} = new{N,T,L}(convert(SMatrix{N,N,T,L}, x)) | ||
end | ||
RotMatrix(x::SMatrix{N,N,T,L}) where {N,T,L} = RotMatrix{N,T,L}(x) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then we probably need to redefine the default outer constructor (which is lost because we defined an inner constructor). RotMatrix(x::SMatrix{N.N,T,L}) where {N,T,L} = RotMatrix{N,T,L}(x) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, we could have a series of constructors to populate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding RotMatrix(x::SMatrix{N,N,T,L}) where {N,T,L} = RotMatrix{N,T,L}(x) in addition to the inner constructor does fix the ambiguity and stack overflow error; sorry, I should have tried that before commenting earlier. |
||
# These functions (plus size) are enough to satisfy the entire StaticArrays interface: | ||
# @inline (::Type{R}){R<:RotMatrix}(t::Tuple) = error("No precise constructor found. Length of input was $(length(t)).") | ||
|
@@ -88,7 +90,7 @@ for N = 2:3 | |
@inline (::Type{RotMatrix{$N,T,$L}}){T}(t::NTuple{$L}) = RotMatrix(SMatrix{$N,$N,T}(t)) | ||
end | ||
end | ||
Base.@propagate_inbounds Base.getindex(r::RotMatrix, i::Integer) = r.mat[i] | ||
Base.@propagate_inbounds Base.getindex(r::RotMatrix, i::Int) = r.mat[i] | ||
|
||
@inline (::Type{RotMatrix})(θ::Real) = RotMatrix(@SMatrix [cos(θ) -sin(θ); sin(θ) cos(θ)]) | ||
@inline (::Type{RotMatrix{2}})(θ::Real) = RotMatrix(@SMatrix [cos(θ) -sin(θ); sin(θ) cos(θ)]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,8 @@ function jacobian(::Type{RotMatrix}, q::Quat) | |
# then R = RotMatrix(q) = RotMatrix(s * qhat) = s * RotMatrix(qhat) | ||
|
||
# get R(q) | ||
R = q[:] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For future reference, this is the only place where JuliaArrays/StaticArrays.jl#128 was causing issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed upstream, will need a StaticArrays-0.4.1 release though |
||
# R = q[:] # FIXME: broken with StaticArrays 0.4.0 due to https://github.com/JuliaArrays/StaticArrays.jl/issues/128 | ||
R = SVector(convert(Tuple, q)) | ||
|
||
# solve d(s*R)/dQ (because its easy) | ||
dsRdQ = @SMatrix [ 2*q.w 2*q.x -2*q.y -2*q.z ; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So should we override the default constructors to fix the ambiguity?
Something like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a stack overflow error: