Ticket #14867: trac_14867_qfminim1.patch

File trac_14867_qfminim1.patch, 3.3 KB (added by John Cremona, 9 years ago)

Replaces previous

  • sage/libs/pari/gen.pyx

    # HG changeset patch
    # User John Cremona <john.cremona@gmail.com>
    # Date 1373032561 -3600
    # Node ID db95889c4d2ad1678b8cbdb2a0e0fa4882ef338d
    # Parent  0f8fd922eaed351e39f913f1317d319dcceb4c01
    Trac 14867: Pari's qfminim problem needs 2nd argument to use 3rd.
    
    diff --git a/sage/libs/pari/gen.pyx b/sage/libs/pari/gen.pyx
    a b  
    82488248    def lllgramint(self):
    82498249        return self.qflllgram(1)
    82508250
    8251     def qfminim(self, B, max, long flag=0):
    8252         """
    8253         qfminim(x,bound,maxnum,flag=0): number of vectors of square norm =
    8254         bound, maximum norm and list of vectors for the integral and
    8255         definite quadratic form x; minimal non-zero vectors if bound=0.
    8256         flag is optional, and can be 0: default; 1: returns the first
    8257         minimal vector found (ignore maxnum); 2: as 0 but uses a more
    8258         robust, slower implementation, valid for non integral quadratic
    8259         forms.
     8251    def qfminim(self, B, max=-1, long flag=0):
     8252        """
     8253        Return vectors with bounded norm for this quadratic form.
     8254
     8255        INPUT:
     8256
     8257        - self -- a quadratic form
     8258        - B -- a bound on vector norm (finds minimal non-zero vectors if B=0)
     8259        - max -- maximum number of vectors to return.  If max=-1
     8260          (default), return all vectors of norm at most B
     8261        - flag (optional) --
     8262
     8263           - 0: default;
     8264           - 1: return only the first minimal vector found (ignore max);
     8265           - 2: as 0 but uses a more robust, slower implementation,
     8266             valid for non integral quadratic forms.
     8267
     8268        OUTPUT:
     8269
     8270        - a triple consisting of
     8271
     8272          - the number of vectors of norm <= B,
     8273          - the actual maximum norm of vectors listed
     8274          - a matrix whose columns are vectors with norm less
     8275            than or equal to B for the definite quadratic form.
     8276
     8277        .. note::
     8278
     8279           If max is specified then only max vectors will be output,
     8280           but all vectors withing the given norm bound will be computed.
     8281
     8282
     8283        EXAMPLES:
     8284
     8285        sage: A = Matrix(3,3,[1,2,3,2,5,5,3,5,11])
     8286        sage: A.is_positive_definite()
     8287        True
     8288
     8289        The first 5 vectors of norm at most 10::
     8290
     8291             sage: pari(A).qfminim(10,5).python()
     8292             [
     8293                      [-17 -14 -15 -16 -13]
     8294                      [  4   3   3   3   2]
     8295             146, 10, [  3   3   3   3   3]
     8296             ]
     8297
     8298
     8299        All vectors of minimal norm::
     8300
     8301             sage: pari(A).qfminim(0).python()
     8302             [
     8303                   [-5 -2  1]
     8304                   [ 1  1  0]
     8305             6, 1, [ 1  0  0]
     8306             ]
     8307
     8308        Use flag=2 for non-integral input::
     8309
     8310             sage: pari(A.change_ring(RR)).qfminim(5,max=5,flag=2).python()
     8311             [
     8312                                                          [ -5 -10  -2  -7   3]
     8313                                                          [  1   2   1   2   0]
     8314             10, 5.0000000002328306436538696289062500000, [  1   2   0   1  -1]
     8315             ]
     8316
    82608317        """
    82618318        t0GEN(B)
    82628319        t1GEN(max)
    82638320        sig_on()
    8264         return self.new_gen(qfminim0(self.g,t0,t1,flag,precdl))
     8321        return self.new_gen(qfminim0(self.g,t0,t1 if max!=-1 else NULL,flag,precdl))
    82658322
    82668323    def qfrep(self, B, long flag=0):
    82678324        """