本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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));
}
}
示例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;
}
示例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;
}
示例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;
}
示例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)));
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}