Hi! I am afraid I don't know a definitive answer to your question. But at least I find the following a bit strange: sage: d = M.det() sage: d == -1 True sage: d == 0 False
So, the inversion of M should work, I think. Let us do compute the inverse "manually" (i.e., by applying Gaussian elimination to the augmented matrix) to see where it fails: sage: N = M.augment(M.parent()(1)) sage: N.swap_rows(0,3) sage: N.add_multiple_of_row(1,0,-N[1,0]) sage: N.add_multiple_of_row(2,0,-N[2,0]) sage: N.add_multiple_of_row(2,1,-N[2,1]) sage: N.rescale_row(2,~N[2,2]) sage: N.add_multiple_of_row(3,2,-N[3,2]) sage: N.add_multiple_of_row(1,2,-N[1,2]) sage: N.add_multiple_of_row(0,2,-N[0,2]) sage: N.rescale_row(3,~N[3,3]) sage: N.add_multiple_of_row(2,3,-N[2,3]) sage: N.add_multiple_of_row(0,3,-N[0,3]) sage: N[:,:4] == 1 True Therefore, N[:,4:] should be inverse to M. But it isn't: sage: N[:,4:]*M == 1 False sage: M*N[:,4:] == 1 False I suppose that there is some p-adic rounding going on. Which would also explain why there is a division-by-zero error (a number which is p-adically close to zero may have been rounded to zero). Best regards, Simon On 2018-01-30, Simon Brandhorst <[email protected]> wrote: > The following may be a bug or me not understanding p-adic floating point > computations: > > > sage: R = Qp(2,type='floating-point',print_mode='terse') > sage: M = Matrix(R,4,[0, 0, 1, 1, 2^20, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1]) > sage: M.det() > 1048575 > sage: M.inverse() > --------------------------------------------------------------------------- > ZeroDivisionError Traceback (most recent call last) > .... > > ZeroDivisionError: input matrix must be nonsingular > > sage: M = Matrix(R,4,[0, 0, 1, 1, 2^19, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1]) > sage: M.inverse() > [ 1048575 2 0 1] > [274878955520 524288 1 1048575] > [ 524289 524287 1 524287] > [274877382656 524289 1048575 524289] > > Works. > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
