I have a program to add n complex numbers, stored as magnitude and phase in the columns of an n x 2 matrix. It converts them one at a time to rectangular format and adds them to the stored sum. I'm setting register I based on the matrix dimension and using ISG to end the loop.

In each case, on the last step of the loop, the "I" key to move the value to the imaginary location fails. It doesn't do this if I perform all the calculations manually, only with the program, and only on the last row of the matrix. The problem seems independent of the matrix size. The sum is correct if I force the program to terminate on the next-to-last row rather than the last row of the matrix.

Here is the program, programmed and run in user mode. This is my first post, so I apologize if it doesn't conform to the nomenclature usually used here.

LBL E

RCL DIM A "Get the matrix dimensions"

X <> Y "Move the number of rows into X"

.

0

0

1

* "Multiply by .001 to set the loop counter

1

+

STO I "Add 1 and store the loop counter as 1.00n in Reg I"

MATRIX 1 "Move to beginning of matrix"

0

ENTER "Initialize the sum"

LBL 1 "Start of loop"

RCL A "Recall magnitude from first column of matrix"

RCL A "Recall phase from second column"

I "Move into imaginary part of X"

-> R "Convert to rectangular"

+ "Add to sum"

ISG I "Check counter for loop end"

GTO 1 "Loop"

-> P "Convert sum to polar form when finished"

RTN

To run the program, dimension the A matrix and load the complex numbers into it, then press "E" in user mode to execute the program. On the last row, it fails to move the second column into the imaginary part of x, instead adding it as a real number to the real part of x.

Anyone know what's going on here? This happens on my HP15C LE and on my DM-15CC. Haven't tried it yet on my original HP15C.

If I replace the 1 in the 9th instruction with 2, so that 2.00n is loaded into reg I and the loop terminates before reaching the last row of the matrix, the sum of the first n-1 rows is correct.

Mike