Gauge duality and low-rank spectral optimization