way to resize a matrix?



On Tue, May 13, 2008 at 9:21 AM, Andrei Zorine <zoav1602 at gmail.com> wrote:
>  What's the canonical way to resize a matrix?
>  resize_matrix(m,rows,cols):=block([list: flatten(m), a],
>   a[i,j]:= list[j+(i-1)*rows],
>   genmatrix(a,rows,cols));

Has the definition of flatten on matrices changed in 5.15 to be
equivalent to xreduce(append,args(m))?

If so, then a definition along those lines seems fine, though I think
it's (i-1)*cols -- and by the way block declarations do *not* make
function or matrix definitions local.  A somewhat more compact
definition would be

 resize_matrix(m,rows,cols) :=
     block([list: xreduce(append,args(m))],
          genmatrix( lambda([i,j],list[j+(i-1)*cols]), rows, cols))$

Is this what you had in mind?

                -s