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


C++ pot函数代码示例

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


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

示例1: makePotTex

void makePotTex(const struct jpeg_img *img, struct npot_tex *tex)
{
	/* tid is assigned by other routines */
	/* only care about calculating the Power-Of-Two size and clip size in s-t texture coordiantes */
	tex->real_width = img->width;
	tex->real_height = img->height;
	tex->pot_width = pot(tex->real_width);
	tex->pot_height = pot(tex->real_height);
	tex->clip_width = tex->real_width / (double)tex->pot_width;
	tex->clip_height = tex->real_height / (double)tex->pot_height;
	tex->per_eye_aspect = tex->real_width / (double)tex->real_height;
	/* correct the real aspect ratio for stereo images */
	if (img->is_stereo) {
		tex->is_stereo = 1;
		tex->per_eye_aspect /= 2;
	} else {
		tex->is_stereo = 0;
	}
	/* copy data and pad */
	tex->data = malloc(tex->pot_width * tex->pot_height * 3);
	int rowStride = tex->pot_width * 3;
	int rowLength = tex->real_width * 3;
	unsigned char *imgPtr;
	unsigned char *dataPtr;
	int row;
	for (imgPtr=img->data, dataPtr=tex->data, row=0; row < tex->real_height; imgPtr+=rowLength, row++, dataPtr+=rowStride) {
		memcpy(dataPtr, imgPtr, rowLength);
	}
	return;
}
开发者ID:haimoz,项目名称:steveo,代码行数:30,代码来源:npot_tex.c

示例2: checkIfTriplet

int checkIfTriplet(int a, int b, int c){
  if(a < b && b < c){
    if( pot(c) == (pot(a) + pot(b) )){
      return 1;
    }
  }
  return 0;
}
开发者ID:RockNCode,项目名称:EulerProblems,代码行数:8,代码来源:problem9euler.c

示例3: d3d_upload_bitmap

static bool d3d_upload_bitmap(ALLEGRO_BITMAP *bitmap)
{
   ALLEGRO_BITMAP_D3D *d3d_bmp = (ALLEGRO_BITMAP_D3D *)bitmap;
   int w = bitmap->w;
   int h = bitmap->h;

   if (d3d_bmp->display->device_lost)
      return false;

   if (d3d_bmp->initialized != true) {
      bool non_pow2 = al_have_d3d_non_pow2_texture_support();
      bool non_square = al_have_d3d_non_square_texture_support();

      if (non_pow2 && non_square) {
         // Any shape and size
         d3d_bmp->texture_w = w;
	 d3d_bmp->texture_h = h;
      }
      else if (non_pow2) {
         // Must be sqaure
         int max = _ALLEGRO_MAX(w,  h);
         d3d_bmp->texture_w = max;
         d3d_bmp->texture_h = max;
      }
      else {
         // Must be POW2
         d3d_bmp->texture_w = pot(w);
         d3d_bmp->texture_h = pot(h);
      }

      // Some cards/drivers don't like small textures
      if (d3d_bmp->texture_w < 16) d3d_bmp->texture_w = 16;
      if (d3d_bmp->texture_h < 16) d3d_bmp->texture_h = 16;

      if (d3d_bmp->video_texture == 0)
         if (!d3d_create_textures(d3d_bmp->display, d3d_bmp->texture_w,
               d3d_bmp->texture_h,
               d3d_bmp->bitmap.flags,
               &d3d_bmp->video_texture,
               &d3d_bmp->system_texture,
               bitmap->format)) {
            return false;
         }

      /*
       * Keep track of created bitmaps, in case the display is lost
       * or resized.
       */
      *(ALLEGRO_BITMAP_D3D **)_al_vector_alloc_back(&created_bitmaps) = d3d_bmp;

      d3d_bmp->initialized = true;
   }

   d3d_do_upload(d3d_bmp, 0, 0, w, h, false);

   return true;
}
开发者ID:dradtke,项目名称:battlechess,代码行数:57,代码来源:d3d_bmp.cpp

示例4: main

