-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
51 lines (47 loc) · 1.54 KB
/
main.cpp
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
#include "buchberger.h"
#include "polynomial.h"
#include <iostream>
#include <iterator>
#include <sstream>
#include <unistd.h>
int main()
{
if (isatty(STDIN_FILENO)) {
std::cout << "groebner-zx Copyright (C) 2020 Daniel Schepler\n";
std::cout << "This program comes with ABSOLUTELY NO WARRANTY.\n";
std::cout << "This is free software, and you are welcome to redistribute it\n";
std::cout << "under the conditions of the GNU General Public License v3\n\n";
std::cout << "Enter the list of polynomials, one on each line as a list of coefficients\n";
std::cout << "e.g. enter x^5 - 3x^2 + x as: 1 0 0 -3 1 0\n";
std::cout << "Then end the list with a blank line or EOF\n";
}
std::string line;
std::vector<polynomial> v;
while (std::getline(std::cin, line) && !line.empty()) {
std::istringstream iss { line };
polynomial p { std::vector<Z> { std::istream_iterator<Z> { iss },
std::istream_iterator<Z> {} } };
v.push_back(std::move(p));
}
std::cout << "< ";
bool first = true;
for (const auto& p : v) {
if (!first)
std::cout << ", ";
std::cout << p.to_string();
first = false;
}
std::cout << " > = " << std::flush;
ideal_basis b { v.begin(), v.end() };
buchberger(b);
std::cout << "< ";
first = true;
for (const auto& p : b) {
if (!first)
std::cout << ", ";
std::cout << p.to_string();
first = false;
}
std::cout << " >\n";
return 0;
}