def test_iszero_substitution():
 m = Matrix([[0.9, (-0.1), (-0.2), 0], [(-0.8), 0.9, (-0.4), 0], [(-0.1), (-0.8), 0.6, 0]])
 m_rref = m.rref(iszerofunc=(lambda x: (abs(x) < 6e-15)))[0]
 m_correct = Matrix([[1.0, 0, (-0.301369863013699), 0], [0, 1.0, (-0.712328767123288), 0], [0, 0, 0, 0]])
 m_diff = (m_rref - m_correct)
 assert (m_diff.norm() < 1e-15)
 assert (m_rref[(2, 2)] == 0)

def test_iszero_substitution ( ) : m = Matrix ( [ [ 0.9 , ( - 0.1 ) , ( - 0.2 ) , 0 ] , [ ( - 0.8 ) , 0.9 , ( - 0.4 ) , 0 ] , [ ( - 0.1 ) , ( - 0.8 ) , 0.6 , 0 ] ] ) m_rref = m . rref ( iszerofunc = ( lambda x : ( abs ( x ) < 6e-15 ) ) ) [ 0 ] m_correct = Matrix ( [ [ 1.0 , 0 , ( - 0.301369863013699 ) , 0 ] , [ 0 , 1.0 , ( - 0.712328767123288 ) , 0 ] , [ 0 , 0 , 0 , 0 ] ] ) m_diff = ( m_rref - m_correct ) assert ( m_diff . norm ( ) < 1e-15 ) assert ( m_rref [ ( 2 , 2 ) ] == 0 )
when doing numerical computations .