Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Try this example:

sage: set_random_seed(100); # to be able to reproduce this example
sage: A = random_matrix(QQ, 5, 4, num_bound=20, den_bound=4); A
[    0    -1  19/3  -1/4]
[ -1/2     8     1  -5/2]
[ -7/2    -9    -5   3/2]
[-11/4  -1/4    -8 -15/4]
[   -9  14/3     8   4/3]
sage: all(map(lambda x: x.is_integer(),A.list()))
False

Hope that helps.

Try this example:

sage: set_random_seed(100); # to be able to reproduce this example
sage: A = random_matrix(QQ, 5, 4, num_bound=20, den_bound=4); A
[    0    -1  19/3  -1/4]
[ -1/2     8     1  -5/2]
[ -7/2    -9    -5   3/2]
[-11/4  -1/4    -8 -15/4]
[   -9  14/3     8   4/3]
sage: all(map(lambda x: x.is_integer(),A.list()))
False

Hope that helps.

Edit. I have found the denominator method, which yields the lowest common denominator of the matrix elements. So, all entries are integers if and only if such denominator is 1. As a continuation of the above example, we have:

sage: A.denominator()==1
False