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


C++ dif函数代码示例

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


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

示例1: calc_src_coef2

void calc_src_coef2(u32 *div_M, u32 *fac_N, u32 freq)
{
	u32 m, n;
	u64 temp;
	u32 temp_m = 0;
	u32 temp_n = 0;
	u64 cur_val = 0;

	if(freq > 4200000000UL) {
		freq = 4200000000UL;
		__wrn("warning: freq set is over 4200M\n");
	}

	for(n = 12; n < 256; n++)
		for(m = 0; m < 2; m++)
		{
			temp = n;
			temp = temp * 24000000;
			temp = temp / (m + 1);
			if(dif(temp, freq) < dif(cur_val, freq))
			{
				temp_m = m;
				temp_n = n;
				cur_val = temp;
			}
		}

		*div_M = temp_m;
		*fac_N = temp_n;
}
开发者ID:GREYFOXRGR,项目名称:BPI-M3-bsp,代码行数:30,代码来源:de_clock.c

示例2: calc_pll8_coef

void calc_pll8_coef(u32 *div_M, u32 *div_P, u32 *fac_N, u32 freq)
{
	u32 m, p, n;
	u64 temp;
	u32 temp_m = 0;
	u32 temp_p = 0;
	u32 temp_n = 0;
	u64 cur_val = 0;

	if(freq > 4200000000UL) {
		freq = 4200000000UL;
		__wrn("warning: freq set is over 4200M\n");
	}

	for(n = 12; n < 256; n++)
		for(m = 0; m < 2; m++)
			for(p = 0; p < 3; p++)
			{
				temp = n;
				temp = temp * 24000000;
				temp = temp / ((m + 1) * pow2(p));
				if(dif(temp, freq) < dif(cur_val, freq))
				{
					temp_m = m;
					temp_p = p;
					temp_n = n;
					cur_val = temp;
				}
			}

	*div_M = temp_m;
	*div_P = temp_p;
	*fac_N = temp_n;
}
开发者ID:GREYFOXRGR,项目名称:BPI-M3-bsp,代码行数:34,代码来源:de_clock.c

示例3: centerArea

static status
centerArea(Area a, Point pos)
{ assign(a, x, dif(pos->x,a->w));
  assign(a, y, dif(pos->y,a->h));

  succeed;
}
开发者ID:brayc0,项目名称:nlfetdb,代码行数:7,代码来源:area.c

示例4: compute

 void compute( const FUNC& f, const X & x, const o_t & o)
 {
   real_t tmptol = tol_;
   init(o, x);
   BOOST_AUTO_TPL(dif, nt2::abs(nt2::diff(nt2::rowvect(wpts_))));
   real_t tol1= tol_/nt2::globalasum1(dif);
   size_t l = numel(dif);
   res_.resize(extent(wpts_));
   res_(1) = nt2::Zero<value_t>();
   tol_ = tol1*dif(1);
   res_(2) = compute<true>(f, wpts_(1), wpts_(2));
   for(size_t i=2; i < l; ++i)
   {
     tol_ = tol1*dif(i);
     res_(i+1) = res_(i)+compute<false>(f, wpts_(i), wpts_(i+1));
   }
   if (l >= 2)
   {
     tol_ = tol1*dif(l);
     res_(l+1) = res_(l)+compute<true>(f, wpts_(l), wpts_(l+1));
   }
   tol_ = tmptol;
   if (!o.return_waypoints)
   {
     res_(begin_) = res_(end_);
     res_.resize(nt2::of_size(1, 1));
   }
 }
开发者ID:fpelliccioni,项目名称:nt2,代码行数:28,代码来源:quadl.hpp

示例5: calc_src_coef3

void calc_src_coef3(u32 *div_M, u32 *fac_K, u32 *fac_N, u32 src_freq, u32 freq)
{
	u32 m, k, n;
	u64 temp;
	u32 temp_m = 0;
	u32 temp_k = 0;
	u32 temp_n = 0;
	u64 cur_val = 0;

	freq = freq > 1440000000 ? 1440000000 : freq;

	for(n = 0; n < 16; n++)
		for(k = 0; k < 4; k++)
			for(m = 0; m < 16; m++)
			{
				temp = src_freq;
				temp = temp * (n + 1) * (k + 1) / (m + 1);
				if(dif(temp, freq) < dif(cur_val, freq))
				{
					temp_m = m;
					temp_k = k;
					temp_n = n;
					cur_val = temp;
				}
			}

	*div_M = temp_m;
	*fac_K = temp_k;
	*fac_N = temp_n;
}
开发者ID:Aorjoa,项目名称:bootloader,代码行数:30,代码来源:de_clock.c

示例6: calc_src_coef2

