Programming Question: How do you augment one matrix with another?
|
07-05-2014, 06:31 PM
(This post was last modified: 07-05-2014 06:59 PM by Jsather.)
Post: #17
|
|||
|
|||
RE: Programming Question: How do you augment one matrix with another?
(07-02-2014 06:09 AM)cyrille de brébisson Wrote: REPLACE(M1, {r,c}, M2) will place M2 at a given location in M1Earlier I mentioned an apparent bug in Replace that prevented Cyrille's makemat; replace; replace; method from working. I now have an explanation: not a bug. Replace(M3,{1,1},M1) returns M3 with M1 inserted beginning at (r,c)=(1,1), but does not change M3. To make the example work, it needs to be M3:=Replace(M3,{1,1},M1). This is counterintuitive because "replace" leads us to an assumption of replacement in M3. For vertical augmentation: M3:=makemat(0,rowDim(M1)+rowDim(M2),colDim(M1)); M3:=replace(M3,{1,1},M1); M3:=replace(M3,{rowDim(M1)+1,1},M2); or M3:=M1; redim(M3,{rowDim(M1)+rowDim(M2),colDim(M1)}); M3:=replace(M3,{rowDim(M1)+1,1},M2); For horizontal augmentation: M3:=makemat(0,rowDim(M1),colDim(M1)+colDim(M2)); M3:=replace(M3,{1,1},M1); M3:=replace(M3,{1,colDim(M1)+1},M2); or M3:=M1; redim(M3,{rowDim(M1),colDim(M1)+colDim(M2)}); M3:=replace(M3,{1,colDim(M1)+1},M2); These and the several other methods discussed in this thread could form the basis of a general purpose augmentation subroutine. The apparent absence of a matrix augment command is a surprising deficiency in the HP Prime command set. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)