1 // descent.h: declaration of classes rank12 and two_descent
2 //////////////////////////////////////////////////////////////////////////
3 //
4 // Copyright 1990-2012 John Cremona
5 //
6 // This file is part of the eclib package.
7 //
8 // eclib is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 2 of the License, or (at your
11 // option) any later version.
12 //
13 // eclib is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 // for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with eclib; if not, write to the Free Software Foundation,
20 // Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef _ECLIB_DESCENT_H_
25 #define _ECLIB_DESCENT_H_
26 
27 #include "mwprocs.h"
28 
29 // rank12 is a common base for separate classes rank1 and rank2 (for
30 // computing rank via general 2-descent and descent via 2-isogeny
31 // repectively); class two_descent is a user interface to these
32 
33 // rank12 must be given a minimal (integral) model.  two_descent can
34 // be given a non-minimal (integral) model, and will work with the
35 // minimal model; any points returned will be transferred back to the
36 // original model
37 
38 class rank1;
39 class rank2;
40 class two_descent;
41 
42 class rank12 {
43 protected:
44   Curvedata* the_curve;
45   int verbose, certain, success, selmer_only, do_second_descent;
46   long num_aux;
47   long rank, rank_bound, selmer_rank;
48   Curvedata IJ_curve;  // [0,0,0,-27*I,-27*J]
49   bigint tr_u,tr_r,tr_s,tr_t;  // transformation from latter to minimal curve
50   long lim1, lim2;
51 public:
52 
53 // Constructor:
54 //
55 // sel is selmer_only switch
56 // firstlim is bound on |x|+|z|
57 // secondlim is bound on log max {|x|,|z| }, i.e. logarithmic
58 // n_aux only relevant for general 2-descent when 2-torsion trivial
59 // n_aux=-1 causes default to be used (depends on method)
60 // second_descent only relevant for descent via 2-isogeny
61 
rank12()62   rank12(){;}
63   rank12(Curvedata* ec,
64          int verb=0, int sel=0,
65          long firstlim=20, long secondlim=5,
66 	 long n_aux=-1, int second_descent=1)
the_curve(ec)67     :the_curve(ec), verbose(verb), selmer_only(sel),
68      do_second_descent(second_descent),
69      num_aux(n_aux), lim1(firstlim), lim2(secondlim) {;}
~rank12()70   virtual ~rank12() {;}
getrank()71   long getrank() const {return rank;}
getrankbound()72   long getrankbound() const {return rank_bound;}
getselmer()73   long getselmer() const {return selmer_rank;}
getcertain()74   long getcertain()  const {return certain;}
ok()75   int ok()      const {return success;}
76   //
77   virtual long getselmerprime() const=0;
78   virtual Curvedata getEprime() const=0;
79   virtual long getselmerphi() const=0;
80   virtual long getselmerphiprime() const=0;
81   //
82   virtual void listpoints()=0;
83   virtual void listpoints(Curvedata* CD_orig,
84 			  const bigint& u, const bigint& r,
85 			  const bigint& s, const bigint& t)=0;
86   virtual vector<Point> getgens() const =0;
87   virtual vector<Point> getpoints() =0;
88 };
89 
90 
91 class two_descent {
92 private: rank12 * r12;  // does all the work
93   int verbose, two_torsion_exists, selmer_only;
94   int success, certain, fullmw;
95   long rank, rank_bound, selmer_rank, sat_bound;
96   mw* mwbasis;
97   vector<bigrational> qai;  // Coefficients of initial curve
98   Curvedata e_orig, e_min;
99   bigint u,r,s,t; // transform between e_orig and e_min
100   bigint v;       // scaling factor needed to make input curve integral
101   void do_the_descent(long firstlim, long secondlim, long n_aux,
102 		      int second_descent); //  (called by constructors)
103 public:
104 // Constructor:
105 //
106 // sel is selmer_only switch
107 // firstlim is bound on |x|+|z|
108 // secondlim is bound on log max {|x|,|z| }, i.e. logarithmic
109 // n_aux only relevant for general 2-descent when 2-torsion trivial
110 // n_aux=-1 causes default to be used (depends on method)
111 // second_descent only relevant for descent via 2-isogeny
112 
113   two_descent(Curvedata* ec,
114 	      int verb=0, int sel=0,
115 	      long firstlim=20, long secondlim=5,
116 	      long n_aux=-1, int second_descent=1);
117   // Version which takes a vector [a1,a2,a3,a4,a6] of *rationals*
118   two_descent(vector<bigrational> ai,
119 	      int verb=0, int sel=0,
120 	      long firstlim=20, long secondlim=5,
121 	      long n_aux=-1, int second_descent=1);
~two_descent()122   ~two_descent() {delete r12; delete mwbasis;}
getrank()123   long getrank() const {return rank;}
getrankbound()124   long getrankbound() const {return rank_bound;}
getselmer()125   long getselmer() const {return selmer_rank;}
getselmerprime()126   long getselmerprime() const {return r12->getselmerprime();}
getEprime()127   Curvedata getEprime() const {return r12->getEprime();}
getselmerphi()128   long getselmerphi() const {return r12->getselmerphi();}
getselmerphiprime()129   long getselmerphiprime() const {return r12->getselmerphiprime();}
getcertain()130   long getcertain()  const {return certain;}
ok()131   int ok()      const {return success;}
get2t()132   int get2t() const {return two_torsion_exists;}
getfullmw()133   int getfullmw() const {return fullmw;}
regulator()134   bigfloat regulator() {return mwbasis->regulator();}
135   vector<P2Point> getbasis(); // returns points on original model
136   vector<Point> getpbasis();  // returns points on integral model
137   void report_rank() const;
138  // sat_bd=0 for none; assume saturated at p<=sat_low_bd
139   void saturate(long sat_bd, long sat_low_bd=2);
140   void show_gens(); // display points on original model
141   void show_result_status();
142   void pari_output();
143 };
144 
145 #endif
146