本文整理匯總了C++中Interval類的典型用法代碼示例。如果您正苦於以下問題:C++ Interval類的具體用法?C++ Interval怎麽用?C++ Interval使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Interval類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: maxnorm
// ---------------------------------------------------------
// 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;
}
示例2: return
Interval Tube::operator[](const ibex::Interval& intv_t) const
{
// Write access is not allowed for this operator:
// a further call to computeTree() is needed when values change,
// this call cannot be garanteed with a direct access to m_intv_y
// For write access: use setY()
if(intv_t.lb() == intv_t.ub())
return (*this)[intv_t.lb()];
Interval intersection = m_intv_t & intv_t;
if(intersection.is_empty())
return Interval::EMPTY_SET;
else if(isSlice() || intv_t == m_intv_t || intv_t.is_unbounded() || intv_t.is_superset(m_intv_t))
{
if(m_tree_computation_needed)
computeTree();
return m_intv_y;
}
else
{
Interval inter_firstsubtube = m_first_subtube->getT() & intersection;
Interval inter_secondsubtube = m_second_subtube->getT() & intersection;
if(inter_firstsubtube == inter_secondsubtube)
return (*m_first_subtube)[inter_firstsubtube.lb()] & (*m_second_subtube)[inter_secondsubtube.lb()];
else if(inter_firstsubtube.lb() == inter_firstsubtube.ub()
&& inter_secondsubtube.lb() != inter_secondsubtube.ub())
return (*m_second_subtube)[inter_secondsubtube];
else if(inter_firstsubtube.lb() != inter_firstsubtube.ub()
&& inter_secondsubtube.lb() == inter_secondsubtube.ub())
return (*m_first_subtube)[inter_firstsubtube];
else
return (*m_first_subtube)[inter_firstsubtube] | (*m_second_subtube)[inter_secondsubtube];
}
}
示例3: findScc
void LinearizePass::processPartition(IntervalPartition & ip, Function & f) {
logger->log(1) << "Partition has " << ip.getIntervals().size() << " intervals\n";
currentPartition = &ip;
const vector<Interval *> & intervals = ip.getIntervals();
for (int i = 0, e = intervals.size(); i < e; i++) {
Interval * currentInterval = intervals[i];
logger->log(2) << "Processing interval:\n";
currentInterval->print(logger->log(2));
set<BasicBlock *> scc;
bool hasScc = findScc(*currentInterval, scc);
if ( hasScc )
logger->log(2) << "SCC found\n";
else
logger->log(2) << "No SCCs\n";
}
}
示例4: readChecked
pBuffer SourceBase::
readChecked( const Interval& I )
{
TIME_SOURCEBASE TaskTimer tt("%s::readChecked( %s )", vartype(*this).c_str(), I.toString().c_str());
EXCEPTION_ASSERT( I.count() );
pBuffer r = read(I);
// Check if read returned the first sample in interval I
Interval i(I.first, I.first + 1);
if ((i & r->getInterval()) != i)
{
TaskTimer tt("%s::readChecked( %s ) got %s", vartype(*this).c_str(), I.toString().c_str(), r->getInterval ().toString ().c_str ());
EXCEPTION_ASSERT_EQUALS( i & r->getInterval(), i );
}
return r;
}
示例5: Interval
Interval Interval::intersect(Interval& other) {
Interval result;
if (isEmpty() || other.isEmpty()) {
return result;
}
if (intersects(*this, other)) {
result = Interval(std::max(_min, other._min), std::min(_max, other._max));
}
return result;
}
示例6: Update
// This method is called before rendering begins to allow the plug-in
// to evaluate anything prior to the render so it can store this information.
void Water::Update(TimeValue t, Interval& ivalid) {
if (!texValidity.InInterval(t)) {
texValidity.SetInfinite();
xyzGen->Update(t, texValidity);
// pblock->GetValue(PB_COL1, t, col[0], texValidity);
pblock->GetValue(water_color1, t, col[0], texValidity);
col[0].ClampMinMax();
// pblock->GetValue(PB_COL2, t, col[1], texValidity);
pblock->GetValue(water_color2, t, col[1], texValidity);
col[1].ClampMinMax();
// pblock->GetValue(PB_NUM, t, count, texValidity);
pblock->GetValue(water_num, t, count, texValidity);
ClampInt(count, (int) MIN_NUM, (int) MAX_NUM);
// pblock->GetValue(PB_SIZE, t, size, texValidity);
pblock->GetValue(water_size, t, size, texValidity);
ClampFloat(size, MIN_SIZE, MAX_SIZE);
// pblock->GetValue(PB_LEN_MIN, t, minperiod, texValidity);
pblock->GetValue(water_len_min, t, minperiod, texValidity);
ClampFloat(minperiod, MIN_LEN_MIN, MAX_LEN_MIN); // > 6/11/02 - 2:42pm --MQM-- typo, was MIN_LEN_MIN, MAX_LEN_MAX
// pblock->GetValue(PB_LEN_MAX, t, maxperiod, texValidity);
pblock->GetValue(water_len_max, t, maxperiod, texValidity);
ClampFloat(maxperiod, MIN_LEN_MAX, MAX_LEN_MAX);
// pblock->GetValue(PB_AMP, t, amp, texValidity);
pblock->GetValue(water_amp, t, amp, texValidity);
ClampFloat(amp, MIN_AMP, MAX_AMP);
// pblock->GetValue(PB_PHASE, t, phase, texValidity);
// pblock->GetValue(PB_TYPE, t, type, texValidity);
pblock->GetValue(water_phase, t, phase, texValidity);
pblock->GetValue(water_type, t, type, texValidity);
for (int i = 0; i < NUM_SUB_TEXMAPS; i++) {
if (subTex[i])
subTex[i]->Update(t, texValidity);
// pblock->GetValue(PB_SEED, t, randSeed, texValidity);
pblock->GetValue(water_seed, t, randSeed, texValidity);
pblock->GetValue(water_mapon1, t, mapOn[0], texValidity);
pblock->GetValue(water_mapon2, t, mapOn[1], texValidity);
ReInit();
}
}
ivalid &= texValidity;
}
示例7: my_f
static double
my_f (const gsl_vector *v, void *params)
{
double x, y;
bits_n_bobs* bnb = (bits_n_bobs *)params;
x = gsl_vector_get(v, 0);
y = gsl_vector_get(v, 1);
Bezier b0(bnb->B[0], bnb->B[0]+bnb->dB[0]*x, bnb->A[0]+bnb->dA[0]*y, bnb->A[0]);
Bezier b1(bnb->B[1], bnb->B[1]+bnb->dB[1]*x, bnb->A[1]+bnb->dA[1]*y, bnb->A[1]);
D2<SBasis> zeroset(b0.toSBasis(), b1.toSBasis());
SBasis comp = compose((*bnb->ff),zeroset);
Interval bounds = *bounds_fast(comp);
double error = (bounds.max()>-bounds.min() ? bounds.max() : -bounds.min() );
//printf("error = %g %g %g\n", bounds.max(), bounds.min(), error);
return error*error;
}
示例8: NotifyRefChanged
RefResult Matte::NotifyRefChanged(
const Interval& changeInt,
RefTargetHandle hTarget,
PartID& partID,
RefMessage message,
BOOL propagate)
{
switch (message) {
case REFMSG_CHANGE:
if (hTarget == pblock)
{
ivalid.SetEmpty();
// see if this message came from a changing parameter in the pblock,
// if so, limit rollout update to the changing item and update any active viewport texture
ParamID changing_param = pblock->LastNotifyParamID();
matte_param_blk.InvalidateUI(changing_param);
if( (changing_param == matte_receive_shadows)
||(changing_param == matte_shadow_brightness)
||(changing_param == matte_color)
||(changing_param == matte_reflection_amount)
||(changing_param == matte_use_reflection_map))
{
mReshadeRQ = RR_NeedReshade;
} else if (changing_param == -1)
mReshadeRQ = RR_NeedPreshade;
else
mReshadeRQ = RR_None;
}
if (hTarget != NULL) {
switch (hTarget->SuperClassID()) {
case TEXMAP_CLASS_ID: {
mReshadeRQ = RR_NeedPreshade;
} break;
// default:
// mReshadeRQ =RR_NeedReshade;
// break;
}
}
break;
case REFMSG_SUBANIM_STRUCTURE_CHANGED:
// if (partID == 0)
// mReshadeRQ = RR_None;
// else {
// mReshadeRQ = RR_NeedPreshade;
// NotifyChanged();
// }
break;
}
return REF_SUCCEED;
}
示例9: IllegalStateException
void IntervalSet::add(const Interval &addition) {
if (_readonly) {
throw IllegalStateException("can't alter read only IntervalSet");
}
if (addition.b < addition.a) {
return;
}
// find position in list
for (auto iterator = _intervals.begin(); iterator != _intervals.end(); ++iterator) {
Interval r = *iterator;
if (addition == r) {
return;
}
if (addition.adjacent(r) || !addition.disjoint(r)) {
// next to each other, make a single larger interval
Interval bigger = addition.Union(r);
*iterator = bigger;
// make sure we didn't just create an interval that
// should be merged with next interval in list
while (iterator + 1 != _intervals.end()) {
Interval next = *++iterator;
if (!bigger.adjacent(next) && bigger.disjoint(next)) {
break;
}
// if we bump up against or overlap next, merge
iterator = _intervals.erase(iterator);// remove this one
--iterator; // move backwards to what we just set
*iterator = bigger.Union(next); // set to 3 merged ones
// ml: no need to advance iterator, we do that in the next round anyway. ++iterator; // first call to next after previous duplicates the result
}
return;
}
if (addition.startsBeforeDisjoint(r)) {
// insert before r
//--iterator;
_intervals.insert(iterator, addition);
return;
}
// if disjoint and after r, a future iteration will handle it
}
// ok, must be after last interval (and disjoint from last interval)
// just add it
_intervals.push_back(addition);
}
示例10: aliasLevelData
void TimeInterpolatorRK4::interpolate(/// interpolated solution on this level coarsened
LevelData<FArrayBox>& a_U,
/// time interpolation coefficient in range [0:1]
const Real& a_timeInterpCoeff,
/// interval of a_U to fill in
const Interval& a_intvl)
{
CH_assert(m_defined);
CH_assert(m_gotFullTaylorPoly);
CH_assert(a_U.nComp() == m_numStates);
LevelData<FArrayBox> UComp;
aliasLevelData(UComp, &a_U, a_intvl);
// For i in 0:m_numCoeffs-1,
// coeffFirst[i] is index of first component of m_taylorCoeffs
// that corresponds to a coefficient of t^i.
Vector<int> coeffFirst(m_numCoeffs);
int intervalLength = a_intvl.size();
for (int i = 0; i < m_numCoeffs; i++)
{
coeffFirst[i] = a_intvl.begin() + i * m_numStates;
}
DataIterator dit = UComp.dataIterator();
for (dit.begin(); dit.ok(); ++dit)
{
FArrayBox& UFab = UComp[dit];
const FArrayBox& taylorFab = m_taylorCoeffs[dit];
// Evaluate a0 + a1*t + a2*t^2 + a3*t^3
// as a0 + t * (a1 + t * (a2 + t * a3)).
UFab.copy(taylorFab, coeffFirst[m_numCoeffs-1], 0, intervalLength);
for (int ind = m_numCoeffs - 2; ind >=0; ind--)
{
UFab *= a_timeInterpCoeff;
UFab.plus(taylorFab, coeffFirst[ind], 0, intervalLength);
}
}
// dummy statement in order to get around gdb bug
int dummy_unused = 0; dummy_unused = 0;
}
示例11: Update
void Gradient::Update(TimeValue t, Interval& valid)
{
if (!ivalid.InInterval(t)) {
ivalid.SetInfinite();
uvGen->Update(t,ivalid);
texout->Update(t,ivalid);
pblock->GetValue( grad_color1, t, col[0], ivalid );
col[0].ClampMinMax();
pblock->GetValue( grad_color2, t, col[1], ivalid );
col[1].ClampMinMax();
pblock->GetValue( grad_color3, t, col[2], ivalid );
col[2].ClampMinMax();
pblock->GetValue( grad_map1_on, t, mapOn[0], ivalid);
pblock->GetValue( grad_map2_on, t, mapOn[1], ivalid);
pblock->GetValue( grad_map3_on, t, mapOn[2], ivalid);
pblock->GetValue( grad_type, t, type, ivalid );
pblock->GetValue( grad_noise_type, t, noiseType, ivalid );
pblock->GetValue( grad_amount, t, amount, ivalid );
pblock->GetValue( grad_size, t, size, ivalid );
pblock->GetValue( grad_phase, t, phase, ivalid );
pblock->GetValue( grad_center, t, center, ivalid );
pblock->GetValue( grad_levels, t, levels, ivalid );
pblock->GetValue( grad_high_thresh, t, high, ivalid );
pblock->GetValue( grad_low_thresh, t, low, ivalid );
pblock->GetValue( grad_thresh_smooth, t, smooth, ivalid );
if (low>high) {
float temp = low;
low = high;
high = temp;
}
hminusl = (high-low);
sd = hminusl*0.5f*smooth;
if (size!=0.0f) size1 = 20.0f/size;
else size1 = 0.0f;
for (int i=0; i<NSUBTEX; i++) {
if (subTex[i])
subTex[i]->Update(t,ivalid);
}
EnableStuff();
}
valid &= ivalid;
}
示例12: 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);
}
}
示例13: vofit
void
EBCoarToFineRedist::increment(const BaseIVFAB<Real>& a_coarseMass,
const DataIndex& a_coarseDataIndex,
const Interval& a_variables)
{
BaseIVFAB<Real>& coarBuf = m_regsCoar[a_coarseDataIndex];
const EBISBox& ebisBox = m_ebislCoar[a_coarseDataIndex];
const IntVectSet& ivsLoc = m_setsCoar[a_coarseDataIndex];
CH_assert(a_coarseMass.getIVS().contains(ivsLoc));
CH_assert(coarBuf.getIVS().contains(ivsLoc));
for (VoFIterator vofit(ivsLoc, ebisBox.getEBGraph()); vofit.ok(); ++vofit)
{
const VolIndex& vof = vofit();
for (int ivar = a_variables.begin();
ivar <= a_variables.end(); ivar++)
{
coarBuf(vof, ivar) += a_coarseMass(vof, ivar);
}
}
}
示例14: insert
void TreeNode::insert(Interval i){
if(i.contains(center)){
left_end.push_back(i.a);
right_end.push_back(i.b);
return;
}
if(i.b < center){
//interval is left to center
if(!left)
left = new TreeNode(i.middle());
left->insert(i);
}
else{
//interval is right to center
if(!right)
right = new TreeNode(i.middle());
right->insert(i);
}
}
示例15: NotifyRefChanged
RefResult Mask::NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget,
PartID& partID, RefMessage message, BOOL propagate ) {
switch (message) {
case REFMSG_CHANGE:
ivalid.SetEmpty();
mapValid.SetEmpty();
if (hTarget == pblock)
{
//if (paramDlg&&!paramDlg->isActive)
ParamID changing_param = pblock->LastNotifyParamID();
mask_param_blk.InvalidateUI(changing_param);
}
// if (paramDlg)
// paramDlg->Invalidate();
break;
}
return(REF_SUCCEED);
}