int Shots(Ship shp,Amount shts) /*****************************************************************************/ /* Calculate the number of shots that a ship has */ { float ratio,tmpshts; int weight; TRLIB(printf("librfs:Shots(shp:%d,shts:%d)\n",shp,shts)); if(turn<gamedet.earth.amnesty && IsEarth(fleet[shp].planet)) { TRLIB(printf("librfs:Zero shots due to Earth amnesty\n")); return(0); } weight=CalcWeight(shp); ratio=(float)shts/(float)weight; TRLIB(printf("librfs:Ship ratio:%f\n",ratio)); if(ratio>=10) { tmpshts=3*shts; TRLIB(printf("librfs:Class three ratio:%f\n",tmpshts)); return((int)tmpshts); } if(ratio<1) { tmpshts=((float)ratio*(float)shts); TRLIB(printf("librfs:Class one ratio:%f\n",tmpshts)); return((int)tmpshts); } tmpshts=(0.222*(float)(ratio)+0.777)*(float)shts; TRLIB(printf("librfs:Class two ratio:%f\n",tmpshts)); return((int)tmpshts); }
void QuantizeLSF( FLOAT fLsf[], FLOAT fQLsf[] ) { INT32 j; FLOAT fDist1; FLOAT fDist2; FLOAT fRes[LPCORDER]; FLOAT fLsfQTemp1[LPCORDER]; FLOAT fLsfQTemp2[LPCORDER]; FLOAT fQuantBuff1[LPCORDER]; FLOAT fQuantBuff2[LPCORDER]; FLOAT fWeight[LPCORDER]; CalcWeight( fLsf, fWeight ); MAPredictor(fLsf, cfPredictor1, fpPredHistory, fRes); VQQuant(fRes,fWeight,fQuantBuff1); InvMAPredictor(fQuantBuff1, cfPredictor1, fpPredHistory, fLsfQTemp1); fDist1=GetDistortion(fLsf,fLsfQTemp1,fWeight,LPCORDER); MAPredictor(fLsf, cfPredictor2, fpPredHistory, fRes); VQQuant(fRes,fWeight,fQuantBuff2); InvMAPredictor(fQuantBuff2, cfPredictor2, fpPredHistory, fLsfQTemp2); fDist2=GetDistortion(fLsf,fLsfQTemp2,fWeight,LPCORDER); if(fDist1>fDist2) { for( j = 0 ; j < LPCORDER ; j++ ) { fQLsf[j]=fLsfQTemp2[j]; } UpdateHistory(fQuantBuff2); } else { for( j = 0 ; j < LPCORDER ; j++ ) { fQLsf[j]=fLsfQTemp1[j]; } UpdateHistory(fQuantBuff1); } return; }
void VoiceInitToken() { // 读取百度语音授权码 int fd, size; fd = open( TOKENDIR, O_RDONLY ); size = read(fd, token, sizeof(token)); token[size-1] = 0; close(fd); // 读取标准语音码 FILE *filed = fopen( STANDDIR, "rb" ); fread( buf, BUFSIZE, 1, filed ); fclose( filed ); CalcWeight( buf, stand ); }
int CompareStand( signed char *buffer ) { int cycle = CalcWeight( buffer, compare ); float result = 0; for( int k=0; k<SPAN; k++ ) { if( (stand[k] + compare[k]) != 0 ) result += 1.0 * abs( stand[k] - compare[k] ) / (stand[k] + compare[k]); // result += 1.0 * abs( stand[k] - compare[k] ); // if( stand[k] != 0 ) result += 1.0 * abs( stand[k] - compare[k] ) / stand[k]; // printf( "%6.3f", 1.0 * abs( stand[k] - compare[k] ) / stand[k] ); } printf( "\n compare: %f\n", result ); if( result > 40 || cycle < 2 ) return 0; else return 1; return 0; }
void CircleTerrainBrush::Apply(TerrainUtility* m,const math::vector3d& pos,float strength,ETerrainModificationMode mode) { math::vector3d*vtx= m->LockVerticies(); //compute min and max bounding box of the brush in XZ plane math::vector3d minP=pos-m_outerRadius; math::vector3d maxP=pos+m_outerRadius; int segments=m->GetTerrain()->GetSegementsCount(); //convert it to terrain space minP=m->GetTerrain()->TransformVectorToLocal(minP); maxP=m->GetTerrain()->TransformVectorToLocal(maxP); minP.x=math::Max(0,(int)minP.x); minP.z=math::Max(0,(int)minP.z); maxP.x=math::Min(segments-1,(int)maxP.x); maxP.z=math::Min(segments-1,(int)maxP.z); float weight; //math::vector3d tPos=m->GetTerrain()->TransformVector(pos); math::vector3d tPos(pos); tPos.y=0; for(int i=minP.x;i<maxP.x;++i) { for(int j=minP.z;j<maxP.z;++j) { int idx=i*segments+j; math::vector3d vPos=vtx[idx]; vPos.y=0; weight=CalcWeight(tPos,vPos); if(weight>0){ vtx[idx].y=ApplyAtVertex(vtx[idx].y,strength*weight,mode); m->GetTerrain()->OnHeightChanged(idx,vtx[idx].y); } } } m->Unlock(); }
bool C_PATCH_INCL_EXCL_MGR::PatchRequired( LPCSTR inLoadedModuleName, LPCSTR inImpModuleName, LPCSTR inFnName, bool inOrdinalExport, IHI_RETURN_DATA *oRetVal) /*++ Routine Description: This routine checks if a function should be patched or not, based on the exclusion/inclusion list. Arguments: inLoadedModuleName - The module which is calling the function inImpModuleName - The module which implements the function inFnName - Name of the function (for functions exported by ordinal this name is Ord%x) inOrdinalExport - Was the function exported by ordinal oRetVal - Return value information if a different return value is specified by the user Return: true - Patching required false - Don't patch --*/ { // // Hardcoded exclusion for the problem causing modules // // // Certain DLLs like MSVCRT and NTDLL causes recursive hooking hence functions // imported from these DLLs are always excluded even if a user wants to hook // if (_strnicmp("MSVC", inImpModuleName, 4) == 0 || _strnicmp("NTDLL", inImpModuleName, 5) == 0) { return false; } // // Ordinal exports from MFC are also always excluded because MFC DLLs export // variables by name too. If we hook an import variable, we eventually end up // supplying a totally wrong data structure to the calling application. This // was causing crash in wordpad // if (_strnicmp("MFC", inImpModuleName, 3) == 0 && inOrdinalExport) { return false; } bool funcResult = false; int inclWeight = 0; int exclWeight = 0; inclWeight = CalcWeight( inLoadedModuleName, inImpModuleName, inFnName, oRetVal, m_IncludeList); exclWeight = CalcWeight( inLoadedModuleName, inImpModuleName, inFnName, NULL, m_ExcludeList); if (exclWeight > inclWeight) { funcResult = false; } else if (exclWeight < inclWeight) { funcResult = true; } else { // // At this point we should see whether included list has higher weight // for LoadedModule or excluded list. If loaded module weight is same // for both included and excluded then we should include the module // PIHI_MAP pImpModuleMap; int inclWt = 0; int exclWt = 0; if (ihiMapFind(m_IncludeList, inLoadedModuleName, (LPVOID**)&pImpModuleMap, false)) { inclWt = 2; } if (ihiMapFind(m_ExcludeList, inLoadedModuleName, (LPVOID**)&pImpModuleMap, false)) { exclWt = 2; } if (inclWt >= exclWt) { funcResult = true; } else { funcResult = false; } } return funcResult; }
void HWwNjetStudy::Loop() { gBenchmark->Start("HWwNjetStudy"); if (fChain == 0) return; int Ntries = fChain->GetEntries(); cout<<"Total: "<<Ntries<<endl; Fout<<"Total: "<<Ntries<<endl; cout<<"LumiW: "<<LumiW<<endl; Fout<<"LumiW: "<<LumiW<<endl; for (int i(0); i<Ntries;i++) { InitVar4Evt(); evtCnt++; fChain->GetEntry(i); if(SampleName == "POWHEG" || SampleName == "POWHEG_VBF") mWW = MHiggs; if(SampleName == "SHERPA") mWW = CalcmWW(); if(mWW <= 130.) continue; EvtWeight = CalcWeight(); if(SampleName == "POWHEG") { //Step1 reweighting Powheg to gg2VV if(mWW > 130 && mWW <= 140) EvtWeight *=0; if(mWW > 140 && mWW <= 150) EvtWeight *=51.1303; if(mWW > 150 && mWW <= 160) EvtWeight *=0.0478779; if(mWW > 160 && mWW <= 170) EvtWeight *=0.122384; if(mWW > 170 && mWW <= 180) EvtWeight *=0.148526; if(mWW > 180 && mWW <= 190) EvtWeight *=0.189493; if(mWW > 190 && mWW <= 200) EvtWeight *=0.23596; if(mWW > 200 && mWW <= 210) EvtWeight *=0.48091; if(mWW > 210 && mWW <= 220) EvtWeight *=19.4147; if(mWW > 220 && mWW <= 230) EvtWeight *=22.3205; if(mWW > 230 && mWW <= 240) EvtWeight *=7.22016; if(mWW > 240 && mWW <= 250) EvtWeight *=0.62342; if(mWW > 250 && mWW <= 260) EvtWeight *=0.613474; if(mWW > 260 && mWW <= 270) EvtWeight *=5.97016; if(mWW > 270 && mWW <= 280) EvtWeight *=7.93497; if(mWW > 280 && mWW <= 290) EvtWeight *=4.19944; if(mWW > 290 && mWW <= 300) EvtWeight *=0.769442; if(mWW > 300 && mWW <= 310) EvtWeight *=0.757447; if(mWW > 310 && mWW <= 320) EvtWeight *=5.3415; if(mWW > 320 && mWW <= 330) EvtWeight *=10.2543; if(mWW > 330 && mWW <= 340) EvtWeight *=15.1817; if(mWW > 340 && mWW <= 350) EvtWeight *=15.8538; if(mWW > 350 && mWW <= 360) EvtWeight *=16.8142; if(mWW > 360 && mWW <= 370) EvtWeight *=12.5228; if(mWW > 370 && mWW <= 380) EvtWeight *=7.53283; if(mWW > 380 && mWW <= 390) EvtWeight *=4.15059; if(mWW > 390 && mWW <= 400) EvtWeight *=2.46605; if(mWW > 400 && mWW <= 410) EvtWeight *=2.79782; if(mWW > 410 && mWW <= 420) EvtWeight *=4.55461; if(mWW > 420 && mWW <= 430) EvtWeight *=6.92859; if(mWW > 430 && mWW <= 440) EvtWeight *=10.0075; if(mWW > 440 && mWW <= 450) EvtWeight *=10.9316; if(mWW > 450 && mWW <= 460) EvtWeight *=10.983; if(mWW > 460 && mWW <= 470) EvtWeight *=10.5683; if(mWW > 470 && mWW <= 480) EvtWeight *=7.84492; if(mWW > 480 && mWW <= 490) EvtWeight *=6.04171; if(mWW > 490 && mWW <= 500) EvtWeight *=6.34104; if(mWW > 500 && mWW <= 510) EvtWeight *=5.87117; if(mWW > 510 && mWW <= 520) EvtWeight *=7.04725; if(mWW > 520 && mWW <= 530) EvtWeight *=8.05815; if(mWW > 530 && mWW <= 540) EvtWeight *=9.74238; if(mWW > 540 && mWW <= 550) EvtWeight *=10.8453; if(mWW > 550 && mWW <= 560) EvtWeight *=9.67099; if(mWW > 560 && mWW <= 570) EvtWeight *=10.8926; if(mWW > 570 && mWW <= 580) EvtWeight *=10.4321; if(mWW > 580 && mWW <= 590) EvtWeight *=10.7205; if(mWW > 590 && mWW <= 600) EvtWeight *=10.8797; if(mWW > 600 && mWW <= 610) EvtWeight *=11.4627; if(mWW > 610 && mWW <= 620) EvtWeight *=10.0712; if(mWW > 620 && mWW <= 630) EvtWeight *=10.759; if(mWW > 630 && mWW <= 640) EvtWeight *=12.9894; if(mWW > 640 && mWW <= 650) EvtWeight *=15.5317; if(mWW > 650 && mWW <= 660) EvtWeight *=20.0885; if(mWW > 660 && mWW <= 670) EvtWeight *=18.7505; if(mWW > 670 && mWW <= 680) EvtWeight *=19.5823; if(mWW > 680 && mWW <= 690) EvtWeight *=18.7507; if(mWW > 690 && mWW <= 700) EvtWeight *=24.2711; if(mWW > 700 && mWW <= 710) EvtWeight *=27.1249; if(mWW > 710 && mWW <= 720) EvtWeight *=26.0178; if(mWW > 720 && mWW <= 730) EvtWeight *=30.3208; if(mWW > 730 && mWW <= 740) EvtWeight *=42.7271; if(mWW > 740 && mWW <= 750) EvtWeight *=28.9253; if(mWW > 750 && mWW <= 760) EvtWeight *=31.6985; if(mWW > 760 && mWW <= 770) EvtWeight *=43.9006; if(mWW > 770 && mWW <= 780) EvtWeight *=43.8016; if(mWW > 780 && mWW <= 790) EvtWeight *=32.9426; if(mWW > 790 && mWW <= 800) EvtWeight *=60.615; if(mWW > 800 && mWW <= 810) EvtWeight *=32.0942; if(mWW > 810 && mWW <= 820) EvtWeight *=28.3471; if(mWW > 820 && mWW <= 830) EvtWeight *=44.8383; if(mWW > 830 && mWW <= 840) EvtWeight *=31.2978; if(mWW > 840 && mWW <= 850) EvtWeight *=41.6292; if(mWW > 850 && mWW <= 860) EvtWeight *=55.7313; if(mWW > 860 && mWW <= 870) EvtWeight *=37.3944; if(mWW > 870 && mWW <= 880) EvtWeight *=45.1447; if(mWW > 880 && mWW <= 890) EvtWeight *=45.2296; if(mWW > 890 && mWW <= 900) EvtWeight *=55.7684; if(mWW > 900 && mWW <= 910) EvtWeight *=62.7376; if(mWW > 910 && mWW <= 920) EvtWeight *=55.7921; if(mWW > 920 && mWW <= 930) EvtWeight *=54.3934; if(mWW > 930 && mWW <= 940) EvtWeight *=102.145; if(mWW > 940 && mWW <= 950) EvtWeight *=37.2144; if(mWW > 950 && mWW <= 960) EvtWeight *=50.58; if(mWW > 960 && mWW <= 970) EvtWeight *=44.3337; if(mWW > 970 && mWW <= 980) EvtWeight *=60.3516; if(mWW > 980 && mWW <= 990) EvtWeight *=74.0306; if(mWW > 990 && mWW <= 1000) EvtWeight *=67.2666; if(mWW > 1000 && mWW <= 1010) EvtWeight *=19.5773; if(mWW > 1010 && mWW <= 1020) EvtWeight *=66.0482; if(mWW > 1020 && mWW <= 1030) EvtWeight *=73.4724; if(mWW > 1030 && mWW <= 1040) EvtWeight *=44.6105; if(mWW > 1040 && mWW <= 1050) EvtWeight *=95.411; if(mWW > 1050 && mWW <= 1060) EvtWeight *=81.114; if(mWW > 1060 && mWW <= 1070) EvtWeight *=42.0407; if(mWW > 1070 && mWW <= 1080) EvtWeight *=116.167; if(mWW > 1080 && mWW <= 1090) EvtWeight *=118.585; if(mWW > 1090 && mWW <= 1100) EvtWeight *=50.1939; if(mWW > 1100 && mWW <= 1110) EvtWeight *=81.9378; if(mWW > 1110 && mWW <= 1120) EvtWeight *=50.4567; if(mWW > 1120 && mWW <= 1130) EvtWeight *=70.9683; if(mWW > 1130 && mWW <= 1140) EvtWeight *=18.4721; if(mWW > 1140 && mWW <= 1150) EvtWeight *=53.0915; if(mWW > 1150 && mWW <= 1160) EvtWeight *=47.0092; if(mWW > 1160 && mWW <= 1170) EvtWeight *=42.3676; if(mWW > 1170 && mWW <= 1180) EvtWeight *=53.8578; if(mWW > 1180 && mWW <= 1190) EvtWeight *=142.918; if(mWW > 1190 && mWW <= 1200) EvtWeight *=43.5121; if(mWW > 1200 && mWW <= 1210) EvtWeight *=64.1233; if(mWW > 1210 && mWW <= 1220) EvtWeight *=18.6497; if(mWW > 1220 && mWW <= 1230) EvtWeight *=148.524; if(mWW > 1230 && mWW <= 1240) EvtWeight *=53.3047; if(mWW > 1240 && mWW <= 1250) EvtWeight *=174.73; if(mWW > 1250 && mWW <= 1260) EvtWeight *=82.8151; if(mWW > 1260 && mWW <= 1270) EvtWeight *=76.0686; if(mWW > 1270 && mWW <= 1280) EvtWeight *=224.172; if(mWW > 1280 && mWW <= 1290) EvtWeight *=95.0422; if(mWW > 1290 && mWW <= 1300) EvtWeight *=140.862; if(mWW > 1300 && mWW <= 1310) EvtWeight *=332.692; if(mWW > 1310 && mWW <= 1320) EvtWeight *=122.033; if(mWW > 1320 && mWW <= 1330) EvtWeight *=300.629; if(mWW > 1330 && mWW <= 1340) EvtWeight *=84.3002; if(mWW > 1340 && mWW <= 1350) EvtWeight *=0; if(mWW > 1350 && mWW <= 1360) EvtWeight *=0; if(mWW > 1360 && mWW <= 1370) EvtWeight *=303.616; if(mWW > 1370 && mWW <= 1380) EvtWeight *=88.6832; if(mWW > 1380 && mWW <= 1390) EvtWeight *=47.9035; if(mWW > 1390 && mWW <= 1400) EvtWeight *=3160.08; if(mWW > 1400 && mWW <= 1410) EvtWeight *=0; if(mWW > 1410 && mWW <= 1420) EvtWeight *=0; if(mWW > 1420 && mWW <= 1430) EvtWeight *=259.887; if(mWW > 1430 && mWW <= 1440) EvtWeight *=147.746; if(mWW > 1440 && mWW <= 1450) EvtWeight *=0; if(mWW > 1450 && mWW <= 1460) EvtWeight *=0; if(mWW > 1460 && mWW <= 1470) EvtWeight *=0; if(mWW > 1470 && mWW <= 1480) EvtWeight *=134.284; if(mWW > 1480 && mWW <= 1490) EvtWeight *=0; if(mWW >= 1490) EvtWeight *=0; } if(SampleName == "POWHEG_VBF") { if(mWW <= 130) EvtWeight *=0; if(mWW > 130 && mWW <= 200) EvtWeight *=0.153388; if(mWW > 200 && mWW <= 300) EvtWeight *=1.78492; if(mWW > 300 && mWW <= 400) EvtWeight *=2.15192; if(mWW > 400 && mWW <= 500) EvtWeight *=3.29945; if(mWW > 500 && mWW <= 600) EvtWeight *=5.25967; if(mWW > 600 && mWW <= 700) EvtWeight *=10.6058; if(mWW > 700 && mWW <= 800) EvtWeight *=18.1124; if(mWW > 800 && mWW <= 900) EvtWeight *=22.0678; if(mWW > 900 && mWW <= 1000) EvtWeight *=36.0357; if(mWW > 1000 && mWW <= 1250) EvtWeight *=77.5059; if(mWW > 1250 && mWW <= 1500) EvtWeight *=234.308; } if( Cut == "CommonCut_njet")if(CommonCut_njet() !=1)continue; if( Cut == "CommonCut_VBFnjet")if(CommonCut_VBFnjet() !=1)continue; if( Cut == "CommonCut_njet") Fill_Histo(); if( Cut == "CommonCut_VBFnjet") Fill_vbfHisto(); } // Usie one of the Write_Histo ro myFile->Write // Write_Histo: to write specific ones // myFile->Write ==> All //Write_Histo(); myFile->Write(); myFile->Close(); Fout.close(); gBenchmark->Show("HWwNjetStudy"); }