Differentiating the QR Decomposition