Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ See [Wahba's problem](https://en.wikipedia.org/wiki/Wahba%27s_problem) for more
function nearest_rotation(M::StaticMatrix{N,N}) where N
u, _, v = svd(M)
s = sign(det(u * v'))
d = @SVector ones(N-1)
d = @SVector ones(eltype(M), N-1)
R = u * Diagonal(push(d,s)) * v'
return RotMatrix{N}(R)
end
Expand Down
7 changes: 7 additions & 0 deletions test/nearest_rotation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@
@test all(sort(eigvals(Symmetric(V)))[2:end] .≥ 0)
end
end
@testset "return eltype" begin
for T in (Float16, Float32, Float64)
M = @SMatrix randn(T, 3, 3)
R = nearest_rotation(M)
@test eltype(M) == eltype(R)
end
end
end
Loading