cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Opposite of submatrix - Insert matrix

PhilipOakley
5-Regular Member

Opposite of submatrix - Insert matrix

I'd like a neat compact way of inserting one matrix
into another, sort of an InsertMatrix(A,B,ir,ic),
where one places the matrix B into the matrix A
starting at row ir and column ic, with any spare
bits of B (i.e. not lying inside A) being ignored.

The limits for ir and ic would allow negative
entries such that B could overlap to the top and
left.
(An alternative is an option that decides if (ir,ic)
is top left / bottom right coordinate..)

I'm sure Stuart will have one in his library, I'd
just like one in the off-the-shelf mathcad.

Philip Oakley
2 REPLIES 2

On 12/6/2009 12:53:23 PM, philipoakley wrote:
== I'd like a neat compact way of inserting one
matrix into another, sort of an
InsertMatrix(A,B,ir,ic), where one places the
matrix B into the matrix A starting at row ir and
column ic, with any spare bits of B (i.e. not
lying inside A) being ignored.
== I'm sure Stuart will have one in his library,
I'd just like one in the off-the-shelf mathcad

I think there is, depends what you mean. I'm
guessing that you mean A to remain the same size
but have B replace the original elements starting
at (ir,ic) - in which case my standard worksheet
library 'Vector Support Functions' includes
insertmat(main,sub,x,y) and insertvec(main,sub,x)
which do that. However, ...

== The limits for ir and ic would allow negative
entries such that B could overlap to the top and
left. (An alternative is an option that decides
if (ir,ic) is top left / bottom right
coordinate..)

They don't wrap. ... oh, all right, if you insist

Stuart
PhilipOakley
5-Regular Member
(To:StuartBruff)

On 12/6/2009 4:02:08 PM, stuartafbruff wrote:
>On 12/6/2009 12:53:23 PM, philipoakley
>wrote:

>
>They don't wrap. ... oh, all right, if
>you insist
>
>Stuart

OOPs - not quite what I was thinking. I was not
thinking of wrapping, rather that for the
insertion of a 2x2 matrix in a 4x4 matrix, with
ORIGIN = 0, then first ('top left') valid values
are (-1,-1). In such a case, the value of main[0,0
would be overwritten by the value of sub[1,1.
the maximum values would be (3,3) where main[3,3
is overwritten by sub[0,0.

I'm happy with your function naming. All we need
is PTC to code it....

Philip Oakley

OOPs again,

Just double checked the example, had to fudge it
for i:=-1;rows(main) as the LHS needed M[i+1,j+i
etc.
Top Tags