Question: Matrix Element Summation

Here is my Problem. Im trying to do some calculations with matrices included. Suppose I have a Matrix A and one B. I wanna create a new Matrix call it C (diagonal) like this. c_ii = sum(a_ik^2 * b_kk, k = 1 .. n) I get an errormessage sayin: "Error, bad index into Matrix" How can i force Maple to evaluate the Matrixentries first before trying to sum them up. At least I think thats the problem. I tried to pack them into a function like (i,j) -> A[i,j] which didn't work either. Thanks for your help Michael
Please Wait...