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

« back to all changes in this revision

Viewing changes to monomial.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
1
#include "monomial.h"
2
2
 
 
3
#include "printer.h"
 
4
#include <sstream>
3
5
 
4
6
Monomial::Monomial(PolynomialRing const &r,const IntegerVector &v):exponent(v),theRing(r)
5
7
{
 
8
  if(v.size()!=r.getNumberOfVariables())
 
9
    {
 
10
      AsciiPrinter(Stderr).printPolynomialRing(r);
 
11
      AsciiPrinter(Stderr).printVector(v); 
 
12
      assert(v.size()==r.getNumberOfVariables());
 
13
    }
 
14
}
 
15
 
 
16
 
 
17
string Monomial::toString(bool alwaysWriteSign, bool writeIfOne, bool latex/*, bool mathMode*/)const
 
18
{
 
19
  stringstream s;
 
20
 
 
21
  /*  if(latex & !mathMode)
 
22
    s << "$";
 
23
  */
 
24
  const int sign=1;
 
25
 
 
26
  bool variablePrinted=false;
 
27
  for(int i=0;i<exponent.size();i++)if(exponent[i]*sign>0)
 
28
    {
 
29
      s << getRing().getVariableName(i);
 
30
      if(int(exponent[i]*sign)!=1)
 
31
        {
 
32
          s << "^";
 
33
          if(latex)
 
34
            s << "{";
 
35
          s << int(exponent[i]*sign);
 
36
          if(latex)
 
37
            s << "}";
 
38
        }
 
39
      variablePrinted=true;
 
40
    }
 
41
  if(!variablePrinted && writeIfOne)
 
42
    s<< "1";
 
43
 
 
44
  /*  if(latex & !mathMode)
 
45
    s << "$";
 
46
  */
 
47
  return s.str();
6
48
}