當前位置: 首頁>>代碼示例>>C++>>正文


C++ Interval::end方法代碼示例

本文整理匯總了C++中Interval::end方法的典型用法代碼示例。如果您正苦於以下問題:C++ Interval::end方法的具體用法?C++ Interval::end怎麽用?C++ Interval::end使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Interval的用法示例。


在下文中一共展示了Interval::end方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: refBox

void
EBMGAverage::averageFAB(EBCellFAB&       a_coar,
                        const Box&       a_boxCoar,
                        const EBCellFAB& a_refCoar,
                        const DataIndex& a_datInd,
                        const Interval&  a_variables) const
{
  CH_TIMERS("EBMGAverage::average");
  CH_TIMER("regular_average", t1);
  CH_TIMER("irregular_average", t2);
  CH_assert(isDefined());

  const Box& coarBox = a_boxCoar;

  //do all cells as if they were regular
  Box refBox(IntVect::Zero, IntVect::Zero);
  refBox.refine(m_refRat);
  int numFinePerCoar = refBox.numPts();

  BaseFab<Real>& coarRegFAB =             a_coar.getSingleValuedFAB();
  const BaseFab<Real>& refCoarRegFAB = a_refCoar.getSingleValuedFAB();

  //set to zero because the fortran is a bit simpleminded
  //and does stuff additively
  a_coar.setVal(0.);
  CH_START(t1);
  for (int comp = a_variables.begin();  comp <= a_variables.end(); comp++)
    {
      FORT_REGAVERAGE(CHF_FRA1(coarRegFAB,comp),
                      CHF_CONST_FRA1(refCoarRegFAB,comp),
                      CHF_BOX(coarBox),
                      CHF_BOX(refBox),
                      CHF_CONST_INT(numFinePerCoar),
                      CHF_CONST_INT(m_refRat));
    }
  CH_STOP(t1);

  //this is really volume-weighted averaging even though it does
  //not look that way.

  //so (in the traditional sense) we want to preserve
  //rhoc * volc = sum(rhof * volf)
  //this translates to
  //volfrac_C * rhoC = (1/numFinePerCoar)(sum(volFrac_F * rhoF))
  //but the data input to this routine is all kappa weigthed so
  //the volumefractions have already been multiplied
  //which means
  // rhoC = (1/numFinePerCoar)(sum(rhoF))
  //which is what this does

  CH_START(t2);
  for (int comp = a_variables.begin();  comp <= a_variables.end(); comp++)
    {
      m_averageEBStencil[a_datInd]->apply(a_coar, a_refCoar, false, comp);
    }
  CH_STOP(t2);

}
開發者ID:rsnemmen,項目名稱:Chombo,代碼行數:58,代碼來源:EBMGAverage.cpp

示例2: newtonMethod

void newtonMethod(Interval const &interval, double const &eps) {
	cout << "Newton method\n";
	double x = (interval.end() + interval.start()) / 2;
	cout << "First approximation: " << x << "\n";

	double xOld = interval.start();
	int n = 0;
	
	do {
		xOld = x;

		double derivatedFuncValue = FuncClass::derivatedFunc(x);

		if (abs(derivatedFuncValue) > minimumNotZero) {
			x -= FuncClass::func(x) / derivatedFuncValue;
		} else {
			cout << derivatedFuncValue << "\n";
			cout << "Hmmm... problem in Newton Method. Trying to divide by smth, too close to zero.\n";	
			break;
		}

		n++;
	} while (abs(x - xOld) > eps);

	cout << "Step: " << n << "\n";
	cout << "Approximated solution: " << x << "\n";
	cout << "Discrepansy module: " << abs(FuncClass::func(x)) << "\n\n";
}
開發者ID:anlunHW,項目名稱:calcMethods,代碼行數:28,代碼來源:main.cpp

示例3: secantMethod

