On Wed, May 20, 2015 at 4:37 PM, Phoenix <[email protected]> wrote:
> I am trying to create the set of 3x3 matrices which have entries in the set
> [0,1,-1]
>
> The simple way to do that would be to create 9 nested loops and run over all
> the possibilities.
Use cartesian_product_iterator:
v = []
for x in cartesian_product_iterator([[0,1,-1]]*9):
v.append(matrix(3,x))
Complete example:
https://cloud.sagemath.com/projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/files/support/2015-05-20-matrices.sagews
>
> One hopefully better way I could think of doing is possibly this,
>
> from itertools import product
> from itertools import izip
>
> A = [(0,0),(0,1),(0,2),(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)]
>
> for a in product([0,1,-1], repeat = 9):
> B = izip (A,a)
>
>
> I believe this "B" of mine encodes the matrix as a list of assignments as to
> which matrix entry has gotten which element of the list [0,1,-1]
>
> But I am not able to convert this B into something that actually is a
> matrix?
> (so that I can say take eigenvalues of it)
>
>
> Can someone help?
>
> Also I am running things on the cloud.sage
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
--
William (http://wstein.org)
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.