On Deterministic And Stochastic Optimization Algorithms For Problems With Riemannian Manifold Constraints