• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ dif函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: dif

void CGeoSquareProjectile::Draw()
{
	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->GetPos());
	dif.ANormalize();
	float3 dir1(dif.cross(v1));
	dir1.ANormalize();
	float3 dif2(p2 - camera->GetPos());
	dif2.ANormalize();
	float3 dir2(dif2.cross(v2));
	dir2.ANormalize();


	const float u = (projectileDrawer->geosquaretex->xstart + projectileDrawer->geosquaretex->xend) / 2;
	const float v0 = projectileDrawer->geosquaretex->ystart;
	const float v1 = projectileDrawer->geosquaretex->yend;

	if (w2 != 0) {
		va->AddVertexTC(p1 - dir1 * w1, u, v1, col);
		va->AddVertexTC(p1 + dir1 * w1, u, v0, col);
		va->AddVertexTC(p2 + dir2 * w2, u, v0, col);
		va->AddVertexTC(p2 - dir2 * w2, u, v1, col);
	} else {
		va->AddVertexTC(p1 - dir1 * w1, u, v1,                    col);
		va->AddVertexTC(p1 + dir1 * w1, u, v0,                    col);
		va->AddVertexTC(p2,             u, v0 + (v1 - v0) * 0.5f, col);
		va->AddVertexTC(p2,             u, v0 + (v1 - v0) * 1.5f, col);
	}
}
开发者ID:304471720,项目名称:spring,代码行数:35,代码来源:GeoSquareProjectile.cpp


示例17: pxi

GMMExpectationMaximization::uint GMMExpectationMaximization::execute(const MatrixX & dataset)
{  
  const uint data_count = dataset.rows();
  const uint num_gaussians = m_means.size();
  const uint dim = dataset.cols();

  MatrixX pxi(data_count,num_gaussians);
  MatrixX pix(data_count,num_gaussians);
  VectorX pxidatatot(data_count);
  VectorX weights(num_gaussians);
  VectorX ex(data_count);
  MatrixX ts(dim,dim);
  VectorX dif(dim);

  Real prev_log_likelyhood = 1.0;
  
  uint it_num;
  for (it_num = 0; it_num < m_max_iterations; it_num++)
  {
    for (uint g = 0; g < num_gaussians; g++)
      weights[g] = m_weights[g];

    for (uint d = 0; d < data_count; d++)
      for (uint g = 0; g < num_gaussians; g++)
        pxi(d,g) = gauss(m_means[g],m_covs[g],dataset.row(d).transpose());

    pxidatatot = pxi * weights;
    Real log_likelyhood = pxidatatot.array().log().sum() / Real(data_count);

    if (it_num != 0 && (std::abs(log_likelyhood / prev_log_likelyhood - 1.0) < m_termination_threshold))
      break;
    prev_log_likelyhood = log_likelyhood;

    for (uint d = 0; d < data_count; d++)
      pix.row(d) = (pxi.row(d).transpose().array() * weights.array()).transpose() / pxidatatot[d];
    
    ex = pix.colwise().sum();

    for(uint g = 0; g < num_gaussians; g++)
    {
      m_weights[g] = ex[g] / Real(data_count);

      m_means[g] = (dataset.transpose() * pix.col(g)) / ex[g];

      ts = MatrixX::Zero(dim,dim);
      for (uint d = 0; d < data_count; d++)
      {
        dif = dataset.row(d).transpose() - m_means[g];
        ts.noalias() += (dif * dif.transpose()) * pix(d,g);
      }
      m_covs[g] = (ts / ex[g]) + MatrixX::Identity(dim,dim) * m_epsilon;
    }

    // interruption point here
    if (m_termination_handler && m_termination_handler->isTerminated())
      return it_num;
  }

  return it_num;
}
开发者ID:wycivil08,项目名称:gaussian_mixture_model,代码行数:60,代码来源:gmm.cpp


示例18: dif