/* testa funcao pot */
main() {
	
	int i;

	for (int i = 0; i < 10; ++i) {
		printf("%d %d %d\n", i, pot(2,i), pot(-3, i) );
	}	
	return 0;
}
开发者ID:kubota,项目名称:CRepo,代码行数:10,代码来源:pot.c

示例5: generate

void generate(PARAMS *p,SSDATA *d)
{
	double GPE,KE,f;
	int i,j;

	for (i=0;i<p->N;i++) {
		gen_body(p,&d[i],i);
		for (j=0;j<i;j++)
			if (OVERLAP(d[i].pos,d[i].radius,d[j].pos,d[j].radius)) {
				(void) printf("Particle %i overlaps particle %i\n"
							  "-- regenerating particle %i\n",i,j,i);
				--i;
				break;
				}
		}

	GPE = KE = 0.0;
	for (i=0;i<p->N;i++) {
		GPE += d[i].mass*pot(p,d,i);
		KE += 0.5*d[i].mass*MAG_SQ(d[i].vel);
		}

	(void) printf("Starting KE = %g = %g times GPE\n",KE,KE/GPE);

	assert(KE > 0.0);

	f = -0.5*p->KEf*GPE/KE;

	assert(f >= 0.0);

	for (i=0;i<p->N;i++)
		reset_vel(p,f,&d[i]);

	GPE = KE = 0.0;
	for (i=0;i<p->N;i++) {
		GPE += d[i].mass*pot(p,d,i);
		KE += 0.5*d[i].mass*MAG_SQ(d[i].vel);
		}

	(void) printf("Adjusted KE = %g = %g times GPE (= %g times virial)\n",KE,KE/GPE,-2*KE/GPE);

	{
	double t_dyn,t_step;

	t_dyn = 2*sqrt(CUBE(p->Rd)/(p->N*p->m));
	(void) printf("Dynamical time ~ %g\n",t_dyn);
	t_step = 2*sqrt(CUBE(p->R)/p->m)/33;
	(void) printf("Recommended time step < %g\n",t_step);
	(void) printf("Estimated number of steps needed per t_dyn = %i\n",(int) (t_dyn/t_step + 0.5));
	}
	}
开发者ID:srs51,项目名称:SRS-3000,代码行数:51,代码来源:ranics.c

示例6: Mod

/* function to calculate the potency (a^n % q) */
Mod Mod::pot(unsigned int n){
	if(n == 0){
		return Mod(1);
	}else{
		if(n == 1){
			return Mod(get_a());
		}
		if(n % 2 == 0){
			return pot(n/2) * pot(n/2);
		}
		if(n % 2 == 1){
			return pot(n-1) * Mod(get_a());
		}
	}
}
开发者ID:D4ryus,项目名称:studium,代码行数:16,代码来源:mod.cpp

示例7: pot

ComplexType ExternalPotential::operator()(PosType r){
    ComplexType pot(0,0);
    for (int i=0;i<_pset.n;i++){
        pot -= _pset.ptcls[i]->q/( (r-_pset.ptcls[i]->r).norm() );
    }
    return pot;
}
开发者ID:yidapa,项目名称:cppDFT,代码行数:7,代码来源:ExternalPotential.cpp

示例8: main

int main()
{
	int N, C, testes, i, j;
	int INV, A;
	scanf("%d", &testes);
	fat[0] = 0;
	fat[1] = 1;
	for(i=2; i<2000001; i++)
	{
		fat[i] = ((long long)fat[i-1]*i)%MOD;
		if(i < 1000001)
			inv[i] = pot(fat[i], MOD-2);
	}
	for(i=0;i<testes;i++)
	{
		scanf("%d %d", &N, &C);
		INV = 1;
		if (C+N > MOD) 
		{
			printf("0\n");
		} 
		else
		{
			INV = ((long long)inv[N-1]*inv[C])%MOD;
			A = ((long long)fat[N+C-1]*INV)%MOD;
			printf("%d\n", A);
		}
	}
	return 0;
}
开发者ID:Rasinhas,项目名称:Maratona,代码行数:30,代码来源:diofanto.c

示例9: appTaskMonitor

