Misc matrix algorithms using FLINT#

sage.matrix.misc_flint.matrix_integer_dense_rational_reconstruction(A, N)[source]#

Given a matrix over the integers and an integer modulus, do rational reconstruction on all entries of the matrix, viewed as numbers mod \(N\). This is done efficiently by assuming there is a large common factor dividing the denominators.

INPUT:

  • A – matrix

  • N – an integer

EXAMPLES:

sage: B = ((matrix(ZZ, 3,4, [1,2,3,-4,7,2,18,3,4,3,4,5])/3)%500).change_ring(ZZ)
sage: from sage.matrix.misc_flint import matrix_integer_dense_rational_reconstruction
sage: matrix_integer_dense_rational_reconstruction(B, 500)
[ 1/3  2/3    1 -4/3]
[ 7/3  2/3    6    1]
[ 4/3    1  4/3  5/3]
>>> from sage.all import *
>>> B = ((matrix(ZZ, Integer(3),Integer(4), [Integer(1),Integer(2),Integer(3),-Integer(4),Integer(7),Integer(2),Integer(18),Integer(3),Integer(4),Integer(3),Integer(4),Integer(5)])/Integer(3))%Integer(500)).change_ring(ZZ)
>>> from sage.matrix.misc_flint import matrix_integer_dense_rational_reconstruction
>>> matrix_integer_dense_rational_reconstruction(B, Integer(500))
[ 1/3  2/3    1 -4/3]
[ 7/3  2/3    6    1]
[ 4/3    1  4/3  5/3]