script conversion magma

+ normalization of tinygb output
parent 83bdcb75
#!/usr/bin/perl
use strict;
use warnings;
my $nbvar;
my $field_card;
chomp($nbvar = <STDIN>);
chomp($field_card = <STDIN>);
print "K := GF($field_card);\n";
print "R<";
for my $i (1 .. ($nbvar - 1)) {
print "x$i,";
}
print "x$nbvar> := PolynomialRing(K, $nbvar, \"grevlex\");\n";
print "sys := [\n";
my $flag_first = 1;
while(<STDIN>) {
chomp();
my $line = $_;
if ("$line" eq ";") {
print ",\n";
$flag_first = 1;
}
else {
my @mon_seq = split(' ', $line);
if ($flag_first == 0) {
print " +\n";
}
$flag_first = 0;
print "$mon_seq[0]*";
for my $i (1 .. ($nbvar - 1)) {
print "x$i^$mon_seq[$i]*";
}
print "x$nbvar^$mon_seq[$nbvar]";
}
}
print "0];\n";
......@@ -26,7 +26,7 @@
#include <map>
#include <set>
#include "timer.h"
//#include "unistd.h"
#include <algorithm>
/****************** Main algorithms ******************/
......@@ -369,10 +369,13 @@ void F4(const vector<polynomial<T> > &sys, vector<polynomial<T> > &res)
log(LOG_INFO) << "------------ cleaning reductors -----------" << endl;
global_reductors.clear();
polynomial<T> tmp_P;
res.clear();
for (unsigned i = 0; i < G.size(); ++i)
{
G[i].to_polynomial(tmp_P);
res.push_back(tmp_P);
}
std::sort(res.begin(), res.end());
std::reverse(res.begin(), res.end());
log(LOG_DEBUG) << "Is minimal: " << gb_is_minimal<T>(res) << endl;
}
......@@ -144,6 +144,10 @@ class polynomial
/// @param out output stream
void print(std::ostream& out) const;
/// @brief compares leading monomials.
/// @param P polynomial to be compared to.
inline bool operator<(const polynomial<T>& P) const;
//human readable formatting
friend std::ostream& operator<< <T>(std::ostream&, const polynomial<T>&);
};
......
......@@ -227,3 +227,9 @@ std::ostream& operator<<(std::ostream& o, const polynomial<T>& p)
o << "+" << it->second << it->first;
return o;
}
template <class T>
inline bool polynomial<T>::operator<(const polynomial<T>& P) const
{
return LM() < P.LM();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment