Ejemplo n.º 1
0
binomialGB::monomial_list *binomialGB::ideal_quotient(monomial m) const
{
  monomial_list *r;
  monomial_list **deglist = newarray(monomial_list *,_max_degree+1);
  for (int i=0; i<=_max_degree; i++)
    deglist[i] = NULL;

  for (iterator p = begin(); p != end(); p++)
    {
      binomial_gb_elem *g = *p;
      gbmin_elem *gm = new gbmin_elem(g, R->mask(g->f.lead));
      monomial n = R->quotient(g->f.lead, m);
      monomial_list *nl = new monomial_list(n,R->mask(n),gm);
      int d = R->degree(n);
      nl->next = deglist[d];
      deglist[d] = nl;
    }
  monomial_list *result = NULL;

  for (int d=0; d<=_max_degree; d++)
    if (deglist[d] != NULL)
      {
        monomial_list *currentresult = NULL;
        while (deglist[d] != NULL)
          {
            monomial_list *p = deglist[d];
            deglist[d] = p->next;
            if (find_divisor(result, p->m))
              {
                R->remove_monomial(p->m);
                deleteitem(p->tag);     // There is only one element at this point
                deleteitem(p);
              }
            else if ((r = find_divisor(currentresult, p->m)))
              {
                gbmin_elem *p1 = new gbmin_elem(p->tag->elem, p->mask);
                R->remove_monomial(p->m);
                deleteitem(p);
                p1->next = r->tag;
                r->tag = p1;
              }
            else
              {
                p->next = currentresult;
                currentresult = p;
              }
          }
        if (result == NULL)
          result = currentresult;
        else if (currentresult != NULL)
          {
            monomial_list *q;
            for (q = result; q->next != NULL; q = q->next);
            q->next = currentresult;
          }
        currentresult = NULL;
      }
  deletearray(deglist);
  return result;
}
Ejemplo n.º 2
0
TQueue::~TQueue() {
	SPBLK* q;
	while((q = spdeq(&sptree_->root)) != nil) {
		deleteitem(q);
	}
	delete sptree_;
	while((q = fifo_->dequeue()) != nil) {
		deleteitem(q);
	}
	delete fifo_;
}
Ejemplo n.º 3
0
void binomial_s_pair_set::remove_lcm_list(s_pair_lcm_list *p)
{
  while (p->pairs != NULL)
    {
      s_pair_elem *thispair = p->pairs;
      p->pairs = thispair->next;
      deleteitem(thispair);
    }
  R->remove_monomial(p->lcm);
  deleteitem(p);
}
Ejemplo n.º 4
0
TQueue::~TQueue() {
	SPBLK* q;
	if (least_) { deleteitem(least_); }
	while((q = spdeq(&sptree_->root)) != nil) {
		deleteitem(q);
	}
	delete sptree_;
	while((q = spdeq(&sptree2_->root)) != nil) {
		deleteitem(q);
	}
	delete sptree2_;
}
Ejemplo n.º 5
0
void* TPtrList::ptr_remove(void *item){
	TListItem *curitem = first;
	if (!current || current->data != item)
		while (curitem && curitem->data != item) curitem = curitem->next;
		else
		curitem = current;
	if (!curitem) return 0; //nicht gefunden!

	if (curitem->prev)
		curitem->prev->next = curitem->next;
	if (curitem->next)
		curitem->next->prev = curitem->prev;
	if (first == curitem) first = curitem->next;
	if (last == curitem) last = curitem->prev;
	if (current = curitem) current = 0;
	count--;

	void *ptr = curitem->data;
	if (autodelete && curitem->data){
		deleteitem(ptr);
		delete curitem;
		return 0;
		}
	delete curitem;
	return ptr;
}
Ejemplo n.º 6
0
Matrix /* or null */ *Matrix::minors(int p,
                       int strategy,
                       int n_to_compute, // -1 means all
                       M2_arrayintOrNull first_row, // possibly NULL
                       M2_arrayintOrNull first_col // possibly NULL
                       ) const
{
  if (strategy == DET_BAREISS && get_ring()->get_precision() > 0)
    {
      ERROR("determinant computations over RR or CC requires Strategy=>Cofactor");
      return 0;
    }
  if (first_row != 0 || first_col != 0)
    {
      // Make sure these are the correct size, and both are given
      if (first_row == 0 || first_row->len != p)
        {
          ERROR("row index set inappropriate");
          return 0;
        }
      if (first_col == 0 || first_col->len != p)
        {
          ERROR("column index set inappropriate");
          return 0;
        }
    }
  DetComputation *d = new DetComputation(this,p,0,strategy);
  if (first_row != 0 && first_col != 0)
    d->set_next_minor(first_row->array, first_col->array);
  d->calc(n_to_compute);
  Matrix *result = d->determinants();
  deleteitem(d);
  return result;
}
Ejemplo n.º 7
0
Dialog::Dialog(QWidget *parent):QDialog(parent)
{
  //top
    QGridLayout *topgrid=new QGridLayout;
    topgrid->setColumnStretch(0, 2);
    topgrid->setColumnStretch(1, 6);
    topgrid->setColumnStretch(2, 1);
    QLabel *warn=new QLabel("添加参考文献<font color=red>(*为必填项)</font>");
    myLabel *feedback=new myLabel("<font color=blue><u>问题反馈</u></font>");
    feedback->setCursor(Qt::PointingHandCursor);
    topgrid->addWidget(warn,0,0);
    topgrid->addWidget(feedback,0,2);
    //Tab
  tabWidget=new QTabWidget;
  tabWidget->addTab(new PeriodicalTab(),trUtf8("期刊"));
  tabWidget->addTab(new NewspaperTab(),trUtf8("报纸"));
  tabWidget->addTab(new BookTab(),trUtf8("图书"));
  tabWidget->addTab(new MeetingTab(),trUtf8("会议集/论文集"));
  tabWidget->addTab(new AcademicTab(),trUtf8("学位论文"));
  tabWidget->addTab(new ReportTab(),trUtf8("报告"));
  tabWidget->addTab(new NetworkTab(),trUtf8("网络文献"));
  tabWidget->setFixedSize(600,250);
  //中间
  QGridLayout *ingrid=new QGridLayout;
  countLabel=new QLabel("已添加<font color=green>0</font>个文献");
  dropLabel=new myLabel("<font color=blue><u>清空</u></font>");
  dropLabel->setCursor(Qt::PointingHandCursor);
  QPushButton *deletebutton=new QPushButton(trUtf8("删除"));
  deletebutton->setCursor(Qt::PointingHandCursor);
  deindex=new QLineEdit;
  deindex->setFixedWidth(30);

  ingrid->setColumnStretch(0, 1);
  ingrid->setColumnStretch(1, 1);
  ingrid->setColumnStretch(2, 5);
  ingrid->setColumnStretch(3, 2);
  ingrid->setColumnStretch(4, 1);
  ingrid->addWidget(countLabel,0,0);
  ingrid->addWidget(dropLabel,0,1);
  ingrid->addWidget(deindex,0,4);
  ingrid->addWidget(deletebutton,0,3);
  //下面
  textEdt= new QTextEdit;
  textEdt->setReadOnly(true);
  QVBoxLayout *mainLayout=new QVBoxLayout;
  mainLayout->addLayout(topgrid);
  mainLayout->addWidget(tabWidget);
  mainLayout->addLayout(ingrid);
  mainLayout->addWidget(textEdt);
  Dialog::setLayout(mainLayout);
  connect(dropLabel,SIGNAL(clicked()),this,SLOT(dropresult()));
  connect(feedback,SIGNAL(clicked()),this,SLOT(about()));
  connect(deletebutton,SIGNAL(clicked()),this,SLOT(deleteitem()));
  setWindowTitle(trUtf8("参考文献格式工具"));
  setWindowFlags(windowFlags()|Qt::WindowMinimizeButtonHint );
  setFixedSize(620,480);
}
Ejemplo n.º 8
0
doubling_stash::~doubling_stash()
{
  for (int i=0; i<NDOUBLES; i++)
    {
      if (doubles[i] != NULL)
        emit("internal warning -- deleting a double stash");
      deleteitem(doubles[i]);
    }
}
Ejemplo n.º 9
0
void binomialGB_comp::remove_gb()
{
  int i;
  deleteitem(Gmin);
  deleteitem(Pairs);
  // remove each element of Gens
  for (i=0; i<Gens.length(); i++)
    deleteitem(Gens[i]);
  // remove each element of G
  for (i=0; i<G.length(); i++)
    deleteitem(G[i]);
  // The following is just to ease garbage collection
  for (i=0; i<mingens.length(); i++)
    mingens[i] = NULL;
  for (i=0; i<mingens_subring.length(); i++)
    mingens_subring[i] = NULL;
  deleteitem(R);
}
Ejemplo n.º 10
0
Archivo: f4.cpp Proyecto: pzinn/M2
void F4GB::insert_gb_element(row_elem &r)
{
  // Insert row as gb element.
  // Actions to do:
  //  translate row to a gbelem + poly
  //    set degrees as needed
  //  insert the monomial into the lookup table
  //  find new pairs associated to this new element

  int nslots = M->max_monomial_size();
  int nlongs = r.len * nslots;

  gbelem *result = new gbelem;
  result->f.len = r.len;

  // If the coeff array is null, then that means the coeffs come from the original array
  // Here we copy it over.

  result->f.coeffs = (r.coeffs ? r.coeffs : KK->copy_F4CoefficientArray(r.len, get_coeffs_array(r)));
  r.coeffs = 0;;

  result->f.monoms = Mem->allocate_monomial_array(nlongs);

  monomial_word *nextmonom = result->f.monoms;
  for (int i=0; i<r.len; i++)
    {
      M->copy(mat->columns[r.comps[i]].monom, nextmonom);
      nextmonom += nslots;
    }
  Mem->components.deallocate(r.comps);
  r.len = 0;
  result->deg = this_degree;
  result->alpha = static_cast<int>(M->last_exponent(result->f.monoms));
  result->minlevel = ELEM_MIN_GB; // MES: How do
                                  // we distinguish between ELEM_MIN_GB, ELEM_POSSIBLE_MINGEN?

  int which = INTSIZE(gb);
  gb.push_back(result);

  if (hilbert)
    {
      int x;
      int *exp = newarray_atomic(int, M->n_vars());
      M->to_intstar_vector(result->f.monoms, exp, x);
      hilbert->addMonomial(exp, x+1);
      deletearray(exp);
    }

  // now insert the lead monomial into the lookup table
  varpower_monomial vp = newarray_atomic(varpower_word, 2 * M->n_vars() + 1);
  M->to_varpower_monomial(result->f.monoms, vp);
  lookup->insert_minimal_vp(M->get_component(result->f.monoms), vp, which);
  deleteitem(vp);
  // now go forth and find those new pairs
  S->find_new_pairs(is_ideal);
}
Ejemplo n.º 11
0
void binomialGB::remove_monomial_list(monomial_list *mm) const
{
  while (mm != NULL)
    {
      R->remove_monomial(mm->m);
      monomial_list *tmp = mm;
      mm = mm->next;
      deleteitem(tmp);
    }
}
Ejemplo n.º 12
0
void GaussElimComputation::remove_gm_elem(gm_elem *&p)
{
  if (p != NULL)
    {
      R->remove_vec(p->f);
      R->remove_vec(p->fsyz);
      deleteitem(p);
      p = NULL;
    }
}
Ejemplo n.º 13
0
void binomial_s_pair_set::remove_pair_list(s_pair_degree_list *p)
{
  while (p->pairs != NULL)
    {
      s_pair_lcm_list *thislcm = p->pairs;
      p->pairs = thislcm->next;
      remove_lcm_list(thislcm);
    }
  deleteitem(p);
}
Ejemplo n.º 14
0
void TreeCtrlTestCase::DeleteItem()
{
    EventCounter deleteitem(m_tree, wxEVT_TREE_DELETE_ITEM);

    wxTreeItemId todelete = m_tree->AppendItem(m_root, "deleteme");
    m_tree->Delete(todelete);
    // We do not test DeleteAllItems() as under some versions of Windows events
    // are not generated.

    CPPUNIT_ASSERT_EQUAL(1, deleteitem.GetCount());
}
Ejemplo n.º 15
0
void res_comp::remove_res_degree(res_degree *p)
{
  if (p == NULL) return;
  while (p->first != NULL)
    {
      res_pair *tmp = p->first;
      p->first = tmp->next;
      remove_res_pair(tmp);
    }
  deleteitem(p);
}
Ejemplo n.º 16
0
void res_comp::remove_res_level(res_level *lev)
{
  if (lev == NULL) return;
  int i;
  for (i = 0; i < lev->bin.length(); i++)
    {
      res_degree *mypairs = lev->bin[i];
      remove_res_degree(mypairs);
    }
  deleteitem(lev);
}
Ejemplo n.º 17
0
Matrix /* or null */ *Matrix::minors(int p,int strategy) const
{
  if (strategy == DET_BAREISS && get_ring()->get_precision() > 0)
    {
      ERROR("determinant computations over RR or CC requires Strategy=>Cofactor");
      return 0;
    }
  DetComputation *d = new DetComputation(this,p,0,strategy);
  d->calc(-1);
  Matrix *result = d->determinants();
  deleteitem(d);
  return result;
}
Ejemplo n.º 18
0
bool binomial_s_pair_set::next(const int *d, binomial_s_pair &result, int &result_deg)
  // returns next pair in degrees <= *d, if any.
  // the caller should not free any of the three fields of the
  // s_pair!!
{
  if (_pairs->next == NULL) return false;
  if (d != NULL && _pairs->next->deg > *d) return false;
  s_pair_degree_list *thisdeg = _pairs->next;
  s_pair_lcm_list *thislcm = thisdeg->pairs;
  s_pair_elem *s = thislcm->pairs;
  result_deg = thisdeg->deg;

  thisdeg->n_elems--;
  _n_elems--;
  _npairs[2*(thisdeg->deg)+1]--;

  result = binomial_s_pair(s->f1, s->f2, thislcm->lcm);

  thislcm->pairs = s->next;
  if (thislcm->pairs == NULL)
    {
      // Now we must remove this set
      thisdeg->pairs = thislcm->next;
      R->remove_monomial(_prev_lcm);
      _prev_lcm = thislcm->lcm;
      thislcm->lcm = NULL;
      deleteitem(thislcm);

      if (thisdeg->pairs == NULL)
        {
          // Now we must remove this larger degree list
          _pairs->next = thisdeg->next;
          deleteitem(thisdeg);
        }
    }

  deleteitem(s);
  return true;
}
Ejemplo n.º 19
0
bool LLLoperations::LLL(MutableMatrix *A,
                        MutableMatrix *Achange, // can be NULL
                        gmp_QQ threshold)
{
  MutableMatrix *LLLstate;
  if (!initializeLLL(A,threshold,LLLstate))
    return false;
  int ret = doLLL(A,Achange,LLLstate);
  if (ret != COMP_DONE)
    {
      deleteitem(LLLstate);
      return false;
    }
  return true;
}
Ejemplo n.º 20
0
FreeModule *FreeModule::sub_space(M2_arrayint a) const
{
    FreeModule *result = new_free();
    for (unsigned int i=0; i<a->len; i++)
        if (a->array[i] >= 0 && a->array[i] < rank())
            result->append(degree(a->array[i]));
        else
        {
            ERROR("subfreemodule: index out of bounds");
            deleteitem(result);
            return NULL;
        }
    if (schreyer != NULL)
        result->schreyer = schreyer->sub_space(a);
    return result;
}
Ejemplo n.º 21
0
void binomialGB_comp::enlarge(const PolynomialRing *newR, int *wts)
{
  binomial_ring *old_ring = R;
  R = new binomial_ring(newR, wts, old_ring->revlex);

  // We need to change all of the monomials in sight.
  Gmin->enlarge(R);
  Pairs->enlarge(R);
  int i;
  for (i=0; i<Gens.length(); i++)
    R->translate_binomial(old_ring, Gens[i]->f);
  for (i=0; i<G.length(); i++)
    R->translate_binomial(old_ring, G[i]->f);

  deleteitem(old_ring);
}
Ejemplo n.º 22
0
SchreyerOrder *SchreyerOrder::sub_space(M2_arrayint a) const
{
  // Since this is called only from FreeModule::sub_space,
  // the elements of 'a' are all in bounds, and do not need to be checked...
  // BUT, we check anyway...
  SchreyerOrder *result = new SchreyerOrder(M);
  for (unsigned int i=0; i<a->len; i++)
    if (a->array[i] >= 0 && a->array[i] < rank())
      result->append(compare_num(a->array[i]), base_monom(a->array[i]));
    else
      {
        ERROR("schreyer order subspace: index out of bounds");
        deleteitem(result);
        return NULL;
      }
  return result;
}
Ejemplo n.º 23
0
void ListBaseTestCase::DeleteItems()
{
#ifndef __WXOSX__
    wxListCtrl* const list = GetList();

    EventCounter deleteitem(list, wxEVT_LIST_DELETE_ITEM);
    EventCounter deleteall(list, wxEVT_LIST_DELETE_ALL_ITEMS);


    list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60);
    list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50);
    list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40);

    list->InsertItem(0, "Item 0");
    list->InsertItem(1, "Item 1");
    list->InsertItem(2, "Item 1");

    list->DeleteItem(0);
    list->DeleteItem(0);
    list->DeleteAllItems();

    //Add some new items to tests ClearAll with
    list->InsertColumn(0, "Column 0");
    list->InsertItem(0, "Item 0");
    list->InsertItem(1, "Item 1");

    //Check that ClearAll actually sends a DELETE_ALL_ITEMS event
    list->ClearAll();

    //ClearAll and DeleteAllItems shouldn't send an event if there was nothing
    //to clear
    list->ClearAll();
    list->DeleteAllItems();

    CPPUNIT_ASSERT_EQUAL(2, deleteitem.GetCount());
    CPPUNIT_ASSERT_EQUAL(2, deleteall.GetCount());
