Exemple #1
0
void IISource::get(Term& x) {
#if 1
  x.setToOne();
  int type = getType();
  if(type==GBInputNumbers::s_IOFUNCTION) {
    pair<bool,Alias<ISource> > pr(queryNamedFunction("Times"));
    if(pr.first) {
      pr.second.access().get(x.Coefficient());
      pr.second.access().get(x.MonomialPart());
    } else {
      pair<bool,Alias<ISource> > pr2(queryNamedFunction("Rational"));
      if(pr2.first) {
        pr2.second.access().get(x.Coefficient());
      } else {
        get(x.MonomialPart());
      };
    };
  } else if(type==GBInputNumbers::s_IOINTEGER) {
    get(x.Coefficient());
  } else {
    get(x.MonomialPart());
  };
#else
  DBG();
#endif
};
Exemple #2
0
void GrbSource::get(Term& x) {
  char c;
  d_so.peekCharacter(c,"\n *");
  if(c=='+') { 
    d_so.passCharacter();
    d_so.peekCharacter(c,"\n *");
  };
  if(c=='-' || ('0'<=c && c <= '9')) {
    // have a number first
    get(x.Coefficient());
    get(x.MonomialPart());
  } else if('a'<=c && c <= 'z') {
    x.Coefficient().setToOne();
    get(x.MonomialPart());
  } else if('A'<=c && c <= 'Z') {
    x.Coefficient().setToOne();
    get(x.MonomialPart());
  } else if(c=='(') {
    d_so.getCharacter(c,"\n *");
    if(c!='1') errorc(__LINE__);
    d_so.getCharacter(c,"\n *");
    if(c!=')') errorc(__LINE__);
    x.Coefficient().setToOne();
    x.MonomialPart().setToOne();
  } else errorc(__LINE__);
  d_eoi = d_so.eof();
};
Exemple #3
0
void Polynomial::doubleProduct(const Field & f,const Monomial & x,
        const Polynomial &  poly,const Monomial & y) {
  if(&poly==this) errorc(__LINE__);
#ifdef CHECK_FOR_ZERO_COEFFICIENTS
GBStream << "MXS:doubleProduct:poly:" << poly << '\n';
GBStream << "MXS:doubleProduct:aTerm:" << aTerm << '\n';
GBStream << "MXS:doubleProduct:bTerm:" << bTerm << '\n';
#endif
  setToZero();
  if(!f.zero())  {
    const int sz = poly.numberOfTerms();
    PolynomialIterator w = poly.begin();
    Term t;
    for(int i=1;i<=sz;++i,++w) {
      t = *w;
      t.Coefficient() *= f;
      Monomial & m = t.MonomialPart();
      Monomial result(x);
      result *= m;
      result *= y;
      m = result;
      addTermToEnd(t);
    }
  }
};