当前位置: 首页>>代码示例>>C++>>正文


C++ FreeModule类代码示例

本文整理汇总了C++中FreeModule的典型用法代码示例。如果您正苦于以下问题:C++ FreeModule类的具体用法?C++ FreeModule怎么用?C++ FreeModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FreeModule类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FreeModule

FreeModule* ResF4toM2Interface::to_M2_freemodule(const PolynomialRing* R,
                                                 SchreyerFrame& C,
                                                 int lev)
{
  FreeModule* result = new FreeModule(R, 0, true);
  if (lev < 0 or lev > C.maxLevel())
    {
      return result;
    }
  const Monoid* M = R->getMonoid();
  auto& thislevel = C.level(lev);
  const ResSchreyerOrder& S = C.schreyerOrder(lev);
  res_ntuple_word* longexp = new res_ntuple_word[M->n_vars()];
  int* exp = new int[M->n_vars()];
  for (auto i = 0; i < thislevel.size(); ++i)
    {
      int d[1];
      d[0] = thislevel[i].mDegree;
      monomial deg = M->degree_monoid()->make_one();
      M->degree_monoid()->from_expvector(d, deg);
      // Now grab the Schreyer info
      // unpack to exponent vector, then repack into monoid element
      monomial totalmonom = M->make_one();
      long comp;
      C.monoid().to_exponent_vector(S.mTotalMonom[i], longexp, comp);
      for (int j=0; j<M->n_vars(); ++j)
        exp[j] = static_cast<int>(longexp[j]);
      M->from_expvector(exp, totalmonom);
      result->append_schreyer(deg, totalmonom, static_cast<int>(S.mTieBreaker[i]));
    }
  delete [] longexp;
  delete [] exp;
  return result;
}
开发者ID:pzinn,项目名称:M2,代码行数:34,代码来源:res-f4-m2-interface.cpp

示例2: ERROR

FreeModule *FreeModule::make_schreyer(const GBMatrix *m)
{
    const FreeModule *F = m->get_free_module();
    const PolynomialRing *R = F->get_ring()->cast_to_PolynomialRing();
    if (R == 0)
    {
        ERROR("expected a polynomial ring");
        return nullptr;
    }
    FreeModule *G = R->make_FreeModule();
    int rk = INTSIZE(m->elems);
    if (rk == 0) return G;

    for (int i=0; i<rk; i++)
    {
        int *deg = R->degree_monoid()->make_one();
        gbvector * v = m->elems[i];
        if (v != 0)
            R->get_gb_ring()->gbvector_multidegree(F, v, deg);
        G->append(deg);
    }

    G->schreyer = SchreyerOrder::create(m);

    return G;
}
开发者ID:doughdemon,项目名称:M2,代码行数:26,代码来源:freemod.cpp

示例3: get_ring

FreeModule *FreeModule::exterior(int pp) const
// p th exterior power
{
    FreeModule *result;
    if (pp == 0)
        return get_ring()->make_FreeModule(1);
    else
        result = new_free();

    int rk = rank();
    if (pp > rk || pp < 0) return result;

    size_t p = static_cast<size_t>(pp);

    Subset a(p, 0);
    for (size_t i=0; i<p; i++) a[i] = i;

    int *deg = degree_monoid()->make_one();
    do
    {
        degree_monoid()->one(deg);

        for (size_t r=0; r<p; r++)
            degree_monoid()->mult(deg, degree(static_cast<int>(a[r])), deg);

        result->append(deg);
    }
    while (Subsets::increment(rk, a));

    degree_monoid()->remove(deg);

    if (schreyer != NULL)
        result->schreyer = schreyer->exterior(pp);
    return result;
}
开发者ID:doughdemon,项目名称:M2,代码行数:35,代码来源:freemod.cpp

示例4: new_free

FreeModule *FreeModule::transpose() const
{
    FreeModule *result = new_free();
    int *deg = degree_monoid()->make_one();

    for (int i=0; i<rank(); i++)
    {
        degree_monoid()->power(degree(i), -1, deg);
        result->append(deg);
    }

    // result has no schreyer order
    degree_monoid()->remove(deg);
    return result;
}
开发者ID:doughdemon,项目名称:M2,代码行数:15,代码来源:freemod.cpp

示例5:

FreeModule *FreeModule::make_schreyer(const Matrix *m)
{
  int i;
  const Ring *R = m->get_ring();
  FreeModule *F = R->make_FreeModule();
  int rk = m->n_cols();
  if (rk == 0) return F;

  for (i=0; i<rk; i++)
    F->append(m->cols()->degree(i));

  F->schreyer = SchreyerOrder::create(m);

  return F;
}
开发者ID:jeremyong,项目名称:M2,代码行数:15,代码来源:freemod.cpp