static void appTaskMonitor(void *pdata) {

	MMA7455 acc(P0_27, P0_28);
	AnalogIn pot(p15);
  LM75B lm75B(P0_27, P0_28, LM75B::ADDRESS_1);


	d->setCursor(2,2);
	if (!acc.setMode(MMA7455::ModeMeasurement)) {
    d->printf("Unable to set mode for MMA7455!\n");
  }
	else {
	  if (!acc.calibrate()) {
      d->printf("Failed to calibrate MMA7455!\n");
    }
		else {
	    d->printf("MMA7455 initialised\n");
		}
  }
  lm75B.open();
	
  while ( true ) {
		acc.read(nodeData.ax, nodeData.ay, nodeData.az);
		nodeData.pt = (int32_t)((1.0F - pot.read()) * 100);
    nodeData.js = 0;
		nodeData.tm = lm75B.temp();
    (void)OSSemPost(dataSem); 
    OSTimeDly(200);    
  }
}
开发者ID:DavidKendall,项目名称:iot,代码行数:30,代码来源:main.cpp

示例10: main

int main(int argc, char* argv[])
{
    CPointerPot pot(32000);
    int i, j, k;
    TPotItem itm;
    clock_t t1, t2;


    for (i = 0;  i < 164000;  i++) {
        itm = rand();
        pot.Add(itm);
    }

    t1= clock();
    pot.Sort(my_cmp);
    t2= clock();
    printf("done in %ld\n", (long)(t2 - t1));

    for (i=0;  i < 31900;  i+= 500) {
        for (j = i;  j < i+10;  j++) {
            k = (int) pot.get(j);
            printf("%d\t", k);
        }
        printf("\n");
    }
}
开发者ID:DmitrySigaev,项目名称:ncbi,代码行数:26,代码来源:pointer_pot.cpp

示例11: FAST_EXIT_ON_OPENPPL_SYMBOLS

bool CSymbolEngineChipAmounts::EvaluateSymbol(const char *name, double *result, bool log /* = false */) {
  FAST_EXIT_ON_OPENPPL_SYMBOLS(name);
	if (memcmp(name, "pot", 3)==0) {
		// CHIP AMOUNTS 1(2)
		if (memcmp(name, "pot", 3)==0 && strlen(name)==3)	{
			*result = pot();
		}	else if (memcmp(name, "potcommon", 9)==0 && strlen(name)==9) {
			*result = potcommon();
		}	else if (memcmp(name, "potplayer", 9)==0 && strlen(name)==9) {
			*result = potplayer();
		}	else {
			// Invalid symbol
			return false;
		}
		// Valid symbol
		return true;
	}	else if (memcmp(name, "balance", 7)==0)	{
		if (memcmp(name, "balance", 7)==0 && strlen(name)==7)	{
			*result = p_table_state->User()->_balance; 
		}	else if (memcmp(name, "balance", 7)==0 && strlen(name)==8) {
			*result = p_table_state->_players[name[7]-'0']._balance;
		}	else if (memcmp(name, "balanceatstartofsession", 23)==0 && strlen(name)==23) {
			*result = balanceatstartofsession();
		} else if (memcmp(name, "balance_rank", 12)==0 && strlen(name)==13) {
      *result = SortedBalance(name[12]-'0');
    }	else {
			// Invalid symbol
			return false;
		}
		// Valid symbol
		return true;
	}
	if (memcmp(name, "maxbalance", 10)==0 && strlen(name)==10) {
		*result = maxbalance();
	}	else if (memcmp(name, "stack", 5)==0 && strlen(name)==6) {
		*result = stack(name[5]-'0');
	}	else if (memcmp(name, "currentbet", 10)==0 && strlen(name)==10)	{
		*result = currentbet(p_symbol_engine_userchair->userchair());
	}	else if (memcmp(name, "currentbet", 10)==0 && strlen(name)==11)	{
		*result = currentbet(name[10]-'0');
	}	else if (memcmp(name, "call", 4)==0 && strlen(name)==4)	{
		*result = call();
	}	else if (memcmp(name, "nbetstocall", 11)==0 && strlen(name)==11) {
		*result = nbetstocall();
	}	else if (memcmp(name, "nbetstorais", 11)==0 && strlen(name)==11) {
		*result = nbetstorais();
	}	else if (memcmp(name, "ncurrentbets", 12)==0 && strlen(name)==12)	{
		*result = ncurrentbets();
	}	else if (memcmp(name, "ncallbets", 9)==0 && strlen(name)==9) {
		*result = ncallbets();
	}	else if (memcmp(name, "nraisbets", 9)==0 && strlen(name)==9) {
		*result = nraisbets();
	}	else {
		// Symbol of a different symbol-engine
		return false;
	}
	// Valid symbol
	return true;
}
开发者ID:awptimus,项目名称:openholdembot,代码行数:59,代码来源:CSymbolEngineChipAmounts.cpp

