ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 29 Nov 2016 22:51:54 +0100How to create a matrix of same entries?https://ask.sagemath.org/question/35797/how-to-create-a-matrix-of-same-entries/For example, I want to make a 20 by 20 matrix with all entries being 10. Is there a quick command for that? Thanks!Tue, 29 Nov 2016 22:26:27 +0100https://ask.sagemath.org/question/35797/how-to-create-a-matrix-of-same-entries/Answer by slelievre for <p>For example, I want to make a 20 by 20 matrix with all entries being 10. Is there a quick command for that? Thanks!</p>
https://ask.sagemath.org/question/35797/how-to-create-a-matrix-of-same-entries/?answer=35798#post-id-35798This is one way.
sage: matrix(ZZ, 4, 4, lambda i, j: 10)
[10 10 10 10]
[10 10 10 10]
[10 10 10 10]
[10 10 10 10]
Tue, 29 Nov 2016 22:47:13 +0100https://ask.sagemath.org/question/35797/how-to-create-a-matrix-of-same-entries/?answer=35798#post-id-35798Comment by Lisewe for <p>This is one way.</p>
<pre><code>sage: matrix(ZZ, 4, 4, lambda i, j: 10)
[10 10 10 10]
[10 10 10 10]
[10 10 10 10]
[10 10 10 10]
</code></pre>
https://ask.sagemath.org/question/35797/how-to-create-a-matrix-of-same-entries/?comment=35799#post-id-35799Thank you! This is what I was looking for.Tue, 29 Nov 2016 22:51:54 +0100https://ask.sagemath.org/question/35797/how-to-create-a-matrix-of-same-entries/?comment=35799#post-id-35799