Implement function to perform QR decomposition