Memory-efficient optimization over positive semidefinite matrices