function IdentityMatrix(n)
$ X:=zeros(n,n);
$ for i=1 to n
$ X[i,i]:=1;
$ end;
$ return X;
$endfunction