void secantMethod(Interval const &interval, double const &eps) {
	double xOld_1 = interval.end();
	double xOld_2 = interval.start();

	cout << "Secant method\n";
	double x = xOld_1;
	cout << "First approximation: " << x << "\n";
	
	int n = 0;

	do {
		double temp = x;
		double funcDiff = FuncClass::func(xOld_1) - FuncClass::func(xOld_2);

		if (abs(funcDiff) > minimumNotZero) {
			x -= FuncClass::func(xOld_1) * (xOld_1 - xOld_2) / funcDiff;
		} else {
			cout << funcDiff << "\n";
			cout << "Hmmm... problem in secant Method. Trying to divide by smth, too close to zero.\n";	
			break;
		}

		xOld_2 = xOld_1;
		xOld_1 = temp;
		n++;
	} while (abs(x - xOld_1) > eps);

	cout << "Step: " << n << "\n";
	cout << "Approximated solution: " << x << "\n";
	cout << "Discrepansy module: " << abs(FuncClass::func(x)) << "\n\n";
}
開發者ID:anlunHW,項目名稱:calcMethods,代碼行數:31,代碼來源:main.cpp

示例4: vofit

void
EBCoarsen::coarsenIrreg(EBCellFAB&       a_coar,
                        const EBCellFAB& a_fine,
                        const DataIndex& a_dit,
                        const Interval&  a_variables)
{
  const BaseIVFAB<VoFStencil>& stenBaseIVFAB = m_coarsenStencil[a_dit];
  VoFIterator& vofit = m_vofIt[a_dit];
  for (vofit.reset(); vofit.ok(); ++vofit)
    {
      const VolIndex&    vofCoar   = vofit();
      const VoFStencil&  stencil   = stenBaseIVFAB(vofCoar,0);

      for (int icomp=a_variables.begin();icomp ==a_variables.end();icomp++)
        {
          //coarsen irreg fine vofs to coarse
          //  compute the coarsening by using fine data
          Real phi = 0.0;
          for (int i = 0; i < stencil.size(); ++i )
            {
              const Real&      weight = stencil.weight(i);
              const VolIndex& vofFine = stencil.vof(i);
              const Real&        phiF = a_fine(vofFine,icomp);
              phi += weight * phiF;
            }

          //set the coarse value
          a_coar(vofCoar,icomp) = phi;
        }
    }
}
開發者ID:dtgraves,項目名稱:EBAMRCNS,代碼行數:31,代碼來源:EBCoarsen.cpp

示例5: merge

bool Interval::merge(const Interval& other) 
{
  // If cant merge, return false
  if(!canMerge(other))
    return false;

  // Else, merge - e.g "2" into "3-5" to create "2-5":

  if(other.start() < m_start)
    m_start = other.start();

  if(other.end() > m_end)
    m_end = other.end();

  return true;
}
開發者ID:trnielsen,項目名稱:mantid,代碼行數:16,代碼來源:MantidWSIndexDialog.cpp

示例6: canMerge

bool Interval::canMerge(const Interval& other) const
{
  if(other.start() > m_end + 1 || other.end() + 1 < m_start)
    return false;
  else
    return true;
}
開發者ID:trnielsen,項目名稱:mantid,代碼行數:7,代碼來源:MantidWSIndexDialog.cpp

示例7: if

 vector<Interval> insert(vector<Interval>& intervals, Interval newInterval)
 {
      int len=intervals.size();
      vector<Interval> res;
      for(int i=0;i<len;i++)
      {
          if(intervals[i].end<newInterval.start)
             res.push_back(intervals[i]);
          else
          {
              for(int j=i+1;j<len;j++)
              {
                  if(newInterval.end<intervals[j].start)
                  {
                      Interval *temp=new Interval();
                      temp->start=intervals[i].start;
                      temp->end=newInterval.end();
                      res.push_back(temp);
                  }
                  else if(newInterval.end<intervals[j].end)
                  {
                      Interval
                  }
              }
          }
      }
 }
開發者ID:hrh007,項目名稱:leetcode-1,代碼行數:27,代碼來源:57.cpp

示例8: incrementFine

