A Template Matrix Class