07-10-2016, 01:36 AM
HP 42S: Column Sums of a Matrix
This could potentially had been a medium to long sized programs involving loops, but thanks to the powerful function RSUM (found in CATALOG-FUNC or executed by XEQ RSUM) this program will be quite short. RSUM is the row sum function, or the sum of each row of a matrix.
Just put a matrix on the stack and run CSUM. When the program is finished, press [shift] [ 9 ] (MATRIX), {EDIT} to see the sums.
Test: MAT1 = [ [4, 3, 1], [5, 8, 2], [7, 6, 3]]
Result: [16, 17, 6]
This could potentially had been a medium to long sized programs involving loops, but thanks to the powerful function RSUM (found in CATALOG-FUNC or executed by XEQ RSUM) this program will be quite short. RSUM is the row sum function, or the sum of each row of a matrix.
Just put a matrix on the stack and run CSUM. When the program is finished, press [shift] [ 9 ] (MATRIX), {EDIT} to see the sums.
Code:
00 {12-Byte Prgm}
01 LBL “CSUM”
02 TRANS \\ transpose
03 RSUM
04 END
Test: MAT1 = [ [4, 3, 1], [5, 8, 2], [7, 6, 3]]
Result: [16, 17, 6]