Need assistance with matrix calculation