Skip to content

Commit

Permalink
a few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran committed Sep 3, 2023
1 parent 0f0be00 commit 0f8e431
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
11 changes: 7 additions & 4 deletions src/manifolds/EssentialManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ Generate the manifold of essential matrices, either the signed (`is_signed=true`
unsigned (`is_signed=false`) variant.
"""
struct EssentialManifold <: AbstractPowerManifold{ℝ,Rotations{3},NestedPowerRepresentation}
struct EssentialManifold <:
AbstractPowerManifold{ℝ,Rotations{TypeParameter{Tuple{3}}},NestedPowerRepresentation}
is_signed::Bool
manifold::Rotations{3}
manifold::Rotations{TypeParameter{Tuple{3}}}
end

EssentialManifold(is_signed::Bool=true) = EssentialManifold(is_signed, Rotations(3))
function EssentialManifold(is_signed::Bool=true)
return EssentialManifold(is_signed, Rotations(3; parameter=:type))
end

@doc raw"""
check_point(M::EssentialManifold, p; kwargs...)
Expand Down Expand Up @@ -482,6 +485,6 @@ pose of camera $i$ $g_i = (R_i,T'_i) ∈ \text{SE}(3)$ and $R_0 ∈ \text{SO}(3)
function vert_proj(M::EssentialManifold, p, X)
return sum(vert_proj.(Ref(M.manifold), p, X))
end
function vert_proj(M::Rotations{3}, p, X)
function vert_proj(M::Rotations{TypeParameter{Tuple{3}}}, p, X)
return (p[3, :]' * get_coordinates(M, p, X, DefaultOrthogonalBasis()))
end
26 changes: 13 additions & 13 deletions src/manifolds/GeneralUnitaryMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ function manifold_dimension(M::GeneralUnitaryMatrices{<:Any,ℂ,DeterminantOneMa
end

@doc raw"""
manifold_volume(::GeneralUnitaryMatrices{n,ℝ,AbsoluteDeterminantOneMatrices}) where {n}
manifold_volume(::GeneralUnitaryMatrices{<:Any,ℝ,AbsoluteDeterminantOneMatrices})
Volume of the manifold of real orthogonal matrices of absolute determinant one. The
formula reads [BoyaSudarshanTilma:2003](@cite):
Expand All @@ -813,13 +813,12 @@ formula reads [BoyaSudarshanTilma:2003](@cite):
\end{cases}
```
"""
function manifold_volume(
::GeneralUnitaryMatrices{n,ℝ,AbsoluteDeterminantOneMatrices},
) where {n}
return 2 * manifold_volume(GeneralUnitaryMatrices{n,ℝ,DeterminantOneMatrices}())
function manifold_volume(M::GeneralUnitaryMatrices{<:Any,ℝ,AbsoluteDeterminantOneMatrices})
n = get_n(M)
return 2 * manifold_volume(GeneralUnitaryMatrices(n, ℝ, DeterminantOneMatrices))
end
@doc raw"""
manifold_volume(::GeneralUnitaryMatrices{n,ℝ,DeterminantOneMatrices}) where {n}
manifold_volume(::GeneralUnitaryMatrices{<:Any,ℝ,DeterminantOneMatrices})
Volume of the manifold of real orthogonal matrices of determinant one. The
formula reads [BoyaSudarshanTilma:2003](@cite):
Expand All @@ -835,7 +834,8 @@ formula reads [BoyaSudarshanTilma:2003](@cite):
It differs from the paper by a factor of `sqrt(2)` due to a different choice of
normalization.
"""
function manifold_volume(::GeneralUnitaryMatrices{n,ℝ,DeterminantOneMatrices}) where {n}
function manifold_volume(M::GeneralUnitaryMatrices{<:Any,ℝ,DeterminantOneMatrices})
n = get_n(M)
vol = 1.0
if n % 2 == 0
k = div(n, 2)
Expand All @@ -856,7 +856,7 @@ function manifold_volume(::GeneralUnitaryMatrices{n,ℝ,DeterminantOneMatrices})
return vol
end
@doc raw"""
manifold_volume(::GeneralUnitaryMatrices{n,ℂ,AbsoluteDeterminantOneMatrices}) where {n}
manifold_volume(::GeneralUnitaryMatrices{<:Any,ℂ,AbsoluteDeterminantOneMatrices})
Volume of the manifold of complex general unitary matrices of absolute determinant one. The
formula reads [BoyaSudarshanTilma:2003](@cite)
Expand All @@ -865,9 +865,8 @@ formula reads [BoyaSudarshanTilma:2003](@cite)
\sqrt{n 2^{n+1}} π^{n(n+1)/2} \prod_{k=1}^{n-1}\frac{1}{k!}
```
"""
function manifold_volume(
::GeneralUnitaryMatrices{n,ℂ,AbsoluteDeterminantOneMatrices},
) where {n}
function manifold_volume(M::GeneralUnitaryMatrices{<:Any,ℂ,AbsoluteDeterminantOneMatrices})
n = get_n(M)
vol = sqrt(n * 2^(n + 1)) * π^(((n + 1) * n) // 2)
kf = 1
for k in 1:(n - 1)
Expand All @@ -877,7 +876,7 @@ function manifold_volume(
return vol
end
@doc raw"""
manifold_volume(::GeneralUnitaryMatrices{n,ℂ,DeterminantOneMatrices}) where {n}
manifold_volume(::GeneralUnitaryMatrices{<:Any,ℂ,DeterminantOneMatrices})
Volume of the manifold of complex general unitary matrices of determinant one. The formula
reads [BoyaSudarshanTilma:2003](@cite)
Expand All @@ -886,7 +885,8 @@ reads [BoyaSudarshanTilma:2003](@cite)
\sqrt{n 2^{n-1}} π^{(n-1)(n+2)/2} \prod_{k=1}^{n-1}\frac{1}{k!}
```
"""
function manifold_volume(::GeneralUnitaryMatrices{n,ℂ,DeterminantOneMatrices}) where {n}
function manifold_volume(M::GeneralUnitaryMatrices{<:Any,ℂ,DeterminantOneMatrices})
n = get_n(M)
vol = sqrt(n * 2^(n - 1)) * π^(((n - 1) * (n + 2)) // 2)
kf = 1
for k in 1:(n - 1)
Expand Down
2 changes: 1 addition & 1 deletion test/manifolds/essential_manifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include("../utils.jl")
p2 = [r1, r3]
p3 = [r2, r2]
@testset "Essential manifold Basics" begin
@test M.manifold == Rotations(3)
@test M.manifold == Rotations(3; parameter=:type)
@test repr(M) == "EssentialManifold(true)"
@test manifold_dimension(M) == 5
@test !is_flat(M)
Expand Down

0 comments on commit 0f8e431

Please sign in to comment.