Ticket #4502: 4502-crude_hack.patch

File 4502-crude_hack.patch, 1.2 KB (added by GeorgSWeber, 13 years ago)

patch against Sage 3.2.rc1

  • sage/matrix/matrix_double_dense.pyx

    # HG changeset patch
    # User Georg S. Weber <GeorgSWeberYouKnowWhatGooglemailYouKnowTheRest>
    # Date 1226828571 -3600
    # Node ID 28d168d2133a79a46d8058372c70dc5ccd0c3c4c
    # Parent  5e45f3ee796ad08b6a3467a21f4809ba9e2d69dc
    #4502 crude hack as proposed in the ticket description
    
    diff -r 5e45f3ee796a -r 28d168d2133a sage/matrix/matrix_double_dense.pyx
    a b  
    456456        if scipy is None:
    457457            import scipy
    458458        import scipy.linalg
     459
     460        if not self.is_square():
     461            raise ValueError, "self must be square"
     462        if 0.0 == scipy.linalg.det(self._matrix_numpy):
     463            #crude hack for trac #4502 till an updated scipy handles this better
     464            #    we should asap get rid of the introduced performance penalty
     465            #    (extra computing of the determinant)
     466            #force scipy to throw the correct error message,
     467            #by telling it to invert the zero matrix (of the correct space)
     468            M._matrix_numpy = scipy.linalg.inv(self._matrix_numpy - self._matrix_numpy)
    459469
    460470        M._matrix_numpy = scipy.linalg.inv(self._matrix_numpy)
    461471        return M