[sage-support] Re: matrix with many repeated entries

2009-06-06 Thread Kim, In-Jae
AM To: sage-support@googlegroups.com Subject: [sage-support] Re: matrix with many repeated entries Thank you all for excellent help on the question. I have another question along this line: For p=20, q=20, r=1, s=2, t=2, I would like to define matrix A=[a(i,j)] such that for k in range(1,t+1), a(i

[sage-support] Re: matrix with many repeated entries

2009-06-06 Thread Kim, In-Jae
e-support Subject: [sage-support] Re: matrix with many repeated entries I dont quite understand the defining rule for your matrix, but in general you can just put whichever rule you have as a function def f(i,j): if ((i<=5) and (j in [1,2,3, 7, ..., 20])) return 1 if i in [6,7,1

[sage-support] Re: matrix with many repeated entries

2009-06-04 Thread Rob Beezer
In-Jae, You can "stack" matrices, which would work here. If top and bottom are matrices with identical number of columns, then top.stack (bottom) will return the right thing. left.augment(right) will build up a matrix "sideways." So for your question above: sage: a=matrix(ZZ, 5, 20, [1]*(5

[sage-support] Re: matrix with many repeated entries

2009-06-04 Thread javier
I dont quite understand the defining rule for your matrix, but in general you can just put whichever rule you have as a function def f(i,j): if ((i<=5) and (j in [1,2,3, 7, ..., 20])) return 1 if i in [6,7,13,..., 20]: return 3 return -1 and then create your matrix us

[sage-support] Re: matrix with many repeated entries

2009-06-04 Thread Jason Grout
t; Sent: Thursday, June 04, 2009 3:19 PM > To: sage-support@googlegroups.com > Subject: [sage-support] Re: matrix with many repeated entries > > Thank you for your help, Jason. > > Can I get some help on the following matrix too? > > a_{i,j} = 1 for 1 \leq i \leq 5 and j \

[sage-support] Re: matrix with many repeated entries

2009-06-04 Thread Kim, In-Jae
: [sage-support] Re: matrix with many repeated entries Thank you for your help, Jason. Can I get some help on the following matrix too? a_{i,j} = 1 for 1 \leq i \leq 5 and j \in \{1,2,3, 7, ..., 20}; a_{i,j} =3 for i \in \{6, 7, 13, ..., 19\}; a_{ij}=-1 otherwise >P.S. If you have any suggesti

[sage-support] Re: matrix with many repeated entries

2009-06-04 Thread Kim, In-Jae
ay, June 04, 2009 1:43 PM To: sage-support@googlegroups.com Subject: [sage-support] Re: matrix with many repeated entries Kim, In-Jae wrote: > Hello, > > I would like to create a matrix with many repeated entries, for example, a > matrix with all entries equal to 1. > How can I do this

[sage-support] Re: matrix with many repeated entries

2009-06-04 Thread Jason Grout
Kim, In-Jae wrote: > Hello, > > I would like to create a matrix with many repeated entries, for example, a > matrix with all entries equal to 1. > How can I do this efficiently when the size of the matrix is large? > Hi In-Jae, In Python (i.e., Sage), you can duplicate a list by multiplying i