A Tutorial on the Optimization of Amplify-and-Forward MIMO Relay Networks