void Loader::LoadMaterial(const aiScene *pScene, const char *file_name)
{
    //store material
    for(int i = 0 ;i<pScene->mNumMaterials;i++)
    {
        aiColor3D dif(0.f,0.f,0.f);
        aiColor3D amb(0.f,0.f,0.f);
        aiColor3D spec(0.f,0.f,0.f);
        aiMaterial * the_material = pScene->mMaterials[i];
        CMC_Material * material = new CMC_Material();
        the_material->Get(AI_MATKEY_COLOR_AMBIENT,amb);
        the_material->Get(AI_MATKEY_COLOR_DIFFUSE,dif);
        the_material->Get(AI_MATKEY_COLOR_SPECULAR,spec);

        material->ambientColor = QVector3D(amb.r,amb.g,amb.b);
        material->diffuseColor = QVector3D(dif.r,dif.g,dif.b);
        material->specularColor = QVector3D(spec.r,spec.g,spec.b);
        aiString normalPath;
        the_material->GetTexture (aiTextureType_NORMALS,0,&normalPath);
        //now ,we only use the first diffuse texture, will fix it later
        aiString diffuse_Path;
        the_material->GetTexture(aiTextureType_DIFFUSE,0,&diffuse_Path);
        if(diffuse_Path.length == 0 )
        {
            material->diffuseTexturePath = "INVALID";
        }else
        {
            material->diffuseTexturePath = diffuse_Path.C_Str ();
        }
        m_model->addMaterial (material);
    }
}
开发者ID:JobsSteve,项目名称:Cube-Engine,代码行数:32,代码来源:Loader.cpp


示例19: dif

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

	if (directional) {
		float3 dif(pos-camera->GetPos());
		dif.ANormalize();
		float3 dir1(dif.cross(speed));
		dir1.ANormalize();
		float3 dir2(dif.cross(dir1));

		unsigned char color[4];

		colorMap->GetColor(color, life);

		va->AddVertexTC(drawPos - dir1 * size - dir2 * size, texture->xstart, texture->ystart, color);
		va->AddVertexTC(drawPos - dir1 * size + dir2 * size, texture->xend,   texture->ystart, color);
		va->AddVertexTC(drawPos + dir1 * size + dir2 * size, texture->xend,   texture->yend,   color);
		va->AddVertexTC(drawPos + dir1 * size - dir2 * size, texture->xstart, texture->yend,   color);
	} else {
		unsigned char color[4];

		colorMap->GetColor(color, life);

		va->AddVertexTC(drawPos - camera->right * size - camera->up * size, texture->xstart, texture->ystart, color);
		va->AddVertexTC(drawPos + camera->right * size - camera->up * size, texture->xend,   texture->ystart, color);
		va->AddVertexTC(drawPos + camera->right * size + camera->up * size, texture->xend,   texture->yend,   color);
		va->AddVertexTC(drawPos - camera->right * size + camera->up * size, texture->xstart, texture->yend,   color);
	}
}
开发者ID:jamerlan,项目名称:spring,代码行数:30,代码来源:GenericParticleProjectile.cpp


示例20: lock

void AresInterdictionManager::CleanTargets(void)
{
	
	Vector v_tmp;
	v_tmp.EnsureSize(mv_interdiction_targets.Size()/2);

	CSingleLock lock(&m_lock,TRUE);
	CTime now=CTime::GetCurrentTime();
	CTimeSpan dif(3,0,0,0);

	for(int i=0;i<(int)mv_interdiction_targets.Size();i++){
		InterdictionTarget* it=(InterdictionTarget*)mv_interdiction_targets.Get(i);
		//if we haven't failed connecting to this target at least twice, then lets keep it for now
		//the target must be less than 3 days old as well
		if(it->m_fail_count<2 && it->m_create_time>(now-dif)){  
			v_tmp.Add(it);
		}
		else if(m_index>=i && m_index>0){
			if(stricmp(it->GetStrIP().c_str(),"81.3.87.174")==0){
				ASSERT(0);
			}
			m_index--;  //decrememt the index so we don't skip over a large set of clients
		}
	}
	
	mv_interdiction_targets.Copy(&v_tmp);
}
开发者ID:vdrive,项目名称:TrapperKeeper,代码行数:27,代码来源:AresInterdictionManager.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ diff_flush函数代码示例发布时间:2022-05-30
下一篇:
C++ die_if_kernel函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap