Question: loops multiplying all the diagonal entries of a matrix together

Hi I'm trying to make a procedure that will multiply all the diagonal entries of any random matrix together, this is what I have tried so far:

 

with(LinearAlgebra):
with(ListTools):
Diag := proc(A)
local aux,V,i,n;
V:=[];
n:=RowDimension(A):

for i from 1 to n do 
aux := 1; 
aux := aux*U2(i,i);
end do:


end proc;

but this just produces the last diagoinal entry of the matrix - how do I make the loop multiply the previous number by the next diagonal entry?

another option I've done is to make a list of the diagonal entries, but then I encounter the same problem with multiplication:

Diag:=proc(A)
local n, List;
n:=RowDimension(A);
List:=[seq(A(i,i),i=1..n)]:
end proc:

any help would be greatly appreciated!
 

Please Wait...