matrix element operation  Printable Version + HP Forums (https://archived.hpcalc.org/museumforum) + Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum1.html) + Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum2.html) + Thread: matrix element operation (/thread184535.html) 
matrix element operation  Sokkhieng Chum Hun  05212011 Hi, is it possible to do matrix element operation on the hp48 or hp50g? In exemple, in matlab, if A = [1 2 3] and B = [2 3 4] A.*B gives [1*2 2*3 3*4] > [2 6 12] Or A./B gives [1/2 2/2 3/4] > [.5 1 .75] Or A.^B gives [1^1 2^3 3^4] > [1 8 81]
Thank you :)
Re: matrix element operation  Jose Gonzalez Divasson  05212011 In HP50g at least it exists the function HADAMARD, that multiplies 2 matrices term by term. Very useful for business purposes, but not for physics or mathematics.
I don't know how to divide, because 1/[matrix] is a defined operation  and different.
Re: matrix element operation  Thomas Klemm  05212011 You could use lists instead of vectors:
1st example: A * B(PRG > LIST > PROC > DOLIS)
Cheers PS: I guess the next question will be, how to turn a vector into a list:
\<< Re: matrix element operation  Donald Ingram  05212011 Enter the values as lists using { } or 1 2 3 3 >LIST and you get the results you desire.
Re: matrix element operation  Gilles Carpentier  05212011 Hi, On the 50G you can use the HADAMARD command for this type of matrices multiplication : [1 2 3] [2 3 4] HADAMARD > [2 6 12 ] To transform LIST <> MATRICE, uses AXL [ 1 2 3 ] AXL > { 1 2 3 } { 1 2 3 } AXL > [ 1 2 3 ] [1 2 3] 'a' STO [2 3 4] 'b' STO « a b HADAMARD a AXL b AXL / AXL a AXL b AXL ^ AXL » You can create news commands « AXL SWAP AXL SWAP / AXL » 'MDiv' STO « AXL SWAP AXL SWAP ^ AXL » 'MPuis' STO There is no need of DOLIST in this case. If you use lists instead of matrices * / and ^ does the job { 1 2 3 } { 2 3 4 } * > { 2 6 12 } { 1 2 3 } { 2 3 4 } / > { 1/2 2/3 3/4 } { 1 2 3 } { 2 3 4 } ^ > { 1 8 81 } Symbolic are allowed
{ 1 2 3 } { 'A' 'B' 'C' } ^ > { 1^A 2^B 3^C } Edited: 21 May 2011, 5:59 p.m.
Re: matrix element operation  Thomas Klemm  05212011 Quote: Thanks for the hint. This works also with the 48G.
Quote: I get the following with the 48G:
{ 1 2 3 } { 'A' 'B' 'C' } ^ > { 1 '2^B' '3^C' }
Cheers Re: matrix element operation  Gilles Carpentier  05212011 >I get the following with the 48G: >{ 1 2 3 } { 'A' 'B' 'C' } ^ > { 1 '2^B' '3^C' }
>Cheers Seems different on the 50
EVAL > 1
(I suppose that 'A' don't exists)
Re: matrix element operation  Oliver Unter Ecker  05222011 Not regarding the devices you ask, but probably still helpful: On ND1, an iOS app with a feature set that closely resembles a 50g without CAS but with other additions (incl. programmability in RPL+ and JavaScript), "lists" and "vectors" are unified, and [1 2 3] [2 3 4] * will return [2 6 12]. "+", "", "1/x" and all singlevalued operators and functions (such as "sin", "!", "loggamma", ...(a list of >100)) work on both real and symbolic vectors. This also works with large vectors (of, say, 10^5 elements). The DOLIST and DOSUBS techniques mentioned also work, and, as on the 48 and 50g, can be used on more than two vectors at once.
48, 50g, ND1 have other vectorprocessing type functionality, btw, sometimes hiding under unusual names. The common "fold" operation is known as STREAM, for example.
Re: matrix element operation  C.Ret  05222011 Hi, I also use MatLab, but I own only an HP28S. That why to get .* .+ ./ or any vectorialized operation on matrix or line/column vector on my HP28, I have to use a dedicated program:
Considering two matrix/vectors A and B of the same shape : A B « * » EXE2 returns matrix/vector ‘A.*B’
This way also si possible on HP48/49/50 and you don’t have to worry about objet type list or array !
[ 1 2 3 ] [ 10 20 30 ] « * » EXE2 is [10 40 90]
Edited: 22 May 2011, 4:48 p.m.
