Question: Identity Matrix

I have been trying to come up w/ a fast way to get identity Matrices which can later accept non-zero non-diagonal entries. If I use the shape=identity parameter then the Matrix can't be manipulated. This is what I've come up with KronDelt :=proc(i,j) => if i=j then 1 else 0 end if end proc: Matrix(1..4,1..4,(i,j) -> KronDelt(i,j)) Was it necessary to seperately define KronDelt ? I tried putting a mapping directly into the Matrix constructor but always got a syntax error, e. g., Matrix(1..4,1..4,(i,j)-> if i=j then 1 else 0 end if ) This doesn't work. Is there any way to do what I am trying to do?
Please Wait...