comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: a matrix whose some elements are matrixes
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: a matrix whose some elements are matrixes [message #49281] Mon, 10 July 2006 02:12
Paolo Grigis is currently offline  Paolo Grigis
Messages: 171
Registered: December 2003
Senior Member
Here's a small example which should help you:

a=[[1,0],[0,1]]
b=[[2,2],[2,2]]

IDL> print,a
1 0
0 1
IDL> print,b
2 2
2 2

To have a matrix c=[[a,b],[b,a]] do:

c=intarr(4,4)

c[0,0]=a
c[0,2]=b
c[2,0]=b
c[2,2]=a

The output is:

IDL> print,c
1 0 2 2
0 1 2 2
2 2 1 0
2 2 0 1


The trick is to figure out where the upper left corners of the smaller matrices
fit into the larger matrix you want to build...

Ciao,
Paolo


haojuanchina@gmail.com wrote:
> I want obtain a matric whose some elements are matrixes, how to compile
> the program?
> example: Iwant to abtain the following matrix
> G I I I I I 0
> I G I 0 0 0 0
> I I G I 0 0 0
> I 0 I G I 0 0
> I 0 0 I G I 0
> I 0 0 0 I G I
> 0 0 0 0 0 I G
> in which I is an identity matrix,
> 1 0 0 0 0 0 0
> 0 1 0 0 0 0 0
> 0 0 1 0 0 0 0
> 0 0 0 1 0 0 0
> 0 0 0 0 1 0 0
> 0 0 0 0 0 1 0
> 0 0 0 0 0 0 1
> and G is a similar diagonal matrix:
> 1 -0.25 -0.25 -0.25 -0.25 -0.25 0
> -0.25 1 0 0 0 0 0
> -0.25 0 1 0 0 0 0
> -0.25 0 0 1 0 0 0
> -0.25 0 0 0 1 0 0
> -0.25 0 0 0 0 1 0
> 0 0 0 0 0 0 1
> I can compile the program of the matrix G:
> PRO Matrix
>
> diag =findgen(7)
> sub=findgen(6)
> super=findgen(6)
>
> diag[0:6]=1
> sub[0:5]=-0.25
> super[0:5]=-0.25
>
> G = DIAG_MATRIX(diag) + $
> DIAG_MATRIX(super, 1) + DIAG_MATRIX(sub, -1)
> G[0,1:5]=-0.25
> G[1:5,0]=-0.25
> print,G
>
> I= DIAG_MATRIX(diag[0:6]);*(-0.25)
> print,I
>
> END
>
> but how to get the first matrix in which include the matrix G and I ?
> Please give me a help!thanks.
>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: a matrix whose some elements are matrixes
Next Topic: Re: a matrix whose some elements are matrixes

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:17:16 PDT 2025

Total time taken to generate the page: 0.00515 seconds