show/hide this revision's text 2 added 282 characters in body; added 55 characters in body

In Pari/GP; one could simplify for either readability, speed or memory organisation for big matrices:

{ makemat_St1(dim=n) = local(f, M); 
   M=matid(dim);
   f=1;
   for(r=2,dim,   \\ comp diagonal and first column
         M[r,1]=f;f*=(r)
      );
   for(c=2,dim,   \\ compute core entries
       for(r=c+1,dim,
           M[r,c]=M[r-1,c-1]+(r-1)*M[r-1,c]
          )
       );
    f1=1;     \\ apply signs 
    for(r=2,dim,
          f1*=-1;f2=-f1;
          for(c=1,r-1,
                f2*=-1;M[r,c]*=f2
                 )
         );
  return(M) }


A shorter form is this

{makemat_st1(dim=6) = local(m);  \\ give it a default dimension of 6
 m=matrix(dim,dim);
 m[1,1]=1;
 for(r = 2,dim, 
    m[r,1]= 0 - (r-1)*m[r-1,1] ; \\ first column has no up-left neighbour
    for(c = 2,r, 
       m[r,c]= m[r-1,c-1]  -  (r-1)*m[r-1,c]
       );
    );
 return(m);}
show/hide this revision's text 1

In Pari/GP; one could simplify for either readability, speed or memory organisation for big matrices:

{ makemat_St1(dim=n) = local(f, M); 
   M=matid(dim);
   f=1;
   for(r=2,dim,   \\ comp diagonal and first column
         M[r,1]=f;f*=(r)
      );
   for(c=2,dim,   \\ compute core entries
       for(r=c+1,dim,
           M[r,c]=M[r-1,c-1]+(r-1)*M[r-1,c]
          )
       );
    f1=1;     \\ apply signs 
    for(r=2,dim,
          f1*=-1;f2=-f1;
          for(c=1,r-1,
                f2*=-1;M[r,c]*=f2
                 )
         );
  return(M) }