1 // mrank2.h: declaration of class rank2 for descent via 2-isogeny
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 #if     !defined(_ECLIB_MRANK2_H)
25 #define _ECLIB_MRANK2_H      1       //flags that this file has been included
26 
27 #include <eclib/descent.h>
28 
29 class rank2 : public rank12 { // class to do 2-descent via 2-isogeny
30 private:
31   vector<bigint> badprimes, supp0, supp1;
32   vector<bigint> elsgens0, elsgens1, els2gens0, els2gens1, glsgens0, glsgens1;
33   long selmer_rank_phi_Eprime, selmer_rank_phiprime_E, selmer_rank_Eprime;
34   long best_rank_bound, best_isogeny, index2;
35   long nt2gens0, nt2gens1, mask0, mask1;
36   long els0, els1, gls0, gls1;   // after first descent
37   long els20, els21, gls20, gls21;   // after second descent
38   int d_is_sq, ddash_is_sq;
39   bigint e2, e3, e2dash, e3dash, s2, s4, s6;
40   Curvedata ee, eedash, Eprime;
41   vector<Point> pointlist, fullpointlist, two_torsion;
42   int npoints, npoints1, fullnpoints, ntwo_torsion;
43 public:
44   rank2(Curvedata* ec, int verb,int sel=0, long l1=20, long l2=5,int second=1);
45 // lim1  is (bigint) bound on |x|+|z| in naive search
46 // lim2 is (double) bound on log max {|x|,|z| }, i.e. logarithmic
47 // sel is selmer_only switch
48 // second is do-second-descent switch
getEprime()49   Curvedata getEprime() const {return Eprime;}
getselmerprime()50   long getselmerprime() const {return selmer_rank_Eprime;}
getselmerphi()51   long getselmerphi() const {return selmer_rank_phi_Eprime;}
getselmerphiprime()52   long getselmerphiprime() const {return selmer_rank_phiprime_E;}
53   void listgens();
54   void listgens(Curvedata* CD_orig, const bigint& u, const bigint& r,
55 		const bigint& s, const bigint& t);
56   void listpoints();
57   void listpoints(Curvedata* CD_orig, const bigint& u, const bigint& r,
58 		  const bigint& s, const bigint& t);
59   void makepoints();
getpoints()60   vector<Point> getpoints()
61   {
62     if(fullnpoints==0) makepoints();
63     return fullpointlist;
64   }
getgens()65   vector<Point> getgens() const {return pointlist;}
66 private:
67   int testquartic(const bigint& c, const bigint& d1, const bigint& d2, int which);
68   int second_descent(const bigint& c, const bigint& d1, const bigint& d2, int which);
69   void makepoint(const bigint& c, const bigint& d1, const bigint& d2,
70 		 const bigint& x, const bigint& y, const bigint& z,
71 		 int which);
72   void local_descent(const bigint& x0);
73   void find_elsgens(int which, const bigint& c, const bigint& d);
74   void find_els2gens(int which, const bigint& c, const bigint& d);
75   void find_glsgens(int which, const bigint& c, const bigint& d);
76   void makegens();
77 };
78 
79 #endif
80