Is there a command to total all matrix elements?



#6

I've got a 5x6 matrix and I need to add all the elements together. I didn't want to have to decompile the matrix and perform '+' 29 times though. I've looked in the matrix section in the user guide a few times, and can't find anything that will do this.

Thanks in advance!
--Reuben


#7

(Revised from earlier post)

You could just take the dot product with unity matrix:

[[ 1 2 3 ]      [[1 1 1]
[ 4 5 6 ] dot [1 1 1] = 45
[ 7 8 9 ]] [1 1 1]]
which is 1+2+3+4+5+6+7+8+9=45

Edited: 24 Feb 2007, 10:19 a.m.


#8

A little longer but faster:


OBJ-> OBJ-> DROP * ->LIST \Sigma\LIST

John


#9

John,
Right you are, your method is at least twice as fast as the method I posted above. My original response was much closer to your objobj method, but I revised it because it did not address the question.

Reuben's question had "opportunities for learning" in programming (trying to sum a list by +,+,+,+,+,+,+) and in mathematics (not knowing that the DOT product already does sum the elements in a vector/matrix). So I thought it more fitting to address only the mathematics issue, hoping that he would take some initiave and figure out the rest. (e.g. a simpler, faster, better... way)

Edited: 26 Feb 2007, 11:49 p.m.

#10

 <<
DUP SIZE 1 CON DOT
>>

(If you say it outloud to yourself it sounds very much like ordering soup in a Vietnamese Restraunt!) :-)

Edited: 25 Feb 2007, 12:32 a.m.


Possibly Related Threads…
Thread Author Replies Views Last Post
  [HP-Prime CAS] "Warning, ^ (Command) Is ambiguous on non square matrices"?? CompSystems 1 2,245 12-07-2013, 07:15 PM
Last Post: CompSystems
  AFTER HP-Prime update, Shift+Matrix CRASHES Joseph Ec 3 2,108 12-06-2013, 11:06 AM
Last Post: Joseph Ec
  HP Prime Matrix TERRIBLE bug and question uklo 19 5,353 11-25-2013, 12:10 PM
Last Post: Mic
  HP Prime: editing a matrix Alberto Candel 6 2,421 11-20-2013, 06:26 PM
Last Post: Helge Gabert
  HP-Prime : Extracting elements from a list in RPN Miguel Toro 0 1,650 11-15-2013, 06:44 PM
Last Post: Miguel Toro
  [HP-Prime] Picking elements from a List in a program Jean-Michel 3 2,087 11-15-2013, 04:16 AM
Last Post: dg1969
  HP Prime - most favorite command bluesun08 2 1,534 11-12-2013, 11:29 AM
Last Post: bluesun08
  Absolute Value and Matrix BruceTTT 5 2,196 11-11-2013, 11:52 PM
Last Post: Walter B
  hp prime - command syntax bluesun08 6 2,530 11-10-2013, 11:57 AM
Last Post: bluesun08
  HP PRIME: command to read the SERIAL ? Joseph Ec 9 5,935 11-01-2013, 12:43 AM
Last Post: Joe Horn

Forum Jump: