示例#1
0
void PolynomialRing::initialize_PolynomialRing(
                                               const Ring *K,
                                               const Monoid *M,
                                               const PolyRing *numeratorR,
                                               const PolynomialRing *ambientR,
                                               const Ring *denomR)
{
  nvars_ = M->n_vars();
  K_ = K;
  M_ = M;
  numerR_ = numeratorR;
  ambientR_ = ambientR;
  denomR_ = denomR;

  exp_size = EXPONENT_BYTE_SIZE(nvars_);

  if (K->is_QQ() || (K == globalZZ && denomR != 0))
    coeff_type_ = Ring::COEFF_QQ;
  else if (K == globalZZ && denomR == 0)
    coeff_type_ = Ring::COEFF_ZZ;
  else
    coeff_type_ = Ring::COEFF_BASIC;

  is_weyl_ = false;
  is_solvable_ = false;
  is_skew_ = false;
  overZZ_ = false;
  qinfo_ = new QRingInfo;
  is_ZZ_quotient_ = false;
  ZZ_quotient_value_ = ZERO_RINGELEM;

  if (numeratorR != this)
    {
      // We must set the non-commutative settings ourselves at this time
      if (numeratorR->cast_to_WeylAlgebra() != 0)
        is_weyl_ = true;
      else if (numeratorR->cast_to_SolvableAlgebra() != 0)
        is_solvable_ = true;
      else if (numeratorR->is_skew_commutative())
        {
          is_skew_ = true;
          skew_ = numeratorR->getSkewInfo();
        }
    }

  poly_size_ = 0; // The callee needs to set this later
  gb_ring_ = 0;  // The callee needs to set this later

  // Also: callee should call setIsGraded, and set oneV, minus_oneV, zeroV
}
示例#2
0
GBKernelComputation::GBKernelComputation(const GBMatrix *m)
    : F(m->get_free_module()),
      n_ones(0),
      n_unique(0),
      n_others(0),
      total_reduce_count(0)
{
  const PolynomialRing *R0 = F->get_ring()->cast_to_PolynomialRing();
  GR = R0->get_gb_ring();
  R = R0;
  K = R->getCoefficients();
  M = R->getMonoid();

  G = FreeModule::make_schreyer(m);
  SF = F->get_schreyer_order();
  SG = G->get_schreyer_order();

  exp_size = EXPONENT_BYTE_SIZE(M->n_vars());
  monom_size = MONOMIAL_BYTE_SIZE(M->monomial_size());

  // Set 'gb'.
  strip_gb(m);
}
示例#3
0
文件: monoid.cpp 项目: BertiniM2/M2
Monoid::Monoid(const MonomialOrdering *mo,
               M2_ArrayString names,
               const PolynomialRing *deg_ring,
               M2_arrayint degs,
               M2_arrayint hefts)
    : nvars_(rawNumberOfVariables(mo)),
      varnames_(names),
      degvals_(degs),
      heftvals_(hefts),
      degree_ring_(deg_ring),
      degree_monoid_(deg_ring->getMonoid()),
      mo_(mo)
{
  monorder_ = monomialOrderMake(mo);

  monomial_size_ = monorder_->nslots;
  n_before_component_ = monorder_->nslots_before_component;
  n_after_component_ = monomial_size_ - n_before_component_;
  component_up_ = monorder_->component_up;

  // Set nslots_
  int total = 0;
  for (int i = 0; i < monorder_->nblocks; i++)
    {
      total += monorder_->blocks[i].nslots;
      nslots_.push_back(total);
    }

  // Set first_weight_value_
  bool get_out = false;
  first_weights_slot_ = -1;
  for (int i = 0; i < monorder_->nblocks && !get_out; i++)
    {
      switch (monorder_->blocks[i].typ)
        {
          case MO_LEX:
          case MO_LEX2:
          case MO_LEX4:
          case MO_NC_LEX:
            get_out = true;
            break;
          case MO_REVLEX:
          case MO_LAURENT:
          case MO_LAURENT_REVLEX:
          case MO_GREVLEX:
          case MO_GREVLEX2:
          case MO_GREVLEX4:
          case MO_GREVLEX_WTS:
          case MO_GREVLEX2_WTS:
          case MO_GREVLEX4_WTS:
          case MO_WEIGHTS:
            first_weights_slot_ = 0;
          case MO_POSITION_UP:
            continue;
          case MO_POSITION_DOWN:
            continue;
          default:
            INTERNAL_ERROR("monomial order block type not handled");
        }
    }
  exp_size = EXPONENT_BYTE_SIZE(nvars_);

  n_invertible_vars_ = rawNumberOfInvertibleVariables(mo_);

  set_degrees();
  set_overflow_flags();

  local_vars = rawNonTermOrderVariables(mo);

  // Debugging only:
  //  fprintf(stderr, "%d variables < 1\n", local_vars->len);
  //  if (local_vars->len > 0)
  //    {
  //      fprintf(stderr, "they are: ");
  //      for (int i=0; i<local_vars->len; i++)
  //      fprintf(stderr, "%d ", local_vars->array[i]);
  //      fprintf(stderr, "\n");
  //    }
}
示例#4
0
文件: res-a1.cpp 项目: BertiniM2/M2
void res_comp::initialize(const Matrix *mat, int LengthLimit, int /*strategy*/)
{
  int i;

  P = mat->get_ring()->cast_to_PolynomialRing();
  assert(P != NULL);
  R = new res_poly(const_cast<PolynomialRing *>(P));
  M = P->getMonoid();
  K = P->getCoefficientRing();
  generator_matrix = mat;

  // These next two lines may be added next (5/2/06)
  //  res_degree_stash      = new stash("resDegree", sizeof(res_degree));
  //  res_level_stash       = new stash("resLevel", sizeof(res_level));
  res_pair_stash = new stash("respair", sizeof(res_pair));
  mi_stash = new stash("res minodes", sizeof(Nmi_node));

  for (i = 0; i <= LengthLimit; i++) resn.append(new res_level);

  max_degree = M->max_degree();
  length_limit = LengthLimit;
  if (mat->n_rows() > 0)
    {
      lodegree = mat->rows()->primary_degree(0);
      for (i = 1; i < mat->n_rows(); i++)
        if (lodegree > mat->rows()->primary_degree(i))
          lodegree = mat->rows()->primary_degree(i);
    }
  else
    lodegree = 0;

  for (i = 0; i < mat->n_cols(); i++)
    if (lodegree > mat->cols()->primary_degree(i) - 1)
      lodegree = mat->cols()->primary_degree(i) - 1;

  hidegree = lodegree;
  n_level = 2;
  n_degree = lodegree;

  component_number = 0;
  next_me_number = 0;
  const SchreyerOrder *S = mat->rows()->get_schreyer_order();
  for (i = 0; i < mat->n_rows(); i++)
    {
      res_pair *p = new_res_pair();

      p->me = component_number++;
      p->minimal_me = p->me;
      next_me_number++;  // this and 'component_number' should still be equal
                         // here.
      p->compare_num = i;

      if (S == 0)
        p->base_monom = M->make_one();
      else
        p->base_monom = M->make_new(S->base_monom(i));
      p->mi = new MonomialIdeal(P, mi_stash);
      p->syz_type = SYZ_MINIMAL;
      p->base_comp = p;
      base_components.append(p);
      search_mi.append(new MonomialIdeal(P, mi_stash));

      int d = mat->rows()->primary_degree(i);
      res_degree *mypairs = make_degree_set(0, d);
      p->next = mypairs->first;
      mypairs->first = p;
      mypairs->npairs++;
      resn[0]->npairs++;
      npairs++;
    }

  nleft = 0;
  npairs = 0;
  nminimal = 0;

  for (i = 0; i < mat->n_cols(); i++)
    if ((*mat)[i] != NULL)
      {
        res_pair *p = new_res_pair(i);  // Makes a generator 'pair'
        int d = mat->cols()->primary_degree(i);
        res_degree *mypairs = make_degree_set(1, d - 1);
        p->next = mypairs->next_gen;
        mypairs->next_gen = p;
        mypairs->nleft++;
        mypairs->npairs++;
        resn[1]->nleft++;
        resn[1]->npairs++;
        nleft++;
        npairs++;
      }

  for (i = 0; i < base_components.length(); i++)
    {
      res_pair *p = base_components[i];
      p->compare_num = i;
    }

  exp_size = EXPONENT_BYTE_SIZE(P->n_vars());
  monom_size = MONOMIAL_BYTE_SIZE(M->monomial_size());

  compare_type = 0;
}
示例#5
0
文件: gb-test1.cpp 项目: pzinn/M2
void gbB::initialize(const Matrix *m, int csyz, int nsyz, M2_arrayint gb_weights0, int strat, int max_reduction_count0)
{
     // max_reduction_count: default was 10
     // 1 is best possible for 3-anderbuch!
     // 5 is: (114.64 sec, 494 MB)
     // 10 is best so far (125.33 sec, 527 MB virtual).
     // 50 is faster/smaller than 100, and 1000 was awful, on 3-andersbuch

  max_reduction_count = max_reduction_count0;

  const PolynomialRing *origR = m->get_ring()->cast_to_PolynomialRing();
  if (origR == NULL)
    {
      ERROR("ring is not a polynomial ring");
      // MES: throw an error here.
      assert(0);
    }
  originalR = origR;
  R = origR->get_gb_ring();
  weightInfo = new GBWeight(m->rows(), gb_weights0);
  gb_weights = weightInfo->get_weights();

  nvars = R->get_flattened_monoid()->n_vars();

  spair_stash = new stash("gbB spairs", sizeof(spair));
  gbelem_stash = new stash("gbB elems", sizeof(gbelem));
  exp_size = EXPONENT_BYTE_SIZE(nvars+2);
  lcm_stash = new stash("gbB lead monoms", exp_size);


  if (nsyz < 0 || nsyz > m->n_cols())
    nsyz = m->n_cols();
  n_rows_per_syz = nsyz;

  F = m->rows();
  Fsyz = m->cols()->sub_space(n_rows_per_syz);

  S = new SPairSet;
  first_in_degree = 0;
  n_syz = 0;
  n_pairs_computed = 0;
  n_gens_left = 0;
  n_subring = 0;

  _strategy = strat;
  _collect_syz = csyz;
  _is_ideal = (F->rank() == 1 && csyz == 0);
  if (R->is_weyl_algebra())
    _is_ideal = false;

  hilbert = 0;
  n_saved_hilb = 0;

  this_degree = F->lowest_primary_degree() - 1;
  npairs = 0;
  complete_thru_this_degree = this_degree;
  set_status(COMP_NOT_STARTED);

  stats_nreductions = 0;
  stats_ntail = 0;
  stats_npairs = 0;
  stats_ngb = 0;
  stats_ngcd1 = 0;

  divisor_previous = -1;
  divisor_previous_comp = -1;

  lookup = MonomialTable::make(nvars);

  minimal_gb = ReducedGB::create(originalR,F,Fsyz);
  minimal_gb_valid = true;

  if (originalR->is_quotient_ring())
    {
      ringtable = originalR->get_quotient_MonomialTable();

      first_gb_element = originalR->n_quotients();
      for (int i=0; i<first_gb_element; i++)
        {
          gbvector *f = const_cast<gbvector *>(originalR->quotient_gbvector(i));
          gbelem *g = gbelem_ring_make(f);
          gb.push_back(g);
        }
    }
  for (int i=0; i<m->n_cols(); i++)
    {
      ring_elem denom;
      gbvector *f = originalR->translate_gbvector_from_vec(F,(*m)[i], denom);
      spair *p = new_gen(i, f, denom);
      if (p != NULL)
        {
          spair_set_insert(p);
          n_gens_left++;
        }
    }

  state = STATE_NEWDEGREE; // will be changed if hilb fcn is used
  np_i = first_gb_element;
  ar_i = first_gb_element;
  ar_j = ar_i+1;
  n_gb = first_gb_element;
}