void calc_src_coef2(u32 *div_M, u32 *fac_N, u32 freq)
{
	u32 m, n;
	u64 temp;
	u32 temp_m = 0;
	u32 temp_n = 0;
	u64 cur_val = 0;

	freq = freq > 1440000000 ? 1440000000 : freq;

	for(n = 0; n < 128; n++)
		for(m = 0; m < 16; m++)
		{
			temp = 24000000 * (n + 1) / (m + 1);
			if(dif(temp, freq) < dif(cur_val, freq))
			{
				temp_m = m;
				temp_n = n;
				cur_val = temp;
			}
		}

		*div_M = temp_m;
		*fac_N = temp_n;
}
开发者ID:Aorjoa,项目名称:bootloader,代码行数:25,代码来源:de_clock.c

示例7: main

int main()
{
    int L;
    char h[2000001];
    while (scanf("%d ", &L) && L)
    {
        gets(h);
        int ur = INF, ud = INF, dist = INF, dist_a;
        for (int i = 0; i < L; i++)
        {
            if (h[i] == 'Z')
            {
                dist = 0;
                break;
            }
            else if (h[i] == 'R')
            {
                ur = i;
                if ((dist_a = dif(ur, ud)) < dist)
                    dist = dist_a;
            }
            else if (h[i] == 'D')
            {
                ud = i;
                if ((dist_a = dif(ur, ud)) < dist)
                    dist = dist_a;
            }
        }
        printf("%d\n", dist);
    }
    return 0;
}
开发者ID:GutoHere,项目名称:Maratona-ICPC,代码行数:32,代码来源:11661-burger_time.cpp

示例8: GetDistance

// Distance between 2 points
_inline int GetDistance(int xp, int yp, int xp2, int yp2)
{
	// Allow decimal calculation
	double x = xp;
	double y = yp;
	double x2 = xp2;
	double y2 = yp2;

	return (int)sqrt((dif (x,x2) * dif (x,x2))+(dif (y,y2) * dif (y,y2)));
}
开发者ID:SortaCore,项目名称:MMF2Exts,代码行数:11,代码来源:TigsExt.hpp

示例9: direce

/*
 *  handles the "directive" state after the "ignore" state
 */
static int direce(lex_t *t)
{
    int i = NELEM(dtab), ign;

    assert(cond_ignore());
    ign = cond_list->f.ignore;

    NEXTSP(t);    /* consumes # */
    if (t->id == LEX_ID) {
        const char *n = LEX_SPELL(t);
        for (i = 0; i < NELEM(dtab); i++)
            if (strcmp(n, dtab[i].name) == 0)
                break;
        switch(i) {
            case DINCLUDE:
            case DDEFINE:
            case DUNDEF:
            case DLINE:
            case DERROR:
            case DPRAGMA:
            default:
                i = NELEM(dtab);
                break;
            case DIF:
                t = dif(t->pos, COND_KIF, 1);
                break;
            case DIFDEF:
                t = dif(t->pos, COND_KIFDEF, 1);
                break;
            case DIFNDEF:
                t = dif(t->pos, COND_KIFNDEF, 1);
                break;
            case DELIF:
                t = delif(t->pos);
                break;
            case DELSE:
                t = delse(t->pos);
                break;
            case DENDIF:
                t = dendif(t->pos);
                break;
        }
    }

    if (warnxtra[i] && ign != 2) {
        SKIPSP(t);
        if (t->id != LEX_NEWLINE)
            t = xtratok(t);
    }
    SKIPNL(t);
    lst_discard(1);
    lex_direc = 0;

    return 0;
}
开发者ID:mycoboco,项目名称:beluga,代码行数:58,代码来源:proc.c

示例10: sceneChange

void title::sceneChange() {
  if (state_ > Blink3) {
    clear_ ? data::reStart(dif(click_mode_ - Easy)) :
      data::newGame(dif(click_mode_ - Easy));
    data::system.scene_[play::Next] = scene::Politics;
  }

  if (click_mode_ == Continue && state_ > Blink2) {
    data::system.scene_[play::Last] = scene::Title;
    data::system.scene_[play::Next] = scene::Load;
  }
}
开发者ID:maro-n,项目名称:LS,代码行数:12,代码来源:title.cpp

示例11: test

void test(){

    std::cout << sum_of_2_numbers(3,5,999) << std::endl;
    std::cout << sum_of_fib(4000000) << std::endl;
    factorize(13195);
    factorize(600851475143);
    std::cout << findPalindrom() << std::endl;
    std::cout << dif(10) << std::endl;
    std::cout.precision(20);
    std::cout << dif(100) << std::endl;
    //std::cout << prime10001() << std::endl;
    std::cout << biggestProduct("/home/paulina/ClionProjects/EulerProb1/Problem8") << std::endl;
}
开发者ID:paulina-szubarczyk,项目名称:workspace,代码行数:13,代码来源:main.cpp

