completed __Calculate AMatrix function in system.py