Added code to calculate alpha matrices