Function to evaluate polynomial with matrix argument added