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


C++ Delta函数代码示例

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


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

示例1: CalcMaxPasteRange

/**
 * Calculate how far tiles can be altered beyond a given paste area bound.
 *
 * When pasting, some tiles around the paste area may be altered (during terraforming).
 * The function return the limit on how far it can happen. Calculations are not exact,
 * the goal is to give a safe range that will include any possible case.
 *
 * Result is based on current and desired heights at neighbour corners of the paste area.
 *
 * @param curr_h1 Current height on the first corner.
 * @param curr_h2 Current height on the second corner.
 * @param new_h1 Desired height on the first corner.
 * @param new_h2 Desired height on the second corner.
 * @param length Distance (in tiles) between corners.
 * @return How far (in tiles) terraforming can reach beyond the given bound.
 *
 * @pre Tile heights and the length can't create an impossible layout, heights can't differ
 *      too much: \n
 *      <tt> Delta(curr_h1, curr_h2) <= length </tt> \n
 *      <tt> Delta(new_h1, new_h2) <= length </tt> \n
 *
 * @see CopyPasteAreasMayColide
 */
static uint CalcMaxPasteRange(uint curr_h1, uint new_h1, uint curr_h2, uint new_h2, uint length)
{
	uint min_curr_h = CeilDiv(max<int>(curr_h1 + curr_h2 - length, 0), 2);
	uint max_curr_h = min((curr_h1 + curr_h2 + length) / 2, MAX_TILE_HEIGHT);
	uint min_new_h = CeilDiv(max<int>(new_h1 + new_h2 - length, 0), 2);
	uint max_new_h = min((new_h1 + new_h2 + length) / 2, MAX_TILE_HEIGHT);

	return max(Delta(max_new_h, min_curr_h), Delta(max_curr_h, min_new_h));
}
开发者ID:koreapyj,项目名称:openttd-yapp,代码行数:32,代码来源:copypaste_cmd.cpp

示例2: simdmaxbitsd1_length

/* maxbit over |length| integers with provided initial value */
uint32_t simdmaxbitsd1_length(uint32_t initvalue, const uint32_t * in,
                uint32_t length) {
    __m128i newvec;
    __m128i oldvec;
    __m128i initoffset;
    __m128i accumulator;
    const __m128i *pin;
    uint32_t tmparray[4];
    uint32_t k = 1;
    uint32_t acc;

    assert(length > 0);

    pin = (const __m128i *)(in);
    initoffset = _mm_set1_epi32(initvalue);
    switch (length) {
      case 1:
        newvec = _mm_set1_epi32(in[0]);
        break;
      case 2:
        newvec = _mm_setr_epi32(in[0], in[1], in[1], in[1]);
        break;
      case 3:
        newvec = _mm_setr_epi32(in[0], in[1], in[2], in[2]);
        break;
      default:
        newvec = _mm_loadu_si128(pin);
        break;
    }
    accumulator = Delta(newvec, initoffset);
    oldvec = newvec;

    /* process 4 integers and build an accumulator */
    while (k * 4 + 4 <= length) {
        newvec = _mm_loadu_si128(pin + k);
        accumulator = _mm_or_si128(accumulator, Delta(newvec, oldvec));
        oldvec = newvec;
        k++;
    }

    /* extract the accumulator as an integer */
    _mm_storeu_si128((__m128i *)(tmparray), accumulator);
    acc = tmparray[0] | tmparray[1] | tmparray[2] | tmparray[3];

    /* now process the remaining integers */
    for (k *= 4; k < length; k++)
        acc |= in[k] - (k == 0 ? initvalue : in[k - 1]);

    /* return the number of bits */
    return bits(acc);
}
开发者ID:NaveenSigmoid,项目名称:simdcomp,代码行数:52,代码来源:simdcomputil.c

示例3: test1

unsigned test1(unsigned sx,unsigned sy)
 {
  AlphaFunc func1(sx,sy);
  DrawAlgo::LineAlphaFunc<UInt> func2(sx,sy);

  unsigned ret=0;

  for(unsigned d=0; d<=sx ;d++)
    {
     Replace_max(ret,Delta(func1.alpha0(d,sx,sy),func2.alpha0(d,sx,sy)));
     Replace_max(ret,Delta(func1.alpha1(d,sx,sy),func2.alpha1(d,sx,sy)));
    }

  return ret;
 }