void
LevelFluxRegisterEdge::incrementFine(
                                     FArrayBox& a_fineFlux,
                                     Real a_scale,
                                     const DataIndex& a_fineDataIndex,
                                     const Interval& a_srcInterval,
                                     const Interval& a_dstInterval)
{
  CH_assert(isDefined());
  CH_assert(!a_fineFlux.box().isEmpty());
  CH_assert(a_srcInterval.size() == a_dstInterval.size());
  CH_assert(a_srcInterval.begin() >= 0);
  CH_assert(a_srcInterval.end() < a_fineFlux.nComp());
  CH_assert(a_dstInterval.begin() >= 0);
  CH_assert(a_dstInterval.end() < m_nComp);

  int edgeDir = -1;
  for (int sideDir = 0; sideDir<SpaceDim; sideDir++)
    {
      if (a_fineFlux.box().type(sideDir) == IndexType::CELL)
        {
          edgeDir = sideDir;
        }
    }
  CH_assert(edgeDir >= 0);
  CH_assert(edgeDir < SpaceDim);

  for (int faceDir=0; faceDir<SpaceDim; faceDir++)
    {
      if (faceDir != edgeDir)
        {

          SideIterator sit;
          for (sit.begin(); sit.ok(); ++sit)
            {
              incrementFine(a_fineFlux,
                            a_scale,
                            a_fineDataIndex,
                            a_srcInterval,
                            a_dstInterval,
                            faceDir,
                            sit());
            }
        }
    }
}
開發者ID:dtgraves,項目名稱:EBAMRCNS,代碼行數:46,代碼來源:LevelFluxRegisterEdge.cpp

示例9:

void
LevelFluxRegisterEdge::incrementCoarse(FArrayBox& a_coarseFlux,
                                       Real a_scale,
                                       const DataIndex& a_coarseDataIndex,
                                       const Interval& a_srcInterval,
                                       const Interval& a_dstInterval)
{
  CH_assert(isDefined());
  CH_assert(!a_coarseFlux.box().isEmpty());

  CH_assert(a_srcInterval.size() == a_dstInterval.size());
  CH_assert(a_srcInterval.begin() >= 0);
  CH_assert(a_srcInterval.end() < a_coarseFlux.nComp());
  CH_assert(a_dstInterval.begin() >= 0);
  CH_assert(a_dstInterval.end() < m_nComp);

  // get edge-centering of coarseFlux
  const Box& edgeBox = a_coarseFlux.box();
  int edgeDir = -1;
  for (int dir=0; dir<SpaceDim; dir++)
    {
      if (edgeBox.type(dir) == IndexType::CELL)
        {
          if (edgeDir == -1)
            {
              edgeDir = dir;
            }
          else
            {
              // already found a cell-centered direction (should only be
              // one for edge-centering)
              MayDay::Error("LevelFluxRegisterEdge::incrementCoarse -- e-field not edge-centered");
            }
        }
    } // end loop over directions
  CH_assert(edgeDir != -1);

  FArrayBox& thisCrseReg = m_regCoarse[a_coarseDataIndex][edgeDir];

  thisCrseReg.plus(a_coarseFlux, -a_scale, a_srcInterval.begin(),
                   a_dstInterval.begin(), a_srcInterval.size());

}
開發者ID:dtgraves,項目名稱:EBAMRCNS,代碼行數:43,代碼來源:LevelFluxRegisterEdge.cpp

示例10: vofit

