I have the following matrix:

$$
 \begin{bmatrix}
 7 & -1\\
 2 & 4 \\
 \end{bmatrix}
$$

I would like to raise it to the power n. I understand the method with finding the matrices P and D through eigenvalues and corresponding eigenvectors. However, my question is, if I transform the above matrix into a diagonal matrix through row operation to obtain the following matrix:

$$
 \begin{bmatrix}
 1 & 0\\
 0 & -15 \\
 \end{bmatrix}
$$

Could I treat this the same way one would treat the diagonal matrix D, where the entries in the diagonal are the eigenvalues? As in, could I just raise each entry of the above diagonal matrix to the power n instead of doing the method with eigenvalues and finding matrices P, inverse P and D, then raising D to the power n and multiplying them? I wasn't sure if we could treat all diagonal matrices this way.

Thank you!