File: mwprocs.h

package info (click to toggle)
eclib 20221012-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,348 kB
  • sloc: cpp: 48,495; makefile: 259; sh: 127
file content (114 lines) | stat: -rw-r--r-- 4,009 bytes parent folder | download
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
// mwprocs.h: definition of class mw for Mordell-Weil basis
//////////////////////////////////////////////////////////////////////////
//
// 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
// 
//////////////////////////////////////////////////////////////////////////
 

// allow for multiple includes
#ifndef _ECLIB_MWPROCS_
#define _ECLIB_MWPROCS_

#include "saturate.h"
#include "sieve_search.h"

// global to this file -- size of height_pairing matrix, equal
// to maximum rank of any curve likely to study

const int MAXRANK = 30;
const int MAXSATPRIME = 20;  // default saturation limit

class mw : public point_processor {
private: 
  Curvedata *E;
  vector<Point> basis;
  int rank, maxrank;
  bigfloat *height_pairs;
  bigfloat reg;
  int verbose, process_points;
  bigfloat& mat_entry(int i, int j);
  bigint a1,a2,a3,a4,a6;
  int iso;
  saturator satsieve;
public:
  mw(Curvedata*, int verb=0, int pp=1, int maxr=999);
  ~mw();

 // processing of new points, with saturation at primes up to sat 
 // (default MAXSATPRIME,  none if sat==0)
  int process(const bigint& x, const bigint& y, const bigint& z);
  int process(const bigint& x, const bigint& y, const bigint& z, int sat);
 // as returned by ms's sieve; the point is (x/z,y/z^(3/2)) and z is square
  int process(const Point& P, int sat=MAXSATPRIME);
  int process(const vector<Point>& Plist, int sat=MAXSATPRIME);
  // saturate the current basis:
  int saturate(long& index, vector<long>& unsat, long sat_bd=-1, long sat_low_bd=0);
  void search(bigfloat h_lim, int moduli_option=0, int verb=0);
  void search_range(bigfloat xmin, bigfloat xmax, bigfloat h_lim, 
		    int moduli_option=2, int verb=0);
  bigfloat regulator(void) {return reg;}
  vector<Point> getbasis() {vector<Point> b(basis.begin(),basis.begin()+rank); return b;}
  int getrank() {return rank;}
};

inline bigfloat& mw::mat_entry(int i, int j)
{
  return *(height_pairs + (i*MAXRANK) + j);
}

class sieve {
private:
  Curvedata *E;
  bigint a1,a2,a3,a4,a6;
  bigint d1,d2,d3,d4,d6,c2,c3,c4,c6;
  long a,c;
  mw * mwbasis;
  int verbose, posdisc, firstnl;
  bigfloat xmin,x1,x2,x3;
  int num_aux;
  long* auxs;
  int** xgood_mod_aux;
  int** x1good_mod_aux;
  int** squares;
  long* amod;
  long *modhits;
  long npoints, ascore, amodc, alim, clim0, clim1, clim2, clim;
  int* cflag;  int use_cflag;
  void a_search(const long& amin, const long& amax);
  void a_simple_search(const long& amin, const long& amax);
public:
  sieve(void) {;}
  sieve(Curvedata * EE, mw* mwb, int moduli_option, int verb=0); 
  ~sieve();
  void search(bigfloat h_lim);
  void search_range(bigfloat xmin, bigfloat xmax, bigfloat h_lim);
  void stats();   // report sieving statistics
};

int order_real_roots(vector<double>& bnd, vector<bigcomplex> roots);
//checks (and returns) how many roots are actually real, and puts those in 
//bnd, in increasing order, by calling set_the_bound
int set_the_bounds(vector<double>& bnd, bigfloat x0, bigfloat x1, bigfloat x2);
//This transforms (if possible) x0, x1 and x1 into double;  the search 
//should be made on [x0,x1]U[x2,infty] so if x1 or x2 overflows, the search 
//is on [x0,infty].  The function returns 3 in the first case, 1 in the second.
//If x0 overflows, it returns 0.  A warning is printed out.

#endif