Skip to content

Commit e8e17c3

Browse files
committed
switched more C-style arrays to STL vectors
1 parent c3bebb6 commit e8e17c3

File tree

11 files changed

+487
-552
lines changed

11 files changed

+487
-552
lines changed

libsrc/eclib/mwprocs.h

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
//////////////////////////////////////////////////////////////////////////
33
//
44
// Copyright 1990-2023 John Cremona
5-
//
5+
//
66
// This file is part of the eclib package.
7-
//
7+
//
88
// eclib is free software; you can redistribute it and/or modify it
99
// under the terms of the GNU General Public License as published by the
1010
// Free Software Foundation; either version 2 of the License, or (at your
1111
// option) any later version.
12-
//
12+
//
1313
// eclib is distributed in the hope that it will be useful, but WITHOUT
1414
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1515
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1616
// for more details.
17-
//
17+
//
1818
// You should have received a copy of the GNU General Public License
1919
// along with eclib; if not, write to the Free Software Foundation,
2020
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21-
//
21+
//
2222
//////////////////////////////////////////////////////////////////////////
23-
23+
2424

2525
// allow for multiple includes
2626
#ifndef _ECLIB_MWPROCS_
@@ -36,7 +36,7 @@ const int MAXRANK = 30;
3636
const int MAXSATPRIME = 20; // default saturation limit
3737

