Saturday, April 4, 2015

HP Prime and HP 50g: Matrices: Sum of the Rows, Columns, and Elements

HP Prime and HP 50g:  Matrices: Sum of the Rows, Columns, and Elements

Define the matrix M with R rows and C columns.

HP Prime

Determine number of Rows and Columns:

L1* := SIZE(M)
R:=L1(1)   // number of rows
C:=L1(2)   // number of columns

*L1 or any list variable.

Sum of the Columns and Sum of all Elements

Sum of the Columns:   MAKEMAT(1,1,R)*M
Sum of all Elements:  result*MAKEMAT(1,C,1)

Sum of the Rows and Sum of all Elements

Sum of the Rows:  M*MAKEMAT(1,C,1)
Sum of all Elements:  TRN(result)*MAKEMAT(1,R,1)

HP 50g

Determine the number of Rows and Columns:

Number of Rows:  << M SIZE 1 GET ‘R’ STO >>
Number of Columns:  << M SIZE 2 GET ‘C’ STO >>

Sum of the Columns and Sum of all Elements

Sum of the Columns:  << M 1 C START 1 NEXT C ->ARRY * >>
Sum of all Elements:  << result   AXL ∑LIST >>

Sum of the Rows and Sum of all Elements

Sum of the Rows:  << M TRAN 1 R START 1 NEXT R ->ARRY * >>
Sum of all Elements:  << result AXL ∑LIST >>

Examples:

[[ 1, 2, 1  ] [ 2, 1, 1]]

Rows:  [[ 4 ] [ 4 ]]
Columns:  [[ 3, 3, 2 ]]
All Elements:  [[ 8 ]]

[[ 6, 0, 5 ] [ 0, -3, 0 ] [ 3, 2, 3 ]]

Rows: [[ 11 ] [ -3 ] [ 8 ]]
Columns: [[ 9, -1, 8 ]]
All Elements: [[ 16 ]]

* Eddie *

This blog is property of Edward Shore.  2015.

Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation

Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation The HP 16C’s #B Function The #B function is the HP 16C’s number of...