[comp.sys.handhelds] HP28: Row Reduce Correction

march@m.cs.uiuc.edu (11/19/89)

   From: ma3164aj@hydra.unm.edu
   Date: Fri, 17 Nov 89 18:09:48 MST

   I believe the program is hanging on the following line:
   1 n FOR j A P j -> a sr sc dr dc

You are quite correct!

The above line should read ...

	1 n FOR j A P j K j -> a sr sc dr dc

In other words add in the extra 'K j' before the ->.  This routine
essentially swaps the elements given by sr/sc (source row and col) and
dr/dc (destination row and col) of the matrix referred to by the local
name 'a'.  Sorry for the lack of comments but I was doing well to 
complete the program AND get some sane example of it to post.  As it
turns out one of the examples is a 'bit' wrong but that shouldn't really
matter too much.

In the future I will try to post a fully commented version but don't look
for that for at least another month.  Like I said I was doing well to 
get the thing done in the first place.

The checksum remains the same.  I have included the full 'fixed' version
below with the corrected line marked with a '===>'.  Don't type this
marking in of course.

Any more questions ... feel free to ask.

ROWR [F79D]

<< DUP A STO SIZE LIST-> DROP -> m n
	<< 1 1 P STO Q STO WHILE P m <= Q n <= AND REPEAT
		0 'F' STO 0 'C' STO P 'K' STO 
		P m FOR i A i Q 2 ->LIST GET ABS -> x 
			<< IF x C > THEN x 'C' STO i 'K' STO END >>
		NEXT
		IF C .00001 < THEN 1 'F' STO Q 1 + 'Q' STO END
		IF F 0 == THEN
===>			1 n FOR j A P j K j -> a sr sc dr dc 
				<< a a sr sc 2 ->LIST GET dr dc 2 ->LIST SWAP PUT
				a dr dc 2 ->LIST GET sr sc 2 ->LIST SWAP PUT >> 'A' STO
			NEXT
			A P Q 2 ->LIST GET 'L' STO
			1 n FOR j A P j 2 ->LIST A P j 2 ->LIST GET L / PUT 'A' STO NEXT
			1 m FOR i A i Q 2 ->LIST GET 'L' STO
				1 n FOR j IF i P != THEN A i j 2 ->LIST A i j 2 ->LIST GET
					A P j 2 ->LIST GET L * - PUT 'A' STO END
				NEXT
			NEXT
			P 1 + 'P' STO Q 1 + 'Q' STO
		END
	END A
	{ A C P Q L F X K } PURGE >>
>>

Remember, any and all optimizations (read no more calls to STO) are
welcome (and needed!).

-Steve


===============================================================================
Steve March                            (H) (217)328-5176/328-5230  (W) 333-7408
Department of Computer Science, University of Illinois	
march@cs.uiuc.edu                           {uunet|convex|pur-ee}!uiucdcs!march
/* You are not expected to understand this. */ - UNIX V6 kernel source
"Time and space are modes by which we think and not conditions in which
 we live."  - Albert Einstein         
===============================================================================