REDUCE

15.3 Matrix- and List-valued Procedures

Normally, procedures can only return scalar values. In order for a procedure to return a matrix, it has to be declared of type matrixproc:

        matrixproc SkewSym1 (w);
           mat((0,-w(3,1),w(2,1)),
               (w(3,1),0,-w(1,1)),
               (-w(2,1), w(1,1), 0));

Following this declaration, the call to SkewSym1 can be used as a matrix, e.g.

        X := SkewSym1(mat((qx),(qy),(qz)));


             [  0     - qz   qy  ]
             [                   ]
        x := [ qz      0     - qx]
             [                   ]
             [ - qy   qx      0  ]

        X * mat((rx),(ry),(rz));


        [ qy*rz - qz*ry  ]
        [                ]
        [ - qx*rz + qz*rx]
        [                ]
        [ qx*ry - qy*rx  ]

Similarly, by using the keyword listproc, an algebraic procedure can be declared to return a list:

listproc spat3(u,v,w);
   begin scalar x,y;
     x := u *. w;
     y := u *. v;
     return v*x - w*y
   end;


Hosted by Download REDUCE Powered by MathJax