开发者ID:SergeyStrukov,项目名称:CCore-2-xx,代码行数:15,代码来源:test7002.DrawAlgo.cpp

示例4: simdmaxbitsd1

/* maxbit over 128 integers (SIMDBlockSize) with provided initial value */
uint32_t simdmaxbitsd1(uint32_t initvalue, const uint32_t * in) {
    __m128i  initoffset = _mm_set1_epi32 (initvalue);
    const __m128i* pin = (const __m128i*)(in);
    __m128i newvec = _mm_loadu_si128(pin);
    __m128i accumulator = Delta(newvec , initoffset);
    __m128i oldvec = newvec;
    uint32_t k = 1;
    for(; 4*k < SIMDBlockSize; ++k) {
        newvec = _mm_loadu_si128(pin+k);
        accumulator = _mm_or_si128(accumulator,Delta(newvec , oldvec));
        oldvec = newvec;
    }
    initoffset = oldvec;
    return maxbitas32int(accumulator);
}
开发者ID:NaveenSigmoid,项目名称:simdcomp,代码行数:16,代码来源:simdcomputil.c

示例5: solReal

void TPZArtDiff::ContributeImplDiff(int dim, TPZFMatrix<REAL> &jacinv, TPZVec<FADREAL> &sol, TPZVec<FADREAL> &dsol, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef, REAL weight,  REAL timeStep, REAL deltaX)
{
    TPZVec<STATE> solReal(sol.NElements());
    int i;
    for(i = 0; i < sol.NElements(); i++)
		solReal[i] = sol[i].val();
	
    REAL delta = Delta(deltaX, solReal);
    REAL constant = /*-*/ delta * weight * timeStep;
	
    TPZVec<TPZVec<FADREAL> > TauDiv;
	
    PrepareFastDiff(dim, jacinv, sol, dsol, TauDiv);
	
    TPZVec<FADREAL> Diff;
    TPZVec<REAL> gradv(dim);
	
    int j, k, l;
    int nstate = dim + 2;
    int neq = sol[0].size();
    int nshape = neq/nstate;
	
    for(l=0;l<nshape;l++)
	{
		for(k=0;k<dim;k++)
			gradv[k] = dsol[k].dx/*fastAccessDx*/(/*k+*/l*nstate);// always retrieving this information from the first state variable...
		ODotOperator(gradv, TauDiv, Diff);
		for(i=0;i<nstate;i++)
		{
			ef(i+l*nstate,0) += constant * Diff[i].val();
			for(j=0;j<neq;j++)
				ek(i+l*nstate, j) -= constant * Diff[i].dx/*fastAccessDx*/(j);
		}
	}
}
开发者ID:labmec,项目名称:neopz,代码行数:35,代码来源:pzartdiff.cpp

示例6: Bp

TSIL_COMPLEX Bp (TSIL_REAL X, TSIL_REAL Y, TSIL_COMPLEX S, TSIL_REAL QQ)
{
  if (X < TSIL_TOL) {
    TSIL_Warn("Bp", "B(x',y) is undefined for x=0.");
    return TSIL_Infinity;
  }

  if (TSIL_CABS(1.0L - S/(X+Y+2.0L*TSIL_SQRT(X*Y))) < TSIL_TOL) {
    TSIL_Warn("Bp", "B(x',y) is undefined at s = (sqrt(x) + sqrt(y))^2.");
    return TSIL_Infinity;
  }

  if (TSIL_CABS(S) < TSIL_TOL) {
    if (TSIL_FABS(1.0L - X/Y) < TSIL_TOL)
      return (-0.5L/X);
    else
      return 1.0L/(Y-X) + Y*TSIL_LOG(X/Y)/((Y-X)*(Y-X));
  }

  if (TSIL_CABS(1.0L - (X + Y - 2.0L*TSIL_SQRT(X*Y))/S) < TSIL_TOL) 
    return (1.0L - TSIL_SQRT(Y/X) +0.5L*TSIL_LOG(Y/X))/(X + Y - 2.0L*TSIL_SQRT(X*Y));
  else
    return ((X-Y-S)*B(X,Y,S,QQ) + (X+Y-S)*TSIL_LOG(X/QQ) 
	    -2.0L*A(Y,QQ) + 2.0L*(S-X))/Delta(S,X,Y);
}
开发者ID:pathron,项目名称:softsusy,代码行数:25,代码来源:analyticAB.c

示例7: Delta

