This method converts a real matrix to a rational matrix, by rounding each entry. The input $n$ specifies the number of (decimal) digits used for rounding.
i1 : A = matrix{{1, 2.5, -13/17}, {2*pi, 4.7, sqrt(2)}} o1 = | 1 2.5 -.764706 | | 6.28319 4.7 1.41421 | 2 3 o1 : Matrix RR <--- RR 53 53 |
i2 : roundMatrix(5, A) o2 = | 1 5/2 -76471/100000 | | 628319/100000 47/10 141421/100000 | 2 3 o2 : Matrix QQ <--- QQ |
The object roundMatrix is a method function.