i got a square matrix

and i need to calculate the matrix when it set by some power

i tried this one

it didnt work

??

Code:for (tndex=0;power>=tndex;tndex++){ for (index=0;index<rows;index++){ for (kndex=0;kndex<cols;kndex++){ sum[index][kndex]=sum[index][kndex]+matrix[index][kndex]*matrix[kndex][index] } } } //end i multiplication