void
EBFineToCoarRedist::
redistribute(LevelData<EBCellFAB>& a_coarSolution,
             const Interval& a_variables)
{
  CH_TIME("EBFineToCoarRedist::redistribute");
  Real nrefD = 1.0;
  for (int idir = 0; idir < SpaceDim; idir++)
    nrefD *= m_refRat;
  //copy the buffer to the coarse layout
  m_regsFine.copyTo(a_variables, m_regsRefCoar, a_variables);
  //redistribute the refined coarse registers to the coarse solution
  int ibox = 0;
  for (DataIterator dit = m_gridsCoar.dataIterator(); dit.ok(); ++dit)
    {
      const BaseIVFAB<Real>& regRefCoar = m_regsRefCoar[dit()];
      const IntVectSet& ivsRefCoar = m_setsRefCoar[dit()];
      const EBISBox& ebisBoxRefCoar = m_ebislRefCoar[dit()];
      const EBISBox& ebisBoxCoar = m_ebislCoar[dit()];
      const BaseIVFAB<VoFStencil>& stenFAB = m_stenRefCoar[dit()];

      EBCellFAB& solFAB = a_coarSolution[dit()];

      for (VoFIterator vofit(ivsRefCoar, ebisBoxRefCoar.getEBGraph());
          vofit.ok(); ++vofit)
        {
          const VolIndex& srcVoFFine = vofit();
          const VoFStencil& vofsten = stenFAB(srcVoFFine, 0);
          for (int isten = 0; isten < vofsten.size(); isten++)
            {
              const Real& weight = vofsten.weight(isten);
              const VolIndex& dstVoFFine = vofsten.vof(isten);
              VolIndex dstVoFCoar =
                m_ebislRefCoar.coarsen(dstVoFFine,m_refRat, dit());
              //by construction...
              CH_assert(m_gridsCoar.get(dit()).contains(dstVoFCoar.gridIndex()));
              Real dstVolFracFine = ebisBoxRefCoar.volFrac(dstVoFFine);
              Real dstVolFracCoar = ebisBoxCoar.volFrac(dstVoFCoar);
              Real denom = dstVolFracCoar*nrefD;
              for (int ivar = a_variables.begin();
                  ivar <= a_variables.end();  ivar++)
                {
                  Real dmFine = regRefCoar(srcVoFFine, ivar);
                  //ucoar+= massfine/volcoar, ie.
                  //ucoar+= (wcoar*dmCoar*volFracfine/volfraccoar)=massfine/volcoar
                  Real dUCoar = dmFine*weight*dstVolFracFine/denom;
                  solFAB(dstVoFCoar, ivar) += dUCoar;
                }
            }
        }
      ibox++;
    }
}
開發者ID:dtgraves,項目名稱:EBAMRCNS,代碼行數:53,代碼來源:EBFineToCoarRedist.cpp

示例11: vofitCoar

void
EBCoarseAverage::averageFAB(BaseIVFAB<Real>&       a_coar,
                            const BaseIVFAB<Real>& a_fine,
                            const DataIndex&       a_datInd,
                            const Interval&        a_variables) const
{
  CH_assert(isDefined());
  //recall that datInd is from the fine layout.
  const EBISBox& ebisBoxCoar = m_eblgCoFi.getEBISL()[a_datInd];
  const EBISBox& ebisBoxFine = m_eblgFine.getEBISL()[a_datInd];
  const IntVectSet& coarIrregIVS = a_coar.getIVS();
  const IntVectSet& fineIrregIVS = a_fine.getIVS();

  for (VoFIterator vofitCoar(coarIrregIVS, ebisBoxCoar.getEBGraph());
      vofitCoar.ok(); ++vofitCoar)
    {
      const VolIndex& coarVoF = vofitCoar();
      Vector<VolIndex> fineVoFs =
        m_eblgCoFi.getEBISL().refine(coarVoF, m_refRat, a_datInd);

      for (int ivar = a_variables.begin(); ivar <= a_variables.end(); ivar++)
        {
          int  numVoFs = 0;
          Real areaTot = 0;
          Real dataVal = 0;
          for (int ifine = 0; ifine < fineVoFs.size(); ifine++)
            {
              const VolIndex& fineVoF = fineVoFs[ifine];
              if (fineIrregIVS.contains(fineVoF.gridIndex()))
                {
                  Real bndryArea = ebisBoxFine.bndryArea(fineVoF);
                  if (bndryArea > 0)
                    {
                      areaTot += bndryArea;
                      numVoFs++;
                      dataVal += a_fine(fineVoF, ivar);
                    }
                }
            }
          if (numVoFs > 1)
            {
              dataVal /= Real(numVoFs);
            }
          a_coar(coarVoF, ivar) = dataVal;
        }
    }
}
開發者ID:rsnemmen,項目名稱:Chombo,代碼行數:47,代碼來源:EBCoarseAverage.cpp

