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 it by a number: sage: [1]*20 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] So you would just use that to create a list long enough for your matrix: sage: matrix(4,5,[1]*20) [1 1 1 1 1] [1 1 1 1 1] [1 1 1 1 1] [1 1 1 1 1] Thanks, Jason P.S. If you have any suggestions for improving the linear algebra or making it easier to use, we'd love to hear them! -- Jason Grout --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
