File: quartic_points.cc

package info (click to toggle)
eclib 20190909-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,196 kB
  • sloc: cpp: 47,090; makefile: 251; sh: 122
file content (117 lines) | stat: -rw-r--r-- 3,527 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// quartic_points.cc:  program to search for points on quartics and map to curve
//////////////////////////////////////////////////////////////////////////
//
// Copyright 1990-2012 John Cremona
// 
// This file is part of the eclib package.
// 
// eclib is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
// 
// eclib is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License
// along with eclib; if not, write to the Free Software Foundation,
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
// 
//////////////////////////////////////////////////////////////////////////
 
#include <eclib/marith.h>
#include <eclib/points.h>
#include <eclib/mquartic.h>
#include <eclib/msoluble.h>
#include <eclib/qc.h>
#include <eclib/version.h>


int getquartic(quartic& g)
{
  bigint a, b, c, d, e;
  
  cout << "Enter quartic coefficients a,b,c,d,e ?" << endl;
  char ch; cin>>ch;
  if(ch=='(') cin>>a>>ch>>b>>ch>>c>>ch>>d>>ch>>e>>ch;
     else 
     {
       cin.putback(ch);
       cin >> a >> b >> c >> d >> e;
     }
     
  if (is_zero(a)&&is_zero(b)&&is_zero(c)&&is_zero(d)&&is_zero(e))
     return 0;
    
  g=quartic(a,b,c,d,e);  // will set its own invariants, roots and type
  return 1;
}

int main()
{
  show_version();
  cout.precision(10);
  cin.flags( cin.flags() | ios::dec );
  
  int verb; cout << "Verbose? "; cin >> verb;
  initprimes("PRIMES",0);
  int modopt=0;
  //  cout<<"moduli option (0 (Stoll)/ 1/2/3)?";      cin >> modopt;

  quartic g;

  while (getquartic(g))
    {
      double hlim;
      cout << "Limit on height? "; cin >> hlim;

      bigint I = g.getI(), J=g.getJ(), zero=BIGINT(0);
      Curvedata IJ_curve(zero,zero,zero,-27*I,-27*J,0);
      bigint tr_u,tr_r,tr_s,tr_t;
      Curvedata E = IJ_curve.minimalize(tr_u,tr_r,tr_s,tr_t);

      cout << "I = " << I << ", J = " << J << "\n";
      cout << "Minimal model for Jacobian: " << (Curve)E << endl;

      bigint badp;
      vector<bigint> plist = pdivs(6*g.getdisc());
      unsigned int i, els, els1;

      cout << "Checking local solublity in R:\n";
      els = ((g.gettype()>1)||(g.geta()>BIGINT(0)));
      if(!els) cout << "Not locally soluble over R\n";

      cout << "Checking local solublity at primes " << plist << ":\n";
      els1 = qpsoluble(g,BIGINT(2));
      if(!els1) cout << "Not locally soluble at p = 2\n";
      els = els&els1;

      for (i=1; i<plist.size(); i++)
	{
	  els1=new_qpsoluble(g,plist[i],verb);
	  if(!els1) cout << "Not locally soluble at p = "<<plist[i]<<"\n";
	  els = els&els1;
	}
      if(!els) continue;
      
      cout << "Everywhere locally soluble.\n";
      
      quartic_sieve qs(&g,modopt,verb);
      cout << "Searching for points on "<<g<<" up to height "<<hlim<<endl;

      if(qs.search(hlim))
	{
	  bigint x, y, z;
	  qs.getpoint(x,y,z);
	  cout << "(x:y:z) = (" << x << ":" << y << ":" << z << ")\n";
	  Point P;
	  qc(g,x,y,z,&E,&IJ_curve,tr_u,tr_r,tr_s,tr_t,P,1);
	  cout << "Curve = " << (Curve)(E) << "\n";
	  cout << "Point = " << P << "\n";
	  cout << "height = " << height(P)<< "\n";
	}
      else cout << "No point found!\n";
    }
}