Exemplo n.º 1
0
Arquivo: schur2.cpp Projeto: pzinn/M2
engine_RawArrayPairOrNull SchurRing2::list_form(const Ring *coeffR, const ring_elem f) const
{
  if (coeffR != coefficientRing)
    {
      ERROR("expected coefficient ring of Schur ring");
      return 0;
    }
  const schur_poly *f1 = f.schur_poly_val;
  int n = static_cast<int>(f1->size()); // this is here because the lengths of arrays for M3 front end use int as length field.
  engine_RawMonomialArray monoms = GETMEM(engine_RawMonomialArray, sizeofarray(monoms,n));
  engine_RawRingElementArray coeffs = GETMEM(engine_RawRingElementArray, sizeofarray(coeffs,n));
  monoms->len = n;
  coeffs->len = n;
  engine_RawArrayPair result = newitem(struct engine_RawArrayPair_struct);
  result->monoms = monoms;
  result->coeffs = coeffs;

  // Loop through the terms
  intarray vp;
  schur_poly::iterator i = f1->begin();
  for (int next=0; next<n; ++i, ++next)
    {
      coeffs->array[next] = RingElement::make_raw(coefficientRing, i.getCoefficient());
      toVarpower(i.getMonomial(), vp);
      monoms->array[next] = Monomial::make(vp.raw());
      vp.shrink(0);
    }
  return result;
}
Exemplo n.º 2
0
Arquivo: hash.c Projeto: vidarh/FPL
ReturnCode REGARGS
AddVar(struct Data *scr, /* pointer to struct Data */
       struct Identifier *ident,/* identifier struct pointer */
       struct Local **local,
       uchar output)
{
  ReturnCode ret;
  struct Local *temp;
  if(ret=AddIdentifier(scr, ident))
    INFO(scr, CERROR_IDENTIFIER_USED, ident->name);
  else {
    GETMEM(temp, sizeof(struct Local));  
    temp->next=*local;
    temp->ident=ident;
    *local=temp;

    scr->currvariables++; /* increase number of current symbols */
    scr->totalvariables++; /* increase total number of symbols */
    ident->number= ++IdentNumber;
    if(output) {
      CALL(PutArg(scr, COMP_DECLARE, ident->flags));
      if(!(ident->flags&FPL_EXPORT_SYMBOL)) {
        CALL(PutArg(scr, COMP_NOTHING, ident->number));
      }
      else {
        CALL(PutArg(scr, COMP_NOTHING, ident->hash));
      }
      CALL(PutString(scr, COMP_NOTHING, ident->name, -1));
    }
  }
  return(ret);
}
Exemplo n.º 3
0
Arquivo: hash.c Projeto: vidarh/FPL
ReturnCode REGARGS
AddLevel(struct Data *scr)
{
  struct Local *temp;
  GETMEM(temp, sizeof(struct Local));  
  temp->next=scr->locals;
  temp->ident=NULL;
  scr->locals=temp;
  return(FPL_OK);
}