Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!wuarchive!zaphod.mps.ohio-state.edu!rpi!batcomputer!llenroc!cornell!uw-beaver!ubc-cs!fs1!ee.ubc.ca!jmorriso From: jmorriso@ee.ubc.ca (John Paul Morrison) Newsgroups: comp.sys.handhelds Subject: Re: Re: HP48 Vectors to Array? Keywords: HP28, HP48 Message-ID: <1991Mar14.115005@ee.ubc.ca> Date: 14 Mar 91 19:50:05 GMT References: <13845@life.ai.mit.edu> <6230002@hplred.HP.COM> Sender: root@fs1.ee.ubc.ca Reply-To: jmorriso@ee.ubc.ca Organization: UBC Electical Engineering Lines: 44 Well, here is yet another vector to array type of program. I use it extensively. It works on both HP28S and HP48SX machines. It is quick, as it uses the stack. A2V @ Extracts the COLUMN vectors of a matrix @ Hit TRN first if you want the ROW vectors @ leaves them on the stack, whith the number of vectors in level 1 %%HP: T(3)A(D)F(.); \<< TRN ARRY\-> LIST\-> DROP DUP 1 - NEG \-> n m m1 \<< m n 1 - * 1 + n FOR i m \->ARRY i ROLLD m1 STEP n \>> \>> V2A @ The inverse of A2V @ Takes n vectors, and the number n and leaves a matrix on the stack %%HP: T(3)A(D)F(.); \<< OVER SIZE 1 GET DUP 1 - \-> n m m1 \<< n m n 1 - * 1 + FOR i i ROLL ARRY\-> DROP m1 STEP { n m } \->ARRY TRN \>> \>> If you're really picky, these do not work for 1 dimesional vectors or n * 1 matrices. Big deal. One dimesional vectors are SCALARs anyways. The bug is in the HP STUPID_FOR loop. I'll fix it when I need the extra "correctness". In case you haven't noticed, HP STUPID_FOR loops ALWAYS execute at least once. I know that's documented, but it's still STUPID (especially if you program in C).