Post Reply 
Matrix references
08-22-2015, 01:18 PM
Post: #1
Matrix references
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.
Find all posts by this user
Quote this message in a reply
08-22-2015, 03:02 PM
Post: #2
RE: Matrix references
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
Find all posts by this user
Quote this message in a reply
08-22-2015, 04:09 PM
Post: #3
RE: Matrix references
(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

∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C - DM42 WP34s :: Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
08-24-2015, 05:23 AM
Post: #4
RE: Matrix references
Hello,

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

cyrille
Find all posts by this user
Quote this message in a reply
08-24-2015, 11:59 AM
Post: #5
RE: Matrix references
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-
Find all posts by this user
Quote this message in a reply
08-24-2015, 02:47 PM
Post: #6
RE: Matrix references
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.

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
08-24-2015, 03:22 PM
Post: #7
RE: Matrix references
Quote:what is the 50g sequence for doing this

matrix
column
COL-
DROP
vector
column
COL+

is one way
Find all posts by this user
Quote this message in a reply
08-24-2015, 03:35 PM
Post: #8
RE: Matrix references
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.
Find all posts by this user
Quote this message in a reply
08-24-2015, 04:28 PM (This post was last modified: 08-24-2015 04:30 PM by Gerald H.)
Post: #9
RE: Matrix references
(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
»
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)