示例12: vofitCoar

void
EBCoarToFineRedist::
redistribute(LevelData<EBCellFAB>& a_fineSolution,
             const Interval& a_variables)
{
  CH_TIME("EBCoarToFineRedist::redistribute");
  //copy the buffer to the fine layout
  m_regsCoar.copyTo(a_variables, m_regsCedFine, a_variables);
  //redistribute the coarsened fine registers to the fine solution
  for (DataIterator dit = m_gridsFine.dataIterator(); dit.ok(); ++dit)
    {
      const BaseIVFAB<Real>& regCoar = m_regsCedFine[dit()];
      const IntVectSet& ivsCoar = m_setsCedFine[dit()];
      const EBISBox& ebisBoxCoar = m_ebislCedFine[dit()];
      const BaseIVFAB<VoFStencil>& stenFAB = m_stenCedFine[dit()];

      EBCellFAB& solFAB = a_fineSolution[dit()];

      for (VoFIterator vofitCoar(ivsCoar, ebisBoxCoar.getEBGraph());
          vofitCoar.ok(); ++vofitCoar)
        {
          const VolIndex& srcVoFCoar = vofitCoar();
          const VoFStencil& vofsten = stenFAB(srcVoFCoar, 0);
          for (int isten = 0; isten < vofsten.size(); isten++)
            {
              const Real& weight = vofsten.weight(isten);
              const VolIndex& dstVoFCoar = vofsten.vof(isten);
              Vector<VolIndex> vofsFine =
                m_ebislCedFine.refine(dstVoFCoar,m_refRat, dit());

              for (int ivar = a_variables.begin();
                  ivar <= a_variables.end();  ivar++)
                {
                  Real dmCoar = regCoar(srcVoFCoar, ivar);
                  for (int ifine = 0; ifine < vofsFine.size(); ifine++)
                    {

                      const VolIndex& dstVoFFine = vofsFine[ifine];
                      //ufine += (wcoar*dmCoar) (piecewise constant density diff)
                      Real dUFine = dmCoar*weight;
                      solFAB(dstVoFFine, ivar) += dUFine;
                    }
                }
            }
        }
    }
}
開發者ID:rsnemmen,項目名稱:Chombo,代碼行數:47,代碼來源:EBCoarToFineRedist.cpp

示例13: findIntervals

void BlockTab::findIntervals( void )
{
	vector< bool > visited( curBlockNum + 1, false );
	list< BasicBlock * > left;
	left.push_back( blockList[ 1 ] );        //entry node
	visited[ blockList[ 1 ] -> no ] = true;
	
	while ( !left.empty( ) ) { 
		Interval current;	
		current.Head( *left.begin( ) );
		bool added = true;
		while ( added == true ) {
		added = false;
		for ( list< BasicBlock * >::iterator i = left.begin( );
							i != left.end( ); ) {
//includes:check if first set includes the second set 

			if ( current.Head( ) == *i || 
				includes( current.begin( ), current.end( ), 
				( *i ) -> predecessors.begin( ), 
						(*i) -> predecessors.end())) {

				current.insert(*i);
				(*i) -> head = current.Head();
               			if ((*i) -> getTakenPtr() && 
					!visited[(*i) -> getTakenPtr() -> no]) {
					
				    visited[(*i) -> getTakenPtr() -> no] = true;
					left.push_back((*i) -> getTakenPtr());
					added = true;
				}
	       			if ((*i) -> getNTakenPtr() && 
					!visited[(*i)-> getNTakenPtr() -> no]) {
				   visited[(*i) -> getNTakenPtr() -> no] = true;
					left.push_back((*i) -> getNTakenPtr());
					added = true;
				}
				left.erase(i++); 
	       		}
			else
				i++;
		}
		}
		all.push_back(current);
	}
}
開發者ID:gunmetal313,項目名稱:relipmoC,代碼行數:46,代碼來源:blocktab.cpp