3838
class mw : public point_processor {
39-
private:
39+
private:
4040
Curvedata *E;
4141
vector<Point> basis;
4242
int rank, maxrank;
@@ -50,7 +50,7 @@ class mw : public point_processor {
5050
public:
5151
mw(Curvedata*, int verb=0, int pp=1, int maxr=999);
5252

53-
// processing of new points, with saturation at primes up to sat
53+
// processing of new points, with saturation at primes up to sat
5454
// (default MAXSATPRIME, none if sat==0)
5555
int process(const bigint& x, const bigint& y, const bigint& z);
5656
int process(const bigint& x, const bigint& y, const bigint& z, int sat);
@@ -60,7 +60,7 @@ class mw : public point_processor {
6060
// saturate the current basis:
6161
int saturate(long& index, vector<long>& unsat, long sat_bd=-1, long sat_low_bd=0);
6262
void search(bigfloat h_lim, int moduli_option=0, int verb=0);
63-
void search_range(bigfloat xmin, bigfloat xmax, bigfloat h_lim,
63+
void search_range(bigfloat xmin, bigfloat xmax, bigfloat h_lim,
6464
int moduli_option=2, int verb=0);
6565
bigfloat regulator(void) {return reg;}
6666
vector<Point> getbasis() {vector<Point> b(basis.begin(),basis.begin()+rank); return b;}
@@ -82,31 +82,27 @@ class sieve {
8282
int verbose, posdisc, firstnl;
8383
bigfloat xmin,x1,x2,x3;
8484
int num_aux;
85-
vector<long> auxs;
86-
int** xgood_mod_aux;
87-
int** x1good_mod_aux;
88-
int** squares;
89-
long* amod;
90-
long *modhits;
85+
vector<long> auxs, amod, modhits;
86+
vector<vector<int>> xgood_mod_aux, squares;
87+
vector<int> cflag;
88+
int use_cflag;
9189
long npoints, ascore, amodc, alim, clim0, clim1, clim2, clim;
92-
int* cflag; int use_cflag;
9390
void a_search(const long& amin, const long& amax);
9491
void a_simple_search(const long& amin, const long& amax);
9592
public:
9693
sieve(void) {;}
97-
sieve(Curvedata * EE, mw* mwb, int moduli_option, int verb=0);
98-
~sieve();
94+
sieve(Curvedata * EE, mw* mwb, int moduli_option, int verb=0);
9995
void search(bigfloat h_lim);
10096
void search_range(bigfloat xmin, bigfloat xmax, bigfloat h_lim);
10197
void stats(); // report sieving statistics
10298
};
10399

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

libsrc/eclib/newforms.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
//////////////////////////////////////////////////////////////////////////
33
//
44
// Copyright 1990-2023 John Cremona
5-
//
5+
//
66
// This file is part of the eclib package.
7-
//
7+
//
88
// eclib is free software; you can redistribute it and/or modify it
99
// under the terms of the GNU General Public License as published by the
1010
// Free Software Foundation; either version 2 of the License, or (at your
1111
// option) any later version.
12-
//
12+
//
1313
// eclib is distributed in the hope that it will be useful, but WITHOUT
1414
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1515
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1616
// for more details.
17-
//
17+
//
1818
// You should have received a copy of the GNU General Public License
1919
// along with eclib; if not, write to the Free Software Foundation,
2020
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21-
//
21+
//
2222
//////////////////////////////////////////////////////////////////////////
2323

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

7575
rational loverp; // L(f,1)/x where x = least real part of a period
@@ -154,23 +154,23 @@ class newforms :public level, splitter_base {
154154
int verbose; long maxdepth, cuspidal, sign;
155155
int basisflag; // is set, then use() only sets bases for newforms
156156
// already defined.
157-
mat opmat(int i, int d, int v=0)
157+
mat opmat(int i, int d, int v=0)
158158
{return h1->opmat(i,d,v);}
159159
vec opmat_col(int i, int j, int v=0)
160160
{return h1->opmat_col(i,j,v);}
161161
mat opmat_cols(int i, const vec& jlist, int v=0)
162162
{return h1->opmat_cols(i,jlist,v);}
163-
mat opmat_restricted(int i, const subspace& s, int d, int v=0)
163+
mat opmat_restricted(int i, const subspace& s, int d, int v=0)
164164
{return h1->opmat_restricted(i,s,d,v);}
165-
smat s_opmat(int i, int d, int v=0)
165+
smat s_opmat(int i, int d, int v=0)
166166
{return h1->s_opmat(i,d,v);}
167167
svec s_opmat_col(int i, int j, int v=0)
168168
{return h1->s_opmat_col(i,j,v);}
169169
smat s_opmat_cols(int i, const vec& jlist, int v=0)
170170
{return h1->s_opmat_cols(i,jlist,v);}
171-
smat s_opmat_restricted(int i, const ssubspace& s, int d, int v=0)
171+
smat s_opmat_restricted(int i, const ssubspace& s, int d, int v=0)
172172
{return h1->s_opmat_restricted(i,s,d,v);}
173-
long matdim(void) {return h1->dimension;}
173+
long matdim(void) {return h1->dimension;}
174174
long matden(void) {return h1->denom1;}
175175
vector<long> eigrange(int i) {return h1->eigrange(i);}
176176
long dimoldpart(const vector<long> l);
@@ -185,7 +185,7 @@ class newforms :public level, splitter_base {
185185
long n1ds, j1ds;
186186
vector<newform> nflist;
187187
vector<int> nf_subset;
188-
newforms(long n, int disp)
188+
newforms(long n, int disp)
189189
:level(n), verbose(disp), of(0), h1(0), h1plus(0), h1minus(0), h1full(0) {;}
190190
~newforms(void);
191191
void display(void) const;
@@ -195,7 +195,7 @@ class newforms :public level, splitter_base {
195195
int get_sign() {return sign;}
196196
void makeh1(int s);
197197
// add newform with basis b1, eiglist l to current list (b2 not used):
198-
void use(const vec& b1, const vec& b2, const vector<long> l);
198+
void use(const vec& b1, const vec& b2, const vector<long> l);
199199

200200
// find newforms using homology; ntp is number of eigenvalues to use
201201
// for oldforms, *not* the number computed via homology (use addap()

libsrc/eclib/periods.h

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
//////////////////////////////////////////////////////////////////////////
33
//
44
// Copyright 1990-2023 John Cremona
5-
//
5+
//
66
// This file is part of the eclib package.
7-
//
7+
//
88
// eclib is free software; you can redistribute it and/or modify it
99
// under the terms of the GNU General Public License as published by the
1010
// Free Software Foundation; either version 2 of the License, or (at your
1111
// option) any later version.
12-
//
12+
//
1313
// eclib is distributed in the hope that it will be useful, but WITHOUT
1414
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1515
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1616
// for more details.
17-
//
17+
//
1818
// You should have received a copy of the GNU General Public License
1919
// along with eclib; if not, write to the Free Software Foundation,
2020
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21-
//
21+
//
2222
//////////////////////////////////////////////////////////////////////////
2323

2424
#ifndef _ECLIB_PERIODS_H
@@ -29,7 +29,7 @@
2929
#define PI Pi()
3030
const bigfloat eps = to_bigfloat(1.0e-16); // ?? mindouble;
3131
#define EULERGAMMA Euler()
32-
32+
3333
bigfloat myg0(bigfloat x);
3434
bigfloat myg1(bigfloat x);
3535
bigfloat myg2(bigfloat x);
@@ -38,11 +38,10 @@ bigfloat myg3(bigfloat x);
3838
class character {
3939
private:
4040
long modul;
41-
int *chartable;
41+
vector<int> chartable;
4242
void init();
4343
public:
4444
character(long m=1);
45-
~character();
4645
void reset(long m);
4746
long modulus(void) {return modul;}
4847
int operator()(long n) {return chartable[n%modul];}
@@ -52,7 +51,7 @@ class summer {
5251
protected:
5352
bigfloat sum1, sum2; // sum2 not necessarily used
5453
long limit, limit1, limit2;
55-
bigfloat rootlimit, rootmod, factor, factor1, factor2, rp, ip;
54+
bigfloat rootlimit, rootmod, factor, factor1, factor2, rp, ip;
5655
long type;
5756
long N, nap; vector<long> aplist; vector<long> primelist;
5857
vector<long> an_cache; // holds a_n for n up to rootlimit
@@ -87,7 +86,7 @@ class periods_via_lfchi :public summer {
8786
bigfloat func1(long n) { return to_bigfloat(chi1(n)) * pow(factor1,to_bigfloat(n)); }
8887
bigfloat func2(long n) { return to_bigfloat(chi2(n)) * pow(factor2,to_bigfloat(n)); }
8988
public:
90-
periods_via_lfchi (const level* iN, const newform* f);
89+
periods_via_lfchi (const level* iN, const newform* f);
9190
void compute(void);
9291
};
9392

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

101100
public:
102-
periods_direct (const level* iN, const newform* f);
101+
periods_direct (const level* iN, const newform* f);
103102
void compute(void);
104-
void compute(long ta, long tb, long tc, long td);
103+
void compute(long ta, long tb, long tc, long td);
105104
// period of (a,b;Nc,d) in Gamma_0(N)
106105
};
107106

108107
class part_period :public summer {
109108
private:
110109
bigfloat efactor,x0,y0,xn;
111-
bigfloat func1(long n) { xn=to_bigfloat(n); efactor = exp(-xn*y0);
110+
bigfloat func1(long n) { xn=to_bigfloat(n); efactor = exp(-xn*y0);
112111
return efactor*cos(xn*x0); }
113112
bigfloat func2(long n) { return efactor*sin(xn*x0); }
114113
void use(long n, long an) {use2(n,an);}
115114

116115
public:
117-
part_period (const level* iN, const newform* f);
116+
part_period (const level* iN, const newform* f);
118117
~part_period () {;}
119118
void compute(const bigcomplex& z0);
120119
void compute();
@@ -133,7 +132,7 @@ class ldash1 : public summer {
133132
void use(long n, long an) {use1(n,an);}
134133
bigfloat func1(long n) { return -G(factor1*to_bigfloat(n)); }
135134
public:
136-
ldash1 (const level* iN, const newform* f);
135+
ldash1 (const level* iN, const newform* f);
137136
ldash1 (const newforms* nf, long i); // the i'th newform
138137
void compute(void);
139138
long rank() {compute(); return r;}
@@ -158,8 +157,8 @@ class lfchi : public summer {
158157
bigfloat scaled_value(void) {return sqrt(to_bigfloat(chi.modulus()))*val;}
159158
};
160159

161-
vector<long> resort_aplist(const level* iN,
162-
const vector<long>& primelist,
160+
vector<long> resort_aplist(const level* iN,
161+
const vector<long>& primelist,
163162
const vector<long>& apl);
164163

165164

libsrc/eclib/reduce.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
//////////////////////////////////////////////////////////////////////////
33
//
44
// Copyright 1990-2023 John Cremona
5-
//
5+
//
66
// This file is part of the eclib package.
7-
//
7+
//
88
// eclib is free software; you can redistribute it and/or modify it
99
// under the terms of the GNU General Public License as published by the
1010
// Free Software Foundation; either version 2 of the License, or (at your
1111
// option) any later version.
12-
//
12+
//
1313
// eclib is distributed in the hope that it will be useful, but WITHOUT
1414
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1515
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1616
// for more details.
17-
//
17+
//
1818
// You should have received a copy of the GNU General Public License
1919
// along with eclib; if not, write to the Free Software Foundation,
2020
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21-
//
21+
//
2222
//////////////////////////////////////////////////////////////////////////
23-
23+
2424
#ifndef _ECLIB_REDUCE_H
2525
#define _ECLIB_REDUCE_H 1
2626
//flags that this file has been included
@@ -42,7 +42,7 @@ void reduce_b(bigint& a, bigint& b, bigint& c, bigint& d, bigint& e,
4242
unimod& m);
4343

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

4747
// Given a pos. def. quadratic x^2+b*x+c, returns a unimod which
4848
// reduces it (whose inverse takes its root into the fundamental

libsrc/eclib/symb.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ class modsym {
6767

6868
class symblist {
6969
private:
70-
symb *list;
70+
vector<symb> list;
7171
map<pair<long,long>,long> hashtable;
7272
long num,maxnum;
7373
public:
74-
symblist(long n=0);
75-
~symblist();
74+
symblist(long n=0);
7675
void add(const symb& s, long start=0);
7776
long index(const symb& s, long start=0) const;
7877
symb operator[](long n) const {return list[n];}

0 commit comments

Comments
 (0)