示例12: add_item

void inventory::form_from_map(game *g, point origin, int range)
{
 items.clear();
 for (int x = origin.x - range; x <= origin.x + range; x++) {
  for (int y = origin.y - range; y <= origin.y + range; y++) {
   if (g->m.has_flag(sealed, x, y))
     continue;
   for (int i = 0; i < g->m.i_at(x, y).size(); i++)
    if (!g->m.i_at(x, y)[i].made_of(LIQUID))
     add_item(g->m.i_at(x, y)[i]);
// Kludges for now!
   ter_id terrain_id = g->m.ter(x, y);
   furn_id furniture_id = g->m.furn(x, y);
   if ((g->m.field_at(x, y).findField(fd_fire)) || (terrain_id == t_lava)) {
    item fire(g->itypes["fire"], 0);
    fire.charges = 1;
    add_item(fire);
   }
   if (terrain_id == t_water_sh || terrain_id == t_water_dp){
    item water(g->itypes["water"], 0);
    water.charges = 50;
    add_item(water);
   }

   int vpart = -1;
   vehicle *veh = g->m.veh_at(x, y, vpart);

   if (veh) {
     const int kpart = veh->part_with_feature(vpart, vpf_kitchen);
     const int weldpart = veh->part_with_feature(vpart, vpf_weldrig);

     if (kpart >= 0) {
       item hotplate(g->itypes["hotplate"], 0);
       hotplate.charges = veh->fuel_left("battery", true);
       add_item(hotplate);

       item water(g->itypes["water_clean"], 0);
       water.charges = veh->fuel_left("water");
       add_item(water);

       item pot(g->itypes["pot"], 0);
       add_item(pot);
       item pan(g->itypes["pan"], 0);
       add_item(pan);
       }
     if (weldpart >= 0) {
       item welder(g->itypes["welder"], 0);
       welder.charges = veh->fuel_left("battery", true);
       add_item(welder);

       item soldering_iron(g->itypes["soldering_iron"], 0);
       soldering_iron.charges = veh->fuel_left("battery", true);
       add_item(soldering_iron);
       }
     }
   }

  }
 }
开发者ID:Anderviel,项目名称:Cataclysm-DDA,代码行数:59,代码来源:inventory.cpp

示例13: main

main(){
   int ncases, cases, a, b;
   for( scanf("%d", &ncases), cases = 1; cases <= ncases ; cases++){
      scanf("%d %d", &a, &b);
      printf("%lld\n", pot(((long long)a)%MOD, (long long)b));
   }
   return 0;    
}
开发者ID:cbedoy,项目名称:CojsSolutions,代码行数:8,代码来源:440685.c

示例14: pot

int pot(int m, int n)
{
	if (n == 1) {
		return m;
	}

	return m * pot(m, n - 1);
}
开发者ID:Linguagem-I,项目名称:Lista02-Final,代码行数:8,代码来源:11.c

示例15: testPotentialFunction

 int testPotentialFunction()
 {
     StandardValuePotentialFunction pot(5.0);
     CHECK_EQ(pot.ratePosition(0.0, 0.0), 5.0);
     CHECK_EQ(pot.ratePosition(GPSPosition(5.0, 6.0)), 5.0);
     CHECK_EQ(pot.ratePosition(5.0, 6.0), pot.ratePosition(GPSPosition(5.0, 6.0)));
     
     return EXIT_SUCCESS;
 }
开发者ID:lenalebt,项目名称:studienprojekt-routing,代码行数:9,代码来源:potentialfunction.cpp


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