示例12: dif

void CGeoSquareProjectile::Draw(void)
{
	inArray=true;
	unsigned char col[4];
	col[0]=(unsigned char) (r*a*255);
	col[1]=(unsigned char) (g*a*255);
	col[2]=(unsigned char) (b*a*255);
	col[3]=(unsigned char) (a*255);

	float3 dif(p1-camera->pos);
	dif.Normalize();
	float3 dir1(dif.cross(v1));
	dir1.Normalize();
	float3 dif2(p2-camera->pos);
	dif2.Normalize();
	float3 dir2(dif2.cross(v2));
	dir2.Normalize();

	if(w2!=0){
		va->AddVertexTC(p1-dir1*w1,1.0/16,1.0/8,col);
		va->AddVertexTC(p1+dir1*w1,1.0/16,0.0/8,col);
		va->AddVertexTC(p2+dir2*w2,1.0/16,0.0/8,col);
		va->AddVertexTC(p2-dir2*w2,1.0/16,1.0/8,col);
	} else {
		va->AddVertexTC(p1-dir1*w1,1.0/16,1.0/8,col);
		va->AddVertexTC(p1+dir1*w1,1.0/16,0.0/8,col);
		va->AddVertexTC(p2+dir2*w2,1.0/16,0.5/8,col);
		va->AddVertexTC(p2-dir2*w2,1.0/16,1.5/8,col);
	}
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:30,代码来源:GeoSquareProjectile.cpp

示例13: trap

    int trap(int A[], int n) {
	vector<int> left(n,0),right(n,0);

	int max=0;
	for(int i=0;i<n;++i) {
	    left[i] = max;
	    if(max<A[i])
		max=A[i];
	}

	max = 0;
	for(int i=n-1;i>=0;--i) {
	    right[i] = max;
	    if(max<A[i])
		max=A[i];
	}

	vector<int> filled(n,0),dif(n,0);
	int ret = 0;
	for(int i=0;i<n;++i) {
	    filled[i] = min(left[i],right[i]);
	    dif[i] = filled[i]-A[i];
	    if(dif[i]>0)
		ret += dif[i];
	}

	return ret;
    }
开发者ID:elden2010,项目名称:leetcode,代码行数:28,代码来源:trapping_rain_water.cpp

示例14: dif

void GUIminimap::MoveView(int xpos, int ypos, int button)
{
	float dist=ground->LineGroundCol(camera->pos,camera->pos+camera->forward*9000);
	float3 dif(0,0,0);
	if(dist>0){
		dif=camera->forward*dist;
	}
	float camHeight=camera->pos.y-ground->GetHeight(camera->pos.x,camera->pos.z);
	float3 clickPos;
	
	float xrel=xpos/(float)w;
	float yrel=ypos/(float)h;
	
	// FIXME: magic number: is this 8 maybe SQUARE_SIZE?
	clickPos.x=xrel*gs->mapx*8;
	clickPos.z=yrel*gs->mapy*8;
	float3 finalPos=clickPos-dif;

	if(guiGameControl->DirectCommand(clickPos, button))
	{
		downInMinimap=false;
		return;
	}
	
	if(button!=1)
		return;

	mouse->currentCamController->SetPos(clickPos);
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:29,代码来源:GUIminimap.cpp

示例15: dif

void CExploSpikeProjectile::Draw(void)
{
	inArray=true;

	float3 dif(pos-camera->pos2);
	dif.Normalize();
	float3 dir2(dif.cross(dir));
	dir2.Normalize();

	unsigned char col[4];
	float a=std::max(0.f,alpha-alphaDecay*gu->timeOffset)*255;
	col[0]=(unsigned char)(a*color.x);
	col[1]=(unsigned char)(a*color.y);
	col[2]=(unsigned char)(a*color.z);
	col[3]=1;

	float3 interpos=pos+speed*gu->timeOffset;
	float3 l=dir*length+lengthGrowth*gu->timeOffset;
	float3 w=dir2*width;

	va->AddVertexTC(interpos+l+w, ph->laserendtex.xend, ph->laserendtex.yend, col);
	va->AddVertexTC(interpos+l-w, ph->laserendtex.xend, ph->laserendtex.ystart, col);
	va->AddVertexTC(interpos-l-w, ph->laserendtex.xstart, ph->laserendtex.ystart, col);
	va->AddVertexTC(interpos-l+w, ph->laserendtex.xstart, ph->laserendtex.yend, col);
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:25,代码来源:ExploSpikeProjectile.cpp


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