示例6: rank

FreeModule *FreeModule::exterior(int p) const
     // p th exterior power
{
  FreeModule *result;

  int rk = rank();

  if (p == 0)
    return get_ring()->make_FreeModule(1);
  else
    result = new_free();
  if (p > rk || p < 0) return result;

  int *a = newarray_atomic(int,p);
  for (int i=0; i<p; i++)
    a[i] = i;

  int *deg = degree_monoid()->make_one();
  do
    {
      degree_monoid()->one(deg);

      for (int r=0; r<p; r++)
        degree_monoid()->mult(deg, degree(a[r]), deg);

      result->append(deg);
    }
  while (comb::increment(p, rk, a));

  degree_monoid()->remove(deg);
  deletearray(a);

  if (schreyer != NULL)
    result->schreyer = schreyer->exterior(p);
  return result;
}
开发者ID:jeremyong,项目名称:M2,代码行数:36,代码来源:freemod.cpp

示例7: stash

void gbres_comp::setup(const Matrix *m,
                     int length,
                     int origsyz,
                     int strategy)
{
  int i;
  originalR = m->get_ring()->cast_to_PolynomialRing();
  if (originalR == NULL) assert(0);
  GR = originalR->get_gb_ring();
  mi_stash = new stash("res mi nodes", sizeof(Nmi_node));

  FreeModule *Fsyz = originalR->make_Schreyer_FreeModule();
  if (length <= 0)
    {
      ERROR("resolution length must be at least 1");
      length = 1;
    }

  // If origsyz, and length>1, create Fsyz as a Schreyer free
  // if origsyz is smaller, truncate this module...

  if (length > 1 && origsyz > 0)
    {
      if (origsyz > m->n_cols())
        origsyz = m->n_cols();
      int *one = originalR->getMonoid()->make_one();
      const int *mon;
      for (i=0; i<origsyz; i++)
        {
          if ((*m)[i] == NULL)
            mon = one;
          else
            {
              Nterm *t = (*m)[i]->coeff;
              mon = t->monom;
            }
          Fsyz->append_schreyer(m->cols()->degree(i), mon, i);
        }
      originalR->getMonoid()->remove(one);
    }

  lo_degree = m->cols()->lowest_primary_degree();
  last_completed_degree = lo_degree-1;

  n_nodes = length + 1;
  nodes = newarray(gb_node_ptr,n_nodes);

  nodes[0] = new gb_emitter(m);
  nodes[1] = new gb2_comp(Fsyz,mi_stash,nodes[0],lo_degree,origsyz,1,strategy);
  nodes[0]->set_output(nodes[1]);
  if (n_nodes == 2)
    {
      // Don't compute syzygies at all.
      nodes[1]->set_output(NULL);
    }
  else if (n_nodes >= 3)
    {
      // Compute a resolution to length 'length', with last being
      // a gb node.
      int deg = lo_degree+1;
      if (origsyz > 0) deg--;
      for (i=2; i<n_nodes-1; i++)
        {
          FreeModule *F = originalR->make_Schreyer_FreeModule();
          nodes[i] = new gb2_comp(F,mi_stash,nodes[i-1],deg++,-1,i,strategy);
          nodes[i-1]->set_output(nodes[i]);
        }
      FreeModule *F = originalR->make_Schreyer_FreeModule();
      nodes[n_nodes-1] = new gb2_comp(F,mi_stash,nodes[n_nodes-2],deg++,0,n_nodes-1,strategy);
      nodes[n_nodes-1]->set_output(NULL);
    }
  strategy_flags = strategy;
}
开发者ID:JosephineYu,项目名称:M2,代码行数:73,代码来源:res-a2.cpp

示例8:

    void symm1(int lastn,      // can use lastn..rank()-1 in product
               int pow) const   // remaining power to take
    {
        if (pow == 0)
            symm1_result->append(symm1_deg);
        else
        {
            for (int i=lastn; i<F->rank(); i++)
            {
                // increase symm1_deg, with e_i
                D->mult(symm1_deg, F->degree(i), symm1_deg);

                symm1(i, pow-1);

                // decrease symm1_deg back
                D->divide(symm1_deg, F->degree(i), symm1_deg);
            }
        }
    }
开发者ID:doughdemon,项目名称:M2,代码行数:19,代码来源:freemod.cpp


注:本文中的FreeModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。