Matrix references
08-22-2015, 01:18 PM
Post: #1
 DrD Senior Member Posts: 1,132 Joined: Feb 2014
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.
08-22-2015, 03:02 PM
Post: #2
 roadrunner Senior Member Posts: 398 Joined: Jun 2015
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
08-22-2015, 04:09 PM
Post: #3
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
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):=
...

simple enough

ciao
Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
08-24-2015, 05:23 AM
Post: #4
 cyrille de brébisson Senior Member Posts: 1,047 Joined: Dec 2013
RE: Matrix references
Hello,

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

cyrille
08-24-2015, 11:59 AM
Post: #5
 DrD Senior Member Posts: 1,132 Joined: Feb 2014
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-
08-24-2015, 02:47 PM
Post: #6
 Tim Wessman Senior Member Posts: 2,280 Joined: Dec 2013
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 HP, the views and opinions I post here are my own.
08-24-2015, 03:22 PM
Post: #7
 roadrunner Senior Member Posts: 398 Joined: Jun 2015
RE: Matrix references
Quote:what is the 50g sequence for doing this

matrix
column
COL-
DROP
vector
column
COL+

is one way
08-24-2015, 03:35 PM
Post: #8
 roadrunner Senior Member Posts: 398 Joined: Jun 2015
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.
08-24-2015, 04:28 PM (This post was last modified: 08-24-2015 04:30 PM by Gerald H.)
Post: #9
 Gerald H Senior Member Posts: 1,461 Joined: May 2014
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
»
 « Next Oldest | Next Newest »

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