#endif
}
Ejemplo n.º 24
0
int binomialGB::n_masks() const
{
  int *masks = newarray_atomic(int,100000);
  buffer o;
  unsigned int nmasks = 1;
  masks[0] = first->mask;
  for (gbmin_elem *p = first; p != NULL; p = p->next)
    {
      o << " " << p->mask;
      bool found = false;
      for (unsigned int i=0; i<nmasks && !found; i++)
        if (masks[i] == p->mask)
          {
            found = true;
            break;
          }
      if (!found)
        masks[nmasks++] = p->mask;
    }
  emit(o.str());
  deleteitem(masks);
  return nmasks;
}
Ejemplo n.º 25
0
void TPtrList::ptr_clear(){
	if (!autodelete){
		while (first){
			TListItem *curitem = first->next;
			delete first;
			first = curitem;
			}
		first = 0;
		last = 0;
		current = 0;
		count = 0;
		}else{
		while (first){
			TListItem *curitem = first->next;
			if (autodelete && first->data)
				deleteitem(first->data);
			delete first;
			first = curitem;
			}
		last = 0;
		current = 0;
		count = 0;
		}
}
Ejemplo n.º 26
0
void GaussElimComputation::insert(gm_elem *p)
{
  if (p->f == NULL)
    {
      if (p->fsyz != NULL && collect_syz)
        {
          syz_list.push_back(p->fsyz);
          n_syz++;
        }
      deleteitem(p);
    }
  else
    {
      ring_elem leadinv = R->invert(p->f->coeff);
      R->mult_vec_to(p->f, leadinv, false);
      R->mult_vec_to(p->fsyz, leadinv, false);
      p->nterms = R->n_nonzero_terms(p->f);
      int i = p->f->comp;
      if (gb_list[i] == NULL)
        {
          gb_list[i] = p;
          n_gb++;
        }
      else
        {
          if (p->nterms < gb_list[i]->nterms)
            {
              gm_elem *q = p;
              p = gb_list[i];
              gb_list[i] = q;
            }
          p->next = reduce_list[i];
          reduce_list[i] = p;
        }
    }
}
Ejemplo n.º 27
0
void SMat<CoeffRing>::vec_remove_node(sparsevec *&v) const
{
  deleteitem(v);
}
Ejemplo n.º 28
0
binomial_ring::~binomial_ring()
{
  deletearray(degrees);
  deletearray(weights);
  deleteitem(monstash);
}