1 | initial version |
Have you tried
sage: M2 = CC.differential(2)
sage: M2.elementary_divisors()
The elementary_divisors method seems to be a lot faster, and maybe more memory efficient, than the smith_form method. For example:
sage: timeit('random_matrix(ZZ, 50, 100).smith_form()')
5 loops, best of 3: 137 ms per loop
sage: timeit('random_matrix(ZZ, 50, 100).elementary_divisors()')
25 loops, best of 3: 10.2 ms per loop
2 | No.2 Revision |
Have you tried
sage: M2 = CC.differential(2)
sage: M2.elementary_divisors()
The elementary_divisors method seems to be a lot faster, and maybe more memory efficient, than the smith_form method. For example:
sage: timeit('random_matrix(ZZ, 50, 100).smith_form()')
5 loops, best of 3: 137 ms per loop
sage: timeit('random_matrix(ZZ, 50, 100).elementary_divisors()')
25 loops, best of 3: 10.2 ms per loop
Note also that smith_form may fail with sparse matrices:
sage: random_matrix(ZZ, 50, 100, sparse=True).smith_form()
raises an error.