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 2cd8bf3 commit c3bebb6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion libsrc/eclib/mrank1.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class rank1 : public rank12 {
long nquarticsa, nquarticsb, nfirstlota, nfirstlotb;
long sha_rank, sha2;
int traceequiv, posdisc, disc_is_square, npairs, extra2, threediv, type;
quartic *qlista, *qlistb;
vector<quartic> qlista, qlistb;
vector<int> qlistbflag;
vector<bigcomplex> croots, cphi;
vector<Point> pointlist1, pointlist2;
Expand Down
42 changes: 19 additions & 23 deletions libsrc/mrank1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ void rank1::addquartic(const bigint& a, const bigint& b, const bigint& c,
long firsti, i, oldnumber=0, thisnumber, nfl;
char ab;
int trivial=0, newone=1, gls=0, els=0;
quartic *qlist, *thisq;;
bigint x,y,z, badp; Point Ptemp;
int btype = 0;
int pivtype=-1; // set to 0 for \infty, 1 for odd prime, 2 for 2
Expand All @@ -152,25 +151,26 @@ void rank1::addquartic(const bigint& a, const bigint& b, const bigint& c,
// only use large quartics for pivoting when there is an odd pivotal
// prime suitable.

vector<quartic>& qlist = (atype? qlista : qlistb);
if(atype)
{qlist=qlista; thisnumber=nquarticsa; nfl=nfirstlota; ab='A';}
{thisnumber=nquarticsa; nfl=nfirstlota; ab='A';}
else
{qlist=qlistb; thisnumber=nquarticsb; nfl=nfirstlotb; ab='B';}
{thisnumber=nquarticsb; nfl=nfirstlotb; ab='B';}

qlist[thisnumber].assign(a,b,c,d,e,croots,type,ii,jj,disc);
thisq=qlist+thisnumber;
quartic& thisq = qlist[thisnumber];

if (verbose) cout << *thisq << "\t";
if (verbose) cout << thisq << "\t";
if (verbose>1)
{
cout << "(ipivot = "<<ipivot<<", type = "<<ab<<") \t";
show_eps_vec(qeps(*thisq,extra2));
show_eps_vec(qeps(thisq,extra2));
cout<<"\t";
}

// Check triviality

if(atype) trivial = thisq->trivial(); // else certainly nontrivial
if(atype) trivial = thisq.trivial(); // else certainly nontrivial
if (trivial)
{
if (verbose) cout << "--trivial"<<endl;
Expand All @@ -180,17 +180,17 @@ void rank1::addquartic(const bigint& a, const bigint& b, const bigint& c,

// Check current is inequivalent to previous

thisq->set_equiv_code(eqplist);
thisq.set_equiv_code(eqplist);
firsti = (extra2==1 ? nfl : 0);
for (i=firsti; newone && (i<thisnumber); i++)
{
if((!atype)&&(!qlistbflag[i])) continue;
if(traceequiv)
cout << "\nTesting equiv with number " << ab<< i+1 << endl;
#ifdef NEW_EQUIV
newone = ! new_equiv(*thisq,qlist[i],traceequiv);
newone = ! new_equiv(thisq,qlist[i],traceequiv);
#else
newone = ! equiv(*thisq,qlist[i],dlist,traceequiv);
newone = ! equiv(thisq,qlist[i],dlist,traceequiv);
#endif
if (!newone) oldnumber=i+1;
}
Expand All @@ -207,9 +207,9 @@ void rank1::addquartic(const bigint& a, const bigint& b, const bigint& c,

if(selmer_only)
{
gls = ratpoint(*thisq,BIGINT(1),BIGINT(lim1),x,y,z);
gls = ratpoint(thisq,BIGINT(1),BIGINT(lim1),x,y,z);
if(gls) els=1;
else els=locallysoluble(*thisq,plist,badp);
else els=locallysoluble(thisq,plist,badp);
if(verbose)
{
if(els) cout<<"locally soluble\n";
Expand All @@ -218,19 +218,19 @@ void rank1::addquartic(const bigint& a, const bigint& b, const bigint& c,
}
else

if (ratpoint(*thisq,BIGINT(1),BIGINT(lim1),x,y,z))
if (ratpoint(thisq,BIGINT(1),BIGINT(lim1),x,y,z))
{
gls=els=1;
if (verbose) cout<<"(x:y:z) = ("<<x<<" : "<<y<<" : "<<z<<")\n";
}
else
{
// cout<<"\nChecking "<<*thisq<<" for local solubility at "<<plist<<endl;
if (locallysoluble(*thisq,plist,badp))
// cout<<"\nChecking "<<thisq<<" for local solubility at "<<plist<<endl;
if (locallysoluble(thisq,plist,badp))
{
els=1;
if (verbose) cout<<"locally soluble..."<<flush;
quartic_sieve qs(thisq,QSIEVE_OPT,0);
quartic_sieve qs(&thisq,QSIEVE_OPT,0);
if(qs.search(lim2))
{
qs.getpoint(x,y,z); gls=1;
Expand All @@ -250,7 +250,7 @@ void rank1::addquartic(const bigint& a, const bigint& b, const bigint& c,
{
if(!selmer_only)
{
qc(*thisq,x,y,z,the_curve,&IJ_curve,tr_u,tr_r,tr_s,tr_t, Ptemp,verbose);
qc(thisq,x,y,z,the_curve,&IJ_curve,tr_u,tr_r,tr_s,tr_t, Ptemp,verbose);
}
if(atype) // we have a quartic in A = ker(eps)
{
Expand Down Expand Up @@ -1419,8 +1419,8 @@ rank1::rank1(Curvedata* ec, int verb, int sel, long lim1, long lim2,long n_aux)
#endif
}

qlista = new quartic[maxnquartics];
qlistb = new quartic[maxnquartics];
qlista.resize(maxnquartics);
qlistb.resize(maxnquartics);
qlistbflag.resize(maxnquartics);
croots.resize(4);

Expand Down Expand Up @@ -1467,8 +1467,6 @@ rank1::rank1(Curvedata* ec, int verb, int sel, long lim1, long lim2,long n_aux)
getquartics();
if (!success)
{
delete [] qlista;
delete [] qlistb;
return;
}

Expand All @@ -1486,8 +1484,6 @@ rank1::rank1(Curvedata* ec, int verb, int sel, long lim1, long lim2,long n_aux)
cout<<"n3 = "<<n3<<endl;
cout<<"B-rank = "<<rank_B<<endl;
}
delete [] qlista;
delete [] qlistb;

if(n3>0){
if(n2>1){
Expand Down

0 comments on commit c3bebb6

Please sign in to comment.