HP Forums
Matrix references - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Matrix references (/thread-4556.html)



Matrix references - DrD - 08-22-2015 01:18 PM

How would you efficiently replace a column vector of a matrix, with another column vector, of suitable dimension?

Example: a:=[[−1,5],[2,5]];
replace column 2 with [3 4] ==> [[−1,3],[2,4]]

Ideally, the same approach will work in HOME or CAS.


RE: Matrix references - roadrunner - 08-22-2015 03:02 PM

This seems to work in cas and home on the emulator:

Code:
#cas
replacecol(matrix,vector,col):=
BEGIN
 local a;
 a:=DELCOL(matrix,col);
 return ADDCOL(a,vector,col);
END;
#end



RE: Matrix references - salvomic - 08-22-2015 04:09 PM

(08-22-2015 03:02 PM)roadrunner Wrote:  This seems to work in cas and home on the emulator:

[code]#cas
replacecol(matrix,vector,col):=
...

thank you, Road, this' helpful also for me!
simple enough Smile

ciao
Salvo


RE: Matrix references - cyrille de brébisson - 08-24-2015 05:23 AM

Hello,

In HOME only, Mat[-Column]:=vector will do it in one go... Mat[-column] will return a column.

cyrille


RE: Matrix references - DrD - 08-24-2015 11:59 AM

The responses provided reveal many of the shortcoming's in Prime's ability to deal with matrices. The burden of column replacement using support functions such as DELCOL(), ADDCOL(), and REPLACE(), make difficult what should be quite a simple operation.

The so-called, "dichotomy," HOME vs. CAS, renders useless, what COULD be a useful solution to this problem: Mat[-Column]:=vector, when matrices contain symbolic entries. Negative indices are not supported in CAS.

For example, replacing column 2 of matrix a, with vector b, isn't supported in HOME mode, even by using Mat[-Column]:=vector, when:

a:=[[x2,-x1],[x3,-x2],[x3,-x4]]; // Symbolic entries not allowed in HOME
b:=[[-x1],[-x2],[-x1]];

My original post attempts to emphasize the current weakness, (and encourage further development), in matrix handling methods; within 'both' sides of the HOME / CAS status quo. Understandably, the Primes's authors have much to do, as the Prime undergoes evolution. May I request that improvement in matrix handling be added to "the list?"

Thanks!
-Dale-


RE: Matrix references - Tim Wessman - 08-24-2015 02:47 PM

So out of curiosity, what is the 50g sequence for doing this? I remember from long before my HP time trying to do a similar thing on the 48 series was pretty painful too.


RE: Matrix references - roadrunner - 08-24-2015 03:22 PM

Quote:what is the 50g sequence for doing this

matrix
column
COL-
DROP
vector
column
COL+

is one way


RE: Matrix references - roadrunner - 08-24-2015 03:35 PM

Personally, I would prefer to see an external compiler/debugger so just the compiled programs can be stored on the handheld and the source code can remain on my PC.

Presumably, with large amounts of requests and limited resources, HP will decide which requests to work on based on what they think will sell the most calculators.


RE: Matrix references - Gerald H - 08-24-2015 04:28 PM

(08-24-2015 02:47 PM)Tim Wessman Wrote:  So out of curiosity, what is the 50g sequence for doing this? I remember from long before my HP time trying to do a similar thing on the 48 series was pretty painful too.

I think these two progs do the job

Stack:

Mat

Vec

R/C Number


V2C, Vector to Column

« 1 SWAP 2 ->LIST
SWAP TRN REPL
»

V2R, Vector to Row

« 1 2 ->LIST SWAP
REPL
»