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

Home » Public Forums » archive » how to compile 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
how to compile a matrix whose some elements are matrixes [message #49308] Fri, 14 July 2006 00:11 Go to next message
haojuanchina@gmail.co is currently offline  haojuanchina@gmail.co
Messages: 3
Registered: July 2006
Junior Member
Hello,everyone
I want obtain a matric whose some elements are matrixes, how to compile

the program?
example: I want to abtain the following matrix
G I 0 0 0 0 0
I G I 0 0 0 0
0 I G I 0 0 0
0 0 I G I 0 0
0 0 0 I G I 0
0 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 2 0 0 0 0 0
2 1 2 0 0 0 0
0 2 1 2 0 0 0
0 0 2 1 2 0 0
0 0 0 2 1 2 0
0 0 0 0 2 1 2
0 0 0 0 0 2 1
I can compile the program of the matrix G and I:
PRO Matrix

diag =findgen(7)
sub=findgen(6)
super=findgen(6)


diag[0:6]=1
sub[0:5]=2
super[0:5]=2


G = DIAG_MATRIX(diag) + $
DIAG_MATRIX(super, 1) + DIAG_MATRIX(sub, -1)
G[0,1:5]=2
G[1:5,0]=2
print,G

I= identity(7)
print,I

END


but how to get the first matrix in which include the matrix G and I?
The difficulty is that I can not compile the diagonal elements (the
smaller matrixes) of the larger matrix. How should I do?
Thanks!
Juan Hao
Re: how to compile a matrix whose some elements are matrixes [message #49391 is a reply to message #49308] Fri, 14 July 2006 09:34 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Hello,

well, your array will hold two different things: an int and an array of int.
If you want to keep your zeroes as individual values, maybe you should
consider using a pointer. You create a 7*7 pointer array, and you assign
either the value 0 or the matrix G or I to each cell.
mat = ptrarr(7,7)
(*mat)[0,0] = G
(*mat)[0,3] = 0

If you don't mind to replicate your zeroes (in a 7,7 array), just create
a 49*49 array and fill it with G,I and the 7*7 zeroes array!
mat[0,0] = G
mat[7,0] = I

Jean

haojuanchina@gmail.com wrote:
> Hello,everyone
> I want obtain a matric whose some elements are matrixes, how to compile
>
> the program?
> example: I want to abtain the following matrix
> G I 0 0 0 0 0
> I G I 0 0 0 0
> 0 I G I 0 0 0
> 0 0 I G I 0 0
> 0 0 0 I G I 0
> 0 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 2 0 0 0 0 0
> 2 1 2 0 0 0 0
> 0 2 1 2 0 0 0
> 0 0 2 1 2 0 0
> 0 0 0 2 1 2 0
> 0 0 0 0 2 1 2
> 0 0 0 0 0 2 1
> I can compile the program of the matrix G and I:
> PRO Matrix
>
> diag =findgen(7)
> sub=findgen(6)
> super=findgen(6)
>
>
> diag[0:6]=1
> sub[0:5]=2
> super[0:5]=2
>
>
> G = DIAG_MATRIX(diag) + $
> DIAG_MATRIX(super, 1) + DIAG_MATRIX(sub, -1)
> G[0,1:5]=2
> G[1:5,0]=2
> print,G
>
> I= identity(7)
> print,I
>
> END
>
>
> but how to get the first matrix in which include the matrix G and I?
> The difficulty is that I can not compile the diagonal elements (the
> smaller matrixes) of the larger matrix. How should I do?
> Thanks!
> Juan Hao
>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL and Macs. Speed is not only about squared roots
Next Topic: IDL and Macs. Speed is not only about squared roots

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

Current Time: Wed Oct 08 19:44:15 PDT 2025

Total time taken to generate the page: 0.00633 seconds