Skip to content

Commit

Permalink
switched more C-style arrays to STL vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnCremona committed Mar 8, 2024
1 parent c3bebb6 commit e8e17c3
Show file tree
Hide file tree
Showing 11 changed files with 487 additions and 552 deletions.
38 changes: 17 additions & 21 deletions libsrc/eclib/mwprocs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright 1990-2023 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_
Expand All @@ -36,7 +36,7 @@ const int MAXRANK = 30;
const int MAXSATPRIME = 20; // default saturation limit

class mw : public point_processor {
private:
private:
Curvedata *E;
vector<Point> basis;
int rank, maxrank;
Expand All @@ -50,7 +50,7 @@ class mw : public point_processor {
public:
mw(Curvedata*, int verb=0, int pp=1, int maxr=999);

// processing of new points, with saturation at primes up to sat
// 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);
Expand All @@ -60,7 +60,7 @@ class mw : public point_processor {
// 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,
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;}
Expand All @@ -82,31 +82,27 @@ class sieve {
int verbose, posdisc, firstnl;
bigfloat xmin,x1,x2,x3;
int num_aux;
vector<long> auxs;
int** xgood_mod_aux;
int** x1good_mod_aux;
int** squares;
long* amod;
long *modhits;
vector<long> auxs, amod, modhits;
vector<vector<int>> xgood_mod_aux, squares;
vector<int> cflag;
int use_cflag;
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();
sieve(Curvedata * EE, mw* mwb, int moduli_option, int verb=0);
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
//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
//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.

Expand Down
34 changes: 17 additions & 17 deletions libsrc/eclib/newforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright 1990-2023 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
//
//
//////////////////////////////////////////////////////////////////////////

#ifndef _ECLIB_NEWFORMS_H
Expand Down Expand Up @@ -48,9 +48,9 @@ Items 1-18 are "int" while the ap and aq are "short"
9. lminus : prime =3 (mod 4) with L(f,lminus,1) nonzero
10. mminus : L(f,lminus,1)*sqrt(-l)=mminus*yi
11-14. a, b, c, d : entries of a matrix M=[a,b;N*c,d] in Gamma_0(N) s.t.
15. dotplus : the integral of f over {0,M(0)} is
15. dotplus : the integral of f over {0,M(0)} is
16. dotminus : dotplus*x+dotminus*yi
17. type : type 1 if period lattice = [2x,x+yi], type 2 if [x,yi]
17. type : type 1 if period lattice = [2x,x+yi], type 2 if [x,yi]
18. degphi : degree of modular parametrization
aq : list of Wq-eigenvalues at bad primes
ap : list of Tp- & Wq-eigenvalues at all primes
Expand All @@ -62,14 +62,14 @@ class newform {
newforms *nf; // the "parent"
int sign; // 1/-1 for old-style newform, 0 for old-style h1newform
vec bplus,bminus; // DUAL eigenvectors
scalar type; // 2 for rectangular, 1 for triangular
scalar type; // 2 for rectangular, 1 for triangular
// period lattice
long index; // splitting index, -1 if not known
vector<long> aplist, aqlist;
vector<long> aplist, aqlist;
long ap0; // Eigenvalue of first "good" p
long sfe; // sign of functional equation
long cuspidalfactorplus, cuspidalfactorminus; // pdot =cuspidalfactor*np0
long pdot,np0,dp0; // np0=1+p0-ap0, pdot = maninvector(p0).bplus,
long pdot,np0,dp0; // np0=1+p0-ap0, pdot = maninvector(p0).bplus,
// = cuspidalfactor*dp0

rational loverp; // L(f,1)/x where x = least real part of a period
Expand Down Expand Up @@ -154,23 +154,23 @@ class newforms :public level, splitter_base {
int verbose; long maxdepth, cuspidal, sign;
int basisflag; // is set, then use() only sets bases for newforms
// already defined.
mat opmat(int i, int d, int v=0)
mat opmat(int i, int d, int v=0)
{return h1->opmat(i,d,v);}
vec opmat_col(int i, int j, int v=0)
{return h1->opmat_col(i,j,v);}
mat opmat_cols(int i, const vec& jlist, int v=0)
{return h1->opmat_cols(i,jlist,v);}
mat opmat_restricted(int i, const subspace& s, int d, int v=0)
mat opmat_restricted(int i, const subspace& s, int d, int v=0)
{return h1->opmat_restricted(i,s,d,v);}
smat s_opmat(int i, int d, int v=0)
smat s_opmat(int i, int d, int v=0)
{return h1->s_opmat(i,d,v);}
svec s_opmat_col(int i, int j, int v=0)
{return h1->s_opmat_col(i,j,v);}
smat s_opmat_cols(int i, const vec& jlist, int v=0)
{return h1->s_opmat_cols(i,jlist,v);}
smat s_opmat_restricted(int i, const ssubspace& s, int d, int v=0)
smat s_opmat_restricted(int i, const ssubspace& s, int d, int v=0)
{return h1->s_opmat_restricted(i,s,d,v);}
long matdim(void) {return h1->dimension;}
long matdim(void) {return h1->dimension;}
long matden(void) {return h1->denom1;}
vector<long> eigrange(int i) {return h1->eigrange(i);}
long dimoldpart(const vector<long> l);
Expand All @@ -185,7 +185,7 @@ class newforms :public level, splitter_base {
long n1ds, j1ds;
vector<newform> nflist;
vector<int> nf_subset;
newforms(long n, int disp)
newforms(long n, int disp)
:level(n), verbose(disp), of(0), h1(0), h1plus(0), h1minus(0), h1full(0) {;}
~newforms(void);
void display(void) const;
Expand All @@ -195,7 +195,7 @@ class newforms :public level, splitter_base {
int get_sign() {return sign;}
void makeh1(int s);
// add newform with basis b1, eiglist l to current list (b2 not used):
void use(const vec& b1, const vec& b2, const vector<long> l);
void use(const vec& b1, const vec& b2, const vector<long> l);

// find newforms using homology; ntp is number of eigenvalues to use
// for oldforms, *not* the number computed via homology (use addap()
Expand Down
33 changes: 16 additions & 17 deletions libsrc/eclib/periods.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright 1990-2023 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
//
//
//////////////////////////////////////////////////////////////////////////

#ifndef _ECLIB_PERIODS_H
Expand All @@ -29,7 +29,7 @@
#define PI Pi()
const bigfloat eps = to_bigfloat(1.0e-16); // ?? mindouble;
#define EULERGAMMA Euler()

bigfloat myg0(bigfloat x);
bigfloat myg1(bigfloat x);
bigfloat myg2(bigfloat x);
Expand All @@ -38,11 +38,10 @@ bigfloat myg3(bigfloat x);
class character {
private:
long modul;
int *chartable;
vector<int> chartable;
void init();
public:
character(long m=1);
~character();
void reset(long m);
long modulus(void) {return modul;}
int operator()(long n) {return chartable[n%modul];}
Expand All @@ -52,7 +51,7 @@ class summer {
protected:
bigfloat sum1, sum2; // sum2 not necessarily used
long limit, limit1, limit2;
bigfloat rootlimit, rootmod, factor, factor1, factor2, rp, ip;
bigfloat rootlimit, rootmod, factor, factor1, factor2, rp, ip;
long type;
long N, nap; vector<long> aplist; vector<long> primelist;
vector<long> an_cache; // holds a_n for n up to rootlimit
Expand Down Expand Up @@ -87,7 +86,7 @@ class periods_via_lfchi :public summer {
bigfloat func1(long n) { return to_bigfloat(chi1(n)) * pow(factor1,to_bigfloat(n)); }
bigfloat func2(long n) { return to_bigfloat(chi2(n)) * pow(factor2,to_bigfloat(n)); }
public:
periods_via_lfchi (const level* iN, const newform* f);
periods_via_lfchi (const level* iN, const newform* f);
void compute(void);
};

Expand All @@ -99,22 +98,22 @@ class periods_direct :public summer {
void use(long n, long an);

public:
periods_direct (const level* iN, const newform* f);
periods_direct (const level* iN, const newform* f);
void compute(void);
void compute(long ta, long tb, long tc, long td);
void compute(long ta, long tb, long tc, long td);
// period of (a,b;Nc,d) in Gamma_0(N)
};

class part_period :public summer {
private:
bigfloat efactor,x0,y0,xn;
bigfloat func1(long n) { xn=to_bigfloat(n); efactor = exp(-xn*y0);
bigfloat func1(long n) { xn=to_bigfloat(n); efactor = exp(-xn*y0);
return efactor*cos(xn*x0); }
bigfloat func2(long n) { return efactor*sin(xn*x0); }
void use(long n, long an) {use2(n,an);}

public:
part_period (const level* iN, const newform* f);
part_period (const level* iN, const newform* f);
~part_period () {;}
void compute(const bigcomplex& z0);
void compute();
Expand All @@ -133,7 +132,7 @@ class ldash1 : public summer {
void use(long n, long an) {use1(n,an);}
bigfloat func1(long n) { return -G(factor1*to_bigfloat(n)); }
public:
ldash1 (const level* iN, const newform* f);
ldash1 (const level* iN, const newform* f);
ldash1 (const newforms* nf, long i); // the i'th newform
void compute(void);
long rank() {compute(); return r;}
Expand All @@ -158,8 +157,8 @@ class lfchi : public summer {
bigfloat scaled_value(void) {return sqrt(to_bigfloat(chi.modulus()))*val;}
};

vector<long> resort_aplist(const level* iN,
const vector<long>& primelist,
vector<long> resort_aplist(const level* iN,
const vector<long>& primelist,
const vector<long>& apl);


Expand Down
14 changes: 7 additions & 7 deletions libsrc/eclib/reduce.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright 1990-2023 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
//
//
//////////////////////////////////////////////////////////////////////////

#ifndef _ECLIB_REDUCE_H
#define _ECLIB_REDUCE_H 1
//flags that this file has been included
Expand All @@ -42,7 +42,7 @@ void reduce_b(bigint& a, bigint& b, bigint& c, bigint& d, bigint& e,
unimod& m);

// Compute the quadratic covariant of a real quartic:
bigfloat* quadratic_covariant(bigint& a, bigint& b, bigint& c, bigint& d, bigint& e);
vector<bigfloat> quadratic_covariant(bigint& a, bigint& b, bigint& c, bigint& d, bigint& e);

// Given a pos. def. quadratic x^2+b*x+c, returns a unimod which
// reduces it (whose inverse takes its root into the fundamental
Expand Down
5 changes: 2 additions & 3 deletions libsrc/eclib/symb.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ class modsym {

class symblist {
private:
symb *list;
vector<symb> list;
map<pair<long,long>,long> hashtable;
long num,maxnum;
public:
symblist(long n=0);
~symblist();
symblist(long n=0);
void add(const symb& s, long start=0);
long index(const symb& s, long start=0) const;
symb operator[](long n) const {return list[n];}
Expand Down
Loading

0 comments on commit e8e17c3

Please sign in to comment.