void TPZArtDiff::ContributeFastestImplDiff_dim(TPZFMatrix<REAL> &jacinv, TPZVec<STATE> &sol, TPZFMatrix<STATE> &dsol, TPZFMatrix<REAL> &phi, TPZFMatrix<REAL> &dphi, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef, REAL weight, REAL timeStep, REAL deltaX)
{
    REAL delta = Delta(deltaX, sol);
    REAL constant = /*-*/ weight * delta * timeStep;
    REAL buff;
	
    TPZVec<TPZVec<STATE> > TauDiv;
    TPZVec<TPZDiffMatrix<STATE> > dTauDiv;
	
    PrepareFastestDiff<dim>( jacinv, sol, dsol, phi, dphi, TauDiv, dTauDiv);
	
    int i, j, k, l;
    int nshape = dphi.Cols();
    int nstate = dim + 2;
    int neq = nstate * nshape;
	
    // ODotProduct speeded up
	
    for(l=0;l<nshape;l++)
		for(i=0;i<nstate;i++)
			for(k=0;k<dim;k++)
			{
				buff = dphi(k,l) * constant;
				ef(i+l*nstate,0) += buff * TauDiv[k][i];
				for(j=0;j<neq;j++)
					ek(i+l*nstate,j) -= buff * dTauDiv[k](i,j);
			}
}
开发者ID:labmec,项目名称:neopz,代码行数:28,代码来源:pzartdiff.cpp

示例8: BMsubst

int BMsubst(char *S, char *T)
{
    int n =  mstrlen(S), m =  mstrlen(T), i, k;
    int **del = Delta(S);
    k = i = n - 1;
    for (k = n - 1; k < m; k += del[n - i - 1][(int) T[k]], i = n - 1)
    {
        while (T[k] == S[i])
        {
            if (i == 0)
            {
                for (i = 0; i < n; ++i)
                {
                    free(del[i]);
                }
                free(del);
                return k;
            }
            --i;
            --k;
        }
    }
    for (i = 0; i < n; i++)
    {
        free(del[i]);
    }
    free(del);
    return (k<m)? k:m;
}
开发者ID:BuDashka,项目名称:UniWork_course1,代码行数:29,代码来源:extstop.c

示例9: Delta

ulen ScrollShape::delta(uCoord delta,uCoord len,uCoord dlen) const
 {
  if( total<=page ) return 0;
  
  uCoord ext=2*dlen;
  
  if( len<=ext ) return 0;
  
  len-=ext;
  
  if( len<=dlen ) return 0;
  
  if( Delta(total,dlen,len)<page ) return Delta(total,delta,len);
  
  return Delta(total-page,delta,len-dlen);
 }
开发者ID:SergeyStrukov,项目名称:CCore,代码行数:16,代码来源:ShapeLib13.cpp

示例10: autonomous

task autonomous()
{
    StartTask(descore);

    StartTask(velocitycalculator);

    if(SensorValue[J1]) // blue
    {
        if(SensorValue[J2]) //normal
        {
            // RAM
            ArmWall();

            ForwardTillStop(127);

        }
        else // oppo
        {
            Gamma();
        }
    }
    else // red
    {
        if(SensorValue[J2]) // normal
        {
            Beta();
        }
        else // oppo
        {
            Delta();
        }
    }

    StopTask(velocitycalculator);
}
开发者ID:Skeer,项目名称:5000A,代码行数:35,代码来源:Autonomous.c

示例11: if

// Update camera
void _Camera::Update(double FrameTime) {
	LastPosition = Position;

	// Cap distance
	if(TargetPosition.z <= 1.0f)
		TargetPosition.z = 1.0f;
	else if(TargetPosition.z >= Far)
		TargetPosition.z = Far;

	// Update position
	glm::vec2 Delta(TargetPosition - Position);
	if(std::abs(Delta.x) > 0.01f)
		Position.x += Delta.x / UpdateDivisor;
	else
		Position.x = TargetPosition.x;

	if(std::abs(Delta.y) > 0.01f)
		Position.y += Delta.y / UpdateDivisor;
	else
		Position.y = TargetPosition.y;

	// Update distance
	float DeltaZ = TargetPosition.z - Position.z;
	if(std::abs(DeltaZ) > 0.01f)
		Position.z += DeltaZ / UpdateDivisor;
	else
		Position.z = TargetPosition.z;
}
开发者ID:jazztickets,项目名称:ae,代码行数:29,代码来源:camera.cpp

