Exemple #1
0
void IGraph::BuildAndCoalesce()
{
	bool improved = false;

	//MakeNew(frst->treecount);
	MakeNew(BasicBlock::nBasicBlocks);
	frst->CalcRegclass();

	// Insert move operations to handle register parameters. We want to do this
	// only once.
	if (forest.pass == 1)
		InsertArgumentMoves();

	// Vist high-priority blocks (blocks in nested loops) first, so sort the
	// blocks according to depth.
	BasicBlock::DepthSort();

	// On the first pass we just want to determine the degree of the nodes so
	// that storage for vectors can be allocated.
	pass = 1;
	Clear();
	Fill();
	AllocVecs();

	pass = 2;
	do {
		Clear();
		Fill();
		Print(2);
		improved = BasicBlock::Coalesce();
		//improved = Var::Coalesce2();
		//IRemove();
	} while (improved);
	//Destroy();	// needed in Simplify()
}
Exemple #2
0
 inline
 Vector* Vector::MakeNewCopy() const
 {
   // ToDo: We can probably copy also the cached values for Norms etc here
   Vector* copy = MakeNew();
   copy->Copy(*this);
   return copy;
 }
Exemple #3
0
  void Vector::AddVectorQuotientImpl(Number a, const Vector& z,
                                     const Vector& s, Number c)
  {
    DBG_ASSERT(Dim() == z.Dim());
    DBG_ASSERT(Dim() == s.Dim());

    if (c==0.) {
      AddOneVector(a, z, 0.);
      ElementWiseDivide(s);
    }
    else {
      SmartPtr<Vector> tmp = MakeNew();
      tmp->Copy(z);
      tmp->ElementWiseDivide(s);
      AddOneVector(a, *tmp, c);
    }
  }
Exemple #4
0
  Number Vector::FracToBoundImpl(const Vector& delta, Number tau) const
  {
    DBG_ASSERT(tau>=0.);
    DBG_ASSERT(Dim() == delta.Dim());
    if (Dim() == 0 && delta.Dim() == 0) {
      return 1;
    }

    SmartPtr<Vector> inv_alpha_bar = MakeNew();
    inv_alpha_bar->AddOneVector(-1/tau, delta, Number(0));
    inv_alpha_bar->ElementWiseDivide(*this);

    Number alpha = inv_alpha_bar->Max();
    if (alpha > 0) {
      alpha = SimTKIpopt::Min(1/alpha, Number(1));
    }
    else {
      alpha = 1;
    }

    return alpha;
  }
Exemple #5
0
/*
 * a simple binary heap
 * it only contains intersection events
 * the regular benley-ottman stuffs the segment ends in it too, but that not needed here since theses points
 * are already sorted. and the binary heap is much faster with only intersections...
 * the code sample on which this code is based comes from purists.org
 */
SweepEvent::SweepEvent()
{
    MakeNew (NULL, NULL, Geom::Point(0, 0), 0, 0);
}
Exemple #6
0
AVLTree::AVLTree()
{
    MakeNew();
}