Created
February 12, 2018 17:13
-
-
Save kersulis/b7c800ff476c5223bdd5a4aa4e09de89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Optim | |
import Optim.retract! | |
import Optim.project_tangent! | |
struct SphereSubspaceComplementIntersection <: Manifold | |
U::Matrix | |
proj::Matrix | |
end | |
function SphereSubspaceComplementIntersection(U) | |
Q = qr(U)[1] | |
SphereSubspaceComplementIntersection(U, eye(size(U, 1)) - Q*(Q')) | |
end | |
function retract!(S::SphereSubspaceComplementIntersection, X) | |
X[:] = S.proj*X | |
normalize!(X) | |
end | |
function project_tangent!(S::SphereSubspaceComplementIntersection, G, X) | |
G .= S.proj*(G .- real(vecdot(X,G)).*X) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment