Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Matrices over ComplexField don't implement round(), unfortunately. But the following variant of John's answer works:

sage: mat = matrix(3, 3, [2+1e-15+i*1e-15]*9)
sage: mat.change_ring(CDF).round()
[2.0 2.0 2.0]
[2.0 2.0 2.0]
[2.0 2.0 2.0]