示例14: dataMasked

// ---------------------------------------------------------
// 7 Dec 2005
Real
maxnorm(const BoxLayoutData<NodeFArrayBox>& a_layout,
        const LevelData<NodeFArrayBox>& a_mask,
        const ProblemDomain& a_domain,
        const Interval& a_interval,
        bool a_verbose)
{
  Real normTotal = 0.;
  // a_p == 0:  max norm
  int ncomp = a_interval.size();
  for (DataIterator it = a_layout.dataIterator(); it.ok(); ++it)
    {
      const NodeFArrayBox& thisNfab = a_layout[it()];
      const FArrayBox& dataFab = thisNfab.getFab();
      const FArrayBox& maskFab = a_mask[it()].getFab();
      const Box& thisBox(a_layout.box(it())); // CELL-centered
      NodeFArrayBox dataMasked(thisBox, ncomp);
      FArrayBox& dataMaskedFab = dataMasked.getFab();
      dataMaskedFab.copy(dataFab);
      // dataMaskedFab *= maskFab;
      for (int comp = a_interval.begin(); comp <= a_interval.end(); comp++)
        {
          // Set dataMaskedFab[comp] *= maskFab[0].
          dataMaskedFab.mult(maskFab, 0, comp);
        }
      Real thisNfabNorm =
        maxnorm(dataMasked, thisBox, a_interval.begin(), a_interval.size());
      if (a_verbose)
        cout << "maxnorm(" << thisBox << ") = " << thisNfabNorm << endl;
       normTotal = Max(normTotal, thisNfabNorm);
    }
# ifdef CH_MPI
  Real recv;
  // add up (a_p is not 0)
  int result = MPI_Allreduce(&normTotal, &recv, 1, MPI_CH_REAL,
                             MPI_MAX, Chombo_MPI::comm);
  if (result != MPI_SUCCESS)
    { //bark!!!
      MayDay::Error("sorry, but I had a communication error on norm");
    }
  normTotal = recv;
# endif
  return normTotal;
}
開發者ID:dtgraves,項目名稱:EBAMRCNS,代碼行數:46,代碼來源:NodeNorms.cpp

示例15: refBox

void
EBMGInterp::pwcInterpFAB(EBCellFAB&       a_refCoar,
                         const Box&       a_coarBox,
                         const EBCellFAB& a_coar,
                         const DataIndex& a_datInd,
                         const Interval&  a_variables) const
{
  CH_TIMERS("EBMGInterp::interp");
  CH_TIMER("regular_interp", t1);
  CH_TIMER("irregular_interp", t2);
  CH_assert(isDefined());

  const Box& coarBox = a_coarBox;

  for (int ivar = a_variables.begin();  ivar <= a_variables.end(); ivar++)
    {
      m_interpEBStencil[a_datInd]->cache(a_refCoar, ivar);

      //do all cells as if they were regular
      Box refBox(IntVect::Zero, IntVect::Zero);
      refBox.refine(m_refRat);

      const BaseFab<Real>& coarRegFAB =    a_coar.getSingleValuedFAB();
      BaseFab<Real>& refCoarRegFAB    = a_refCoar.getSingleValuedFAB();

      CH_START(t1);

      FORT_REGPROLONG(CHF_FRA1(refCoarRegFAB,ivar),
                      CHF_CONST_FRA1(coarRegFAB,ivar),
                      CHF_BOX(coarBox),
                      CHF_BOX(refBox),
                      CHF_CONST_INT(m_refRat));

      CH_STOP(t1);

      m_interpEBStencil[a_datInd]->uncache(a_refCoar, ivar);

      CH_START(t2);
      m_interpEBStencil[a_datInd]->apply(a_refCoar, a_coar, true, ivar);
      CH_STOP(t2);
    }
}
開發者ID:rsnemmen,項目名稱:Chombo,代碼行數:42,代碼來源:EBMGInterp.cpp


注:本文中的Interval::end方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。