forked from JohnCremona/eclib
/
tequiv.cc
90 lines (82 loc) · 2.48 KB
/
tequiv.cc
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
// tequiv.cc: test program for quartic equivalence
//////////////////////////////////////////////////////////////////////////
//
// 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/mquartic.h>
#include <eclib/mequiv.h>
#define NEQPLIST 0 // Number of primes for equiv-test sieving
vector<long> eqplist;
int getquartic(quartic& g, int verbose)
{
bigint a, b, c, d, e;
if(verbose) 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
g.set_equiv_code(eqplist);
return 1;
}
int main()
{
initprimes("PRIMES",0);
cout.precision(50);
cin.flags( cin.flags() | ios::dec ); //force decimal input (bug fix)
int verb; cout << "Verbose? "; cin >> verb;
while (1)
{
long nq; cout << "How many quartics to check (0 to quit)? "; cin >> nq;
cout<<endl<<endl;
if (nq<1) {return 0;}
quartic* glist = new quartic[nq];
vector<bigint> dlist;
int i,j;
for(i=0; i<nq; i++)
{
getquartic(glist[i], verb);
cout<<(i+1)<<": "<<glist[i];
if(verb) cout<<endl;
#ifndef NEW_EQUIV
if(i==0) dlist = sqdivs(glist[i].getdisc());
#endif
int eq=0;
for(j=0; (j<i)&&(!eq); j++)
{
#ifdef NEW_EQUIV
eq = new_equiv(glist+i,glist+j,verb);
#else
eq = equiv(glist+i,glist+j,dlist,verb);
#endif
if(eq) cout<<" equivalent to #"<<(j+1)<<endl;
}
if(!eq) cout<<" new"<<endl;
}
delete[] glist;
}
return(0);
}