~ubuntu-branches/ubuntu/saucy/gfan/saucy-proposed

« back to all changes in this revision

Viewing changes to app_initialforms.cpp

  • Committer: Package Import Robot
  • Author(s): Cédric Boutillier
  • Date: 2013-07-09 10:44:01 UTC
  • mfrom: (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130709104401-5q66ozz5j5af0dak
Tags: 0.5+dfsg-3
* Upload to unstable.
* modify remove_failing_tests_on_32bits.patch to replace command of
  0009RenderStairCase test with an empty one instead of deleting it.
* remove lintian override about spelling error

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include  <iostream>
1
2
#include "parser.h"
2
3
#include "printer.h"
3
4
#include "polynomial.h"
6
7
#include "termorder.h"
7
8
#include "gfanapplication.h"
8
9
#include "tropical2.h"
 
10
#include "log.h"
 
11
 
 
12
using namespace std;
9
13
 
10
14
class InitialFormsApplication : public GFanApplication
11
15
{
12
16
  SimpleOption optionIdeal;
13
17
  SimpleOption optionPair;
 
18
  SimpleOption optionMark;
 
19
  SimpleOption optionList;
14
20
public:
15
21
  const char *helpText()
16
22
  {
17
23
    return "This program converts a list of polynomials to a list of their initial forms with respect to the vector given after the list.\n";
18
24
  }
19
25
  InitialFormsApplication():
20
 
    optionIdeal("--ideal","Treat input as an ideal. This will make the program compute the initial ideal of the ideal generated by the input polynomials. The computation is done by computing a Groebner basis with respect to the given vector. The vector must be positive or the input polynomials must be homogenous in a positive grading. None of these conditions are checked by the program.\n"),
21
 
    optionPair("--pair","Produce a pair of polynomial lists. Used together with --ideal this option will also write a compatible reduced Groebner basis for the input ideal to the output. This is useful for finding the Groebner cone of a non-monomial initial ideal.\n")
 
26
    optionIdeal("--ideal","Treat input as an ideal. This will make the program compute the initial ideal of the ideal generated by the input polynomials. The computation is done by computing a Groebner basis with respect to the given vector. The vector must be positive or the input polynomials must be homogeneous in a positive grading. None of these conditions are checked by the program.\n"),
 
27
    optionPair("--pair","Produce a pair of polynomial lists. Used together with --ideal this option will also write a compatible reduced Groebner basis for the input ideal to the output. This is useful for finding the Groebner cone of a non-monomial initial ideal.\n"),
 
28
    optionMark("--mark","If the --pair option is and the --ideal option is not used this option will still make sure that the second output basis is marked consistently with the vector."),
 
29
    optionList("--list","Read in a list of vectors instead of a single vector and produce a list of polynomial sets as output.")
22
30
  {
23
31
    registerOptions();
24
32
  }
25
 
  
26
 
  char *name()
 
33
 
 
34
  const char *name()
27
35
  {
28
36
    return "_initialforms";
29
37
  }
31
39
  int main()
32
40
  {
33
41
    FileParser P(Stdin);
34
 
    
 
42
 
35
43
    PolynomialSet g=P.parsePolynomialSetWithRing();
36
 
    IntegerVector w=P.parseIntegerVector();
37
 
 
38
 
    assert(w.size()==g.getRing().getNumberOfVariables());
39
 
 
40
 
    if(optionIdeal.getValue())
41
 
      {
42
 
        WeightReverseLexicographicTermOrder T(w);
43
 
        buchberger(&g,T);
44
 
      }
45
 
 
46
 
    AsciiPrinter(Stdout).printPolynomialRing(g.getRing());
47
 
    AsciiPrinter(Stdout).printNewLine();
48
 
    AsciiPrinter(Stdout).printPolynomialSet(initialForms(g,w));
49
 
    if(optionPair.getValue())
50
 
      {
51
 
        AsciiPrinter(Stdout).printNewLine();
52
 
        AsciiPrinter(Stdout).printPolynomialSet(g);
53
 
      }
54
 
 
 
44
 
 
45
    IntegerVectorList wList;
 
46
    if(optionList.getValue())
 
47
        wList=P.parseIntegerVectorList();
 
48
    else
 
49
        wList.push_back(P.parseIntegerVector());
 
50
 
 
51
    for(IntegerVectorList::const_iterator i=wList.begin();i!=wList.end();i++)
 
52
    {
 
53
                log1 cerr<<"-\n";
 
54
        assert(i->size()==g.getRing().getNumberOfVariables());
 
55
 
 
56
        if(optionMark.getValue())
 
57
        {
 
58
                WeightReverseLexicographicTermOrder T(*i);
 
59
                g.markAndScale(T);
 
60
        }
 
61
        if(optionIdeal.getValue())
 
62
        {
 
63
                WeightReverseLexicographicTermOrder T(*i);
 
64
                buchberger(&g,T);
 
65
        }
 
66
 
 
67
        pout<<g.getRing()<<"\n"<<initialForms(g,*i);
 
68
        if(optionPair.getValue())
 
69
        {
 
70
                pout<<"\n"<<g;
 
71
        }
 
72
    }
55
73
    return 0;
56
74
  }
57
75
};