示例12: NPFDistanceTrack

/**
 * Calculates the minimum distance traveled to get from t0 to t1 when only
 * using tracks (ie, only making 45 degree turns). Returns the distance in the
 * NPF scale, ie the number of full tiles multiplied by NPF_TILE_LENGTH to
 * prevent rounding.
 */
static uint NPFDistanceTrack(TileIndex t0, TileIndex t1)
{
	const uint dx = Delta(TileX(t0), TileX(t1));
	const uint dy = Delta(TileY(t0), TileY(t1));

	const uint straightTracks = 2 * min(dx, dy); // The number of straight (not full length) tracks
	/* OPTIMISATION:
	 * Original: diagTracks = max(dx, dy) - min(dx,dy);
	 * Proof:
	 * (dx+dy) - straightTracks  == (min + max) - straightTracks = min + max - 2 * min = max - min */
	const uint diagTracks = dx + dy - straightTracks; // The number of diagonal (full tile length) tracks.

	/* Don't factor out NPF_TILE_LENGTH below, this will round values and lose
	 * precision */
	return diagTracks * NPF_TILE_LENGTH + straightTracks * NPF_TILE_LENGTH * STRAIGHT_TRACK_LENGTH;
}
开发者ID:andrew889,项目名称:OpenTTD,代码行数:22,代码来源:npf.cpp

示例13: taylorSample

/** An sample for taylor expansion of logdet(X). */
void taylorSample() {

  std::string ans;
  char rowChar[5];
  int rowTmp = ROW;
  sprintf(rowChar, "%d", rowTmp);
  std::string row = rowChar;
  // Initialize the matrices.
  symbolic_matrix_type X("X", ROW, COL);
  symbolic_matrix_type X0("X0", ROW, COL);
  symbolic_matrix_type Delta("(X-X0)", ROW, COL);
    
  AMD::SymbolicScalarMatlab a2("1/2!");
  AMD::SymbolicScalarMatlab a3("1/3!"); 
  SymbolicSMFunc r2(a2,ROW,COL);
  SymbolicSMFunc r3(a3,ROW, COL);

  // Initialize MatrixMatrixFunction. 
  SymbolicMMFunc fX(X, false);
  SymbolicMMFunc fX0(X0, false);
  SymbolicMMFunc fDelta(Delta, true);

  // Compute Taylor series iteratively. 
  SymbolicSMFunc f0 =  logdet(fX0);
  SymbolicSMFunc f1 = trace(fDelta * transpose(*f0.derivativeFuncVal));
  SymbolicSMFunc f2 = trace(fDelta * transpose(*f1.derivativeFuncVal));
  SymbolicSMFunc f3 = trace(fDelta * transpose(*f2.derivativeFuncVal));
  // Taylor Expansion. 
  SymbolicSMFunc func = f0 + f1 + r2*f2 + r3*f3;

  std::cout<<"The first 4 terms of Taylor Expansion for logdet(X) around X0 is:";
  std::cout << std::endl;
  std::cout << func.functionVal.getString() << std::endl;

}
开发者ID:yyzreal,项目名称:AMD,代码行数:36,代码来源:TaylorSample.cpp

示例14: NS_ENSURE_ARG_POINTER

/* readonly attribute float delta; */
NS_IMETHODIMP
nsDOMSimpleGestureEvent::GetDelta(double *aDelta)
{
    NS_ENSURE_ARG_POINTER(aDelta);
    *aDelta = Delta();
    return NS_OK;
}
开发者ID:hwine,项目名称:test-mmc,代码行数:8,代码来源:nsDOMSimpleGestureEvent.cpp

示例15: min

/**
 * Moves some cargo from one designation to another. You can only move
 * between adjacent designations. E.g. you can keep cargo that was
 * previously reserved (MTA_LOAD) or you can mark cargo to be transferred
 * that was previously marked as to be delivered, but you can't reserve
 * cargo that's marked as to be delivered.
 */
uint VehicleCargoList::Reassign(uint max_move, MoveToAction from, MoveToAction to)
{
	max_move = min(this->action_counts[from], max_move);
	assert(Delta((int)from, (int)to) == 1);
	this->action_counts[from] -= max_move;
	this->action_counts[to] += max_move;
	return max_move;
}
开发者ID:kestereverts,项目名称:openttd-ijpack,代码行数:15,代码来源:cargopacket.cpp


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