Ticket #14391: trac_14391_matsolvemod_in_pari_interface.patch

File trac_14391_matsolvemod_in_pari_interface.patch, 2.3 KB (added by robharron, 9 years ago)

Creates an interface method for matsolvemod

  • sage/libs/pari/gen.pyx

    # HG changeset patch
    # User Robert Harron <rharron@math.wisc.edu>
    # Date 1364693281 18000
    # Node ID 47afd94c8334b6ee5644cbdc81b1a86e6c61a62f
    # Parent  4381a8e9f0c8d5d481433f3e670c8de9ddeadc4f
    Trac 14391: Add matsolvemod to pari interface
    
    diff --git a/sage/libs/pari/gen.pyx b/sage/libs/pari/gen.pyx
    a b  
    82828282        t0GEN(B)
    82838283        sig_on()
    82848284        return self.new_gen(gauss(self.g,t0))
    8285        
     8285   
     8286    def matsolvemod(self, D, B, long flag = 0):
     8287        r"""
     8288        For column vectors `D=(d_i)` and `B=(b_i)`, find a small integer
     8289        solution to the system of linear congruences
     8290       
     8291        .. math::
     8292       
     8293            R_ix=b_i\text{ (mod }d_i),
     8294       
     8295        where `R_i` is the ith row of ``self``. If `d_i=0`, the equation is
     8296        considered over the integers. The entries of ``self``, ``D``, and
     8297        ``B`` should all be integers (those of ``D`` should also be
     8298        non-negative).
     8299       
     8300        If ``flag`` is 1, the output is a two-component row vector whose first
     8301        component is a solution and whose second component is a matrix whose
     8302        columns form a basis of the solution set of the homogeneous system.
     8303       
     8304        For either value of ``flag``, the output is 0 if there is no solution.
     8305       
     8306        Note that if ``D`` or ``B`` is an integer, then it will be considered
     8307        as a vector all of whose entries are that integer.
     8308       
     8309        EXAMPLES::
     8310       
     8311            sage: D = pari('[3,4]~')
     8312            sage: B = pari('[1,2]~')
     8313            sage: M = pari('[1,2;3,4]')
     8314            sage: M.matsolvemod(D, B)
     8315            [-2, 0]~
     8316            sage: M.matsolvemod(3, 1)
     8317            [-1, 1]~
     8318            sage: M.matsolvemod(pari('[3,0]~'), pari('[1,2]~'))
     8319            [6, -4]~
     8320            sage: M2 = pari('[1,10;9,18]')
     8321            sage: M2.matsolvemod(3, pari('[2,3]~'), 1)
     8322            [[0, -1]~, [-1, -2; 1, -1]]
     8323            sage: M2.matsolvemod(9, pari('[2,3]~'))
     8324            0
     8325            sage: M2.matsolvemod(9, pari('[2,45]~'), 1)
     8326            [[1, 1]~, [-1, -4; 1, -5]]
     8327        """
     8328        t0GEN(D)
     8329        t1GEN(B)
     8330        sig_on()
     8331        return self.new_gen(matsolvemod0(self.g, t0, t1, flag))
     8332   
    82868333    def matker(self, long flag=0):
    82878334        """
    82888335        Return a basis of the kernel of this matrix.