blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
73195176f7fb275194b8f9e66033132175b2af7b
9861baf0aff68fc9c4e13479b9accbb93dcb5428
/src/effects/videoStreamEffect.h
d3ddd4ae8b58a743423207abdf4773fc0435f5a0
[]
no_license
Daandelange/karmaMapper
9b36c0bd7244e6f1cb2feee07968eb11feff0d23
274b694f61d1a09e2e58c219d4232344ffceb49e
refs/heads/master
2022-12-27T11:36:29.204878
2020-10-10T11:51:19
2020-10-10T11:51:19
18,294,275
1
1
null
null
null
null
UTF-8
C++
false
false
648
h
// // videoStreamEffect.h // karmaMapper // // Created by Daan de Lange on 12/3/14. // // // tmp disabled #ifdef KM_PLEASESKIPME #pragma once #include "ofMain.h" #include "basicEffect.h" #include "ofxAbletonLiveSet.h" class videoStreamEffect : public basicEffect { public: videoStreamEffect(); ~videoStreamEffect(); virtual void spawn(); virtual bool render(); virtual void update(); virtual void reset(); bool grabShape(); bool grabStream(); void noteEventListener(ofx::AbletonLiveSet::LSNoteEvent & noteEvent); protected: ofVideoGrabber grabber; int currentStream = -1; private: }; // END KM_PLEASESKIPME #endif
[ "idaany@gmail.com" ]
idaany@gmail.com
dd913316575136a20d668a9992aa1ecaad053bb4
4b5a6c207886eb664889b8d28bef8724dd26fa63
/ROOT/bin/OSLSMTMethodAllElectrons.cc
d462407fe95845b1a5e9da063117f9bff86e2c1b
[]
no_license
iross/UWAnalysis
2b5d2ada9cfdc28e2c00f97a04767b4e283a04f1
5b3d21ddf2cb8557fd87b7e4f449496fb1f41479
refs/heads/master
2021-01-23T07:15:38.950859
2013-07-24T20:55:03
2013-07-24T20:55:03
4,274,658
1
0
null
2013-03-01T19:46:28
2012-05-09T17:51:09
Python
UTF-8
C++
false
false
18,001
cc
#include "RooRealVar.h" #include "RooGaussian.h" #include "RooBifurGauss.h" #include "RooExponential.h" #include "RooAddPdf.h" #include "RooHistPdf.h" #include "RooDataSet.h" #include "RooDataHist.h" #include "RooGlobalFunc.h" #include "RooChi2Var.h" #include "RooRealVar.h" #include "RooLandau.h" #include "RooGaussian.h" #include "RooCBShape.h" #include "RooNumConvPdf.h" #include "RooMinuit.h" #include "RooFitResult.h" #include "RooPlot.h" #include "TCanvas.h" #include "TROOT.h" #include "TFile.h" #include "TTree.h" #include "TChain.h" #include "TH1.h" #include "TF1.h" #include "PhysicsTools/FWLite/interface/CommandLineParser.h" struct BkgOutput { float WEN; float WENErr; float TOP; float TOPErr; float WTN; float WTNErr; float QCD; float QCDErr; float ZEFT; float ZEFTErr; float ZJFT; float ZJFTErr; float VV; float VVErr; }; BkgOutput extractSignal(float osHigh,float osLow,float sHigh,float ssLow,float zeft,float zjft,float ttbarHigh,float ttbarLow,float vvHigh,float vvLow,optutl::CommandLineParser parser); float poissonFluctuation(Long_t N); //float getFluctuatedEvents(TTree*,std:string selection); int main (int argc, char* argv[]) { gROOT->SetBatch(kTRUE); gROOT->SetStyle("Plain"); optutl::CommandLineParser parser ("Background subtrcation "); //Input Files------------------- //Data parser.addOption("dataFile",optutl::CommandLineParser::kString,"File with the data","DATA.root"); // parser.addOption("preselection",optutl::CommandLineParser::kString,"lepton veto cuts ","HLT_Any&&abs(eleTauEta1)<2.1&&eleTauPt1>15&&eleTauPt2>20&&eleTauMissHits==0&&eleTauChargeIso==0&&eleTauGammaIso==0&&eleTauNeutralIso==0&&(abs(eleTauEta2)>1.566||abs(eleTauEta2)<1.4442)&&!(abs(eleTauConvDist)<0.1&&abs(eleTauDCotTheta)<0.05)"); // parser.addOption("preselection",optutl::CommandLineParser::kString,"lepton veto cuts ","HLT_Any&&abs(eleTauEta1)<2.1&&eleTauPt1>15&&eleTauPt2>20&&eleTauMissHits==0&&((eleTauRelIso04B<0.07&&abs(eleTauEta1)<1.44)||(eleTauRelIso04E<0.06&&abs(eleTauEta1)>1.44))&&(abs(eleTauEta2)>1.566||abs(eleTauEta2)<1.4442)&&!(abs(eleTauConvDist)<0.1&&abs(eleTauDCotTheta)<0.05)"); parser.addOption("preselection",optutl::CommandLineParser::kString,"lepton veto cuts ","HLT_Any&&eleTauPt1>15&&eleTauPt2>20&&abs(eleTauEleIP)<0.02&&((abs(eleTauEta1)<1.4442&&eleTauPFRelIso<0.08)||(abs(eleTauEta1)>1.566&&eleTauPFRelIso<0.04))&&eleTauMissHitsWW==0&&PVs>0&&(abs(eleTauEta2)>1.566||abs(eleTauEta2)<1.442)"); parser.addOption("oshighSelection",optutl::CommandLineParser::kString,"lepton veto cuts ","eleTauCharge==0&&eleTauMt1>60&&eleTauLeadCandMVA<-0.1&&dieleSize==0&&(!(eleTauProngs==1&&eleTauGammas>0&&eleTauBremEnergy/eleTauEmEnergy>0.99&&eleTauHadMass<0.55))&&(!(eleTauProngs==1&&eleTauGammas==0&&eleTauLeadTrackHOP<0.08))"); parser.addOption("oslowSelection",optutl::CommandLineParser::kString,"lepton veto cuts ","eleTauCharge==0&&eleTauMt1<40&&eleTauLeadCandMVA<-0.1&&dieleSize==0&&(!(eleTauProngs==1&&eleTauGammas>0&&eleTauBremEnergy/eleTauEmEnergy>0.99&&eleTauHadMass<0.55))&&(!(eleTauProngs==1&&eleTauGammas==0&&eleTauLeadTrackHOP<0.08))"); parser.addOption("sshighSelection",optutl::CommandLineParser::kString,"lepton veto cuts ","eleTauCharge!=0&&eleTauMt1>60&&eleTauLeadCandMVA<-0.1&&dieleSize==0&&(!(eleTauProngs==1&&eleTauGammas>0&&eleTauBremEnergy/eleTauEmEnergy>0.99&&eleTauHadMass<0.55))&&(!(eleTauProngs==1&&eleTauGammas==0&&eleTauLeadTrackHOP<0.08))"); parser.addOption("sslowSelection",optutl::CommandLineParser::kString,"lepton veto cuts ","eleTauCharge!=0&&eleTauMt1<40&&eleTauLeadCandMVA<-0.1&&(!(eleTauProngs==1&&eleTauGammas>0&&eleTauBremEnergy/eleTauEmEnergy>0.99&&eleTauHadMass<0.55))&&(!(eleTauProngs==1&&eleTauGammas==0&&eleTauLeadTrackHOP<0.08))"); parser.addOption("zeftSelection",optutl::CommandLineParser::kString,"lepton veto cuts ","eleTauCharge==0&&eleTauMt1<40&&dieleSize==1&&eleTauLeadCandMVA>-0.1&&(!(eleTauProngs==1&&eleTauGammas>0&&eleTauBremEnergy/eleTauEmEnergy>0.99&&eleTauHadMass>0.55))&&(!(eleTauProngs==1&&eleTauGammas==0&&eleTauLeadTrackHOP>0.08))"); parser.addOption("zjftSelection",optutl::CommandLineParser::kString,"lepton veto cuts ","eleTauCharge!=0&&eleTauMt1<40&&eleTauLeadCandMVA<-0.1&&dieleSize==1&&(!(eleTauProngs==1&&eleTauGammas>0&&eleTauBremEnergy/eleTauEmEnergy>0.99&&eleTauHadMass<0.55))&&(!(eleTauProngs==1&&eleTauGammas==0&&eleTauLeadTrackHOP<0.08))"); parser.addOption("qcdFactor",optutl::CommandLineParser::kDouble,"qcd OSLS Ratio",1.08); parser.addOption("qcdFactorErr",optutl::CommandLineParser::kDouble,"qcd OSLS Ratio Error",0.13); parser.addOption("wenFactor",optutl::CommandLineParser::kDouble,"WEN factor",0.28); parser.addOption("wenFactorErr",optutl::CommandLineParser::kDouble,"WEN Factor Error",0.0); parser.addOption("wtnFactor",optutl::CommandLineParser::kDouble,"WTN Factor",0.23); parser.addOption("wtnFactorErr",optutl::CommandLineParser::kDouble,"WTN Factor Error",0.0); parser.addOption("ttbarMCLow",optutl::CommandLineParser::kDouble,"TTBar From MC Low",2.6); parser.addOption("ttbarMCHigh",optutl::CommandLineParser::kDouble,"TTBar From MC High",7.4); parser.addOption("ttbarErr",optutl::CommandLineParser::kDouble,"TTBar Error(percent)",0.5); parser.addOption("vvMCLow",optutl::CommandLineParser::kDouble,"DiBoson From MC Low",0.8); parser.addOption("vvMCHigh",optutl::CommandLineParser::kDouble,"DiBoson From MC High",1.3); parser.addOption("vvErr",optutl::CommandLineParser::kDouble,"DiBoson Error(percent)",0.5); parser.addOption("zeftFactor",optutl::CommandLineParser::kDouble,"ZEEFactor1",0.017); parser.addOption("zeftFactorErr",optutl::CommandLineParser::kDouble,"ZEEFactor1",0.004); parser.addOption("zjftFactor",optutl::CommandLineParser::kDouble,"ZEEFactor2",2.5); parser.addOption("zjftFactorErr",optutl::CommandLineParser::kDouble,"ZEEFactor2",0.13); parser.addOption("energyScale",optutl::CommandLineParser::kDouble,"energy Scale",0.98); parser.addOption("energyScaleErr",optutl::CommandLineParser::kDouble,"energy scale error ",0.02); parser.addOption("experiments",optutl::CommandLineParser::kInteger,"experiments ",0); parser.addOption("treeName",optutl::CommandLineParser::kString,"tree Name","eleTauEventTree/eventTree"); parser.parseArguments (argc, argv); //translate the parser selections std::string preselection = parser.stringValue("preselection"); std::string oshighSelection = preselection+"&&"+parser.stringValue("oshighSelection"); std::string oslowSelection = preselection+"&&"+parser.stringValue("oslowSelection"); std::string sshighSelection = preselection+"&&"+parser.stringValue("sshighSelection"); std::string sslowSelection = preselection+"&&"+parser.stringValue("sslowSelection"); std::string zeftSelection = preselection+"&&"+parser.stringValue("zeftSelection"); std::string zjftSelection = preselection+"&&"+parser.stringValue("zjftSelection"); //std::string ttbarSelection = preselection+"&&"+parser.stringValue("ttbarSelection"); //Get file and tree TFile *f = new TFile(parser.stringValue("dataFile").c_str()); TTree *t =(TTree*) f->Get(parser.stringValue("treeName").c_str()); //calculate events in the regions float osHigh = t->GetEntries( oshighSelection.c_str()); float osLow = t->GetEntries( oslowSelection.c_str()); float ssHigh = t->GetEntries( sshighSelection.c_str()); float ssLow = t->GetEntries( sslowSelection.c_str()); float zeft = t->GetEntries( zeftSelection.c_str()); float zjft = t->GetEntries( zjftSelection.c_str()); //float ttbarHigh = t->GetEntries( (ttbarSelection+"&&"+oshighSelection).c_str()); //float ttbarLow = t->GetEntries( (ttbarSelection+"&&"+oslowSelection).c_str()); float ttbarHigh = parser.doubleValue("ttbarMCHigh"); float ttbarLow = parser.doubleValue("ttbarMCLow"); float vvHigh = parser.doubleValue("vvMCHigh"); float vvLow = parser.doubleValue("vvMCLow"); //create results tree TFile *fout = new TFile("results.root","RECREATE"); TTree *results = new TTree("results","Results tree"); float wenExpected=0; float wenExtracted=0; float wtnExpected=0; float wtnExtracted=0; float ttbarExpected=0; float ttbarExtracted=0; float qcdExpected=0; float qcdExtracted=0; float zeftExpected=0; float zeftExtracted=0; float zjftExpected=0; float zjftExtracted=0; results->Branch("wenExp",&wenExpected,"wenExp/F"); results->Branch("wenExt",&wenExtracted,"wenExt/F"); results->Branch("wenExp",&wtnExpected,"wtnExp/F"); results->Branch("wenExt",&wtnExtracted,"wtnExt/F"); results->Branch("ttbarExp",&ttbarExpected,"ttbarExp/F"); results->Branch("ttbarExt",&ttbarExtracted,"ttbarExt/F"); results->Branch("qcdExp",&qcdExpected,"qcdExp/F"); results->Branch("qcdExt",&qcdExtracted,"qcdExt/F"); results->Branch("zeftExp",&zeftExpected,"zeftExp/F"); results->Branch("zeftExt",&zeftExtracted,"zeftExt/F"); results->Branch("zjftExp",&zjftExpected,"zjftExp/F"); results->Branch("zjftExt",&zjftExtracted,"zjftExt/F"); // int nexperiments = parser.integerValue("experiments"); BkgOutput out = extractSignal( osHigh, osLow, ssHigh, ssLow, zeft, zjft, ttbarHigh, ttbarLow, vvHigh, vvLow,parser); fout->Close(); } BkgOutput extractSignal(float osHigh,float osLow,float ssHigh,float ssLow,float zeft,float zjft,float ttbarHigh,float ttbarLow,float vvHigh,float vvLow,optutl::CommandLineParser parser) { BkgOutput output; printf("total os high events = %f\n",osHigh); printf("total ss high events = %f\n",ssHigh); printf("total os low events = %f\n",osLow); printf("total ss low events = %f\n",ssLow); printf("VV from MC\n"); double VVLow = vvLow; double VVLowErr = vvLow*parser.doubleValue("vvErr"); printf("OS signal MT< = %f +- %f \n",VVLow, VVLowErr); output.VV = VVLow; output.VVErr = VVLowErr; double VVHigh = vvHigh; double VVHighErr = vvHigh*parser.doubleValue("vvErr"); printf("OS signal MT> = %f +- %f \n",VVHigh, VVHighErr); //extrapolate TTbar events in MT>40 // printf("Extrapolating TTbar background\n"); // printf("control region Mt > =%f\n",ttbarHigh); // printf("control region Mt < =%f\n",ttbarLow); //double topLow = ttbarLow*parser.doubleValue("ttbarFactor"); printf("TTbar from MC\n"); double topLow = ttbarLow; double topLowErr = ttbarLow*parser.doubleValue("ttbarErr"); printf("OS signal MT< = %f +- %f \n",topLow, topLowErr); output.TOP = topLow; output.TOPErr = topLowErr; double topHigh = ttbarHigh; double topHighErr = ttbarHigh*parser.doubleValue("ttbarErr"); printf("OS signal MT> = %f +- %f \n",topHigh, topHighErr); printf("Extrapolating Z , electron fakes tau background\n"); printf("control region = %f \n",zeft); double zeftLow = zeft*parser.doubleValue("zeftFactor"); double zeftLowErr = sqrt(zeft*parser.doubleValue("zeftFactor")*parser.doubleValue("zeftFactor")+ zeft*zeft*parser.doubleValue("zeftFactorErr")*parser.doubleValue("zeftFactorErr")); printf(" signal region %f*%f = %f +- %f \n",zeft,parser.doubleValue("zeftFactor"),zeftLow, zeftLowErr); output.ZEFT = zeftLow; output.ZEFTErr = zeftLowErr; printf("Extrapolating Z , jet fakes tau background\n"); printf("control region =%f\n",zjft); double zjftLow = zjft*parser.doubleValue("zjftFactor"); double zjftLowErr = sqrt(zjft*parser.doubleValue("zjftFactor")*parser.doubleValue("zjftFactor")+ zjft*zjft*parser.doubleValue("zjftFactorErr")*parser.doubleValue("zjftFactorErr")); printf(" signal region = %f +- %f \n",zjftLow, zjftLowErr); output.ZJFT = zjftLow; output.ZJFTErr = zjftLowErr; printf("1. Subtract TTbar and VV from sideband"); float osWHigh = osHigh-topHigh-VVHigh; float osWHighErr = sqrt(osWHigh+topHighErr*topHighErr+VVHighErr*VVHighErr); printf("OS W in sideband =%f -%f = %f +- %f \n",osHigh,topHigh,osWHigh,osWHighErr); printf("2. Extrapolate W in the low MT region\n"); float osWLow = osWHigh*parser.doubleValue("wenFactor"); float osWLowErr = sqrt(osWHigh*osWHigh*parser.doubleValue("wenFactorErr")*parser.doubleValue("wenFactorErr")+osWHighErr*osWHighErr*parser.doubleValue("wenFactor")*parser.doubleValue("wenFactor")); output.WEN = osWLow; output.WENErr = osWLowErr; printf("OS W e nu in core =%f *%f = %f +- %f \n",osWHigh,parser.doubleValue("wenFactor"),osWLow,osWLowErr); printf("3. Extrapolate W ->tau nu from W -> munu using MC \n"); float osWTLow = osWLow*parser.doubleValue("wtnFactor"); float osWTLowErr = sqrt(osWLowErr*osWLowErr*parser.doubleValue("wtnFactor")*parser.doubleValue("wtnFactor")+osWLow*osWLow*parser.doubleValue("wtnFactorErr")*parser.doubleValue("wtnFactorErr")); printf("OS W tau nu in core =%f *%f = %f +- %f \n",osWLow,parser.doubleValue("wtnFactor"),osWTLow,osWTLowErr); output.WTN = osWTLow; output.WTNErr = osWTLowErr; printf("4. Repeat for SS : first extrapolate W\n"); float ssWLow = ssHigh*parser.doubleValue("wenFactor"); float ssWLowErr = sqrt(ssHigh*ssHigh*parser.doubleValue("wenFactorErr")*parser.doubleValue("wenFactorErr")+ssHigh*parser.doubleValue("wenFactor")*parser.doubleValue("wenFactor")); printf("SS W e nu in core =%f *%f = %f +- %f \n",ssHigh,parser.doubleValue("wenFactor"),ssWLow,ssWLowErr); printf("5. Extrapolate W ->tau nu from W -> munu using MC \n"); float ssWTLow = ssWLow*parser.doubleValue("wtnFactor"); float ssWTLowErr = sqrt(ssWLowErr*ssWLowErr*parser.doubleValue("wtnFactor")*parser.doubleValue("wtnFactor")+ssWLow*ssWLow*parser.doubleValue("wtnFactorErr")*parser.doubleValue("wtnFactorErr")); printf("SS W tau nu in core =%f *%f = %f +- %f \n",ssWLow,parser.doubleValue("wtnFactor"),ssWTLow,ssWTLowErr); printf("6. From all SS events subtract W and Z jet fakes tau to get QCD "); float ssQCDLow = ssLow-ssWLow-ssWTLow-zjftLow; float ssQCDLowErr = sqrt(ssLow+ssWLowErr*ssWLowErr+ssWTLowErr*ssWTLowErr+zjftLowErr*zjftLowErr); printf("SS QCD in core =%f -%f -%f -%f = %f +- %f \n",ssLow,ssWLow,ssWTLow,zjftLow,ssQCDLow,ssQCDLowErr); printf("7. Extrapolate OS QCD "); float osQCDLow = ssQCDLow*parser.doubleValue("qcdFactor"); float osQCDLowErr = sqrt(ssQCDLowErr*ssQCDLowErr*parser.doubleValue("qcdFactor")*parser.doubleValue("qcdFactor")+parser.doubleValue("qcdFactorErr")*parser.doubleValue("qcdFactorErr")*ssQCDLow*ssQCDLow); output.QCD = osQCDLow; output.QCDErr = osQCDLowErr; printf("OS QCD in core =%f *%f = %f +- %f \n",ssQCDLow,parser.doubleValue("qcdFactor"),osQCDLow,osQCDLowErr); printf("BACKGROUND=%f +-%f \n",osQCDLow+osWLow+osWTLow+ttbarLow+VVLow+zeftLow+zjftLow,sqrt(osQCDLowErr*osQCDLowErr+ osWLowErr*osWLowErr+ osWTLowErr*osWTLowErr+ topLowErr*topLowErr+ VVLowErr*VVLowErr+ zeftLowErr*zeftLowErr+ zjftLowErr*zjftLowErr)); printf("Z=%f +-%f \n",osLow-osQCDLow-osWLow-osWTLow-ttbarLow-VVLow-zeftLow-zjftLow,sqrt(osLow+osQCDLowErr*osQCDLowErr+ osWLowErr*osWLowErr+ osWTLowErr*osWTLowErr+ topLowErr*topLowErr+ VVLowErr*VVLowErr+ zeftLowErr*zeftLowErr+ zjftLowErr*zjftLowErr)); printf(" \n \n "); printf("Total & %.2f & %.2f & %.2f & %.2f \\\\ \n", osLow, osHigh, ssLow, ssHigh); printf("Di-Boson & %.2f $\\pm$ %.2f & %.2f $\\pm$ %.2f & - & - \\\\ \n", VVLow, VVLowErr, VVHigh, VVHighErr); printf("$t\\bar{t}$ & %.2f $\\pm$ %.2f & %.2f $\\pm$ %.2f & - & - \\\\ \n", topLow, topLowErr, topHigh, topHighErr); printf("$Z^{l+jet}$ & %.2f $\\pm$ %.2f & - & %.2f $\\pm$ %.2f & - \\\\ \n", zjftLow, zjftLowErr, zjftLow, zjftLowErr); printf("$Z^{ll}$ & %.2f $\\pm$ %.2f & - & - & - \\\\ \n", zeftLow, zeftLowErr); printf("$W^{\\tau \\nu}$ & %.2f $\\pm$ %.2f & - & %.2f $\\pm$ %.2f & - \\\\ \n", osWTLow, osWTLowErr, ssWTLow, ssWTLowErr); printf("$W^{l \\nu}$ & %.2f $\\pm$ %.2f & %.2f $\\pm$ %.2f & %.2f $\\pm$ %.2f & %.2f $\\pm$ %.2f \\\\ \n", osWLow, osWLowErr, osWHigh, osWHighErr, ssWLow, ssWLowErr, ssHigh, sqrt(ssHigh)); printf("QCD & %.2f $\\pm$ %.2f & - & %.2f $\\pm$ %.2f & - \\\\ \n", osQCDLow, osQCDLowErr, ssQCDLow, ssQCDLowErr); printf("Total Background & %.2f $\\pm$ %.2f & - & - & - \\\\ \n",osQCDLow+osWLow+osWTLow+ttbarLow+VVLow+zeftLow+zjftLow, sqrt(osQCDLowErr*osQCDLowErr+ osWLowErr*osWLowErr+ osWTLowErr*osWTLowErr+ topLowErr*topLowErr+ VVLowErr*VVLowErr+ zeftLowErr*zeftLowErr+ zjftLowErr*zjftLowErr)); return output; } float poissonFluctuation(Long_t N) { TF1 f("mypoisson","TMath::Poisson(x,[0])",0,N); f.SetParameter(0,N); unsigned N2 = (unsigned)(f.GetRandom()); return (float) N2; } // float getFluctuatedEvents(TTree* tree ,std:string selection,std::string lumi ) { // TH1F * pvs = new TH1F("pvs","PVs",10,0,1000); // tree->Draw("PVs>>pvs",("__WEIGHT__*"+lumi+ "("+selection+")").c_str()); // Long_t events = (Long_t)pvs->Integral(); // return poissonFluctuation(events); // }
[ "iross@login06.hep.wisc.edu" ]
iross@login06.hep.wisc.edu
adb88d635ef233694ed9c4260c49d8bf494071dd
7598faccaa6a30f05d98590fc3874435e32f54a2
/src/NNDepParser/model/ActionedNodes.h
9c2bcc2913dba8a39c39de27615fb82eeb68690c
[]
no_license
XrosLiang/NNDepParser
2ca875f6f622e0f687f4501901ef817300ff603b
af49a428e5ceb785358ef360993ed46cb100dc95
refs/heads/master
2021-08-16T21:26:26.123024
2017-11-20T10:35:07
2017-11-20T10:35:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,260
h
#ifndef ACTIONED_NODES_H #define ACTIONED_NODES_H #include "ModelParams.h" #include "AtomFeature.h" // score the action one by one class ActionedNodes { public: LookupNode pre_action_input; LookupNode pre_pre_action_input; ConcatNode action_concat; IncLSTM1Builder action_lstm; vector<LookupNode> current_action_input; vector<PDotNode> action_score; vector<PAddNode> outputs; ConcatNode state_concat; UniNode state_hidden; BucketNode bucket_word; const HyperParams *pOpts; inline void initial(ModelParams &params, const HyperParams &hyparams) { current_action_input.resize(hyparams.actionNum); action_score.resize(hyparams.actionNum); outputs.resize(hyparams.actionNum); for (int idx = 0; idx < hyparams.actionNum; idx++) { current_action_input[idx].setParam(&params.scored_action_table); current_action_input[idx].init(hyparams.stateHiddenSize, hyparams.dropProb); action_score[idx].init(1, -1); outputs[idx].init(1, -1); } pre_action_input.setParam(&params.action_table); pre_action_input.init(hyparams.actionDim, hyparams.dropProb); pre_pre_action_input.setParam(&params.action_table); pre_pre_action_input.init(hyparams.actionDim, hyparams.dropProb); action_concat.init(hyparams.actionDim * 2, -1); action_lstm.init(&params.action_lstm_params, hyparams.dropProb); bucket_word.init(hyparams.rnnHiddenSize * 4, -1); state_concat.init(hyparams.stateConcatSize, -1); state_hidden.setParam(&params.state_hidden_params); state_hidden.init(hyparams.stateHiddenSize, hyparams.dropProb); pOpts = &hyparams; } inline void forward(Graph *cg, const vector<CAction> &actions, AtomFeat &atomFeat) { int action_num = actions.size(); pre_action_input.forward(cg, atomFeat._pre_action_str); pre_pre_action_input.forward(cg, atomFeat._pre_pre_action_str); action_concat.forward(cg, &pre_action_input, &pre_pre_action_input); action_lstm.forward(cg, &action_concat, atomFeat._pre_action_lstm); CAction ac; bucket_word.forward(cg, 0); PNode pword_lstm_buffer0 = atomFeat._next_index >= 0 ? &(*atomFeat._pword_lstm)[atomFeat._next_index] : (PNode)&bucket_word; PNode pword_lstm_stack_top0 = atomFeat._stack_top_0 >= 0 ? &(*atomFeat._pword_lstm)[atomFeat._stack_top_0] : (PNode)&bucket_word; PNode pword_lstm_stack_top1 = atomFeat._stack_top_1 >= 0 ? &(*atomFeat._pword_lstm)[atomFeat._stack_top_1] : (PNode)&bucket_word; PNode pword_lstm_stack_top2 = atomFeat._stack_top_2 >= 0 ? &(*atomFeat._pword_lstm)[atomFeat._stack_top_2] : (PNode)&bucket_word; vector<PNode> feats; feats.push_back(&action_lstm._hidden); feats.push_back(pword_lstm_buffer0); feats.push_back(pword_lstm_stack_top0); feats.push_back(pword_lstm_stack_top1); feats.push_back(pword_lstm_stack_top2); state_concat.forward(cg, feats); state_hidden.forward(cg, &state_concat); vector<PNode> sumNodes; for (int idx = 0; idx < action_num; idx++) { sumNodes.clear(); ac.set(actions[idx]); const string &action = ac.str(*pOpts); current_action_input[idx].forward(cg, action); action_score[idx].forward(cg, &current_action_input[idx], &state_hidden); sumNodes.push_back(&action_score[idx]); outputs[idx].forward(cg, sumNodes); } } }; #endif /*ACTIONED_NODES_H*/
[ "yunan.hlju@gmail.com" ]
yunan.hlju@gmail.com
a9c9d4adf8ae0e4f78a7c4a87c4f8420955ef691
8b1cedbca5f5a967e5c37c280f53dfdbff00ff19
/cocos/170704/170704_Lesson_Swap_Refrence/170704_Lesson_Swap_Refrence/170704_Lesson_Swap_Refrence.cpp
ae034aa75534e5f7a7c7ac2fb8b90cbe09d0cd97
[]
no_license
kcwzzz/KCW
ef552641c77d1971ad4536d37a70eb9a59f4d4e6
34973e5fae0a4095418ac0bd99637ffa24f525be
refs/heads/master
2020-12-03T05:11:38.828978
2017-09-29T08:10:59
2017-09-29T08:10:59
95,736,720
0
0
null
null
null
null
UHC
C++
false
false
621
cpp
// 170704_Lesson_Swap_Refrence.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다. // #include "stdafx.h" #include <iostream> void Swap(int &tA, int &tB); using namespace std; int main() { int tAA = 777; int &tBB = tAA; //tAA라는 변수에 tBB라는 이름을 새로 붙였다. cout << "tAA [" << &tAA << "] : " << tAA << endl; cout << "tBB [" << &tBB << "] : " << tBB << endl; int tA = 3; int tB = 2; Swap(tA, tB); cout << "tA : " << tA << endl; cout << "tB : " << tB << endl; return 0; } void Swap(int &tA, int &tB) { int tTemp = tA; tA = tB; tB = tTemp; return; }
[ "kcwzzz@naver.com" ]
kcwzzz@naver.com
4a5ae4116c80def4daccd40261d29159a14ec3fe
3ffcc0bc7d59ba2fa5f7d7e721d0ed80fe203363
/Medium/159_LongestSubstringWithAtMostTwoDistinctCharacters.cpp
fe2e3e50ad17e7c1f379642df9270876a9cc61f5
[]
no_license
davidwang318/LeetCode
325f69894c86da376c5799101246ce1d4deaac54
efc04f32b334ffd2bfbd8e902ffe40ea6a7ed272
refs/heads/master
2021-07-09T15:30:02.491489
2021-04-01T01:01:16
2021-04-01T01:01:16
234,077,651
3
0
null
null
null
null
UTF-8
C++
false
false
522
cpp
class Solution { public: int lengthOfLongestSubstringTwoDistinct(string s) { if (s.size() <= 2) return s.size(); int cnt = 0, l = 0, r = 0, res = 0; unordered_map<char, int> m; while (r != s.size()) { if (cnt > 2) { if (--m[s[l++]] == 0) --cnt; } else { if (m[s[r++]]++ == 0) ++cnt; if (cnt > 2) continue; else res = max(res, r - l); } } return res; } };
[ "davidwang106@gmail.com" ]
davidwang106@gmail.com
6ce6dd6923a3c0c397ea9a5a67a9303cf35a74ea
5b30dc8638b31b4921ac1611950d48065319ad42
/JNU/线段树+离散化求逆序对.cpp
1ddc7e45b914ecb7a27968962b2f0190b7190195
[ "Apache-2.0" ]
permissive
taisuishen/code
041916ac14973d24f669efd0f6c2606ad9cb554b
b959ffcd9f401fa7c6362d6d7cf745e48acfca89
refs/heads/main
2023-02-02T21:31:27.448785
2020-12-21T16:25:16
2020-12-21T16:25:16
303,955,660
1
0
null
null
null
null
GB18030
C++
false
false
1,366
cpp
#include<bits/stdc++.h> #define lson l,m,rt*2 #define rson m+1,r,rt*2+1 #define maxn 100000+10 using namespace std; int n,now[maxn],tree[4*maxn],sign=0,ans=0; const int mod=99999997; struct node{ int v,w; }a[maxn],b[maxn]; bool cmp(node a,node b) { return a.v<b.v; } void pushup(int rt) { tree[rt]=tree[rt<<1]+tree[rt<<1|1]; } void ins(int p, int l, int r, int rt) { if( l == r ) { tree[rt] ++; return ; } int m = ( l + r ) >> 1; if(p <= m) ins(p,lson); else ins(p,rson); pushup(rt); } int query(int L,int R,int l,int r,int rt)//要询问的区间L-R { if(l>=L&&r<=R) { return tree[rt]; } int m=(l+r)>>1; int ans=0; if(L<=m)ans+=query(L,R,lson); if(R>m)ans+=query(L,R,rson); return ans; } int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a[i].v; a[i].w=i; } for(int i=1;i<=n;i++) { cin>>b[i].v; b[i].w=i; } sort(a+1,a+1+n,cmp); sort(b+1,b+1+n,cmp); for(int i=1;i<=n;i++) now[b[i].w]=a[i].w; for(int i=1;i<=n;i++) { ins(now[i],1,n,1); ans=(ans+i-query(1,now[i],1,n,1))%mod; } cout<<ans; return 0; }
[ "1037381963@qq.com" ]
1037381963@qq.com
04d235b465c7cfe9bc363e5cd5b057c681d20b75
4b43a0b828cfa2ebe545e254cc04d4b203f87592
/MP-SPDZ/MPC-ACC/Defines.h
5a6739a10d1160113b1847727324590924eb5eaf
[ "MIT", "BSD-2-Clause" ]
permissive
dmpingfan/MPC-Accumulator
14c3b65ec26a83273bcb9db4b3ab833be9244f78
c7b42ceb72ee9adcebf210619d8decaaacb6694d
refs/heads/master
2023-08-15T18:34:44.198811
2021-05-17T11:06:49
2021-05-17T11:06:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,609
h
// Defines.h // // The implementation in this file is a modification // of the implementation in: // https://github.com/ladnir/cryptoTools/blob/master/cryptoTools/Common/Defines.h #pragma once #include <cstdint> #include <iostream> #include <memory> #include <emmintrin.h> #include <smmintrin.h> #define ENABLE_RELIC #define STRINGIZE_DETAIL(x) #x #define STRINGIZE(x) STRINGIZE_DETAIL(x) #define LOCATION __FILE__ ":" STRINGIZE(__LINE__) #define RTE_LOC std::runtime_error(LOCATION) // add instrinsics names that intel knows but clang doesn't… #ifdef __clang__ #define _mm_cvtsi128_si64x _mm_cvtsi128_si64 #endif namespace osuCrypto { template<typename T> using ptr = T*; template<typename T> using uPtr = std::unique_ptr<T>; template<typename T> using sPtr = std::shared_ptr<T>; typedef uint64_t u64; typedef int64_t i64; typedef uint32_t u32; typedef int32_t i32; typedef uint16_t u16; typedef int16_t i16; typedef uint8_t u8; typedef int8_t i8; // template<typename T> //static std::string ToString(const T& t) { return boost::lexical_cast<std::string>(t); } typedef __m128i block; inline block toBlock(u8*data) { return _mm_set_epi64x(((u64*)data)[1], ((u64*)data)[0]);} inline block toBlock(u64 low_u64) { return _mm_set_epi64x(0, low_u64); } inline block toBlock(u64 high_u64, u64 low_u64) { return _mm_set_epi64x(high_u64, low_u64); } extern const block ZeroBlock; extern const block OneBlock; extern const block AllOneBlock; extern const block CCBlock; // extern const std::array<block, 2> zeroAndAllOne; inline u64 roundUpTo(u64 val, u64 step) { return ((val + step - 1) / step) * step; } u64 log2ceil(u64); u64 log2floor(u64); block sysRandomSeed(); } std::ostream& operator<<(std::ostream& out, const osuCrypto::block& block); namespace osuCrypto { using ::operator<<; } inline bool eq(const osuCrypto::block& lhs, const osuCrypto::block& rhs) { osuCrypto::block neq = _mm_xor_si128(lhs, rhs); return _mm_test_all_zeros(neq, neq) != 0; } inline bool neq(const osuCrypto::block& lhs, const osuCrypto::block& rhs) { osuCrypto::block neq = _mm_xor_si128(lhs, rhs); return _mm_test_all_zeros(neq, neq) == 0; } #ifdef _MSC_VER inline bool operator<(const osuCrypto::block& lhs, const osuCrypto::block& rhs) { return lhs.m128i_u64[1] < rhs.m128i_u64[1] || (eq(lhs, rhs) && lhs.m128i_u64[0] < rhs.m128i_u64[0]); } inline osuCrypto::block operator^(const osuCrypto::block& lhs, const osuCrypto::block& rhs) { return _mm_xor_si128(lhs, rhs); } inline osuCrypto::block operator&(const osuCrypto::block& lhs, const osuCrypto::block& rhs) { return _mm_and_si128(lhs, rhs); } inline osuCrypto::block operator|(const osuCrypto::block& lhs, const osuCrypto::block& rhs) { return _mm_or_si128(lhs, rhs); } inline osuCrypto::block operator<<(const osuCrypto::block& lhs, const osuCrypto::u8& rhs) { return _mm_slli_epi64(lhs, rhs); } inline osuCrypto::block operator>>(const osuCrypto::block& lhs, const osuCrypto::u8& rhs) { return _mm_srli_epi64(lhs, rhs); } inline osuCrypto::block operator+(const osuCrypto::block& lhs, const osuCrypto::block& rhs) { return _mm_add_epi64(lhs, rhs); } #ifdef ENABLE_RELIC #pragma comment(lib, "relic_s.lib") #endif #ifdef ENABLE_MIRACL #pragma comment(lib, "miracl.lib") #endif #ifdef ENABLE_WOLFSSL #pragma comment(lib, "wolfssl.lib") #endif #endif namespace oc = osuCrypto;
[ "roman.walch@iaik.tugraz.at" ]
roman.walch@iaik.tugraz.at
6b36d46f06a0b0b8df2a4527e8cf13780f256f5a
8dc84558f0058d90dfc4955e905dab1b22d12c08
/net/proxy_resolution/proxy_resolver_v8_tracing.cc
8b96c07fbb97d6cb8b402a57c2cbb23d5b27fb27
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
meniossin/src
42a95cc6c4a9c71d43d62bc4311224ca1fd61e03
44f73f7e76119e5ab415d4593ac66485e65d700a
refs/heads/master
2022-12-16T20:17:03.747113
2020-09-03T10:43:12
2020-09-03T10:43:12
263,710,168
1
0
BSD-3-Clause
2020-05-13T18:20:09
2020-05-13T18:20:08
null
UTF-8
C++
false
false
35,964
cc
// Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "net/proxy_resolution/proxy_resolver_v8_tracing.h" #include <map> #include <string> #include <utility> #include <vector> #include "base/bind.h" #include "base/macros.h" #include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" #include "base/synchronization/cancellation_flag.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" #include "base/threading/thread_checker.h" #include "base/threading/thread_restrictions.h" #include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "net/base/address_list.h" #include "net/base/net_errors.h" #include "net/base/network_interfaces.h" #include "net/base/trace_constants.h" #include "net/dns/host_resolver.h" #include "net/log/net_log_with_source.h" #include "net/proxy_resolution/proxy_info.h" #include "net/proxy_resolution/proxy_resolver_error_observer.h" #include "net/proxy_resolution/proxy_resolver_v8.h" // The intent of this class is explained in the design document: // https://docs.google.com/a/chromium.org/document/d/16Ij5OcVnR3s0MH4Z5XkhI9VTPoMJdaBn9rKreAmGOdE/edit // // In a nutshell, PAC scripts are Javascript programs and may depend on // network I/O, by calling functions like dnsResolve(). // // This is problematic since functions such as dnsResolve() will block the // Javascript execution until the DNS result is availble, thereby stalling the // PAC thread, which hurts the ability to process parallel proxy resolves. // An obvious solution is to simply start more PAC threads, however this scales // poorly, which hurts the ability to process parallel proxy resolves. // // The solution in ProxyResolverV8Tracing is to model PAC scripts as being // deterministic, and depending only on the inputted URL. When the script // issues a dnsResolve() for a yet unresolved hostname, the Javascript // execution is "aborted", and then re-started once the DNS result is // known. namespace net { namespace { // Upper bound on how many *unique* DNS resolves a PAC script is allowed // to make. This is a failsafe both for scripts that do a ridiculous // number of DNS resolves, as well as scripts which are misbehaving // under the tracing optimization. It is not expected to hit this normally. const size_t kMaxUniqueResolveDnsPerExec = 20; // Approximate number of bytes to use for buffering alerts() and errors. // This is a failsafe in case repeated executions of the script causes // too much memory bloat. It is not expected for well behaved scripts to // hit this. (In fact normal scripts should not even have alerts() or errors). const size_t kMaxAlertsAndErrorsBytes = 2048; // The Job class is responsible for executing GetProxyForURL() and // creating ProxyResolverV8 instances, since both of these operations share // similar code. // // The DNS for these operations can operate in either blocking or // non-blocking mode. Blocking mode is used as a fallback when the PAC script // seems to be misbehaving under the tracing optimization. // // Note that this class runs on both the origin thread and a worker // thread. Most methods are expected to be used exclusively on one thread // or the other. // // The lifetime of Jobs does not exceed that of the ProxyResolverV8TracingImpl // that spawned it. Destruction might happen on either the origin thread or the // worker thread. class Job : public base::RefCountedThreadSafe<Job>, public ProxyResolverV8::JSBindings { public: struct Params { Params( const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner, int* num_outstanding_callbacks) : v8_resolver(nullptr), worker_task_runner(worker_task_runner), num_outstanding_callbacks(num_outstanding_callbacks) {} ProxyResolverV8* v8_resolver; scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner; int* num_outstanding_callbacks; }; // |params| is non-owned. It contains the parameters for this Job, and must // outlive it. Job(const Params* params, std::unique_ptr<ProxyResolverV8Tracing::Bindings> bindings); // Called from origin thread. void StartCreateV8Resolver(const scoped_refptr<PacFileData>& script_data, std::unique_ptr<ProxyResolverV8>* resolver, const CompletionCallback& callback); // Called from origin thread. void StartGetProxyForURL(const GURL& url, ProxyInfo* results, const CompletionCallback& callback); // Called from origin thread. void Cancel(); // Called from origin thread. LoadState GetLoadState() const; private: typedef std::map<std::string, std::string> DnsCache; friend class base::RefCountedThreadSafe<Job>; enum Operation { CREATE_V8_RESOLVER, GET_PROXY_FOR_URL, }; struct AlertOrError { bool is_alert; int line_number; base::string16 message; }; ~Job() override; void CheckIsOnWorkerThread() const; void CheckIsOnOriginThread() const; void SetCallback(const CompletionCallback& callback); void ReleaseCallback(); ProxyResolverV8* v8_resolver(); const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner(); HostResolver* host_resolver(); // Invokes the user's callback. void NotifyCaller(int result); void NotifyCallerOnOriginLoop(int result); void Start(Operation op, bool blocking_dns, const CompletionCallback& callback); void ExecuteBlocking(); void ExecuteNonBlocking(); int ExecuteProxyResolver(); // Implementation of ProxyResolverv8::JSBindings bool ResolveDns(const std::string& host, ResolveDnsOperation op, std::string* output, bool* terminate) override; void Alert(const base::string16& message) override; void OnError(int line_number, const base::string16& error) override; bool ResolveDnsBlocking(const std::string& host, ResolveDnsOperation op, std::string* output); bool ResolveDnsNonBlocking(const std::string& host, ResolveDnsOperation op, std::string* output, bool* terminate); bool PostDnsOperationAndWait(const std::string& host, ResolveDnsOperation op, bool* completed_synchronously) WARN_UNUSED_RESULT; void DoDnsOperation(); void OnDnsOperationComplete(int result); void ScheduleRestartWithBlockingDns(); bool GetDnsFromLocalCache(const std::string& host, ResolveDnsOperation op, std::string* output, bool* return_value); void SaveDnsToLocalCache(const std::string& host, ResolveDnsOperation op, int net_error, const AddressList& addresses); // Builds a RequestInfo to service the specified PAC DNS operation. static HostResolver::RequestInfo MakeDnsRequestInfo(const std::string& host, ResolveDnsOperation op); // Makes a key for looking up |host, op| in |dns_cache_|. Strings are used for // convenience, to avoid defining custom comparators. static std::string MakeDnsCacheKey(const std::string& host, ResolveDnsOperation op); void HandleAlertOrError(bool is_alert, int line_number, const base::string16& message); void DispatchBufferedAlertsAndErrors(); void DispatchAlertOrErrorOnOriginThread(bool is_alert, int line_number, const base::string16& message); // The thread which called into ProxyResolverV8TracingImpl, and on which the // completion callback is expected to run. scoped_refptr<base::SingleThreadTaskRunner> origin_runner_; // The Parameters for this Job. // Initialized on origin thread and then accessed from both threads. const Params* const params_; std::unique_ptr<ProxyResolverV8Tracing::Bindings> bindings_; // The callback to run (on the origin thread) when the Job finishes. // Should only be accessed from origin thread. CompletionCallback callback_; // Flag to indicate whether the request has been cancelled. base::CancellationFlag cancelled_; // The operation that this Job is running. // Initialized on origin thread and then accessed from both threads. Operation operation_; // The DNS mode for this Job. // Initialized on origin thread, mutated on worker thread, and accessed // by both the origin thread and worker thread. bool blocking_dns_; // Used to block the worker thread on a DNS operation taking place on the // origin thread. base::WaitableEvent event_; // Map of DNS operations completed so far. Written into on the origin thread // and read on the worker thread. DnsCache dns_cache_; // The job holds a reference to itself to ensure that it remains alive until // either completion or cancellation. scoped_refptr<Job> owned_self_reference_; // ------------------------------------------------------- // State specific to CREATE_V8_RESOLVER. // ------------------------------------------------------- scoped_refptr<PacFileData> script_data_; std::unique_ptr<ProxyResolverV8>* resolver_out_; // ------------------------------------------------------- // State specific to GET_PROXY_FOR_URL. // ------------------------------------------------------- ProxyInfo* user_results_; // Owned by caller, lives on origin thread. GURL url_; ProxyInfo results_; // --------------------------------------------------------------------------- // State for ExecuteNonBlocking() // --------------------------------------------------------------------------- // These variables are used exclusively on the worker thread and are only // meaningful when executing inside of ExecuteNonBlocking(). // Whether this execution was abandoned due to a missing DNS dependency. bool abandoned_; // Number of calls made to ResolveDns() by this execution. int num_dns_; // Sequence of calls made to Alert() or OnError() by this execution. std::vector<AlertOrError> alerts_and_errors_; size_t alerts_and_errors_byte_cost_; // Approximate byte cost of the above. // Number of calls made to ResolveDns() by the PREVIOUS execution. int last_num_dns_; // Whether the current execution needs to be restarted in blocking mode. bool should_restart_with_blocking_dns_; // --------------------------------------------------------------------------- // State for pending DNS request. // --------------------------------------------------------------------------- // Handle to the outstanding request in the HostResolver, or NULL. // This is mutated and used on the origin thread, however it may be read by // the worker thread for some DCHECKS(). std::unique_ptr<HostResolver::Request> pending_dns_; // Indicates if the outstanding DNS request completed synchronously. Written // on the origin thread, and read by the worker thread. bool pending_dns_completed_synchronously_; // These are the inputs to DoDnsOperation(). Written on the worker thread, // read by the origin thread. std::string pending_dns_host_; ResolveDnsOperation pending_dns_op_; // This contains the resolved address list that DoDnsOperation() fills in. // Used exclusively on the origin thread. AddressList pending_dns_addresses_; }; class ProxyResolverV8TracingImpl : public ProxyResolverV8Tracing { public: ProxyResolverV8TracingImpl(std::unique_ptr<base::Thread> thread, std::unique_ptr<ProxyResolverV8> resolver, std::unique_ptr<Job::Params> job_params); ~ProxyResolverV8TracingImpl() override; // ProxyResolverV8Tracing overrides. void GetProxyForURL(const GURL& url, ProxyInfo* results, const CompletionCallback& callback, std::unique_ptr<ProxyResolver::Request>* request, std::unique_ptr<Bindings> bindings) override; class RequestImpl : public ProxyResolver::Request { public: explicit RequestImpl(scoped_refptr<Job> job); ~RequestImpl() override; LoadState GetLoadState() override; private: scoped_refptr<Job> job_; }; private: // The worker thread on which the ProxyResolverV8 will be run. std::unique_ptr<base::Thread> thread_; std::unique_ptr<ProxyResolverV8> v8_resolver_; std::unique_ptr<Job::Params> job_params_; // The number of outstanding (non-cancelled) jobs. int num_outstanding_callbacks_; THREAD_CHECKER(thread_checker_); DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8TracingImpl); }; Job::Job(const Job::Params* params, std::unique_ptr<ProxyResolverV8Tracing::Bindings> bindings) : origin_runner_(base::ThreadTaskRunnerHandle::Get()), params_(params), bindings_(std::move(bindings)), event_(base::WaitableEvent::ResetPolicy::MANUAL, base::WaitableEvent::InitialState::NOT_SIGNALED), last_num_dns_(0) { CheckIsOnOriginThread(); } void Job::StartCreateV8Resolver(const scoped_refptr<PacFileData>& script_data, std::unique_ptr<ProxyResolverV8>* resolver, const CompletionCallback& callback) { CheckIsOnOriginThread(); resolver_out_ = resolver; script_data_ = script_data; // Script initialization uses blocking DNS since there isn't any // advantage to using non-blocking mode here. That is because the // parent ProxyResolutionService can't submit any ProxyResolve requests until // initialization has completed successfully! Start(CREATE_V8_RESOLVER, true /*blocking*/, callback); } void Job::StartGetProxyForURL(const GURL& url, ProxyInfo* results, const CompletionCallback& callback) { CheckIsOnOriginThread(); url_ = url; user_results_ = results; Start(GET_PROXY_FOR_URL, false /*non-blocking*/, callback); } void Job::Cancel() { CheckIsOnOriginThread(); // There are several possibilities to consider for cancellation: // (a) The job has been posted to the worker thread, however script execution // has not yet started. // (b) The script is executing on the worker thread. // (c) The script is executing on the worker thread, however is blocked inside // of dnsResolve() waiting for a response from the origin thread. // (d) Nothing is running on the worker thread, however the host resolver has // a pending DNS request which upon completion will restart the script // execution. // (e) The worker thread has a pending task to restart execution, which was // posted after the DNS dependency was resolved and saved to local cache. // (f) The script execution completed entirely, and posted a task to the // origin thread to notify the caller. // (g) The job is already completed. // // |cancelled_| is read on both the origin thread and worker thread. The // code that runs on the worker thread is littered with checks on // |cancelled_| to break out early. // If the job already completed, there is nothing to be cancelled. if (callback_.is_null()) return; cancelled_.Set(); ReleaseCallback(); pending_dns_.reset(); // The worker thread might be blocked waiting for DNS. event_.Signal(); bindings_.reset(); owned_self_reference_ = NULL; } LoadState Job::GetLoadState() const { CheckIsOnOriginThread(); if (pending_dns_) return LOAD_STATE_RESOLVING_HOST_IN_PAC_FILE; return LOAD_STATE_RESOLVING_PROXY_FOR_URL; } Job::~Job() { DCHECK(!pending_dns_); DCHECK(callback_.is_null()); DCHECK(!bindings_); } void Job::CheckIsOnWorkerThread() const { DCHECK(params_->worker_task_runner->BelongsToCurrentThread()); } void Job::CheckIsOnOriginThread() const { DCHECK(origin_runner_->BelongsToCurrentThread()); } void Job::SetCallback(const CompletionCallback& callback) { CheckIsOnOriginThread(); DCHECK(callback_.is_null()); (*params_->num_outstanding_callbacks)++; callback_ = callback; } void Job::ReleaseCallback() { CheckIsOnOriginThread(); DCHECK(!callback_.is_null()); CHECK_GT(*params_->num_outstanding_callbacks, 0); (*params_->num_outstanding_callbacks)--; callback_.Reset(); // For good measure, clear this other user-owned pointer. user_results_ = NULL; } ProxyResolverV8* Job::v8_resolver() { return params_->v8_resolver; } const scoped_refptr<base::SingleThreadTaskRunner>& Job::worker_task_runner() { return params_->worker_task_runner; } HostResolver* Job::host_resolver() { return bindings_->GetHostResolver(); } void Job::NotifyCaller(int result) { CheckIsOnWorkerThread(); origin_runner_->PostTask( FROM_HERE, base::Bind(&Job::NotifyCallerOnOriginLoop, this, result)); } void Job::NotifyCallerOnOriginLoop(int result) { CheckIsOnOriginThread(); if (cancelled_.IsSet()) return; DispatchBufferedAlertsAndErrors(); // This isn't the ordinary execution flow, however it is exercised by // unit-tests. if (cancelled_.IsSet()) return; DCHECK(!callback_.is_null()); DCHECK(!pending_dns_); if (operation_ == GET_PROXY_FOR_URL) { *user_results_ = results_; } CompletionCallback callback = callback_; ReleaseCallback(); callback.Run(result); bindings_.reset(); owned_self_reference_ = NULL; } void Job::Start(Operation op, bool blocking_dns, const CompletionCallback& callback) { CheckIsOnOriginThread(); operation_ = op; blocking_dns_ = blocking_dns; SetCallback(callback); owned_self_reference_ = this; worker_task_runner()->PostTask( FROM_HERE, blocking_dns_ ? base::Bind(&Job::ExecuteBlocking, this) : base::Bind(&Job::ExecuteNonBlocking, this)); } void Job::ExecuteBlocking() { CheckIsOnWorkerThread(); DCHECK(blocking_dns_); if (cancelled_.IsSet()) return; NotifyCaller(ExecuteProxyResolver()); } void Job::ExecuteNonBlocking() { CheckIsOnWorkerThread(); DCHECK(!blocking_dns_); if (cancelled_.IsSet()) return; // Reset state for the current execution. abandoned_ = false; num_dns_ = 0; alerts_and_errors_.clear(); alerts_and_errors_byte_cost_ = 0; should_restart_with_blocking_dns_ = false; int result = ExecuteProxyResolver(); if (should_restart_with_blocking_dns_) { DCHECK(!blocking_dns_); DCHECK(abandoned_); blocking_dns_ = true; ExecuteBlocking(); return; } if (abandoned_) return; NotifyCaller(result); } int Job::ExecuteProxyResolver() { TRACE_EVENT0(kNetTracingCategory, "Job::ExecuteProxyResolver"); int result = ERR_UNEXPECTED; // Initialized to silence warnings. switch (operation_) { case CREATE_V8_RESOLVER: { std::unique_ptr<ProxyResolverV8> resolver; result = ProxyResolverV8::Create(script_data_, this, &resolver); if (result == OK) *resolver_out_ = std::move(resolver); break; } case GET_PROXY_FOR_URL: { result = v8_resolver()->GetProxyForURL( url_, // Important: Do not write directly into |user_results_|, since if the // request were to be cancelled from the origin thread, must guarantee // that |user_results_| is not accessed anymore. &results_, this); break; } } return result; } bool Job::ResolveDns(const std::string& host, ResolveDnsOperation op, std::string* output, bool* terminate) { if (cancelled_.IsSet()) { *terminate = true; return false; } if ((op == DNS_RESOLVE || op == DNS_RESOLVE_EX) && host.empty()) { // a DNS resolve with an empty hostname is considered an error. return false; } return blocking_dns_ ? ResolveDnsBlocking(host, op, output) : ResolveDnsNonBlocking(host, op, output, terminate); } void Job::Alert(const base::string16& message) { HandleAlertOrError(true, -1, message); } void Job::OnError(int line_number, const base::string16& error) { HandleAlertOrError(false, line_number, error); } bool Job::ResolveDnsBlocking(const std::string& host, ResolveDnsOperation op, std::string* output) { CheckIsOnWorkerThread(); // Check if the DNS result for this host has already been cached. bool rv; if (GetDnsFromLocalCache(host, op, output, &rv)) { // Yay, cache hit! return rv; } if (dns_cache_.size() >= kMaxUniqueResolveDnsPerExec) { // Safety net for scripts with unexpectedly many DNS calls. // We will continue running to completion, but will fail every // subsequent DNS request. return false; } if (!PostDnsOperationAndWait(host, op, NULL)) return false; // Was cancelled. CHECK(GetDnsFromLocalCache(host, op, output, &rv)); return rv; } bool Job::ResolveDnsNonBlocking(const std::string& host, ResolveDnsOperation op, std::string* output, bool* terminate) { CheckIsOnWorkerThread(); if (abandoned_) { // If this execution was already abandoned can fail right away. Only 1 DNS // dependency will be traced at a time (for more predictable outcomes). return false; } num_dns_ += 1; // Check if the DNS result for this host has already been cached. bool rv; if (GetDnsFromLocalCache(host, op, output, &rv)) { // Yay, cache hit! return rv; } if (num_dns_ <= last_num_dns_) { // The sequence of DNS operations is different from last time! ScheduleRestartWithBlockingDns(); *terminate = true; return false; } if (dns_cache_.size() >= kMaxUniqueResolveDnsPerExec) { // Safety net for scripts with unexpectedly many DNS calls. return false; } DCHECK(!should_restart_with_blocking_dns_); bool completed_synchronously; if (!PostDnsOperationAndWait(host, op, &completed_synchronously)) return false; // Was cancelled. if (completed_synchronously) { CHECK(GetDnsFromLocalCache(host, op, output, &rv)); return rv; } // Otherwise if the result was not in the cache, then a DNS request has // been started. Abandon this invocation of FindProxyForURL(), it will be // restarted once the DNS request completes. abandoned_ = true; *terminate = true; last_num_dns_ = num_dns_; return false; } bool Job::PostDnsOperationAndWait(const std::string& host, ResolveDnsOperation op, bool* completed_synchronously) { // Post the DNS request to the origin thread. DCHECK(!pending_dns_); pending_dns_host_ = host; pending_dns_op_ = op; origin_runner_->PostTask(FROM_HERE, base::Bind(&Job::DoDnsOperation, this)); event_.Wait(); event_.Reset(); if (cancelled_.IsSet()) return false; if (completed_synchronously) *completed_synchronously = pending_dns_completed_synchronously_; return true; } void Job::DoDnsOperation() { CheckIsOnOriginThread(); DCHECK(!pending_dns_); if (cancelled_.IsSet()) return; std::unique_ptr<HostResolver::Request> dns_request; int result = host_resolver()->Resolve( MakeDnsRequestInfo(pending_dns_host_, pending_dns_op_), DEFAULT_PRIORITY, &pending_dns_addresses_, base::Bind(&Job::OnDnsOperationComplete, this), &dns_request, bindings_->GetNetLogWithSource()); pending_dns_completed_synchronously_ = result != ERR_IO_PENDING; // Check if the request was cancelled as a side-effect of calling into the // HostResolver. This isn't the ordinary execution flow, however it is // exercised by unit-tests. if (cancelled_.IsSet()) return; if (pending_dns_completed_synchronously_) { OnDnsOperationComplete(result); } else { DCHECK(dns_request); pending_dns_ = std::move(dns_request); // OnDnsOperationComplete() will be called by host resolver on completion. } if (!blocking_dns_) { // The worker thread always blocks waiting to see if the result can be // serviced from cache before restarting. event_.Signal(); } } void Job::OnDnsOperationComplete(int result) { CheckIsOnOriginThread(); DCHECK(!cancelled_.IsSet()); DCHECK(pending_dns_completed_synchronously_ == (pending_dns_ == NULL)); SaveDnsToLocalCache(pending_dns_host_, pending_dns_op_, result, pending_dns_addresses_); pending_dns_.reset(); if (blocking_dns_) { event_.Signal(); return; } if (!blocking_dns_ && !pending_dns_completed_synchronously_) { // Restart. This time it should make more progress due to having // cached items. worker_task_runner()->PostTask(FROM_HERE, base::Bind(&Job::ExecuteNonBlocking, this)); } } void Job::ScheduleRestartWithBlockingDns() { CheckIsOnWorkerThread(); DCHECK(!should_restart_with_blocking_dns_); DCHECK(!abandoned_); DCHECK(!blocking_dns_); abandoned_ = true; // The restart will happen after ExecuteNonBlocking() finishes. should_restart_with_blocking_dns_ = true; } bool Job::GetDnsFromLocalCache(const std::string& host, ResolveDnsOperation op, std::string* output, bool* return_value) { CheckIsOnWorkerThread(); DnsCache::const_iterator it = dns_cache_.find(MakeDnsCacheKey(host, op)); if (it == dns_cache_.end()) return false; *output = it->second; *return_value = !it->second.empty(); return true; } void Job::SaveDnsToLocalCache(const std::string& host, ResolveDnsOperation op, int net_error, const AddressList& addresses) { CheckIsOnOriginThread(); // Serialize the result into a string to save to the cache. std::string cache_value; if (net_error != OK) { cache_value = std::string(); } else if (op == DNS_RESOLVE || op == MY_IP_ADDRESS) { // dnsResolve() and myIpAddress() are expected to return a single IP // address. cache_value = addresses.front().ToStringWithoutPort(); } else { // The *Ex versions are expected to return a semi-colon separated list. for (AddressList::const_iterator iter = addresses.begin(); iter != addresses.end(); ++iter) { if (!cache_value.empty()) cache_value += ";"; cache_value += iter->ToStringWithoutPort(); } } dns_cache_[MakeDnsCacheKey(host, op)] = cache_value; } // static HostResolver::RequestInfo Job::MakeDnsRequestInfo(const std::string& host, ResolveDnsOperation op) { HostPortPair host_port = HostPortPair(host, 80); if (op == MY_IP_ADDRESS || op == MY_IP_ADDRESS_EX) { host_port.set_host(GetHostName()); } HostResolver::RequestInfo info(host_port); // Flag myIpAddress requests. if (op == MY_IP_ADDRESS || op == MY_IP_ADDRESS_EX) { // TODO: Provide a RequestInfo construction mechanism that does not // require a hostname and sets is_my_ip_address to true instead of this. info.set_is_my_ip_address(true); } // The non-ex flavors are limited to IPv4 results. if (op == MY_IP_ADDRESS || op == DNS_RESOLVE) { info.set_address_family(ADDRESS_FAMILY_IPV4); } return info; } std::string Job::MakeDnsCacheKey(const std::string& host, ResolveDnsOperation op) { return base::StringPrintf("%d:%s", op, host.c_str()); } void Job::HandleAlertOrError(bool is_alert, int line_number, const base::string16& message) { CheckIsOnWorkerThread(); if (cancelled_.IsSet()) return; if (blocking_dns_) { // In blocking DNS mode the events can be dispatched immediately. origin_runner_->PostTask( FROM_HERE, base::Bind(&Job::DispatchAlertOrErrorOnOriginThread, this, is_alert, line_number, message)); return; } // Otherwise in nonblocking mode, buffer all the messages until // the end. if (abandoned_) return; alerts_and_errors_byte_cost_ += sizeof(AlertOrError) + message.size() * 2; // If there have been lots of messages, enqueing could be expensive on // memory. Consider a script which does megabytes worth of alerts(). // Avoid this by falling back to blocking mode. if (alerts_and_errors_byte_cost_ > kMaxAlertsAndErrorsBytes) { alerts_and_errors_.clear(); ScheduleRestartWithBlockingDns(); return; } AlertOrError entry = {is_alert, line_number, message}; alerts_and_errors_.push_back(entry); } void Job::DispatchBufferedAlertsAndErrors() { CheckIsOnOriginThread(); for (size_t i = 0; i < alerts_and_errors_.size(); ++i) { const AlertOrError& x = alerts_and_errors_[i]; DispatchAlertOrErrorOnOriginThread(x.is_alert, x.line_number, x.message); } } void Job::DispatchAlertOrErrorOnOriginThread(bool is_alert, int line_number, const base::string16& message) { CheckIsOnOriginThread(); if (cancelled_.IsSet()) return; if (is_alert) { // ------------------- // alert // ------------------- VLOG(1) << "PAC-alert: " << message; bindings_->Alert(message); } else { // ------------------- // error // ------------------- if (line_number == -1) VLOG(1) << "PAC-error: " << message; else VLOG(1) << "PAC-error: " << "line: " << line_number << ": " << message; bindings_->OnError(line_number, message); } } ProxyResolverV8TracingImpl::ProxyResolverV8TracingImpl( std::unique_ptr<base::Thread> thread, std::unique_ptr<ProxyResolverV8> resolver, std::unique_ptr<Job::Params> job_params) : thread_(std::move(thread)), v8_resolver_(std::move(resolver)), job_params_(std::move(job_params)), num_outstanding_callbacks_(0) { job_params_->num_outstanding_callbacks = &num_outstanding_callbacks_; } ProxyResolverV8TracingImpl::~ProxyResolverV8TracingImpl() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); // Note, all requests should have been cancelled. CHECK_EQ(0, num_outstanding_callbacks_); // Join the worker thread. See http://crbug.com/69710. base::ThreadRestrictions::ScopedAllowIO allow_io; thread_.reset(); } ProxyResolverV8TracingImpl::RequestImpl::RequestImpl(scoped_refptr<Job> job) : job_(std::move(job)) {} ProxyResolverV8TracingImpl::RequestImpl::~RequestImpl() { job_->Cancel(); } LoadState ProxyResolverV8TracingImpl::RequestImpl::GetLoadState() { return job_->GetLoadState(); } void ProxyResolverV8TracingImpl::GetProxyForURL( const GURL& url, ProxyInfo* results, const CompletionCallback& callback, std::unique_ptr<ProxyResolver::Request>* request, std::unique_ptr<Bindings> bindings) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK(!callback.is_null()); scoped_refptr<Job> job = new Job(job_params_.get(), std::move(bindings)); request->reset(new RequestImpl(job)); job->StartGetProxyForURL(url, results, callback); } class ProxyResolverV8TracingFactoryImpl : public ProxyResolverV8TracingFactory { public: ProxyResolverV8TracingFactoryImpl(); ~ProxyResolverV8TracingFactoryImpl() override; void CreateProxyResolverV8Tracing( const scoped_refptr<PacFileData>& pac_script, std::unique_ptr<ProxyResolverV8Tracing::Bindings> bindings, std::unique_ptr<ProxyResolverV8Tracing>* resolver, const CompletionCallback& callback, std::unique_ptr<ProxyResolverFactory::Request>* request) override; private: class CreateJob; void RemoveJob(CreateJob* job); std::set<CreateJob*> jobs_; DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8TracingFactoryImpl); }; class ProxyResolverV8TracingFactoryImpl::CreateJob : public ProxyResolverFactory::Request { public: CreateJob(ProxyResolverV8TracingFactoryImpl* factory, std::unique_ptr<ProxyResolverV8Tracing::Bindings> bindings, const scoped_refptr<PacFileData>& pac_script, std::unique_ptr<ProxyResolverV8Tracing>* resolver_out, const CompletionCallback& callback) : factory_(factory), thread_(new base::Thread("Proxy Resolver")), resolver_out_(resolver_out), callback_(callback), num_outstanding_callbacks_(0) { // Start up the thread. base::Thread::Options options; options.timer_slack = base::TIMER_SLACK_MAXIMUM; CHECK(thread_->StartWithOptions(options)); job_params_.reset( new Job::Params(thread_->task_runner(), &num_outstanding_callbacks_)); create_resolver_job_ = new Job(job_params_.get(), std::move(bindings)); create_resolver_job_->StartCreateV8Resolver( pac_script, &v8_resolver_, base::Bind( &ProxyResolverV8TracingFactoryImpl::CreateJob::OnV8ResolverCreated, base::Unretained(this))); } ~CreateJob() override { if (factory_) { factory_->RemoveJob(this); DCHECK(create_resolver_job_); create_resolver_job_->Cancel(); StopWorkerThread(); } DCHECK_EQ(0, num_outstanding_callbacks_); } void FactoryDestroyed() { factory_ = nullptr; create_resolver_job_->Cancel(); create_resolver_job_ = nullptr; StopWorkerThread(); } private: void OnV8ResolverCreated(int error) { DCHECK(factory_); if (error == OK) { job_params_->v8_resolver = v8_resolver_.get(); resolver_out_->reset(new ProxyResolverV8TracingImpl( std::move(thread_), std::move(v8_resolver_), std::move(job_params_))); } else { StopWorkerThread(); } factory_->RemoveJob(this); factory_ = nullptr; create_resolver_job_ = nullptr; callback_.Run(error); } void StopWorkerThread() { // Join the worker thread. See http://crbug.com/69710. base::ThreadRestrictions::ScopedAllowIO allow_io; thread_.reset(); } ProxyResolverV8TracingFactoryImpl* factory_; std::unique_ptr<base::Thread> thread_; std::unique_ptr<Job::Params> job_params_; scoped_refptr<Job> create_resolver_job_; std::unique_ptr<ProxyResolverV8> v8_resolver_; std::unique_ptr<ProxyResolverV8Tracing>* resolver_out_; const CompletionCallback callback_; int num_outstanding_callbacks_; DISALLOW_COPY_AND_ASSIGN(CreateJob); }; ProxyResolverV8TracingFactoryImpl::ProxyResolverV8TracingFactoryImpl() = default; ProxyResolverV8TracingFactoryImpl::~ProxyResolverV8TracingFactoryImpl() { for (auto* job : jobs_) { job->FactoryDestroyed(); } } void ProxyResolverV8TracingFactoryImpl::CreateProxyResolverV8Tracing( const scoped_refptr<PacFileData>& pac_script, std::unique_ptr<ProxyResolverV8Tracing::Bindings> bindings, std::unique_ptr<ProxyResolverV8Tracing>* resolver, const CompletionCallback& callback, std::unique_ptr<ProxyResolverFactory::Request>* request) { std::unique_ptr<CreateJob> job( new CreateJob(this, std::move(bindings), pac_script, resolver, callback)); jobs_.insert(job.get()); *request = std::move(job); } void ProxyResolverV8TracingFactoryImpl::RemoveJob( ProxyResolverV8TracingFactoryImpl::CreateJob* job) { size_t erased = jobs_.erase(job); DCHECK_EQ(1u, erased); } } // namespace // static std::unique_ptr<ProxyResolverV8TracingFactory> ProxyResolverV8TracingFactory::Create() { return std::make_unique<ProxyResolverV8TracingFactoryImpl>(); } } // namespace net
[ "arnaud@geometry.ee" ]
arnaud@geometry.ee
f6a84d402c1d149f4c742c5ba200fcc0fbefef76
e06e5cec524d56e31fd2ab9ed1dc2ce5901132ab
/src/majority-element.cpp
10af683cbec3d1ed606f5a650eb926bf04dad801
[ "MIT" ]
permissive
amoudgl/leetcode-solutions
d08ccd2fb8c8df17946ef665b701473c37725d27
dc6570bb06b82c2c70d6f387b3486897035cc995
refs/heads/master
2021-07-14T11:39:53.627346
2017-10-11T16:19:14
2017-10-11T16:19:14
90,723,556
0
0
null
null
null
null
UTF-8
C++
false
false
368
cpp
// Author: Abhinav Moudgil [ https://leetcode.com/amoudgl/ ] class Solution { public: int majorityElement(vector<int>& nums) { int count = 0, ans = 0; for (int i = 0; i < nums.size(); i++) { if (count == 0) ans = nums[i]; if (ans != nums[i]) count--; else count++; } return ans; } };
[ "abhinavmoudgil95@gmail.com" ]
abhinavmoudgil95@gmail.com
62bd02362018f53efeb2a947f7e126ee56290a83
08d3ae56aac8bba5cf5c40db1cdbb2594ceb97d0
/src/Breakout/Game.h
54521e74002fd86f71c0d3a2b1d3808854e22b84
[]
no_license
wyrover/sdl-examples
ec99c37b56a6fb2dfd56f4fbfdf912fb9f4e9f76
da825457dcdf9b34f2ad7e59fc0ab9e8233633a7
refs/heads/master
2021-01-17T18:58:36.868667
2017-09-27T01:30:08
2017-09-27T01:30:08
84,137,392
1
1
null
null
null
null
UTF-8
C++
false
false
1,204
h
// ------------------------------------------------------------ // The Breakout Tutorial // (c) 2015 Rembound.com // http://rembound.com/articles/the-breakout-tutorial // ------------------------------------------------------------ #ifndef GAME_H_ #define GAME_H_ #include "SDL.h" #include "SDL_image.h" #include <iostream> #include <stdio.h> #include "Board.h" #include "Paddle.h" #include "Ball.h" #define FPS_DELAY 500 class Game { public: Game(); ~Game(); bool Init(); void Run(); private: SDL_Window* window; SDL_Renderer* renderer; SDL_Texture* texture; // Timing unsigned int lasttick, fpstick, fps, framecount; // Test float testx, testy; Board* board; Paddle* paddle; Ball* ball; bool paddlestick; void Clean(); void Update(float delta); void Render(float delta); void NewGame(); void ResetPaddle(); void StickBall(); void SetPaddleX(float x); void CheckBoardCollisions(); float GetReflection(float hitx); void CheckPaddleCollisions(); void CheckBrickCollisions(); void CheckBrickCollisions2(); void BallBrickResponse(int dirindex); int GetBrickCount(); }; #endif
[ "wyrover@gmail.com" ]
wyrover@gmail.com
945821b9be7a429b7bca8543d79ec053de149819
9546b2c00eaefbe9eb57f4f14711214b2009dc3b
/ChronoEngineWrapper/ChronoEngineWrapper/FunctionSine.cpp
796ba71af7486631365b2645787338d93df2f939
[]
no_license
globus000/cew
671096366385805a8f4dbe2d2f8c185edb4163cb
13d2a3c007239c8caccab2c5198ef5e8147369e1
refs/heads/master
2016-09-05T09:18:55.011986
2015-04-26T16:45:00
2015-04-26T16:45:00
34,566,328
0
0
null
null
null
null
UTF-8
C++
false
false
1,486
cpp
#include "stdafx.h" #include "Functionsine.h" namespace cew { FunctionSine::FunctionSine() : Function( new chrono::ChFunction_Sine() ) { } FunctionSine::~FunctionSine() { } double FunctionSine::Amp::get() { return SharedPtr->DynamicCastTo<chrono::ChFunction_Sine>()->Get_amp(); } void FunctionSine::Amp::set(double value) { SharedPtr->DynamicCastTo<chrono::ChFunction_Sine>()->Set_amp(value); } double FunctionSine::Freq::get() { return SharedPtr->DynamicCastTo<chrono::ChFunction_Sine>()->Get_freq(); } void FunctionSine::Freq::set(double value) { SharedPtr->DynamicCastTo<chrono::ChFunction_Sine>()->Set_freq(value); } double FunctionSine::W::get() { return SharedPtr->DynamicCastTo<chrono::ChFunction_Sine>()->Get_w(); } void FunctionSine::W::set(double value) { SharedPtr->DynamicCastTo<chrono::ChFunction_Sine>()->Set_w(value); } double FunctionSine::Phase::get() { return SharedPtr->DynamicCastTo<chrono::ChFunction_Sine>()->Get_phase(); } void FunctionSine::Phase::set(double value) { SharedPtr->DynamicCastTo<chrono::ChFunction_Sine>()->Set_phase(value); } double FunctionSine::GetY(double x) { return SharedPtr->DynamicCastTo<chrono::ChFunction_Sine>()->Get_y(x); } double FunctionSine::GetYdx(double x) { return SharedPtr->DynamicCastTo<chrono::ChFunction_Sine>()->Get_y_dx(x); } double FunctionSine::GetYdxdx(double x) { return SharedPtr->DynamicCastTo<chrono::ChFunction_Sine>()->Get_y_dxdx(x); } }
[ "zr_contact@mail.ru" ]
zr_contact@mail.ru
a492ec4bd8e35a6789f025cde62937169339fb6a
b7f3edb5b7c62174bed808079c3b21fb9ea51d52
/third_party/blink/renderer/bindings/tests/results/core/string_treat_null_as_empty_string_or_long.cc
552e6c61822ec2b21687eda43d1aecd2eba8fde2
[ "LGPL-2.0-or-later", "GPL-1.0-or-later", "MIT", "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "GPL-2.0-only", "LGPL-2.0-only", "BSD-2-Clause", "LicenseRef-scancode-other-copyleft", "BSD-3-Clause" ]
permissive
otcshare/chromium-src
26a7372773b53b236784c51677c566dc0ad839e4
64bee65c921db7e78e25d08f1e98da2668b57be5
refs/heads/webml
2023-03-21T03:20:15.377034
2020-11-16T01:40:14
2020-11-16T01:40:14
209,262,645
18
21
BSD-3-Clause
2023-03-23T06:20:07
2019-09-18T08:52:07
null
UTF-8
C++
false
false
4,069
cc
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file has been auto-generated from the Jinja2 template // third_party/blink/renderer/bindings/templates/union_container.cc.tmpl // by the script code_generator_v8.py. // DO NOT MODIFY! // clang-format off #include "third_party/blink/renderer/bindings/tests/results/core/string_treat_null_as_empty_string_or_long.h" #include "base/stl_util.h" #include "third_party/blink/renderer/bindings/core/v8/idl_types.h" #include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h" #include "third_party/blink/renderer/bindings/core/v8/to_v8_for_core.h" namespace blink { StringTreatNullAsEmptyStringOrLong::StringTreatNullAsEmptyStringOrLong() : type_(SpecificType::kNone) {} int32_t StringTreatNullAsEmptyStringOrLong::GetAsLong() const { DCHECK(IsLong()); return long_; } void StringTreatNullAsEmptyStringOrLong::SetLong(int32_t value) { DCHECK(IsNull()); long_ = value; type_ = SpecificType::kLong; } StringTreatNullAsEmptyStringOrLong StringTreatNullAsEmptyStringOrLong::FromLong(int32_t value) { StringTreatNullAsEmptyStringOrLong container; container.SetLong(value); return container; } const String& StringTreatNullAsEmptyStringOrLong::GetAsString() const { DCHECK(IsString()); return string_treat_null_as_empty_string_; } void StringTreatNullAsEmptyStringOrLong::SetString(const String& value) { DCHECK(IsNull()); string_treat_null_as_empty_string_ = value; type_ = SpecificType::kStringTreatNullAsEmptyString; } StringTreatNullAsEmptyStringOrLong StringTreatNullAsEmptyStringOrLong::FromString(const String& value) { StringTreatNullAsEmptyStringOrLong container; container.SetString(value); return container; } StringTreatNullAsEmptyStringOrLong::StringTreatNullAsEmptyStringOrLong(const StringTreatNullAsEmptyStringOrLong&) = default; StringTreatNullAsEmptyStringOrLong::~StringTreatNullAsEmptyStringOrLong() = default; StringTreatNullAsEmptyStringOrLong& StringTreatNullAsEmptyStringOrLong::operator=(const StringTreatNullAsEmptyStringOrLong&) = default; void StringTreatNullAsEmptyStringOrLong::Trace(Visitor* visitor) const { } void V8StringTreatNullAsEmptyStringOrLong::ToImpl( v8::Isolate* isolate, v8::Local<v8::Value> v8_value, StringTreatNullAsEmptyStringOrLong& impl, UnionTypeConversionMode conversion_mode, ExceptionState& exception_state) { if (v8_value.IsEmpty()) return; if (conversion_mode == UnionTypeConversionMode::kNullable && IsUndefinedOrNull(v8_value)) return; if (v8_value->IsNumber()) { int32_t cpp_value{ NativeValueTraits<IDLLong>::NativeValue(isolate, v8_value, exception_state) }; if (exception_state.HadException()) return; impl.SetLong(cpp_value); return; } { V8StringResource<kTreatNullAsEmptyString> cpp_value{ v8_value }; if (!cpp_value.Prepare(exception_state)) return; impl.SetString(cpp_value); return; } } v8::Local<v8::Value> ToV8(const StringTreatNullAsEmptyStringOrLong& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) { switch (impl.type_) { case StringTreatNullAsEmptyStringOrLong::SpecificType::kNone: return v8::Null(isolate); case StringTreatNullAsEmptyStringOrLong::SpecificType::kLong: return v8::Integer::New(isolate, impl.GetAsLong()); case StringTreatNullAsEmptyStringOrLong::SpecificType::kStringTreatNullAsEmptyString: return V8String(isolate, impl.GetAsString()); default: NOTREACHED(); } return v8::Local<v8::Value>(); } StringTreatNullAsEmptyStringOrLong NativeValueTraits<StringTreatNullAsEmptyStringOrLong>::NativeValue( v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exception_state) { StringTreatNullAsEmptyStringOrLong impl; V8StringTreatNullAsEmptyStringOrLong::ToImpl(isolate, value, impl, UnionTypeConversionMode::kNotNullable, exception_state); return impl; } } // namespace blink
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
a532d2dc04d716d783afd0b9206ced9d93391802
53052e0064bf42316e6f7f94fd0003096b010f78
/week3_hash_tables/1_phone_book/phone_book.cpp
42da106d7d9a614bf66ef51f9cd6891563f311cd
[]
no_license
muhammedSabbah/Data-Structures
4b60f33e9fe48d31dbe0d88c3fc8512885c6709e
b80831b2dc32c2cb334c9931df7ff9405484dd67
refs/heads/master
2020-09-13T20:42:25.716658
2020-04-06T12:54:58
2020-04-06T12:54:58
222,897,064
0
0
null
null
null
null
UTF-8
C++
false
false
2,013
cpp
#include <iostream> #include <vector> #include <string> #include <unordered_map> using namespace std; struct Query { string type, name; int number; }; vector<Query> read_queries() { int n; cin >> n; vector<Query> queries(n); for (int i = 0; i < n; ++i) { cin >> queries[i].type; if (queries[i].type == "add") cin >> queries[i].number >> queries[i].name; else cin >> queries[i].number; } return queries; } void write_responses(const vector<string>& result) { for (size_t i = 0; i < result.size(); ++i) cout << result[i] << "\n"; } vector<string> process_queries(const vector<Query>& queries) { vector<string> result; // Keep list of all existing (i.e. not deleted yet) contacts. unordered_map<int, string> contacts; //vector<string> contacts; for (size_t i = 0; i < queries.size(); ++i) if (queries[i].type == "add") { bool was_founded = false; // if we already have contact with such number, // we should rewrite contact's name contacts[queries[i].number] = queries[i].name; /* for (size_t j = 0; j < contacts.size(); ++j) if (contacts[j].number == queries[i].number) { contacts[j].name = queries[i].name; was_founded = true; break; } // otherwise, just add it if (!was_founded) contacts.push_back(queries[i]); */ } else if (queries[i].type == "del") { contacts.erase(queries[i].number); /* for (size_t j = 0; j < contacts.size(); ++j) if (contacts[j].number == queries[i].number) { contacts.erase(contacts.begin() + j); break; } */ } else { string response = "not found"; unordered_map<int, string>::iterator it = contacts.find(queries[i].number); if (it != contacts.end()){ response = it->second; } result.push_back(response); /* for (size_t j = 0; j < contacts.size(); ++j) if (contacts[j].number == queries[i].number) { response = contacts[j].name; break; } result.push_back(response); */ } return result; } int main() { write_responses(process_queries(read_queries())); return 0; }
[ "30741844+muhammedSabbah@users.noreply.github.com" ]
30741844+muhammedSabbah@users.noreply.github.com
99b1883178b40c601522ff91180a2e67e61d65cc
395833de59e625da5a0c8c9c4f6ea3320cefabfb
/MikuMikuGameEngine/engine/core/ResourceManager.h
3741239b983fb92e8fdb3e5b24694e4f02d91ec9
[]
no_license
dugong001/MikuMikuGameEngine
e7214c62bf86aee72d3b14f63268cfab1bab08e1
3621580da9ee3dc2c244fc182de53d31dfbd7e80
refs/heads/master
2020-03-27T18:26:27.296118
2013-02-23T12:05:18
2013-02-23T12:05:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
856
h
#pragma once #include "util/Charset.h" class IResource { public: IResource(){}; virtual ~IResource(){}; }; typedef std::tr1::shared_ptr< IResource > ResourcePtr; typedef std::tr1::weak_ptr< IResource > ResourceWeakPtr; class ResourceManager { public: static ResourceManager& GetInstance() { static ResourceManager manager; return manager; } private: typedef std::map<tstring_symbol,ResourceWeakPtr> MapResource; MapResource m_mapResource; public: ResourceManager(); virtual ~ResourceManager(); public: ResourcePtr GetResource( const tstring_symbol& name ); template< class T > std::tr1::shared_ptr<T> GetResource( const tstring_symbol& name ) { return std::tr1::dynamic_pointer_cast<T>( GetResource( name ) ); } void AddResource( const tstring_symbol& name,ResourcePtr resource ); };
[ "miyabi@circle-chips.com" ]
miyabi@circle-chips.com
52234e04ab3dc7c7002254635e506205be5f1d9e
6e707dc66ddd5ad85f7d3e3d37ee8758644889ae
/GGP_Engine/Engine/DX11Starter/Entities.cpp
2461b6ad09686ee530e61c6edb9d0669ae13e9e4
[]
no_license
ArturoKuang/ClothSimulation
61c82ca2fa012b3483cb26492dbaa5c491c7b424
3ea55d99ced224394912a30ce299620bb9e458e2
refs/heads/master
2022-02-24T16:16:51.664429
2019-09-20T18:57:19
2019-09-20T18:57:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,307
cpp
#include "Entities.h" Entities::Entities(Mesh * Mesh, Material* Material) { material = Material; mesh = Mesh; XMStoreFloat4x4(&worldMatrix, XMMatrixIdentity()); position = { 1, 1, 0 }; scale = { 1, 1, 1 }; rotation = { 0, 0, 0 }; } void Entities::SetTranslation(float x, float y, float z) { position = { x, y, z }; } void Entities::SetRotation(float x, float y, float z) { rotation = { x, y, z }; } void Entities::SetScale(float x, float y, float z) { scale = { x, y, z }; } XMFLOAT4X4 Entities::GetWorldMatrix() { XMMATRIX tr = XMMatrixTranslation(position.x, position.y, position.z); XMMATRIX ro = XMMatrixRotationRollPitchYaw(rotation.x, rotation.y, rotation.z); XMMATRIX sc = XMMatrixScaling(scale.x, scale.y, scale.z); // Store the matrix so it's sent to the GPU during draw XMStoreFloat4x4(&worldMatrix, XMMatrixTranspose(sc * ro * tr)); return worldMatrix; } void Entities::Draw(ID3D11DeviceContext * context, DXGI_FORMAT format, UINT strideSize) { //UINT stride = sizeof(VertexPosColor); UINT offset = 0; ID3D11Buffer* vertexBuffer = mesh->GetVertexBuffer(); context->IASetVertexBuffers(0, 1, &vertexBuffer, &strideSize, &offset); context->IASetIndexBuffer(mesh->GetIndexBuffer(), format, 0); //context->IASetIndexBuffer(mesh->GetIndexBuffer(), DXGI_FORMAT_R16_UINT, 0); //draw context->DrawIndexed( mesh->GetIndexCount(), 0, 0 ); } void Entities::Move(float totalTime) { float sinTime = sin(totalTime * 2); position.x = sinTime; //rotation = { 0, 0, XM_PI * totalTime }; scale = { .25f , .25f, .25f }; } void Entities::PerpareMaterial(XMFLOAT4X4 view, XMFLOAT4X4 projection) { //set vertex shader material->GetVertexShader()->SetMatrix4x4("view", view); material->GetVertexShader()->SetMatrix4x4("projection", projection); material->GetVertexShader()->SetMatrix4x4("world", GetWorldMatrix()); material->GetVertexShader()->SetShader(); material->GetVertexShader()->CopyAllBufferData(); //set pixel shader material->GetPixelShader()->SetSamplerState("Samp", material->getSampler()); material->GetPixelShader()->SetShaderResourceView("DiffuseTexture", material->getTexture()); material->GetPixelShader()->CopyAllBufferData(); material->GetPixelShader()->SetShader(); } void Entities::UpdateCloth(float timer, ID3D11DeviceContext* device, VertexPosColor* vertices) { XMFLOAT3* pEdge = particleSystem->GetEdge(); static float animationCounter = .0f; for (int32_t ii = 0; ii < 32; ii++) { pEdge[ii].z = 1.f * sinf(animationCounter); } animationCounter += .125f * timer; particleSystem->Update(timer); //copy particles pos to vertex pos D3D11_MAPPED_SUBRESOURCE mappedResource; ZeroMemory(&mappedResource, sizeof(D3D11_MAPPED_SUBRESOURCE)); //disable gpu access to the vertex buffer data device->Map(mesh->GetVertexBuffer(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); uint32_t ii = 0; for (uint32_t zz = 0; zz < 32; zz++) { for (uint32_t xx = 0; xx < 32; xx++) { vertices[ii].pos = particleSystem->GetParticlesPos(ii); ii++; } } memcpy(mappedResource.pData, mesh->GetClothVertices(), mesh->GetClothVerticesSize()); //reenable GPU access to the vertex buffer data device->Unmap(mesh->GetVertexBuffer(), 0); } void Entities::SetParticleSystem(ParticleSystem * p_System) { particleSystem = p_System; }
[ "Arturo@DESKTOP-L6C1D74" ]
Arturo@DESKTOP-L6C1D74
11a7ae729a7e1f0b3c2771dbf9ea8394d083ec7c
ab116a11edb15f076480864c6d349c02e3434cf5
/team.cpp
55da46f66067e491fe0fd8fd30b7a838fe8e96de
[]
no_license
amengede/cpp-practice
ece5512e77d7c3220b15bc3f9d202502ea6af3be
37fb7c1ecd5a36c2912a729f7b24a61dea570d3c
refs/heads/master
2022-10-23T19:10:53.405119
2020-06-19T02:09:36
2020-06-19T02:09:36
272,578,003
1
0
null
null
null
null
UTF-8
C++
false
false
853
cpp
/* How many problems to attempt? A team has 3 members and is given n problems. For each problem, each team member knows whether they can solve it. The team will only attempt a problem if 2 out of 3 of them can solve it. How many problems can they attempt? input: standard, no. of problems and the data set where row=problem and column=team member, 0=can't solve, 1=can solve output: no. of problems the team can attempt example: 3 1 1 0 1 1 1 1 0 0 2 */ #include <iostream> using namespace std; int main() { int n, temp, thisP = 0, problems = 0; cin >> n; for (int i = 0;i < n;i++) { int thisP = 0; for(int j = 0;j < 3;j++) { cin >> temp; thisP += temp; } if (thisP >= 2) { problems++; } } cout << problems; }
[ "amengede27@outlook.com" ]
amengede27@outlook.com
702780427e4c10ab4d552a875da97d10c06f1894
38cea84aad798112978e45e330792d50ec05bd3e
/game/client/c_vguiscreen.cpp
b27d2ea0f470e2d616dd1b4ff0dc861e10b56846
[]
no_license
HL2-Ghosting-Team/src
3822c5f7b621ef8e158fa7e2a74551c9cd81257f
8c9e32e78a0f67591d6dd8a17cb77bc0ebf832b5
refs/heads/master
2022-06-25T01:15:20.989386
2022-06-16T19:58:43
2022-06-18T17:52:05
12,396,254
20
19
null
2022-06-18T17:52:06
2013-08-27T03:49:09
C++
WINDOWS-1252
C++
false
false
26,018
cpp
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// // // Purpose: // // $NoKeywords: $ //=============================================================================// #include "cbase.h" #include "networkstringtable_clientdll.h" #include <KeyValues.h> #include "PanelMetaClassMgr.h" #include <vgui_controls/Controls.h> #include "mathlib/VMatrix.h" #include "VGUIMatSurface/IMatSystemSurface.h" #include "view.h" #include "CollisionUtils.h" #include <vgui/IInput.h> #include <vgui/IPanel.h> #include <vgui/IVGui.h> #include "ienginevgui.h" #include "in_buttons.h" #include <vgui/Mousecode.h> #include "materialsystem/IMesh.h" #include "ClientEffectPrecacheSystem.h" #include "C_VGuiScreen.h" #include "IClientMode.h" #include "vgui_bitmapbutton.h" #include "vgui_bitmappanel.h" #include "filesystem.h" #include "iinput.h" #include <vgui/IInputInternal.h> extern vgui::IInputInternal *g_InputInternal; // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" #define VGUI_SCREEN_MODE_RADIUS 80 //Precache the materials CLIENTEFFECT_REGISTER_BEGIN( PrecacheEffectVGuiScreen ) CLIENTEFFECT_MATERIAL( "engine/writez" ) CLIENTEFFECT_REGISTER_END() // ----------------------------------------------------------------------------- // // This is a cache of preloaded keyvalues. // ----------------------------------------------------------------------------- // CUtlDict<KeyValues*, int> g_KeyValuesCache; KeyValues* CacheKeyValuesForFile( const char *pFilename ) { MEM_ALLOC_CREDIT(); int i = g_KeyValuesCache.Find( pFilename ); if ( i == g_KeyValuesCache.InvalidIndex() ) { KeyValues *rDat = new KeyValues( pFilename ); rDat->LoadFromFile( filesystem, pFilename, NULL ); g_KeyValuesCache.Insert( pFilename, rDat ); return rDat; } else { return g_KeyValuesCache[i]; } } void ClearKeyValuesCache() { MEM_ALLOC_CREDIT(); for ( int i=g_KeyValuesCache.First(); i != g_KeyValuesCache.InvalidIndex(); i=g_KeyValuesCache.Next( i ) ) { g_KeyValuesCache[i]->deleteThis(); } g_KeyValuesCache.Purge(); } IMPLEMENT_CLIENTCLASS_DT(C_VGuiScreen, DT_VGuiScreen, CVGuiScreen) RecvPropFloat( RECVINFO(m_flWidth) ), RecvPropFloat( RECVINFO(m_flHeight) ), RecvPropInt( RECVINFO(m_fScreenFlags) ), RecvPropInt( RECVINFO(m_nPanelName) ), RecvPropInt( RECVINFO(m_nAttachmentIndex) ), RecvPropInt( RECVINFO(m_nOverlayMaterial) ), RecvPropEHandle( RECVINFO(m_hPlayerOwner) ), END_RECV_TABLE() //----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- C_VGuiScreen::C_VGuiScreen() { m_nOldPanelName = m_nPanelName = -1; m_nOldOverlayMaterial = m_nOverlayMaterial = -1; m_nOldPx = m_nOldPy = -1; m_nButtonState = 0; m_bLoseThinkNextFrame = false; m_bAcceptsInput = true; m_WriteZMaterial.Init( "engine/writez", TEXTURE_GROUP_VGUI ); m_OverlayMaterial.Init( m_WriteZMaterial ); } C_VGuiScreen::~C_VGuiScreen() { DestroyVguiScreen(); } //----------------------------------------------------------------------------- // Network updates //----------------------------------------------------------------------------- void C_VGuiScreen::PreDataUpdate( DataUpdateType_t updateType ) { BaseClass::PreDataUpdate( updateType ); m_nOldPanelName = m_nPanelName; m_nOldOverlayMaterial = m_nOverlayMaterial; } void C_VGuiScreen::OnDataChanged( DataUpdateType_t type ) { BaseClass::OnDataChanged( type ); if ((type == DATA_UPDATE_CREATED) || (m_nPanelName != m_nOldPanelName)) { CreateVguiScreen( PanelName() ); m_nButtonState = 0; } // Set up the overlay material if (m_nOldOverlayMaterial != m_nOverlayMaterial) { m_OverlayMaterial.Shutdown(); const char *pMaterialName = GetMaterialNameFromIndex(m_nOverlayMaterial); if (pMaterialName) { m_OverlayMaterial.Init( pMaterialName, TEXTURE_GROUP_VGUI ); } else { m_OverlayMaterial.Init( m_WriteZMaterial ); } } } void FormatViewModelAttachment( Vector &vOrigin, bool bInverse ); //----------------------------------------------------------------------------- // Returns the attachment render origin + origin //----------------------------------------------------------------------------- void C_VGuiScreen::GetAimEntOrigin( IClientEntity *pAttachedTo, Vector *pOrigin, QAngle *pAngles ) { C_BaseEntity *pEnt = pAttachedTo->GetBaseEntity(); if (pEnt && (m_nAttachmentIndex > 0)) { { C_BaseAnimating::AutoAllowBoneAccess boneaccess( true, true ); pEnt->GetAttachment( m_nAttachmentIndex, *pOrigin, *pAngles ); } if ( IsAttachedToViewModel() ) { FormatViewModelAttachment( *pOrigin, true ); } } else { BaseClass::GetAimEntOrigin( pAttachedTo, pOrigin, pAngles ); } } //----------------------------------------------------------------------------- // Create, destroy vgui panels... //----------------------------------------------------------------------------- void C_VGuiScreen::CreateVguiScreen( const char *pTypeName ) { // Clear out any old screens. DestroyVguiScreen(); AddEFlags( EFL_USE_PARTITION_WHEN_NOT_SOLID ); // Create the new screen... VGuiScreenInitData_t initData( this ); m_PanelWrapper.Activate( pTypeName, NULL, 0, &initData ); // Retrieve the panel dimensions vgui::Panel *pPanel = m_PanelWrapper.GetPanel(); if (pPanel) { int x, y; pPanel->GetBounds( x, y, m_nPixelWidth, m_nPixelHeight ); } else { m_nPixelWidth = m_nPixelHeight = 0; } } void C_VGuiScreen::DestroyVguiScreen( ) { m_PanelWrapper.Deactivate(); } //----------------------------------------------------------------------------- // Is the screen active? //----------------------------------------------------------------------------- bool C_VGuiScreen::IsActive() const { return (m_fScreenFlags & VGUI_SCREEN_ACTIVE) != 0; } //----------------------------------------------------------------------------- // Purpose: // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool C_VGuiScreen::IsAttachedToViewModel() const { return (m_fScreenFlags & VGUI_SCREEN_ATTACHED_TO_VIEWMODEL) != 0; } //----------------------------------------------------------------------------- // Purpose: // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool C_VGuiScreen::AcceptsInput() const { return m_bAcceptsInput; } //----------------------------------------------------------------------------- // Purpose: // Input : acceptsinput - //----------------------------------------------------------------------------- void C_VGuiScreen::SetAcceptsInput( bool acceptsinput ) { m_bAcceptsInput = acceptsinput; } //----------------------------------------------------------------------------- // Purpose: // Output : RenderGroup_t //----------------------------------------------------------------------------- RenderGroup_t C_VGuiScreen::GetRenderGroup() { if ( IsAttachedToViewModel() ) return RENDER_GROUP_VIEW_MODEL_TRANSLUCENT; return BaseClass::GetRenderGroup(); } //----------------------------------------------------------------------------- // Are we only visible to teammates? //----------------------------------------------------------------------------- bool C_VGuiScreen::IsVisibleOnlyToTeammates() const { return (m_fScreenFlags & VGUI_SCREEN_VISIBLE_TO_TEAMMATES) != 0; } //----------------------------------------------------------------------------- // Are we visible to someone on this team? //----------------------------------------------------------------------------- bool C_VGuiScreen::IsVisibleToTeam( int nTeam ) { // FIXME: Should this maybe go into a derived class of some sort? // Don't bother with screens on the wrong team if (IsVisibleOnlyToTeammates() && (nTeam > 0)) { // Hmmm... sort of a hack... C_BaseEntity *pOwner = GetOwnerEntity(); if ( pOwner && (nTeam != pOwner->GetTeamNumber()) ) return false; } return true; } //----------------------------------------------------------------------------- // Activate, deactivate the view screen //----------------------------------------------------------------------------- void C_VGuiScreen::GainFocus( ) { SetNextClientThink( CLIENT_THINK_ALWAYS ); m_bLoseThinkNextFrame = false; m_nOldButtonState = 0; } void C_VGuiScreen::LoseFocus() { m_bLoseThinkNextFrame = true; m_nOldButtonState = 0; } void C_VGuiScreen::SetButtonState( int nButtonState ) { m_nButtonState = nButtonState; } //----------------------------------------------------------------------------- // Returns the panel name //----------------------------------------------------------------------------- const char *C_VGuiScreen::PanelName() const { return g_StringTableVguiScreen->GetString( m_nPanelName ); } //-------------------------------------------------------------------------- // Purpose: // Given a field of view and mouse/screen positions as well as the current // render origin and angles, returns a unit vector through the mouse position // that can be used to trace into the world under the mouse click pixel. // Input : // mousex - // mousey - // fov - // vecRenderOrigin - // vecRenderAngles - // Output : // vecPickingRay //-------------------------------------------------------------------------- void ScreenToWorld( int mousex, int mousey, float fov, const Vector& vecRenderOrigin, const QAngle& vecRenderAngles, Vector& vecPickingRay ) { float dx, dy; float c_x, c_y; float dist; Vector vpn, vup, vright; float scaled_fov = ScaleFOVByWidthRatio( fov, engine->GetScreenAspectRatio() * 0.75f ); c_x = ScreenWidth() / 2; c_y = ScreenHeight() / 2; dx = (float)mousex - c_x; // Invert Y dy = c_y - (float)mousey; //Tony; fix for 2008 express. why this is an issue, is unbeknownst to me. - http://developer.valvesoftware.com/cgi-bin/bugzilla/show_bug.cgi?id=214 // Convert view plane distance //dist = c_x / tan( M_PI * scaled_fov / 360.0 ); float dist_denom = tan(M_PI * scaled_fov / 360.0f); dist = c_x / dist_denom; // Decompose view angles AngleVectors( vecRenderAngles, &vpn, &vright, &vup ); // Offset forward by view plane distance, and then by pixel offsets vecPickingRay = vpn * dist + vright * ( dx ) + vup * ( dy ); // Convert to unit vector VectorNormalize( vecPickingRay ); } //----------------------------------------------------------------------------- // Purpose: Deal with input //----------------------------------------------------------------------------- void C_VGuiScreen::ClientThink( void ) { int nButtonsChanged = m_nOldButtonState ^ m_nButtonState; m_nOldButtonState = m_nButtonState; // Debounced button codes for pressed/released // UNDONE: Do we need auto-repeat? m_nButtonPressed = nButtonsChanged & m_nButtonState; // The changed ones still down are "pressed" m_nButtonReleased = nButtonsChanged & (~m_nButtonState); // The ones not down are "released" BaseClass::ClientThink(); // FIXME: We should really be taking bob, shake, and roll into account // but if we did, then all the inputs would be generated multiple times // if the world was rendered multiple times (for things like water, etc.) vgui::Panel *pPanel = m_PanelWrapper.GetPanel(); if (!pPanel) return; C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer(); if (!pLocalPlayer) return; // Generate a ray along the view direction Vector vecEyePosition = pLocalPlayer->EyePosition(); QAngle viewAngles = pLocalPlayer->EyeAngles( ); // Compute cursor position... Ray_t lookDir; Vector endPos; float u, v; // Viewmodel attached screens that take input need to have a moving cursor // Do a pick under the cursor as our selection Vector viewDir; AngleVectors( viewAngles, &viewDir ); VectorMA( vecEyePosition, 1000.0f, viewDir, endPos ); lookDir.Init( vecEyePosition, endPos ); if (!IntersectWithRay( lookDir, &u, &v, NULL )) return; if ( ((u < 0) || (v < 0) || (u > 1) || (v > 1)) && !m_bLoseThinkNextFrame) return; // This will cause our panel to grab all input! g_pClientMode->ActivateInGameVGuiContext( pPanel ); // Convert (u,v) into (px,py) int px = (int)(u * m_nPixelWidth + 0.5f); int py = (int)(v * m_nPixelHeight + 0.5f); // Generate mouse input commands if ((px != m_nOldPx) || (py != m_nOldPy)) { g_InputInternal->InternalCursorMoved( px, py ); m_nOldPx = px; m_nOldPy = py; } if (m_nButtonPressed & IN_ATTACK) { g_InputInternal->SetMouseCodeState( MOUSE_LEFT, vgui::BUTTON_PRESSED ); g_InputInternal->InternalMousePressed(MOUSE_LEFT); } if (m_nButtonPressed & IN_ATTACK2) { g_InputInternal->SetMouseCodeState( MOUSE_RIGHT, vgui::BUTTON_PRESSED ); g_InputInternal->InternalMousePressed( MOUSE_RIGHT ); } if ( (m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus { g_InputInternal->SetMouseCodeState( MOUSE_LEFT, vgui::BUTTON_RELEASED ); g_InputInternal->InternalMouseReleased( MOUSE_LEFT ); } if (m_nButtonReleased & IN_ATTACK2) { g_InputInternal->SetMouseCodeState( MOUSE_RIGHT, vgui::BUTTON_RELEASED ); g_InputInternal->InternalMouseReleased( MOUSE_RIGHT ); } if ( m_bLoseThinkNextFrame == true ) { m_bLoseThinkNextFrame = false; SetNextClientThink( CLIENT_THINK_NEVER ); } g_pClientMode->DeactivateInGameVGuiContext( ); } //----------------------------------------------------------------------------- // Computes control points of the quad describing the screen //----------------------------------------------------------------------------- void C_VGuiScreen::ComputeEdges( Vector *pUpperLeft, Vector *pUpperRight, Vector *pLowerLeft ) { Vector vecOrigin = GetAbsOrigin(); Vector xaxis, yaxis; AngleVectors( GetAbsAngles(), &xaxis, &yaxis, NULL ); // NOTE: Have to multiply by -1 here because yaxis goes out the -y axis in AngleVectors actually... yaxis *= -1.0f; VectorCopy( vecOrigin, *pLowerLeft ); VectorMA( vecOrigin, m_flHeight, yaxis, *pUpperLeft ); VectorMA( *pUpperLeft, m_flWidth, xaxis, *pUpperRight ); } //----------------------------------------------------------------------------- // Return intersection point of ray with screen in barycentric coords //----------------------------------------------------------------------------- bool C_VGuiScreen::IntersectWithRay( const Ray_t &ray, float *u, float *v, float *t ) { // Perform a raycast to see where in barycentric coordinates the ray hits // the viewscreen; if it doesn't hit it, you're not in the mode Vector origin, upt, vpt; ComputeEdges( &origin, &upt, &vpt ); return ComputeIntersectionBarycentricCoordinates( ray, origin, upt, vpt, *u, *v, t ); } //----------------------------------------------------------------------------- // Is the vgui screen backfacing? //----------------------------------------------------------------------------- bool C_VGuiScreen::IsBackfacing( const Vector &viewOrigin ) { // Compute a ray from camera to center of the screen.. Vector cameraToScreen; VectorSubtract( GetAbsOrigin(), viewOrigin, cameraToScreen ); // Figure out the face normal Vector zaxis; GetVectors( NULL, NULL, &zaxis ); // The actual backface cull return (DotProduct( zaxis, cameraToScreen ) > 0.0f); } //----------------------------------------------------------------------------- // Computes the panel center to world transform //----------------------------------------------------------------------------- void C_VGuiScreen::ComputePanelToWorld() { // The origin is at the upper-left corner of the screen Vector vecOrigin, vecUR, vecLL; ComputeEdges( &vecOrigin, &vecUR, &vecLL ); m_PanelToWorld.SetupMatrixOrgAngles( vecOrigin, GetAbsAngles() ); } //----------------------------------------------------------------------------- // a pass to set the z buffer... //----------------------------------------------------------------------------- void C_VGuiScreen::DrawScreenOverlay() { CMatRenderContextPtr pRenderContext( materials ); pRenderContext->MatrixMode( MATERIAL_MODEL ); pRenderContext->PushMatrix(); pRenderContext->LoadMatrix( m_PanelToWorld ); unsigned char pColor[4] = {255, 255, 255, 255}; CMeshBuilder meshBuilder; IMesh *pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, m_OverlayMaterial ); meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); meshBuilder.Position3f( 0.0f, 0.0f, 0 ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.Color4ubv( pColor ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( m_flWidth, 0.0f, 0 ); meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); meshBuilder.Color4ubv( pColor ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( m_flWidth, -m_flHeight, 0 ); meshBuilder.TexCoord2f( 0, 1.0f, 1.0f ); meshBuilder.Color4ubv( pColor ); meshBuilder.AdvanceVertex(); meshBuilder.Position3f( 0.0f, -m_flHeight, 0 ); meshBuilder.TexCoord2f( 0, 0.0f, 1.0f ); meshBuilder.Color4ubv( pColor ); meshBuilder.AdvanceVertex(); meshBuilder.End(); pMesh->Draw(); pRenderContext->PopMatrix(); } //----------------------------------------------------------------------------- // Draws the panel using a 3D transform... //----------------------------------------------------------------------------- int C_VGuiScreen::DrawModel( int flags ) { vgui::Panel *pPanel = m_PanelWrapper.GetPanel(); if (!pPanel || !IsActive()) return 0; // Don't bother drawing stuff not visible to me... C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer(); if (!pLocalPlayer || !IsVisibleToTeam(pLocalPlayer->GetTeamNumber()) ) return 0; if ( !IsVisibleToPlayer( pLocalPlayer ) ) { return 0; } // Backface cull the entire panel here... if (IsBackfacing(CurrentViewOrigin())) return 0; // Recompute the panel-to-world center // FIXME: Can this be cached off? ComputePanelToWorld(); g_pMatSystemSurface->DrawPanelIn3DSpace( pPanel->GetVPanel(), m_PanelToWorld, m_nPixelWidth, m_nPixelHeight, m_flWidth, m_flHeight ); // Finally, a pass to set the z buffer... DrawScreenOverlay(); return 1; } bool C_VGuiScreen::ShouldDraw( void ) { return !IsEffectActive(EF_NODRAW); } //----------------------------------------------------------------------------- // Purpose: Hook for vgui screens to determine visibility //----------------------------------------------------------------------------- bool C_VGuiScreen::IsVisibleToPlayer( C_BasePlayer *pViewingPlayer ) { return true; } bool C_VGuiScreen::IsTransparent( void ) { return (m_fScreenFlags & VGUI_SCREEN_TRANSPARENT) != 0; } //----------------------------------------------------------------------------- // Purpose: Sometimes we only want a specific player to be able to input to a panel //----------------------------------------------------------------------------- C_BasePlayer *C_VGuiScreen::GetPlayerOwner( void ) { return ( C_BasePlayer * )( m_hPlayerOwner.Get() ); } bool C_VGuiScreen::IsInputOnlyToOwner( void ) { return (m_fScreenFlags & VGUI_SCREEN_ONLY_USABLE_BY_OWNER) != 0; } //----------------------------------------------------------------------------- // // Enumator class for finding vgui screens close to the local player // //----------------------------------------------------------------------------- class CVGuiScreenEnumerator : public IPartitionEnumerator { DECLARE_CLASS_GAMEROOT( CVGuiScreenEnumerator, IPartitionEnumerator ); public: virtual IterationRetval_t EnumElement( IHandleEntity *pHandleEntity ); int GetScreenCount(); C_VGuiScreen *GetVGuiScreen( int index ); private: CUtlVector< CHandle< C_VGuiScreen > > m_VguiScreens; }; IterationRetval_t CVGuiScreenEnumerator::EnumElement( IHandleEntity *pHandleEntity ) { C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( pHandleEntity->GetRefEHandle() ); if ( pEnt == NULL ) return ITERATION_CONTINUE; // FIXME.. pretty expensive... C_VGuiScreen *pScreen = dynamic_cast<C_VGuiScreen*>(pEnt); if ( pScreen ) { int i = m_VguiScreens.AddToTail( ); m_VguiScreens[i].Set( pScreen ); } return ITERATION_CONTINUE; } int CVGuiScreenEnumerator::GetScreenCount() { return m_VguiScreens.Count(); } C_VGuiScreen *CVGuiScreenEnumerator::GetVGuiScreen( int index ) { return m_VguiScreens[index].Get(); } //----------------------------------------------------------------------------- // // Look for vgui screens, returns true if it found one ... // //----------------------------------------------------------------------------- C_BaseEntity *FindNearbyVguiScreen( const Vector &viewPosition, const QAngle &viewAngle, int nTeam ) { if ( IsX360() ) { // X360TBD: Turn this on if feature actually used return NULL; } C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer(); Assert( pLocalPlayer ); if ( !pLocalPlayer ) return NULL; // Get the view direction... Vector lookDir; AngleVectors( viewAngle, &lookDir ); // Create a ray used for raytracing Vector lookEnd; VectorMA( viewPosition, 2.0f * VGUI_SCREEN_MODE_RADIUS, lookDir, lookEnd ); Ray_t lookRay; lookRay.Init( viewPosition, lookEnd ); // Look for vgui screens that are close to the player CVGuiScreenEnumerator localScreens; partition->EnumerateElementsInSphere( PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens ); Vector vecOut, vecViewDelta; float flBestDist = 2.0f; C_VGuiScreen *pBestScreen = NULL; for (int i = localScreens.GetScreenCount(); --i >= 0; ) { C_VGuiScreen *pScreen = localScreens.GetVGuiScreen(i); if ( pScreen->IsAttachedToViewModel() ) continue; // Don't bother with screens I'm behind... // Hax - don't cancel backfacing with viewmodel attached screens. // we can get prediction bugs that make us backfacing for one frame and // it resets the mouse position if we lose focus. if ( pScreen->IsBackfacing(viewPosition) ) continue; // Don't bother with screens that are turned off if (!pScreen->IsActive()) continue; // FIXME: Should this maybe go into a derived class of some sort? // Don't bother with screens on the wrong team if (!pScreen->IsVisibleToTeam(nTeam)) continue; if ( !pScreen->AcceptsInput() ) continue; if ( pScreen->IsInputOnlyToOwner() && pScreen->GetPlayerOwner() != pLocalPlayer ) continue; // Test perpendicular distance from the screen... pScreen->GetVectors( NULL, NULL, &vecOut ); VectorSubtract( viewPosition, pScreen->GetAbsOrigin(), vecViewDelta ); float flPerpDist = DotProduct(vecViewDelta, vecOut); if ( (flPerpDist < 0) || (flPerpDist > VGUI_SCREEN_MODE_RADIUS) ) continue; // Perform a raycast to see where in barycentric coordinates the ray hits // the viewscreen; if it doesn't hit it, you're not in the mode float u, v, t; if (!pScreen->IntersectWithRay( lookRay, &u, &v, &t )) continue; // Barycentric test if ((u < 0) || (v < 0) || (u > 1) || (v > 1)) continue; if ( t < flBestDist ) { flBestDist = t; pBestScreen = pScreen; } } return pBestScreen; } void ActivateVguiScreen( C_BaseEntity *pVguiScreenEnt ) { if (pVguiScreenEnt) { Assert( dynamic_cast<C_VGuiScreen*>(pVguiScreenEnt) ); C_VGuiScreen *pVguiScreen = static_cast<C_VGuiScreen*>(pVguiScreenEnt); pVguiScreen->GainFocus( ); } } void SetVGuiScreenButtonState( C_BaseEntity *pVguiScreenEnt, int nButtonState ) { if (pVguiScreenEnt) { Assert( dynamic_cast<C_VGuiScreen*>(pVguiScreenEnt) ); C_VGuiScreen *pVguiScreen = static_cast<C_VGuiScreen*>(pVguiScreenEnt); pVguiScreen->SetButtonState( nButtonState ); } } void DeactivateVguiScreen( C_BaseEntity *pVguiScreenEnt ) { if (pVguiScreenEnt) { Assert( dynamic_cast<C_VGuiScreen*>(pVguiScreenEnt) ); C_VGuiScreen *pVguiScreen = static_cast<C_VGuiScreen*>(pVguiScreenEnt); pVguiScreen->LoseFocus( ); } } CVGuiScreenPanel::CVGuiScreenPanel( vgui::Panel *parent, const char *panelName ) : BaseClass( parent, panelName ) { m_hEntity = NULL; } CVGuiScreenPanel::CVGuiScreenPanel( vgui::Panel *parent, const char *panelName, vgui::HScheme hScheme ) : BaseClass( parent, panelName, hScheme ) { m_hEntity = NULL; } bool CVGuiScreenPanel::Init( KeyValues* pKeyValues, VGuiScreenInitData_t* pInitData ) { const char *pResFile = pKeyValues->GetString( "resfile" ); if (pResFile[0] != 0) { KeyValues *pCachedKeyValues = CacheKeyValuesForFile( pResFile ); LoadControlSettings( pResFile, NULL, pCachedKeyValues ); } // Dimensions in pixels int nWidth, nHeight; nWidth = pKeyValues->GetInt( "pixelswide", 240 ); nHeight = pKeyValues->GetInt( "pixelshigh", 160 ); if ((nWidth <= 0) || (nHeight <= 0)) return false; // If init data isn't specified, then we're just precaching. if ( pInitData ) { m_hEntity.Set( pInitData->m_pEntity ); C_VGuiScreen *screen = dynamic_cast< C_VGuiScreen * >( pInitData->m_pEntity ); if ( screen ) { bool acceptsInput = pKeyValues->GetInt( "acceptsinput", 1 ) ? true : false; screen->SetAcceptsInput( acceptsInput ); } } SetBounds( 0, 0, nWidth, nHeight ); return true; } vgui::Panel *CVGuiScreenPanel::CreateControlByName(const char *controlName) { // Check the panel metaclass manager to make these controls... if (!Q_strncmp(controlName, "MaterialImage", 20)) { return new CBitmapPanel(NULL, "BitmapPanel"); } if (!Q_strncmp(controlName, "MaterialButton", 20)) { return new CBitmapButton(NULL, "BitmapButton", ""); } // Didn't find it? Just use the default stuff return BaseClass::CreateControlByName( controlName ); } //----------------------------------------------------------------------------- // Purpose: Called when the user presses a button //----------------------------------------------------------------------------- void CVGuiScreenPanel::OnCommand( const char *command) { if ( Q_stricmp( command, "vguicancel" ) ) { engine->ClientCmd( const_cast<char *>( command ) ); } BaseClass::OnCommand(command); } DECLARE_VGUI_SCREEN_FACTORY( CVGuiScreenPanel, "vgui_screen_panel" );
[ "nkerns25@yahoo.com" ]
nkerns25@yahoo.com
b9ef27592adb4cebed2b507e83eccb7b61d85d6e
5816ebd0e1ae77a46ac9faf197e79ba50c06d5e8
/src/object.hpp
595d0396cf5cc196239e6b875abd272a5c77e789
[]
no_license
isergeyam/mipt-comp-graph-hw2
9601fbfdb519f6e92e81d36a9ab8fa29d6769025
6d622144a9243a36a874f99793be49123c8054f2
refs/heads/main
2023-04-05T01:44:13.237367
2021-04-16T16:17:33
2021-04-16T16:17:33
358,652,358
0
0
null
null
null
null
UTF-8
C++
false
false
739
hpp
#pragma once #include <GL/glew.h> #include <glm/glm.hpp> #include <random> class Object { public: Object(); void draw(); glm::vec3 getObjectPosition(); public: static bool init(); static void finalize(); public: static constexpr float colliderRadius = 1.0f; private: glm::mat4 ModelMatrix; glm::vec3 position; private: static GLuint vertexBuffer; static GLuint uvBuffer; static GLuint MatrixID; static GLuint programID; static GLuint TextureID; static GLuint Texture; static size_t verticesCount; static std::random_device rd; static std::mt19937 generator; static std::uniform_real_distribution<float> uniform_distrib; static std::uniform_real_distribution<float> uniform_distrib_angle; };
[ "isergey.am@gmail.com" ]
isergey.am@gmail.com
71fccb19180890db4a57ae4c9b874038ee91ee80
9ac8b9942a7428c45f33e644005055ca6bf7897e
/Re audio/C_SDL.h
fdf15895c210f134a217433f2c324403d7528d62
[]
no_license
Glitched-Manual/Downtime-1.0
26361b4d6eddc9489177cb87d98674250587d254
79c58f6b95fde4d864d431c0296da10c66807afe
refs/heads/master
2020-04-02T05:13:05.601388
2018-10-22T01:50:18
2018-10-22T01:50:18
154,058,525
1
0
null
null
null
null
UTF-8
C++
false
false
2,535
h
#pragma once #ifndef _C_SDL_H #define _C_SDL_H #include <SDL.h> #include <SDL_image.h> #include <SDL_mixer.h> #include <stdio.h> #include <string> #include <SDL_ttf.h> #include <stdio.h> #include <cstring> #include <cmath> #include <iostream> #include <filesystem> using std::cin; using std::cout; /* *This source code copyrighted by Lazy Foo' Productions (2004-2015) and may not be redistributed without written permission.*/ //Using SDL, SDL_image, SDL_ttf, SDL_mixer, standard IO, math, and strings //Screen dimension constants const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; //Texture wrapper class class LTexture { public: //Initializes variables LTexture(); //Deallocates memory ~LTexture(); //Loads image at specified path virtual bool loadFromFile(std::string path) = 0; virtual bool loadFromFile_sub(std::string path) = 0; #ifdef _SDL_TTF_H //Creates image from font string virtual bool loadFromRenderedText(std::string textureText, SDL_Color textColor) = 0; virtual bool loadFromRenderedText_sub(std::string textureText, SDL_Color textColor) = 0; #endif //Deallocates texture virtual void free()=0; virtual void free_sub()=0; //Set color modulation virtual void setColor(Uint8 red, Uint8 green, Uint8 blue) = 0; virtual void setColor_sub(Uint8 red, Uint8 green, Uint8 blue) = 0; //Set blending virtual void setBlendMode(SDL_BlendMode blending) = 0; virtual void setBlendMode_sub(SDL_BlendMode blending) = 0; //Set alpha modulation virtual void setAlpha(Uint8 alpha) = 0; virtual void setAlpha_sub(Uint8 alpha) = 0; void createWindow(); void createRenderer(); //Renders texture at given point virtual void render(int x, int y, SDL_Rect* clip = NULL, double angle = 0.0, SDL_Point* center = NULL, SDL_RendererFlip flip = SDL_FLIP_NONE) =0; virtual void render_sub(int x, int y, SDL_Rect* clip = NULL, double angle = 0.0, SDL_Point* center = NULL, SDL_RendererFlip flip = SDL_FLIP_NONE) = 0; //Gets image dimensions SDL_Window* getWindow(); SDL_Renderer* getRenderer(); void clearWindow(); void clearRenderer(); //Starts up SDL and creates window bool init(); //Frees media and shuts down SDL void endSDL(); protected: //The window we'll be rendering to SDL_Window* gWindow = NULL; //The window renderer SDL_Renderer* gRenderer = NULL; private: //The actual hardware texture SDL_Texture* mTexture; SDL_Texture* sTexture; //Image dimensions int mWidth; int mHeight; int sWidth; int sHeight; }; #endif _C_SDL_H
[ "popcorneater720@gmail.com" ]
popcorneater720@gmail.com
98de1737f70ac6800ba95dcaeb23da257dee539e
9b40f4863166327b0d51a83459ed8e271b4e8e57
/Basic_Algorithm/kth.cpp
0e5be390b72ab414ccc77105d608c7e79b1bb798
[]
no_license
3378950/Algorithm-Template
20d576440eaca54d7497984112a1cc9174037ecb
115254c9c1a325afdcaea76db031c646cbcc6783
refs/heads/master
2022-11-25T04:37:28.968518
2020-08-05T06:43:37
2020-08-05T06:43:37
261,932,020
0
0
null
null
null
null
UTF-8
C++
false
false
577
cpp
#include <iostream> #include <algorithm> const int N = 1e6 + 10; int a[N]; int qs(int l, int r, int k) { if(l >= r) return a[l]; int x = a[(l + r) >> 1], i = l - 1, j = r + 1; while(i < j) { do i++; while(a[i] < x); do j--; while(a[j] > x); if(i < j) std::swap(a[i], a[j]); } int s = j - l + 1; if(s >= k) return qs(l, j, k); else return qs(j + 1, r, k - s); } int main() { int n, k; scanf("%d%d", &n, &k); for(int i = 0; i < n; i++) scanf("%d", &a[i]); std::cout << qs(0, n - 1, k); return 0; }
[ "374008063@qq.com" ]
374008063@qq.com
e6103434874e3f333c2383afe1c56c8198efbe41
ba7f34c45b7bf65b9f38c1dd561d133fa645e540
/include/Solver.h
b2fdb7f253ee732e524457970f30a4ae12009425
[]
no_license
khbence/GSLMultiRoot
d363ea650e05b2c5d6ded571c4b79dcdbef9e806
cb1ed0ec3df527c22756d23823c4902bd2195629
refs/heads/master
2021-05-16T21:28:38.344222
2020-03-27T09:19:44
2020-03-27T09:19:44
250,476,149
0
0
null
null
null
null
UTF-8
C++
false
false
2,284
h
#pragma once #include <iostream> #include "GSLVector.h" #include <gsl/gsl_multiroots.h> #include <memory> //TODO make CRTP to reach F directly class SimpleMethod { protected: using solverType = gsl_multiroot_fsolver; static void deleteSolver(solverType* ptr) { gsl_multiroot_fsolver_free(ptr); } solverType* allocateSolver(unsigned N) { return gsl_multiroot_fsolver_alloc(gsl_multiroot_fsolver_hybrids, N); } void setSolver(solverType* method, gsl_multiroot_function* F, gsl_vector* x_init) { gsl_multiroot_fsolver_set(method, F, x_init); } inline int iterate(solverType* method) { return gsl_multiroot_fsolver_iterate(method); } inline int test(solverType* method, double precision) { return gsl_multiroot_test_residual(method->f, precision); } }; template<typename Equation, typename Parameters, typename Method = SimpleMethod> class Solver : public Method { struct methodDeleter { void operator()(typename Method::solverType* ptr) { Method::deleteSolver(ptr); } }; using arrayType = typename std::result_of<Equation(const gsl_vector*, Parameters*)>::type; static constexpr size_t N = arrayType().size(); std::unique_ptr<typename Method::solverType, methodDeleter> method{Method::allocateSolver(N), methodDeleter{}}; gsl_multiroot_function F; static int system(const gsl_vector* x, void* params, gsl_vector* f) { Parameters* p = reinterpret_cast<Parameters*>(params); std::array<double, N> result = Equation()(x, p); for(size_t i = 0; i < N; ++i) gsl_vector_set(f, i, result[i]); return GSL_SUCCESS; } public: Solver() : Method() { F.f = system; F.n = N; } std::array<double, N> solve(std::array<double, N> initValues, Parameters& params, double precision = 1e-7) { F.params = &params; Method::setSolver(method.get(), &F, GSLVector{initValues}.getPointer()); int status = 1; do { status = Method::iterate(method.get()); if(status != GSL_SUCCESS) break; status = Method::test(method.get(), precision); } while(status == GSL_CONTINUE); std::array<double, N> ret; for(size_t i = 0; i < N; ++i) ret[i] = gsl_vector_get(method->x, i); return ret; } };
[ "horvathb94@gmail.com" ]
horvathb94@gmail.com
0c218f55cbc6b689c6ab1d5a8115aab99f73667e
16bb1ca4f642a3d9132df34c1a7a9afbc69f1ac5
/TommyGun/Plugins/CodeEditor/SevenuPImageParser/fSevenuPImageParserOptions.cpp
ad1cfd31d9e5ff8acb590629d972b2394565d979
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
tonyt73/TommyGun
6138b81b447da0b448bcecb893ed46cadcf56c80
19e704243bc02500193fe798bd3bee71f75de094
refs/heads/master
2023-03-17T10:19:08.971368
2023-03-11T23:39:37
2023-03-11T23:39:37
89,913,869
41
6
NOASSERTION
2023-03-11T22:41:39
2017-05-01T10:02:20
C++
UTF-8
C++
false
false
10,269
cpp
/*--------------------------------------------------------------------------- (c) 2004 Scorpio Software 19 Wittama Drive Glenmore Park Sydney NSW 2745 Australia ----------------------------------------------------------------------------- $Workfile:: $ $Revision:: $ $Date:: $ $Author:: $ ---------------------------------------------------------------------------*/ //--------------------------------------------------------------------------- #include "pch.h" #pragma hdrstop //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" #pragma link "KXmlInfo" //--------------------------------------------------------------------------- using namespace Scorpio; using namespace ImageParser; //--------------------------------------------------------------------------- TfrmSevenuPImageParserOptions *frmSevenuPImageParserOptions = NULL; //--------------------------------------------------------------------------- __fastcall TfrmSevenuPImageParserOptions::TfrmSevenuPImageParserOptions(TComponent* Owner) : TForm(Owner) , m_pPlugin(NULL) , m_DataOutputted(doGraphicsAttributes) , m_Compiler(asmGeneric) , m_NumberBase(nbHexidecimal) , m_Interleave(iSprite) , m_MaskBefore(false) { m_Prefixes[0] = ""; // decimal m_Prefixes[1] = "0x"; // hexidecimal m_Prefixes[2] = "%"; // binary m_Prefixes[3] = "0"; // octal m_Postfixes[0] = ""; // decimal m_Postfixes[1] = ""; // hexidecimal m_Postfixes[2] = ""; // binary m_Postfixes[3] = ""; // octal radSourceCodeC->Checked = true; } //--------------------------------------------------------------------------- HRESULT __fastcall TfrmSevenuPImageParserOptions::Initialize(ZXPlugin* pPlugin) { RL_HRESULT(S_OK); m_pPlugin = pPlugin; return hResult; } //--------------------------------------------------------------------------- HRESULT __fastcall TfrmSevenuPImageParserOptions::Release(void) { RL_HRESULT(S_OK); return hResult; } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::radSourceCodeAsmClick(TObject *Sender) { lblPrefix->Enabled = radSourceCodeAsm->Checked; edtPrefix->Enabled = radSourceCodeAsm->Checked; chkSourceCodeUseLabel->Enabled = radSourceCodeAsm->Checked; radBinary->Enabled = radSourceCodeAsm->Checked; lblLabelPrefix->Enabled = radSourceCodeAsm->Checked && chkSourceCodeUseLabel->Checked; lblLabelPostfix->Enabled = radSourceCodeAsm->Checked && chkSourceCodeUseLabel->Checked; edtLabelPrefix->Enabled = radSourceCodeAsm->Checked && chkSourceCodeUseLabel->Checked; edtLabelPostfix->Enabled = radSourceCodeAsm->Checked && chkSourceCodeUseLabel->Checked; lblExample->Enabled = radSourceCodeAsm->Checked && chkSourceCodeUseLabel->Checked; radHexidecimal->Checked |= radBinary->Checked; m_Compiler = asmGeneric; if (radSourceCodeC->Checked) { m_Compiler = cGeneric; } } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::chkMaskingAttributeMaskClick(TObject *Sender) { chkMaskingAttributeInk->Enabled = chkMaskingAttributeMask->Checked; chkMaskingAttributePaper->Enabled = chkMaskingAttributeMask->Checked; chkMaskingAttributeBright->Enabled = chkMaskingAttributeMask->Checked; chkMaskingAttributeFlash->Enabled = chkMaskingAttributeMask->Checked; UpdateAttributeMask(); } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::chkMaskingAttributeInkClick(TObject *Sender) { UpdateAttributeMask(); } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::edtNumberBasePrefixChange(TObject *Sender) { m_Prefixes[m_NumberBase] = edtNumberBasePrefix->Text; UpdateExample(); } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::edtNumberBasePostfixChange(TObject *Sender) { m_Postfixes[m_NumberBase] = edtNumberBasePostfix->Text; UpdateExample(); } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::radDataGraphicsAttributesClick(TObject *Sender) { TRadioButton* Button = dynamic_cast<TRadioButton*>(Sender); if (Button) { m_DataOutputted = (eDataOutputted)Button->Tag; } } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::radDecimalClick(TObject *Sender) { TRadioButton* Button = dynamic_cast<TRadioButton*>(Sender); if (Button) { m_NumberBase = (eNumberBase)Button->Tag; edtNumberBasePrefix->Text = m_Prefixes[m_NumberBase]; edtNumberBasePostfix->Text = m_Postfixes[m_NumberBase]; UpdateExample(); } } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::radInterleaveLineClick(TObject *Sender) { TRadioButton* Button = dynamic_cast<TRadioButton*>(Sender); if (Button) { m_Interleave = (eInterleave)Button->Tag; } } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::radAssemblerGenericClick(TObject *Sender) { TRadioButton* Button = dynamic_cast<TRadioButton*>(Sender); if (Button) { m_Compiler = (eCompiler)Button->Tag; } } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::lstByteSortPriorityClick(TObject *Sender) { cmdSortListMoveUp->Enabled = lstByteSortPriority->ItemIndex > 0; cmdSortListMoveDown->Enabled = lstByteSortPriority->ItemIndex >=0 && lstByteSortPriority->ItemIndex < 4; } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::cmdSortListMoveUpClick(TObject *Sender) { int ItemIndex = lstByteSortPriority->ItemIndex; String tmp = lstByteSortPriority->Items->Strings[lstByteSortPriority->ItemIndex]; lstByteSortPriority->Items->Strings[lstByteSortPriority->ItemIndex] = lstByteSortPriority->Items->Strings[lstByteSortPriority->ItemIndex - 1]; lstByteSortPriority->Items->Strings[lstByteSortPriority->ItemIndex - 1] = tmp; lstByteSortPriority->ItemIndex = ItemIndex - 1; lstByteSortPriorityClick(Sender); } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::cmdSortListMoveDownClick(TObject *Sender) { int ItemIndex = lstByteSortPriority->ItemIndex; String tmp = lstByteSortPriority->Items->Strings[lstByteSortPriority->ItemIndex]; lstByteSortPriority->Items->Strings[lstByteSortPriority->ItemIndex] = lstByteSortPriority->Items->Strings[lstByteSortPriority->ItemIndex + 1]; lstByteSortPriority->Items->Strings[lstByteSortPriority->ItemIndex + 1] = tmp; lstByteSortPriority->ItemIndex = ItemIndex + 1; lstByteSortPriorityClick(Sender); } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::cmdListDefaultClick(TObject *Sender) { lstByteSortPriority->Items->Strings[0] = "X Char"; lstByteSortPriority->Items->Strings[1] = "Char Line"; lstByteSortPriority->Items->Strings[2] = "Y Char"; lstByteSortPriority->Items->Strings[3] = "Mask"; lstByteSortPriority->Items->Strings[4] = "Frame Number"; } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::UpdateExample(void) { String Value; switch(m_NumberBase) { case nbHexidecimal: Value = "7B"; break; case nbBinary: Value = "1111011"; break; case nbOctal: Value = "173"; break; case nbDecimal: default: Value = "123"; break; } lblExampleValue->Caption = edtNumberBasePrefix->Text + Value + edtNumberBasePostfix->Text; } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::UpdateAttributeMask(void) { m_AttributeMask = 0; m_AttributeMask |= chkMaskingAttributeInk->Checked ? 0x07 : 0x00; m_AttributeMask |= chkMaskingAttributePaper->Checked ? 0x38 : 0x00; m_AttributeMask |= chkMaskingAttributeBright->Checked ? 0x40 : 0x00; m_AttributeMask |= chkMaskingAttributeFlash->Checked ? 0x80 : 0x00; } //--------------------------------------------------------------------------- String __fastcall TfrmSevenuPImageParserOptions::GetPrefix(int NumberBase) { return m_Prefixes[NumberBase]; } //--------------------------------------------------------------------------- String __fastcall TfrmSevenuPImageParserOptions::GetPostfix(int NumberBase) { return m_Postfixes[NumberBase]; } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::chkMaskingBeforeGraphicsClick(TObject *Sender) { m_MaskBefore = chkMaskingBeforeGraphics->Checked; } //--------------------------------------------------------------------------- String __fastcall TfrmSevenuPImageParserOptions::GetAsmPrefix() { return edtPrefix->Text; } //--------------------------------------------------------------------------- void __fastcall TfrmSevenuPImageParserOptions::edtLabelPostfixChange(TObject *Sender) { lblExample->Caption = edtLabelPrefix->Text + "MyLabel" + edtLabelPostfix->Text; } //---------------------------------------------------------------------------
[ "tonyt73@gmail.com" ]
tonyt73@gmail.com
cba109b36f6963dc8e8298c4b76aaa24007486a3
b91bf644e3ef5d78bda0fbf1c828386f343e1e36
/LineParser.hh
fe698fc5a07b08671fdd5480de11cc6d994bd05d
[]
no_license
1059444127/blobfs
0db702ff9952091ae27ea35f7a4f1ecf6f4c8a53
53315a435f1778603f805ac7b2a8d21c0e5f7844
refs/heads/master
2021-01-01T18:40:13.344350
2009-01-28T15:35:03
2009-01-28T15:35:03
98,400,876
1
0
null
2017-07-26T08:47:34
2017-07-26T08:47:34
null
UTF-8
C++
false
false
3,620
hh
#ifndef _LINEPARSER_HH_ #define _LINEPARSER_HH_ #include <stdarg.h> #include <stdlib.h> #include <exception> #include <iostream> #include <string> using namespace std; // TODO Move to util class? static string buildMessage(const string msg, va_list ap) throw() { size_t maxsize = 128; char *buf = static_cast<char *>(malloc(maxsize)); size_t size = vsnprintf(buf, maxsize, msg.c_str(), ap); if (size >= maxsize) { buf = static_cast<char *>(realloc(buf, size)); vsnprintf(buf, maxsize, msg.c_str(), ap); } string s = string(buf); return s; } // TODO Move to separate files class ParseError : public exception { private: string msg; public: ParseError(const string msg, ...) throw() { va_list ap; va_start(ap, msg); this->msg = buildMessage(msg, ap); va_end(ap); } ~ParseError() throw() { } const char *what() const throw() { return msg.c_str(); } }; class LineParser { private: const string line; enum { SKIP_INITIAL_SPACE, PARSE_KEY, SKIP_SPACE_AFTER_KEY, SKIP_EQUALS_SIGN, SKIP_SPACE_AFTER_EQUALS_SIGN, PARSE_VALUE, SKIP_SPACE_AFTER_VALUE } state; size_t idx; string key; string val; bool isvalidchar(int c) throw() { return c == '.' || isalnum(c); } void process(size_t i, const char c) throw(ParseError) { switch (state) { case SKIP_INITIAL_SPACE: if (isspace(c)) { // NOP } else if (isvalidchar(c)) { state = PARSE_KEY; idx = i; } else { throw ParseError("Invalid character '%c': pos %zu line '%s'", c, i, line.c_str()); } break; case PARSE_KEY: if (isvalidchar(c)) { // NOP } else if (isspace(c)) { state = SKIP_SPACE_AFTER_KEY; key = line.substr(idx, i - idx); } else if (c == '=') { state = SKIP_EQUALS_SIGN; key = line.substr(idx, i - idx); } else { throw ParseError("Invalid character '%c': pos %zu line '%s'", c, i, line.c_str()); } break; case SKIP_SPACE_AFTER_KEY: if (isspace(c)) { // NOP } else if (c == '=') { state = SKIP_EQUALS_SIGN; } else { throw ParseError("Invalid character '%c': pos %zu line '%s'", c, i, line.c_str()); } break; case SKIP_EQUALS_SIGN: if (isspace(c)) { state = SKIP_SPACE_AFTER_EQUALS_SIGN; } else if (isvalidchar(c)) { state = PARSE_VALUE; idx = i; } else { throw ParseError("Invalid character '%c': pos %zu line '%s'", c, i, line.c_str()); } break; case SKIP_SPACE_AFTER_EQUALS_SIGN: if (isspace(c)) { // NOP } else if (isvalidchar(c)) { state = PARSE_VALUE; idx = i; } else { throw ParseError("Invalid character '%c': pos %zu line '%s'", c, i, line.c_str()); } break; case PARSE_VALUE: if (isvalidchar(c)) { // NOP } else if (isspace(c)) { state = SKIP_SPACE_AFTER_VALUE; val = line.substr(idx, i - idx); } else { throw ParseError("Invalid character '%c': pos %zu line '%s'", c, i, line.c_str()); } break; case SKIP_SPACE_AFTER_VALUE: if (isspace(c)) { // NOP } else { throw ParseError("Invalid character '%c': pos %zu line '%s'", c, i, line.c_str()); } break; default: throw ParseError("Invalid state"); } } public: LineParser(string line) throw(ParseError) : line(line), state(SKIP_INITIAL_SPACE), idx(0) { size_t i; for (i = 0; i < line.length(); i++) process(i, line[i]); process(i, ' '); } const string getKey() { return key; } const string getVal() { return val; } }; #endif /* _LINEPARSER_HH_ */
[ "arnaud.installe@pandora.be" ]
arnaud.installe@pandora.be
93e138333d964ee625a02a4e24d029458863d65e
c6bea426cf51887127bfd39ab971ea950c94fe11
/second-year/cpp/third-task/main.cpp
49e2c665e4bc0d727e2f612198590b8d8ccbc85e
[]
no_license
nikiquark/nsu-tasks
4abdc9db5a56570d283d10330f2c34683e71007b
62c9f50917e23dcb3f0027f3b344b75c52f80ea1
refs/heads/master
2020-07-22T23:49:10.569237
2019-09-17T04:49:46
2019-09-17T04:49:46
207,373,268
4
0
null
null
null
null
UTF-8
C++
false
false
42
cpp
#include "ArrayStat.h" int main() { }
[ "nikiquark@gmail.com" ]
nikiquark@gmail.com
9ee4fb4b534250186b7a7e09d9dc0246cbea7cc8
5dc4ea36514927efd678638e2095a4e8e32c0386
/NPSVisor/SVisor/common/dlistchoose.cpp
636f65c07f4a7c0c44ff7eaa88002fc2ebcb9aa3
[ "Unlicense" ]
permissive
NPaolini/NPS_OpenSource
732173afe958f9549af13bc39b15de79e5d6470c
0c7da066b02b57ce282a1903a3901a563d04a28f
refs/heads/main
2023-03-15T09:34:19.674662
2021-03-13T13:22:00
2021-03-13T13:22:00
342,852,203
0
0
null
null
null
null
UTF-8
C++
false
false
3,329
cpp
//------- dlistchoose.cpp ---------------------------------------------------- //---------------------------------------------------------------------------- #include "precHeader.h" #include <stdio.h> //---------------------------------------------------------------------------- #include "dlistChoose.h" #include "1.h" #include "language.h" //---------------------------------------------------------------------------- int TD_ListChoose::choose; //---------------------------------------------------------------------------- TD_ListChoose::TD_ListChoose(PWin* parent, uint resId) : baseClass(parent, resId) { LB = new PListBox(this, IDC_LISTBOX_CHOOSE_EXP); } //-------------------------------------------------------------------------- TD_ListChoose::~TD_ListChoose() { destroy(); } //-------------------------------------------------------------------------- #ifndef SIZE_A #define SIZE_A(a) (sizeof(a) / sizeof(*(a))) #endif bool TD_ListChoose::create() { if(!baseClass::create()) return false; setWindowTextByLangGlob(GetDlgItem(*this, IDC_BUTTON_F1), ID_DIALOG_OK); setWindowTextByLangGlob(GetDlgItem(*this, IDC_BUTTON_F2), ID_DIALOG_CANC); const int Width = 140; const int Height = 70; PRect r(0, 0, Width, Height); int offsX = (GetSystemMetrics(SM_CXSCREEN) - Width) /2; int offsY = (GetSystemMetrics(SM_CYSCREEN) - Height) /3; r.Offset(offsX, offsY); setWindowPos(0, r, SWP_NOZORDER); GetClientRect(*this, r); // r.MoveTo(-2,-2); // r.Inflate(-7,-7); LB->setWindowPos(0, r, SWP_NOZORDER); #if 1 smartPointerConstString normal = getStringOrIdByLangGlob(ID_TIT_NORMAL_EXPORT); smartPointerConstString binary = getStringOrIdByLangGlob(ID_TIT_BINARY_EXPORT); SendMessage(*LB, LB_ADDSTRING, 0, (LPARAM)&normal); SendMessage(*LB, LB_ADDSTRING, 0, (LPARAM)&binary); #else LPCTSTR msg[] = { _T("Normal Export"), _T("Binary Export") }; for(int i = 0; i < SIZE_A(msg); ++i) SendMessage(*LB, LB_ADDSTRING, 0, (LPARAM)msg[i]); #endif SendMessage(*LB, LB_SETCURSEL, choose, 0); return true; } //-------------------------------------------------------------------------- void TD_ListChoose::LBNDblclk() { // INSERT>> Your code here. CmOk(); } //-------------------------------------------------------------------------- void TD_ListChoose::CmOk() { choose = SendMessage(*LB, LB_GETCURSEL, 0, 0); EndDialog(*this, IDOK); } //-------------------------------------------------------------------------- //---------------------------------------------------------------------------- #define EV_BN_CLICKED(id, fz) \ case id: \ fz(); \ break; //---------------------------------------------------------------------------- LRESULT TD_ListChoose::windowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_BUTTON_F1: EV_BN_CLICKED(IDOK, CmOk) case IDC_BUTTON_F2: case IDCANCEL: EndDialog(hwnd, IDCANCEL); break; } switch(HIWORD(wParam)) { case LBN_DBLCLK: LBNDblclk(); break; } break; } return baseClass::windowProc(hwnd, message, wParam, lParam); } //--------------------------------------------------------------------------
[ "npaolini@ennepisoft.it" ]
npaolini@ennepisoft.it
ab61970b28dbaa12920b8cd77c570f3171ce3d1a
50fd7caec8b1283e9753f012ef7767b626477545
/BankAccount/BankAccount/BankAccunt.cpp
05fe12583b8b96c09e7f9a14ea8b63121364b108
[]
no_license
Rensy93/Repos
611ea3bdb6275befe29d088c99e3bfbb81a95b31
18114f7e58624f1763146c220536ca0a9a3e5e93
refs/heads/master
2021-09-13T19:18:58.511880
2018-05-03T11:54:39
2018-05-03T11:54:39
111,279,329
0
0
null
null
null
null
UTF-8
C++
false
false
2,213
cpp
#include "BankAccunt.h" #include <ctime> #include <cstdlib> BankAccunt::BankAccunt() { srand(time(0)); this->nameOfOwner = "?"; this->code = "0"; this->accountNr = rand() % 89999 + 10000; this->balance = 0; this->nrStatment = 0; } BankAccunt::BankAccunt(string nameOfOwner, string code) { srand(time(0)); this->nameOfOwner = nameOfOwner; this->code = code; this->accountNr = rand() % 89999 + 10000; this->balance = 0; this->nrStatment = 0; } BankAccunt::~BankAccunt() { } //string BankAccunt::toString() //{ // // return ""; // //} //get string BankAccunt::getNameOfOwner()const { return this->nameOfOwner; } int BankAccunt::getBalance()const { return this->balance; } int BankAccunt::getAccountNr()const { return this->accountNr; } //set void BankAccunt::setNameOfOwner(string nameOfOwner) { this->nameOfOwner = nameOfOwner; } //code bool BankAccunt::changeCode(string oldCode, string newCode) { bool codeChange = false; if (this->code == oldCode) { this->code = newCode; codeChange = true; } return codeChange; } bool BankAccunt::checkCode(string code)const { bool Codecheck = false; if (this->code == code) { Codecheck = true; } return Codecheck; } //transferstuff void BankAccunt::deposit(int amount) { this->balance += amount; if (nrStatment <= 10) { transaktion[nrStatment] = amount; nrStatment++; } else { this->nrStatment = 0; transaktion[nrStatment] = amount; nrStatment++; } } bool BankAccunt::withdraw(int amunt) { bool complited = false; if (this->balance >= amunt) { this->balance -= amunt; complited = true; } if (nrStatment < 10) { transaktion[nrStatment] = amunt; nrStatment++; } else { this->nrStatment = 0; transaktion[nrStatment] = amunt; nrStatment++; } return complited; } string BankAccunt::statementtOfAccount()const { string statement; for (int i = 0; i < CAP_TRANSAKTION && transaktion[i] != 0; i++) { statement += "transaktion " + to_string(i) + " " + to_string(transaktion[i]) + "\n"; } return statement; } //operators bool BankAccunt::operator==(const BankAccunt &otherAccount)const { return this->nameOfOwner == otherAccount.nameOfOwner; }
[ "rasmusflomen@live.se" ]
rasmusflomen@live.se
68533218b82e229d5ec45dffdec6672d1130ed8f
c51febc209233a9160f41913d895415704d2391f
/library/ATF/_ATTACK_DELAY_CHECKERDetail.hpp
f54e1ed670971fed093b0aa8ff639d6c8af34504
[ "MIT" ]
permissive
roussukke/Yorozuya
81f81e5e759ecae02c793e65d6c3acc504091bc3
d9a44592b0714da1aebf492b64fdcb3fa072afe5
refs/heads/master
2023-07-08T03:23:00.584855
2023-06-29T08:20:25
2023-06-29T08:20:25
463,330,454
0
0
MIT
2022-02-24T23:15:01
2022-02-24T23:15:00
null
UTF-8
C++
false
false
366
hpp
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually #pragma once #include <common/common.h> #include <_ATTACK_DELAY_CHECKERInfo.hpp> START_ATF_NAMESPACE namespace Detail { extern ::std::array<hook_record, 5> _ATTACK_DELAY_CHECKER_functions; }; // end namespace Detail END_ATF_NAMESPACE
[ "b1ll.cipher@yandex.ru" ]
b1ll.cipher@yandex.ru
5fd50bb635202758ce7f51d097d234ef2d9346fa
f89b03dd7ce186caf3f5e249cc0b63579ae22186
/6.5.ExCriticalSection/Sample.cpp
cd1e27e4de79045ff69862efcab0523d58e6e541
[]
no_license
yura0525/01_YuraHomework
cdf8c645c47c71f39bf7edf44093977b9c7d273c
7f2a37ee19e1a00eb301ff676f7fbaf8f9954b22
refs/heads/master
2021-07-12T07:12:24.630819
2019-02-26T08:11:15
2019-02-26T08:11:15
146,382,373
0
0
null
null
null
null
UHC
C++
false
false
866
cpp
#include <windows.h> #include <stdio.h> #define MAXCNT 100000000 CRITICAL_SECTION cs; int g_count = 0; DWORD WINAPI MyThread1(LPVOID arg) { for (int i = 0; i < MAXCNT; i++) { EnterCriticalSection(&cs); g_count += 2; LeaveCriticalSection(&cs); } return 0; } DWORD WINAPI MyThread2(LPVOID arg) { for (int i = 0; i < MAXCNT; i++) { EnterCriticalSection(&cs); g_count -= 2; LeaveCriticalSection(&cs); } return 0; } int main() { //임계 영역 초기화 InitializeCriticalSection(&cs); //스레드 두개 생성 HANDLE hThread[2]; hThread[0] = CreateThread(NULL, 0, MyThread1, NULL, 0, NULL); hThread[1] = CreateThread(NULL, 0, MyThread2, NULL, 0, NULL); //스레드 두개 종료 대기 WaitForMultipleObjects(2, hThread, TRUE, INFINITE); DeleteCriticalSection(&cs); //결과 출력 printf("g_count = %d\n", g_count); return 0; }
[ "yura0525@naver.com" ]
yura0525@naver.com
e5bcfd9847cae96d8882ded80b46e22c18aad7dd
2a7e77565c33e6b5d92ce6702b4a5fd96f80d7d0
/fuzzedpackages/jsonify/inst/include/jsonify/from_json/simplify/simplify.hpp
7cf232e7d052d67c5c74af7ad14606033bb3f56b
[]
no_license
akhikolla/testpackages
62ccaeed866e2194652b65e7360987b3b20df7e7
01259c3543febc89955ea5b79f3a08d3afe57e95
refs/heads/master
2023-02-18T03:50:28.288006
2021-01-18T13:23:32
2021-01-18T13:23:32
329,981,898
7
1
null
null
null
null
UTF-8
C++
false
false
18,740
hpp
#ifndef R_JSONIFY_FROM_JSON_SIMPLIFY_H #define R_JSONIFY_FROM_JSON_SIMPLIFY_H #include "rapidjson/document.h" namespace jsonify { namespace from_json { // takes a list, where each element is the same TYPE and SIZE and simplifies to // a vector // requires each list element to be the same size // param n is the length of each list element template< int RTYPE > inline SEXP simplify_vector( Rcpp::List& x, R_xlen_t n = 1 ) { R_xlen_t i; R_xlen_t x_size = x.size(); R_xlen_t counter = 0; R_xlen_t vec_length = x_size* n; // each list element MUST be length n for( i = 0; i < x_size; ++i ) { if( Rf_length( x[i] ) != n ) { Rcpp::stop("jsonify - list elements different sizes"); } } Rcpp::Vector< RTYPE > v( vec_length ); for( i = 0; i < vec_length; counter++, i+=n ) { Rcpp::Vector< RTYPE > this_vec = x[ counter ]; std::copy( this_vec.begin(), this_vec.end(), v.begin() + i ); } return v; } inline SEXP simplify_vector( Rcpp::List& x, int r_type, R_xlen_t n = 1 ) { switch( r_type ) { case 0: { //return R_NilValue; return Rcpp::List(); } case 10: { return simplify_vector< LGLSXP >( x, n ); } case 13: { return simplify_vector< INTSXP >( x, n ); } case 14: { return simplify_vector< REALSXP >( x, n ); } case 16: { return simplify_vector< STRSXP >( x, n ); } case 19: { return x; // can't simplify } default: { Rcpp::stop("jsonify - unknown vector type"); } } return Rcpp::List(); // #nocov never reaches } template< int RTYPE > inline void update_rtype( int& r_type ) { r_type = RTYPE > r_type ? RTYPE : r_type; } template< typename T > inline SEXP array_to_vector( const T& array, bool& simplify ) { // takes an array of scalars (any types) and returns // them in an R vector int r_type = 0; // int first_r_type; // for keeping track if the vector has been coerced when simplified // every member of the array will be coerced to the max d-type sexp type // but first, get each element and put into a list R_xlen_t arr_len = array.Size(); R_xlen_t i = 0; Rcpp::List out( arr_len ); // Rcpp::Rcout << "arr_len: " << arr_len << std::endl; for( const auto& child : array ) { // Rcpp::Rcout << "child type: " << child.GetType() << std::endl; switch( child.GetType() ) { // bool case rapidjson::kFalseType: {} case rapidjson::kTrueType: { out[i] = child.GetBool(); update_rtype< LGLSXP >( r_type ); break; } // string case rapidjson::kStringType: { //out[i] = "test"; size_t sl = child.GetStringLength(); std::string s = std::string( child.GetString(), sl); out[i] = s; update_rtype< STRSXP >( r_type ); break; } // numeric case rapidjson::kNumberType: { if( child.IsDouble() ) { // // double out[i] = child.GetDouble(); update_rtype< REALSXP >( r_type ); } else { // // int out[i] = child.GetInt(); update_rtype< INTSXP >( r_type ); } break; } // null case rapidjson::kNullType: { out[i] = R_NA_VAL; update_rtype< LGLSXP >( r_type ); break; } // some other data type not covered, including arrays and objects default: { Rcpp::stop("jsonify - array_to_vector only able to parse int, double, string and bool"); } } ++i; } // Rcpp::Rcout << "i: " << i << std::endl; if( simplify ) { return jsonify::from_json::simplify_vector( out, r_type, 1 ); } return out; } template< int RTYPE > inline SEXP simplify_matrix( Rcpp::List& out, R_xlen_t& n_col, R_xlen_t& n_row ) { typedef typename Rcpp::traits::storage_type< RTYPE >::type T; R_xlen_t i, j; Rcpp::Matrix< RTYPE >mat( n_row, n_col ); for( i = 0; i < n_row; ++i ) { Rcpp::Vector< RTYPE > this_vec = out[i]; for( j = 0; j < n_col; ++j ) { T this_val = this_vec[j]; mat( i, j ) = this_val; } } return mat; } inline SEXP simplify_matrix( Rcpp::List& out, R_xlen_t& n_col, R_xlen_t& n_row, int& r_type ) { switch( r_type ) { case INTSXP: { return simplify_matrix< INTSXP >( out, n_col, n_row ); } case REALSXP: { return simplify_matrix< REALSXP >( out, n_col, n_row ); } case LGLSXP: { return simplify_matrix< LGLSXP >( out, n_col, n_row ); } case VECSXP: { return out; // list / data.frame } default: { return simplify_matrix< STRSXP >( out, n_col, n_row ); } } return Rcpp::LogicalMatrix(0); // never reaches? } inline SEXP list_to_matrix( Rcpp::List& array_of_array ) { // Rcpp::Rcout << "list_to_matrix" << std::endl; R_xlen_t n = array_of_array.size(); R_xlen_t j; std::unordered_set< R_xlen_t > array_lengths; std::unordered_set< int > array_types; bool can_be_matrix = true; for( j = 0; j < n; ++j ) { SEXP s = array_of_array[j]; int this_type = TYPEOF( s ); if( Rf_isMatrix( s ) || this_type == VECSXP ) { // can't be simplified can_be_matrix = false; break; } else { // keep track of sizes and types array_lengths.insert( get_sexp_length( s ) ); array_types.insert( this_type ); if( array_lengths.size() > 1 ) { // can't be simplified to matrix can_be_matrix = false; break; } } } if( can_be_matrix ) { Rcpp::IntegerVector arr_types( array_types.begin(), array_types.end() ); int r_type = Rcpp::max( arr_types ); R_xlen_t n_col = *array_lengths.begin(); // only one size R_xlen_t n_row = n; return jsonify::from_json::simplify_matrix( array_of_array, n_col, n_row, r_type ); } else { return array_of_array; } } // takes a list element and converts it to the correct type // only works with single-elements (vectors) template< int RTYPE > inline void list_to_vector( Rcpp::List& lst, Rcpp::List& columns, std::string& this_name, bool fill_na ) { R_xlen_t i; R_xlen_t n_rows = lst.size(); Rcpp::Vector< RTYPE > v( n_rows ); for( i = 0; i < n_rows; ++i ) { if( Rf_isNull( lst[i] ) ) { v[i] = Rcpp::Vector< RTYPE >::get_na(); } else { Rcpp::Vector< RTYPE > x = Rcpp::as< Rcpp::Vector< RTYPE > >( lst[i] ); v[i] = x[0]; } } columns[ this_name ] = v; } inline void list_to_vector( Rcpp::List& columns, std::string& this_name, int& r_type, R_xlen_t& struct_type, // 1 vector, 2 matrix, 3 list bool fill_na ) { Rcpp::List lst = columns[ this_name.c_str() ]; R_xlen_t n_rows = lst.size(); // TODO; is this needed? if( n_rows > 0 ) { // if struct_type == 2; the result is a matrix // need the dimensions... if( struct_type == 2 ) { // i.e., the entire list element is one matrix. // so n_rows remains // n_cols is the length of the first list element R_xlen_t n_cols = get_sexp_length( lst[0] ); columns[ this_name ] = simplify_matrix( lst, n_cols, n_rows, r_type ); } else if( struct_type == 1 ) { switch( r_type ) { case LGLSXP: { list_to_vector< LGLSXP >( lst, columns, this_name, fill_na ); break; } case INTSXP: { list_to_vector< INTSXP >( lst, columns, this_name, fill_na ); break; } case REALSXP: { list_to_vector< REALSXP >( lst, columns, this_name, fill_na ); break; } case STRSXP: { list_to_vector< STRSXP >( lst, columns, this_name, fill_na ); break; } case VECSXP: { // TODO ?? (or is it actually correct to not simplify this??) // should it even get here? //list_to_vector< VECSXP >( lst, columns, this_name, fill_na ); //list_to_vector( lst, ) break; } case NILSXP: { if( !fill_na ) { // if we are filling with NAs, the column will already exist as NAs // (from append_new_column_fill_na) Rcpp::Nullable< Rcpp::List >lst_null( n_rows ); columns[ this_name ] = lst_null; } break; } default: { Rcpp::stop("jsonify - vector-column not found"); } } } } else { // nrows == 0; empty vector/list? } // if( struct_type == 3 ) { // // it's a list; can it be simplified to a data.frame? // // } } inline SEXP make_dataframe( Rcpp::List& lst, R_xlen_t& n_rows ) { lst.attr("class") = "data.frame"; if( n_rows > 0 ) { lst.attr("row.names") = Rcpp::seq(1, n_rows); } else { lst.attr("row.names") = Rcpp::IntegerVector(0); } return lst; } inline SEXP simplify_dataframe_fill_na( Rcpp::List& out, R_xlen_t& doc_len ) { // the number of rows is equal to the number of list elements? // the number of columns is equal to the unique names R_xlen_t n_rows = out.size(); R_xlen_t i, j; // initialise a new list for each column // keep track of it's type Rcpp::List columns; // will grow when a new column name is found std::unordered_map< std::string, R_xlen_t > column_types; std::unordered_map< std::string, R_xlen_t > column_structs; // int : 1 == vector element, 2 == matrix, 3 == list; std::unordered_map< std::string, R_xlen_t > column_lengths; R_xlen_t struct_type; R_xlen_t sexp_length; R_xlen_t tp; R_xlen_t st; R_xlen_t ln; Rcpp::StringVector list_names; std::vector< std::string > column_names; bool new_column = true; for( i = 0; i < n_rows; ++i ) { // iterating list elements Rcpp::List this_list = out[i]; if( !Rf_isNull( this_list.names() ) ) { list_names = this_list.names(); } R_xlen_t list_size = this_list.size(); if( list_names.size() != list_size || list_size == 0 ) { return out; } // Iterate over names?? for( j = 0; j < list_size; ++j ) { const char* this_name = list_names[j]; // does this_name exist in the vector of names? if( std::find( column_names.begin(), column_names.end(), this_name ) != column_names.end() ) { // it exists in the vector new_column = false; } else { new_column = true; // add it to the vector column_names.push_back( this_name ); append_new_column_fill_na( columns, this_name, n_rows ); } SEXP this_elem = this_list[ this_name ]; sexp_length = get_sexp_length( this_elem ); int this_type = TYPEOF( this_elem ); bool is_matrix = Rf_isMatrix( this_elem ); if( sexp_length > 1 && this_type != VECSXP && !is_matrix ) { // the object is more than a scalar, but not a list or matrix struct_type = 3; // matrix } else if ( this_type == VECSXP || is_matrix) { // the object is a list struct_type = 3; // list } else { struct_type = 1; // scalar-vector } tp = column_value( column_types, this_name ); st = column_value( column_structs, this_name ); ln = column_value( column_lengths, this_name ); if( new_column ) { column_types[ this_name ] = this_type; column_structs[ this_name ] = struct_type; column_lengths[ this_name ] = sexp_length; } if( i > 0 && st >= 0 ) { // onto the second row // if this struct_type is different to the previous one, make it a list; // OR, if it's going to be a matrix, but the type is different if( ( struct_type != st || sexp_length != ln ) || ( tp != this_type && struct_type == 2 ) ) { column_structs[ this_name ] = 3; } if( sexp_length > ln ) { column_lengths[ this_name ] = sexp_length; } if( this_type > tp ) { column_types[ this_name ] = this_type; } } // put the element in the correct column slot insert_column_value( columns, this_name, this_elem, i ); } // for j } // for i for( auto& it: column_types ) { std::string this_name = it.first; int r_type = it.second; struct_type = column_value( column_structs, this_name.c_str() ); if( struct_type == 3 ) { // can it be a data.frame? Rcpp::List lst = columns[ this_name ]; columns[ this_name ] = simplify_dataframe_fill_na( lst, doc_len ); } else { list_to_vector( columns, this_name, r_type, struct_type, true ); // true: fill_na } } return make_dataframe( columns, n_rows ); } // iff all the column lengths are the same, and > 1, the whole column can become a matrix // iff all the column lenghts are the same, and == 1, the whole column is a vector // iff any column lenghts are different, it's a list inline SEXP simplify_dataframe( Rcpp::List& out, R_xlen_t& doc_len ) { // the number of rows is equal to the number of list elements? // the number of columns is equal to the unique names R_xlen_t n_rows = out.size(); R_xlen_t i, j; // initialise a new list for each column // keep track of it's type Rcpp::List columns; // will grow when a new column name is found std::unordered_map< std::string, R_xlen_t > column_types; std::unordered_map< std::string, R_xlen_t > column_structs; // int : 1 == vector element, 2 == matrix, 3 == list; std::unordered_map< std::string, R_xlen_t > column_lengths; R_xlen_t struct_type; R_xlen_t sexp_length; R_xlen_t tp; R_xlen_t st; R_xlen_t ln; Rcpp::StringVector list_names; for( i = 0; i < n_rows; ++i ) { // iterating list elements Rcpp::List this_list = out[i]; if( i == 0 ) { if( !Rf_isNull( this_list.names() ) ) { list_names = this_list.names(); } } R_xlen_t list_size = this_list.size(); if( list_names.size() != list_size || list_size == 0 ) { return out; } // Iterate over names?? for( j = 0; j < list_size; ++j ) { const char* this_name = list_names[j]; Rcpp::StringVector these_names = this_list.names(); R_xlen_t found_name = where_is( this_name, these_names ); if( found_name == -1 ) { // can't simplify return out; } SEXP this_elem = this_list[ this_name ]; sexp_length = get_sexp_length( this_elem ); int this_type = TYPEOF( this_elem ); bool is_matrix = Rf_isMatrix( this_elem ); if( sexp_length > 1 && this_type != VECSXP && !is_matrix ) { // the object is more than a scalar, but not a list or matrix struct_type = 2; // matrix } else if ( ( i == 0 && this_type == VECSXP ) || is_matrix) { // the object is a list struct_type = 3; // list } else { struct_type = 1; // scalar-vector } tp = column_value( column_types, this_name ); st = column_value( column_structs, this_name ); ln = column_value( column_lengths, this_name ); //if( i == 0 && tp >= 0 ) { // on the first row, but the column already exists //return out; //} // only add column types if we're on the first 'row' if( i == 0 ) { column_types[ this_name ] = this_type; column_structs[ this_name ] = struct_type; column_lengths[ this_name ] = sexp_length; append_new_column( columns, this_name, n_rows ); } if( tp == -1 && i > 0 ) { // can't simplify because new column names return out; } if( i > 0 && st >= 0 ) { // onto the second row // if this struct_type is different to the previous one, make it a list; // OR, if it's going to be a matrix, but the type is different if( ( struct_type != st || sexp_length != ln ) || ( tp != this_type && struct_type == 2 ) ) { column_structs[ this_name ] = 3; } if( this_type > tp ) { column_types[ this_name ] = this_type; } } // put the element in the correct column slot insert_column_value( columns, this_name, this_elem, i ); } } for( auto& it: column_types ) { std::string this_name = it.first; int r_type = it.second; struct_type = column_value( column_structs, this_name.c_str() ); if( struct_type == 3 ) { // can it be a data.frame? Rcpp::List lst = columns[ this_name ]; columns[ this_name ] = simplify_dataframe( lst, doc_len ); } else { list_to_vector( columns, this_name, r_type, struct_type, false ); // false : fill_na } } return make_dataframe( columns, n_rows ); } inline SEXP simplify( Rcpp::List& out, std::unordered_set< int > dtypes, R_xlen_t json_length, bool fill_na ) { Rcpp::List res(1); if ( dtypes.size() == 1 && contains_array( dtypes ) ) { return jsonify::from_json::list_to_matrix( out ); } else if ( contains_object( dtypes ) && dtypes.size() == 1 && !contains_array( dtypes ) ) { if( fill_na ) { return jsonify::from_json::simplify_dataframe_fill_na( out, json_length ); } else { return jsonify::from_json::simplify_dataframe( out, json_length ); } } else { return out; } return res; } } // from_json } // jsonify #endif
[ "akhilakollasrinu424jf@gmail.com" ]
akhilakollasrinu424jf@gmail.com
a318a117278ec3c61b0b9ef6ac6662667639a4a4
6631041fe2cd98c885cf004381a214c34bb62f0f
/App/DeckLinkDemo/StreamReceiverSrc/TMReceiverSrc.cpp
175eb135341d8feececa969897afda6a0566a1e1
[]
no_license
usher2007/Navigation
05b5e227b9123f455deba3fb0a07392eb8f4d9ff
1c18ee12ba23c33c3f34d06ac0fd50f89203e79f
refs/heads/develop
2021-01-23T14:57:07.800809
2013-04-17T09:37:21
2013-04-17T09:37:21
2,854,394
4
13
null
2014-08-19T07:01:10
2011-11-26T06:15:08
C++
MacCentralEurope
C++
false
false
40,289
cpp
#include "stdafx.h" #include <streams.h> #include "TMReceiverSrc.h" static const LONGLONG ONESEC = 10000000; static const int FPS = 25; static const int DEFAULT_WIDTH = 720; static const int DEFAULT_HEIGHT = 576; static const CRefTime Offset = ONESEC/FPS; DWORD ReaderProc(LPVOID pParam); const AMOVIESETUP_MEDIATYPE sudOpVideoPinTypes = { &MEDIATYPE_Video, // Major type &MEDIASUBTYPE_NULL // Minor type }; const AMOVIESETUP_MEDIATYPE sudOpAudioPinTypes = { &MEDIATYPE_Audio, // Major type &MEDIASUBTYPE_NULL // Minor type }; const AMOVIESETUP_PIN sudOpPins[] = { { L"Video Output", // Pin string name FALSE, // Is it rendered TRUE, // Is it an output FALSE, // Can we have none FALSE, // Can we have many &CLSID_NULL, // Connects to filter NULL, // Connects to pin 1, // Number of types &sudOpVideoPinTypes }, { L"Audio Output", // Pin string name FALSE, // Is it rendered TRUE, // Is it an output FALSE, // Can we have none FALSE, // Can we have many &CLSID_NULL, // Connects to filter NULL, // Connects to pin 1, // Number of types &sudOpAudioPinTypes } }; const AMOVIESETUP_FILTER sudTMReceiverSrcax = { &CLSID_TMStreamReceiver, // Filter CLSID L"TMReceiver Source Filter", // String name MERIT_DO_NOT_USE, // Filter merit 2, // Number pins sudOpPins // Pin details }; CUnknown * WINAPI CTMReceiverSrc::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr) { ASSERT(phr); CUnknown *punk = new CTMReceiverSrc(lpunk, phr); if(punk == NULL) { if(phr) *phr = E_OUTOFMEMORY; } return punk; } CTMReceiverSrc::CTMReceiverSrc(LPUNKNOWN lpunk, HRESULT *phr) : CSource(NAME("TMReceiver Source Filter"), lpunk, CLSID_TMStreamReceiver) { ASSERT(phr); CAutoLock cAutoLock(&m_cStateLock); m_paStreams = (CSourceStream **)new CSourceStream*[2]; if(m_paStreams == NULL) { if(phr) *phr = E_OUTOFMEMORY; return; } m_pVideoPin = new CTMReceiverVideoOutputPin(phr, this, L"TMReceiver Video Pin"); m_pAudioPin = NULL; m_paStreams[0] = m_pVideoPin; m_pFileName = NULL; m_bRecordStatus = FALSE; m_bHasAudio = FALSE; memset(m_recordFileName, 0x00, sizeof(m_recordFileName)); beforeDecodeCB = NULL; beforeCBParam = NULL; afterDecodeCB = NULL; afterCBParam = NULL; m_bQuitReaderThread = FALSE; } CTMReceiverSrc::~CTMReceiverSrc() { m_bQuitReaderThread = TRUE; while(m_bQuitReaderThread) { Sleep(100); } if(m_pFileName != NULL) { delete[] m_pFileName; m_pFileName = NULL; } if(m_paStreams != NULL) { delete[] m_paStreams; m_paStreams = NULL; } m_iPins = 0; } HRESULT CTMReceiverSrc::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt) { //TODO: Open the file using ffmpeg; HRESULT hr = S_FALSE; USES_CONVERSION; AVCodecContext *pVideoCodecCtx = NULL; AVCodec *pVideoCodec = NULL; avcodec_register_all(); av_register_all(); avformat_network_init(); int cch = lstrlenW(pszFileName) + 1; m_pFileName = new WCHAR[cch]; if(m_pFileName != NULL) { CopyMemory(m_pFileName, pszFileName, cch*sizeof(WCHAR)); } m_pFormatContext = avformat_alloc_context(); int err = avformat_open_input(&m_pFormatContext, W2A(m_pFileName), NULL, NULL); if(err != 0) { return E_FAIL; } m_pFormatContext->flags |= AVFMT_FLAG_GENPTS; m_pFormatContext->flags |= AVFMT_GENERIC_INDEX; m_pFormatContext->max_index_size = 99; m_pFormatContext->probesize /= 3; m_pFormatContext->max_analyze_duration /= 3; if(av_find_stream_info(m_pFormatContext) < 0) { return E_FAIL; } av_dump_format(m_pFormatContext, 0, W2A(m_pFileName), false); for(int i=0; i<m_pFormatContext->nb_streams; i++) { if(m_pFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { m_videoStreamIndex = i; pVideoCodecCtx = m_pFormatContext->streams[i]->codec; m_resolution.width = pVideoCodecCtx->width; m_resolution.height = pVideoCodecCtx->height; } else if(m_pFormatContext->streams[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO) { m_audioStreamIndex = i; m_pAudioPin = new CTMReceiverAudioOutputPin(&hr, this, L"TMReceiver Audio Pin"); m_paStreams[1] = m_pAudioPin; m_pAudioPin->m_pAudioCodecCtx = m_pFormatContext->streams[i]->codec; m_pAudioPin->m_pAudioCodec = avcodec_find_decoder((m_pAudioPin->m_pAudioCodecCtx->codec_id)); if(m_pAudioPin->m_pAudioCodec == NULL) { continue; } if(avcodec_open(m_pAudioPin->m_pAudioCodecCtx, m_pAudioPin->m_pAudioCodec) < 0) { continue; } m_bHasAudio = TRUE; m_pAudioPin->m_rtAvgTimePerPts = m_pFormatContext->streams[i]->time_base.num * ONESEC / m_pFormatContext->streams[i]->time_base.den; } } if(m_resolution.width != DEFAULT_WIDTH || m_resolution.height != DEFAULT_HEIGHT) { return E_FAIL; } if(m_bHasAudio) { m_pAudioPin->m_pRelatedVideoPin = m_pVideoPin; } //TODO: Start a thread to read the packet. m_bQuitReaderThread = FALSE; DWORD dwThreadId = 0; m_readerThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ReaderProc, (LPVOID*)this, 0, &dwThreadId); return S_OK; } HRESULT CTMReceiverSrc::GetCurFile(LPOLESTR * ppszFileName,AM_MEDIA_TYPE * pmt){ CheckPointer(ppszFileName, E_POINTER); *ppszFileName = NULL; if (m_pFileName!=NULL) { DWORD n = sizeof(WCHAR)*(1+lstrlenW(m_pFileName)); *ppszFileName = (LPOLESTR) CoTaskMemAlloc( n ); if (*ppszFileName!=NULL) { CopyMemory(*ppszFileName, m_pFileName, n); } } return S_OK; } STDMETHODIMP CTMReceiverSrc::Run(REFERENCE_TIME tStart){ CAutoLock cObjectLock(m_pLock); { CAutoLock lock(&(m_pVideoPin->m_csDecoder)); m_pVideoPin->m_pDecoder = new H264Decoder; m_pVideoPin->m_pDecoder->Init(m_pFormatContext->streams[m_videoStreamIndex]->codec); } m_pVideoPin->m_bWorking = TRUE; m_pVideoPin->m_rtFirstFrameTime = 0; m_pVideoPin->m_rtSampleTime = 0; m_pVideoPin->m_rtPosition = 0; m_pVideoPin->m_bGetAvgFrameTime = FALSE; if(m_bHasAudio) { m_pAudioPin->m_bWorking = TRUE; m_pAudioPin->m_rtFirstFrameTime = 0; m_pAudioPin->m_rtSampleTime = 0; m_pAudioPin->m_rtPosition = 0; m_pAudioPin->m_bGetAvgFrameTime = FALSE; } return CBaseFilter::Run(tStart); } STDMETHODIMP CTMReceiverSrc::Pause(){ CAutoLock cObjectLock(m_pLock); return CBaseFilter::Pause(); } STDMETHODIMP CTMReceiverSrc::Stop(){ CAutoLock cObjectLock(m_pLock); m_pVideoPin->m_bWorking = FALSE; int ret = 0; { CAutoLock lock(&(m_pVideoPin->m_csDecoder)); if(m_pVideoPin->m_pDecoder != NULL){ m_pVideoPin->m_pDecoder->Release(); delete m_pVideoPin->m_pDecoder; m_pVideoPin->m_pDecoder = NULL; } } m_pVideoPin->m_rtFirstFrameTime = 0; m_pVideoPin->m_rtSampleTime = 0; if(m_pAudioPin) { m_pAudioPin->m_bWorking = FALSE; m_pAudioPin->m_rtFirstFrameTime = 0; m_pAudioPin->m_rtSampleTime = 0; } return CBaseFilter::Stop(); } void CTMReceiverSrc::ReadAndCachePreviewPackets() { //TODO: READ AND CACHE PACKETS. AVPacket packet; AVPacket packetToAbolish; while(!m_bQuitReaderThread) { if(m_pVideoPin->m_queueBuffer.nb_packets > 256) { for(int i=0; i<10; i++) { av_init_packet(&packetToAbolish); m_pVideoPin->m_queueBuffer.Get(&packetToAbolish, 1); //m_channelPts[channel] = packetToAbolish.pts; av_free_packet(&packetToAbolish); } } int ret = av_read_frame(m_pFormatContext, &packet); if(ret < 0) { /*av_init_packet(&packet); packet.data = NULL; packet.size = 0; packet.stream_index = m_videoStreamIndex; m_queueBuffer.Put(&packet);*/ //For debug char tmp[1024]; sprintf(tmp," ===================================BAD Put %d bad Packet!\n", ret); OutputDebugStringA(tmp); Sleep(10); continue; } if(packet.stream_index == m_videoStreamIndex) { //For debug char tmp[1024]; sprintf(tmp," ===================================GOOD Put %d good Video Packet!\n",m_pVideoPin->m_queueBuffer.nb_packets); OutputDebugStringA(tmp); //m_channelPts[channel] = packet.pts; m_pVideoPin->m_queueBuffer.Put(&packet); //char tmp[1024]; //sprintf(tmp, "Channel %d__PTS %lld\n", channel, packet.pts); //OutputDebugStringA(tmp); //continue; } else if(m_bHasAudio && packet.stream_index == m_audioStreamIndex) { // TODO char tmp[1024]; sprintf(tmp," ===================================GOOD Put %d good Audio Packet!\n",m_pAudioPin->m_queueBuffer.nb_packets); OutputDebugStringA(tmp); m_pAudioPin->m_queueBuffer.Put(&packet); } Sleep(10); } m_bQuitReaderThread = FALSE; return; } STDMETHODIMP CTMReceiverSrc::StartRecord(const char *fileName) { memcpy(m_recordFileName, fileName, strlen(fileName)); m_pVideoPin->InitRecord(m_recordFileName); m_bRecordStatus = TRUE; return S_OK; } STDMETHODIMP CTMReceiverSrc::StopRecord() { if(m_bRecordStatus == TRUE) { m_bRecordStatus = FALSE; m_pVideoPin->StopRecord(); memset(m_recordFileName, 0x00, sizeof(m_recordFileName)); } return S_OK; } STDMETHODIMP CTMReceiverSrc::SetCallBackBeforeDecode(TMReceiverCB cb, void* arg) { beforeDecodeCB = cb; beforeCBParam = arg; return S_OK; } STDMETHODIMP CTMReceiverSrc::SetCallBackAfterDecode(TMReceiverCB cb, void* arg) { afterDecodeCB = cb; afterCBParam = arg; return S_OK; } STDMETHODIMP CTMReceiverSrc::IsSourceHasAudio() { if(m_bHasAudio) { return S_OK; } else { return E_FAIL; } } int CTMReceiverSrc::CallBeforeDecodeCB(TMFrame *pFrame) { if(beforeDecodeCB != NULL) { return beforeDecodeCB(pFrame, beforeCBParam); } return -1; } int CTMReceiverSrc::CallAfterDecodeCB(TMFrame *pFrame) { if(afterDecodeCB != NULL) { return afterDecodeCB(pFrame, afterCBParam); } return -1; } ////////////////////////////////////////////////////////////////// // Video Output Pin ////////////////////////////////////////////////////////////////// CTMReceiverVideoOutputPin::CTMReceiverVideoOutputPin(HRESULT *phr, CTMReceiverSrc *pParent, LPCWSTR pPinName) : CSourceStream(NAME("TMReceiver Source Filter Output Pin"), phr, pParent, pPinName) { m_rtPosition = 0; m_rtSampleTime = 0; m_bWorking = FALSE; m_bGetAvgFrameTime = FALSE; m_pData = NULL; m_rtAvgTimePerFrame = ONESEC/FPS; m_rtFirstFrameTime = 0; m_pinIntialized = FALSE; m_pDecoder = NULL; m_bFPSGuessed = FALSE; m_rtStartForAudio = 0; m_rtStopForAudio = 0; m_bDecodeSuccess = FALSE; } CTMReceiverVideoOutputPin::~CTMReceiverVideoOutputPin() { m_pDecoder->Release(); delete m_pDecoder; m_pDecoder = NULL; } HRESULT CTMReceiverVideoOutputPin::FillBuffer(IMediaSample *pms) { //TODO: Fill buffer with the decoded frames. CTMReceiverSrc* pFilter = (CTMReceiverSrc*)m_pFilter; char tmp[1024]; sprintf(tmp," ===================================Fill Buffer In!\n"); OutputDebugStringA(tmp); AVPacket pkt, pktForRecord; AVPicture pic; BYTE *pData; long lDataLen; lDataLen = pms->GetSize(); if (m_pData==NULL) { m_pData = new BYTE[lDataLen]; } //if(m_queueBuffer.nb_packets<=0) //{ // REFERENCE_TIME rtStart, rtStop, rtMediaStart, rtMediaStop; // // The sample times are modified by the current rate. // rtStart = static_cast<REFERENCE_TIME>(m_rtSampleTime); // rtStop = rtStart + static_cast<int>(m_rtAvgTimePerFrame ); // rtMediaStart = static_cast<REFERENCE_TIME>(m_rtPosition); // rtMediaStop = rtMediaStart + static_cast<int>(m_rtAvgTimePerFrame ); // pms->SetTime(&rtStart, &rtStop); // pms->SetMediaTime(&rtMediaStart, &rtMediaStop); // m_rtSampleTime = m_rtSampleTime + static_cast<int>(m_rtAvgTimePerFrame ); // m_rtPosition = m_rtPosition + m_rtAvgTimePerFrame; // pms->SetSyncPoint(TRUE); // Sleep(10); // //char tmp[1024]; // //sprintf(tmp,"====================No Data!====================\n"); // //OutputDebugStringA(tmp); // return S_OK; //} av_init_packet(&pkt); int maxPktNum = m_bGetAvgFrameTime ? 10 : 5; while (m_queueBuffer.nb_packets > maxPktNum) { CAutoLock lock(&m_csBuffer); m_queueBuffer.Get(&pkt,1); av_free_packet(&pkt); } { CAutoLock lock(&m_csBuffer); m_queueBuffer.Get(&pkt, 1); if(pkt.flags & AV_PKT_FLAG_KEY) { /*char tmp[1024]; sprintf(tmp,"Key Frame!\n"); OutputDebugStringA(tmp);*/ } } int ret = -1; //Record Video if(m_bRecordStatus == TRUE) { if(pkt.flags & AV_PKT_FLAG_KEY) { m_bFindKeyFrame = TRUE; } if(m_bFindKeyFrame) { av_init_packet(&pktForRecord); pktForRecord.size = pkt.size; pktForRecord.flags = pkt.flags; pktForRecord.pts = pts; pktForRecord.dts = pts; pktForRecord.data = new uint8_t[pktForRecord.size]; memcpy(pktForRecord.data, pkt.data, pktForRecord.size); ret = av_interleaved_write_frame(m_fileSaverCtx, &pktForRecord); delete [] pktForRecord.data; pktForRecord.data = NULL; pktForRecord.size = 0; av_init_packet(&pktForRecord); av_free_packet(&pktForRecord); //pts += m_rtAvgTimePerFrame/1000*9; pts++; } } // BEFORE DECODE CB TMFrame beforeDecodeFrame; beforeDecodeFrame.data = (char *)pkt.data; beforeDecodeFrame.len = pkt.size; beforeDecodeFrame.decoded = FALSE; beforeDecodeFrame.error = FALSE; pFilter->CallBeforeDecodeCB(&beforeDecodeFrame); ret = -1; { CAutoLock lock(&m_csDecoder); if (m_pDecoder!=NULL) { ret = m_pDecoder->DecodeFrame(&pic, m_pData, pkt.data, pkt.size); } } // AFTER DECODE CB TMFrame afterDecodeFrame; afterDecodeFrame.data = (char *)pkt.data; afterDecodeFrame.len = pkt.size; afterDecodeFrame.decoded = TRUE; afterDecodeFrame.error = ret <= 0 ? TRUE : FALSE; // TODO: construct the pic for(int ptr_i=0; ptr_i<AV_NUM_DATA_POINTERS; ptr_i++) { afterDecodeFrame.pic.data[ptr_i] = pic.data[ptr_i]; afterDecodeFrame.pic.linesize[ptr_i] = pic.linesize[ptr_i]; } pFilter->CallAfterDecodeCB(&afterDecodeFrame); if(ret <=0) { char tmp[1024]; sprintf(tmp," ===================================BAD£¨rtSampleTime:%lld\n",m_rtSampleTime); OutputDebugStringA(tmp); REFERENCE_TIME rtStart, rtStop, rtMediaStart, rtMediaStop; // The sample times are modified by the current rate. rtStart = static_cast<REFERENCE_TIME>(m_rtSampleTime); rtStop = rtStart + static_cast<int>(m_rtAvgTimePerFrame ); rtMediaStart = static_cast<REFERENCE_TIME>(m_rtPosition); rtMediaStop = rtMediaStart + static_cast<int>(m_rtAvgTimePerFrame ); pms->SetTime(&rtStart, &rtStop); pms->SetMediaTime(&rtMediaStart, &rtMediaStop); m_rtSampleTime = rtStop; m_rtPosition = m_rtPosition + m_rtAvgTimePerFrame; pms->SetSyncPoint(TRUE); return S_OK; } pms->GetPointer(&pData); USES_CONVERSION; ZeroMemory(pData, lDataLen); { CAutoLock cAutoLockShared(&m_cSharedState); memcpy(pData,m_pData,lDataLen); //hack the 1920*1088, the last 8 line should be set to 0. if(pFilter->GetImageHeight() == 1088) { memset(pData, 0, pFilter->GetImageWidth()*8*sizeof(RGBQUAD)); } //hack the 720*576, the first and last 2 lines should be set to 0. if(pFilter->GetImageHeight() == 576) { memset(pData, 0, pFilter->GetImageWidth()*2*sizeof(RGBQUAD)); memset(pData + pFilter->GetImageWidth()*(pFilter->GetImageHeight()-2)*sizeof(RGBQUAD), 0, pFilter->GetImageWidth()*2*sizeof(RGBQUAD)); } REFERENCE_TIME rtStart, rtStop, rtMediaStart, rtMediaStop; // The sample times are modified by the current rate. //rtStart = static_cast<REFERENCE_TIME>(m_rtSampleTime); if(m_rtFirstFrameTime == 0) { m_rtFirstFrameTime = pkt.pts ; } rtStart = (pkt.pts - m_rtFirstFrameTime)*100/9*10; //rtStart = rtStart < m_rtPosition ? rtStart : m_rtPosition; rtStart = m_rtPosition; // FOR DEBUG //rtStart += Offset; rtStop = rtStart + static_cast<int>(m_rtAvgTimePerFrame ); rtMediaStart = static_cast<REFERENCE_TIME>(m_rtPosition); rtMediaStop = rtMediaStart + static_cast<int>(m_rtAvgTimePerFrame ); pms->SetTime(&rtStart, &rtStop); pms->SetMediaTime(&rtMediaStart, &rtMediaStop); m_rtSampleTime = rtStop; m_rtPosition = m_rtPosition + m_rtAvgTimePerFrame; char tmp[1024]; sprintf(tmp," %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Good Video! Start %lld - Stop:%lld\n", rtStart, rtStop); OutputDebugStringA(tmp); if(m_rtStartForAudio == 0) { m_rtStartForAudio = rtStart; } m_rtStopForAudio = rtStop; } pms->SetSyncPoint(TRUE); //For debug //char tmp2[1024]; //sprintf(tmp2,"Channel %d__Fill Buffer Finallly %d!\n", pFilter->m_relatedChannel, frame_count); //OutputDebugStringA(tmp2); av_free_packet(&pkt); //CallBack //DecodeCallback decodeCB = NULL; //void *pCBParam = NULL; //HRESULT hr = pFilter->m_pConfigManager->GetDecodeCB(pFilter->m_relatedChannel, &decodeCB, &pCBParam); //if(SUCCEEDED(hr) && decodeCB != NULL) //{ // decodeCB(m_pData, lDataLen, pCBParam); //} m_bDecodeSuccess = TRUE; return S_OK; return S_OK; } STDMETHODIMP CTMReceiverVideoOutputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv){ return CSourceStream::NonDelegatingQueryInterface(riid, ppv); } STDMETHODIMP CTMReceiverVideoOutputPin::Notify(IBaseFilter * pSender, Quality q){ return S_OK; } HRESULT CTMReceiverVideoOutputPin::DecideBufferSize(IMemAllocator *pAlloc,ALLOCATOR_PROPERTIES *pProperties){ CheckPointer(pAlloc,E_POINTER); CheckPointer(pProperties,E_POINTER); CAutoLock cAutoLock(m_pFilter->pStateLock()); HRESULT hr = S_OK; pProperties->cBuffers = 1; int imageWidth = ((CTMReceiverSrc *)m_pFilter)->GetImageWidth(); int imageHeight = ((CTMReceiverSrc *)m_pFilter)->GetImageHeight(); if(imageWidth < 0 || imageHeight < 0) { return E_FAIL; } pProperties->cbBuffer = imageWidth*imageHeight*sizeof(RGBQUAD); ASSERT(pProperties->cbBuffer); ALLOCATOR_PROPERTIES Actual; hr = pAlloc->SetProperties(pProperties,&Actual); if(FAILED(hr)) { return hr; } if(Actual.cbBuffer < pProperties->cbBuffer) { return E_FAIL; } ASSERT(Actual.cBuffers == 1); return S_OK; } HRESULT CTMReceiverVideoOutputPin::CheckMediaType(const CMediaType *pMediaType){ CheckPointer(pMediaType,E_POINTER); if((*(pMediaType->Type()) != MEDIATYPE_Video) || // we only output video !(pMediaType->IsFixedSize())) // in fixed size samples { return E_INVALIDARG; } // Check for the subtypes we support const GUID *SubType = pMediaType->Subtype(); if (SubType == NULL) return E_INVALIDARG; if(*SubType != MEDIASUBTYPE_RGB32) { return E_INVALIDARG; } // Get the format area of the media type VIDEOINFO *pvi = (VIDEOINFO *) pMediaType->Format(); if(pvi == NULL) return E_INVALIDARG; // Check the image size. As my default ball is 10 pixels big // look for at least a 20x20 image. This is an arbitary size constraint, // but it avoids balls that are bigger than the picture... // Check if the image width & height have changed if(pvi->bmiHeader.biWidth != ((CTMReceiverSrc *)m_pFilter)->GetImageWidth()|| pvi->bmiHeader.biHeight != ((CTMReceiverSrc *)m_pFilter)->GetImageHeight()) { // If the image width/height is changed, fail CheckMediaType() to force // the renderer to resize the image. return E_INVALIDARG; } return S_OK; // This format is acceptable. } HRESULT CTMReceiverVideoOutputPin::GetMediaType(int iPosition, CMediaType *pmt){ CheckPointer(pmt,E_POINTER); CAutoLock cAutoLock(m_pFilter->pStateLock()); if(iPosition < 0) { return E_INVALIDARG; } if(iPosition > 0) { return VFW_S_NO_MORE_ITEMS; } VIDEOINFO* pvih = (VIDEOINFO*)pmt->AllocFormatBuffer(sizeof(VIDEOINFO)); LPBITMAPINFOHEADER lpBitmapInfoHeader = &(pvih->bmiHeader); lpBitmapInfoHeader->biSize = sizeof(BITMAPINFOHEADER); lpBitmapInfoHeader->biBitCount = 32; lpBitmapInfoHeader->biWidth = ((CTMReceiverSrc *)m_pFilter)->GetImageWidth()/4*4; lpBitmapInfoHeader->biHeight = ((CTMReceiverSrc *)m_pFilter)->GetImageHeight(); lpBitmapInfoHeader->biPlanes = 1; lpBitmapInfoHeader->biCompression = BI_RGB; lpBitmapInfoHeader->biSizeImage = ((CTMReceiverSrc *)m_pFilter)->GetImageWidth() / 4 * 4 * ((CTMReceiverSrc *)m_pFilter)->GetImageHeight() * 4; lpBitmapInfoHeader->biXPelsPerMeter = 0; lpBitmapInfoHeader->biYPelsPerMeter =0; lpBitmapInfoHeader->biClrUsed = 0; lpBitmapInfoHeader->biClrImportant = 0; pvih->AvgTimePerFrame = m_rtAvgTimePerFrame; pmt->SetFormatType(&FORMAT_VideoInfo); pmt->SetTemporalCompression(FALSE); SetRectEmpty(&(pvih->rcSource)); // we want the whole image area rendered. SetRectEmpty(&(pvih->rcTarget)); // no particular destination rectangle pmt->SetType(&MEDIATYPE_Video); // Work out the GUID for the subtype from the header info. const GUID SubTypeGUID = GetBitmapSubtype(&pvih->bmiHeader); pmt->SetSubtype(&SubTypeGUID); pmt->SetSampleSize(pvih->bmiHeader.biSizeImage); return S_OK; } HRESULT CTMReceiverVideoOutputPin::GetMediaType(CMediaType *pmt){ VIDEOINFO* pvih = (VIDEOINFO*)pmt->AllocFormatBuffer(sizeof(VIDEOINFO)); LPBITMAPINFOHEADER lpBitmapInfoHeader = &(pvih->bmiHeader); lpBitmapInfoHeader->biSize = sizeof(BITMAPINFOHEADER); lpBitmapInfoHeader->biBitCount = 32; lpBitmapInfoHeader->biWidth = ((CTMReceiverSrc *)m_pFilter)->GetImageWidth()/4*4; lpBitmapInfoHeader->biHeight = ((CTMReceiverSrc *)m_pFilter)->GetImageHeight(); lpBitmapInfoHeader->biPlanes = 1; lpBitmapInfoHeader->biCompression = BI_RGB; lpBitmapInfoHeader->biSizeImage = ((CTMReceiverSrc *)m_pFilter)->GetImageWidth() / 4 * 4 * ((CTMReceiverSrc *)m_pFilter)->GetImageHeight() * 4; lpBitmapInfoHeader->biXPelsPerMeter = 0; lpBitmapInfoHeader->biYPelsPerMeter =0; lpBitmapInfoHeader->biClrUsed = 0; lpBitmapInfoHeader->biClrImportant = 0; pvih->AvgTimePerFrame = m_rtAvgTimePerFrame; pmt->SetFormatType(&FORMAT_VideoInfo); pmt->SetTemporalCompression(FALSE); SetRectEmpty(&(pvih->rcSource)); // we want the whole image area rendered. SetRectEmpty(&(pvih->rcTarget)); // no particular destination rectangle pmt->SetType(&MEDIATYPE_Video); // Work out the GUID for the subtype from the header info. const GUID SubTypeGUID = GetBitmapSubtype(&pvih->bmiHeader); pmt->SetSubtype(&SubTypeGUID); pmt->SetSampleSize(pvih->bmiHeader.biSizeImage); return S_OK; } STDMETHODIMP CTMReceiverVideoOutputPin::Run() { m_rtFirstFrameTime = 0; m_rtPosition = 0; m_bDecodeSuccess = FALSE; return CSourceStream::Run(); } STDMETHODIMP CTMReceiverVideoOutputPin::Stop() { m_rtFirstFrameTime = 0; m_rtPosition = 0; return CSourceStream::Stop(); } HRESULT CTMReceiverVideoOutputPin::InitRecord(const char* fileName) { avcodec_register_all(); av_register_all(); avformat_alloc_output_context2(&m_fileSaverCtx, NULL, NULL, fileName); if(!m_fileSaverCtx) { return E_FAIL; } m_fileSaverFmt = m_fileSaverCtx->oformat; m_fileSaverFmt->video_codec = CODEC_ID_H264; m_fileSaverStream = avformat_new_stream(m_fileSaverCtx, NULL); if(!m_fileSaverStream) { return E_FAIL; } AVCodecContext *outputCodecContext; outputCodecContext = m_fileSaverStream->codec; CTMReceiverSrc *pFilter = (CTMReceiverSrc *)m_pFilter; AVStream *pInputStream = pFilter->m_pFormatContext->streams[pFilter->m_videoStreamIndex]; AVCodecContext *inputCodecContext = pFilter->m_pFormatContext->streams[pFilter->m_videoStreamIndex]->codec; outputCodecContext->codec_id = m_fileSaverFmt->video_codec; outputCodecContext->codec_type = inputCodecContext->codec_type; outputCodecContext->codec_tag = inputCodecContext->codec_tag; outputCodecContext->bit_rate = 400000; outputCodecContext->extradata = inputCodecContext->extradata; outputCodecContext->extradata_size = inputCodecContext->extradata_size; outputCodecContext->width = ((CTMReceiverSrc *)m_pFilter)->GetImageWidth(); outputCodecContext->height = ((CTMReceiverSrc *)m_pFilter)->GetImageHeight(); outputCodecContext->time_base.den = FPS; outputCodecContext->time_base.num = 1; outputCodecContext->gop_size = inputCodecContext->gop_size; outputCodecContext->pix_fmt = inputCodecContext->pix_fmt; outputCodecContext->has_b_frames = inputCodecContext->has_b_frames; //DIFF outputCodecContext->bit_rate = inputCodecContext->bit_rate; /*outputCodecContext->time_base = inputCodecContext->time_base; m_fileSaverStream->time_base = pInputStream->time_base; if(av_q2d(inputCodecContext->time_base) * inputCodecContext->ticks_per_frame > av_q2d(pInputStream->time_base) && av_q2d(pInputStream->time_base) < 1.0/1000) { outputCodecContext->time_base = inputCodecContext->time_base; outputCodecContext->time_base.num *= inputCodecContext->ticks_per_frame; } av_reduce(&outputCodecContext->time_base.num, &outputCodecContext->time_base.den,outputCodecContext->time_base.num, outputCodecContext->time_base.den, INT_MAX); */ if(m_fileSaverCtx->oformat->flags & AVFMT_GLOBALHEADER) { outputCodecContext->flags |= CODEC_FLAG_GLOBAL_HEADER; } m_fileSaverStream->codec = outputCodecContext; av_dump_format(m_fileSaverCtx, 0, fileName, 1); //Open Video int ret = -1; if(!(m_fileSaverFmt->flags & AVFMT_NOFILE)) { if(avio_open(&m_fileSaverCtx->pb, fileName, AVIO_FLAG_WRITE)<0) { return E_FAIL; } } ret = avformat_write_header(m_fileSaverCtx, NULL); pts = 1; m_bRecordStatus = TRUE; m_bFindKeyFrame = FALSE; return S_OK; } HRESULT CTMReceiverVideoOutputPin::StopRecord() { m_bRecordStatus = FALSE; int ret = -1; Sleep(100); ret = av_write_trailer(m_fileSaverCtx); ret = avcodec_close(m_fileSaverStream->codec); for(int i=0; i<m_fileSaverCtx->nb_streams; i++) { av_freep(&(m_fileSaverCtx->streams[i]->codec)); av_freep(&(m_fileSaverCtx->streams[i])); } if(!(m_fileSaverFmt->flags & AVFMT_NOFILE)) { ret = avio_close(m_fileSaverCtx->pb); } av_free(m_fileSaverCtx); pts = 1; return S_OK; } ////////////////////////////////////////////////////////////////// // Audio Output Pin ////////////////////////////////////////////////////////////////// CTMReceiverAudioOutputPin::CTMReceiverAudioOutputPin(HRESULT *phr, CTMReceiverSrc *pParent, LPCWSTR pPinName) : CSourceStream(NAME("TMReceiver Source Audio Output Pin"), phr, pParent, pPinName) { m_pFrame = avcodec_alloc_frame(); m_rtSampleTime = 0; m_remainData = new BYTE[AVCODEC_MAX_AUDIO_FRAME_SIZE*3/2]; m_remainDataSize = 0; m_rtFirstFrameTime = 0; m_nDiffOrigin = 0; m_rtOffset = 10000; } CTMReceiverAudioOutputPin::~CTMReceiverAudioOutputPin() { av_free(m_pFrame); } STDMETHODIMP CTMReceiverAudioOutputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv) { return CSourceStream::NonDelegatingQueryInterface(riid, ppv); } HRESULT CTMReceiverAudioOutputPin::DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pProperties) { CheckPointer(pAlloc,E_POINTER); CheckPointer(pProperties,E_POINTER); CAutoLock cAutoLock(m_pFilter->pStateLock()); HRESULT hr = NOERROR; WAVEFORMATEX *pwi = (WAVEFORMATEX *) m_mt.Format(); pProperties->cBuffers = 1; pProperties->cbBuffer = pwi->nSamplesPerSec; pProperties->cbAlign = pwi->nBlockAlign; ASSERT(pProperties->cbBuffer); ALLOCATOR_PROPERTIES Actual; hr = pAlloc->SetProperties(pProperties,&Actual); if(FAILED(hr)) { return hr; } if(Actual.cbBuffer < pProperties->cbBuffer) { return E_FAIL; } ASSERT(Actual.cBuffers == 1); return NOERROR; } HRESULT CTMReceiverAudioOutputPin::CheckMediaType(const CMediaType *pMediaType) { CheckPointer(pMediaType, E_POINTER); if((*(pMediaType->Type())) != MEDIATYPE_Audio || !(pMediaType->IsFixedSize())) { return E_INVALIDARG; } const GUID *SubType = pMediaType->Subtype(); if(SubType == NULL) return E_INVALIDARG; if(*SubType != MEDIASUBTYPE_PCM) { return E_INVALIDARG; } WAVEFORMATEX *pwi = (WAVEFORMATEX *)pMediaType->Format(); int wBitPerSampleFromFFmpeg = 16; switch(m_pAudioCodecCtx->sample_fmt) { case AV_SAMPLE_FMT_U8: wBitPerSampleFromFFmpeg = 8; break; case AV_SAMPLE_FMT_S32: wBitPerSampleFromFFmpeg = 32; break; default: wBitPerSampleFromFFmpeg = 16; } if((pwi->nChannels != m_pAudioCodecCtx->channels) || (pwi->nSamplesPerSec != m_pAudioCodecCtx->sample_rate) || (pwi->wBitsPerSample != wBitPerSampleFromFFmpeg)) { return E_INVALIDARG; } return S_OK; } HRESULT CTMReceiverAudioOutputPin::GetMediaType(int iPosition, CMediaType *pMediaType) { if (iPosition < 0 || iPosition >= 1) { return E_FAIL; } pMediaType-> SetType(&MEDIATYPE_Audio); pMediaType-> SetSubtype(&MEDIASUBTYPE_PCM); pMediaType-> SetFormatType(&FORMAT_WaveFormatEx); WAVEFORMATEX format; format.cbSize = 0; format.wFormatTag = WAVE_FORMAT_PCM; switch (iPosition) { //case 0: // format.nSamplesPerSec = 44100; // 44.1k, stereo, 16-bit // format.nChannels = 2; // format.wBitsPerSample = 16; // break; //case 1: // format.nSamplesPerSec = 44100; // format.nChannels = 1; // format.wBitsPerSample = 16; // break; //case 2: // format.nSamplesPerSec = 44100; // format.nChannels = 2; // format.wBitsPerSample = 8; // break; //case 3: // format.nSamplesPerSec = 44100; // format.nChannels = 1; // format.wBitsPerSample = 8; // break; //case 4: // format.nSamplesPerSec = 22050; // 22.050k, stereo, 16-bit // format.nChannels = 2; // format.wBitsPerSample = 16; // break; //case 5: // format.nSamplesPerSec = 22050; // format.nChannels = 1; // format.wBitsPerSample = 16; // break; //case 6: // format.nSamplesPerSec = 22050; // format.nChannels = 2; // format.wBitsPerSample = 8; // break; //case 7: // format.nSamplesPerSec = 22050; // format.nChannels = 1; // format.wBitsPerSample = 8; // break; //case 8: // format.nSamplesPerSec = 11025; // 11.025k, stereo, 16-bit // format.nChannels = 2; // format.wBitsPerSample = 16; // break; //case 9: // format.nSamplesPerSec = 11025; // format.nChannels = 1; // format.wBitsPerSample = 16; // break; //case 10: // format.nSamplesPerSec = 11025; // format.nChannels = 2; // format.wBitsPerSample = 8; // break; //case 11: // format.nSamplesPerSec = 11025; // format.nChannels = 1; // format.wBitsPerSample = 8; // break; case 0: format.nSamplesPerSec = 48000; // 48k, stereo, 16-bit format.nChannels = 2; format.wBitsPerSample = 16; break; //case 13: // format.nSamplesPerSec = 48000; // format.nChannels = 1; // format.wBitsPerSample = 16; // break; //case 14: // format.nSamplesPerSec = 48000; // format.nChannels = 2; // format.wBitsPerSample = 8; // break; //case 15: // format.nSamplesPerSec = 48000; // format.nChannels = 1; // format.wBitsPerSample = 8; // break; //case 16: // format.nSamplesPerSec = 32000; // 32k, stereo, 16-bit // format.nChannels = 2; // format.wBitsPerSample = 16; // break; //case 17: // format.nSamplesPerSec = 32000; // format.nChannels = 1; // format.wBitsPerSample = 16; // break; //case 18: // format.nSamplesPerSec = 32000; // format.nChannels = 2; // format.wBitsPerSample = 8; // break; //case 19: // format.nSamplesPerSec = 32000; // format.nChannels = 1; // format.wBitsPerSample = 8; // break; //case 20: // format.nSamplesPerSec = 8000; // 8k, stereo, 16-bit // format.nChannels = 2; // format.wBitsPerSample = 16; // break; //case 21: // format.nSamplesPerSec = 8000; // format.nChannels = 1; // format.wBitsPerSample = 16; // break; //case 22: // format.nSamplesPerSec = 8000; // format.nChannels = 2; // format.wBitsPerSample = 8; // break; //case 23: // format.nSamplesPerSec = 8000; // format.nChannels = 1; // format.wBitsPerSample = 8; // break; //case 24: // format.nSamplesPerSec = 16000; // for rtmp streams // format.nChannels = 2; // format.wBitsPerSample = 16; } format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8; format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; pMediaType-> SetFormat(PBYTE(&format), sizeof(WAVEFORMATEX)); m_nBytePerSec = format.nAvgBytesPerSec; return NOERROR; } HRESULT CTMReceiverAudioOutputPin::GetMediaType(CMediaType *pmt) { CheckPointer(pmt,E_POINTER); CAutoLock cAutoLock(m_pFilter->pStateLock()); WAVEFORMATEX *pwi = (WAVEFORMATEX *) pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX)); if(NULL == pwi) return(E_OUTOFMEMORY); ZeroMemory(pwi, sizeof(WAVEFORMATEX)); int nFrequency = 48000; int nChannels = 2; int nBytesPerSample = 2; long lBytesPerSecond = (long) (nBytesPerSample * nFrequency * nChannels); long lBufferSize = (long) ((float) lBytesPerSecond); pwi->wFormatTag = WAVE_FORMAT_PCM; pwi->nChannels = (unsigned short)nChannels; pwi->nSamplesPerSec = nFrequency; pwi->nAvgBytesPerSec = lBytesPerSecond; pwi->wBitsPerSample = (WORD) (nBytesPerSample * 8); pwi->nBlockAlign = (WORD) (nBytesPerSample * nChannels); pmt->SetType(&MEDIATYPE_Audio); pmt->SetFormatType(&WMFORMAT_WaveFormatEx); pmt->SetTemporalCompression(FALSE); pmt->SetSubtype(&MEDIASUBTYPE_PCM); pmt->SetSampleSize(lBufferSize); return NOERROR; } HRESULT CTMReceiverAudioOutputPin::FillBuffer(IMediaSample *pms) { char tmp[1024]; sprintf(tmp," %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Audio Fill Buffer In!\n"); OutputDebugStringA(tmp); CheckPointer(pms, E_POINTER); AVPacket pkt, nextPkt; BYTE *pData, *pActualPMSData, *pDataOrigin; REFERENCE_TIME rtStart, rtStop, rtMediaStart,rtMediaStop; bool setStart = false; int lDataLen = pms->GetSize(); pData = new BYTE[lDataLen]; pDataOrigin = pData; BYTE *outBuffer = new BYTE[AVCODEC_MAX_AUDIO_FRAME_SIZE*3/2]; BYTE *outBufferOrigin = outBuffer; int outBufferSize = AVCODEC_MAX_AUDIO_FRAME_SIZE*3/2; int curDataLength = 0; av_init_packet(&pkt); int maxPktNum1 = 5; int maxPktNum2 = 2; while (m_queueBuffer.nb_packets > maxPktNum1) { while(m_queueBuffer.nb_packets > maxPktNum2) { CAutoLock lock(&m_csBuffer); m_queueBuffer.Get(&pkt,1); av_free_packet(&pkt); } } if(m_remainDataSize > 0) { memcpy(pData, m_remainData, m_remainDataSize); pData += m_remainDataSize; curDataLength += m_remainDataSize; m_remainDataSize = 0; } while(curDataLength < lDataLen) { av_init_packet(&pkt); int pktQueueRet = m_queueBuffer.Get(&pkt, 1); if(pktQueueRet == 0) { continue; } if(pktQueueRet < 0) { return S_FALSE; } if(pkt.data == NULL) { continue; } outBufferSize = AVCODEC_MAX_AUDIO_FRAME_SIZE*3/2; ZeroMemory(outBuffer, outBufferSize); { int len = avcodec_decode_audio3(m_pAudioCodecCtx, (int16_t *)outBuffer, &outBufferSize, &pkt); if(len <= 0 || outBufferSize <= 0 || outBufferSize > lDataLen) { sprintf(tmp," Audio Decode Bad!\n"); OutputDebugStringA(tmp); av_free_packet(&pkt); continue; } if(!setStart) { if(m_rtFirstFrameTime == 0) { m_rtFirstFrameTime = pkt.pts; } rtStart = (pkt.pts - m_rtFirstFrameTime) * m_rtAvgTimePerPts; setStart = true; } if(curDataLength + outBufferSize <= lDataLen) { curDataLength += outBufferSize; memcpy(pData, outBuffer, outBufferSize); pData += outBufferSize; } else { memcpy(pData, outBuffer, lDataLen-curDataLength); outBuffer += (lDataLen - curDataLength); ZeroMemory(m_remainData, AVCODEC_MAX_AUDIO_FRAME_SIZE*3/2); m_remainDataSize = outBufferSize - (lDataLen - curDataLength); memcpy(m_remainData, outBuffer, m_remainDataSize); curDataLength = lDataLen; } } av_free_packet(&pkt); } pms->GetPointer(&pActualPMSData); ZeroMemory(pActualPMSData, lDataLen); { CAutoLock cAutoLockShared(&m_cSharedState); memcpy(pActualPMSData, pDataOrigin, lDataLen); } // Sync With Video int nMediaSamplePerSec = m_nBytePerSec / lDataLen; rtStart = m_pRelatedVideoPin->m_rtStartForAudio; rtStop = m_pRelatedVideoPin->m_rtStopForAudio; /*if(rtStart == 0 && rtStop == 0) { rtStart = 0; } else { rtStart = (rtStart / (ONESEC / nMediaSamplePerSec) + 1) * (ONESEC / nMediaSamplePerSec); }*/ if(rtStop != 0 && m_nDiffOrigin == 0) { m_nDiffOrigin = m_rtSampleTime - rtStart; } /*if(m_rtSampleTime - rtStart > ONESEC/nMediaSamplePerSec*2 + m_nDiffOrigin) { rtStart = m_rtSampleTime - ONESEC/nMediaSamplePerSec*2; } else*/ { rtStart = m_rtSampleTime; } //rtStart += m_rtOffset; rtStop = rtStart + ONESEC/nMediaSamplePerSec + m_rtOffset; m_rtSampleTime = rtStop; HRESULT hr = E_FAIL; //rtStop = rtStop - rtStart; //rtStart = 0; hr = pms->SetTime(&rtStart, &rtStop); //hr = pms->SetTime(NULL,NULL); hr = pms->SetSyncPoint(TRUE); hr = pms->SetPreroll(FALSE); hr = pms->SetActualDataLength(pms->GetSize()); hr = pms->GetTime(&rtStart, &rtStop); sprintf(tmp," %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Good Audio! Start %lld - Stop:%lld\n", rtStart, rtStop); OutputDebugStringA(tmp); m_pRelatedVideoPin->m_rtStartForAudio = 0; delete[] outBufferOrigin; delete[] pDataOrigin; return NOERROR; } STDMETHODIMP CTMReceiverAudioOutputPin::Notify(IBaseFilter * pSender, Quality q) { return S_OK; } STDMETHODIMP CTMReceiverAudioOutputPin::Run() { m_rtFirstFrameTime = 0; m_rtSampleTime = 0; m_rtOffset = 0; return CSourceStream::Run(); } STDMETHODIMP CTMReceiverAudioOutputPin::Stop() { m_rtFirstFrameTime = 0; return CSourceStream::Stop(); } HRESULT CTMReceiverAudioOutputPin::InitRecord(const char* fileName) { return S_OK; } HRESULT CTMReceiverAudioOutputPin::StopRecord() { return S_OK; } ////////////////////////////////////////////////////////////////// // H264 Video Decoder ////////////////////////////////////////////////////////////////// H264Decoder::H264Decoder(void) { m_bInitialized = FALSE; } H264Decoder::~H264Decoder(void) { } int H264Decoder::Init(AVCodecContext *pCtx){ av_register_all(); avcodec_register_all(); m_pCodec = avcodec_find_decoder(CODEC_ID_H264); m_pCodecCtx = avcodec_alloc_context3(m_pCodec); (*m_pCodecCtx) = (*pCtx); if (avcodec_open2(m_pCodecCtx, m_pCodec,NULL) < 0) { return 0; } m_pFrame = avcodec_alloc_frame(); m_pImgConvertCtx = NULL; m_bInitialized = TRUE; return 0; } void H264Decoder::Release(){ if(m_pCodecCtx) { avcodec_close(m_pCodecCtx); av_free(m_pCodecCtx); m_pCodecCtx = NULL; } if(m_pFrame) { av_free(m_pFrame); m_pFrame = NULL; } if (m_pImgConvertCtx) { sws_freeContext(m_pImgConvertCtx); m_pImgConvertCtx=NULL; } } int H264Decoder::DecodeFrame(AVPicture *pic, unsigned char* img, unsigned char* data, unsigned long size){ if(!m_bInitialized) { return 0; } AVPacket pkt; int got_picture; pkt.data = data; pkt.size = size; int consumed=-1; consumed = avcodec_decode_video2(m_pCodecCtx,m_pFrame,&got_picture,&pkt); if(!got_picture){ //Release(); //Init(); return 0; } //if(m_pCodecCtx->width!=720||m_pCodecCtx->height!=576){ // return 0; //} if(m_pImgConvertCtx==NULL){ m_pImgConvertCtx = sws_getContext(m_pCodecCtx->width, m_pCodecCtx->height, m_pCodecCtx->pix_fmt, m_pCodecCtx->width, m_pCodecCtx->height, PIX_FMT_RGB32, SWS_BICUBIC, NULL, NULL, NULL); } avpicture_fill(pic, img, PIX_FMT_RGB32, m_pCodecCtx->width, m_pCodecCtx->height); m_pFrame->data[0] += m_pFrame->linesize[0] * (m_pCodecCtx->height - 1); m_pFrame->linesize[0] *= -1; m_pFrame->data[1] += m_pFrame->linesize[1] * (m_pCodecCtx->height / 2 - 1); m_pFrame->linesize[1] *= -1; m_pFrame->data[2] += m_pFrame->linesize[2] * (m_pCodecCtx->height / 2 - 1); m_pFrame->linesize[2] *= -1; sws_scale(m_pImgConvertCtx, m_pFrame->data, m_pFrame->linesize, 0, m_pCodecCtx->height, pic->data, pic->linesize); return consumed; } DWORD ReaderProc(LPVOID pParam) { //USES_CONVERSION; CTMReceiverSrc *pReceiverSrc = (CTMReceiverSrc *)pParam; pReceiverSrc->ReadAndCachePreviewPackets(); return 0; }
[ "usher2007@foxmail.com" ]
usher2007@foxmail.com
ddbbd358a087b0068f9bbdb46e73d6e324d41906
ece46d54db148fcd1717ae33e9c277e156067155
/SDK/arxsdk2011/samples/database/tbliter_dg/tbliter.cpp
5be96a58e6e9f2f50b3392df7f335bbb1fd44872
[]
no_license
15831944/ObjectArx
ffb3675875681b1478930aeac596cff6f4187ffd
8c15611148264593730ff5b6213214cebd647d23
refs/heads/main
2023-06-16T07:36:01.588122
2021-07-09T10:17:27
2021-07-09T10:17:27
384,473,453
0
1
null
2021-07-09T15:08:56
2021-07-09T15:08:56
null
UTF-8
C++
false
false
3,458
cpp
// (C) Copyright 1996-2006 by Autodesk, Inc. // // Permission to use, copy, modify, and distribute this software in // object code form for any purpose and without fee is hereby granted, // provided that the above copyright notice appears in all copies and // that both that copyright notice and the limited warranty and // restricted rights notice below appear in all supporting // documentation. // // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. // // Use, duplication, or disclosure by the U.S. Government is subject to // restrictions set forth in FAR 52.227-19 (Commercial Computer // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) // (Rights in Technical Data and Computer Software), as applicable. // // Description: // // This program demonstrates iterating over a symbol table. // Specifically the linetype table. #if defined(_DEBUG) && !defined(AC_FULL_DEBUG) #error _DEBUG should not be defined except in internal Adesk debug builds #endif #include <stdlib.h> #include <rxobject.h> #include <rxregsvc.h> #include <aced.h> #include <dbsymtb.h> #include <dbapserv.h> #include <adslib.h> #include "tchar.h" void iterateLinetypes(); void initApp(); void unloadApp(); extern "C" AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode, void*); // Opens the linetype table and iterates through all the // entries printing the name of each linetype. // // THE FOLLOWING CODE APPEARS IN THE SDK DOCUMENT. // void iterateLinetypes() { AcDbLinetypeTable *pLinetypeTbl; acdbHostApplicationServices()->workingDatabase() ->getSymbolTable(pLinetypeTbl, AcDb::kForRead); // Create a new iterator that starts at table // beginning and skips deleted. // AcDbLinetypeTableIterator *pLtIterator; pLinetypeTbl->newIterator(pLtIterator); // Walk the table, getting every table record and // printing the linetype name. // AcDbLinetypeTableRecord *pLtTableRcd; const TCHAR *pLtName; for (; !pLtIterator->done(); pLtIterator->step()) { pLtIterator->getRecord(pLtTableRcd, AcDb::kForRead); pLtTableRcd->getName(pLtName); pLtTableRcd->close(); acutPrintf(_T("\nLinetype name is: %s"), pLtName); } delete pLtIterator; pLinetypeTbl->close(); } // END CODE APPEARING IN SDK DOCUMENT. // Initialization function called from acrxEntryPoint during // kInitAppMsg case. This function is used to add commands // to the command stack. // void initApp() { acedRegCmds->addCommand(_T("ASDK_TABLETEST_COMMANDS"), _T("ASDK_ITERATE"), _T("ITERATE"), ACRX_CMD_MODAL, iterateLinetypes); } // Clean up function called from acrxEntryPoint during the // kUnloadAppMsg case. This function removes this apps // command set from the command stack. // void unloadApp() { acedRegCmds->removeGroup(_T("ASDK_TABLETEST_COMMANDS")); } // ARX entry point // AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* appId) { switch (msg) { case AcRx::kInitAppMsg: acrxDynamicLinker->unlockApplication(appId); acrxDynamicLinker->registerAppMDIAware(appId); initApp(); break; case AcRx::kUnloadAppMsg: unloadApp(); } return AcRx::kRetOK; }
[ "zhangsensen@zwcad.com" ]
zhangsensen@zwcad.com
ad8ef040508d084a00ec2e566400d1aa8aa1f807
31475b58b676a174d89b3130f869656366dc3078
/fm_model/oct_tree.cpp
fc390787b37b6e90a00788221856f9780fca1070
[]
no_license
cooper-zhzhang/engine
ed694d15b5d065d990828e43e499de9fa141fc47
b19b45316220fae2a1d00052297957268c415045
refs/heads/master
2021-06-21T07:09:37.355174
2017-07-18T14:51:45
2017-07-18T14:51:45
null
0
0
null
null
null
null
GB18030
C++
false
false
17,882
cpp
//-------------------------------------------------------------------- // 文件名: oct_tree.cpp // 内 容: // 说 明: // 创建日期: 2011年8月30日 // 创建人: 陆利民 // 版权所有: 苏州蜗牛电子有限公司 //-------------------------------------------------------------------- #include "oct_tree.h" #include "math_3d.h" #include "model_player.h" #include "../visual/vis_utils.h" #include "../public/core_mem.h" #include "../public/core_log.h" #include "../public/inlines.h" #include "../public/portable.h" // 获得贴图指定位置的ALPHA值 bool get_texture_alpha(ITexture* pTex, float u, float v, unsigned int* alpha); // 获得三角形的贴图坐标 bool get_triangle_tex_uv(model_node_t* pNode, node_material_t* pMat, unsigned int tri_id, FmVec2* uv0, FmVec2* uv1, FmVec2* uv2); #pragma pack(push, 1) struct triangle_info_t { unsigned short nMatIndex; unsigned short nTriIndex; }; #pragma pack(pop) static CModelPlayer* s_pModelRef = NULL; static model_node_t* s_pModelNode = NULL; static COctTree* s_pTraceTree = NULL; static FmVec3 s_vTraceSrc(0.0F, 0.0F, 0.0F); static FmVec3 s_vTraceDir(0.0F, 0.0F, 0.0F); static int s_nTraceAlphaRef = 0; static bool s_bTraceOnlyFront = false; static bool s_bTraceHitted = false; static trace_info_t* s_TraceResult = NULL; static FmVec3 s_vTraceCenter(0.0F, 0.0F, 0.0F); static float s_fTraceRadius = 0.0F; static const FmPlane* s_CullPlanes = NULL; static size_t s_nCullPlaneNum = 0; static CULL_FUNC s_CullFunc = NULL; static void* s_CullContext = NULL; static const FmMat4* s_CullMatrix = NULL; static FmVec3 s_vTriangle0(0.0F, 0.0F, 0.0F); static FmVec3 s_vTriangle1(0.0F, 0.0F, 0.0F); static FmVec3 s_vTriangle2(0.0F, 0.0F, 0.0F); // COctTree COctTree::COctTree() { m_pModelNode = NULL; m_vBoundMin = FmVec3(0.0F, 0.0F, 0.0F); m_vBoundMax = FmVec3(0.0F, 0.0F, 0.0F); m_pTreeData = NULL; m_nTreeSize = NULL; } COctTree::~COctTree() { if (m_pTreeData) { CORE_FREE(m_pTreeData, m_nTreeSize); } } void COctTree::Init(model_node_t* pModelNode, const FmVec3& bound_min, const FmVec3& bound_max, char* tree_data, size_t tree_size) { Assert(pModelNode != NULL); Assert(tree_data != NULL); m_pModelNode = pModelNode; m_vBoundMin = bound_min; m_vBoundMax = bound_max; m_pTreeData = tree_data; m_nTreeSize = tree_size; } bool COctTree::TraceDetail(CModelPlayer* ref, const FmVec3& src, const FmVec3& dir, int alpha_ref, bool only_front, trace_info_t& result) { Assert(m_pTreeData != NULL); if (!FmBoxBoundProbe(&m_vBoundMin, &m_vBoundMax, &src, &dir)) { // 先与包围盒做测试 return false; } s_pModelRef = ref; s_pModelNode = m_pModelNode; s_pTraceTree = this; s_vTraceSrc = src; s_vTraceDir = dir; s_nTraceAlphaRef = alpha_ref; s_bTraceOnlyFront = only_front; s_bTraceHitted = false; s_TraceResult = &result; TraceNode((COctNode*)m_pTreeData); return s_bTraceHitted; } bool COctTree::TraceHitted(CModelPlayer* ref, const FmVec3& src, const FmVec3& dir, int alpha_ref, bool only_front) { Assert(m_pTreeData != NULL); if (!FmBoxBoundProbe(&m_vBoundMin, &m_vBoundMax, &src, &dir)) { // 先与包围盒做测试 return false; } s_pModelRef = ref; s_pModelNode = m_pModelNode; s_pTraceTree = this; s_vTraceSrc = src; s_vTraceDir = dir; s_nTraceAlphaRef = alpha_ref; s_bTraceOnlyFront = only_front; s_TraceResult = NULL; return TraceNode((COctNode*)m_pTreeData); } bool COctTree::TraceNode(COctNode* node) { // 这个还是用微软的效率高一些 除非改进上面的算法 if (!FmBoxBoundProbe(&node->m_vBoundMin, &node->m_vBoundMax, &s_vTraceSrc, &s_vTraceDir)) { // 先与包围盒做测试 return false; } size_t triangle_num = node->m_nTriangleNum; if (triangle_num > 0) { triangle_info_t* pTriangleInfo = (triangle_info_t*)((char*)node + sizeof(COctNode)); for (size_t k = 0; k < triangle_num; ++k) { unsigned int mat_index = pTriangleInfo[k].nMatIndex; unsigned int tri_index = pTriangleInfo[k].nTriIndex; Assert(mat_index < s_pModelNode->nMaterialCount); node_material_t* pMat = &s_pModelNode->Materials[mat_index]; Assert(tri_index < (pMat->pLODIndexCount[0] / 3)); unsigned short* pIB = pMat->pLODIB[0]; vertex_data_t* pVB = &(pMat->SingleVB); //char* pVB = (char*)pMat->pSingleVB; //size_t stride = pMat->uSingleVertexSize; size_t index = tri_index * 3; size_t vi0 = pIB[index + 0]; size_t vi1 = pIB[index + 1]; size_t vi2 = pIB[index + 2]; Assert(vi0 < pMat->nVertexCount); Assert(vi1 < pMat->nVertexCount); Assert(vi2 < pMat->nVertexCount); //FmVec3* v0 = (FmVec3*)(pVB + vi0 * stride); //FmVec3* v1 = (FmVec3*)(pVB + vi1 * stride); //FmVec3* v2 = (FmVec3*)(pVB + vi2 * stride); FmVec3* v0 = (FmVec3*)get_vertex_by_index(pVB, vi0); FmVec3* v1 = (FmVec3*)get_vertex_by_index(pVB, vi1); FmVec3* v2 = (FmVec3*)get_vertex_by_index(pVB, vi2); float u; float v; float t; if (VisUtil_IntersectTri(v0, v1, v2, &s_vTraceSrc, &s_vTraceDir, &u, &v, &t)) { if ((t < 0.0F) || (t > 1.0F) || Port_IsNaN(t)) { continue; } if (s_bTraceOnlyFront) { // 三角形对应的平面 FmPlane plane; FmPlaneFromPoints(&plane, v0, v1, v2); // 射线起点到面的距离 float dist = FmPlaneDotCoord(&plane, &s_vTraceSrc); if (dist < 0.0F) { // 不对反面进行碰撞 continue; } } if ((s_nTraceAlphaRef > 0) && pMat->MatInfo.bAlphaTest && ((NULL == s_TraceResult) || (s_TraceResult->nHitMax > 1) || (t < s_TraceResult->fDistance))) { ITexture* pTex = pMat->MatInfo.DiffuseMap.pTex; if (pTex) { FmVec2 uv0; FmVec2 uv1; FmVec2 uv2; get_triangle_tex_uv(s_pModelNode, pMat, tri_index * 3, &uv0, &uv1, &uv2); FmVec2 uv; uv = uv0 * (1.0F - u - v) + uv1 * u + uv2 * v; unsigned int alpha = 0; get_texture_alpha(pTex, uv.x, uv.y, &alpha); if (alpha < (unsigned int)s_nTraceAlphaRef) { continue; } } //else //{ // FXLOG_ERROR("[error 030024] FXVANodeRayTraceAlpha:The destination triangle has no diffuse texture!\n"); //} } if (NULL == s_TraceResult) { // 只测试第一次碰撞 return true; } if (!s_pModelRef->SetTraceInfo(s_TraceResult, s_pModelNode, pMat, tri_index * 3, u, v, t, *v0, *v1, *v2)) { return false; } } } } if (node->m_nChildNum > 0) { if (TravelChildren(node, TraceNode)) { return true; } } return false; } bool COctTree::TraceSphere(CModelPlayer* ref, const FmVec3& center, float radius) { Assert(m_pTreeData != NULL); if (!VisUtil_BoxIntersectSphere(m_vBoundMin, m_vBoundMax, center, radius)) { // 先与包围盒做测试 return false; } s_pModelRef = ref; s_pModelNode = m_pModelNode; s_pTraceTree = this; s_vTraceCenter = center; s_fTraceRadius = radius; return TraceSphereNode((COctNode*)m_pTreeData); } // 三角形碰撞 bool COctTree::TraceTriangle(CModelPlayer* ref, const FmVec3& v0, const FmVec3& v1, const FmVec3& v2) { Assert(m_pTreeData != NULL); if (!math_intersect_bb_and_triangle(&m_vBoundMin, &m_vBoundMax, &v0, &v1, &v2)) { // 先与包围盒做测试 return false; } s_pModelRef = ref; s_pModelNode = m_pModelNode; s_pTraceTree = this; s_vTriangle0 = v0; s_vTriangle1 = v1; s_vTriangle2 = v2; return TraceTriangleNode((COctNode*)m_pTreeData); } bool COctTree::TraceSphereNode(COctNode* node) { if (!VisUtil_BoxIntersectSphere(node->m_vBoundMin, node->m_vBoundMax, s_vTraceCenter, s_fTraceRadius)) { // 先与包围盒做测试 return false; } size_t triangle_num = node->m_nTriangleNum; if (triangle_num > 0) { triangle_info_t* pTriangleInfo = (triangle_info_t*)((char*)node + sizeof(COctNode)); for (size_t k = 0; k < triangle_num; ++k) { unsigned int mat_index = pTriangleInfo[k].nMatIndex; unsigned int tri_index = pTriangleInfo[k].nTriIndex; Assert(mat_index < s_pModelNode->nMaterialCount); node_material_t* pMat = &s_pModelNode->Materials[mat_index]; Assert(tri_index < (pMat->pLODIndexCount[0] / 3)); unsigned short* pIB = pMat->pLODIB[0]; vertex_data_t* pVB = &(pMat->SingleVB); //char* pVB = (char*)pMat->pSingleVB; //size_t stride = pMat->uSingleVertexSize; size_t index = tri_index * 3; size_t vi0 = pIB[index + 0]; size_t vi1 = pIB[index + 1]; size_t vi2 = pIB[index + 2]; Assert(vi0 < pMat->nVertexCount); Assert(vi1 < pMat->nVertexCount); Assert(vi2 < pMat->nVertexCount); //FmVec3* v0 = (FmVec3*)(pVB + vi0 * stride); //FmVec3* v1 = (FmVec3*)(pVB + vi1 * stride); //FmVec3* v2 = (FmVec3*)(pVB + vi2 * stride); FmVec3* v0 = (FmVec3*)get_vertex_by_index(pVB, vi0); FmVec3* v1 = (FmVec3*)get_vertex_by_index(pVB, vi1); FmVec3* v2 = (FmVec3*)get_vertex_by_index(pVB, vi2); if (math_sphere_triangle_collision(s_vTraceCenter, s_fTraceRadius, *v0, *v1, *v2)) { return true; } } } if (node->m_nChildNum > 0) { if (TravelChildren(node, TraceSphereNode)) { return true; } } return false; } bool COctTree::TraceTriangleNode(COctNode* node) { if (!math_intersect_bb_and_triangle(&node->m_vBoundMin, &node->m_vBoundMax, &s_vTriangle0, &s_vTriangle1, &s_vTriangle2)) { // 先与包围盒做测试 return false; } size_t triangle_num = node->m_nTriangleNum; if (triangle_num > 0) { triangle_info_t* pTriangleInfo = (triangle_info_t*)((char*)node + sizeof(COctNode)); for (size_t k = 0; k < triangle_num; ++k) { unsigned int mat_index = pTriangleInfo[k].nMatIndex; unsigned int tri_index = pTriangleInfo[k].nTriIndex; Assert(mat_index < s_pModelNode->nMaterialCount); node_material_t* pMat = &s_pModelNode->Materials[mat_index]; Assert(tri_index < (pMat->pLODIndexCount[0] / 3)); unsigned short* pIB = pMat->pLODIB[0]; vertex_data_t* pVB = &(pMat->SingleVB); //char* pVB = (char*)pMat->pSingleVB; //size_t stride = pMat->uSingleVertexSize; size_t index = tri_index * 3; size_t vi0 = pIB[index + 0]; size_t vi1 = pIB[index + 1]; size_t vi2 = pIB[index + 2]; Assert(vi0 < pMat->nVertexCount); Assert(vi1 < pMat->nVertexCount); Assert(vi2 < pMat->nVertexCount); //FmVec3* v0 = (FmVec3*)(pVB + vi0 * stride); //FmVec3* v1 = (FmVec3*)(pVB + vi1 * stride); //FmVec3* v2 = (FmVec3*)(pVB + vi2 * stride); FmVec3* v0 = (FmVec3*)get_vertex_by_index(pVB, vi0); FmVec3* v1 = (FmVec3*)get_vertex_by_index(pVB, vi1); FmVec3* v2 = (FmVec3*)get_vertex_by_index(pVB, vi2); if (math_triangle_triangle_collision(s_vTriangle0, s_vTriangle1, s_vTriangle2, *v0, *v1, *v2)) { return true; } } } if (node->m_nChildNum > 0) { if (TravelChildren(node, TraceSphereNode)) { return true; } } return false; } bool COctTree::Cull(CModelPlayer* ref, const FmPlane* planes, size_t plane_num, const FmVec3& center, float radius, CULL_FUNC cull_func, void* context, const FmMat4& mat) { Assert(m_pTreeData != NULL); if (!VisUtil_BoxIntersectSphere(m_vBoundMin, m_vBoundMax, center, radius)) { // 先与包围盒做测试 return false; } s_pModelRef = ref; s_pModelNode = m_pModelNode; s_pTraceTree = this; s_vTraceCenter = center; s_fTraceRadius = radius; s_CullPlanes = planes; s_nCullPlaneNum = plane_num; s_CullFunc = cull_func; s_CullContext = context; s_CullMatrix = &mat; CullNode((COctNode*)m_pTreeData); return true; } bool COctTree::CullNode(COctNode* node) { if (!VisUtil_BoxIntersectSphere(node->m_vBoundMin, node->m_vBoundMax, s_vTraceCenter, s_fTraceRadius)) { // 先与包围盒做测试 return false; } size_t triangle_num = node->m_nTriangleNum; if (triangle_num > 0) { triangle_info_t* pTriangleInfo = (triangle_info_t*)((char*)node + sizeof(COctNode)); FmVec3 v[3]; for (size_t k = 0; k < triangle_num; ++k) { unsigned int mat_index = pTriangleInfo[k].nMatIndex; unsigned int tri_index = pTriangleInfo[k].nTriIndex; Assert(mat_index < s_pModelNode->nMaterialCount); node_material_t* pMat = &s_pModelNode->Materials[mat_index]; Assert(tri_index < (pMat->pLODIndexCount[0] / 3)); unsigned short* pIB = pMat->pLODIB[0]; vertex_data_t* pVB = &(pMat->SingleVB); //char* pVB = (char*)pMat->pSingleVB; //size_t stride = pMat->uSingleVertexSize; size_t index = tri_index * 3; size_t vi0 = pIB[index + 0]; size_t vi1 = pIB[index + 1]; size_t vi2 = pIB[index + 2]; Assert(vi0 < pMat->nVertexCount); Assert(vi1 < pMat->nVertexCount); Assert(vi2 < pMat->nVertexCount); //FmVec3* v0 = (FmVec3*)(pVB + vi0 * stride); //FmVec3* v1 = (FmVec3*)(pVB + vi1 * stride); //FmVec3* v2 = (FmVec3*)(pVB + vi2 * stride); FmVec3* v0 = (FmVec3*)get_vertex_by_index(pVB, vi0); FmVec3* v1 = (FmVec3*)get_vertex_by_index(pVB, vi1); FmVec3* v2 = (FmVec3*)get_vertex_by_index(pVB, vi2); if (s_nCullPlaneNum > 0) { // 使用剪裁面 FmVec3 bound_min = *v0; FmVec3 bound_max = *v0; FmVec3Minimize(&bound_min, &bound_min, v1); FmVec3Minimize(&bound_min, &bound_min, v2); FmVec3Maximize(&bound_max, &bound_max, v1); FmVec3Maximize(&bound_max, &bound_max, v2); FmVec3 center = (bound_min + bound_max) * 0.5F; float sx = (bound_max.x - bound_min.x) * 0.5F; float sy = (bound_max.y - bound_min.y) * 0.5F; float sz = (bound_max.z - bound_min.z) * 0.5F; float radius_sq = sx * sx + sy * sy + sz * sz; bool bIn = true; for (size_t p = 0; p < s_nCullPlaneNum; p++) { float dist = FmPlaneDotCoord(&s_CullPlanes[p], &center); if (dist < 0.0F) { continue; } if ((dist * dist) > radius_sq) { bIn = false; break; } } if (!bIn) { continue; } } else { // 只用球体做碰撞检测 if (!math_sphere_triangle_aabb_collision(s_vTraceCenter, s_fTraceRadius, *v0, *v1, *v2)) { continue; } } FmVec3TransformCoord(&v[0], v0, &s_pModelRef->GetCurrentTM()); FmVec3TransformCoord(&v[1], v1, &s_pModelRef->GetCurrentTM()); FmVec3TransformCoord(&v[2], v2, &s_pModelRef->GetCurrentTM()); FmMat4 mtxWorldInverse; FmMat4Inverse(&mtxWorldInverse, NULL, &s_pModelRef->GetWorldTM()); // FmVec3TransformCoordArray(&v[0], sizeof(FmVec3), // &v[0], sizeof(FmVec3), &mtxWorldInverse, 3); for( int j = 0; j < 3 ; j++ ) FmVec3TransformCoord( &v[j], &v[j], &mtxWorldInverse ); //v[0] = *v0; //v[1] = *v1; //v[2] = *v2; if (!s_CullFunc(s_CullContext, *s_CullMatrix, &v[0], 3)) { return true; } } } if (node->m_nChildNum > 0) { if (TravelChildren(node, CullNode)) { return true; } } return false; } bool COctTree::TravelChildren(COctNode* node, bool (*travel_func)(COctNode*)) { char* p = (char*)node + sizeof(COctNode) + node->m_nTriangleNum * sizeof(unsigned int); unsigned int child_mask = node->m_nChildMask; char* tree_data = s_pTraceTree->m_pTreeData; if (child_mask & 0x1) { // 节点000 unsigned int child_offset = *(unsigned int*)p; Assert(child_offset < s_pTraceTree->m_nTreeSize); COctNode* pChild = (COctNode*)(tree_data + child_offset); if (travel_func(pChild)) { return true; } p += sizeof(unsigned int); } if (child_mask & 0x2) { // 节点001 unsigned int child_offset = *(unsigned int*)p; Assert(child_offset < s_pTraceTree->m_nTreeSize); COctNode* pChild = (COctNode*)(tree_data + child_offset); if (travel_func(pChild)) { return true; } p += sizeof(unsigned int); } if (child_mask & 0x4) { // 节点010 unsigned int child_offset = *(unsigned int*)p; Assert(child_offset < s_pTraceTree->m_nTreeSize); COctNode* pChild = (COctNode*)(tree_data + child_offset); if (travel_func(pChild)) { return true; } p += sizeof(unsigned int); } if (child_mask & 0x8) { // 节点011 unsigned int child_offset = *(unsigned int*)p; Assert(child_offset < s_pTraceTree->m_nTreeSize); COctNode* pChild = (COctNode*)(tree_data + child_offset); if (travel_func(pChild)) { return true; } p += sizeof(unsigned int); } if (child_mask & 0x10) { // 节点100 unsigned int child_offset = *(unsigned int*)p; Assert(child_offset < s_pTraceTree->m_nTreeSize); COctNode* pChild = (COctNode*)(tree_data + child_offset); if (travel_func(pChild)) { return true; } p += sizeof(unsigned int); } if (child_mask & 0x20) { // 节点101 unsigned int child_offset = *(unsigned int*)p; Assert(child_offset < s_pTraceTree->m_nTreeSize); COctNode* pChild = (COctNode*)(tree_data + child_offset); if (travel_func(pChild)) { return true; } p += sizeof(unsigned int); } if (child_mask & 0x40) { // 节点110 unsigned int child_offset = *(unsigned int*)p; Assert(child_offset < s_pTraceTree->m_nTreeSize); COctNode* pChild = (COctNode*)(tree_data + child_offset); if (travel_func(pChild)) { return true; } p += sizeof(unsigned int); } if (child_mask & 0x80) { // 节点111 unsigned int child_offset = *(unsigned int*)p; Assert(child_offset < s_pTraceTree->m_nTreeSize); COctNode* pChild = (COctNode*)(tree_data + child_offset); if (travel_func(pChild)) { return true; } p += sizeof(unsigned int); } return false; }
[ "1542971595@qq.com" ]
1542971595@qq.com
03ecbe1c081066592dabb02bc51916ee09eb0384
a0dbfb684fade8bd01b3729c561ebb382303be75
/LIB/tubemodel_3.01_win/6C4.inc
12d3a85863e8942c1ebc2d7446fcf3fb2fe0aef0
[]
no_license
sa66ath/LTSpice
4bfd129d7bb05e05f3c860d2f6208c0aecacb3be
fe5c38508f0498e6fd065c0fcd60bf5dd980c72e
refs/heads/master
2021-06-26T10:09:26.590934
2017-09-13T08:36:24
2017-09-13T08:36:24
103,091,498
0
0
null
null
null
null
UTF-8
C++
false
false
789
inc
* * Generic triode model: 6C4 * Copyright 2003--2006 by Ayumi Nakabayashi, All rights reserved. * Version 3.01, Generated on Wed Mar 22 17:19:50 2006 .SUBCKT 6C4 A G K BGG GG 0 V=V(G,K)+0.736372 BEP EP 0 V=URAMP(V(A,K))+1e-10 BEG EG 0 V=URAMP(V(G,K))+1e-10 BM1 M1 0 V=(0.038076967*(URAMP(V(EP)-1e-10)+1e-10))^-1.295136 BM2 M2 0 V=(0.53664652*(URAMP(V(GG)+V(EP)/12.168865)+1e-10))^2.795136 BP P 0 V=0.0010502869*(URAMP(V(GG)+V(EP)/22.675755)+1e-10)^1.5 BIK IK 0 V=U(V(GG))*V(P)+(1-U(V(GG)))*0.00086837935*V(M1)*V(M2) BIG IG 0 V=0.00055989418*V(EG)^1.5*(V(EG)/(V(EP)+V(EG))*1.2+0.4) BIAK A K I=URAMP(V(IK,IG)-URAMP(V(IK,IG)-(0.00049903612*V(EP)^1.5)))+1e-10*V(A,K) BIGK G K I=V(IG) * CAPS CGA G A 1.6p CGK G K 1.8p CAK A K 1.3p .ENDS
[ "sa66ath@yahoo.co.jp" ]
sa66ath@yahoo.co.jp
a8e9337b4ab9b5567f720b5f675083691cfdad04
6acd44f44879352cf0dced0ce6735a47d76332b5
/TestingGrounds/TestingGrounds.cpp
de164b2ba0f09c6bbc52a8eaac9365205e89f8d6
[]
no_license
Timothy-Hagler/StoreDatabase
3f7cf7341a932b0243ef58282ce6433831d42acc
07ecafa485f038a12fc07b778ce89a3ee293605d
refs/heads/master
2023-01-07T22:03:34.042021
2020-11-09T17:21:31
2020-11-09T17:21:31
289,564,415
0
0
null
null
null
null
UTF-8
C++
false
false
820
cpp
// TestingGrounds.cpp : This file contains the 'main' function. Program execution begins and ends there. // /*#include <iostream> int main() { std::cout << "Hello World!\n"; } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu // Tips for Getting Started: // 1. Use the Solution Explorer window to add/manage files // 2. Use the Team Explorer window to connect to source control // 3. Use the Output window to see build output and other messages // 4. Use the Error List window to view errors // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file */
[ "tmhglr@gmail.com" ]
tmhglr@gmail.com
1c5f03f4c027aebb3ceef77c66ebe91c9705f678
761c1ae19594e49d7047d059b25640c3e558f3d5
/Facebook/238. Product of Array Except Self.cpp
4436c043df57594990756fb089a37195dd9b6ce4
[]
no_license
SunNEET/LeetCode
a09772c4f3c23788afebceb4f6c2150d3c127695
96b08c45f5241579aaf27625510570d718965ec2
refs/heads/master
2020-03-12T15:43:07.019708
2019-06-25T03:53:56
2019-06-25T03:53:56
130,697,627
0
0
null
null
null
null
UTF-8
C++
false
false
2,707
cpp
// O(n) time and O(n) space class Solution { // 假如我們有 nums = [a,b,c,d,e] 五個數,要讓他們乘上不同的數 x[i] 後的乘積都會一樣大。 // 直覺做法是,讓他乘起來會變成 a*b*c*d*e,因為這是個保證大家都可以乘出來的數字。 // 而要乘出這個數自然就是用 a[i]本身 乘上 剩下的部分。 // E.g. a[2] = c 要變成 a*b*c*d*e ,還需要乘 a*b 和 d*e,而在處理這個剩下的部分有個技巧 // 就是用兩個 array 紀錄從左乘到右 (a*b*....) 和 從右乘到左 (e*d*.....) // 這樣再用一個for迴圈掃過 nums 時就把他左右兩側的乘積再乘起來就好 public: vector<int> productExceptSelf(vector<int>& nums) { int n = nums.size(); vector<int> ans(n); vector<int> prefix(n); // prefix[i] denotes a product from nums[0] to nums[i-1] vector<int> suffix(n); // suffix[i] denotes a product from nums[n-i] to nums[n-1] prefix[0]=1; suffix[0]=1; for(int i=1;i<n;i++) { prefix[i] = prefix[i-1]*nums[i-1]; suffix[i] = suffix[i-1]*nums[n-i]; } for(int i=0;i<n;i++) ans[i] = prefix[i]*suffix[n-1-i]; return ans; } }; // O(n) time and O(1) space except the ans array class Solution { // 已經知道 ans 裡每格該填什麼了,現在要做的是不用額外的空間來存 prefix 和 suffix // 其實就是直接維護一個 prefix 的值和一個 suffix 的值,執行 for 迴圈掃過去的時候 // 他們分別從左右兩側往另一側移動,所以也可以看成有兩個 two pointers // 當prefix的 pointer 經過 nums[i] 和 suffix 的 pointer 經過 nums[n-1-i] 的時候 // 就把目前的值乘到他們經過的位置上 // 換句話說,一個ans[i]會先拿到他該有的 prefix 或 suffix 某一側的乘積,然後才會拿到另一側的 // e.g nums = [a,b,c,d,e], ans are suppose to be [b*c*d*e, a*c*d*e,......, a*b*c*d] // 對於 ans 的第二個元素 ans[1], 他會先拿到 prefix = a, 然後把 prefix 乘上自己的value向右傳 // 之後才有已經乘好的 suffix = c*d*e 過來乘給他 public: vector<int> productExceptSelf(vector<int>& nums) { int n = nums.size(); vector<int> ans(n,1); int prefix=1; // prefix[i] denotes a product from nums[0] to nums[i-1] int suffix=1; // suffix[i] denotes a product from nums[n-i] to nums[n-1] for(int i=0;i<nums.size();i++) { ans[i] *= prefix; prefix *= nums[i]; ans[n-1-i] *= suffix; suffix *= nums[n-1-i]; } return ans; } };
[ "sunnyinvadeher@gmail.com" ]
sunnyinvadeher@gmail.com
2585fbe1f3144be098cc023825cf2e62ed851410
43c90833ed09d0358c78408663ebd8b231a2b055
/Lib/CosmoBolognaLib/Headers/Lib/TwoPointCorrelation_multipoles.h
c6c31a4df4e60250f31267af7f62aae6f51156ca
[]
no_license
ready4euclid/pipeline
7b45c9b41e4c701d3c5b85bfc1130960c3f484e0
cdc51fbeb11869a1e006ae1bc24b50dfae6fc48a
refs/heads/master
2021-01-15T15:52:04.866110
2016-11-30T10:30:55
2016-11-30T10:30:55
51,307,731
1
0
null
null
null
null
UTF-8
C++
false
false
23,266
h
/******************************************************************** * Copyright (C) 2010 by Federico Marulli and Alfonso Veropalumbo * * federico.marulli3@unibo.it * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public * * License along with this program; if not, write to the Free * * Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ********************************************************************/ /** * @file Headers/Lib/TwoPointCorrelation_multipoles.h * * @brief The class TwoPointCorrelation_multipoles * * This file defines the interface of the class * TwoPointCorrelation_multipoles, used to measure the first three * multipole moments of the two-point correlation function * * @authors Federico Marulli, Alfonso Veropalumbo * * @authors federico.marulli3@unbo.it, alfonso.veropalumbo@unibo.it */ #ifndef __TWOPOINTMULT__ #define __TWOPOINTMULT__ #include "TwoPointCorrelation2D_polar.h" // =================================================================================================== namespace cosmobl { namespace twopt { /** * @class TwoPointCorrelation_multipoles * TwoPointCorrelation_multipoles.h * "Headers/Lib/TwoPointCorrelation_multipoles.h" * * @brief The class TwoPointCorrelation_multipoles * * This class is used to handle objects of type <EM> * TwoPointCorrelation_multipoles </EM>. It is used to measure * the first three multipole moments of the two-point correlation * function, i.e. the monopole, the quadrupole and the * exadecupole \f$\xi_l(r) = (2l+1) \int_{\mu_{min}}^{\mu_{max}} * \xi(s,\mu) L_l(\mu) d\mu\f$, with \f$l=0,2,4\f$. If * \f$\mu_{min}\neq0\f$ and \f$\mu_{max}\neq1\f$, the algorithm * provides the truncated multipoles ( * http://arxiv.org/abs/1502.05045 ). * * This class uses the so-called <EM> integrated </EM> method * (e.g. http://arxiv.org/abs/1105.2037 , appendix E). This * method is unbiased even in presence of wide angle and observer * angle effects, i.e. if the random-random (RR) pairs depend * also on \f$\mu\f$. However it is more affected by numerical * uncertainties, relative to the <EM> direct </EM> method, due * to the numerical integration. Moreover, it requires a large * enough random catalogue, in order to have random pairs in each * angular bin. * * The monopole estimated with the <EM> direct </EM> method can be * obtained with the class TwoPointCorrelation1D_monopole. */ class TwoPointCorrelation_multipoles : public TwoPointCorrelation2D_polar { protected: /** * @brief measure the multipoles of the two-point correlation * function * * @param rr absolute separation * * @param mu angular separation * * @param xi 2dD cartesian two-point correlation function * * @param error_xi errors on the 2d polar two-point correlation * function * * @return pointer to an object of type Data */ shared_ptr<data::Data> Multipoles (const vector<double> rr, const vector<double> mu, const vector<vector<double>> xi, const vector<vector<double>> error_xi) override; /** * @brief return a data object with extra info * * @param rad vector containing the binned separations * * @param xil vector containing the binned multipoles of the * correlation function * * @param error vector containing the errors * * @return pointer to an object of type Data */ shared_ptr<data::Data> data_with_extra_info (const vector<double> rad, const vector<double> xil, const vector<double> error) const; /** * @brief measure the first three multipoles of the two-point * correlation function with Poisson errors * * @param dir_output_pairs output directory used to store the * number of pairs * * @param dir_input_pairs vector of input directories used to * store the number of pairs (if the pairs are read from files) * * @param count_dd true &rarr; count the number of data-data * pairs; false &rarr; read the number of data-data pairs from * file * * @param count_rr true &rarr; count the number of * random-random pairs; false &rarr; read the number of * random-random pairs from file * * @param count_dr true &rarr; count the number of data-random * pairs; false &rarr; read the number of data-random pairs * * @param tcount true &rarr; activate the time counter; false * &rarr; no time counter * * @param estimator the estimator used to measure the two-point * correlation function * * @return none */ void measurePoisson (const string dir_output_pairs = par::defaultString, const vector<string> dir_input_pairs={}, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=_LandySzalay_) override; /** * @brief measure the first three multipoles of the two-point * correlation function estimating the covariance with * Jackknife resampling * * @param dir_output_pairs output directory used to store the * number of pairs * * @param dir_input_pairs vector of input directories used to * store the number of pairs (if the pairs are read from files) * * @param dir_output_resample output directory used to store * the Jackknife resampling correlation functions, with Poisson * errors * * @param count_dd true &rarr; count the number of data-data * pairs; false &rarr; read the number of data-data pairs from * file * * @param count_rr true &rarr; count the number of * random-random pairs; false &rarr; read the number of * random-random pairs from file * * @param count_dr true &rarr; count the number of data-random * pairs; false &rarr; read the number of data-random pairs * * @param tcount true &rarr; activate the time counter; false * &rarr; no time counter * * @param estimator the estimator used to measure the two-point * correlation function * * @return none */ void measureJackknife (const string dir_output_pairs = par::defaultString, const vector<string> dir_input_pairs={}, const string dir_output_resample = par::defaultString, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=_LandySzalay_) override; /** * @brief measure the first three multipoles of the two-point * correlation function estimating the covariance with * Bootstrap resampling * * @param nMocks number of mocks to be generated with bootstrap * resampling * * @param dir_output_pairs output directory used to store the * number of pairs * * @param dir_input_pairs vector of input directories used to * store the number of pairs (if the pairs are read from files) * * @param dir_output_resample output directory used to store * the Bootstrap resampling correlation function, with Poisson * errors * * @param count_dd true &rarr; count the number of data-data * pairs; false &rarr; read the number of data-data pairs from * file * * @param count_rr true &rarr; count the number of * random-random pairs; false &rarr; read the number of * random-random pairs from file * * @param count_dr true &rarr; count the number of data-random * pairs; false &rarr; read the number of data-random pairs * * @param tcount true &rarr; activate the time counter; false * &rarr; no time counter * * @param estimator the estimator used to measure the two-point * correlation function * * @return none */ void measureBootstrap (const int nMocks, const string dir_output_pairs = par::defaultString, const vector<string> dir_input_pairs={}, const string dir_output_resample = par::defaultString, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=_LandySzalay_) override; /** * @brief measure the jackknife resampling of the first three * multipoles of the two-point correlation function * * @param dd vector of data-data pairs, divided per regions * * @param rr vector of random-random pairs, divided per regions * * @return none */ vector<shared_ptr<data::Data>> XiJackknife (const vector<shared_ptr<pairs::Pair>> dd, const vector<shared_ptr<pairs::Pair>> rr) override; /** * @brief measure the jackknife resampling of the first three * multipoles of the two-point correlation function * * @param dd vector of data-data pairs, divided per regions * * @param rr vector of random-random pairs, divided per regions * * @param dr vector of random-random pairs, divided per regions * * @return a vector of pointers to objects of type Data */ vector<shared_ptr<data::Data>> XiJackknife (const vector<shared_ptr<pairs::Pair>> dd, const vector<shared_ptr<pairs::Pair>> rr, const vector<shared_ptr<pairs::Pair>> dr) override; /** * @brief measure the bootstrap resampling of the first three * multipoles of the two-point correlation function * * @param nMocks number of bootstrap resamplings * * @param dd vector of data-data pairs, divided per regions * * @param rr vector of random-random pairs, divided per regions * * @return a vector of pointers to objects of type Data */ vector<shared_ptr<data::Data>> XiBootstrap (const int nMocks, const vector<shared_ptr<pairs::Pair>> dd, const vector<shared_ptr<pairs::Pair>> rr) override; /** * @brief measure the bootstrap resampling of the two-point correlation * function, &xi;(r) * * @param nMocks number of bootstrap resamplings * * @param dd vector of data-data pairs, divided per regions * * @param rr vector of random-random pairs, divided per regions * * @param dr vector of random-random pairs, divided per regions * * @return a vector of pointers to objects of type Data */ vector<shared_ptr<data::Data>> XiBootstrap (const int nMocks, const vector<shared_ptr<pairs::Pair>> dd, const vector<shared_ptr<pairs::Pair>> rr, const vector<shared_ptr<pairs::Pair>> dr) override; public: /** * @name Constructors/destructors */ ///@{ /** * @brief default constructor * @return object of class TwoPointCorrelation_multipoles */ TwoPointCorrelation_multipoles () { m_twoPType = _1D_multipoles_; } /** * @brief constructor * @param data object of class Catalogue containing the input * catalogue * @param random of class Catalogue containing the random data * catalogue * @param binType_rad binning type in absolute separations * @param rMin minimum absolute separation used to count * the pairs * @param rMax maximum absolute separation used to count * the pairs * @param nbins_rad number of bins in the absolute * separation * @param shift_rad shift parameter in the absolute * separation, i.e. the radial shift is binSize*shift * @param muMin minimum angular used to count the pairs * @param muMax maximum angular used to count the pairs * @param nbins_mu number of bins in the angular * separation * @param shift_mu shift parameter in the angular * separation, i.e. the radial shift is binSize*shift * @param angularUnits angular units * @param angularWeight angular weight function * @param compute_extra_info true &rarr; compute extra * information related to the pairs, such as the mean pair * separation and redshift * @return object of class TwoPointCorrelation2D_polar */ TwoPointCorrelation_multipoles (catalogue::Catalogue data, catalogue::Catalogue random, const binType binType_rad, const double rMin, const double rMax, const int nbins_rad, const double shift_rad, const double muMin, const double muMax, const int nbins_mu, const double shift_mu, const CoordUnits angularUnits=_radians_, function<double(double)> angularWeight=nullptr, const bool compute_extra_info=false) : TwoPointCorrelation2D_polar(data, random, binType_rad, rMin, rMax, nbins_rad, shift_rad, _linear_, muMin, muMax, nbins_mu, shift_mu, angularUnits, angularWeight, compute_extra_info) { m_twoPType = _1D_multipoles_; } /** * @brief constructor * @param data object of class Catalogue containing the input * catalogue * @param random of class Catalogue containing the random data * catalogue * @param binType_rad binning type in absolute separations * @param rMin minimum absolute separation used to count * the pairs * @param rMax maximum absolute separation used to count * the pairs * @param binSize_rad bin size in the absolute separation * @param shift_rad shift parameter in the absolute * separation, i.e. the radial shift is binSize*shift * @param muMin minimum angular separation used to count * the pairs * @param muMax maximum angular separation used to count * the pairs * @param binSize_mu bin size in the angular separation * @param shift_mu shift parameter in the angular * separation, i.e. the radial shift is binSize*shift * @param angularUnits angular units * @param angularWeight angular weight function * @param compute_extra_info true &rarr; compute extra * information related to the pairs, such as the mean pair * separation and redshift * @return object of class TwoPointCorrelation_multipoles */ TwoPointCorrelation_multipoles (catalogue::Catalogue data, catalogue::Catalogue random, const binType binType_rad, const double rMin, const double rMax, const double binSize_rad, const double shift_rad, const double muMin, const double muMax, const double binSize_mu, const double shift_mu, const CoordUnits angularUnits=_radians_, function<double(double)> angularWeight=nullptr, const bool compute_extra_info=false) : TwoPointCorrelation2D_polar(data, random, binType_rad, rMin, rMax, binSize_rad, shift_rad, _linear_, muMin, muMax, binSize_mu, shift_mu, angularUnits, angularWeight, compute_extra_info) { m_twoPType = _1D_multipoles_; } /** * @brief default destructor * @return none */ ~TwoPointCorrelation_multipoles () = default; ///@} /** * @name Member functions to count the number of pairs and measure the two-point correlation function */ ///@{ /** * @brief get the x coordinates * @return the x coordinates */ vector<double> xx () const override; /** * @brief get the y coordinates * @return the y coordinates */ vector<double> yy () const { cosmobl::ErrorCBL("Error in yy() of TwoPointCorrelation_multipoles.h!"); vector<double> vv; return vv; } /** * @brief get the the binned correlation function * @return the binned correlation function */ vector<double> xi1D () const { cosmobl::ErrorCBL("Error in xi1D() of TwoPointCorrelation_multipoles.h!"); vector<double> vv; return vv; } /** * @brief get the error on the binned correlation function * function * @return the error on the binned correlation function * function */ vector<double> error1D () const { cosmobl::ErrorCBL("Error in error1D() of TwoPointCorrelation_multipoles.h!"); vector<double> vv; return vv; } /** * @brief get the the binned correlation function * @return the binned correlation function */ vector<vector<double>> xi2D () const { cosmobl::ErrorCBL("Error in xi2D() of TwoPointCorrelation_multipoles.h!"); vector<vector<double>> vv; return vv; } /** * @brief get the error on the binned correlation function * function * @return the error on the binned correlation function * function */ vector<vector<double>> error2D () const { cosmobl::ErrorCBL("Error in error2D() of TwoPointCorrelation_multipoles.h!"); vector<vector<double>> vv; return vv; } /** * @brief get the monopole of the polar xi * @return the xiMonopole */ vector<double> xiMonopole () const override; /** * @brief get the error on the monopole of the polar xi * @return the error on the Monopole */ vector<double> errorMonopole () const override; /** * @brief get the quadrupole of the polar xi * @return the Quadrupole */ vector<double> xiQuadrupole () const override; /** * @brief get the error on the quadrupole of the polar xi * @return the error on the Quadrupole */ vector<double> errorQuadrupole () const override; /** * @brief get the octupole of the polar xi * @return the Octupole */ vector<double> xiOctupole () const override; /** * @brief get the error on the octupole of the polar xi * @return the error on Octupole */ vector<double> errorOctupole () const override; /** * @brief measure the first three multipoles of the two-point * correlation function * * @param errorType type of error * * @param dir_output_pairs output directory used to store the * number of pairs * * @param dir_input_pairs vector of input directories used to * store the number of pairs (if the pairs are read from files) * * @param dir_output_resample output directory of the * resampled correlation function * * @param nMocks number of resampling used for bootstrap * * @param count_dd true &rarr; count the number of data-data * pairs; false &rarr; read the number of data-random pairs from * file * * @param count_rr true &rarr; count the number of random-random * pairs; false &rarr; read the number of random-random pairs * * @param count_dr true &rarr; count the number of data-random * pairs; false &rarr; read the number of data-random pairs * * @param tcount true &rarr; activate the time counter; false * &rarr; no time counter * * @param estimator the estimator used to measure the two-point * correlation function * * @return none */ void measure (const ErrorType errorType=ErrorType::_Poisson_, const string dir_output_pairs=par::defaultString, const vector<string> dir_input_pairs={}, const string dir_output_resample=par::defaultString, const int nMocks=0, const bool count_dd=true, const bool count_rr=true, const bool count_dr=true, const bool tcount=true, const Estimator estimator=_LandySzalay_) override; ///@} /** * @name Input/Output methods */ ///@{ /** * @brief read the multipoles of the two-point correlation * function * @param dir input directory * @param file input file * @return none */ void read (const string dir, const string file) override { (void)dir; (void)file; ErrorCBL("Error in TwoPointCorrelation_multipoles::read of TwoPointCorrelation_multipoles.h: work in progress!", glob::ExitCode::_workInProgress_); } /** * @brief write the multipoles of the two-point correlation * function * @param dir output directory * @param file output file * @param rank cpu index (for MPI usage) * @return none */ void write (const string dir=par::defaultString, const string file=par::defaultString, const int rank=0) const override; ///@} /** * @name Member functions to compute, read and write covariance matrix */ ///@{ /** * @brief read the measured covariance matrix * @param dir input directory * @param file input file * @return none */ virtual void read_covariance_matrix (const string dir, const string file) override; /** * @brief write the measured two-point correlation * @param dir output directory * @param file output file * @return none */ virtual void write_covariance_matrix (const string dir, const string file) const override; /** * @brief compute the covariance matrix * @param xi_collection vector containing the xi to compute the covariance matrix * @param doJK 1 &rarr; compute jackknife covariance matrix; 0 compute standard covariance matrix * @return none */ virtual void compute_covariance_matrix (vector<shared_ptr<data::Data>> xi_collection, bool doJK) override; /** * @brief compute the covariance matrix * @param file_xi vector containing the path to the xi to compute the covariance matrix * @param doJK 1 &rarr; compute jackknife covariance matrix; 0 compute standard covariance matrix * @return none */ virtual void compute_covariance_matrix (vector<string> file_xi, bool doJK) override; ///@} }; } } #endif
[ "federico.marulli3@unibo.it" ]
federico.marulli3@unibo.it
a6c608634456a81fc320854aabc7dfe01a4827cc
2b354b4180af895e1042a9e596b8d5abdc88d9c8
/lib/assembler/include/assembler.h
04010f7ac8f751eccc5ee8d5802fee2aefcc8e04
[ "MIT" ]
permissive
lschiavini/Hypothetical-Language-Assembler
cd222ff9fdada2e6d83bc95f494e71fad2f6f064
e47f01241bbb4ac0251e58d7e016c252a2d2d434
refs/heads/main
2023-08-15T01:05:43.056539
2021-09-16T03:25:13
2021-09-16T03:25:13
404,135,225
0
0
null
null
null
null
UTF-8
C++
false
false
4,678
h
#pragma once #ifndef ASSEMBLER_H #define ASSEMBLER_H #include <fstream> #include <iostream> #include <map> #include <symboltable.h> #include <string> #define ADDRESS_FILELINE 0 #define OPCODE_FILELINE 1 #define ARG1_FILELINE 2 #define ARG2_FILELINE 3 #define DESIRED_ADDRESS 0 #define ADDRESS_KEY 1 typedef std::vector< std::string> ListOfStrings; typedef std::map<std::string, uint16_t> DirectiveToNumber; typedef std::map<std::string, std::string> DirectiveToOpCode; typedef std::tuple<uint16_t, uint16_t> DesiredAddressToKeyAddress; typedef std::vector<DesiredAddressToKeyAddress> ListOfUsedLabel; typedef std::tuple< uint16_t, std::string, std::string, std::string > AddressOpcodeArgsLine; // map<[addressKey] [address, opcode, arg1, arg2]> // address opcode/value arg1 arg2 lineOriginalFile typedef std::map<uint16_t, AddressOpcodeArgsLine > FileLines; class Assembler { public: Assembler(std::fstream *source, std::string fileName); ~Assembler(); void assembleFile(); bool canSimulate = false; private: DirectiveToOpCode instructionToOpcode = { {"SPACE", "0"}, {"ADD", "1"}, {"SUB", "2"}, {"MULT", "3"}, {"DIV", "4"}, {"JMP", "5"}, {"JMPN", "6"}, {"JMPP", "7"}, {"JMPZ", "8"}, {"COPY", "9"}, {"LOAD", "10"}, {"STORE", "11"}, {"INPUT", "12"}, {"OUTPUT", "13"}, {"STOP", "14"} }; DirectiveToNumber instructToSizeInMemory = { // shows Number of arguments valueMap.second-1 {"ADD", 2}, {"SUB", 2}, {"MULT", 2}, {"DIV", 2}, {"JMP", 2}, {"JMPN", 2}, {"JMPP", 2}, {"JMPZ", 2}, {"COPY", 3}, {"LOAD", 2}, {"STORE", 2}, {"INPUT", 2}, {"OUTPUT", 2}, {"STOP", 1}, {"SPACE", 1}, {"CONST", 1}, }; SymbolTable symbolTable; FileLines fileLineTable; std::fstream * sourceCode; bool shouldWriteFile = false; uint16_t currentLine = 1; uint16_t currentAddress = 0; std::string currentToken = ""; std::string fileName = "binComments.asm"; // TESTING void printsMaps(); void printsCurrentLine(); void printsFileLine(uint16_t address); // END OF TESTING std::string currentLineReading, typeOfSection, comment, labelDef, instruction, // opcode or value vectorSpace, arg1, arg2; uint16_t numberOfArgs, sizeOfLine; ListOfStrings fromSplit; void onePassAlgorithm(); void writeAssembledFile(); void fileLinesInNumericOrder(); void resetLineOperands(); void getLabelDefAtLine(); void getCommentsAtLine(); void getInstructionAtLine(); void setsSizeVectorSpace(std::string strToBeSearched); void setsSizeLine(); void getArgsAtLine(); void processLineRead(); void populatesFileLine(); void updateCurrentLineAddress(); // TOKEN // VERIFIERS bool isValidInstruction(std::string token); void validateLabel(std::string token); void validateInstruction(std::string token); void sintaticValidator(u_int16_t numOfArgs); // TODO semanticValidator void hasMoreThanOneSameSection(); // TODO hasMoreThanOneSameSection // END VERIFIERS std::string getOpCode(std::string token); void operatesLabelsForLine( std::string labelDef, std::string arg1, std::string arg2 ); void operatesLabel( std::string label, uint16_t addressLabelDef, bool isDefinition, uint16_t labelAddress ); void operatesInstruction(std::string instruction); void operatesConstant(std::string constant); // END TOKEN void putOnFileLineTable(std::string value); void updatesCurrentAddress( DirectiveToNumber mapToSizeInMemory, uint16_t sizeVector, bool isCONST ); void updatesAllUsedPositions(uint16_t addressValueDef, ListOfUsedLabel usedLabels); void updatesAssembledCodeAtAddress(uint16_t addressValueDef , DesiredAddressToKeyAddress position); }; #endif
[ "lucaschiavini@hotmail.com" ]
lucaschiavini@hotmail.com
e8415b3bec7ab682ad47de1d21d1c02777c0f59c
b35b0e874c2d04e68fab4c6fd75023fb407c2965
/pegasus/src/Pegasus/Compiler/cimmofMessages.cpp
ee2f15fc5f809790bf51b6ebaa7cd25af9d74b93
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
xenserver/openpegasus
38de7f2062adf1f039ef9ead222c40d75d8acaaa
57e10a2ca29c17e5dca26a1c6c40a1a5fc4ba20d
refs/heads/master
2020-05-17T16:22:40.019817
2013-11-19T00:42:25
2014-04-07T16:25:45
10,623,043
3
2
null
2013-12-04T14:44:02
2013-06-11T14:19:20
C++
UTF-8
C++
false
false
9,191
cpp
//%LICENSE//////////////////////////////////////////////////////////////// // // Licensed to The Open Group (TOG) under one or more contributor license // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with // this work for additional information regarding copyright ownership. // Each contributor licenses this file to you under the OpenPegasus Open // Source License; you may not use this file except in compliance with the // License. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // ////////////////////////////////////////////////////////////////////////// // //%///////////////////////////////////////////////////////////////////////////// // // implementation of cimmofMessages class #include "cimmofMessages.h" #include <cstdio> #include <iostream> // for debug only #include <Pegasus/Common/MessageLoader.h> PEGASUS_NAMESPACE_BEGIN PEGASUS_USING_STD; const cimmofMessages::arglist cimmofMessages::EMPTYLIST; static const char* _cimmofMessages[] = { "OK", //CIM_ERR_SUCCESS "$0:$1: $2 before '$3'", //PARSER_SYNTAX_ERROR "Error applying parameter $0 to method $1: $2", //APPLY_PARAMETER_ERROR "Error creating new CIMParameter object $0: $1", //NEW_PARAMETER_ERROR //UNINTIALIZED_PARAMETER_ERROR "Internal Error: Uninitialized parameter handle $0 in class $1", //METHOD_ALREADY_EXISTS_WARNING "Warning: CIMMethod $0 already exists for CIMClass $1", "Error applying method $0 to CIMClass $1: $2:", //APPLY_METHOD_ERROR "Error creating new CIMMethod $0: $1", //NEW_METHOD_ERROR "ADD QUALIFIER: ", //ADD_QUALIFIER "[Trace]", //TRACE "Error adding qualifier declaration $0: $1", //ADD_QUALIFIER_DECL_ERROR "\tOK", //TAB_OK "Error creating new Qualifier $0: $1", //NEW_QUALIFIER_ERROR "Error adding new Qualifier $0: $1", //ADD_QUALIFIER_ERROR //NEW_QUALIFIER_DECLARATION_ERROR "Error creating new Qualifier Declaration $0: $1", // GET_QUALIFIER_DECL_ERROR "Could not find declaration for Qualifier named $0", "ADD INSTANCE: ", //ADD_INSTANCE //UNINITIALIZED_PROPERTY_ERROR "Internal Error: Uninitialized parameter $1 in class $0", //PROPERTY_ALREADY_EXISTS_WARNING "Warning: Property $1 already exists in class $0", "Error applying property $1 to class $0: $2", //APPLYING_PROPERTY_ERROR "Error creating new Property $0: $1", //NEW_PROPERTY_ERROR "Error creating new Class Declaration $0: $1", //NEW_CLASS_ERROR "ADD CLASS: ", //ADD_CLASS "Warning: Class $0 already exists in the repository",//CLASS_EXISTS_WARNING "Error adding class $0 to the repository: $1", //ADD_CLASS_ERROR //SETREPOSITORY_NO_COMPILER_OPTIONS "Internal Error: Compiler options not set before setting repository", //SETREPOSITORY_BLANK_NAME "Internal Error: No repository name was specified to setRepository", //NAMESPACE_CREATE_ERROR "Error trying to create repository name space $0: $1", // REPOSITORY_CREATE_ERROR "Error trying to create Repository in path $0: $1", // NEW_REFERENCE_ERROR "Error trying to create a reference to object $0: $1", //FIND_CLASS_OF_INSTANCE_ERROR "Error looking for class of current instance while looking up property" " $0: $1", // FIND_PROPERTY_VALUE_ERROR "Error looking up value of property $2 in class $1 (namespace $0): $3", "Error cloning property $0: $1", // CLONING_PROPERTY_ERROR // APPLY_INSTANCE_PROPERTY_ERROR "Error applying property $0 to an instance of class $1: $2", // GET_INSTANCE_PROPERTY_ERROR "Error getting property $0 from an instance: $1", "Error getting class $0 from namespace $1: $2", //GET_CLASS_ERROR "Error getting value of property $0: $1", //GET_PROPERTY_VALUE_ERROR "Error creating new instance of class $0: $1", // NEW_INSTANCE_ERROR // INSTANCE_PROPERTY_EXISTS_WARNING "Warning: property $1 already exists for this instance of class $0", // INSTANCE_EXISTS_WARNING "Warning: the instance already exists.\nIn this" " implementation, that means it cannot be changed.", "Error adding an instance: $0", // ADD_INSTANCE_ERROR "Error: $0", // GENERAL_ERROR "Warning: Class $0 was not added or updated: $1", //CLASS_NOT_UPDATED "Class has the same version", //SAME_VERSION // NO_EXPERIMENTAL_UPDATE "Experimental update not allowed (set appropriate compiler option)", //NO_VERSION_UPDATE "Version update not allowed (set appropriate compiler option)", //NO_CLASS_UPDATE "Class update not allowed (set appropriate compiler option)", //INVALID_VERSION_FORMAT "Invalid version format in mof class or repository class" " (valid format is m.n.u)", //INVALID_VERSION_FORMAT "Invalid $0 value: $1", // INVALID_LITERAL_VALUE "" }; static const char* _cimmofMessagesKeys [] = { "Compiler.cimmofMessages.CIM_ERR_SUCCESS", "Compiler.cimmofMessages.PARSER_SYNTAX_ERROR", "Compiler.cimmofMessages.APPLY_PARAMETER_ERROR", "Compiler.cimmofMessages.NEW_PARAMETER_ERROR", "Compiler.cimmofMessages.UNINITIALIZED_PARAMETER_ERROR", "Compiler.cimmofMessages.METHOD_ALREADY_EXISTS_WARNING", "Compiler.cimmofMessages.APPLY_METHOD_ERROR", "Compiler.cimmofMessages.NEW_METHOD_ERROR", "Compiler.cimmofMessages.ADD_QUALIFIER", "Compiler.cimmofMessages.TRACE", "Compiler.cimmofMessages.ADD_QUALIFIER_DECL_ERROR", "Compiler.cimmofMessages.TAB_OK", "Compiler.cimmofMessages.NEW_QUALIFIER_ERROR", "Compiler.cimmofMessages.ADD_QUALIFIER_ERROR", "Compiler.cimmofMessages.NEW_QUALIFIER_DECLARATION_ERROR", "Compiler.cimmofMessages.GET_QUALIFIER_DECL_ERROR", "Compiler.cimmofMessages.ADD_INSTANCE", "Compiler.cimmofMessages.UNINITIALIZED_PROPERTY_ERROR", "Compiler.cimmofMessages.PROPERTY_ALREADY_EXISTS_WARNING", "Compiler.cimmofMessages.APPLYING_PROPERTY_ERROR", "Compiler.cimmofMessages.NEW_PROPERTY_ERROR", "Compiler.cimmofMessages.NEW_CLASS_ERROR", "Compiler.cimmofMessages.ADD_CLASS", "Compiler.cimmofMessages.CLASS_EXISTS_WARNING", "Compiler.cimmofMessages.ADD_CLASS_ERROR", "Compiler.cimmofMessages.SETREPOSITORY_NO_COMPILER_OPTIONS", "Compiler.cimmofMessages.SETREPOSITORY_BLANK_NAME", "Compiler.cimmofMessages.NAMESPACE_CREATE_ERROR", "Compiler.cimmofMessages.REPOSITORY_CREATE_ERROR", "Compiler.cimmofMessages.NEW_REFERENCE_ERROR", "Compiler.cimmofMessages.FIND_CLASS_OF_INSTANCE_ERROR", "Compiler.cimmofMessages.FIND_PROPERTY_VALUE_ERROR", "Compiler.cimmofMessages.CLONING_PROPERTY_ERROR", "Compiler.cimmofMessages.APPLY_INSTANCE_PROPERTY_ERROR", "Compiler.cimmofMessages.GET_INSTANCE_PROPERTY_ERROR", "Compiler.cimmofMessages.GET_CLASS_ERROR", "Compiler.cimmofMessages.GET_PROPERTY_VALUE_ERROR", "Compiler.cimmofMessages.NEW_INSTANCE_ERROR", "Compiler.cimmofMessages.INSTANCE_PROPERTY_EXISTS_WARNING", "Compiler.cimmofMessages.INSTANCE_EXISTS_WARNING", "Compiler.cimmofMessages.ADD_INSTANCE_ERROR", "Compiler.cimmofMessages.GENERAL_ERROR", "Compiler.cimmofMessages.CLASS_NOT_UPDATED", "Compiler.cimmofMessages.SAME_VERSION", "Compiler.cimmofMessages.NO_EXPERIMENTAL_UPDATE", "Compiler.cimmofMessages.NO_VERSION_UPDATE", "Compiler.cimmofMessages.NO_CLASS_UPDATE", "Compiler.cimmofMessages.INVALID_VERSION_FORMAT", "Compiler.cimmofMessages.INVALID_LITERAL_VALUE", "Compiler.cimmofMessages.END" }; const char* cimmofMessages::msgCodeToString(MsgCode code) { return _cimmofMessages[(unsigned int)code]; } void cimmofMessages::getMessage(String &out, MsgCode code, const arglist &args) { Array<String> _args; for (unsigned int i = 0; i < 10; i++) { if(i < args.size()) _args.append(args[i]); else _args.append(""); } MessageLoaderParms parms(_cimmofMessagesKeys[(unsigned int)code], _cimmofMessages[(unsigned int)code], _args[0],_args[1],_args[2],_args[3],_args[4], _args[5],_args[6],_args[7],_args[8],_args[9]); out = MessageLoader::getMessage(parms); } PEGASUS_NAMESPACE_END
[ "rob@rdobson.co.uk" ]
rob@rdobson.co.uk
2a8571f9b486fc1c73f101939fabc120595c2a94
065ed4355f638371a545284bd91a973b6a42e0e9
/test/edyn/parallel/test_registry_delta.cpp
82447ce88e838d42f12f0e120562fc010b63f384
[ "MIT" ]
permissive
brucelevis/edyn
6825c8df07e5362ffe646e83ada61fddecee62f7
832eeb52eed0e0963fe93fcf741364f42e718b45
refs/heads/master
2023-02-10T09:03:00.302800
2021-01-12T05:02:07
2021-01-12T05:02:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,598
cpp
#include "../common/common.hpp" #include <tuple> #include <memory> struct custom_component { edyn::scalar value; entt::entity entity; }; // `custom_component` needs a custom merge function to map its entity into the // context of the other registry where it's being imported into. namespace edyn { template<merge_type MergeType> void merge(const custom_component *old_comp, custom_component &new_comp, merge_context &ctx) { new_comp.entity = ctx.map->remloc(new_comp.entity); } } TEST(registry_delta_test, test_registry_delta_export_import) { edyn::register_external_components<custom_component>(); edyn::init(); entt::registry reg0; auto child0 = reg0.create(); auto child1 = reg0.create(); auto ent0 = reg0.create(); reg0.emplace<edyn::island_node>(ent0, edyn::entity_set{child0, child1}); auto ent1 = reg0.create(); reg0.emplace<edyn::contact_point>(ent1, std::array<entt::entity, 2>{child0, child1}); reg0.get<edyn::contact_point>(ent1).distance = 6.28; auto ent2 = reg0.create(); reg0.emplace<custom_component>(ent2, 3.14, child0); auto map0 = edyn::entity_map{}; auto builder = edyn::make_registry_delta_builder(map0); builder->created(ent0); builder->created(ent0, reg0.get<edyn::island_node>(ent0)); builder->created(ent1); builder->created(ent1, reg0.get<edyn::contact_point>(ent1)); builder->created(child0); builder->created(child1); builder->created(ent2); builder->created_all(ent2, reg0); entt::registry reg1; auto map1 = edyn::entity_map{}; builder->get_delta().import(reg1, map1); auto builder1 = edyn::make_registry_delta_builder(map1); // `map1` contains the entity mapping between reg0 and reg1 (corresponding // entities are created on import and mappings are added to `map1`). // It is necessary to insert these mappings in `builder1` so when the delta // is exported and then imported into `reg0`, it can map the entities back. for (auto remote_entity : builder->get_delta().created_entities()) { auto local_entity = map1.remloc(remote_entity); builder1->insert_entity_mapping(local_entity); } ASSERT_TRUE(reg1.get<edyn::island_node>(map1.remloc(ent0)).entities.count(map1.remloc(child0))); ASSERT_TRUE(reg1.get<edyn::island_node>(map1.remloc(ent0)).entities.count(map1.remloc(child1))); ASSERT_EQ(map1.locrem(reg1.get<edyn::contact_point>(map1.remloc(ent1)).body[0]), child0); ASSERT_SCALAR_EQ(reg1.get<edyn::contact_point>(map1.remloc(ent1)).distance, 6.28); ASSERT_SCALAR_EQ(reg1.get<custom_component>(map1.remloc(ent2)).value, 3.14); ASSERT_EQ(reg1.get<custom_component>(map1.remloc(ent2)).entity, map1.remloc(child0)); // Replace some entities in `reg1`, export it and load it into `reg0`. auto &comp0 = reg1.get<edyn::island_node>(map1.remloc(ent0)); comp0.entities.erase(map1.remloc(child0)); comp0.entities.insert(map1.remloc(ent1)); builder1->updated(map1.remloc(ent0), comp0); auto &custom = reg1.get<custom_component>(map1.remloc(ent2)); custom.entity = map1.remloc(ent2); builder1->updated_all(map1.remloc(ent2), reg1); builder1->get_delta().import(reg0, map0); ASSERT_TRUE(reg0.get<edyn::island_node>(ent0).entities.count(ent1)); ASSERT_TRUE(reg0.get<edyn::island_node>(ent0).entities.count(child1)); ASSERT_EQ(reg0.get<edyn::contact_point>(ent1).body[0], child0); ASSERT_SCALAR_EQ(reg0.get<edyn::contact_point>(ent1).distance, 6.28); ASSERT_EQ(reg0.get<custom_component>(ent2).entity, ent2); }
[ "xissburg@xissburg.com" ]
xissburg@xissburg.com
6028c60cc6f57e3a21419cdb1b955159dfdc4101
3cc7601427169f882d05e65fd5a396d26e53fa04
/Encodes/Base32/stdafx.cpp
d75e26b5754ebd7ae3e56cdf5cf9b79a51c3b866
[]
no_license
kkfnui/Experiments
9a4ff1e9bd9d6e7861328b75e88324ff7b1afab6
94c335d0962b0faeba14ef45e4a2932c0d4beab5
refs/heads/master
2021-01-20T04:32:41.184724
2015-11-01T14:48:40
2015-11-01T14:48:40
3,078,990
3
0
null
null
null
null
UTF-8
C++
false
false
274
cpp
// stdafx.cpp : source file that includes just the standard includes // Base32.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" #if (_ATL_VER < 0x0700) #include <atlimpl.cpp> #endif //(_ATL_VER < 0x0700)
[ "kkfnui@gmail.com" ]
kkfnui@gmail.com
6c7127d1dfeb09ad2d4fb14b50d4325c9e43ce13
e4cba428476da6e6a1b08483cf7ab459fe5534d9
/Source/RendererGL/Mesh/VertexBuffer.cpp
04de7e1284ba8f7f4b9d4121f58b8066d34ac858
[]
no_license
wolves3d/idea
c69fcf1e72da322b6bd150b73d55c14f854ae32f
72c6b03996acb911b80e829a7821814b6ef77787
refs/heads/master
2020-05-18T17:51:10.076203
2015-08-14T20:30:20
2015-08-14T20:30:20
38,781,205
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
14,360
cpp
//////////////////////////////////////////////////////////////////////////////// #include "Common.h" /** * */ const byte * GetMemPointer( const IIndexBuffer * pBuffer ); /** * */ class CVertexBuffer : public IVertexBuffer { friend CRenderer_GL; //-------------------------------------------------------------------------- // Tip: Public methods & fields //-------------------------------------------------------------------------- public: CVertexBuffer (); ~CVertexBuffer (); bool Alloc ( uint nSize, dword dwFlags ); bool Free (); void Release (); bool AllocMulti(uint nCount) ; IVertexBuffer * GetSubBuffer(uint nID); void * Lock ( size_t nOffset, size_t nSize, bool bReadBack = false ); void Unlock (); EResult UpdateData ( size_t nOffset, void * pData, size_t nSize ); void RenderIndexed ( IVertexDecl * pDecl, IIndexBuffer * pIB, EPrimitive ePrim, uint nFirst = 0, uint nSize = 0 ); void Render ( IVertexDecl * pDecl, uint nFirst, uint nCount, EPrimitive ePrim ); uint GetHandle() { return m_nBufferID; } size_t GetSize() { return m_nSize; } //-------------------------------------------------------------------------- // Tip: Private methods & fields //-------------------------------------------------------------------------- private: void BindVertexDecl( IVertexDecl * pDecl ); bool m_isMultiSub; IVertexBuffer ** m_ppSubBuffers; size_t m_nSize; uint m_nIndex; // Индекс в списке всех VB bool m_bLocked; union { uint m_nBufferID; // OpenGL buffer void * m_pMemBuffer; // Buffer in system memory }; }; /** * */ CVertexBuffer::CVertexBuffer() : m_nSize(0) , m_bLocked(false) , m_isMultiSub(false) , m_ppSubBuffers(NULL) { m_nBufferID = 0; m_pMemBuffer = NULL; } /** * */ CVertexBuffer::~CVertexBuffer() { Free(); g_pRenderer->RemoveVB( m_nIndex ); } /** * */ void CVertexBuffer::Release() { PURE_DEL( this ); } bool CVertexBuffer::AllocMulti(uint nCount) { m_isMultiSub = true; m_nSize = nCount; m_ppSubBuffers = new PVertexBuffer [nCount]; for (uint i = 0; i < nCount; ++i) { m_ppSubBuffers[i] = g_pRenderer->CreateVB(); } return true; } IVertexBuffer * CVertexBuffer::GetSubBuffer(uint nID) { if (true == m_isMultiSub) { if (nID < m_nSize) { return m_ppSubBuffers[nID]; } } DEBUG_ASSERT(!"invalid op"); return NULL; } /** * */ bool CVertexBuffer::Alloc( uint nSize, dword dwFlags ) { GLenum eUsage = GL_STATIC_DRAW_ARB; //-------------------------------------------------------------------------- // Tip: Проверка аргумента //-------------------------------------------------------------------------- if ( 0 == nSize ) { DEBUG_ASSERT( !"Allocating null-size buffer" ); return false; } //-------------------------------------------------------------------------- // Tip: Высвобождаем, если память уже была выделена //-------------------------------------------------------------------------- if ( 0 != m_nSize ) { DEBUG_ASSERT( !"Allocating allocated buffer" ); return Free(); } if ( g_pRenderer->IsExtSupported( EXT_GL_VBO ) ) { //---------------------------------------------------------------------- // Tip: Создаём VBO буффер //---------------------------------------------------------------------- glGenBuffersARB( 1, &m_nBufferID ); GL_VALIDATE; if ( 0 == m_nBufferID ) { // Ошибка! Буффер не был создан! return false; } // Делаем новый буффер активным glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nBufferID ); GL_VALIDATE; // Выделяем память для буффера glBufferDataARB( GL_ARRAY_BUFFER_ARB, nSize, NULL, eUsage ); if ( GL_NO_ERROR != glGetError() ) { // Tip: Ошибка! Память не была выделена! return false; } // Делаем буффер неактивным glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); } else { //---------------------------------------------------------------------- // Tip: Создаём SysMem буффер //---------------------------------------------------------------------- m_pMemBuffer = NEW byte [ nSize ]; if ( NULL == m_pMemBuffer ) { // Ошибка! Буффер не был создан! return false; } } //-------------------------------------------------------------------------- // Tip: ОК //-------------------------------------------------------------------------- m_nSize = nSize; return true; } /** * */ bool CVertexBuffer::Free() { if (true == m_isMultiSub) { for (uint i = 0; i < m_nSize; ++i) { IVertexBuffer * subBuffer = GetSubBuffer(i); subBuffer->Release(); } DEL_ARRAY(m_ppSubBuffers); m_nSize = 0; return true; } //-------------------------------------------------------------------------- // Tip: Выходим, если буффер залочен //-------------------------------------------------------------------------- if ( m_bLocked ) { DEBUG_ASSERT( !"deleting locked buffer" ); return false; } //-------------------------------------------------------------------------- // Tip: Выходим, если память не выделена //-------------------------------------------------------------------------- if ( 0 == m_nSize ) return true; //-------------------------------------------------------------------------- // Tip: Высвобождаем память //-------------------------------------------------------------------------- if ( g_pRenderer->IsExtSupported( EXT_GL_VBO ) ) { glDeleteBuffersARB( 1, &m_nBufferID ); GL_VALIDATE; m_nBufferID = 0; } else { DEL_ARRAY( m_pMemBuffer ); } m_nSize = 0; return true; } /** * */ void * CVertexBuffer::Lock( size_t nOffset, size_t nSize, bool bReadBack ) { GL_VALIDATE; byte * pResult = NULL; //-------------------------------------------------------------------------- // Tip: Выходим, если буффер уже залочен //-------------------------------------------------------------------------- if ( m_bLocked ) { DEBUG_ASSERT( !"Try to lock locked buffer" ); return NULL; } //-------------------------------------------------------------------------- // Tip: Выходим, если nOffset и nSize не помещаются в буффере //-------------------------------------------------------------------------- if ( ( nOffset + nSize ) > m_nSize ) { DEBUG_ASSERT( !"Out of buffer" ); return NULL; } //-------------------------------------------------------------------------- // Tip: //-------------------------------------------------------------------------- if ( g_pRenderer->IsExtSupported( EXT_GL_VBO ) ) { glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nBufferID ); GL_VALIDATE; pResult = (byte *)glMapBufferARB( GL_ARRAY_BUFFER_ARB, bReadBack ? GL_READ_WRITE_ARB : GL_WRITE_ONLY_ARB ); GL_VALIDATE; glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); GL_VALIDATE; } else { pResult = (byte *)m_pMemBuffer; } //-------------------------------------------------------------------------- // Tip: ОК //-------------------------------------------------------------------------- m_bLocked = true; return pResult + nOffset; } /** * */ void CVertexBuffer::Unlock() { //-------------------------------------------------------------------------- // Tip: Выходим, если буффер не был залочен //-------------------------------------------------------------------------- if ( false == m_bLocked ) { DEBUG_ASSERT( !"Try to unlock non-locked buffer" ); return; } if ( g_pRenderer->IsExtSupported( EXT_GL_VBO ) ) { glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nBufferID ); GL_VALIDATE; glUnmapBufferARB( GL_ARRAY_BUFFER_ARB ); GL_VALIDATE; glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); GL_VALIDATE; } m_bLocked = false; } /** * */ EResult CVertexBuffer::UpdateData( size_t nOffset, void * pData, size_t nSize ) { if ( ( 0 == nSize ) || ( NULL == pData ) ) { DEBUG_ASSERT( !"invalid arg" ); return R_INVALID_ARG; } if ( ( nOffset + nSize ) > m_nSize ) { DEBUG_ASSERT( !"Out of buffer" ); return R_INVALID_ARG; } if ( g_pRenderer->IsExtSupported( EXT_GL_VBO ) ) { glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nBufferID ); GL_VALIDATE; glBufferSubDataARB( GL_ARRAY_BUFFER_ARB, nOffset, nSize, pData ); GL_VALIDATE; glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); GL_VALIDATE; } else { memcpy( (byte *)m_pMemBuffer + nOffset, pData, nSize ); } return R_OK; } /** * */ void CVertexBuffer::BindVertexDecl( IVertexDecl * pDecl ) { if ( NULL == pDecl ) return; byte * pOffset = NULL; for (uint n = 0; n < pDecl->GetAttrCount(); ++n) { const TVertexAttr * pAttr = pDecl->GetAttr( n ); // for debug int a = glGetAttribLocationARB(g_pRenderer->GetCurrentProgram(), pAttr->szName); { uint bufferID = m_nBufferID; uint stride = (GLsizei)pDecl->GetStride(); uint offset = pAttr->nOffset; if (m_isMultiSub) { if (n < m_nSize) { bufferID = GetSubBuffer(n)->GetHandle(); stride = 0; offset = 0; } else { bufferID = 0; } } if (0 != bufferID) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, bufferID); GL_VALIDATE; glEnableVertexAttribArrayARB(n /* tAttr.nLoc */); GL_VALIDATE; glVertexAttribPointerARB( n, //tAttr.nLoc, g_pElemCountGL[pAttr->eType], // element count GL_FLOAT, //tAttr.eType, // element type GL_FALSE, //( tAttr.eType == GL_FLOAT ) ? GL_FALSE : GL_TRUE, // need normalize int numbers? stride, // stride pOffset + offset); // offset GL_VALIDATE; } } } /*else { if ( n == 0 ) { glDisableClientState( GL_VERTEX_ARRAY ); continue; } glDisableVertexAttribArrayARB( n ); GL_VALIDATE; }*/ } /** * */ void CVertexBuffer::Render( IVertexDecl * pDecl, uint nFirst, uint nCount, EPrimitive ePrim ) { // DEBUG_ASSERT( !"not working function" ); //if ( !PrepareRender() ) // return; //-------------------------------------------------------------------------- // Tip: Bind VBO object //-------------------------------------------------------------------------- /* if ( g_pRenderer->IsExtSupported( EXT_GL_VBO ) ) { glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nBufferID ); GL_VALIDATE; } */ // assign vertex declaration BindVertexDecl( pDecl ); GLenum prim_mode = GL_POINTS; switch ( ePrim ) { case PRIM_LINE: prim_mode = GL_LINES; break; case PRIM_TRIANGLE: prim_mode = GL_TRIANGLES; break; case PRIM_QUAD: prim_mode = GL_QUADS; break; } glDrawArrays( prim_mode, nFirst, (GLsizei)nCount ); GL_VALIDATE; glUseProgramObjectARB( 0 ); GL_VALIDATE; if ( g_pRenderer->IsExtSupported( EXT_GL_VBO ) ) { glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); GL_VALIDATE; } } /* ================================================================================ // Name: // Desc: ================================================================================ */ void CVertexBuffer::RenderIndexed( IVertexDecl * pDecl, IIndexBuffer * pIB, EPrimitive ePrim, uint nFirst, uint nSize ) { if ( ( 0 == m_nSize ) || ( true == m_bLocked ) ) { DEBUG_ASSERT( !"error" ); return; } if ( NULL == pDecl ) return; if ( !pIB ) { DEBUG_ASSERT( !"invalid index buffer" ); return; } if ( ( nFirst + nSize ) >= pIB->GetNumIndices() ) { DEBUG_ASSERT( !"out of vb" ); return; } //-------------------------------------------------------------------------- // Tip: Bind VBO object //-------------------------------------------------------------------------- BindVertexDecl( pDecl ); // assgin index buffer pIB->Bind(); GLenum prim_mode = GL_POINTS; switch ( ePrim ) { case PRIM_LINE: prim_mode = GL_LINES; break; case PRIM_TRIANGLE: prim_mode = GL_TRIANGLES; break; case PRIM_QUAD: prim_mode = GL_QUADS; break; } GLenum index_type = GL_INVALID_ENUM; uint nElemSize = 0; switch ( pIB->GetType() ) { case TYPE_SHORT: index_type = GL_UNSIGNED_SHORT; nElemSize = sizeof( short ); break; case TYPE_INT: index_type = GL_UNSIGNED_INT; nElemSize = sizeof( uint ); break; default: DEBUG_ASSERT( !"unknown buffer index type" ); return; } if ( GL_INVALID_ENUM != index_type ) { GLsizei nCount = ( 0 == nSize ) ? pIB->GetNumIndices() : nSize; const byte * pOffset = g_pRenderer->IsExtSupported( EXT_GL_VBO ) ? NULL : GetMemPointer( pIB ); glDrawElements( prim_mode, nCount, index_type, pOffset + ( nFirst * nElemSize ) ); GL_VALIDATE; } pDecl->Assign( false ); glUseProgramObjectARB( 0 ); GL_VALIDATE; if ( g_pRenderer->IsExtSupported( EXT_GL_VRTX_PROGRAM ) ) { glBindProgramARB( GL_VERTEX_PROGRAM_ARB, 0 ); GL_VALIDATE; glDisable( GL_VERTEX_PROGRAM_ARB ); GL_VALIDATE; glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, 0 ); GL_VALIDATE; glDisable( GL_FRAGMENT_PROGRAM_ARB ); GL_VALIDATE; } if ( g_pRenderer->IsExtSupported( EXT_GL_VBO ) ) { glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); GL_VALIDATE; glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); GL_VALIDATE; } } /** * */ PVertexBuffer CRenderer_GL::CreateVB() { CVertexBuffer * pVB; PVertexBuffer pResult; if ( pVB = NEW CVertexBuffer() ) { pVB->m_nIndex = m_VBList.Add( pResult ); if ( INVALID_INDEX == pVB->m_nIndex ) { pVB->Release(); } else { pResult = pVB; } } return pResult; } /** * */ void CRenderer_GL::RemoveVB( uint nListID ) { m_VBList.Remove( nListID ); } ////////////////////////////////////////////////////////////////////////////////
[ "wolves3d@gmail.com" ]
wolves3d@gmail.com
bdee3708d231d7383f293a0edfaf595e0b066915
51635684d03e47ebad12b8872ff469b83f36aa52
/external/gcc-12.1.0/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/starts_with/wchar_t/1.cc
6ff55b787f60aac059c9c958e5db66c4a9524761
[ "LGPL-2.1-only", "GPL-3.0-only", "GCC-exception-3.1", "GPL-2.0-only", "LGPL-3.0-only", "LGPL-2.0-or-later", "Zlib", "LicenseRef-scancode-public-domain" ]
permissive
zhmu/ananas
8fb48ddfe3582f85ff39184fc7a3c58725fe731a
30850c1639f03bccbfb2f2b03361792cc8fae52e
refs/heads/master
2022-06-25T10:44:46.256604
2022-06-12T17:04:40
2022-06-12T17:04:40
30,108,381
59
8
Zlib
2021-09-26T17:30:30
2015-01-31T09:44:33
C
UTF-8
C++
false
false
1,695
cc
// { dg-options "-std=gnu++2a" } // { dg-do compile { target c++2a } } // Copyright (C) 2018-2022 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // basic_string_view begins_with #include <string_view> void test01() { constexpr wchar_t cstr_dir[] = L"slugs/"; constexpr std::wstring_view sv_dir(L"slugs/"); constexpr wchar_t cstr_dir2[] = L"worms/"; constexpr std::wstring_view sv_dir2(L"worms/"); constexpr std::wstring_view sv_test(L"slugs/slimy.jpg"); constexpr auto cstr_in_slugs = sv_test.starts_with(cstr_dir); static_assert(cstr_in_slugs); constexpr auto sv_in_slugs = sv_test.starts_with(sv_dir); static_assert(sv_in_slugs); constexpr auto char_s = sv_test.starts_with(L's'); static_assert(char_s); constexpr auto cstr_in_worms = sv_test.starts_with(cstr_dir2); static_assert(!cstr_in_worms); constexpr auto sv_in_worms = sv_test.starts_with(sv_dir2); static_assert(!sv_in_worms); constexpr auto char_w = sv_test.starts_with(L'w'); static_assert(!char_w); }
[ "rink@rink.nu" ]
rink@rink.nu
9a9e35f8d633c5524062673ec0e3eeb389284214
ea19a24083f99895f1313a6a958037fa99ef08f0
/HWPrograms/forHW4/x.cpp
c6982a795b98bcd7e189bdec4c7f1918064014d0
[]
no_license
hanji117/dataStructuresCplusPlus
a908bbef72aace731736c5332b2b239239dcc122
206e9b3046146e6ca449af0206a9121e817990c4
refs/heads/master
2021-05-01T21:00:45.474968
2018-02-10T00:21:03
2018-02-10T00:21:03
120,969,825
0
0
null
null
null
null
UTF-8
C++
false
false
8,435
cpp
// delete // insert // in order using namespace std; #include <iostream> #include "binstree.h" // constructor initializes Root BST::BST() { Root = NULL; // This is an empty tree } // destructor must completely destroy the tree BST::~BST() { dtraverse(Root); // traverse to delete all vertices in post order Root = NULL; } // PURPOSE: Does Post Order traversal of the tree and deletes each vertex // PARAM: V is a pointer to the vertex to be deleted void BST::dtraverse(Vertex *V) // recursive post order traversal { if (V != NULL) { dtraverse(V->Left); // visit left sub tree of V dtraverse(V->Right); // visit right sub tree of V delete V; // deletes V } } // PURPOSE: Show elements in IN order traversal from the Root void BST::ShowInOrder() { cout << "Elements in the IN order: " << endl; INorderTraversal(Root); // start in-order traversal from the root } // PURPOSE: Does IN order traversal from V recursively // PARAM: V is te pointer to the vertex to visit right now void BST::INorderTraversal(Vertex *V) { if (V != NULL) { INorderTraversal(V->Left);// ** traverse left sub-tree of V recursively cout << V->Elem << " "; // ** display V's element and do endl; INorderTraversal(V->Right); // ** traverse right sub-tree of V recursively } } // PURPOSE: Show elements in PRE order traversal from the Root // This is the same as Depth First Traversal void BST::ShowPreOrder() { cout << "Elements in the PRE order:" << endl; PREorderTraversal(Root); // start pre-order traversal from the root } // PURPOSE: Does PRE order traversal from V recursively // PARAM: V is the pointer to the vertex to be visited now void BST::PREorderTraversal(Vertex *V) { if (V != NULL) { cout << V->Elem << " "; // ** display V's element and do endl; PREorderTraversal(V->Left); // ** traverse left sub-tree of V recursively PREorderTraversal(V->Right); // ** traverse right sub-tree of V recursively } } // PURPOSE: Adds a vertex to the binary search tree for a new element // PARAM: the new element E // ALGORITHM: We will do this iteratively (not recursively) to demonstrate // the algorithm that is in the notes // - smaller than the current -> go to the left // - bigger than the current -> go to the right // - cannot go any further -> add it there void BST::Insertvertex(elem_t E){ // Set up a new vertex first Vertex *N; // N will point to the new vertex to be inserted N = new Vertex; // a new vertex is created N->Left = NULL; // make sure it does not N->Right = NULL; // point to anything N->Elem = E; // put element E in it cout << "Trying to insert " << E << endl; // Special case: we have a brand new empty tree if (Root == NULL) { Root = N; // the new vertex is added as the root cout << "...adding " << E << " as the root" << endl; } // the tree is not empty else { Vertex *V; // V will point to the current vertex Vertex *Parent; // Parent will point to V's parent V = Root; // start with the root as V // go down the tree until you cannot go any further while (V != NULL) { if (N->Elem == V->Elem) // the element already exists { cout << "...error: the element already exists" << endl; return; } else if (N->Elem < V->Elem) // what I have is smaller than V { cout << "...going to the left" << endl; Parent =V; // **change Parent to be V to go down V=V->Left; // **change V to be V's Left } else // what I have is bigger than V { cout << "...going to the right" << endl; Parent=V; // **change Parent to be V to go down V=V->Right; // **change V to be V's Right } }//end of while // reached NULL -- Must add N as the Parent's child if (N->Elem < Parent->Elem) { Parent->Left = N; // ** Parent's Left should point to the same place as N cout << "...adding " << E << " as the left child of " << Parent->Elem << endl; } // ** Parent's Right should point to the same place as N else { Parent->Right =N; cout << "...adding " << E << " as the right child of " << Parent->Elem << endl; } }// end of normal case } // PURPOSE: Deletes a vertex that has E as its element. // PARAM: element E to be removed // ALGORITHM: First we must find the vertex then call Remove void BST::DeleteVertex(elem_t E){ cout << "Trying to delete " << E << endl; Vertex *V; // the current vertex Vertex *Parent = NULL; // its parent if ((E == Root->Elem) && (Root->Left == NULL) && (Root->Right == NULL)){ cout << "...deleting the lonely root" << endl; delete Root; Root = NULL; return; } // only the Root was there and deleted it /* Condition for if the element is the root and only has a leaf Node to the right change the root to the child and return - this could be the left or the right child */ if((E == Root->Elem) && (Root->Left == NULL) && (Root->Right!= NULL)){ V = Root; Root=Root->Right; // Move root to the right delete V; // delete original root and return return; }// end of deleting the root // Condition for if the element is the root and only has a leaf Node to the left if ((E == Root->Elem) && (Root->Left != NULL) && (Root->Right == NULL)){ V = Root; Root = Root->Left; // Move root to the left delete V; // delete original root and return return; } // Condition for if the root has leaf Node to both left and right if ((E == Root->Elem) && (Root->Left != NULL) && (Root->Right != NULL)){ Root->Elem = findMax(Root->Left); // Replaces the element with max of Left sub tree return; // return }// Otherwise deleting something else V = Root; // start with the root to look for E while (V != NULL){ // This while loops goes to find the appropriate element to deletez if (E == V->Elem){ // if element found, use remove function to delete it remove(V, Parent); return; } if (E < V->Elem){ // if element is smaller, then move the tree down left Parent = V; V = V->Left; } else if(E > V->Elem){ // if element is bigger, move the tree down right Parent = V; V = V->Right; } // Process repeats until whole tree is traversed } return; } // PURPOSE: Removes vertex pointed to by V // PARAM: V and its parent pointer P // Case 1: it is a leaf, delete it // Case 2: it has just one child, bypass it // Case 3: it has two children, replace it with the max of the left subtree void BST::remove(Vertex *V, Vertex *Parent){ /* CASE 1: V is a leaf */ if (V->Left == NULL && V->Right == NULL){ // condition if there is no leaf node if (Parent->Elem < V->Elem) Parent->Right = NULL; // Parent Node will be set accordingly else Parent->Left = NULL; delete V; // delete original return; // return } /* Case 2: it has just one child, bypass it*/ if (V->Left == NULL && V->Right != NULL){ // condition for only right leaf node if (Parent->Elem < V->Elem) Parent->Right = V->Right; // Parent node will be set accordingly else Parent->Left = V->Right; delete V; // delete original and return return; } if (V->Left != NULL && V->Right == NULL){ // condition for only left leaf node if (Parent->Elem < V->Elem) Parent->Right = V->Left; // parent node will be set accordingly else Parent->Left = V->Right; delete V; // delete original and return return; } if (V->Left != NULL && V->Right != NULL){ // condition 3 V->Elem = findMax(V->Left); // Element will be replaced by the max of the left sub tree return; // return } } // PURPOSE: Finds the Maximum element in the left sub-tree of V elem_t BST::findMax(Vertex *V){ Vertex *Parent = NULL; elem_t max; while (V->Right != NULL){ // Keep shifting right until NULL to find the max value Parent = V; // Have parent follow behind V = V->Right; } max = V->Elem; // hold the max value Parent->Right = NULL; // set the parent->right to NULL delete V; // delete the original V = NULL; // set V to NULL return max; // return the max value }
[ "cruz085@empress.csusm.edu" ]
cruz085@empress.csusm.edu
6d47c1b2656d1edcc9b9a5a62b91f09f33865cdf
f3e4c254c214111fbefb8f54de3fd3bddcb13014
/PolarPong/MovementEvent.hpp
e1e7c8891284864ca9ba891c8236126adb319a95
[]
no_license
gozzle/polarPong
ca1e96b2d5bd14e3e4a0dfb86d108231876f551f
38a99a7a4bae4106670198b1e8847b6bf572b22b
refs/heads/master
2020-04-06T04:55:55.173353
2012-06-01T09:00:02
2012-06-01T09:00:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,257
hpp
// // MovementEvent.hpp // PolarPong // // Created by Callum Chalk on 13/05/2012. // Copyright (c) 2012 __MyCompanyName__. All rights reserved. // #ifndef PolarPong_MovementEvent_hpp #define PolarPong_MovementEvent_hpp #include "Event.hpp" #include <tr1/unordered_map> class MovementEvent : Event { public: enum Direction { CLOCKWISE, ANTI_CLOCKWISE, STOP } direction; private: int playerNumber; public: MovementEvent(int player, Direction direction) { this->playerNumber = player; this->direction = direction; } MovementEvent(const MovementEvent& event) { this->playerNumber = event.playerNumber; this->direction = event.direction; } ~MovementEvent() {}; Direction getDirection() const {return this->direction;} int getPlayer() const {return this->playerNumber;} }; // define hash method for Type namespace std { namespace tr1 { template<> struct hash<typename MovementEvent::Direction> { inline std::size_t operator()(MovementEvent::Direction const &key) const { int type = key; return std::tr1::hash<int>()(type); } }; } } #endif
[ "callum.chalk@hotmail.com" ]
callum.chalk@hotmail.com
c3cb8ed9c2210a92be7cf96da51afdfd3ccf779a
b87b99a79fa63668854ad3d831cbb968b86160a4
/surface/material/SolidMaterial.cpp
df7d1ef3b85621163adc9c00496a605a03c601a9
[]
no_license
erkansari/ray_tracer
2a5dd79c94a28aec43806faa1b2b7941e27ca7a6
a69281fc325c403379d3a6825844012d80afca9e
refs/heads/master
2022-11-20T00:24:02.933199
2020-07-13T11:01:23
2020-07-13T11:01:23
278,351,860
0
0
null
null
null
null
UTF-8
C++
false
false
297
cpp
#include "SolidMaterial.h" SolidMaterial::SolidMaterial(Phong phong, double reflectance, double transmittance, double refraction, Vec3<float> color): Material(phong, reflectance, transmittance, refraction) { this->color = color; } Vec3<float> SolidMaterial::getColor() { return this->color; }
[ "a11907632@unet.univie.ac.at" ]
a11907632@unet.univie.ac.at
8c01b1e1b8752e3299df2fae8986e80f02e4876b
bf8fd2eb2530c98d24a30af1074afd1a58a165d9
/Source/DemoScene/BaseVector3.h
2e6a5b5273ed3e74e2019029a33ce8cdd4a9f0ec
[ "MIT" ]
permissive
ookumaneko/PC-Psp-Cross-Platform-Demoscene
1b4a947c82b4efa381f3aba809d20a97e3d285b1
0c192f9ecf5a4fd9db3c9a2c9998b365bf480c1e
refs/heads/master
2020-05-30T20:55:08.570718
2015-04-07T11:43:40
2015-04-07T11:43:40
33,538,146
0
0
null
null
null
null
UTF-8
C++
false
false
581
h
#ifndef _BASE_VECTOR_3 #define _BASE_VECTOR_3 #ifdef _PSP_VER #include <libgum.h> #else #include <D3dx9math.h> #endif class BaseVector3 { protected: BaseVector3(void) {} public: virtual ~BaseVector3(void) {} public: #ifdef _PSP_VER ScePspFVector3& GetVector(void) { return _vec; } const ScePspFVector3& GetVector(void) const { return _vec; } protected: ScePspFVector3 _vec; #else D3DXVECTOR3& GetVector(void) { return _vec; } const D3DXVECTOR3& GetVector(void) const { return _vec; } protected: D3DXVECTOR3 _vec; #endif }; #endif
[ "shanageek@gmail.com" ]
shanageek@gmail.com
2375fcddd06631ceb88639528279136ef2b808d2
f0bd42c8ae869dee511f6d41b1bc255cb32887d5
/Codeforces/909B. Segments.cpp
fd6b99cfa6fe24bc82292418474a8d17aa66e11d
[]
no_license
osamahatem/CompetitiveProgramming
3c68218a181d4637c09f31a7097c62f20977ffcd
a5b54ae8cab47b2720a64c68832a9c07668c5ffb
refs/heads/master
2021-06-10T10:21:13.879053
2020-07-07T14:59:44
2020-07-07T14:59:44
113,673,720
3
1
null
null
null
null
UTF-8
C++
false
false
696
cpp
/* * 909B. Segments.cpp * * Created on: Dec 27, 2017 * Author: Osama Hatem */ /* http://codeforces.com/blog/entry/56666 My solution is based on the same idea (overlapping segments must belong to different layers), but I just count the maximum overlap in O(N^3) due to the small constraints. */ #include <bits/stdtr1c++.h> #include <ext/numeric> using namespace std; int cnt[105]; int main() { #ifndef ONLINE_JUDGE freopen("in.in", "r", stdin); // freopen("out.out", "w", stdout); #endif int n, ans = 0; cin >> n; for (int i = 0; i <= n; i++) for (int j = i + 1; j <= n; j++) for (int k = i; k < j; k++) ans = max(ans, ++cnt[k]); cout << ans << endl; return 0; }
[ "osama@elysian.team" ]
osama@elysian.team
cff9b2d0870a02c9d769d1c5a11772d0198dd48e
456551bbf0c752075d23e2dd348d9bf09533c40f
/ABC/156/e.cpp
b88cc587d441b33b4efa6d1f487e2e0d32fd1b57
[]
no_license
skjmp/ProCon
5bed08c6efdc202d5f7d6038cd7a99d9c59d58f0
b9971b374d45499f22e6eb0107473ca37ca46591
refs/heads/master
2020-03-27T20:12:38.044762
2020-03-01T11:42:03
2020-03-01T13:49:31
147,048,755
0
0
null
null
null
null
UTF-8
C++
false
false
4,484
cpp
#include <bits/stdc++.h> #define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i) #define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i) #define ALL(t) t.begin(), t.end() #define RALL(t) t.rbegin(), t.rend() #define MATINIT(type, row, col, init) \ vector<vector<type>>(row, vector<type>(col, init)); #define Yes(cond) cout << (cond ? "Yes" : "No") << endl; #define YES(cond) cout << (cond ? "YES" : "NO") << endl; using namespace std; using LL = long long; using ULL = unsigned long long; template <class T> using VEC = std::vector<T>; template <class T> using MAT = std::vector<std::vector<T>>; void DUMP() { cerr << endl; } template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) { cerr << head << ", "; DUMP(std::move(tail)...); } template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, set<T> &s) { os << "{"; for (auto p : s) os << p << ","; os << "}"; return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, map<T1, T2> &m) { os << "{"; for (auto p : m) os << p << ","; os << "}"; return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "[" << p.first << " " << p.second << "]"; return os; } // ABC129 https://youtu.be/L8grWxBlIZ4?t=9860 struct ModInt { static const int MOD = 1000000007; long long x; ModInt(long long x = 0) : x((x % MOD + MOD) % MOD) {} ModInt &operator+=(const ModInt a) { if ((x += a.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(const ModInt a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(const ModInt a) { (x *= a.x) %= MOD; return *this; } ModInt operator+(const ModInt a) const { ModInt res(*this); return res += a; } ModInt operator-(const ModInt a) const { ModInt res(*this); return res -= a; } ModInt operator*(const ModInt a) const { ModInt res(*this); return res *= a; } bool operator==(const ModInt a) const { return this->x == a.x; } bool operator!=(const ModInt a) const { return this->x != a.x; } ModInt pow(long long t) const { if (!t) return 1; ModInt a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime MOD ModInt inv() const { // オイラーの定理より // https://ja.wikipedia.org/wiki/%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%A9%E9%80%86%E6%95%B0 return pow(MOD - 2); } // for prime MOD ModInt &operator/=(const ModInt a) { return (*this) *= a.inv(); } // for prime MOD ModInt operator/(const ModInt a) const { ModInt res(*this); return res /= a; } }; std::ostream &operator<<(std::ostream &os, const ModInt &a) { os << a.x; return os; } // http://drken1215.hatenablog.com/entry/2018/06/08/210000 const int MAX = 210000; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } /* calculate n^p mod M. O(log(p)) */ long long modpow(long long n, long long p, long long M) { long long ans = 1; while (p > 0) { if (p & 1) ans = (ans * n) % M; n = (n * n) % M; p >>= 1; } return ans; } LL M = 1e9 + 7; ModInt Com(LL n, LL k) { ModInt res = 1; REP(i, 1, k + 1) { ModInt a = n - i + 1; res *= a / i; } return res; } const LL LIM_N = 2 * 1e5 + 2; const LL LIM_K = 1e9 + 1; ModInt dp[LIM_N][LIM_N]; ModInt Sum(LL n, LL k){ } ModInt dfs(LL n, LL k){ DUMP(n,k ,dp[n][k]); if(dp[n][k]!=-1){ return dp[n][k]; } dp[n][k]=0; REP(i,0,k){ dp[n][k]+=dfs(n-1, i); } return dp[n][k]; } int main() { LL N, K; cin >> N >> K; ModInt dp[LIM_N][LIM_K]; REP(i, 0, LIM_N) { REP(j, 0, LIM_K) { dp[i][j] = -1; } dp[i][0]=1; } if(K>N){ LL nk=N; if(nk%2!=K%2)nk++; K=nk; } ModInt ans= dfs(N,K); cout<<ans<<endl; return 0; }
[ "2036oshmkufafg36@gmail.com" ]
2036oshmkufafg36@gmail.com
444c02cfcc2cf0429f2ced4fccb56df60093482a
a92eca8084a4100267555c9f0c11e0bb702675f9
/cplusplus/class/friend.cpp
38990f6af2a70d1d212cd006c6821026f54594c2
[]
no_license
victorygogogo/LearnAndTry
ceabddd02b9feb751c6c3f0e0713b1c9683b4869
8d2f651ca8b14986f920c5c6fbbc42e1be8eb7fb
refs/heads/main
2023-06-28T22:03:20.295098
2021-07-21T08:58:11
2021-07-21T08:58:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,383
cpp
#include <iostream> using namespace std; //友元的作用是为了让一个类的私有属性可以在类外被访问 // 三种实现方式 // 1.全局函数作友元 // 2.类作友元 // 3.成员函数作友元 class goodgay2; class Person { friend void g_fun( Person& p); //在类里设置该全局函数的声明为友元,可访问该类的私有属性 friend class goodgay; //在类里设置另一个类的声明为友元,可访问该类的私有属性 friend void goodgay2::visit( Person& p); //在类里设置另一个类的成员函数声明为友元,可访问该类的私有属性 public: Person() { m_age = 10; } private: int m_age; }; void g_fun(Person& p) { int a = p.m_age; //一般情况无法在实例中访问private属性 } class goodgay { public: goodgay() { m_p = new Person; int a = m_p->m_age; //在另外一个类里一般无法访问类的私有属性 } void visit() { int a = m_p->m_age; //在另外一个类里一般无法访问类的私有属性 } void visit2(Person& p) { int a = p.m_age; //在另外一个类里一般无法访问类的私有属性 } private: Person* m_p; }; class goodgay2 { public: void visit(Person& p) { int a = p.m_age; //在另外一个类的成员函数里一般无法访问类的私有属性 } }; int main() { Person p; g_fun(p); return 0; }
[ "hsqyc@163.com" ]
hsqyc@163.com
eabdfb4af6ff5b44a04ad149d16c746d63a03aa3
2274aa4ef2e0069aa770d7f5f28aa3dd0c6e275b
/3SumClosest.cpp
33ef457d28638de835f93cc0059ea69629be558b
[]
no_license
zhaoxiaohui/LeetCode
0b68349aac6431df5f06baea9202c520cab5a01f
13a2be605070f7d4e7f8798b8d312e91de78fd45
refs/heads/master
2021-01-10T01:45:55.062641
2016-01-25T03:51:11
2016-01-25T03:51:11
45,035,293
0
0
null
null
null
null
UTF-8
C++
false
false
868
cpp
/** * Description: * Author: zhaoxiaohui * Site: zhaoxiaohui.sinaapp.com * Date: 2014 */ class Solution { public: int threeSumClosest(vector<int> &num, int target) { sort(num.begin(), num.end()); int n = num.size(); int left = 0, right, middle, dis, sum, ret_sum=INT_MAX, ret; while(left < n-2){ middle = left + 1; right = n-1; while(middle < right){ sum = num[left] + num[middle] + num[right]; if(sum > target){ right--; //ret_sum = min(abs(sum-target), ret_sum); if(ret_sum > abs(sum-target)){ ret_sum = abs(sum-target); ret = sum; } }else if(sum < target){ middle++; //ret = min(abs(sum-target), ret); if(ret_sum > abs(sum-target)){ ret_sum = abs(sum-target); ret = sum; } }else return sum; } left++; } return ret; } };
[ "fire.guy@163.com" ]
fire.guy@163.com
f9f875b5245dbba9ec15f084cff67eaffed0450e
814bb0707527fed31cbacbb8048ec4f7859b96f3
/src/main.cc
f9d89a020347200e72df1aabfc35277668c381c6
[ "MIT" ]
permissive
thomas-joubert/Sokoban
a38a0400988a85216b858b95e8f0c7870f40b39e
b3b92bdb02dbce466bf6c47067f99af8dcf7e687
refs/heads/master
2023-08-18T20:14:34.132191
2023-08-03T20:41:49
2023-08-03T20:41:49
272,073,337
0
0
null
null
null
null
UTF-8
C++
false
false
1,300
cc
#include <SFML/Graphics/Texture.hpp> #include <SFML/Window.hpp> #include <SFML/Graphics/Sprite.hpp> #include <SFML/Graphics/RenderWindow.hpp> #include <SFML/System/Vector2.hpp> #include <SFML/Window/Keyboard.hpp> #include <SFML/Graphics/Vertex.hpp> #include <SFML/Graphics/VertexArray.hpp> #include <SFML/Graphics/Shape.hpp> #include <iostream> #include <vector> #include <memory> #include <thread> int main(void) { // Main window of the prg sf::RenderWindow window(sf::VideoMode(1920, 1080, sf::Style::Default), "Sokoban"); window.setVerticalSyncEnabled(true); // Creating the background for the menu sf::Texture background_t; background_t.create(1920, 1080); sf::Sprite background(background_t); background.setColor(sf::Color(255, 0, 0)); while (window.isOpen()) { // Stores the event (keyboards...) sf::Event event; window.clear(); window.draw(background); window.display(); //pollEvent renvoie true si un event est en attente, false sinon while (window.pollEvent(event)) { if (event.type == sf::Event::Closed || (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Tab)) window.close(); } } }
[ "thomas.joubert@epita.fr" ]
thomas.joubert@epita.fr
d9cb2882f382d79555bd2f4bd79d56e9cccafd46
bebe0ece30df465bdab906aaed600e357ae89233
/TCPIP/MainTCP.cpp
f7e858ca5502d738adc75a5ad294f38de7a63eb2
[ "MIT" ]
permissive
Patrick-Gourdet/BasicVulnerabilityChecker
2b7cf2fcbf7f330131484b775e23084b8773813d
27eb07df8a913b0ec12bacd95782b6946ab0012e
refs/heads/master
2022-04-28T01:08:15.636548
2020-04-26T14:51:16
2020-04-26T14:51:16
258,628,983
0
0
null
2020-04-25T16:47:49
2020-04-24T21:31:42
C#
UTF-8
C++
false
false
1,647
cpp
//---cat rawtcp.c--- // Run as root or suid 0, just datagram no data/payload #include <Winsock2.h> //#include <unistd.h> //#include <netinet/ip.h> //#include <netinet/tcp.h> //#include <sys/socket.h> // Packet length #define PCKT_LEN 8192 // May create separate header file (.h) for all // headers' structures // IP header's structure struct ipheader { unsigned char iph_ihl : 5, /* Little-endian */ iph_ver : 4; unsigned char iph_tos; unsigned short int iph_len; unsigned short int iph_ident; unsigned char iph_flags; unsigned short int iph_offset; unsigned char iph_ttl; unsigned char iph_protocol; unsigned short int iph_chksum; unsigned int iph_sourceip; unsigned int iph_destip; }; /* Structure of a TCP header */ struct tcpheader { unsigned short int tcph_srcport; unsigned short int tcph_destport; unsigned int tcph_seqnum; unsigned int tcph_acknum; unsigned char tcph_reserved : 4, tcph_offset : 4; // unsigned char tcph_flags; unsigned int tcp_res1 : 4, /*little-endian*/ tcph_hlen : 4, /*length of tcp header in 32-bit words*/ tcph_fin : 1, /*Finish flag "fin"*/ tcph_syn : 1, /*Synchronize sequence numbers to start a connection*/ tcph_rst : 1, /*Reset flag */ tcph_psh : 1, /*Push, sends data to the application*/ tcph_ack : 1, /*acknowledge*/ tcph_urg : 1, /*urgent pointer*/ tcph_res2 : 2; unsigned short int tcph_win; unsigned short int tcph_chksum; unsigned short int tcph_urgptr; }; // Simple checksum function, may use others such as // Cyclic Redundancy Check, CRC
[ "admin@irondigital.com" ]
admin@irondigital.com
66dd42cb33b1a2410da464bb90cade370335fd8f
809bbbddf5f4abdf8f85a6591df61fcf11f52ce0
/05_05_pool/src/libs/libserver/connect_obj.cpp
a0566ea86c50ac99c9ead36deadcbee29e23a840
[ "MIT" ]
permissive
KMUS1997/GameBookServer
542df52ac3f7cb1443584394e3d8033dbb2d29e3
6f32333cf464088a155f0637f188acd452b631b7
refs/heads/master
2023-03-15T18:52:23.253198
2020-06-09T01:58:36
2020-06-09T01:58:36
null
0
0
null
null
null
null
GB18030
C++
false
false
4,922
cpp
#include "connect_obj.h" #include "network.h" #include "network_buffer.h" #include "packet.h" #include "thread_mgr.h" #include "object_pool_interface.h" ConnectObj::ConnectObj(IDynamicObjectPool* pPool) :ObjectBlock(pPool) { _pNetWork = nullptr; _socket = INVALID_SOCKET; _recvBuffer = new RecvNetworkBuffer(DEFAULT_RECV_BUFFER_SIZE, this); _sendBuffer = new SendNetworkBuffer(DEFAULT_SEND_BUFFER_SIZE, this); } ConnectObj::~ConnectObj() { if (_recvBuffer != nullptr) delete _recvBuffer; if (_sendBuffer != nullptr) delete _sendBuffer; } void ConnectObj::TakeoutFromPool(Network* pNetWork, SOCKET socket) { _pNetWork = pNetWork; _socket = socket; } void ConnectObj::BackToPool() { //std::cout << "close socket:" << _socket << std::endl; if (!Global::GetInstance()->IsStop) { // 通知其他对象,有Socket中断了 Packet* pResultPacket = new Packet(Proto::MsgId::MI_NetworkDisconnect, _socket); MessageList::DispatchPacket(pResultPacket); } _pNetWork = nullptr; _socket = INVALID_SOCKET; _recvBuffer->BackToPool(); _sendBuffer->BackToPool(); _pPool->FreeObject(this); } bool ConnectObj::HasRecvData() const { return _recvBuffer->HasData(); } Packet* ConnectObj::GetRecvPacket() const { return _recvBuffer->GetPacket(); } bool ConnectObj::Recv() const { bool isRs = false; char* pBuffer = nullptr; while (true) { // 总空间数据不足一个头的大小,扩容 if (_recvBuffer->GetEmptySize() < (sizeof(PacketHead) + sizeof(TotalSizeType))) { _recvBuffer->ReAllocBuffer(); } const int emptySize = _recvBuffer->GetBuffer(pBuffer); const int dataSize = ::recv(_socket, pBuffer, emptySize, 0); if (dataSize > 0) { //std::cout << "recv size:" << size << std::endl; _recvBuffer->FillDate(dataSize); } else if (dataSize == 0) { //std::cout << "recv size:" << dataSize << " error:" << _sock_err() << std::endl; break; } else { const auto socketError = _sock_err(); #ifndef WIN32 if (socketError == EINTR || socketError == EWOULDBLOCK || socketError == EAGAIN) { isRs = true; } #else if (socketError == WSAEINTR || socketError == WSAEWOULDBLOCK) { isRs = true; } #endif //std::cout << "recv size:" << dataSize << " error:" << socketError << std::endl; break; } } if (isRs) { while (true) { const auto pPacket = _recvBuffer->GetPacket(); if (pPacket == nullptr) break; //const google::protobuf::EnumDescriptor *descriptor = Proto::MsgId_descriptor(); //auto name = descriptor->FindValueByNumber(pPacket->GetMsgId())->name(); //std::cout << "recv msg:" << name.c_str() << std::endl; if (pPacket->GetMsgId() == Proto::MsgId::MI_Ping) { //RecvPing(); } else { if (_pNetWork->IsBroadcast() && _pNetWork->GetThread() != nullptr) { ThreadMgr::GetInstance()->DispatchPacket(pPacket); } else { _pNetWork->GetThread()->AddPacketToList(pPacket); } } } } return isRs; } bool ConnectObj::HasSendData() const { return _sendBuffer->HasData(); } void ConnectObj::SendPacket(Packet* pPacket) const { //const google::protobuf::EnumDescriptor *descriptor = Proto::MsgId_descriptor(); //auto name = descriptor->FindValueByNumber(pPacket->GetMsgId())->name(); //std::cout << "send msg:" << name.c_str() << std::endl; _sendBuffer->AddPacket(pPacket); } bool ConnectObj::Send() const { while (true) { char* pBuffer = nullptr; const int needSendSize = _sendBuffer->GetBuffer(pBuffer); // 没有数据可发送 if (needSendSize <= 0) { return true; } const int size = ::send(_socket, pBuffer, needSendSize, 0); if (size > 0) { _sendBuffer->RemoveDate(size); // 下一帧再发送 if (size < needSendSize) { return true; } } if (size <= 0) { const auto socketError = _sock_err(); std::cout << "needSendSize:" << needSendSize << " error:" << socketError << std::endl; return false; } } } void ConnectObj::Close() { const auto pPacketDis = new Packet(Proto::MsgId::MI_NetworkDisconnectToNet, GetSocket()); _pNetWork->GetThread()->AddPacketToList(pPacketDis); }
[ "setup_pf@hotmail.com" ]
setup_pf@hotmail.com
114ee26a9a472f759229f9ca6f96f75c22f0e041
4508de1150e176b51a20dedc9e4f9a25b14b7239
/src/ReportR.h
475077a444942bc86bb054d05800e592aae4a084
[]
no_license
rscharpf/XDE
cb5a5b8bae6a937f02266cfa5a532732c5eb8a9c
0459396ef32086488527c2b9fe8909fb3d3ebc0f
refs/heads/master
2021-05-15T02:05:36.722648
2017-09-28T23:56:24
2017-09-28T23:56:24
2,355,265
0
0
null
null
null
null
UTF-8
C++
false
false
969
h
#ifndef REPORTR_H #define REPORTR_H #include "Report.h" class ReportR : public Report { public: ReportR(const string &filename); ReportR(double *value); ~ReportR(void); void report(const Structure *str); private: int writeToFile; double *value; int nr; }; inline ReportR::ReportR(const string &filename) : Report(filename) { writeToFile = 1; return; } inline ReportR::ReportR(double *value) : Report() { writeToFile = 0; this->value = value; nr = 0; return; } inline ReportR::~ReportR(void) { return; } inline void ReportR::report(const Structure *str) { if (writeToFile) { int i,j; for (i = 0; i < str->Q; i++) for (j = i+1; j < str->Q; j++) out << str->r[i][j] << " "; out << "\n"; out.flush(); } else { int i,j; for (i = 0; i < str->Q; i++) for (j = i+1; j < str->Q; j++) { value[nr] = str->r[i][j]; nr++; } } return; } #endif
[ "p.aboyoun@bc3139a8-67e5-0310-9ffc-ced21a209358" ]
p.aboyoun@bc3139a8-67e5-0310-9ffc-ced21a209358
1415c74a4edc386720c997f6f9d8a80792922774
3da0b0276bc8c3d7d1bcdbabfb0e763a38d3a24c
/zju.finished/1601.cpp
475cf6e91f28f099361a4684932be65d6a0f3afe
[]
no_license
usherfu/zoj
4af6de9798bcb0ffa9dbb7f773b903f630e06617
8bb41d209b54292d6f596c5be55babd781610a52
refs/heads/master
2021-05-28T11:21:55.965737
2009-12-15T07:58:33
2009-12-15T07:58:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
754
cpp
#include<cstdio> #include<cmath> /*看了别人的代码,设置了A*L<=1 和 A>=L的情况*/ using namespace std; double A; int L; void fun(){ if(A * L <= 1){ printf("%d %d\n",1,L); return; } if(A >= L){ printf("%d %d\n",L,1); return; } int a,b; int sa=0,sb=1; double eps = A,t; for(b=1;b<=L;b++){ t = b * A; a = (int)t; t -= a; if(t >= 0.5) a++; if(a > L) break; t = fabs(A - a/(double)b); if(t < eps){ eps = t; sa = a; sb = b; } } printf("%d %d\n",sa,sb); } int main(){ while( scanf("%lf%d ", &A, &L) > 0){ fun(); } return 0; }
[ "zhouweikuan@gmail.com" ]
zhouweikuan@gmail.com
c36b3a7ae2ad70d511571a414c182e206f6b7d78
30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a
/scrape/data/Tokitsukaze and Discard Items/haomie_TLE.cpp
0e9d73c490cc5f27e8b0176cf2150ff3698a3775
[]
no_license
thegamer1907/Code_Analysis
0a2bb97a9fb5faf01d983c223d9715eb419b7519
48079e399321b585efc8a2c6a84c25e2e7a22a61
refs/heads/master
2020-05-27T01:20:55.921937
2019-11-20T11:15:11
2019-11-20T11:15:11
188,403,594
2
1
null
null
null
null
UTF-8
C++
false
false
687
cpp
#include<iostream> #include<cstdio> #include<cstring> #include<queue> #include<algorithm> #include<cmath> #include<vector> #include<map> #include<set> #include<deque> #include<string> using namespace std; int main() { #ifdef local freopen("1.txt","r",stdin); #endif long long n,m,k,num; cin>>n>>m>>k; queue<long long>a; int i; for(i=0;i<m;i++)cin>>num,a.push(num); long long page=n/k; long long fp; for(fp=1;fp<=page;fp++) { if(fp*k>=a.front())break; } long long ans=0,sum=0; while(!a.empty()) { int j=0; while(!a.empty()&&a.front()-sum<=fp*k)a.pop(),j++; if(j==0)fp++; else { sum+=j; ans++; } } cout<<ans; }
[ "harshitagar1907@gmail.com" ]
harshitagar1907@gmail.com
c9396978274982c96ff8a02daa546bea94ac9044
7e686824108f22f095a89860b235cc1267e6d32f
/src/consensus/merkle.cpp
f246a8cf3e89e15fbe3d5c7c8811699580956324
[ "MIT" ]
permissive
alleck/Splendid
2aace2cf675233c3c435c4eab4aedf8b32f23347
8ea29bda381628f954d1699a38a70c3ae3506ed9
refs/heads/main
2023-03-20T11:20:13.567687
2021-02-22T21:56:34
2021-02-22T21:56:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,796
cpp
// Copyright (c) 2015-2016 The Bitcoin Core developers // Copyright (c) 2017-2019 The Splendid Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "merkle.h" #include "hash.h" #include "utilstrencodings.h" /* WARNING! If you're reading this because you're learning about crypto and/or designing a new system that will use merkle trees, keep in mind that the following merkle tree algorithm has a serious flaw related to duplicate txids, resulting in a vulnerability (CVE-2012-2459). The reason is that if the number of hashes in the list at a given time is odd, the last one is duplicated before computing the next level (which is unusual in Merkle trees). This results in certain sequences of transactions leading to the same merkle root. For example, these two trees: A A / \ / \ B C B C / \ | / \ / \ D E F D E F F / \ / \ / \ / \ / \ / \ / \ 1 2 3 4 5 6 1 2 3 4 5 6 5 6 for transaction lists [1,2,3,4,5,6] and [1,2,3,4,5,6,5,6] (where 5 and 6 are repeated) result in the same root hash A (because the hash of both of (F) and (F,F) is C). The vulnerability results from being able to send a block with such a transaction list, with the same merkle root, and the same block hash as the original without duplication, resulting in failed validation. If the receiving node proceeds to mark that block as permanently invalid however, it will fail to accept further unmodified (and thus potentially valid) versions of the same block. We defend against this by detecting the case where we would hash two identical hashes at the end of the list together, and treating that identically to the block having an invalid merkle root. Assuming no double-SHA256 collisions, this will detect all known ways of changing the transactions without affecting the merkle root. */ /* This implements a constant-space merkle root/path calculator, limited to 2^32 leaves. */ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot, bool* pmutated, uint32_t branchpos, std::vector<uint256>* pbranch) { if (pbranch) pbranch->clear(); if (leaves.size() == 0) { if (pmutated) *pmutated = false; if (proot) *proot = uint256(); return; } bool mutated = false; // count is the number of leaves processed so far. uint32_t count = 0; // inner is an array of eagerly computed subtree hashes, indexed by tree // level (0 being the leaves). // For example, when count is 25 (11001 in binary), inner[4] is the hash of // the first 16 leaves, inner[3] of the next 8 leaves, and inner[0] equal to // the last leaf. The other inner entries are undefined. uint256 inner[32]; // Which position in inner is a hash that depends on the matching leaf. int matchlevel = -1; // First process all leaves into 'inner' values. while (count < leaves.size()) { uint256 h = leaves[count]; bool matchh = count == branchpos; count++; int level; // For each of the lower bits in count that are 0, do 1 step. Each // corresponds to an inner value that existed before processing the // current leaf, and each needs a hash to combine it. for (level = 0; !(count & (((uint32_t)1) << level)); level++) { if (pbranch) { if (matchh) { pbranch->push_back(inner[level]); } else if (matchlevel == level) { pbranch->push_back(h); matchh = true; } } mutated |= (inner[level] == h); CHash256().Write(inner[level].begin(), 32).Write(h.begin(), 32).Finalize(h.begin()); } // Store the resulting hash at inner position level. inner[level] = h; if (matchh) { matchlevel = level; } } // Do a final 'sweep' over the rightmost branch of the tree to process // odd levels, and reduce everything to a single top value. // Level is the level (counted from the bottom) up to which we've sweeped. int level = 0; // As long as bit number level in count is zero, skip it. It means there // is nothing left at this level. while (!(count & (((uint32_t)1) << level))) { level++; } uint256 h = inner[level]; bool matchh = matchlevel == level; while (count != (((uint32_t)1) << level)) { // If we reach this point, h is an inner value that is not the top. // We combine it with itself (Splendid's special rule for odd levels in // the tree) to produce a higher level one. if (pbranch && matchh) { pbranch->push_back(h); } CHash256().Write(h.begin(), 32).Write(h.begin(), 32).Finalize(h.begin()); // Increment count to the value it would have if two entries at this // level had existed. count += (((uint32_t)1) << level); level++; // And propagate the result upwards accordingly. while (!(count & (((uint32_t)1) << level))) { if (pbranch) { if (matchh) { pbranch->push_back(inner[level]); } else if (matchlevel == level) { pbranch->push_back(h); matchh = true; } } CHash256().Write(inner[level].begin(), 32).Write(h.begin(), 32).Finalize(h.begin()); level++; } } // Return result. if (pmutated) *pmutated = mutated; if (proot) *proot = h; } uint256 ComputeMerkleRoot(const std::vector<uint256>& leaves, bool* mutated) { uint256 hash; MerkleComputation(leaves, &hash, mutated, -1, nullptr); return hash; } std::vector<uint256> ComputeMerkleBranch(const std::vector<uint256>& leaves, uint32_t position) { std::vector<uint256> ret; MerkleComputation(leaves, nullptr, nullptr, position, &ret); return ret; } uint256 ComputeMerkleRootFromBranch(const uint256& leaf, const std::vector<uint256>& vMerkleBranch, uint32_t nIndex) { uint256 hash = leaf; for (std::vector<uint256>::const_iterator it = vMerkleBranch.begin(); it != vMerkleBranch.end(); ++it) { if (nIndex & 1) { hash = Hash(BEGIN(*it), END(*it), BEGIN(hash), END(hash)); } else { hash = Hash(BEGIN(hash), END(hash), BEGIN(*it), END(*it)); } nIndex >>= 1; } return hash; } uint256 BlockMerkleRoot(const CBlock& block, bool* mutated) { std::vector<uint256> leaves; leaves.resize(block.vtx.size()); for (size_t s = 0; s < block.vtx.size(); s++) { leaves[s] = block.vtx[s]->GetHash(); } return ComputeMerkleRoot(leaves, mutated); } uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated) { std::vector<uint256> leaves; leaves.resize(block.vtx.size()); leaves[0].SetNull(); // The witness hash of the coinbase is 0. for (size_t s = 1; s < block.vtx.size(); s++) { leaves[s] = block.vtx[s]->GetWitnessHash(); } return ComputeMerkleRoot(leaves, mutated); } std::vector<uint256> BlockMerkleBranch(const CBlock& block, uint32_t position) { std::vector<uint256> leaves; leaves.resize(block.vtx.size()); for (size_t s = 0; s < block.vtx.size(); s++) { leaves[s] = block.vtx[s]->GetHash(); } return ComputeMerkleBranch(leaves, position); }
[ "79376856+SplendidProject@users.noreply.github.com" ]
79376856+SplendidProject@users.noreply.github.com
465373fe284d301226dd36ae09427d90ffe99f7c
775acebaa6559bb12365c930330a62365afb0d98
/source/sdksamples/basicshape/BscShpID.cpp
fb3341a6cd1b8ca7feea4757bfb0dae762f6ed12
[]
no_license
Al-ain-Developers/indesing_plugin
3d22c32d3d547fa3a4b1fc469498de57643e9ee3
36a09796b390e28afea25456b5d61597b20de850
refs/heads/main
2023-08-14T13:34:47.867890
2021-10-05T07:57:35
2021-10-05T07:57:35
339,970,603
1
1
null
2021-10-05T07:57:36
2021-02-18T07:33:40
C++
UTF-8
C++
false
false
1,177
cpp
//======================================================================================== // // $File: //depot/devtech/16.0.x/plugin/source/sdksamples/basicshape/BscShpID.cpp $ // // Owner: Adobe Developer Technologies // // $Author: pmbuilder $ // // $DateTime: 2020/11/06 13:08:29 $ // // $Revision: #2 $ // // $Change: 1088580 $ // // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance // with the terms of the Adobe license agreement accompanying it. If you have received // this file from a source other than Adobe, then your use, modification, or // distribution of it requires the prior written permission of Adobe. // // // Makes your IDs available as named symbols in the Debug build. // //======================================================================================== #include "VCPlugInHeaders.h" // General includes: #include "ShuksanID.h" #include "IDFactory_cpp.h" #pragma export on #include "BscShpID.h" #pragma export off // Generated by Dolly build 17: template "IfPanelMenu". // End, BscShpID.cpp.
[ "75730278+Tarekhesham10@users.noreply.github.com" ]
75730278+Tarekhesham10@users.noreply.github.com
87500661294c71adb45d587c92f9d8a2a7bf07cf
46f53e9a564192eed2f40dc927af6448f8608d13
/chrome/browser/safe_browsing/database_manager_unittest.cc
a3e2e710e486dc0fb05389102b165a6f79d46e0b
[ "BSD-3-Clause" ]
permissive
sgraham/nope
deb2d106a090d71ae882ac1e32e7c371f42eaca9
f974e0c234388a330aab71a3e5bbf33c4dcfc33c
refs/heads/master
2022-12-21T01:44:15.776329
2015-03-23T17:25:47
2015-03-23T17:25:47
32,344,868
2
2
null
null
null
null
UTF-8
C++
false
false
9,360
cc
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <string> #include <vector> #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "chrome/browser/safe_browsing/database_manager.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "components/variations/variations_associated_data.h" #include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" #include "url/gurl.h" using content::TestBrowserThreadBundle; namespace { class TestClient : public SafeBrowsingDatabaseManager::Client { public: TestClient() {} ~TestClient() override {} void OnCheckBrowseUrlResult(const GURL& url, SBThreatType threat_type, const std::string& metadata) override {} void OnCheckDownloadUrlResult(const std::vector<GURL>& url_chain, SBThreatType threat_type) override {} private: DISALLOW_COPY_AND_ASSIGN(TestClient); }; } // namespace class SafeBrowsingDatabaseManagerTest : public PlatformTest { public: bool RunSBHashTest(const safe_browsing_util::ListType list_type, const std::vector<SBThreatType>& expected_threats, const std::string& result_list); private: TestBrowserThreadBundle thread_bundle_; }; bool SafeBrowsingDatabaseManagerTest::RunSBHashTest( const safe_browsing_util::ListType list_type, const std::vector<SBThreatType>& expected_threats, const std::string& result_list) { scoped_refptr<SafeBrowsingService> sb_service_( SafeBrowsingService::CreateSafeBrowsingService()); scoped_refptr<SafeBrowsingDatabaseManager> db_manager_( new SafeBrowsingDatabaseManager(sb_service_)); const SBFullHash same_full_hash = {}; SafeBrowsingDatabaseManager::SafeBrowsingCheck* check = new SafeBrowsingDatabaseManager::SafeBrowsingCheck( std::vector<GURL>(), std::vector<SBFullHash>(1, same_full_hash), NULL, list_type, expected_threats); db_manager_->checks_.insert(check); const SBFullHashResult full_hash_result = { same_full_hash, safe_browsing_util::GetListId(result_list) }; std::vector<SBFullHashResult> fake_results(1, full_hash_result); bool result = db_manager_->HandleOneCheck(check, fake_results); db_manager_->checks_.erase(check); delete check; return result; } TEST_F(SafeBrowsingDatabaseManagerTest, CheckCorrespondsListType) { std::vector<SBThreatType> malware_threat(1, SB_THREAT_TYPE_BINARY_MALWARE_URL); EXPECT_FALSE(RunSBHashTest(safe_browsing_util::BINURL, malware_threat, safe_browsing_util::kMalwareList)); EXPECT_TRUE(RunSBHashTest(safe_browsing_util::BINURL, malware_threat, safe_browsing_util::kBinUrlList)); // Check for multiple threats std::vector<SBThreatType> multiple_threats; multiple_threats.push_back(SB_THREAT_TYPE_URL_MALWARE); multiple_threats.push_back(SB_THREAT_TYPE_URL_PHISHING); EXPECT_FALSE(RunSBHashTest(safe_browsing_util::MALWARE, multiple_threats, safe_browsing_util::kBinUrlList)); EXPECT_TRUE(RunSBHashTest(safe_browsing_util::MALWARE, multiple_threats, safe_browsing_util::kMalwareList)); } TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) { std::vector<SBFullHashResult> full_hashes; const GURL kMalwareUrl("http://www.malware.com/page.html"); const GURL kPhishingUrl("http://www.phishing.com/page.html"); const GURL kUnwantedUrl("http://www.unwanted.com/page.html"); const GURL kUnwantedAndMalwareUrl( "http://www.unwantedandmalware.com/page.html"); const GURL kSafeUrl("http://www.safe.com/page.html"); const SBFullHash kMalwareHostHash = SBFullHashForString("malware.com/"); const SBFullHash kPhishingHostHash = SBFullHashForString("phishing.com/"); const SBFullHash kUnwantedHostHash = SBFullHashForString("unwanted.com/"); const SBFullHash kUnwantedAndMalwareHostHash = SBFullHashForString("unwantedandmalware.com/"); const SBFullHash kSafeHostHash = SBFullHashForString("www.safe.com/"); { SBFullHashResult full_hash; full_hash.hash = kMalwareHostHash; full_hash.list_id = static_cast<int>(safe_browsing_util::MALWARE); full_hashes.push_back(full_hash); } { SBFullHashResult full_hash; full_hash.hash = kPhishingHostHash; full_hash.list_id = static_cast<int>(safe_browsing_util::PHISH); full_hashes.push_back(full_hash); } { SBFullHashResult full_hash; full_hash.hash = kUnwantedHostHash; full_hash.list_id = static_cast<int>(safe_browsing_util::UNWANTEDURL); full_hashes.push_back(full_hash); } { // Add both MALWARE and UNWANTEDURL list IDs for // kUnwantedAndMalwareHostHash. SBFullHashResult full_hash_malware; full_hash_malware.hash = kUnwantedAndMalwareHostHash; full_hash_malware.list_id = static_cast<int>(safe_browsing_util::MALWARE); full_hashes.push_back(full_hash_malware); SBFullHashResult full_hash_unwanted; full_hash_unwanted.hash = kUnwantedAndMalwareHostHash; full_hash_unwanted.list_id = static_cast<int>(safe_browsing_util::UNWANTEDURL); full_hashes.push_back(full_hash_unwanted); } EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, SafeBrowsingDatabaseManager::GetHashSeverestThreatType( kMalwareHostHash, full_hashes)); EXPECT_EQ(SB_THREAT_TYPE_URL_PHISHING, SafeBrowsingDatabaseManager::GetHashSeverestThreatType( kPhishingHostHash, full_hashes)); EXPECT_EQ(SB_THREAT_TYPE_URL_UNWANTED, SafeBrowsingDatabaseManager::GetHashSeverestThreatType( kUnwantedHostHash, full_hashes)); EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, SafeBrowsingDatabaseManager::GetHashSeverestThreatType( kUnwantedAndMalwareHostHash, full_hashes)); EXPECT_EQ(SB_THREAT_TYPE_SAFE, SafeBrowsingDatabaseManager::GetHashSeverestThreatType( kSafeHostHash, full_hashes)); const size_t kArbitraryValue = 123456U; size_t index = kArbitraryValue; EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, SafeBrowsingDatabaseManager::GetUrlSeverestThreatType( kMalwareUrl, full_hashes, &index)); EXPECT_EQ(0U, index); EXPECT_EQ(SB_THREAT_TYPE_URL_PHISHING, SafeBrowsingDatabaseManager::GetUrlSeverestThreatType( kPhishingUrl, full_hashes, &index)); EXPECT_EQ(1U, index); EXPECT_EQ(SB_THREAT_TYPE_URL_UNWANTED, SafeBrowsingDatabaseManager::GetUrlSeverestThreatType( kUnwantedUrl, full_hashes, &index)); EXPECT_EQ(2U, index); EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, SafeBrowsingDatabaseManager::GetUrlSeverestThreatType( kUnwantedAndMalwareUrl, full_hashes, &index)); EXPECT_EQ(3U, index); index = kArbitraryValue; EXPECT_EQ(SB_THREAT_TYPE_SAFE, SafeBrowsingDatabaseManager::GetUrlSeverestThreatType( kSafeUrl, full_hashes, &index)); EXPECT_EQ(kArbitraryValue, index); } TEST_F(SafeBrowsingDatabaseManagerTest, ServiceStopWithPendingChecks) { // Force the "blocking pool" mode for the test. This allows test coverage // for this behavior while that mode is still not the default. Additionally, // it is currently required for this test to work - as RunUntilIdle() will // not run tasks of the special spawned thread, but will for the worker pool. // TODO(asvitkine): Clean up, when blocking pool mode is made the default. base::FieldTrialList list(nullptr); std::map<std::string, std::string> params; params["SBThreadingMode"] = "BlockingPool2"; variations::AssociateVariationParams("LightSpeed", "X", params); base::FieldTrialList::CreateFieldTrial("LightSpeed", "X"); scoped_refptr<SafeBrowsingService> sb_service( SafeBrowsingService::CreateSafeBrowsingService()); scoped_refptr<SafeBrowsingDatabaseManager> db_manager( new SafeBrowsingDatabaseManager(sb_service)); TestClient client; // Start the service and flush tasks to ensure database is made available. db_manager->StartOnIOThread(); content::RunAllBlockingPoolTasksUntilIdle(); base::RunLoop().RunUntilIdle(); EXPECT_TRUE(db_manager->DatabaseAvailable()); // Start an extension check operation, which is done asynchronously. std::set<std::string> extension_ids; extension_ids.insert("testtesttesttesttesttesttesttest"); db_manager->CheckExtensionIDs(extension_ids, &client); // Stop the service without first flushing above tasks. db_manager->StopOnIOThread(false); // Now run posted tasks, whish should include the extension check which has // been posted to the safe browsing task runner. This should not crash. content::RunAllBlockingPoolTasksUntilIdle(); base::RunLoop().RunUntilIdle(); variations::testing::ClearAllVariationParams(); }
[ "scottmg@chromium.org" ]
scottmg@chromium.org
9ca91dc64c88db274659b853e98f7c1ca766e01b
44a09c05c678705b39d12bc3de282a0e800b1779
/Coin Change (II).cpp
2bcfd8c6b49fc1e4a50f7aeb8de8f886f276b56b
[]
no_license
sohelarman1100/Dynamic-Programming
70af7edee1df78f326193f6375781e62a958cc27
cc56e25c1b2d4c33ce1f7f4e77ff83b65ffe0c94
refs/heads/master
2023-03-22T05:29:21.964627
2021-03-18T09:39:30
2021-03-18T09:39:30
343,735,436
0
0
null
null
null
null
UTF-8
C++
false
false
662
cpp
#include<bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back #define mod 100000007 int main() { ll t,c; ll tot[10005]; cin>>t; for(c=1; c<=t; c++) { ll i,j,k,l,m,n; cin>>n>>k; ll val[n+1]; for(i=1; i<=n; i++) cin>>val[i]; for(i=0; i<=10000; i++) tot[i]=0; tot[0]=1; for(i=1; i<=n; i++) { for(j=val[i]; j<=k; j++) { tot[j]+=tot[j-val[i]]; tot[j]=tot[j]%mod; } } cout<<"Case "<<c<<": "<<tot[k]<<endl; } return 0; }
[ "armanhossain54546@gmail.com" ]
armanhossain54546@gmail.com
70989128366a49ebbea45c69fb85d68d05b95451
003fb5094021351eb82c49c8eadbb6dd5b139004
/006_BAEKJOON/09461.cpp
c9e3593e1d39f3b3f15672e801231af3d69418be
[]
no_license
woongbinni/algorithm
ebdb700195ccc158f7be1ebf7af06e9913d4e8fd
a1d5c0bc8b727d4feea670ea35218e701e0ffdb4
refs/heads/master
2022-11-16T23:40:44.628307
2022-11-11T15:21:26
2022-11-11T15:21:26
32,263,313
0
0
null
null
null
null
UTF-8
C++
false
false
291
cpp
#include <stdio.h> unsigned long long P[101]; int main(){ int T; int N; P[1] = 1; P[2] = 1; P[3] = 1; for(int i=4; i<=100; ++i){ P[i] = P[i-2] + P[i-3]; } scanf("%d", &T); for(int i=0; i<T; ++i){ scanf("%d", &N); printf("%llu\n", P[N]); } return 0; }
[ "woongbinni@gmail.com" ]
woongbinni@gmail.com
783838f34e16f8a7bc48da95cfc4839e9d267a4d
8c8820fb84dea70d31c1e31dd57d295bd08dd644
/Core/Private/Misc/Crc.cpp
6f6da69421451642ddd79710eda91fd98994e73b
[]
no_license
redisread/UE-Runtime
e1a56df95a4591e12c0fd0e884ac6e54f69d0a57
48b9e72b1ad04458039c6ddeb7578e4fc68a7bac
refs/heads/master
2022-11-15T08:30:24.570998
2020-06-20T06:37:55
2020-06-20T06:37:55
274,085,558
3
0
null
null
null
null
UTF-8
C++
false
false
57,988
cpp
// Copyright Epic Games, Inc. All Rights Reserved. #include "Misc/Crc.h" #include "Templates/AlignmentTemplates.h" #include "Templates/UnrealTemplate.h" #include "Misc/ByteSwap.h" /** CRC 32 polynomial */ enum { Crc32Poly = 0x04c11db7 }; uint32 FCrc::CRCTable_DEPRECATED[256] = { 0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B, 0x1A864DB2, 0x1E475005, 0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6, 0x2B4BCB61, 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD, 0x4C11DB70, 0x48D0C6C7, 0x4593E01E, 0x4152FDA9, 0x5F15ADAC, 0x5BD4B01B, 0x569796C2, 0x52568B75, 0x6A1936C8, 0x6ED82B7F, 0x639B0DA6, 0x675A1011, 0x791D4014, 0x7DDC5DA3, 0x709F7B7A, 0x745E66CD, 0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039, 0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5, 0xBE2B5B58, 0xBAEA46EF, 0xB7A96036, 0xB3687D81, 0xAD2F2D84, 0xA9EE3033, 0xA4AD16EA, 0xA06C0B5D, 0xD4326D90, 0xD0F37027, 0xDDB056FE, 0xD9714B49, 0xC7361B4C, 0xC3F706FB, 0xCEB42022, 0xCA753D95, 0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1, 0xE13EF6F4, 0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D, 0x34867077, 0x30476DC0, 0x3D044B19, 0x39C556AE, 0x278206AB, 0x23431B1C, 0x2E003DC5, 0x2AC12072, 0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16, 0x018AEB13, 0x054BF6A4, 0x0808D07D, 0x0CC9CDCA, 0x7897AB07, 0x7C56B6B0, 0x71159069, 0x75D48DDE, 0x6B93DDDB, 0x6F52C06C, 0x6211E6B5, 0x66D0FB02, 0x5E9F46BF, 0x5A5E5B08, 0x571D7DD1, 0x53DC6066, 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA, 0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E, 0xBFA1B04B, 0xBB60ADFC, 0xB6238B25, 0xB2E29692, 0x8AAD2B2F, 0x8E6C3698, 0x832F1041, 0x87EE0DF6, 0x99A95DF3, 0x9D684044, 0x902B669D, 0x94EA7B2A, 0xE0B41DE7, 0xE4750050, 0xE9362689, 0xEDF73B3E, 0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2, 0xC6BCF05F, 0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686, 0xD5B88683, 0xD1799B34, 0xDC3ABDED, 0xD8FBA05A, 0x690CE0EE, 0x6DCDFD59, 0x608EDB80, 0x644FC637, 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB, 0x4F040D56, 0x4BC510E1, 0x46863638, 0x42472B8F, 0x5C007B8A, 0x58C1663D, 0x558240E4, 0x51435D53, 0x251D3B9E, 0x21DC2629, 0x2C9F00F0, 0x285E1D47, 0x36194D42, 0x32D850F5, 0x3F9B762C, 0x3B5A6B9B, 0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF, 0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623, 0xF12F560E, 0xF5EE4BB9, 0xF8AD6D60, 0xFC6C70D7, 0xE22B20D2, 0xE6EA3D65, 0xEBA91BBC, 0xEF68060B, 0xD727BBB6, 0xD3E6A601, 0xDEA580D8, 0xDA649D6F, 0xC423CD6A, 0xC0E2D0DD, 0xCDA1F604, 0xC960EBB3, 0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7, 0xAE3AFBA2, 0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B, 0x9B3660C6, 0x9FF77D71, 0x92B45BA8, 0x9675461F, 0x8832161A, 0x8CF30BAD, 0x81B02D74, 0x857130C3, 0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640, 0x4E8EE645, 0x4A4FFBF2, 0x470CDD2B, 0x43CDC09C, 0x7B827D21, 0x7F436096, 0x7200464F, 0x76C15BF8, 0x68860BFD, 0x6C47164A, 0x61043093, 0x65C52D24, 0x119B4BE9, 0x155A565E, 0x18197087, 0x1CD86D30, 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC, 0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088, 0x2497D08D, 0x2056CD3A, 0x2D15EBE3, 0x29D4F654, 0xC5A92679, 0xC1683BCE, 0xCC2B1D17, 0xC8EA00A0, 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB, 0xDBEE767C, 0xE3A1CBC1, 0xE760D676, 0xEA23F0AF, 0xEEE2ED18, 0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4, 0x89B8FD09, 0x8D79E0BE, 0x803AC667, 0x84FBDBD0, 0x9ABC8BD5, 0x9E7D9662, 0x933EB0BB, 0x97FFAD0C, 0xAFB010B1, 0xAB710D06, 0xA6322BDF, 0xA2F33668, 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4 }; uint32 FCrc::CRCTablesSB8_DEPRECATED[8][256] = { { 0x00000000, 0xb71dc104, 0x6e3b8209, 0xd926430d, 0xdc760413, 0x6b6bc517, 0xb24d861a, 0x0550471e, 0xb8ed0826, 0x0ff0c922, 0xd6d68a2f, 0x61cb4b2b, 0x649b0c35, 0xd386cd31, 0x0aa08e3c, 0xbdbd4f38, 0x70db114c, 0xc7c6d048, 0x1ee09345, 0xa9fd5241, 0xacad155f, 0x1bb0d45b, 0xc2969756, 0x758b5652, 0xc836196a, 0x7f2bd86e, 0xa60d9b63, 0x11105a67, 0x14401d79, 0xa35ddc7d, 0x7a7b9f70, 0xcd665e74, 0xe0b62398, 0x57abe29c, 0x8e8da191, 0x39906095, 0x3cc0278b, 0x8bdde68f, 0x52fba582, 0xe5e66486, 0x585b2bbe, 0xef46eaba, 0x3660a9b7, 0x817d68b3, 0x842d2fad, 0x3330eea9, 0xea16ada4, 0x5d0b6ca0, 0x906d32d4, 0x2770f3d0, 0xfe56b0dd, 0x494b71d9, 0x4c1b36c7, 0xfb06f7c3, 0x2220b4ce, 0x953d75ca, 0x28803af2, 0x9f9dfbf6, 0x46bbb8fb, 0xf1a679ff, 0xf4f63ee1, 0x43ebffe5, 0x9acdbce8, 0x2dd07dec, 0x77708634, 0xc06d4730, 0x194b043d, 0xae56c539, 0xab068227, 0x1c1b4323, 0xc53d002e, 0x7220c12a, 0xcf9d8e12, 0x78804f16, 0xa1a60c1b, 0x16bbcd1f, 0x13eb8a01, 0xa4f64b05, 0x7dd00808, 0xcacdc90c, 0x07ab9778, 0xb0b6567c, 0x69901571, 0xde8dd475, 0xdbdd936b, 0x6cc0526f, 0xb5e61162, 0x02fbd066, 0xbf469f5e, 0x085b5e5a, 0xd17d1d57, 0x6660dc53, 0x63309b4d, 0xd42d5a49, 0x0d0b1944, 0xba16d840, 0x97c6a5ac, 0x20db64a8, 0xf9fd27a5, 0x4ee0e6a1, 0x4bb0a1bf, 0xfcad60bb, 0x258b23b6, 0x9296e2b2, 0x2f2bad8a, 0x98366c8e, 0x41102f83, 0xf60dee87, 0xf35da999, 0x4440689d, 0x9d662b90, 0x2a7bea94, 0xe71db4e0, 0x500075e4, 0x892636e9, 0x3e3bf7ed, 0x3b6bb0f3, 0x8c7671f7, 0x555032fa, 0xe24df3fe, 0x5ff0bcc6, 0xe8ed7dc2, 0x31cb3ecf, 0x86d6ffcb, 0x8386b8d5, 0x349b79d1, 0xedbd3adc, 0x5aa0fbd8, 0xeee00c69, 0x59fdcd6d, 0x80db8e60, 0x37c64f64, 0x3296087a, 0x858bc97e, 0x5cad8a73, 0xebb04b77, 0x560d044f, 0xe110c54b, 0x38368646, 0x8f2b4742, 0x8a7b005c, 0x3d66c158, 0xe4408255, 0x535d4351, 0x9e3b1d25, 0x2926dc21, 0xf0009f2c, 0x471d5e28, 0x424d1936, 0xf550d832, 0x2c769b3f, 0x9b6b5a3b, 0x26d61503, 0x91cbd407, 0x48ed970a, 0xfff0560e, 0xfaa01110, 0x4dbdd014, 0x949b9319, 0x2386521d, 0x0e562ff1, 0xb94beef5, 0x606dadf8, 0xd7706cfc, 0xd2202be2, 0x653deae6, 0xbc1ba9eb, 0x0b0668ef, 0xb6bb27d7, 0x01a6e6d3, 0xd880a5de, 0x6f9d64da, 0x6acd23c4, 0xddd0e2c0, 0x04f6a1cd, 0xb3eb60c9, 0x7e8d3ebd, 0xc990ffb9, 0x10b6bcb4, 0xa7ab7db0, 0xa2fb3aae, 0x15e6fbaa, 0xccc0b8a7, 0x7bdd79a3, 0xc660369b, 0x717df79f, 0xa85bb492, 0x1f467596, 0x1a163288, 0xad0bf38c, 0x742db081, 0xc3307185, 0x99908a5d, 0x2e8d4b59, 0xf7ab0854, 0x40b6c950, 0x45e68e4e, 0xf2fb4f4a, 0x2bdd0c47, 0x9cc0cd43, 0x217d827b, 0x9660437f, 0x4f460072, 0xf85bc176, 0xfd0b8668, 0x4a16476c, 0x93300461, 0x242dc565, 0xe94b9b11, 0x5e565a15, 0x87701918, 0x306dd81c, 0x353d9f02, 0x82205e06, 0x5b061d0b, 0xec1bdc0f, 0x51a69337, 0xe6bb5233, 0x3f9d113e, 0x8880d03a, 0x8dd09724, 0x3acd5620, 0xe3eb152d, 0x54f6d429, 0x7926a9c5, 0xce3b68c1, 0x171d2bcc, 0xa000eac8, 0xa550add6, 0x124d6cd2, 0xcb6b2fdf, 0x7c76eedb, 0xc1cba1e3, 0x76d660e7, 0xaff023ea, 0x18ede2ee, 0x1dbda5f0, 0xaaa064f4, 0x738627f9, 0xc49be6fd, 0x09fdb889, 0xbee0798d, 0x67c63a80, 0xd0dbfb84, 0xd58bbc9a, 0x62967d9e, 0xbbb03e93, 0x0cadff97, 0xb110b0af, 0x060d71ab, 0xdf2b32a6, 0x6836f3a2, 0x6d66b4bc, 0xda7b75b8, 0x035d36b5, 0xb440f7b1 }, { 0x00000000, 0xdcc119d2, 0x0f9ef2a0, 0xd35feb72, 0xa9212445, 0x75e03d97, 0xa6bfd6e5, 0x7a7ecf37, 0x5243488a, 0x8e825158, 0x5dddba2a, 0x811ca3f8, 0xfb626ccf, 0x27a3751d, 0xf4fc9e6f, 0x283d87bd, 0x139b5110, 0xcf5a48c2, 0x1c05a3b0, 0xc0c4ba62, 0xbaba7555, 0x667b6c87, 0xb52487f5, 0x69e59e27, 0x41d8199a, 0x9d190048, 0x4e46eb3a, 0x9287f2e8, 0xe8f93ddf, 0x3438240d, 0xe767cf7f, 0x3ba6d6ad, 0x2636a320, 0xfaf7baf2, 0x29a85180, 0xf5694852, 0x8f178765, 0x53d69eb7, 0x808975c5, 0x5c486c17, 0x7475ebaa, 0xa8b4f278, 0x7beb190a, 0xa72a00d8, 0xdd54cfef, 0x0195d63d, 0xd2ca3d4f, 0x0e0b249d, 0x35adf230, 0xe96cebe2, 0x3a330090, 0xe6f21942, 0x9c8cd675, 0x404dcfa7, 0x931224d5, 0x4fd33d07, 0x67eebaba, 0xbb2fa368, 0x6870481a, 0xb4b151c8, 0xcecf9eff, 0x120e872d, 0xc1516c5f, 0x1d90758d, 0x4c6c4641, 0x90ad5f93, 0x43f2b4e1, 0x9f33ad33, 0xe54d6204, 0x398c7bd6, 0xead390a4, 0x36128976, 0x1e2f0ecb, 0xc2ee1719, 0x11b1fc6b, 0xcd70e5b9, 0xb70e2a8e, 0x6bcf335c, 0xb890d82e, 0x6451c1fc, 0x5ff71751, 0x83360e83, 0x5069e5f1, 0x8ca8fc23, 0xf6d63314, 0x2a172ac6, 0xf948c1b4, 0x2589d866, 0x0db45fdb, 0xd1754609, 0x022aad7b, 0xdeebb4a9, 0xa4957b9e, 0x7854624c, 0xab0b893e, 0x77ca90ec, 0x6a5ae561, 0xb69bfcb3, 0x65c417c1, 0xb9050e13, 0xc37bc124, 0x1fbad8f6, 0xcce53384, 0x10242a56, 0x3819adeb, 0xe4d8b439, 0x37875f4b, 0xeb464699, 0x913889ae, 0x4df9907c, 0x9ea67b0e, 0x426762dc, 0x79c1b471, 0xa500ada3, 0x765f46d1, 0xaa9e5f03, 0xd0e09034, 0x0c2189e6, 0xdf7e6294, 0x03bf7b46, 0x2b82fcfb, 0xf743e529, 0x241c0e5b, 0xf8dd1789, 0x82a3d8be, 0x5e62c16c, 0x8d3d2a1e, 0x51fc33cc, 0x98d88c82, 0x44199550, 0x97467e22, 0x4b8767f0, 0x31f9a8c7, 0xed38b115, 0x3e675a67, 0xe2a643b5, 0xca9bc408, 0x165addda, 0xc50536a8, 0x19c42f7a, 0x63bae04d, 0xbf7bf99f, 0x6c2412ed, 0xb0e50b3f, 0x8b43dd92, 0x5782c440, 0x84dd2f32, 0x581c36e0, 0x2262f9d7, 0xfea3e005, 0x2dfc0b77, 0xf13d12a5, 0xd9009518, 0x05c18cca, 0xd69e67b8, 0x0a5f7e6a, 0x7021b15d, 0xace0a88f, 0x7fbf43fd, 0xa37e5a2f, 0xbeee2fa2, 0x622f3670, 0xb170dd02, 0x6db1c4d0, 0x17cf0be7, 0xcb0e1235, 0x1851f947, 0xc490e095, 0xecad6728, 0x306c7efa, 0xe3339588, 0x3ff28c5a, 0x458c436d, 0x994d5abf, 0x4a12b1cd, 0x96d3a81f, 0xad757eb2, 0x71b46760, 0xa2eb8c12, 0x7e2a95c0, 0x04545af7, 0xd8954325, 0x0bcaa857, 0xd70bb185, 0xff363638, 0x23f72fea, 0xf0a8c498, 0x2c69dd4a, 0x5617127d, 0x8ad60baf, 0x5989e0dd, 0x8548f90f, 0xd4b4cac3, 0x0875d311, 0xdb2a3863, 0x07eb21b1, 0x7d95ee86, 0xa154f754, 0x720b1c26, 0xaeca05f4, 0x86f78249, 0x5a369b9b, 0x896970e9, 0x55a8693b, 0x2fd6a60c, 0xf317bfde, 0x204854ac, 0xfc894d7e, 0xc72f9bd3, 0x1bee8201, 0xc8b16973, 0x147070a1, 0x6e0ebf96, 0xb2cfa644, 0x61904d36, 0xbd5154e4, 0x956cd359, 0x49adca8b, 0x9af221f9, 0x4633382b, 0x3c4df71c, 0xe08ceece, 0x33d305bc, 0xef121c6e, 0xf28269e3, 0x2e437031, 0xfd1c9b43, 0x21dd8291, 0x5ba34da6, 0x87625474, 0x543dbf06, 0x88fca6d4, 0xa0c12169, 0x7c0038bb, 0xaf5fd3c9, 0x739eca1b, 0x09e0052c, 0xd5211cfe, 0x067ef78c, 0xdabfee5e, 0xe11938f3, 0x3dd82121, 0xee87ca53, 0x3246d381, 0x48381cb6, 0x94f90564, 0x47a6ee16, 0x9b67f7c4, 0xb35a7079, 0x6f9b69ab, 0xbcc482d9, 0x60059b0b, 0x1a7b543c, 0xc6ba4dee, 0x15e5a69c, 0xc924bf4e }, { 0x00000000, 0x87acd801, 0x0e59b103, 0x89f56902, 0x1cb26207, 0x9b1eba06, 0x12ebd304, 0x95470b05, 0x3864c50e, 0xbfc81d0f, 0x363d740d, 0xb191ac0c, 0x24d6a709, 0xa37a7f08, 0x2a8f160a, 0xad23ce0b, 0x70c88a1d, 0xf764521c, 0x7e913b1e, 0xf93de31f, 0x6c7ae81a, 0xebd6301b, 0x62235919, 0xe58f8118, 0x48ac4f13, 0xcf009712, 0x46f5fe10, 0xc1592611, 0x541e2d14, 0xd3b2f515, 0x5a479c17, 0xddeb4416, 0xe090153b, 0x673ccd3a, 0xeec9a438, 0x69657c39, 0xfc22773c, 0x7b8eaf3d, 0xf27bc63f, 0x75d71e3e, 0xd8f4d035, 0x5f580834, 0xd6ad6136, 0x5101b937, 0xc446b232, 0x43ea6a33, 0xca1f0331, 0x4db3db30, 0x90589f26, 0x17f44727, 0x9e012e25, 0x19adf624, 0x8ceafd21, 0x0b462520, 0x82b34c22, 0x051f9423, 0xa83c5a28, 0x2f908229, 0xa665eb2b, 0x21c9332a, 0xb48e382f, 0x3322e02e, 0xbad7892c, 0x3d7b512d, 0xc0212b76, 0x478df377, 0xce789a75, 0x49d44274, 0xdc934971, 0x5b3f9170, 0xd2caf872, 0x55662073, 0xf845ee78, 0x7fe93679, 0xf61c5f7b, 0x71b0877a, 0xe4f78c7f, 0x635b547e, 0xeaae3d7c, 0x6d02e57d, 0xb0e9a16b, 0x3745796a, 0xbeb01068, 0x391cc869, 0xac5bc36c, 0x2bf71b6d, 0xa202726f, 0x25aeaa6e, 0x888d6465, 0x0f21bc64, 0x86d4d566, 0x01780d67, 0x943f0662, 0x1393de63, 0x9a66b761, 0x1dca6f60, 0x20b13e4d, 0xa71de64c, 0x2ee88f4e, 0xa944574f, 0x3c035c4a, 0xbbaf844b, 0x325aed49, 0xb5f63548, 0x18d5fb43, 0x9f792342, 0x168c4a40, 0x91209241, 0x04679944, 0x83cb4145, 0x0a3e2847, 0x8d92f046, 0x5079b450, 0xd7d56c51, 0x5e200553, 0xd98cdd52, 0x4ccbd657, 0xcb670e56, 0x42926754, 0xc53ebf55, 0x681d715e, 0xefb1a95f, 0x6644c05d, 0xe1e8185c, 0x74af1359, 0xf303cb58, 0x7af6a25a, 0xfd5a7a5b, 0x804356ec, 0x07ef8eed, 0x8e1ae7ef, 0x09b63fee, 0x9cf134eb, 0x1b5decea, 0x92a885e8, 0x15045de9, 0xb82793e2, 0x3f8b4be3, 0xb67e22e1, 0x31d2fae0, 0xa495f1e5, 0x233929e4, 0xaacc40e6, 0x2d6098e7, 0xf08bdcf1, 0x772704f0, 0xfed26df2, 0x797eb5f3, 0xec39bef6, 0x6b9566f7, 0xe2600ff5, 0x65ccd7f4, 0xc8ef19ff, 0x4f43c1fe, 0xc6b6a8fc, 0x411a70fd, 0xd45d7bf8, 0x53f1a3f9, 0xda04cafb, 0x5da812fa, 0x60d343d7, 0xe77f9bd6, 0x6e8af2d4, 0xe9262ad5, 0x7c6121d0, 0xfbcdf9d1, 0x723890d3, 0xf59448d2, 0x58b786d9, 0xdf1b5ed8, 0x56ee37da, 0xd142efdb, 0x4405e4de, 0xc3a93cdf, 0x4a5c55dd, 0xcdf08ddc, 0x101bc9ca, 0x97b711cb, 0x1e4278c9, 0x99eea0c8, 0x0ca9abcd, 0x8b0573cc, 0x02f01ace, 0x855cc2cf, 0x287f0cc4, 0xafd3d4c5, 0x2626bdc7, 0xa18a65c6, 0x34cd6ec3, 0xb361b6c2, 0x3a94dfc0, 0xbd3807c1, 0x40627d9a, 0xc7cea59b, 0x4e3bcc99, 0xc9971498, 0x5cd01f9d, 0xdb7cc79c, 0x5289ae9e, 0xd525769f, 0x7806b894, 0xffaa6095, 0x765f0997, 0xf1f3d196, 0x64b4da93, 0xe3180292, 0x6aed6b90, 0xed41b391, 0x30aaf787, 0xb7062f86, 0x3ef34684, 0xb95f9e85, 0x2c189580, 0xabb44d81, 0x22412483, 0xa5edfc82, 0x08ce3289, 0x8f62ea88, 0x0697838a, 0x813b5b8b, 0x147c508e, 0x93d0888f, 0x1a25e18d, 0x9d89398c, 0xa0f268a1, 0x275eb0a0, 0xaeabd9a2, 0x290701a3, 0xbc400aa6, 0x3becd2a7, 0xb219bba5, 0x35b563a4, 0x9896adaf, 0x1f3a75ae, 0x96cf1cac, 0x1163c4ad, 0x8424cfa8, 0x038817a9, 0x8a7d7eab, 0x0dd1a6aa, 0xd03ae2bc, 0x57963abd, 0xde6353bf, 0x59cf8bbe, 0xcc8880bb, 0x4b2458ba, 0xc2d131b8, 0x457de9b9, 0xe85e27b2, 0x6ff2ffb3, 0xe60796b1, 0x61ab4eb0, 0xf4ec45b5, 0x73409db4, 0xfab5f4b6, 0x7d192cb7 }, { 0x00000000, 0xb79a6ddc, 0xd9281abc, 0x6eb27760, 0x054cf57c, 0xb2d698a0, 0xdc64efc0, 0x6bfe821c, 0x0a98eaf9, 0xbd028725, 0xd3b0f045, 0x642a9d99, 0x0fd41f85, 0xb84e7259, 0xd6fc0539, 0x616668e5, 0xa32d14f7, 0x14b7792b, 0x7a050e4b, 0xcd9f6397, 0xa661e18b, 0x11fb8c57, 0x7f49fb37, 0xc8d396eb, 0xa9b5fe0e, 0x1e2f93d2, 0x709de4b2, 0xc707896e, 0xacf90b72, 0x1b6366ae, 0x75d111ce, 0xc24b7c12, 0xf146e9ea, 0x46dc8436, 0x286ef356, 0x9ff49e8a, 0xf40a1c96, 0x4390714a, 0x2d22062a, 0x9ab86bf6, 0xfbde0313, 0x4c446ecf, 0x22f619af, 0x956c7473, 0xfe92f66f, 0x49089bb3, 0x27baecd3, 0x9020810f, 0x526bfd1d, 0xe5f190c1, 0x8b43e7a1, 0x3cd98a7d, 0x57270861, 0xe0bd65bd, 0x8e0f12dd, 0x39957f01, 0x58f317e4, 0xef697a38, 0x81db0d58, 0x36416084, 0x5dbfe298, 0xea258f44, 0x8497f824, 0x330d95f8, 0x559013d1, 0xe20a7e0d, 0x8cb8096d, 0x3b2264b1, 0x50dce6ad, 0xe7468b71, 0x89f4fc11, 0x3e6e91cd, 0x5f08f928, 0xe89294f4, 0x8620e394, 0x31ba8e48, 0x5a440c54, 0xedde6188, 0x836c16e8, 0x34f67b34, 0xf6bd0726, 0x41276afa, 0x2f951d9a, 0x980f7046, 0xf3f1f25a, 0x446b9f86, 0x2ad9e8e6, 0x9d43853a, 0xfc25eddf, 0x4bbf8003, 0x250df763, 0x92979abf, 0xf96918a3, 0x4ef3757f, 0x2041021f, 0x97db6fc3, 0xa4d6fa3b, 0x134c97e7, 0x7dfee087, 0xca648d5b, 0xa19a0f47, 0x1600629b, 0x78b215fb, 0xcf287827, 0xae4e10c2, 0x19d47d1e, 0x77660a7e, 0xc0fc67a2, 0xab02e5be, 0x1c988862, 0x722aff02, 0xc5b092de, 0x07fbeecc, 0xb0618310, 0xded3f470, 0x694999ac, 0x02b71bb0, 0xb52d766c, 0xdb9f010c, 0x6c056cd0, 0x0d630435, 0xbaf969e9, 0xd44b1e89, 0x63d17355, 0x082ff149, 0xbfb59c95, 0xd107ebf5, 0x669d8629, 0x1d3de6a6, 0xaaa78b7a, 0xc415fc1a, 0x738f91c6, 0x187113da, 0xafeb7e06, 0xc1590966, 0x76c364ba, 0x17a50c5f, 0xa03f6183, 0xce8d16e3, 0x79177b3f, 0x12e9f923, 0xa57394ff, 0xcbc1e39f, 0x7c5b8e43, 0xbe10f251, 0x098a9f8d, 0x6738e8ed, 0xd0a28531, 0xbb5c072d, 0x0cc66af1, 0x62741d91, 0xd5ee704d, 0xb48818a8, 0x03127574, 0x6da00214, 0xda3a6fc8, 0xb1c4edd4, 0x065e8008, 0x68ecf768, 0xdf769ab4, 0xec7b0f4c, 0x5be16290, 0x355315f0, 0x82c9782c, 0xe937fa30, 0x5ead97ec, 0x301fe08c, 0x87858d50, 0xe6e3e5b5, 0x51798869, 0x3fcbff09, 0x885192d5, 0xe3af10c9, 0x54357d15, 0x3a870a75, 0x8d1d67a9, 0x4f561bbb, 0xf8cc7667, 0x967e0107, 0x21e46cdb, 0x4a1aeec7, 0xfd80831b, 0x9332f47b, 0x24a899a7, 0x45cef142, 0xf2549c9e, 0x9ce6ebfe, 0x2b7c8622, 0x4082043e, 0xf71869e2, 0x99aa1e82, 0x2e30735e, 0x48adf577, 0xff3798ab, 0x9185efcb, 0x261f8217, 0x4de1000b, 0xfa7b6dd7, 0x94c91ab7, 0x2353776b, 0x42351f8e, 0xf5af7252, 0x9b1d0532, 0x2c8768ee, 0x4779eaf2, 0xf0e3872e, 0x9e51f04e, 0x29cb9d92, 0xeb80e180, 0x5c1a8c5c, 0x32a8fb3c, 0x853296e0, 0xeecc14fc, 0x59567920, 0x37e40e40, 0x807e639c, 0xe1180b79, 0x568266a5, 0x383011c5, 0x8faa7c19, 0xe454fe05, 0x53ce93d9, 0x3d7ce4b9, 0x8ae68965, 0xb9eb1c9d, 0x0e717141, 0x60c30621, 0xd7596bfd, 0xbca7e9e1, 0x0b3d843d, 0x658ff35d, 0xd2159e81, 0xb373f664, 0x04e99bb8, 0x6a5becd8, 0xddc18104, 0xb63f0318, 0x01a56ec4, 0x6f1719a4, 0xd88d7478, 0x1ac6086a, 0xad5c65b6, 0xc3ee12d6, 0x74747f0a, 0x1f8afd16, 0xa81090ca, 0xc6a2e7aa, 0x71388a76, 0x105ee293, 0xa7c48f4f, 0xc976f82f, 0x7eec95f3, 0x151217ef, 0xa2887a33, 0xcc3a0d53, 0x7ba0608f }, { 0x00000000, 0x8d670d49, 0x1acf1a92, 0x97a817db, 0x8383f420, 0x0ee4f969, 0x994ceeb2, 0x142be3fb, 0x0607e941, 0x8b60e408, 0x1cc8f3d3, 0x91affe9a, 0x85841d61, 0x08e31028, 0x9f4b07f3, 0x122c0aba, 0x0c0ed283, 0x8169dfca, 0x16c1c811, 0x9ba6c558, 0x8f8d26a3, 0x02ea2bea, 0x95423c31, 0x18253178, 0x0a093bc2, 0x876e368b, 0x10c62150, 0x9da12c19, 0x898acfe2, 0x04edc2ab, 0x9345d570, 0x1e22d839, 0xaf016503, 0x2266684a, 0xb5ce7f91, 0x38a972d8, 0x2c829123, 0xa1e59c6a, 0x364d8bb1, 0xbb2a86f8, 0xa9068c42, 0x2461810b, 0xb3c996d0, 0x3eae9b99, 0x2a857862, 0xa7e2752b, 0x304a62f0, 0xbd2d6fb9, 0xa30fb780, 0x2e68bac9, 0xb9c0ad12, 0x34a7a05b, 0x208c43a0, 0xadeb4ee9, 0x3a435932, 0xb724547b, 0xa5085ec1, 0x286f5388, 0xbfc74453, 0x32a0491a, 0x268baae1, 0xabeca7a8, 0x3c44b073, 0xb123bd3a, 0x5e03ca06, 0xd364c74f, 0x44ccd094, 0xc9abdddd, 0xdd803e26, 0x50e7336f, 0xc74f24b4, 0x4a2829fd, 0x58042347, 0xd5632e0e, 0x42cb39d5, 0xcfac349c, 0xdb87d767, 0x56e0da2e, 0xc148cdf5, 0x4c2fc0bc, 0x520d1885, 0xdf6a15cc, 0x48c20217, 0xc5a50f5e, 0xd18eeca5, 0x5ce9e1ec, 0xcb41f637, 0x4626fb7e, 0x540af1c4, 0xd96dfc8d, 0x4ec5eb56, 0xc3a2e61f, 0xd78905e4, 0x5aee08ad, 0xcd461f76, 0x4021123f, 0xf102af05, 0x7c65a24c, 0xebcdb597, 0x66aab8de, 0x72815b25, 0xffe6566c, 0x684e41b7, 0xe5294cfe, 0xf7054644, 0x7a624b0d, 0xedca5cd6, 0x60ad519f, 0x7486b264, 0xf9e1bf2d, 0x6e49a8f6, 0xe32ea5bf, 0xfd0c7d86, 0x706b70cf, 0xe7c36714, 0x6aa46a5d, 0x7e8f89a6, 0xf3e884ef, 0x64409334, 0xe9279e7d, 0xfb0b94c7, 0x766c998e, 0xe1c48e55, 0x6ca3831c, 0x788860e7, 0xf5ef6dae, 0x62477a75, 0xef20773c, 0xbc06940d, 0x31619944, 0xa6c98e9f, 0x2bae83d6, 0x3f85602d, 0xb2e26d64, 0x254a7abf, 0xa82d77f6, 0xba017d4c, 0x37667005, 0xa0ce67de, 0x2da96a97, 0x3982896c, 0xb4e58425, 0x234d93fe, 0xae2a9eb7, 0xb008468e, 0x3d6f4bc7, 0xaac75c1c, 0x27a05155, 0x338bb2ae, 0xbeecbfe7, 0x2944a83c, 0xa423a575, 0xb60fafcf, 0x3b68a286, 0xacc0b55d, 0x21a7b814, 0x358c5bef, 0xb8eb56a6, 0x2f43417d, 0xa2244c34, 0x1307f10e, 0x9e60fc47, 0x09c8eb9c, 0x84afe6d5, 0x9084052e, 0x1de30867, 0x8a4b1fbc, 0x072c12f5, 0x1500184f, 0x98671506, 0x0fcf02dd, 0x82a80f94, 0x9683ec6f, 0x1be4e126, 0x8c4cf6fd, 0x012bfbb4, 0x1f09238d, 0x926e2ec4, 0x05c6391f, 0x88a13456, 0x9c8ad7ad, 0x11eddae4, 0x8645cd3f, 0x0b22c076, 0x190ecacc, 0x9469c785, 0x03c1d05e, 0x8ea6dd17, 0x9a8d3eec, 0x17ea33a5, 0x8042247e, 0x0d252937, 0xe2055e0b, 0x6f625342, 0xf8ca4499, 0x75ad49d0, 0x6186aa2b, 0xece1a762, 0x7b49b0b9, 0xf62ebdf0, 0xe402b74a, 0x6965ba03, 0xfecdadd8, 0x73aaa091, 0x6781436a, 0xeae64e23, 0x7d4e59f8, 0xf02954b1, 0xee0b8c88, 0x636c81c1, 0xf4c4961a, 0x79a39b53, 0x6d8878a8, 0xe0ef75e1, 0x7747623a, 0xfa206f73, 0xe80c65c9, 0x656b6880, 0xf2c37f5b, 0x7fa47212, 0x6b8f91e9, 0xe6e89ca0, 0x71408b7b, 0xfc278632, 0x4d043b08, 0xc0633641, 0x57cb219a, 0xdaac2cd3, 0xce87cf28, 0x43e0c261, 0xd448d5ba, 0x592fd8f3, 0x4b03d249, 0xc664df00, 0x51ccc8db, 0xdcabc592, 0xc8802669, 0x45e72b20, 0xd24f3cfb, 0x5f2831b2, 0x410ae98b, 0xcc6de4c2, 0x5bc5f319, 0xd6a2fe50, 0xc2891dab, 0x4fee10e2, 0xd8460739, 0x55210a70, 0x470d00ca, 0xca6a0d83, 0x5dc21a58, 0xd0a51711, 0xc48ef4ea, 0x49e9f9a3, 0xde41ee78, 0x5326e331 }, { 0x00000000, 0x780d281b, 0xf01a5036, 0x8817782d, 0xe035a06c, 0x98388877, 0x102ff05a, 0x6822d841, 0xc06b40d9, 0xb86668c2, 0x307110ef, 0x487c38f4, 0x205ee0b5, 0x5853c8ae, 0xd044b083, 0xa8499898, 0x37ca41b6, 0x4fc769ad, 0xc7d01180, 0xbfdd399b, 0xd7ffe1da, 0xaff2c9c1, 0x27e5b1ec, 0x5fe899f7, 0xf7a1016f, 0x8fac2974, 0x07bb5159, 0x7fb67942, 0x1794a103, 0x6f998918, 0xe78ef135, 0x9f83d92e, 0xd9894268, 0xa1846a73, 0x2993125e, 0x519e3a45, 0x39bce204, 0x41b1ca1f, 0xc9a6b232, 0xb1ab9a29, 0x19e202b1, 0x61ef2aaa, 0xe9f85287, 0x91f57a9c, 0xf9d7a2dd, 0x81da8ac6, 0x09cdf2eb, 0x71c0daf0, 0xee4303de, 0x964e2bc5, 0x1e5953e8, 0x66547bf3, 0x0e76a3b2, 0x767b8ba9, 0xfe6cf384, 0x8661db9f, 0x2e284307, 0x56256b1c, 0xde321331, 0xa63f3b2a, 0xce1de36b, 0xb610cb70, 0x3e07b35d, 0x460a9b46, 0xb21385d0, 0xca1eadcb, 0x4209d5e6, 0x3a04fdfd, 0x522625bc, 0x2a2b0da7, 0xa23c758a, 0xda315d91, 0x7278c509, 0x0a75ed12, 0x8262953f, 0xfa6fbd24, 0x924d6565, 0xea404d7e, 0x62573553, 0x1a5a1d48, 0x85d9c466, 0xfdd4ec7d, 0x75c39450, 0x0dcebc4b, 0x65ec640a, 0x1de14c11, 0x95f6343c, 0xedfb1c27, 0x45b284bf, 0x3dbfaca4, 0xb5a8d489, 0xcda5fc92, 0xa58724d3, 0xdd8a0cc8, 0x559d74e5, 0x2d905cfe, 0x6b9ac7b8, 0x1397efa3, 0x9b80978e, 0xe38dbf95, 0x8baf67d4, 0xf3a24fcf, 0x7bb537e2, 0x03b81ff9, 0xabf18761, 0xd3fcaf7a, 0x5bebd757, 0x23e6ff4c, 0x4bc4270d, 0x33c90f16, 0xbbde773b, 0xc3d35f20, 0x5c50860e, 0x245dae15, 0xac4ad638, 0xd447fe23, 0xbc652662, 0xc4680e79, 0x4c7f7654, 0x34725e4f, 0x9c3bc6d7, 0xe436eecc, 0x6c2196e1, 0x142cbefa, 0x7c0e66bb, 0x04034ea0, 0x8c14368d, 0xf4191e96, 0xd33acba5, 0xab37e3be, 0x23209b93, 0x5b2db388, 0x330f6bc9, 0x4b0243d2, 0xc3153bff, 0xbb1813e4, 0x13518b7c, 0x6b5ca367, 0xe34bdb4a, 0x9b46f351, 0xf3642b10, 0x8b69030b, 0x037e7b26, 0x7b73533d, 0xe4f08a13, 0x9cfda208, 0x14eada25, 0x6ce7f23e, 0x04c52a7f, 0x7cc80264, 0xf4df7a49, 0x8cd25252, 0x249bcaca, 0x5c96e2d1, 0xd4819afc, 0xac8cb2e7, 0xc4ae6aa6, 0xbca342bd, 0x34b43a90, 0x4cb9128b, 0x0ab389cd, 0x72bea1d6, 0xfaa9d9fb, 0x82a4f1e0, 0xea8629a1, 0x928b01ba, 0x1a9c7997, 0x6291518c, 0xcad8c914, 0xb2d5e10f, 0x3ac29922, 0x42cfb139, 0x2aed6978, 0x52e04163, 0xdaf7394e, 0xa2fa1155, 0x3d79c87b, 0x4574e060, 0xcd63984d, 0xb56eb056, 0xdd4c6817, 0xa541400c, 0x2d563821, 0x555b103a, 0xfd1288a2, 0x851fa0b9, 0x0d08d894, 0x7505f08f, 0x1d2728ce, 0x652a00d5, 0xed3d78f8, 0x953050e3, 0x61294e75, 0x1924666e, 0x91331e43, 0xe93e3658, 0x811cee19, 0xf911c602, 0x7106be2f, 0x090b9634, 0xa1420eac, 0xd94f26b7, 0x51585e9a, 0x29557681, 0x4177aec0, 0x397a86db, 0xb16dfef6, 0xc960d6ed, 0x56e30fc3, 0x2eee27d8, 0xa6f95ff5, 0xdef477ee, 0xb6d6afaf, 0xcedb87b4, 0x46ccff99, 0x3ec1d782, 0x96884f1a, 0xee856701, 0x66921f2c, 0x1e9f3737, 0x76bdef76, 0x0eb0c76d, 0x86a7bf40, 0xfeaa975b, 0xb8a00c1d, 0xc0ad2406, 0x48ba5c2b, 0x30b77430, 0x5895ac71, 0x2098846a, 0xa88ffc47, 0xd082d45c, 0x78cb4cc4, 0x00c664df, 0x88d11cf2, 0xf0dc34e9, 0x98feeca8, 0xe0f3c4b3, 0x68e4bc9e, 0x10e99485, 0x8f6a4dab, 0xf76765b0, 0x7f701d9d, 0x077d3586, 0x6f5fedc7, 0x1752c5dc, 0x9f45bdf1, 0xe74895ea, 0x4f010d72, 0x370c2569, 0xbf1b5d44, 0xc716755f, 0xaf34ad1e, 0xd7398505, 0x5f2efd28, 0x2723d533 }, { 0x00000000, 0x1168574f, 0x22d0ae9e, 0x33b8f9d1, 0xf3bd9c39, 0xe2d5cb76, 0xd16d32a7, 0xc00565e8, 0xe67b3973, 0xf7136e3c, 0xc4ab97ed, 0xd5c3c0a2, 0x15c6a54a, 0x04aef205, 0x37160bd4, 0x267e5c9b, 0xccf772e6, 0xdd9f25a9, 0xee27dc78, 0xff4f8b37, 0x3f4aeedf, 0x2e22b990, 0x1d9a4041, 0x0cf2170e, 0x2a8c4b95, 0x3be41cda, 0x085ce50b, 0x1934b244, 0xd931d7ac, 0xc85980e3, 0xfbe17932, 0xea892e7d, 0x2ff224c8, 0x3e9a7387, 0x0d228a56, 0x1c4add19, 0xdc4fb8f1, 0xcd27efbe, 0xfe9f166f, 0xeff74120, 0xc9891dbb, 0xd8e14af4, 0xeb59b325, 0xfa31e46a, 0x3a348182, 0x2b5cd6cd, 0x18e42f1c, 0x098c7853, 0xe305562e, 0xf26d0161, 0xc1d5f8b0, 0xd0bdafff, 0x10b8ca17, 0x01d09d58, 0x32686489, 0x230033c6, 0x057e6f5d, 0x14163812, 0x27aec1c3, 0x36c6968c, 0xf6c3f364, 0xe7aba42b, 0xd4135dfa, 0xc57b0ab5, 0xe9f98894, 0xf891dfdb, 0xcb29260a, 0xda417145, 0x1a4414ad, 0x0b2c43e2, 0x3894ba33, 0x29fced7c, 0x0f82b1e7, 0x1eeae6a8, 0x2d521f79, 0x3c3a4836, 0xfc3f2dde, 0xed577a91, 0xdeef8340, 0xcf87d40f, 0x250efa72, 0x3466ad3d, 0x07de54ec, 0x16b603a3, 0xd6b3664b, 0xc7db3104, 0xf463c8d5, 0xe50b9f9a, 0xc375c301, 0xd21d944e, 0xe1a56d9f, 0xf0cd3ad0, 0x30c85f38, 0x21a00877, 0x1218f1a6, 0x0370a6e9, 0xc60bac5c, 0xd763fb13, 0xe4db02c2, 0xf5b3558d, 0x35b63065, 0x24de672a, 0x17669efb, 0x060ec9b4, 0x2070952f, 0x3118c260, 0x02a03bb1, 0x13c86cfe, 0xd3cd0916, 0xc2a55e59, 0xf11da788, 0xe075f0c7, 0x0afcdeba, 0x1b9489f5, 0x282c7024, 0x3944276b, 0xf9414283, 0xe82915cc, 0xdb91ec1d, 0xcaf9bb52, 0xec87e7c9, 0xfdefb086, 0xce574957, 0xdf3f1e18, 0x1f3a7bf0, 0x0e522cbf, 0x3dead56e, 0x2c828221, 0x65eed02d, 0x74868762, 0x473e7eb3, 0x565629fc, 0x96534c14, 0x873b1b5b, 0xb483e28a, 0xa5ebb5c5, 0x8395e95e, 0x92fdbe11, 0xa14547c0, 0xb02d108f, 0x70287567, 0x61402228, 0x52f8dbf9, 0x43908cb6, 0xa919a2cb, 0xb871f584, 0x8bc90c55, 0x9aa15b1a, 0x5aa43ef2, 0x4bcc69bd, 0x7874906c, 0x691cc723, 0x4f629bb8, 0x5e0accf7, 0x6db23526, 0x7cda6269, 0xbcdf0781, 0xadb750ce, 0x9e0fa91f, 0x8f67fe50, 0x4a1cf4e5, 0x5b74a3aa, 0x68cc5a7b, 0x79a40d34, 0xb9a168dc, 0xa8c93f93, 0x9b71c642, 0x8a19910d, 0xac67cd96, 0xbd0f9ad9, 0x8eb76308, 0x9fdf3447, 0x5fda51af, 0x4eb206e0, 0x7d0aff31, 0x6c62a87e, 0x86eb8603, 0x9783d14c, 0xa43b289d, 0xb5537fd2, 0x75561a3a, 0x643e4d75, 0x5786b4a4, 0x46eee3eb, 0x6090bf70, 0x71f8e83f, 0x424011ee, 0x532846a1, 0x932d2349, 0x82457406, 0xb1fd8dd7, 0xa095da98, 0x8c1758b9, 0x9d7f0ff6, 0xaec7f627, 0xbfafa168, 0x7faac480, 0x6ec293cf, 0x5d7a6a1e, 0x4c123d51, 0x6a6c61ca, 0x7b043685, 0x48bccf54, 0x59d4981b, 0x99d1fdf3, 0x88b9aabc, 0xbb01536d, 0xaa690422, 0x40e02a5f, 0x51887d10, 0x623084c1, 0x7358d38e, 0xb35db666, 0xa235e129, 0x918d18f8, 0x80e54fb7, 0xa69b132c, 0xb7f34463, 0x844bbdb2, 0x9523eafd, 0x55268f15, 0x444ed85a, 0x77f6218b, 0x669e76c4, 0xa3e57c71, 0xb28d2b3e, 0x8135d2ef, 0x905d85a0, 0x5058e048, 0x4130b707, 0x72884ed6, 0x63e01999, 0x459e4502, 0x54f6124d, 0x674eeb9c, 0x7626bcd3, 0xb623d93b, 0xa74b8e74, 0x94f377a5, 0x859b20ea, 0x6f120e97, 0x7e7a59d8, 0x4dc2a009, 0x5caaf746, 0x9caf92ae, 0x8dc7c5e1, 0xbe7f3c30, 0xaf176b7f, 0x896937e4, 0x980160ab, 0xabb9997a, 0xbad1ce35, 0x7ad4abdd, 0x6bbcfc92, 0x58040543, 0x496c520c }, { 0x00000000, 0xcadca15b, 0x94b943b7, 0x5e65e2ec, 0x9f6e466a, 0x55b2e731, 0x0bd705dd, 0xc10ba486, 0x3edd8cd4, 0xf4012d8f, 0xaa64cf63, 0x60b86e38, 0xa1b3cabe, 0x6b6f6be5, 0x350a8909, 0xffd62852, 0xcba7d8ad, 0x017b79f6, 0x5f1e9b1a, 0x95c23a41, 0x54c99ec7, 0x9e153f9c, 0xc070dd70, 0x0aac7c2b, 0xf57a5479, 0x3fa6f522, 0x61c317ce, 0xab1fb695, 0x6a141213, 0xa0c8b348, 0xfead51a4, 0x3471f0ff, 0x2152705f, 0xeb8ed104, 0xb5eb33e8, 0x7f3792b3, 0xbe3c3635, 0x74e0976e, 0x2a857582, 0xe059d4d9, 0x1f8ffc8b, 0xd5535dd0, 0x8b36bf3c, 0x41ea1e67, 0x80e1bae1, 0x4a3d1bba, 0x1458f956, 0xde84580d, 0xeaf5a8f2, 0x202909a9, 0x7e4ceb45, 0xb4904a1e, 0x759bee98, 0xbf474fc3, 0xe122ad2f, 0x2bfe0c74, 0xd4282426, 0x1ef4857d, 0x40916791, 0x8a4dc6ca, 0x4b46624c, 0x819ac317, 0xdfff21fb, 0x152380a0, 0x42a4e0be, 0x887841e5, 0xd61da309, 0x1cc10252, 0xddcaa6d4, 0x1716078f, 0x4973e563, 0x83af4438, 0x7c796c6a, 0xb6a5cd31, 0xe8c02fdd, 0x221c8e86, 0xe3172a00, 0x29cb8b5b, 0x77ae69b7, 0xbd72c8ec, 0x89033813, 0x43df9948, 0x1dba7ba4, 0xd766daff, 0x166d7e79, 0xdcb1df22, 0x82d43dce, 0x48089c95, 0xb7deb4c7, 0x7d02159c, 0x2367f770, 0xe9bb562b, 0x28b0f2ad, 0xe26c53f6, 0xbc09b11a, 0x76d51041, 0x63f690e1, 0xa92a31ba, 0xf74fd356, 0x3d93720d, 0xfc98d68b, 0x364477d0, 0x6821953c, 0xa2fd3467, 0x5d2b1c35, 0x97f7bd6e, 0xc9925f82, 0x034efed9, 0xc2455a5f, 0x0899fb04, 0x56fc19e8, 0x9c20b8b3, 0xa851484c, 0x628de917, 0x3ce80bfb, 0xf634aaa0, 0x373f0e26, 0xfde3af7d, 0xa3864d91, 0x695aecca, 0x968cc498, 0x5c5065c3, 0x0235872f, 0xc8e92674, 0x09e282f2, 0xc33e23a9, 0x9d5bc145, 0x5787601e, 0x33550079, 0xf989a122, 0xa7ec43ce, 0x6d30e295, 0xac3b4613, 0x66e7e748, 0x388205a4, 0xf25ea4ff, 0x0d888cad, 0xc7542df6, 0x9931cf1a, 0x53ed6e41, 0x92e6cac7, 0x583a6b9c, 0x065f8970, 0xcc83282b, 0xf8f2d8d4, 0x322e798f, 0x6c4b9b63, 0xa6973a38, 0x679c9ebe, 0xad403fe5, 0xf325dd09, 0x39f97c52, 0xc62f5400, 0x0cf3f55b, 0x529617b7, 0x984ab6ec, 0x5941126a, 0x939db331, 0xcdf851dd, 0x0724f086, 0x12077026, 0xd8dbd17d, 0x86be3391, 0x4c6292ca, 0x8d69364c, 0x47b59717, 0x19d075fb, 0xd30cd4a0, 0x2cdafcf2, 0xe6065da9, 0xb863bf45, 0x72bf1e1e, 0xb3b4ba98, 0x79681bc3, 0x270df92f, 0xedd15874, 0xd9a0a88b, 0x137c09d0, 0x4d19eb3c, 0x87c54a67, 0x46ceeee1, 0x8c124fba, 0xd277ad56, 0x18ab0c0d, 0xe77d245f, 0x2da18504, 0x73c467e8, 0xb918c6b3, 0x78136235, 0xb2cfc36e, 0xecaa2182, 0x267680d9, 0x71f1e0c7, 0xbb2d419c, 0xe548a370, 0x2f94022b, 0xee9fa6ad, 0x244307f6, 0x7a26e51a, 0xb0fa4441, 0x4f2c6c13, 0x85f0cd48, 0xdb952fa4, 0x11498eff, 0xd0422a79, 0x1a9e8b22, 0x44fb69ce, 0x8e27c895, 0xba56386a, 0x708a9931, 0x2eef7bdd, 0xe433da86, 0x25387e00, 0xefe4df5b, 0xb1813db7, 0x7b5d9cec, 0x848bb4be, 0x4e5715e5, 0x1032f709, 0xdaee5652, 0x1be5f2d4, 0xd139538f, 0x8f5cb163, 0x45801038, 0x50a39098, 0x9a7f31c3, 0xc41ad32f, 0x0ec67274, 0xcfcdd6f2, 0x051177a9, 0x5b749545, 0x91a8341e, 0x6e7e1c4c, 0xa4a2bd17, 0xfac75ffb, 0x301bfea0, 0xf1105a26, 0x3bccfb7d, 0x65a91991, 0xaf75b8ca, 0x9b044835, 0x51d8e96e, 0x0fbd0b82, 0xc561aad9, 0x046a0e5f, 0xceb6af04, 0x90d34de8, 0x5a0fecb3, 0xa5d9c4e1, 0x6f0565ba, 0x31608756, 0xfbbc260d, 0x3ab7828b, 0xf06b23d0, 0xae0ec13c, 0x64d26067 } }; uint32 FCrc::CRCTablesSB8[8][256] = { { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }, { 0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, 0x7d77f445, 0x565aa786, 0x4f4196c7, 0xc8d98a08, 0xd1c2bb49, 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, 0x87981ccf, 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, 0x821b9859, 0x9b00a918, 0xb02dfadb, 0xa936cb9a, 0xe6775d5d, 0xff6c6c1c, 0xd4413fdf, 0xcd5a0e9e, 0x958424a2, 0x8c9f15e3, 0xa7b24620, 0xbea97761, 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, 0x39316bae, 0x202a5aef, 0x0b07092c, 0x121c386d, 0xdf4636f3, 0xc65d07b2, 0xed705471, 0xf46b6530, 0xbb2af3f7, 0xa231c2b6, 0x891c9175, 0x9007a034, 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, 0xf0794f05, 0xe9627e44, 0xc24f2d87, 0xdb541cc6, 0x94158a01, 0x8d0ebb40, 0xa623e883, 0xbf38d9c2, 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, 0x138d96ce, 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca, 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97, 0xded79850, 0xc7cca911, 0xece1fad2, 0xf5facb93, 0x7262d75c, 0x6b79e61d, 0x4054b5de, 0x594f849f, 0x160e1258, 0x0f152319, 0x243870da, 0x3d23419b, 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864, 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60, 0xad24e1af, 0xb43fd0ee, 0x9f12832d, 0x8609b26c, 0xc94824ab, 0xd05315ea, 0xfb7e4629, 0xe2657768, 0x2f3f79f6, 0x362448b7, 0x1d091b74, 0x04122a35, 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31, 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d, 0x838a36fa, 0x9a9107bb, 0xb1bc5478, 0xa8a76539, 0x3b83984b, 0x2298a90a, 0x09b5fac9, 0x10aecb88, 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, 0x74c20e8c, 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180, 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484, 0x71418a1a, 0x685abb5b, 0x4377e898, 0x5a6cd9d9, 0x152d4f1e, 0x0c367e5f, 0x271b2d9c, 0x3e001cdd, 0xb9980012, 0xa0833153, 0x8bae6290, 0x92b553d1, 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5, 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a, 0xca6b79ed, 0xd37048ac, 0xf85d1b6f, 0xe1462a2e, 0x66de36e1, 0x7fc507a0, 0x54e85463, 0x4df36522, 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, 0x299fa026, 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b, 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f, 0x2c1c24b0, 0x350715f1, 0x1e2a4632, 0x07317773, 0x4870e1b4, 0x516bd0f5, 0x7a468336, 0x635db277, 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, 0xe0d7848d, 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, 0x674f9842, 0x7e54a903, 0x5579fac0, 0x4c62cb81, 0x8138c51f, 0x9823f45e, 0xb30ea79d, 0xaa1596dc, 0xe554001b, 0xfc4f315a, 0xd7626299, 0xce7953d8, 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0, 0x5e7ef3ec, 0x4765c2ad, 0x6c48916e, 0x7553a02f, 0x3a1236e8, 0x230907a9, 0x0824546a, 0x113f652b, 0x96a779e4, 0x8fbc48a5, 0xa4911b66, 0xbd8a2a27, 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23, 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, 0x70d024b9, 0x69cb15f8, 0x42e6463b, 0x5bfd777a, 0xdc656bb5, 0xc57e5af4, 0xee530937, 0xf7483876, 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, 0x9324fd72 }, { 0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, 0x0709a8dc, 0x06cbc2eb, 0x048d7cb2, 0x054f1685, 0x0e1351b8, 0x0fd13b8f, 0x0d9785d6, 0x0c55efe1, 0x091af964, 0x08d89353, 0x0a9e2d0a, 0x0b5c473d, 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, 0x1235f2c8, 0x13f798ff, 0x11b126a6, 0x10734c91, 0x153c5a14, 0x14fe3023, 0x16b88e7a, 0x177ae44d, 0x384d46e0, 0x398f2cd7, 0x3bc9928e, 0x3a0bf8b9, 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, 0x3157bf84, 0x3095d5b3, 0x32d36bea, 0x331101dd, 0x246be590, 0x25a98fa7, 0x27ef31fe, 0x262d5bc9, 0x23624d4c, 0x22a0277b, 0x20e69922, 0x2124f315, 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, 0x709a8dc0, 0x7158e7f7, 0x731e59ae, 0x72dc3399, 0x7793251c, 0x76514f2b, 0x7417f172, 0x75d59b45, 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, 0x7ccf6221, 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd, 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9, 0x6bb5866c, 0x6a77ec5b, 0x68315202, 0x69f33835, 0x62af7f08, 0x636d153f, 0x612bab66, 0x60e9c151, 0x65a6d7d4, 0x6464bde3, 0x662203ba, 0x67e0698d, 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579, 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5, 0x46c49a98, 0x4706f0af, 0x45404ef6, 0x448224c1, 0x41cd3244, 0x400f5873, 0x4249e62a, 0x438b8c1d, 0x54f16850, 0x55330267, 0x5775bc3e, 0x56b7d609, 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5, 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1, 0x5deb9134, 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d, 0xe1351b80, 0xe0f771b7, 0xe2b1cfee, 0xe373a5d9, 0xe63cb35c, 0xe7fed96b, 0xe5b86732, 0xe47a0d05, 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461, 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd, 0xfd13b8f0, 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9, 0xfa1a102c, 0xfbd87a1b, 0xf99ec442, 0xf85cae75, 0xf300e948, 0xf2c2837f, 0xf0843d26, 0xf1465711, 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd, 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339, 0xde71f5bc, 0xdfb39f8b, 0xddf521d2, 0xdc374be5, 0xd76b0cd8, 0xd6a966ef, 0xd4efd8b6, 0xd52db281, 0xd062a404, 0xd1a0ce33, 0xd3e6706a, 0xd2241a5d, 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049, 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895, 0xcb4dafa8, 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1, 0xcc440774, 0xcd866d43, 0xcfc0d31a, 0xce02b92d, 0x91af9640, 0x906dfc77, 0x922b422e, 0x93e92819, 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, 0x98b56f24, 0x99770513, 0x9b31bb4a, 0x9af3d17d, 0x8d893530, 0x8c4b5f07, 0x8e0de15e, 0x8fcf8b69, 0x8a809dec, 0x8b42f7db, 0x89044982, 0x88c623b5, 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, 0xa9e2d0a0, 0xa820ba97, 0xaa6604ce, 0xaba46ef9, 0xaeeb787c, 0xaf29124b, 0xad6fac12, 0xacadc625, 0xa7f18118, 0xa633eb2f, 0xa4755576, 0xa5b73f41, 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, 0xb2cddb0c, 0xb30fb13b, 0xb1490f62, 0xb08b6555, 0xbbd72268, 0xba15485f, 0xb853f606, 0xb9919c31, 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, 0xbe9834ed }, { 0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, 0x8f629757, 0x37def032, 0x256b5fdc, 0x9dd738b9, 0xc5b428ef, 0x7d084f8a, 0x6fbde064, 0xd7018701, 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, 0x58631056, 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, 0x95ad7f70, 0x2d111815, 0x3fa4b7fb, 0x8718d09e, 0x1acfe827, 0xa2738f42, 0xb0c620ac, 0x087a47c9, 0xa032af3e, 0x188ec85b, 0x0a3b67b5, 0xb28700d0, 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, 0xeae41086, 0x525877e3, 0x40edd80d, 0xf851bf68, 0xf02bf8a1, 0x48979fc4, 0x5a22302a, 0xe29e574f, 0x7f496ff6, 0xc7f50893, 0xd540a77d, 0x6dfcc018, 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7, 0x9b14583d, 0x23a83f58, 0x311d90b6, 0x89a1f7d3, 0x1476cf6a, 0xaccaa80f, 0xbe7f07e1, 0x06c36084, 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, 0x4c15df3c, 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b, 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c, 0x446f98f5, 0xfcd3ff90, 0xee66507e, 0x56da371b, 0x0eb9274d, 0xb6054028, 0xa4b0efc6, 0x1c0c88a3, 0x81dbb01a, 0x3967d77f, 0x2bd27891, 0x936e1ff4, 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed, 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba, 0xfe92dfec, 0x462eb889, 0x549b1767, 0xec277002, 0x71f048bb, 0xc94c2fde, 0xdbf98030, 0x6345e755, 0x6b3fa09c, 0xd383c7f9, 0xc1366817, 0x798a0f72, 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825, 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d, 0x21e91f24, 0x99557841, 0x8be0d7af, 0x335cb0ca, 0xed59b63b, 0x55e5d15e, 0x47507eb0, 0xffec19d5, 0x623b216c, 0xda874609, 0xc832e9e7, 0x708e8e82, 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a, 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d, 0xbd40e1a4, 0x05fc86c1, 0x1749292f, 0xaff54e4a, 0x322276f3, 0x8a9e1196, 0x982bbe78, 0x2097d91d, 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, 0x6a4166a5, 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2, 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb, 0xc2098e52, 0x7ab5e937, 0x680046d9, 0xd0bc21bc, 0x88df31ea, 0x3063568f, 0x22d6f961, 0x9a6a9e04, 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, 0x15080953, 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174, 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623, 0xd8c66675, 0x607a0110, 0x72cfaefe, 0xca73c99b, 0x57a4f122, 0xef189647, 0xfdad39a9, 0x45115ecc, 0x764dee06, 0xcef18963, 0xdc44268d, 0x64f841e8, 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, 0x3c9b51be, 0x842736db, 0x96929935, 0x2e2efe50, 0x2654b999, 0x9ee8defc, 0x8c5d7112, 0x34e11677, 0xa9362ece, 0x118a49ab, 0x033fe645, 0xbb838120, 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, 0xd67f4138, 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, 0x591dd66f, 0xe1a1b10a, 0xf3141ee4, 0x4ba87981, 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, 0x017ec639, 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e, 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, 0x090481f0, 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, 0x43d23e48, 0xfb6e592d, 0xe9dbf6c3, 0x516791a6, 0xccb0a91f, 0x740cce7a, 0x66b96194, 0xde0506f1 }, { 0x00000000, 0x3d6029b0, 0x7ac05360, 0x47a07ad0, 0xf580a6c0, 0xc8e08f70, 0x8f40f5a0, 0xb220dc10, 0x30704bc1, 0x0d106271, 0x4ab018a1, 0x77d03111, 0xc5f0ed01, 0xf890c4b1, 0xbf30be61, 0x825097d1, 0x60e09782, 0x5d80be32, 0x1a20c4e2, 0x2740ed52, 0x95603142, 0xa80018f2, 0xefa06222, 0xd2c04b92, 0x5090dc43, 0x6df0f5f3, 0x2a508f23, 0x1730a693, 0xa5107a83, 0x98705333, 0xdfd029e3, 0xe2b00053, 0xc1c12f04, 0xfca106b4, 0xbb017c64, 0x866155d4, 0x344189c4, 0x0921a074, 0x4e81daa4, 0x73e1f314, 0xf1b164c5, 0xccd14d75, 0x8b7137a5, 0xb6111e15, 0x0431c205, 0x3951ebb5, 0x7ef19165, 0x4391b8d5, 0xa121b886, 0x9c419136, 0xdbe1ebe6, 0xe681c256, 0x54a11e46, 0x69c137f6, 0x2e614d26, 0x13016496, 0x9151f347, 0xac31daf7, 0xeb91a027, 0xd6f18997, 0x64d15587, 0x59b17c37, 0x1e1106e7, 0x23712f57, 0x58f35849, 0x659371f9, 0x22330b29, 0x1f532299, 0xad73fe89, 0x9013d739, 0xd7b3ade9, 0xead38459, 0x68831388, 0x55e33a38, 0x124340e8, 0x2f236958, 0x9d03b548, 0xa0639cf8, 0xe7c3e628, 0xdaa3cf98, 0x3813cfcb, 0x0573e67b, 0x42d39cab, 0x7fb3b51b, 0xcd93690b, 0xf0f340bb, 0xb7533a6b, 0x8a3313db, 0x0863840a, 0x3503adba, 0x72a3d76a, 0x4fc3feda, 0xfde322ca, 0xc0830b7a, 0x872371aa, 0xba43581a, 0x9932774d, 0xa4525efd, 0xe3f2242d, 0xde920d9d, 0x6cb2d18d, 0x51d2f83d, 0x167282ed, 0x2b12ab5d, 0xa9423c8c, 0x9422153c, 0xd3826fec, 0xeee2465c, 0x5cc29a4c, 0x61a2b3fc, 0x2602c92c, 0x1b62e09c, 0xf9d2e0cf, 0xc4b2c97f, 0x8312b3af, 0xbe729a1f, 0x0c52460f, 0x31326fbf, 0x7692156f, 0x4bf23cdf, 0xc9a2ab0e, 0xf4c282be, 0xb362f86e, 0x8e02d1de, 0x3c220dce, 0x0142247e, 0x46e25eae, 0x7b82771e, 0xb1e6b092, 0x8c869922, 0xcb26e3f2, 0xf646ca42, 0x44661652, 0x79063fe2, 0x3ea64532, 0x03c66c82, 0x8196fb53, 0xbcf6d2e3, 0xfb56a833, 0xc6368183, 0x74165d93, 0x49767423, 0x0ed60ef3, 0x33b62743, 0xd1062710, 0xec660ea0, 0xabc67470, 0x96a65dc0, 0x248681d0, 0x19e6a860, 0x5e46d2b0, 0x6326fb00, 0xe1766cd1, 0xdc164561, 0x9bb63fb1, 0xa6d61601, 0x14f6ca11, 0x2996e3a1, 0x6e369971, 0x5356b0c1, 0x70279f96, 0x4d47b626, 0x0ae7ccf6, 0x3787e546, 0x85a73956, 0xb8c710e6, 0xff676a36, 0xc2074386, 0x4057d457, 0x7d37fde7, 0x3a978737, 0x07f7ae87, 0xb5d77297, 0x88b75b27, 0xcf1721f7, 0xf2770847, 0x10c70814, 0x2da721a4, 0x6a075b74, 0x576772c4, 0xe547aed4, 0xd8278764, 0x9f87fdb4, 0xa2e7d404, 0x20b743d5, 0x1dd76a65, 0x5a7710b5, 0x67173905, 0xd537e515, 0xe857cca5, 0xaff7b675, 0x92979fc5, 0xe915e8db, 0xd475c16b, 0x93d5bbbb, 0xaeb5920b, 0x1c954e1b, 0x21f567ab, 0x66551d7b, 0x5b3534cb, 0xd965a31a, 0xe4058aaa, 0xa3a5f07a, 0x9ec5d9ca, 0x2ce505da, 0x11852c6a, 0x562556ba, 0x6b457f0a, 0x89f57f59, 0xb49556e9, 0xf3352c39, 0xce550589, 0x7c75d999, 0x4115f029, 0x06b58af9, 0x3bd5a349, 0xb9853498, 0x84e51d28, 0xc34567f8, 0xfe254e48, 0x4c059258, 0x7165bbe8, 0x36c5c138, 0x0ba5e888, 0x28d4c7df, 0x15b4ee6f, 0x521494bf, 0x6f74bd0f, 0xdd54611f, 0xe03448af, 0xa794327f, 0x9af41bcf, 0x18a48c1e, 0x25c4a5ae, 0x6264df7e, 0x5f04f6ce, 0xed242ade, 0xd044036e, 0x97e479be, 0xaa84500e, 0x4834505d, 0x755479ed, 0x32f4033d, 0x0f942a8d, 0xbdb4f69d, 0x80d4df2d, 0xc774a5fd, 0xfa148c4d, 0x78441b9c, 0x4524322c, 0x028448fc, 0x3fe4614c, 0x8dc4bd5c, 0xb0a494ec, 0xf704ee3c, 0xca64c78c }, { 0x00000000, 0xcb5cd3a5, 0x4dc8a10b, 0x869472ae, 0x9b914216, 0x50cd91b3, 0xd659e31d, 0x1d0530b8, 0xec53826d, 0x270f51c8, 0xa19b2366, 0x6ac7f0c3, 0x77c2c07b, 0xbc9e13de, 0x3a0a6170, 0xf156b2d5, 0x03d6029b, 0xc88ad13e, 0x4e1ea390, 0x85427035, 0x9847408d, 0x531b9328, 0xd58fe186, 0x1ed33223, 0xef8580f6, 0x24d95353, 0xa24d21fd, 0x6911f258, 0x7414c2e0, 0xbf481145, 0x39dc63eb, 0xf280b04e, 0x07ac0536, 0xccf0d693, 0x4a64a43d, 0x81387798, 0x9c3d4720, 0x57619485, 0xd1f5e62b, 0x1aa9358e, 0xebff875b, 0x20a354fe, 0xa6372650, 0x6d6bf5f5, 0x706ec54d, 0xbb3216e8, 0x3da66446, 0xf6fab7e3, 0x047a07ad, 0xcf26d408, 0x49b2a6a6, 0x82ee7503, 0x9feb45bb, 0x54b7961e, 0xd223e4b0, 0x197f3715, 0xe82985c0, 0x23755665, 0xa5e124cb, 0x6ebdf76e, 0x73b8c7d6, 0xb8e41473, 0x3e7066dd, 0xf52cb578, 0x0f580a6c, 0xc404d9c9, 0x4290ab67, 0x89cc78c2, 0x94c9487a, 0x5f959bdf, 0xd901e971, 0x125d3ad4, 0xe30b8801, 0x28575ba4, 0xaec3290a, 0x659ffaaf, 0x789aca17, 0xb3c619b2, 0x35526b1c, 0xfe0eb8b9, 0x0c8e08f7, 0xc7d2db52, 0x4146a9fc, 0x8a1a7a59, 0x971f4ae1, 0x5c439944, 0xdad7ebea, 0x118b384f, 0xe0dd8a9a, 0x2b81593f, 0xad152b91, 0x6649f834, 0x7b4cc88c, 0xb0101b29, 0x36846987, 0xfdd8ba22, 0x08f40f5a, 0xc3a8dcff, 0x453cae51, 0x8e607df4, 0x93654d4c, 0x58399ee9, 0xdeadec47, 0x15f13fe2, 0xe4a78d37, 0x2ffb5e92, 0xa96f2c3c, 0x6233ff99, 0x7f36cf21, 0xb46a1c84, 0x32fe6e2a, 0xf9a2bd8f, 0x0b220dc1, 0xc07ede64, 0x46eaacca, 0x8db67f6f, 0x90b34fd7, 0x5bef9c72, 0xdd7beedc, 0x16273d79, 0xe7718fac, 0x2c2d5c09, 0xaab92ea7, 0x61e5fd02, 0x7ce0cdba, 0xb7bc1e1f, 0x31286cb1, 0xfa74bf14, 0x1eb014d8, 0xd5ecc77d, 0x5378b5d3, 0x98246676, 0x852156ce, 0x4e7d856b, 0xc8e9f7c5, 0x03b52460, 0xf2e396b5, 0x39bf4510, 0xbf2b37be, 0x7477e41b, 0x6972d4a3, 0xa22e0706, 0x24ba75a8, 0xefe6a60d, 0x1d661643, 0xd63ac5e6, 0x50aeb748, 0x9bf264ed, 0x86f75455, 0x4dab87f0, 0xcb3ff55e, 0x006326fb, 0xf135942e, 0x3a69478b, 0xbcfd3525, 0x77a1e680, 0x6aa4d638, 0xa1f8059d, 0x276c7733, 0xec30a496, 0x191c11ee, 0xd240c24b, 0x54d4b0e5, 0x9f886340, 0x828d53f8, 0x49d1805d, 0xcf45f2f3, 0x04192156, 0xf54f9383, 0x3e134026, 0xb8873288, 0x73dbe12d, 0x6eded195, 0xa5820230, 0x2316709e, 0xe84aa33b, 0x1aca1375, 0xd196c0d0, 0x5702b27e, 0x9c5e61db, 0x815b5163, 0x4a0782c6, 0xcc93f068, 0x07cf23cd, 0xf6999118, 0x3dc542bd, 0xbb513013, 0x700de3b6, 0x6d08d30e, 0xa65400ab, 0x20c07205, 0xeb9ca1a0, 0x11e81eb4, 0xdab4cd11, 0x5c20bfbf, 0x977c6c1a, 0x8a795ca2, 0x41258f07, 0xc7b1fda9, 0x0ced2e0c, 0xfdbb9cd9, 0x36e74f7c, 0xb0733dd2, 0x7b2fee77, 0x662adecf, 0xad760d6a, 0x2be27fc4, 0xe0beac61, 0x123e1c2f, 0xd962cf8a, 0x5ff6bd24, 0x94aa6e81, 0x89af5e39, 0x42f38d9c, 0xc467ff32, 0x0f3b2c97, 0xfe6d9e42, 0x35314de7, 0xb3a53f49, 0x78f9ecec, 0x65fcdc54, 0xaea00ff1, 0x28347d5f, 0xe368aefa, 0x16441b82, 0xdd18c827, 0x5b8cba89, 0x90d0692c, 0x8dd55994, 0x46898a31, 0xc01df89f, 0x0b412b3a, 0xfa1799ef, 0x314b4a4a, 0xb7df38e4, 0x7c83eb41, 0x6186dbf9, 0xaada085c, 0x2c4e7af2, 0xe712a957, 0x15921919, 0xdececabc, 0x585ab812, 0x93066bb7, 0x8e035b0f, 0x455f88aa, 0xc3cbfa04, 0x089729a1, 0xf9c19b74, 0x329d48d1, 0xb4093a7f, 0x7f55e9da, 0x6250d962, 0xa90c0ac7, 0x2f987869, 0xe4c4abcc }, { 0x00000000, 0xa6770bb4, 0x979f1129, 0x31e81a9d, 0xf44f2413, 0x52382fa7, 0x63d0353a, 0xc5a73e8e, 0x33ef4e67, 0x959845d3, 0xa4705f4e, 0x020754fa, 0xc7a06a74, 0x61d761c0, 0x503f7b5d, 0xf64870e9, 0x67de9cce, 0xc1a9977a, 0xf0418de7, 0x56368653, 0x9391b8dd, 0x35e6b369, 0x040ea9f4, 0xa279a240, 0x5431d2a9, 0xf246d91d, 0xc3aec380, 0x65d9c834, 0xa07ef6ba, 0x0609fd0e, 0x37e1e793, 0x9196ec27, 0xcfbd399c, 0x69ca3228, 0x582228b5, 0xfe552301, 0x3bf21d8f, 0x9d85163b, 0xac6d0ca6, 0x0a1a0712, 0xfc5277fb, 0x5a257c4f, 0x6bcd66d2, 0xcdba6d66, 0x081d53e8, 0xae6a585c, 0x9f8242c1, 0x39f54975, 0xa863a552, 0x0e14aee6, 0x3ffcb47b, 0x998bbfcf, 0x5c2c8141, 0xfa5b8af5, 0xcbb39068, 0x6dc49bdc, 0x9b8ceb35, 0x3dfbe081, 0x0c13fa1c, 0xaa64f1a8, 0x6fc3cf26, 0xc9b4c492, 0xf85cde0f, 0x5e2bd5bb, 0x440b7579, 0xe27c7ecd, 0xd3946450, 0x75e36fe4, 0xb044516a, 0x16335ade, 0x27db4043, 0x81ac4bf7, 0x77e43b1e, 0xd19330aa, 0xe07b2a37, 0x460c2183, 0x83ab1f0d, 0x25dc14b9, 0x14340e24, 0xb2430590, 0x23d5e9b7, 0x85a2e203, 0xb44af89e, 0x123df32a, 0xd79acda4, 0x71edc610, 0x4005dc8d, 0xe672d739, 0x103aa7d0, 0xb64dac64, 0x87a5b6f9, 0x21d2bd4d, 0xe47583c3, 0x42028877, 0x73ea92ea, 0xd59d995e, 0x8bb64ce5, 0x2dc14751, 0x1c295dcc, 0xba5e5678, 0x7ff968f6, 0xd98e6342, 0xe86679df, 0x4e11726b, 0xb8590282, 0x1e2e0936, 0x2fc613ab, 0x89b1181f, 0x4c162691, 0xea612d25, 0xdb8937b8, 0x7dfe3c0c, 0xec68d02b, 0x4a1fdb9f, 0x7bf7c102, 0xdd80cab6, 0x1827f438, 0xbe50ff8c, 0x8fb8e511, 0x29cfeea5, 0xdf879e4c, 0x79f095f8, 0x48188f65, 0xee6f84d1, 0x2bc8ba5f, 0x8dbfb1eb, 0xbc57ab76, 0x1a20a0c2, 0x8816eaf2, 0x2e61e146, 0x1f89fbdb, 0xb9fef06f, 0x7c59cee1, 0xda2ec555, 0xebc6dfc8, 0x4db1d47c, 0xbbf9a495, 0x1d8eaf21, 0x2c66b5bc, 0x8a11be08, 0x4fb68086, 0xe9c18b32, 0xd82991af, 0x7e5e9a1b, 0xefc8763c, 0x49bf7d88, 0x78576715, 0xde206ca1, 0x1b87522f, 0xbdf0599b, 0x8c184306, 0x2a6f48b2, 0xdc27385b, 0x7a5033ef, 0x4bb82972, 0xedcf22c6, 0x28681c48, 0x8e1f17fc, 0xbff70d61, 0x198006d5, 0x47abd36e, 0xe1dcd8da, 0xd034c247, 0x7643c9f3, 0xb3e4f77d, 0x1593fcc9, 0x247be654, 0x820cede0, 0x74449d09, 0xd23396bd, 0xe3db8c20, 0x45ac8794, 0x800bb91a, 0x267cb2ae, 0x1794a833, 0xb1e3a387, 0x20754fa0, 0x86024414, 0xb7ea5e89, 0x119d553d, 0xd43a6bb3, 0x724d6007, 0x43a57a9a, 0xe5d2712e, 0x139a01c7, 0xb5ed0a73, 0x840510ee, 0x22721b5a, 0xe7d525d4, 0x41a22e60, 0x704a34fd, 0xd63d3f49, 0xcc1d9f8b, 0x6a6a943f, 0x5b828ea2, 0xfdf58516, 0x3852bb98, 0x9e25b02c, 0xafcdaab1, 0x09baa105, 0xfff2d1ec, 0x5985da58, 0x686dc0c5, 0xce1acb71, 0x0bbdf5ff, 0xadcafe4b, 0x9c22e4d6, 0x3a55ef62, 0xabc30345, 0x0db408f1, 0x3c5c126c, 0x9a2b19d8, 0x5f8c2756, 0xf9fb2ce2, 0xc813367f, 0x6e643dcb, 0x982c4d22, 0x3e5b4696, 0x0fb35c0b, 0xa9c457bf, 0x6c636931, 0xca146285, 0xfbfc7818, 0x5d8b73ac, 0x03a0a617, 0xa5d7ada3, 0x943fb73e, 0x3248bc8a, 0xf7ef8204, 0x519889b0, 0x6070932d, 0xc6079899, 0x304fe870, 0x9638e3c4, 0xa7d0f959, 0x01a7f2ed, 0xc400cc63, 0x6277c7d7, 0x539fdd4a, 0xf5e8d6fe, 0x647e3ad9, 0xc209316d, 0xf3e12bf0, 0x55962044, 0x90311eca, 0x3646157e, 0x07ae0fe3, 0xa1d90457, 0x579174be, 0xf1e67f0a, 0xc00e6597, 0x66796e23, 0xa3de50ad, 0x05a95b19, 0x34414184, 0x92364a30 }, { 0x00000000, 0xccaa009e, 0x4225077d, 0x8e8f07e3, 0x844a0efa, 0x48e00e64, 0xc66f0987, 0x0ac50919, 0xd3e51bb5, 0x1f4f1b2b, 0x91c01cc8, 0x5d6a1c56, 0x57af154f, 0x9b0515d1, 0x158a1232, 0xd92012ac, 0x7cbb312b, 0xb01131b5, 0x3e9e3656, 0xf23436c8, 0xf8f13fd1, 0x345b3f4f, 0xbad438ac, 0x767e3832, 0xaf5e2a9e, 0x63f42a00, 0xed7b2de3, 0x21d12d7d, 0x2b142464, 0xe7be24fa, 0x69312319, 0xa59b2387, 0xf9766256, 0x35dc62c8, 0xbb53652b, 0x77f965b5, 0x7d3c6cac, 0xb1966c32, 0x3f196bd1, 0xf3b36b4f, 0x2a9379e3, 0xe639797d, 0x68b67e9e, 0xa41c7e00, 0xaed97719, 0x62737787, 0xecfc7064, 0x205670fa, 0x85cd537d, 0x496753e3, 0xc7e85400, 0x0b42549e, 0x01875d87, 0xcd2d5d19, 0x43a25afa, 0x8f085a64, 0x562848c8, 0x9a824856, 0x140d4fb5, 0xd8a74f2b, 0xd2624632, 0x1ec846ac, 0x9047414f, 0x5ced41d1, 0x299dc2ed, 0xe537c273, 0x6bb8c590, 0xa712c50e, 0xadd7cc17, 0x617dcc89, 0xeff2cb6a, 0x2358cbf4, 0xfa78d958, 0x36d2d9c6, 0xb85dde25, 0x74f7debb, 0x7e32d7a2, 0xb298d73c, 0x3c17d0df, 0xf0bdd041, 0x5526f3c6, 0x998cf358, 0x1703f4bb, 0xdba9f425, 0xd16cfd3c, 0x1dc6fda2, 0x9349fa41, 0x5fe3fadf, 0x86c3e873, 0x4a69e8ed, 0xc4e6ef0e, 0x084cef90, 0x0289e689, 0xce23e617, 0x40ace1f4, 0x8c06e16a, 0xd0eba0bb, 0x1c41a025, 0x92cea7c6, 0x5e64a758, 0x54a1ae41, 0x980baedf, 0x1684a93c, 0xda2ea9a2, 0x030ebb0e, 0xcfa4bb90, 0x412bbc73, 0x8d81bced, 0x8744b5f4, 0x4beeb56a, 0xc561b289, 0x09cbb217, 0xac509190, 0x60fa910e, 0xee7596ed, 0x22df9673, 0x281a9f6a, 0xe4b09ff4, 0x6a3f9817, 0xa6959889, 0x7fb58a25, 0xb31f8abb, 0x3d908d58, 0xf13a8dc6, 0xfbff84df, 0x37558441, 0xb9da83a2, 0x7570833c, 0x533b85da, 0x9f918544, 0x111e82a7, 0xddb48239, 0xd7718b20, 0x1bdb8bbe, 0x95548c5d, 0x59fe8cc3, 0x80de9e6f, 0x4c749ef1, 0xc2fb9912, 0x0e51998c, 0x04949095, 0xc83e900b, 0x46b197e8, 0x8a1b9776, 0x2f80b4f1, 0xe32ab46f, 0x6da5b38c, 0xa10fb312, 0xabcaba0b, 0x6760ba95, 0xe9efbd76, 0x2545bde8, 0xfc65af44, 0x30cfafda, 0xbe40a839, 0x72eaa8a7, 0x782fa1be, 0xb485a120, 0x3a0aa6c3, 0xf6a0a65d, 0xaa4de78c, 0x66e7e712, 0xe868e0f1, 0x24c2e06f, 0x2e07e976, 0xe2ade9e8, 0x6c22ee0b, 0xa088ee95, 0x79a8fc39, 0xb502fca7, 0x3b8dfb44, 0xf727fbda, 0xfde2f2c3, 0x3148f25d, 0xbfc7f5be, 0x736df520, 0xd6f6d6a7, 0x1a5cd639, 0x94d3d1da, 0x5879d144, 0x52bcd85d, 0x9e16d8c3, 0x1099df20, 0xdc33dfbe, 0x0513cd12, 0xc9b9cd8c, 0x4736ca6f, 0x8b9ccaf1, 0x8159c3e8, 0x4df3c376, 0xc37cc495, 0x0fd6c40b, 0x7aa64737, 0xb60c47a9, 0x3883404a, 0xf42940d4, 0xfeec49cd, 0x32464953, 0xbcc94eb0, 0x70634e2e, 0xa9435c82, 0x65e95c1c, 0xeb665bff, 0x27cc5b61, 0x2d095278, 0xe1a352e6, 0x6f2c5505, 0xa386559b, 0x061d761c, 0xcab77682, 0x44387161, 0x889271ff, 0x825778e6, 0x4efd7878, 0xc0727f9b, 0x0cd87f05, 0xd5f86da9, 0x19526d37, 0x97dd6ad4, 0x5b776a4a, 0x51b26353, 0x9d1863cd, 0x1397642e, 0xdf3d64b0, 0x83d02561, 0x4f7a25ff, 0xc1f5221c, 0x0d5f2282, 0x079a2b9b, 0xcb302b05, 0x45bf2ce6, 0x89152c78, 0x50353ed4, 0x9c9f3e4a, 0x121039a9, 0xdeba3937, 0xd47f302e, 0x18d530b0, 0x965a3753, 0x5af037cd, 0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, 0xb78b1a2e, 0x39041dcd, 0xf5ae1d53, 0x2c8e0fff, 0xe0240f61, 0x6eab0882, 0xa201081c, 0xa8c40105, 0x646e019b, 0xeae10678, 0x264b06e6 } }; void FCrc::Init() { #if !UE_BUILD_SHIPPING for( uint32 iCRC=0; iCRC < 256; iCRC++ ) { uint32 CrcCheck = 0; for( uint32 c=iCRC<<24, j=8; j!=0; j-- ) { CrcCheck = c = c & 0x80000000 ? (c << 1) ^ Crc32Poly : (c << 1); } check(CrcCheck == CRCTable_DEPRECATED[iCRC]); } uint32 RCrc32Poly = ReverseBits((uint32)Crc32Poly); for (uint32 i = 0; i != 256; ++i) { uint32 CRC = i; for (uint32 j = 8; j; --j) { CRC = (CRC & 1) ? (CRC >> 1) ^ RCrc32Poly : (CRC >> 1); } check(CRCTablesSB8[0][i] == CRC); } for (uint32 i = 0; i != 256; ++i) { uint32 CRC = CRCTablesSB8[0][i]; for (uint32 j = 1; j != 8; ++j) { CRC = CRCTablesSB8[0][CRC & 0xFF] ^ (CRC >> 8); check(CRCTablesSB8[j][i] == CRC); } } for (uint32 Cell = 0; Cell != 256; ++Cell) { uint32 CRC = Cell << 24; for (uint32 Repeat = 8; Repeat; --Repeat) { CRC = (CRC & 0x80000000) ? (CRC << 1) ^ Crc32Poly : (CRC << 1); } check(CRCTablesSB8_DEPRECATED[0][Cell] == BYTESWAP_ORDER32(CRC)); } for (uint32 Cell = 0; Cell != 256; ++Cell) { uint32 CRC = BYTESWAP_ORDER32(CRCTablesSB8_DEPRECATED[0][Cell]); for (uint32 Table = 1; Table != 8; ++Table) { CRC = BYTESWAP_ORDER32(CRCTablesSB8_DEPRECATED[0][CRC >> 24]) ^ (CRC << 8); check(CRCTablesSB8_DEPRECATED[Table][Cell] == BYTESWAP_ORDER32(CRC)); } } #endif // !UE_BUILD_SHIPPING } #if PLATFORM_HAS_CRC_INTRINSICS // Need to include the header file with the intrinsic definitions per platform until conformity comes #if PLATFORM_SWITCH #include <arm_acle.h> #endif // PLATFORM_SWITCH uint32 FCrc::MemCrc32(const void* InData, int32 Length, uint32 CRC/*=0 */) { CRC = ~CRC; const uint8_t* __restrict Data = reinterpret_cast<const uint8_t*>(InData); // First we need to align to 32-bits int32 InitBytes = Align(Data, 4) - Data; if (Length > InitBytes) { Length -= InitBytes; for (; InitBytes; --InitBytes) { CRC = (CRC >> 8) ^ __crc32b(CRC & 0xFF, *Data++); } auto Data8 = reinterpret_cast<const uint64_t*>(Data); for (uint32 Repeat = Length / 8; Repeat; --Repeat) { CRC = __crc32d(CRC, *Data8++); } Data = reinterpret_cast<const uint8_t*>(Data8); Length %= 8; } for (; Length; --Length) { CRC = (CRC >> 8) ^ __crc32b(CRC & 0xFF, *Data++); } return ~CRC; } #else uint32 FCrc::MemCrc32( const void* InData, int32 Length, uint32 CRC/*=0 */ ) { // Based on the Slicing-by-8 implementation found here: // http://slicing-by-8.sourceforge.net/ CRC = ~CRC; const uint8* __restrict Data = (uint8*)InData; // First we need to align to 32-bits int32 InitBytes = UE_PTRDIFF_TO_INT32(Align(Data, 4) - Data); if (Length > InitBytes) { Length -= InitBytes; for (; InitBytes; --InitBytes) { CRC = (CRC >> 8) ^ CRCTablesSB8[0][(CRC & 0xFF) ^ *Data++]; } auto Data4 = (const uint32*)Data; for (uint32 Repeat = Length / 8; Repeat; --Repeat) { uint32 V1 = *Data4++ ^ CRC; uint32 V2 = *Data4++; CRC = CRCTablesSB8[7][ V1 & 0xFF] ^ CRCTablesSB8[6][(V1 >> 8) & 0xFF] ^ CRCTablesSB8[5][(V1 >> 16) & 0xFF] ^ CRCTablesSB8[4][ V1 >> 24 ] ^ CRCTablesSB8[3][ V2 & 0xFF] ^ CRCTablesSB8[2][(V2 >> 8) & 0xFF] ^ CRCTablesSB8[1][(V2 >> 16) & 0xFF] ^ CRCTablesSB8[0][ V2 >> 24 ]; } Data = (const uint8*)Data4; Length %= 8; } for (; Length; --Length) { CRC = (CRC >> 8) ^ CRCTablesSB8[0][(CRC & 0xFF) ^ *Data++]; } return ~CRC; } #endif uint32 FCrc::MemCrc_DEPRECATED(const void* InData, int32 Length, uint32 CRC/*=0 */) { // Based on the Slicing-by-8 implementation found here: // http://slicing-by-8.sourceforge.net/ CRC = ~BYTESWAP_ORDER32(CRC); const uint8* __restrict Data = (uint8*)InData; // First we need to align to 32-bits int32 InitBytes = UE_PTRDIFF_TO_INT32(Align(Data, 4) - Data); if (Length > InitBytes) { Length -= InitBytes; for (; InitBytes; --InitBytes) { CRC = (CRC >> 8) ^ CRCTablesSB8_DEPRECATED[0][(CRC & 0xFF) ^ *Data++]; } auto Data4 = (const uint32*)Data; for (uint32 Repeat = Length / 8; Repeat; --Repeat) { uint32 V1 = *Data4++ ^ CRC; uint32 V2 = *Data4++; CRC = CRCTablesSB8_DEPRECATED[7][ V1 & 0xFF] ^ CRCTablesSB8_DEPRECATED[6][(V1 >> 8) & 0xFF] ^ CRCTablesSB8_DEPRECATED[5][(V1 >> 16) & 0xFF] ^ CRCTablesSB8_DEPRECATED[4][ V1 >> 24 ] ^ CRCTablesSB8_DEPRECATED[3][ V2 & 0xFF] ^ CRCTablesSB8_DEPRECATED[2][(V2 >> 8) & 0xFF] ^ CRCTablesSB8_DEPRECATED[1][(V2 >> 16) & 0xFF] ^ CRCTablesSB8_DEPRECATED[0][ V2 >> 24 ]; } Data = (const uint8*)Data4; Length %= 8; } for (; Length; --Length) { CRC = (CRC >> 8) ^ CRCTablesSB8_DEPRECATED[0][(CRC & 0xFF) ^ *Data++]; } return BYTESWAP_ORDER32(~CRC); }
[ "wujiahong19981022@outlook.com" ]
wujiahong19981022@outlook.com
f320e1a084b5417e61e3a6f3bdc6b92cba1eb366
7c8f97296914cc3cb0a0eb9872ec96c77c107aee
/CartesianTree2/MyVector.cpp
28328d7fccf61cfb1303b888520dee4d0a3a71b3
[]
no_license
Boialex/Algorithms
17d406ebc0a8b0ffe1d44fdbe2cd06ecbf90e253
9b0e77189e30682b3597547051a08f97896bbafc
refs/heads/master
2020-12-31T00:29:49.346091
2017-03-19T15:36:48
2017-03-19T15:36:48
85,487,695
0
0
null
null
null
null
UTF-8
C++
false
false
1,081
cpp
#include "stdafx.h" #include "MyVector.h" void MyVector::Insert(int key, size_t position) { array.push_back(key); for (int i = position; i < array.size(); ++i) std::swap(array[i], array[array.size() - 1]); } void MyVector::Output() { for (std::vector<int>::iterator i = array.begin(); i < array.end(); ++i) std::cout << *i << ' '; std::cout << std::endl; } void MyVector::Assign(int key, size_t position) { if (position < 0 || position > array.size() + 1) return; array[position] = key; } int MyVector::Sum(size_t l, size_t r) { if (l > r) return 0; int sum = 0; if (l < 0) l = 0; if (r > array.size()) r = array.size(); for (int i = l; i < r; ++i) sum += array[i]; return sum; } bool MyVector::NextPermutation(size_t l, size_t r) { if (l > r) return 0; return std::next_permutation(array.begin() + l, array.begin() + r); } size_t MyVector::Size() { return array.size(); } void MyVector::VectorOutput(std::vector<int> & array) { for (std::vector<int>::iterator i = (this->array).begin(); i < (this->array).end(); ++i) array.push_back(*i); }
[ "xdr007@gmail.com" ]
xdr007@gmail.com
61633cfb06809a666fecaeb7f710ed22f6cefa04
b1ca290baa255e9939882e3711093a8ca0509687
/278/Untitled6.cpp
c15d502a7372d52591927acdf5bc0627e4aa54a2
[]
no_license
ZeeshanAhmadKhalil/DevCpp
26872a9059d683072c116169b4035ea6ae706c54
c68c67f2972cbc6bca2691dd773a4bff62aa5889
refs/heads/master
2020-07-29T00:00:33.065937
2019-09-24T06:13:57
2019-09-24T06:13:57
209,585,282
0
0
null
null
null
null
UTF-8
C++
false
false
387
cpp
#include<iostream> #include<conio.h> using namespace std; class record { private: int marks; char grade; public: record(int m,char g) { marks=m; grade=g; } show() { cout<<"Marks="<<marks<<endl; cout<<"Grade="<<grade<<endl; } }; main() { record s1(750,'A'),s2(650,'B'); cout<<"Record of student 1"<<endl; s1.show(); cout<<"Record of student 2"<<endl; s2.show(); }
[ "mk1411997@gmail.com" ]
mk1411997@gmail.com
48d733a102c070324c653a94f86722ab8cc00b41
eb2f8b3271e8ef9c9b092fcaeff3ff8307f7af86
/Grade 10-12/2018 autumn/NOIP/NOIP2018提高组Day2程序包/answers/GD-0166/defense/defense.cpp
70956fb195c609bae04abd57b0520e7aaa196cf2
[]
no_license
Orion545/OI-Record
0071ecde8f766c6db1f67b9c2adf07d98fd4634f
fa7d3a36c4a184fde889123d0a66d896232ef14c
refs/heads/master
2022-01-13T19:39:22.590840
2019-05-26T07:50:17
2019-05-26T07:50:17
188,645,194
4
2
null
null
null
null
UTF-8
C++
false
false
577
cpp
#include<cstdio> using namespace std; int n,m; int main() { freopen("defense.in","r",stdin); freopen("defense.out","w",stdout); scanf("%d%d",&n,&m); if (n==5&&m==3) { printf("12\n"); printf("7\n"); printf("-1\n"); } else if (n==10&&m==10) { printf("213696\n"); printf("202573\n"); printf("202573\n"); printf("155871\n"); printf("-1\n"); printf("202573\n"); printf("254631\n"); printf("155871\n"); printf("173718\n"); printf("-1\n"); } else { for (int i=1;i<=m;i++) printf("-1\n"); } fclose(stdin); fclose(stdout); }
[ "orion545@qq.com" ]
orion545@qq.com
25fda72655bde8f75e486f5ebb3921f2deec323c
4799044cec94c502cdd3bac8f7efbd457d44b912
/Trees/GenericTree.h
a099e3058c1ad96be36352850682767f99018521
[]
no_license
yogesh019/DataStructures
669d8b6927df5807904ec3cecd1c8216d21db2f8
ab369068cab3bb68a84b35deb858cf1aa1472ec5
refs/heads/master
2021-01-19T10:56:57.504014
2019-06-30T11:08:01
2019-06-30T11:08:01
82,221,401
0
0
null
null
null
null
UTF-8
C++
false
false
9,942
h
#ifndef GENERICTREE_H_INCLUDED #define GENERICTREE_H_INCLUDED #include<iostream> #include<queue> #include<stack> using namespace std; template<typename T> class GenericTree; template<typename T> class GenericTreeNode{ public: T data; GenericTreeNode**children; GenericTreeNode*parent; unsigned int child_count; GenericTreeNode(const T&ele=0):data(ele),parent(0),child_count(0),children(0){} GenericTreeNode(const GenericTreeNode&G){ data=G.data; child_count=G.child_count; parent=0; children=new GenericTreeNode<T>*[child_count]; for(int i=0;i<child_count;i++){ children[i]=new GenericTreeNode<T>(*G.children[i]); children[i]->parent=this; } } GenericTreeNode&operator=(const GenericTreeNode&G){ for(int i=0;i<child_count;i++){ delete children[i]; } if(children) delete children; data=G.data; child_count=G.child_count; parent=0; children=new GenericTreeNode<T>[child_count]; for(int i=0;i<child_count;i++){ children[i]=new GenericTreeNode<T>(*G.children[i]); children[i]->parent=this; } return (*this); } ~GenericTreeNode(){ for(int i=0;i<child_count;i++){ delete children[i]; } if(children) delete [] children; children=0; } friend class GenericTree<T>; }; template<typename T> class GenericTree{ GenericTreeNode<T>*root; static void Clear(GenericTreeNode<T>*root){ if(!root)return; for(int i=0;i<root->child_count;i++){ Clear(root->children[i]); } delete [] root->children; delete root; } static GenericTreeNode<T>*DuplicateAs(GenericTreeNode<T>*root){ GenericTreeNode<T>*temp=new GenericTreeNode<T>(root->data); temp->child_count=root->child_count; temp->children=new GenericTreeNode<T>*[temp->child_count]; for(int i=0;i<temp->child_count;i++){ temp->children[i]=DuplicateAs(root->children[i]); } return temp; } public: GenericTree():root(0){} GenericTree(const GenericTree&G):root(0){ root=new GenericTreeNode<T>(*G.root); //root=DuplicatAs(G.root); } GenericTree&operator=(const GenericTree&G){ if(root)delete root; root=new GenericTreeNode<T>(*G.root); //if(root)Clear(root); //root=DuplicateAs(G.root); return(*this); } ~GenericTree(){ if(root) delete root; //Clear(root); root=0; } void createTree(){ T ele; //taking input level wise cout<<"Enter root: "; cin>>ele; root=new GenericTreeNode<T>(ele); queue<GenericTreeNode<T>*>Q; Q.push(root); while(!Q.empty()){ GenericTreeNode<T>*temp=Q.front(); Q.pop(); cout<<"Enter the child count of "<<temp->data<<": "; cin>>temp->child_count; temp->children=new GenericTreeNode<T>*[temp->child_count]; for(int i=0;i<temp->child_count;i++){ cout<<"Enter the "<<i+1<<" child of "<<temp->data<<": "; cin>>ele; temp->children[i]=new GenericTreeNode<T>(ele); temp->children[i]->parent=temp; Q.push(temp->children[i]); } } } void printTree(){ //level wise printing , bfs if(!root)return; queue<GenericTreeNode<T>*>Q; Q.push(root); Q.push(NULL); while(!Q.empty()){ GenericTreeNode<T>*temp=Q.front(); Q.pop(); if(!temp){ if(!Q.empty()){ cout<<endl; Q.push(NULL); } continue; } cout<<temp->data<<" "; for(int i=0;i<temp->child_count;i++){ Q.push(temp->children[i]); } } } // constructing tree in a depth first search way void constructTreeRecursive(){ T ele; cout<<"Enter root: "; cin>>ele; root=new GenericTreeNode<T>(ele); constructTreeRecursiveHelper(root); return; } void constructTree(){ T ele; cout<<"Enter root: "; cin>>ele; root=new GenericTreeNode<T>(ele); stack<GenericTreeNode<T>*>S; S.push(root); while(!S.empty()){ GenericTreeNode<T>*temp=S.top(); S.pop(); cout<<"Enter the child count of "<<temp->data<<": "; cin>>temp->child_count; temp->children=new GenericTreeNode<T>*[temp->child_count]; for(int i=0;i<temp->child_count;i++){ cout<<"Enter the "<<i+1<<" child of "<<temp->data<<": "; cin>>ele; temp->children[i]=new GenericTreeNode<T>(ele); temp->children[i]->parent=temp; S.push(temp->children[i]); } } } void printPreOrder(){ if(!root) return; printPreOrderHelper(root); } void printPostOrder(){ if(!root) return; printPostOrderHelper(root); } int height(){ if(!root)return -1; return heightOfNode(root); } void printAtDepthK(int K){ if(K<0||!root)return; printAtDepthKHelper(root,K); return; } GenericTreeNode<T>*LargestNode(){ if(!root)return root; return LargestNodeHelper(root); } int NodesGreaterThanRootRecursive(){ if(!root)return 0; return NodesGreaterThanNode(root,root->data); } T SumOfNodes(){ if(!root)return 0; return SumOfNodesHelper(root); } void preOrderUsingStack(){ if(!root)return; stack<GenericTreeNode<T>*>S; S.push(root); while(!S.empty()){ GenericTreeNode<T>*temp=S.top(); S.pop(); cout<<temp->data<<" "; for(int i=temp->child_count-1;i>=0;i--){ S.push(temp->children[i]); } } return; } GenericTreeNode<T>*findMaxSum(){ if(!root)return root; return findMaxSumHelper(root); } int NodesGreaterThanRoot(){ queue<GenericTreeNode<T>*>Q; Q.push(root); int count=0; while(!Q.empty()){ GenericTreeNode<T>*temp=Q.front(); Q.pop(); if(temp->data>root->data){ count++; } for(int i=0;i<temp->child_count;i++){ Q.push(temp->children[i]); } } return count; } private: static GenericTreeNode<T>*findMaxSumHelper(GenericTreeNode<T>*root){ GenericTreeNode<T>*max=root; T max_sum=root->data; for(int i=0;i<root->child_count;i++){ max_sum+=root->children[i]->data; } for(int i=0;i<root->child_count;i++){ GenericTreeNode<T>*temp=findMaxSumHelper(root->children[i]); T sum=temp->data; for(int i=0;i<temp->child_count;i++){ sum+=temp->children[i]->data; } max=max_sum>sum?max:temp; max_sum=max_sum>sum?max_sum:sum; } return max; } static T SumOfNodesHelper(GenericTreeNode<T>*root){ T sum=root->data; for(int i=0;i<root->child_count;i++){ sum+=SumOfNodesHelper(root->children[i]); } return sum; } static int NodesGreaterThanNode(GenericTreeNode<T>*root,int K){ int count=0; if(root->data>K){ count++; } for(int i=0;i<root->child_count;i++){ count+=NodesGreaterThanNode(root->children[i],K); } return count; } static GenericTreeNode<T>*LargestNodeHelper(GenericTreeNode<T>*root){ GenericTreeNode<T>*large=root; for(int i=0;i<root->child_count;i++){ large=large->data>LargestNodeHelper(root->children[i])->data?large:LargestNodeHelper(root->children[i]); } return large; } static void printAtDepthKHelper(GenericTreeNode<T>*root,int K){ if(!K)cout<<root->data<<" "; for(int i=0;i<root->child_count;i++){ printAtDepthKHelper(root->children[i],K-1); } } static int heightOfNode(GenericTreeNode<T>*root){ int h=-1; for(int i=0;i<root->child_count;i++){ h=h>heightOfNode(root->children[i])?h:heightOfNode(root->children[i]); } return h+1; } static void printPostOrderHelper(GenericTreeNode<T>*root){ for(int i=0;i<root->child_count;i++){ printPostOrderHelper(root->children[i]); } cout<<root->data<<" "; return; } static void printPreOrderHelper(GenericTreeNode<T>*root){ cout<<root->data<<" "; for(int i=0;i<root->child_count;i++){ printPreOrderHelper(root->children[i]); } return; } static void constructTreeRecursiveHelper(GenericTreeNode<T>*root){ cout<<"Enter the child count of "<<root->data<<": "; cin>>root->child_count; root->children=new GenericTreeNode<T>*[root->child_count]; for(int i=0;i<root->child_count;i++){ cout<<"Enter the "<<i+1<<"child of "<<root->data<<": "; T ele; cin>>ele; root->children[i]=new GenericTreeNode<T>(ele); root->children[i]->parent=root; // constructTreeRecursiveHelper(root->children[i]); } for(int i=0;i<root->child_count;i++){ constructTreeRecursiveHelper(root->children[i]); } } }; #endif //GENERICTREE_H_INCLUDED
[ "sharmay376@gmail.com" ]
sharmay376@gmail.com
ee44038c72a75f9fe7a846fdce6baab8b867a8b1
7f1e7aaf7100612b6181ad7d79ff33bb3038e22c
/tools/quantize.cc
00dfe18231cb973fc6ef6868a08347a0f1b4f799
[]
no_license
tyfkda/save_endo
209d8d5e3653705e74385b4d0cb62993a47b043c
94a6ea01967a9b1532796a60e57ca5d104d42af1
refs/heads/master
2020-12-24T21:28:27.610789
2016-04-14T05:50:14
2016-04-14T05:50:14
56,209,728
0
0
null
null
null
null
UTF-8
C++
false
false
1,230
cc
#include "util.h" #include <iostream> #include <png.h> using namespace std; int CompareImage(unsigned char* image1, unsigned char* image2, int width, int height) { int risk = 0; for (int i = 0; i < width * height; ++i) { unsigned char* p = &image1[i * 3]; unsigned char* q = &image2[i * 3]; int r = p[0] - q[0]; int g = p[1] - q[1]; int b = p[2] - q[2]; if (r == 0 && g == 0 && b == 0) { p[0] = p[1] = p[2] = 255; } else { ++risk; int diff = min(abs(r) + abs(g) + abs(b), 255); p[0] = diff; p[1] = p[2] = 0; } } return risk; } int main(int argc, char* argv[]) { if (argc < 3) { cerr << "2 filename required." << endl; return 1; } int width, height; unsigned char* image = LoadPng(argv[1], &width, &height); if (image == NULL) { cerr << "Load " << argv[1] << " failed." << endl; return 1; } // Modify color. for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { unsigned char* p = &image[(i * width + j) * 3]; p[0] = (p[0] & 1) ? 255 : 0; p[1] = (p[1] & 1) ? 255 : 0; p[2] = (p[2] & 1) ? 255 : 0; } } SavePng(argv[2], width, height, image); return 0; }
[ "tyfkda@gmail.com" ]
tyfkda@gmail.com
db8977cb12edc3d81a3298412e83d352418ca39b
8f9a6e3cf0be0510210b800188ba790939a72d06
/1135.cpp
520e29f7544abd659c8880308e51ac1196dd5aec
[]
no_license
ppdg123/hihoCoder
ac6d042463cbda2d0726d6df2d07621d6e3dcd02
8fada68531304366581f73116621ab13cd6d14db
refs/heads/master
2021-01-10T04:39:51.294284
2015-10-21T11:41:20
2015-10-21T11:41:20
43,962,401
1
0
null
null
null
null
UTF-8
C++
false
false
872
cpp
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <algorithm> using namespace std; int main() { int val[3],cur[3]; char str[20005]; scanf("%d%d%d",&val[0],&val[1],&val[2]); sort(val,val+3); scanf("%s",str); int len = strlen(str); int cnt = 0; int pcnt[200],tmp,i; memset(pcnt,0,sizeof pcnt); i = 0; int maxv = 0; while(i<len) { pcnt[str[i]]++; tmp = pcnt['R']+pcnt['B']+pcnt['Y']; if(tmp>cnt) cnt = tmp; cur[0] = abs(pcnt['R']-pcnt['B']); cur[1] = abs(pcnt['R']-pcnt['Y']); cur[2] = abs(pcnt['B']-pcnt['Y']); sort(cur,cur+3); if(maxv<cnt) maxv=cnt; if(cur[0]==val[0]&&cur[1]==val[1]&&cur[2]==val[2]) { pcnt['R']=0,pcnt['B']=0,pcnt['Y']=0; } i++; } printf("%d\n",maxv); return 0; }
[ "ppdg@foxmail.com" ]
ppdg@foxmail.com
4d134248f30a0fa9dcf42a3578e6e5f9155a1d93
dd656493066344e70123776c2cc31dd13f31c1d8
/MITK/Modules/DiffusionImaging/Algorithms/itkTractsToProbabilityImageFilter.cpp
ea27142da41231ba044e46a534a6dfdfbab43f7f
[]
no_license
david-guerrero/MITK
e9832b830cbcdd94030d2969aaed45da841ffc8c
e5fbc9993f7a7032fc936f29bc59ca296b4945ce
refs/heads/master
2020-04-24T19:08:37.405353
2011-11-13T22:25:21
2011-11-13T22:25:21
2,372,730
0
1
null
null
null
null
UTF-8
C++
false
false
13,253
cpp
#include "itkTractsToProbabilityImageFilter.h" #include "itkBSplineUpsampleImageFilter.h" #define __CEIL_UCHAR__(val) (val) = \ ( (val) < 0 ) ? ( 0 ) : ( ( (val)>255 ) ? ( 255 ) : ( (val) ) ); namespace itk{ template< class TInputImage, class TOutputPixelType > TractsToProbabilityImageFilter< TInputImage, TOutputPixelType > ::TractsToProbabilityImageFilter(): m_BinaryEnvelope(false) { this->SetNumberOfRequiredInputs(0); } template< class TInputImage, class TOutputPixelType > TractsToProbabilityImageFilter< TInputImage, TOutputPixelType > ::~TractsToProbabilityImageFilter() { } template< class TInputImage, class TOutputPixelType > void TractsToProbabilityImageFilter< TInputImage, TOutputPixelType > ::GenerateData() { bool isRgba = false; if(&typeid(TOutputPixelType) == &typeid(itk::RGBAPixel<unsigned char>)) { isRgba = true; } else if(&typeid(TOutputPixelType) != &typeid(unsigned char)) { MITK_INFO << "Only 'unsigned char' and 'itk::RGBAPixel<unsigned char> supported as OutputPixelType"; return; } mitk::Geometry3D::Pointer geometry = m_FiberBundle->GetGeometry(); typename OutputImageType::Pointer outImage = static_cast< OutputImageType * >(this->ProcessObject::GetOutput(0)); outImage->SetSpacing( geometry->GetSpacing()/m_UpsamplingFactor ); // Set the image spacing mitk::Point3D origin = geometry->GetOrigin(); mitk::Point3D indexOrigin; geometry->WorldToIndex(origin, indexOrigin); indexOrigin[0] = indexOrigin[0] - .5 * (1.0-1.0/m_UpsamplingFactor); indexOrigin[1] = indexOrigin[1] - .5 * (1.0-1.0/m_UpsamplingFactor); indexOrigin[2] = indexOrigin[2] - .5 * (1.0-1.0/m_UpsamplingFactor); mitk::Point3D newOrigin; geometry->IndexToWorld(indexOrigin, newOrigin); outImage->SetOrigin( newOrigin ); // Set the image origin itk::Matrix<double, 3, 3> matrix; for (int i=0; i<3; i++) for (int j=0; j<3; j++) matrix[j][i] = geometry->GetMatrixColumn(i)[j]; outImage->SetDirection( matrix ); // Set the image direction float* bounds = m_FiberBundle->GetBounds(); ImageRegion<3> upsampledRegion; upsampledRegion.SetSize(0, bounds[0]); upsampledRegion.SetSize(1, bounds[1]); upsampledRegion.SetSize(2, bounds[2]); typename InputImageType::RegionType::SizeType upsampledSize = upsampledRegion.GetSize(); for (unsigned int n = 0; n < 3; n++) { upsampledSize[n] = upsampledSize[n] * m_UpsamplingFactor; } upsampledRegion.SetSize( upsampledSize ); outImage->SetRegions( upsampledRegion ); outImage->Allocate(); // itk::RGBAPixel<unsigned char> pix; // pix.Set(0,0,0,0); // outImage->FillBuffer(pix); int w = upsampledSize[0]; int h = upsampledSize[1]; int d = upsampledSize[2]; unsigned char* accuout; float* accu; accuout = reinterpret_cast<unsigned char*>(outImage->GetBufferPointer()); if(isRgba) { // accuout = static_cast<unsigned char*>( outImage->GetBufferPointer()[0].GetDataPointer()); accu = new float[w*h*d*4]; for (int i=0; i<w*h*d*4; i++) accu[i] = 0; } else { accu = new float[w*h*d]; for (int i=0; i<w*h*d; i++) accu[i] = 0; } // for each tract int numTracts = m_FiberBundle->GetNumTracts(); for( int i=0; i<numTracts; i++ ) { //////////////////// // upsampling std::vector< itk::Point<float, 3> > vertices; // for each vertex int numVertices = m_FiberBundle->GetNumPoints(i); for( int j=0; j<numVertices-1; j++) { itk::Point<float, 3> point = m_FiberBundle->GetPoint(i,j); itk::Point<float, 3> nextPoint = m_FiberBundle->GetPoint(i,j+1); point[0] += 0.5 - 0.5/m_UpsamplingFactor; point[1] += 0.5 - 0.5/m_UpsamplingFactor; point[2] += 0.5 - 0.5/m_UpsamplingFactor; nextPoint[0] += 0.5 - 0.5/m_UpsamplingFactor; nextPoint[1] += 0.5 - 0.5/m_UpsamplingFactor; nextPoint[2] += 0.5 - 0.5/m_UpsamplingFactor; for(int k=1; k<=m_UpsamplingFactor; k++) { itk::Point<float, 3> newPoint; newPoint[0] = point[0] + ((double)k/(double)m_UpsamplingFactor)*(nextPoint[0]-point[0]); newPoint[1] = point[1] + ((double)k/(double)m_UpsamplingFactor)*(nextPoint[1]-point[1]); newPoint[2] = point[2] + ((double)k/(double)m_UpsamplingFactor)*(nextPoint[2]-point[2]); vertices.push_back(newPoint); } } //////////////////// // calc directions (which are used as weights) std::list< itk::Point<float, 3> > rgbweights; std::list<float> intensities; // for each vertex numVertices = vertices.size(); for( int j=0; j<numVertices-1; j++) { itk::Point<float, 3> vertex = vertices.at(j); itk::Point<float, 3> vertexPost = vertices.at(j+1); itk::Point<float, 3> dir; dir[0] = fabs((vertexPost[0] - vertex[0]) * outImage->GetSpacing()[0]); dir[1] = fabs((vertexPost[1] - vertex[1]) * outImage->GetSpacing()[1]); dir[2] = fabs((vertexPost[2] - vertex[2]) * outImage->GetSpacing()[2]); if(isRgba) { rgbweights.push_back(dir); } float intensity = sqrt(dir[0]*dir[0]+dir[1]*dir[1]+dir[2]*dir[2]); intensities.push_back(intensity); // last point gets same as previous one if(j==numVertices-2) { if(isRgba) { rgbweights.push_back(dir); } intensities.push_back(intensity); } } //////////////////// // fill output image // for each vertex for( int j=0; j<numVertices; j++) { itk::Point<float, 3> vertex = vertices.at(j); itk::Point<float, 3> rgbweight; if(isRgba) { rgbweight = rgbweights.front(); rgbweights.pop_front(); } float intweight = intensities.front(); intensities.pop_front(); // scaling coordinates (index coords scale with upsampling) vertex[0] = vertex[0] * m_UpsamplingFactor; vertex[1] = vertex[1] * m_UpsamplingFactor; vertex[2] = vertex[2] * m_UpsamplingFactor; // int coordinates inside image? int px = (int) (vertex[0]); if (px < 0 || px >= w-1) continue; int py = (int) (vertex[1]); if (py < 0 || py >= h-1) continue; int pz = (int) (vertex[2]); if (pz < 0 || pz >= d-1) continue; // float fraction of coordinates float frac_x = vertex[0] - px; float frac_y = vertex[1] - py; float frac_z = vertex[2] - pz; float scale = 100 * pow((float)m_UpsamplingFactor,3); if(isRgba) { // add to r-channel in output image accu[0+4*( px + w*(py + h*pz ))] += (1-frac_x)*(1-frac_y)*(1-frac_z) * rgbweight[0] * scale; accu[0+4*( px + w*(py+1+ h*pz ))] += (1-frac_x)*( frac_y)*(1-frac_z) * rgbweight[0] * scale; accu[0+4*( px + w*(py + h*pz+h))] += (1-frac_x)*(1-frac_y)*( frac_z) * rgbweight[0] * scale; accu[0+4*( px + w*(py+1+ h*pz+h))] += (1-frac_x)*( frac_y)*( frac_z) * rgbweight[0] * scale; accu[0+4*( px+1 + w*(py + h*pz ))] += ( frac_x)*(1-frac_y)*(1-frac_z) * rgbweight[0] * scale; accu[0+4*( px+1 + w*(py + h*pz+h))] += ( frac_x)*(1-frac_y)*( frac_z) * rgbweight[0] * scale; accu[0+4*( px+1 + w*(py+1+ h*pz ))] += ( frac_x)*( frac_y)*(1-frac_z) * rgbweight[0] * scale; accu[0+4*( px+1 + w*(py+1+ h*pz+h))] += ( frac_x)*( frac_y)*( frac_z) * rgbweight[0] * scale; // add to g-channel in output image accu[1+4*( px + w*(py + h*pz ))] += (1-frac_x)*(1-frac_y)*(1-frac_z) * rgbweight[1] * scale; accu[1+4*( px + w*(py+1+ h*pz ))] += (1-frac_x)*( frac_y)*(1-frac_z) * rgbweight[1] * scale; accu[1+4*( px + w*(py + h*pz+h))] += (1-frac_x)*(1-frac_y)*( frac_z) * rgbweight[1] * scale; accu[1+4*( px + w*(py+1+ h*pz+h))] += (1-frac_x)*( frac_y)*( frac_z) * rgbweight[1] * scale; accu[1+4*( px+1 + w*(py + h*pz ))] += ( frac_x)*(1-frac_y)*(1-frac_z) * rgbweight[1] * scale; accu[1+4*( px+1 + w*(py + h*pz+h))] += ( frac_x)*(1-frac_y)*( frac_z) * rgbweight[1] * scale; accu[1+4*( px+1 + w*(py+1+ h*pz ))] += ( frac_x)*( frac_y)*(1-frac_z) * rgbweight[1] * scale; accu[1+4*( px+1 + w*(py+1+ h*pz+h))] += ( frac_x)*( frac_y)*( frac_z) * rgbweight[1] * scale; // add to b-channel in output image accu[2+4*( px + w*(py + h*pz ))] += (1-frac_x)*(1-frac_y)*(1-frac_z) * rgbweight[2] * scale; accu[2+4*( px + w*(py+1+ h*pz ))] += (1-frac_x)*( frac_y)*(1-frac_z) * rgbweight[2] * scale; accu[2+4*( px + w*(py + h*pz+h))] += (1-frac_x)*(1-frac_y)*( frac_z) * rgbweight[2] * scale; accu[2+4*( px + w*(py+1+ h*pz+h))] += (1-frac_x)*( frac_y)*( frac_z) * rgbweight[2] * scale; accu[2+4*( px+1 + w*(py + h*pz ))] += ( frac_x)*(1-frac_y)*(1-frac_z) * rgbweight[2] * scale; accu[2+4*( px+1 + w*(py + h*pz+h))] += ( frac_x)*(1-frac_y)*( frac_z) * rgbweight[2] * scale; accu[2+4*( px+1 + w*(py+1+ h*pz ))] += ( frac_x)*( frac_y)*(1-frac_z) * rgbweight[2] * scale; accu[2+4*( px+1 + w*(py+1+ h*pz+h))] += ( frac_x)*( frac_y)*( frac_z) * rgbweight[2] * scale; // add to a-channel in output image accu[3+4*( px + w*(py + h*pz ))] += (1-frac_x)*(1-frac_y)*(1-frac_z) * intweight * scale; accu[3+4*( px + w*(py+1+ h*pz ))] += (1-frac_x)*( frac_y)*(1-frac_z) * intweight * scale; accu[3+4*( px + w*(py + h*pz+h))] += (1-frac_x)*(1-frac_y)*( frac_z) * intweight * scale; accu[3+4*( px + w*(py+1+ h*pz+h))] += (1-frac_x)*( frac_y)*( frac_z) * intweight * scale; accu[3+4*( px+1 + w*(py + h*pz ))] += ( frac_x)*(1-frac_y)*(1-frac_z) * intweight * scale; accu[3+4*( px+1 + w*(py + h*pz+h))] += ( frac_x)*(1-frac_y)*( frac_z) * intweight * scale; accu[3+4*( px+1 + w*(py+1+ h*pz ))] += ( frac_x)*( frac_y)*(1-frac_z) * intweight * scale; accu[3+4*( px+1 + w*(py+1+ h*pz+h))] += ( frac_x)*( frac_y)*( frac_z) * intweight * scale; } else if (m_BinaryEnvelope) { accu[( px + w*(py + h*pz ))] = 1; accu[( px + w*(py+1+ h*pz ))] = 1; accu[( px + w*(py + h*pz+h))] = 1; accu[( px + w*(py+1+ h*pz+h))] = 1; accu[( px+1 + w*(py + h*pz ))] = 1; accu[( px+1 + w*(py + h*pz+h))] = 1; accu[( px+1 + w*(py+1+ h*pz ))] = 1; accu[( px+1 + w*(py+1+ h*pz+h))] = 1; } else { accu[( px + w*(py + h*pz ))] += (1-frac_x)*(1-frac_y)*(1-frac_z) * intweight * scale; accu[( px + w*(py+1+ h*pz ))] += (1-frac_x)*( frac_y)*(1-frac_z) * intweight * scale; accu[( px + w*(py + h*pz+h))] += (1-frac_x)*(1-frac_y)*( frac_z) * intweight * scale; accu[( px + w*(py+1+ h*pz+h))] += (1-frac_x)*( frac_y)*( frac_z) * intweight * scale; accu[( px+1 + w*(py + h*pz ))] += ( frac_x)*(1-frac_y)*(1-frac_z) * intweight * scale; accu[( px+1 + w*(py + h*pz+h))] += ( frac_x)*(1-frac_y)*( frac_z) * intweight * scale; accu[( px+1 + w*(py+1+ h*pz ))] += ( frac_x)*( frac_y)*(1-frac_z) * intweight * scale; accu[( px+1 + w*(py+1+ h*pz+h))] += ( frac_x)*( frac_y)*( frac_z) * intweight * scale; } } } float maxRgb = 0.000000001; float maxInt = 0.000000001; int numPix; if(isRgba) { numPix = w*h*d*4; // calc maxima for(int i=0; i<numPix; i++) { if((i-3)%4 != 0) { if(accu[i] > maxRgb) { maxRgb = accu[i]; } } else { if(accu[i] > maxInt) { maxInt = accu[i]; } } } // write output, normalized uchar 0..255 for(int i=0; i<numPix; i++) { if((i-3)%4 != 0) { accuout[i] = (unsigned char) (255.0 * accu[i] / maxRgb); } else { accuout[i] = (unsigned char) (255.0 * accu[i] / maxInt); } } } else if (m_BinaryEnvelope) { numPix = w*h*d; // write output, normalized uchar 0..255 for(int i=0; i<numPix; i++) { if(m_InvertImage) { accuout[i] = (unsigned char) ((int)(accu[i]+1)%2); } else { accuout[i] = (unsigned char) accu[i]; } } } else { numPix = w*h*d; // calc maxima for(int i=0; i<numPix; i++) { if(accu[i] > maxInt) { maxInt = accu[i]; } } // write output, normalized uchar 0..255 for(int i=0; i<numPix; i++) { accuout[i] = (unsigned char) (255.0 * accu[i] / maxInt); } } delete[] accu; } }
[ "dav@live.ca" ]
dav@live.ca
2731a594e9a8a7425ba292450e45342afff81a5f
25d4df40ca9e15578548c2167cd9fb207fc8a3e4
/HW2/H4B/rk4.h
5b57d54e796bb340006459a6dcde8c502e93bd2d
[]
no_license
Ukami/closuit_PHYS401
398cfac6299ae53ca6255cc71e1c43bdcfa495f6
db46cce6d9a5a62a5b9dcfc64be4bf5f2060d594
refs/heads/master
2020-05-01T07:47:17.915516
2015-04-17T19:41:51
2015-04-17T19:41:51
29,846,194
0
0
null
null
null
null
UTF-8
C++
false
false
696
h
#ifndef RK4_H #define RK4_H #include <stdio.h> #include <algorithm> #include <iostream> #include <fstream> #include <vector> #include <cmath> #include "datstruct.h" double func(double a) { return -pow(a, 3.0); // change this is function changes } data rk4(double x, double p, double h) //x and p position and momentum, h is step size { double kp[4], kx[4]; data c; kx[0]=p; kp[0]=func(x); kx[1]=p+.5*h*kp[0]; kp[1]=func(x+.5*h*kx[0]); kx[2]=p+.5*h*kp[1]; kp[2]=func(x+.5*h*kx[1]); kx[3]=p+.5*h*kp[2]; kp[3]=func(x+h*kx[2]); c.x=x+(h/6.0)*kx[0]+(h/3.0)*kx[1]+(h/3.0)*kx[2]+(h/6.0)*kx[3]; c.p=p+(h/6.0)*kp[0]+(h/3.0)*kp[1]+(h/3.0)*kp[2]+(h/6.0)*kp[3]; return c; } #endif
[ "u421006155@thebe.physics.tamu.edu" ]
u421006155@thebe.physics.tamu.edu
403fe2257385f878cdc3cae6cf5f77114af96cc1
07ad6f5980d009ddb6c4c5d535a8fbea4ecb8394
/imesh-cloud-node.ino
188bf3340e38640b8d4c9f1bf7111e667e0c83d7
[]
no_license
mojisejr/i-mesh-gateway-node
c83a31d706de6015a0f3f6386ed21e344ffafc26
aaff8ce8c9381fb3c44cead0f8fc408837df466f
refs/heads/master
2020-03-22T03:54:16.875289
2018-07-03T14:03:17
2018-07-03T14:03:17
139,459,328
0
0
null
null
null
null
UTF-8
C++
false
false
3,985
ino
//#define BLYNK_PRINT Serial #include <SoftwareSerial.h> #include "ESP8266WiFi.h" #include "ArduinoJson.h" #include "PubSubClient.h" #include <BlynkSimpleEsp8266.h> #include <SimpleTimer.h> #include "ifarm.h" //Blynk Params--> SimpleTimer timer; WidgetTerminal terminal(V51); //<--- //ThingSpeak params---> char* mqttServer = "mqtt.thingspeak.com"; //<--- //WiFiSetting params---> WiFiClient wifiClient; PubSubClient client(mqttServer, 1883, wifiClient); //<--- SoftwareSerial swSerial(D5, D7); //Define hardware connections RX, TX String DataString = ""; DynamicJsonBuffer jsonBuffer; void setup() { pinMode(D5, INPUT); pinMode(D7, OUTPUT); Serial.begin(115200); //Initialize hardware serial with baudrate of 115200 //BLYNK TEST--> Blynk.begin(blynkAuth, ssid, pwd); terminal.println("BLYNK[OK]: Blynk Initialized!"); //<--- //WiFi Connection Initialization --> Serial.printf("\n\n"); Serial.print("WIFI: connecting"); WiFi.begin(ssid, pwd); while(WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(); Serial.println("WIFI: connected!"); //<--- //MQTT CONNECTION TEST --> Serial.println("MQTT: connecting"); String clientName = "imesh"; if(client.connect((char*) clientName.c_str())) { Serial.println("MQTT: connected"); Serial.println("MQTT[\"TOPIC\"]: " + String(topic)); terminal.println("BLYNK[OK]: MQTT connected!"); if(client.publish(topic, "hello from ESP8266")) { Serial.println("MQTT: Publish OK!"); terminal.println("BLYNK[OK]: MQTT Initialized!"); } else { Serial.println("MQTT: Publish falied"); terminal.println("BLYNK[ERR]: MQTT Initialization failed!"); } } else { Serial.println("MQTT: connection failed"); terminal.println("BLYNK[ERR]: MQTT connection failed!"); abort(); } //<--- //SerialCommunication initialization --> Serial.println("sw-SERIAL: Initializing Software Serial"); swSerial.begin(4800); Serial.println("sw-SERIAL: Software serial Inintialized --> Start Gathering Data"); //<--- terminal.println("BLYNK[OK]: BRIDGE data trasfering started!"); terminal.flush(); timer.setInterval(2000, mqttDataReader); } void loop() { Blynk.run(); timer.run(); } //Additional Function--> void mqttDataReader() { while (swSerial.available() > 0) { char c = swSerial.read(); //gets one byte from serial buffer⸮ DataString += c; //makes the string DataString } if (DataString != "" && DataString.startsWith("{")) { Serial.println("SERIAL: " + DataString); Serial.println("SERIAL: data length: [" + String(DataString.length()) + "]"); terminal.println("BLYNK[OK]: Incoming Data: " + DataString); terminal.flush(); JsonObject& payload = jsonBuffer.parseObject(DataString); if(payload.containsKey("topic") && payload.containsKey("temp") && payload.containsKey("humid")) { String str = ""; payload.printTo(str); Serial.printf("JSON: %s\n", str.c_str()); String temp = ""; payload["temp"].printTo(temp); String humid = ""; payload["humid"].printTo(humid); humid.replace("\"", ""); temp.replace("\"", ""); String mqttMsg = "field1="; mqttMsg += temp; mqttMsg += "&field2="; mqttMsg += humid; // mqttMsg += "&status=MQTTPUBLISH"; if(client.connected()) { Serial.println("MQTT: Sending " + mqttMsg); if(client.publish(topic, (char*) mqttMsg.c_str())) { Serial.println("MQTT: Publish OK!"); Serial.println("BLYNK[OK]: Sending data to BLYNK"); terminal.println("TEMP: " + temp); terminal.println("HUMID: " + humid); } else { Serial.println("MQTT: Publish Failed"); terminal.println("BLYNK[ERR]: Data Sending Failed!"); } } } } else { Serial.println("."); } DataString = ""; } //<--
[ "nonthasak.l@gmail.com" ]
nonthasak.l@gmail.com
779eddee6f673676397d559374456dc4f1d857ac
7884ca202744631a23a1810480b296d208450472
/Codes.cpp
988a386c9124d54f1275d1052bad84a703631984
[]
no_license
Tayfurbal/Tutulan_Sayiyi_Tahmin_Etme
202024dfab5e963713e207cd5b4502fd2c3adf19
42fc78b1ef2363ac0e5d48dd73f3f5d3e55dc528
refs/heads/main
2023-06-24T08:40:08.727775
2021-07-23T11:56:08
2021-07-23T11:56:08
388,785,612
0
0
null
null
null
null
UTF-8
C++
false
false
655
cpp
#include <iostream.h> #include <conio.h> main () { int taban=0, tavan, tahmin, sonuc, deneme_sayisi=0; cout<<"0 ile kac arasinda sayi tutmak istersiniz:"; cin>>tavan; do { cout<<"Benim tahminim "; tahmin=(taban+tavan)/2; cout<<tahmin<<endl; deneme_sayisi=deneme_sayisi+1; cout<<"Tahminim sizin tuttugunuz sayidan kucuk ise 1,"<<endl; cout<<"Tahminim sizin tuttugunuz sayidan buyuk ise 2,"<<endl; cout<<"Tahminim sizin tuttugunuz sayiya esit ise 0 giriniz:"<<endl; cin>>sonuc; if(sonuc==1) taban=tahmin; if(sonuc==2) tavan=tahmin; } while (sonuc!=0); cout<<"Aferin bana "<<deneme_sayisi<<" denemede buldum"; getch(); }
[ "tayfunzbal@gmail.com" ]
tayfunzbal@gmail.com
de16406d943ee1e333dc3a8d0c771852394afd6e
2bc835b044f306fca1affd1c61b8650b06751756
/mshtml/src/other/htmldlg/htmlpop.cxx
8441896dad875ab5cd7c7d9f37ac078fa8e19105
[]
no_license
KernelPanic-OpenSource/Win2K3_NT_inetcore
bbb2354d95a51a75ce2dfd67b18cfb6b21c94939
75f614d008bfce1ea71e4a727205f46b0de8e1c3
refs/heads/master
2023-04-04T02:55:25.139618
2021-04-14T05:25:01
2021-04-14T05:25:01
357,780,123
1
0
null
null
null
null
UTF-8
C++
false
false
17,750
cxx
//+------------------------------------------------------------------------ // // Microsoft Forms // Copyright (C) Microsoft Corporation, 1996 // // File: htmlpop.cxx // // Contents: Implementation of the CHtmlPopup // // History: 05-27-99 YinXIE Created // //------------------------------------------------------------------------- #include "headers.hxx" #ifndef X_OTHRGUID_H_ #define X_OTHRGUID_H_ #include "othrguid.h" #endif #ifndef X_SITEGUID_H_ #define X_SITEGUID_H_ #include "siteguid.h" #endif #ifndef X_ROSTM_HXX_ #define X_ROSTM_HXX_ #include "rostm.hxx" #endif #ifndef X_CONNECT_HXX_ #define X_CONNECT_HXX_ #include "connect.hxx" #endif #ifndef X_COMMIT_HXX_ #define X_COMMIT_HXX_ #include "commit.hxx" #endif #ifndef X_DISPEX_H_ #define X_DISPEX_H_ #include "dispex.h" #endif #ifndef X_COREDISP_H_ #define X_COREDISP_H_ #include <coredisp.h> #endif #ifndef X_SHELLAPI_H_ #define X_SHELLAPI_H_ #include <shellapi.h> #endif #ifndef X_MULTIMON_H_ #define X_MULTIMON_H_ #include <multimon.h> #endif #ifndef X_HTMLPOP_HXX_ #define X_HTMLPOP_HXX_ #include "htmlpop.hxx" #endif #ifndef X_FUNCSIG_HXX_ #define X_FUNCSIG_HXX_ #include "funcsig.hxx" #endif #ifndef X_COMMCTRL_H_ #define X_COMMCTRL_H_ #define WINCOMMCTRLAPI #include <commctrl.h> #endif #ifndef X_ELEMENT_HXX_ #define X_ELEMENT_HXX_ #include "element.hxx" #endif #ifndef X_MARKUP_HXX_ #define X_MARKUP_HXX_ #include "markup.hxx" #endif #ifndef X_HEDELEMS_HXX_ #define X_HEDELEMS_HXX_ #include "hedelems.hxx" #endif #ifndef X_PROPS_HXX_ #define X_PROPS_HXX_ #include "props.hxx" // for MAKEUNITVALUE macro. #endif #ifndef X_CFPF_HXX_ #define X_CFPF_HXX_ #include "cfpf.hxx" // for propdesc components #endif #ifndef X_STYLE_HXX_ #define X_STYLE_HXX_ #include "style.hxx" // for CSSParser #endif // True if we run on unicode operating system extern BOOL g_fUnicodePlatform; #define _cxx_ #include "htmlpop.hdl" DeclareTag(tagHTMLPopupMethods, "HTML Popup", "Methods on the html popup") MtDefine(Popup, Mem, "Popup") MtDefine(CHTMLPopup, Popup, "CHTMLPopup") MtDefine(CHTMLPopupFactory, Popup, "CHTMLPopupFactory") const CBase::CLASSDESC CHTMLPopup::s_classdesc = { &CLSID_HTMLPopup, // _pclsid 0, // _idrBase #ifndef NO_PROPERTY_PAGE NULL, // _apClsidPages #endif // NO_PROPERTY_PAGE NULL, // _pcpi 0, // _dwFlags &IID_IHTMLPopup, // _piidDispinterface &s_apHdlDescs, // _apHdlDesc }; MtDefine(CHTMLPopup_s_aryStackPopup_pv, CHTMLPopup, "CHTMLPopup::_aryStackPopup::_pv"); HHOOK CHTMLPopup::s_hhookMouse = 0; // REVIEW alexmog: this calls a global constructor. Can we avoid it? CStackAryPopup CHTMLPopup::s_aryStackPopup; typedef HMONITOR (WINAPI* PFNMONITORFROMPOINT)(POINT, DWORD); typedef BOOL (WINAPI* PFNGETMONITORINFO)(HMONITOR, LPMONITORINFO); PFNMONITORFROMPOINT g_pfnMonitorFromPoint = NULL; PFNGETMONITORINFO g_pfnGetMonitorInfo = NULL; BOOL g_fMutlimonInitialized = FALSE; BOOL InitMultimonFuncs() { if (g_fMutlimonInitialized) return g_pfnGetMonitorInfo != NULL; g_pfnGetMonitorInfo = (PFNGETMONITORINFO)GetProcAddress(GetModuleHandleA("user32"), "GetMonitorInfoA"); if (g_pfnGetMonitorInfo != NULL) { g_pfnMonitorFromPoint = (PFNMONITORFROMPOINT)GetProcAddress(GetModuleHandleA("user32"), "MonitorFromPoint"); if (g_pfnMonitorFromPoint == NULL) { g_pfnGetMonitorInfo = NULL; } } g_fMutlimonInitialized = TRUE; return g_pfnGetMonitorInfo != NULL; } //+------------------------------------------------------------------------- // // Function: PopupMouseProc // // Synopsis: //-------------------------------------------------------------------------- static LRESULT CALLBACK PopupMouseProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode < 0) /* do not process the message */ goto Cleanup; if (nCode == HC_ACTION) { Assert(CHTMLPopup::s_aryStackPopup.Size()); MOUSEHOOKSTRUCT * pmh = (MOUSEHOOKSTRUCT *) lParam; int i; if ( wParam != WM_LBUTTONDOWN && wParam != WM_MBUTTONDOWN && wParam != WM_RBUTTONDOWN && wParam != WM_NCLBUTTONDOWN && wParam != WM_NCMBUTTONDOWN && wParam != WM_NCRBUTTONDOWN ) goto Cleanup; for (i = CHTMLPopup::s_aryStackPopup.Size() - 1; i >= 0; i --) { if (PtInRect(&CHTMLPopup::s_aryStackPopup[i]->_rcView, pmh->pt)) break; CHTMLPopup::s_aryStackPopup[i]->hide(); } } Cleanup: return CallNextHookEx(CHTMLPopup::s_hhookMouse, nCode, wParam, lParam); } CBase * CreateHTMLPopup(IUnknown *pUnkOuter) { return new CHTMLPopup(pUnkOuter); } CHTMLPopupFactory g_cfHTMLPopup (CreateHTMLPopup); //+------------------------------------------------------------------------ // // Member: CHTMLPopup // // Synopsis: ctor // //------------------------------------------------------------------------- CHTMLPopup::CHTMLPopup(IUnknown *pUnkOuter) //, BOOL fTrusted, IUnknown *pUnkHost) : CBase() { TraceTag((tagHTMLPopupMethods, "constructing CHTMLPopup")); _fIsOpen = FALSE; } //+------------------------------------------------------------------------ // // Member: ~CHTMLPopup // // Synopsis: dtor // //------------------------------------------------------------------------- CHTMLPopup::~CHTMLPopup( ) { Assert(!s_hhookMouse); TraceTag((tagHTMLPopupMethods, "destroying CHTMLPopup")); } //+------------------------------------------------------------------------ // // Member: CHTMLPopup::hide // // Synopsis: Show Window // // Arguments: // //------------------------------------------------------------------------- HRESULT CHTMLPopup::hide() { HRESULT hr = S_OK; CDoc *pDoc = NULL; if (!_fIsOpen || !_pOleObj) goto Cleanup; hr = THR(_pUnkObj->QueryInterface(CLSID_HTMLDocument, (void**)&pDoc)); if (FAILED(hr) || _pWindowParent->Doc()->_pDocPopup != pDoc) goto Cleanup; hr = THR(_pOleObj->DoVerb( OLEIVERB_HIDE, NULL, &_Site, 0, 0, //GetDesktopWindow(), ENSUREOLERECT(&_rcView))); Cleanup: RRETURN(hr); } //+------------------------------------------------------------------------ // // Member: CHTMLPopup::Show // // Synopsis: Show Window // // Arguments: // // x,y,w,h: position and size of the window // pElement: IUnknown of the element, optional, if none, position abs // //------------------------------------------------------------------------- HRESULT CHTMLPopup::show( long x, long y, long w, long h, VARIANT *pElement) { HRESULT hr = S_OK; SIZEL sizel; CDoc *pDocPopup = NULL; RECT rcDesktop; BOOL fPosRelative = pElement->vt == VT_UNKNOWN || pElement->vt == VT_DISPATCH; HMONITOR hMonitor; MONITORINFO mi; IOleWindow *pIOleWnd = NULL; if (!_pUnkObj) { hr = THR(CreatePopupDoc()); if (FAILED(hr)) goto Cleanup; } Assert(_pOleObj); Assert(_pWindowParent && _pWindowParent->Doc()); if (!_pWindowParent->Doc()->InPlace()) goto Cleanup; hr = THR(_pUnkObj->QueryInterface(CLSID_HTMLDocument, (void**)&pDocPopup)); if (FAILED(hr)) goto Cleanup; // // if there is a popup window on the parant doc, hide it // if (_pWindowParent->Doc()->_pDocPopup && pDocPopup != _pWindowParent->Doc()->_pDocPopup) { IGNORE_HR(_pWindowParent->Doc()->_pDocPopup->DoVerb(OLEIVERB_HIDE, NULL, _pWindowParent->Doc()->_pDocPopup->_pClientSite, 0, NULL, NULL)); } sizel.cx = HimetricFromHPix(w); sizel.cy = HimetricFromVPix(h); IGNORE_HR(_pOleObj->SetExtent(DVASPECT_CONTENT, &sizel)); if (fPosRelative && pElement->punkVal) { CElement* pElem = NULL; CRect rc; GetWindowRect(_pWindowParent->Doc()->InPlace()->_hwnd, &rc); x = x + rc.left; y = y + rc.top; hr = THR(pElement->punkVal->QueryInterface(CLSID_CElement, (void**)&pElem)); if (FAILED(hr)) goto Cleanup; hr = THR(pElem->GetBoundingRect(&rc, RFE_SCREENCOORD)); if (FAILED(hr)) goto Cleanup; x = x + rc.left; y = y + rc.top; } if (InitMultimonFuncs()) { hMonitor = g_pfnMonitorFromPoint(CPoint(x, y), MONITOR_DEFAULTTONEAREST); mi.cbSize = sizeof(mi); g_pfnGetMonitorInfo(hMonitor, &mi); rcDesktop = mi.rcMonitor; } else { GetWindowRect(GetDesktopWindow(), &rcDesktop); } // // if the popup window goes out of desktop window space // display it inside // if (x < rcDesktop.left) { x = rcDesktop.left; } if (y < rcDesktop.top) { y = rcDesktop.top; } if (x + w > rcDesktop.right) { x = rcDesktop.right - w; } if (y + h > rcDesktop.bottom) { y = rcDesktop.bottom - h; } _rcView.left = x; _rcView.top = y; _rcView.right = x + w; _rcView.bottom = y + h; if ( _fIsOpen && _pWindowParent->Doc()->_pDocPopup && _pWindowParent->Doc()->_pDocPopup == pDocPopup) { pDocPopup->SetObjectRects(ENSUREOLERECT(&_rcView), ENSUREOLERECT(&_rcView)); } else { _pWindowParent->Doc()->_pDocPopup = pDocPopup; hr = THR(_pOleObj->DoVerb( OLEIVERB_SHOW, NULL, &_Site, 0, 0, //GetDesktopWindow(), ENSUREOLERECT(&_rcView))); if (FAILED(hr)) goto Cleanup; } hr = THR(_pUnkObj->QueryInterface(IID_IOleWindow, (void **)&pIOleWnd)); if (FAILED(hr)) goto Cleanup; IGNORE_HR(pIOleWnd->GetWindow(&_hwnd)); ReleaseInterface(pIOleWnd); if (!s_hhookMouse) { s_hhookMouse = SetWindowsHookEx( WH_MOUSE, PopupMouseProc, (HINSTANCE) NULL, GetCurrentThreadId()); } if (!_fIsOpen) { s_aryStackPopup.Append(this); _fIsOpen = TRUE; } Cleanup: RRETURN(hr); } HRESULT CHTMLPopup::CreatePopupDoc() { HRESULT hr = S_OK; IPersistMoniker *pPMk = NULL; IMoniker *pMk = NULL; IPersistStreamInit *pPSI = NULL; TCHAR *pBaseUrl; CElement *pElementBase = NULL; BOOL fDefault; CDoc *pDocPopup = NULL; IHTMLElement *pIBody = NULL; IHTMLStyle *pIStyleBody = NULL; IHTMLDocument2 *pIDoc2 = NULL; Assert(_pWindowParent && _pWindowParent->Doc()); hr = THR(CoCreateInstance(CLSID_HTMLPopupDoc, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **) &_pUnkObj)); if (FAILED(hr)) goto Cleanup; // // initialize CBase members // hr = THR(DefaultMembers()); if (FAILED(hr)) goto Cleanup; hr = THR(_pUnkObj->QueryInterface(IID_IOleObject, (void **) &_pOleObj)); if (FAILED(hr)) goto Cleanup; hr = THR(_pOleObj->SetClientSite(&_Site)); if (FAILED(hr)) goto Cleanup; hr = _pUnkObj->QueryInterface(IID_IPersistStreamInit,(void**)&pPSI); if (FAILED(hr)) goto Cleanup; hr = pPSI->InitNew(); if (FAILED(hr)) goto Cleanup; hr = THR(CMarkup::GetBaseUrl( _pWindowParent->Markup(), &pBaseUrl, pElementBase, &fDefault, NULL)); if (FAILED(hr)) goto Cleanup; hr = THR(_pUnkObj->QueryInterface(CLSID_HTMLDocument, (void**)&pDocPopup)); if (FAILED(hr)) goto Cleanup; hr = THR(_pUnkObj->QueryInterface(IID_IHTMLDocument2, (void**)&pIDoc2)); if (FAILED(hr)) goto Cleanup; pDocPopup->_pPopupParentWindow = _pWindowParent; pDocPopup->SetPrimaryUrl(pBaseUrl); pDocPopup->PrimaryMarkup()->UpdateSecurityID(); // // set the default style on the body // hr = pIDoc2->get_body(&pIBody); if (FAILED(hr)) goto Cleanup; if (!pIBody) goto Cleanup; hr = pIBody->get_style(&pIStyleBody); if (FAILED(hr)) goto Cleanup; hr = pIStyleBody->put_border(_T("0")); if (FAILED(hr)) goto Cleanup; hr = pIStyleBody->put_margin(_T("0")); if (FAILED(hr)) goto Cleanup; hr = pIStyleBody->put_padding(_T("0")); if (FAILED(hr)) goto Cleanup; hr = pIStyleBody->put_overflow(_T("hidden")); if (FAILED(hr)) goto Cleanup; Cleanup: ClearInterface(&pIDoc2); ClearInterface(&pIBody); ClearInterface(&pIStyleBody); ClearInterface(&pMk); ClearInterface(&pPMk); ClearInterface(&pPSI); RRETURN(hr); } //+------------------------------------------------------------------------ // // Member: CHTMLPopup::Passivate // // Synopsis: 1st stage destruction // //------------------------------------------------------------------------- void CHTMLPopup::Passivate() { if (_fIsOpen && _pOleObj) { hide(); } if (!_pWindowParent->IsShuttingDown()) { CDoc *pDoc = NULL; HRESULT hr = S_OK; hr = THR(_pUnkObj->QueryInterface(CLSID_HTMLDocument, (void**)&pDoc)); if (SUCCEEDED(hr) && pDoc == _pWindowParent->Doc()->_pDocPopup) { _pWindowParent->Doc()->_pDocPopup = NULL; } } ClearInterface(&_pOleObj); ClearInterface(&_pUnkObj); _pWindowParent->Release(); _pWindowParent = NULL; super::Passivate(); } //+------------------------------------------------------------------------ // // Member: CHTMLPopup::GetViewRect // // Synopsis: Get the rectangular extent of the window. // //------------------------------------------------------------------------- void CHTMLPopup::GetViewRect(RECT *prc) { *prc = _rcView; } //+------------------------------------------------------------------------ // // Member: CHTMLPopup::get_document // //------------------------------------------------------------------------- HRESULT CHTMLPopup::get_document(IHTMLDocument ** ppDoc) { HRESULT hr = S_OK; CDoc *pDocPopup = NULL; Assert (ppDoc); *ppDoc = NULL; // // if there is no doc create the doc // if (!_pUnkObj) { hr = THR(CreatePopupDoc()); if (FAILED(hr)) goto Cleanup; } Assert(_pUnkObj); hr = THR(_pUnkObj->QueryInterface(CLSID_HTMLDocument, (void**)&pDocPopup)); if (FAILED(hr)) goto Cleanup; if (!pDocPopup->PrimaryMarkup()->AccessAllowed(_pWindowParent->Markup())) { hr = E_ACCESSDENIED; goto Cleanup; } hr = THR(_pUnkObj->QueryInterface(IID_IHTMLDocument, (void**)ppDoc)); Cleanup: RRETURN(SetErrorInfo(hr)); } //+------------------------------------------------------------------------ // // Member: CHTMLPopup::get_isOpen // //------------------------------------------------------------------------- HRESULT CHTMLPopup::get_isOpen(VARIANT_BOOL * pfIsOpen) { *pfIsOpen = _fIsOpen ? VARIANT_TRUE : VARIANT_FALSE; RRETURN(S_OK); } //+------------------------------------------------------------------------ // // Member: CHTMLPopup::PrivateQueryInterface // // Synopsis: per IPrivateUnknown // //------------------------------------------------------------------------- HRESULT CHTMLPopup::PrivateQueryInterface(REFIID iid, void **ppv) { HRESULT hr = S_OK; *ppv = NULL; switch (iid.Data1) { QI_TEAROFF_DISPEX(this, NULL) QI_TEAROFF(this, IObjectIdentity, NULL) QI_INHERITS((IPrivateUnknown *)this, IUnknown) QI_TEAROFF(this, IHTMLPopup, NULL) default: if (iid == CLSID_HTMLPopup) { *ppv = this; goto Cleanup; } break; } if (!*ppv) { hr = E_NOINTERFACE; } else { ((IUnknown *)*ppv)->AddRef(); hr = S_OK; } Cleanup: RRETURN_NOTRACE(hr); } void CHTMLPopup::ClearPopupInParentDoc() { if (!_fIsOpen) return; _fIsOpen = FALSE; if (_pWindowParent && _pWindowParent->Doc()) { _pWindowParent->Doc()->_pDocPopup = NULL; } if (s_hhookMouse) { int iSizeStack = s_aryStackPopup.Size(); int i; Assert(iSizeStack); for (i = iSizeStack - 1; i >= 0; i --) { // BOOL fFound = s_aryStackPopup[i] == this; if (s_aryStackPopup[i] == this) { s_aryStackPopup.Delete(i); break; } } if (!s_aryStackPopup.Size()) { UnhookWindowsHookEx(s_hhookMouse); s_hhookMouse = NULL; } } }
[ "polarisdp@gmail.com" ]
polarisdp@gmail.com
8ae62553847dd86063ffccaab6694e12b92bfbd1
1d3c46aee4b676d0f53194ab3afef8ba11f1ea20
/FluxEngine/Rendering/Drawable.h
4ee5219e7bd2dc5ab190fda9481a5c30a2b342fb
[ "MIT" ]
permissive
echofriendly/FluxEngine
fe2d3752b224a2b92fe064c8e4f3f24f70ddc000
e77f34223cd70f011af18b8acedc41ccdb6311ca
refs/heads/master
2020-04-14T08:47:35.497127
2018-08-21T21:07:22
2018-08-21T21:07:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
992
h
#pragma once #include "Scenegraph/Component.h" class Scene; class SceneNode; class Material; class Geometry; struct Batch { const Material* pMaterial = nullptr; const Geometry* pGeometry = nullptr; const Matrix* pModelMatrix = nullptr; const Matrix* pSkinMatrices = nullptr; int NumSkinMatrices = 1; }; class Drawable : public Component { FLUX_OBJECT(Drawable, Component) public: Drawable(Context* pContext) : Component(pContext) {} virtual ~Drawable() {} virtual void Update() {} virtual void OnSceneSet(Scene* pScene) override; std::vector<Batch>& GetBatches() { return m_Batches; } void SetCullingEnabled(const bool enabled) { m_Cull = enabled; } bool GetCullingEnabled() const { return m_Cull; } const BoundingBox& GetBoundingBox() const { return m_BoundingBox; } BoundingBox GetWorldBoundingBox() const; bool DrawEnabled() const { return m_Draw; } protected: bool m_Draw = true; bool m_Cull = true; std::vector<Batch> m_Batches; BoundingBox m_BoundingBox; };
[ "sim2.coenen@gmail.com" ]
sim2.coenen@gmail.com
046a9eaa5e6fe493445eb277f24ef30d2277ea1c
553298299eed97e2c22835bb7c3912f5006c3c28
/Common/Obj8/Comment.cpp
ab2b38f4ce2a2f0d37c32fcb32a756fff5af4e4a
[]
no_license
SchaichAlonso/StaticsMapping
853d8f8bd6df0f02b755830902ba36199278d7f9
9b33139f853a45e3c1a3535d445e89ba6772f9e5
refs/heads/master
2022-11-03T03:09:14.964266
2022-10-19T17:02:10
2022-10-19T17:02:10
110,700,210
1
1
null
null
null
null
UTF-8
C++
false
false
1,011
cpp
#include "Parser/SyntaxError.hpp" #include "Comment.hpp" Obj8::Comment::Comment () : Record () { } Obj8::Comment::Comment (StringRef str, Parser::LexerContext *ctx, int flags) : Record (str, ctx, Parser::Word::ConsumeRemainingLine | flags) { if (not qualified (m_identifier)) { throw (Parser::SyntaxError(ctx)); } } Obj8::Comment::~Comment () { } bool Obj8::Comment::qualified (Parser::Word w) { StringRef id = w.value (); String::ConstIterator i, e; bool retval; i = id.constBegin (); e = id.constEnd (); if (i == e) { retval = false; } else { if (*i == '#') { retval = true; } else { retval = false; } } return (retval); } void Obj8::Comment::accept (AbstractVisitor *, bool) { } Obj8::RecordPointer Obj8::Comment::instantiate (StringRef str, Parser::LexerContext *ctx) const { return (RecordPointer (new Comment (str, ctx))); } Obj8::String Obj8::Comment::name () const { Q_ASSERT (false); return (String ()); }
[ "alonso.schaich@sodgeit.de" ]
alonso.schaich@sodgeit.de
4a3beda182e3c008ea4b79052dcb04531257e33c
7e791eccdc4d41ba225a90b3918ba48e356fdd78
/chromium/src/chrome/browser/ui/views/frame/browser_non_client_frame_view_mus.cc
191a03a512377373f533229b76f5aadfb12a427d
[ "BSD-3-Clause" ]
permissive
WiViClass/cef-3.2623
4e22b763a75e90d10ebf9aa3ea9a48a3d9ccd885
17fe881e9e481ef368d9f26e903e00a6b7bdc018
refs/heads/master
2021-01-25T04:38:14.941623
2017-06-09T07:37:43
2017-06-09T07:37:43
93,824,379
2
1
null
null
null
null
UTF-8
C++
false
false
25,743
cc
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_mus.h" #include <algorithm> #include "base/profiler/scoped_tracker.h" #include "build/build_config.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/views/frame/browser_frame.h" #include "chrome/browser/ui/views/frame/browser_frame_mus.h" #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" #include "chrome/browser/ui/views/frame/web_app_left_header_view_ash.h" #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" #include "chrome/browser/ui/views/tab_icon_view.h" #include "chrome/browser/ui/views/tabs/tab_strip.h" #include "chrome/browser/web_applications/web_app.h" #include "components/mus/public/cpp/window.h" #include "components/signin/core/common/profile_management_switches.h" #include "content/public/browser/web_contents.h" #include "extensions/browser/extension_registry.h" #include "grit/theme_resources.h" #include "ui/accessibility/ax_view_state.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/window.h" #include "ui/base/hit_test.h" #include "ui/base/layout.h" #include "ui/base/resource/material_design/material_design_controller.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/theme_provider.h" #include "ui/compositor/layer_animator.h" #include "ui/gfx/canvas.h" #include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/scoped_canvas.h" #include "ui/views/controls/label.h" #include "ui/views/layout/layout_constants.h" #include "ui/views/mus/window_manager_frame_values.h" #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" #if defined(ENABLE_SUPERVISED_USERS) #include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h" #endif namespace { #if defined(FRAME_AVATAR_BUTTON) // Space between the new avatar button and the minimize button. const int kNewAvatarButtonOffset = 5; #endif // Space between right edge of tabstrip and maximize button. const int kTabstripRightSpacing = 10; // Height of the shadow of the content area, at the top of the toolbar. const int kContentShadowHeight = 1; // Space between top of window and top of tabstrip for tall headers, such as // for restored windows, apps, etc. const int kTabstripTopSpacingTall = 4; // Space between top of window and top of tabstrip for short headers, such as // for maximized windows, pop-ups, etc. const int kTabstripTopSpacingShort = 0; // Height of the shadow in the tab image, used to ensure clicks in the shadow // area still drag restored windows. This keeps the clickable area large enough // to hit easily. const int kTabShadowHeight = 4; // Combines View::ConvertPointToTarget() and View::HitTest() for a given // |point|. Converts |point| from |src| to |dst| and hit tests it against |dst|. bool ConvertedHitTest(views::View* src, views::View* dst, const gfx::Point& point) { DCHECK(src); DCHECK(dst); gfx::Point converted_point(point); views::View::ConvertPointToTarget(src, dst, &converted_point); return dst->HitTestPoint(converted_point); } const views::WindowManagerFrameValues& frame_values() { return views::WindowManagerFrameValues::instance(); } } // namespace /////////////////////////////////////////////////////////////////////////////// // BrowserNonClientFrameViewMus, public: // static const char BrowserNonClientFrameViewMus::kViewClassName[] = "BrowserNonClientFrameViewMus"; BrowserNonClientFrameViewMus::BrowserNonClientFrameViewMus( BrowserFrame* frame, BrowserView* browser_view) : BrowserNonClientFrameView(frame, browser_view), web_app_left_header_view_(nullptr), window_icon_(nullptr), tab_strip_(nullptr) {} BrowserNonClientFrameViewMus::~BrowserNonClientFrameViewMus() { if (tab_strip_) { tab_strip_->RemoveObserver(this); tab_strip_ = nullptr; } } void BrowserNonClientFrameViewMus::Init() { // Initializing the TabIconView is expensive, so only do it if we need to. if (browser_view()->ShouldShowWindowIcon()) { window_icon_ = new TabIconView(this, nullptr); window_icon_->set_is_light(true); AddChildView(window_icon_); window_icon_->Update(); } UpdateAvatar(); } /////////////////////////////////////////////////////////////////////////////// // BrowserNonClientFrameView: void BrowserNonClientFrameViewMus::OnBrowserViewInitViewsComplete() { DCHECK(browser_view()->tabstrip()); DCHECK(!tab_strip_); tab_strip_ = browser_view()->tabstrip(); tab_strip_->AddObserver(this); } gfx::Rect BrowserNonClientFrameViewMus::GetBoundsForTabStrip( views::View* tabstrip) const { if (!tabstrip) return gfx::Rect(); // When the tab strip is painted in the immersive fullscreen light bar style, // the caption buttons and the avatar button are not visible. However, their // bounds are still used to compute the tab strip bounds so that the tabs have // the same horizontal position when the tab strip is painted in the immersive // light bar style as when the top-of-window views are revealed. int left_inset = GetTabStripLeftInset(); int right_inset = GetTabStripRightInset(); return gfx::Rect(left_inset, GetTopInset(false), std::max(0, width() - left_inset - right_inset), tabstrip->GetPreferredSize().height()); } int BrowserNonClientFrameViewMus::GetTopInset(bool restored) const { if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) return 0; if (browser_view()->IsTabStripVisible()) { return ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored) ? kTabstripTopSpacingShort : kTabstripTopSpacingTall; } int caption_buttons_bottom = frame_values().normal_insets.top(); // The toolbar partially overlaps the caption buttons. if (browser_view()->IsToolbarVisible()) return caption_buttons_bottom - kContentShadowHeight; return caption_buttons_bottom + kClientEdgeThickness; } int BrowserNonClientFrameViewMus::GetThemeBackgroundXInset() const { return 5; } void BrowserNonClientFrameViewMus::UpdateThrobber(bool running) { if (window_icon_) window_icon_->Update(); } void BrowserNonClientFrameViewMus::UpdateToolbar() { if (web_app_left_header_view_) web_app_left_header_view_->Update(); } views::View* BrowserNonClientFrameViewMus::GetLocationIconView() const { if (web_app_left_header_view_) return web_app_left_header_view_->GetLocationIconView(); return nullptr; } /////////////////////////////////////////////////////////////////////////////// // views::NonClientFrameView: gfx::Rect BrowserNonClientFrameViewMus::GetBoundsForClientView() const { // The ClientView must be flush with the top edge of the widget so that the // web contents can take up the entire screen in immersive fullscreen (with // or without the top-of-window views revealed). When in immersive fullscreen // and the top-of-window views are revealed, the TopContainerView paints the // window header by redirecting paints from its background to // BrowserNonClientFrameViewMus. return bounds(); } gfx::Rect BrowserNonClientFrameViewMus::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { return client_bounds; } int BrowserNonClientFrameViewMus::NonClientHitTest(const gfx::Point& point) { // TODO(sky): figure out how this interaction should work. int hit_test = HTCLIENT; #if defined(FRAME_AVATAR_BUTTON) if (hit_test == HTCAPTION && new_avatar_button() && ConvertedHitTest(this, new_avatar_button(), point)) { return HTCLIENT; } #endif // See if the point is actually within the web app back button. if (hit_test == HTCAPTION && web_app_left_header_view_ && ConvertedHitTest(this, web_app_left_header_view_, point)) { return HTCLIENT; } #if defined(ENABLE_SUPERVISED_USERS) // ...or within the avatar label, if it's a supervised user. if (hit_test == HTCAPTION && supervised_user_avatar_label() && ConvertedHitTest(this, supervised_user_avatar_label(), point)) { return HTCLIENT; } #endif // When the window is restored we want a large click target above the tabs // to drag the window, so redirect clicks in the tab's shadow to caption. if (hit_test == HTCLIENT && !(frame()->IsMaximized() || frame()->IsFullscreen())) { // Convert point to client coordinates. gfx::Point client_point(point); View::ConvertPointToTarget(this, frame()->client_view(), &client_point); // Report hits in shadow at top of tabstrip as caption. gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); if (client_point.y() < tabstrip_bounds.y() + kTabShadowHeight) hit_test = HTCAPTION; } return hit_test; } void BrowserNonClientFrameViewMus::GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) { // Aura does not use window masks. } void BrowserNonClientFrameViewMus::ResetWindowControls() {} void BrowserNonClientFrameViewMus::UpdateWindowIcon() { if (window_icon_) window_icon_->SchedulePaint(); } void BrowserNonClientFrameViewMus::UpdateWindowTitle() {} void BrowserNonClientFrameViewMus::SizeConstraintsChanged() {} /////////////////////////////////////////////////////////////////////////////// // views::View: void BrowserNonClientFrameViewMus::OnPaint(gfx::Canvas* canvas) { if (!ShouldPaint()) return; // TODO(sky): get immersive mode working. if (UseImmersiveLightbarHeaderStyle()) { PaintImmersiveLightbarStyleHeader(canvas); return; } if (web_app_left_header_view_) web_app_left_header_view_->SetPaintAsActive(ShouldPaintAsActive()); if (browser_view()->IsToolbarVisible()) PaintToolbarBackground(canvas); else if (!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()) PaintContentEdge(canvas); } void BrowserNonClientFrameViewMus::Layout() { if (avatar_button()) LayoutAvatar(); #if defined(FRAME_AVATAR_BUTTON) if (new_avatar_button()) LayoutNewStyleAvatar(); #endif BrowserNonClientFrameView::Layout(); UpdateClientArea(); } const char* BrowserNonClientFrameViewMus::GetClassName() const { return kViewClassName; } void BrowserNonClientFrameViewMus::GetAccessibleState(ui::AXViewState* state) { state->role = ui::AX_ROLE_TITLE_BAR; } gfx::Size BrowserNonClientFrameViewMus::GetMinimumSize() const { gfx::Size min_client_view_size(frame()->client_view()->GetMinimumSize()); const int min_frame_width = frame_values().max_title_bar_button_width + frame_values().normal_insets.width(); int min_width = std::max(min_frame_width, min_client_view_size.width()); if (browser_view()->IsTabStripVisible()) { // Ensure that the minimum width is enough to hold a minimum width tab strip // at its usual insets. int min_tabstrip_width = browser_view()->tabstrip()->GetMinimumSize().width(); min_width = std::max(min_width, min_tabstrip_width + GetTabStripLeftInset() + GetTabStripRightInset()); } return gfx::Size(min_width, min_client_view_size.height()); } void BrowserNonClientFrameViewMus::ChildPreferredSizeChanged( views::View* child) { // FrameCaptionButtonContainerView animates the visibility changes in // UpdateSizeButtonVisibility(false). Due to this a new size is not available // until the completion of the animation. Layout in response to the preferred // size changes. if (!browser_view()->initialized()) return; bool needs_layout = false; #if defined(FRAME_AVATAR_BUTTON) needs_layout = needs_layout || child == new_avatar_button(); #endif if (needs_layout) { InvalidateLayout(); frame()->GetRootView()->Layout(); } } /////////////////////////////////////////////////////////////////////////////// // TabIconViewModel: bool BrowserNonClientFrameViewMus::ShouldTabIconViewAnimate() const { // This function is queried during the creation of the window as the // TabIconView we host is initialized, so we need to null check the selected // WebContents because in this condition there is not yet a selected tab. content::WebContents* current_tab = browser_view()->GetActiveWebContents(); return current_tab ? current_tab->IsLoading() : false; } gfx::ImageSkia BrowserNonClientFrameViewMus::GetFaviconForTabIconView() { views::WidgetDelegate* delegate = frame()->widget_delegate(); if (!delegate) return gfx::ImageSkia(); return delegate->GetWindowIcon(); } /////////////////////////////////////////////////////////////////////////////// // views::ButtonListener: void BrowserNonClientFrameViewMus::ButtonPressed(views::Button* sender, const ui::Event& event) { #if !defined(FRAME_AVATAR_BUTTON) NOTREACHED(); #else DCHECK(sender == new_avatar_button()); int command = IDC_SHOW_AVATAR_MENU; if (event.IsMouseEvent() && static_cast<const ui::MouseEvent&>(event).IsRightMouseButton()) { command = IDC_SHOW_FAST_USER_SWITCHER; } chrome::ExecuteCommand(browser_view()->browser(), command); #endif } /////////////////////////////////////////////////////////////////////////////// // BrowserNonClientFrameViewMus, protected: // BrowserNonClientFrameView: void BrowserNonClientFrameViewMus::UpdateNewAvatarButtonImpl() { #if defined(FRAME_AVATAR_BUTTON) UpdateNewAvatarButton(this, NewAvatarButton::NATIVE_BUTTON); #endif } /////////////////////////////////////////////////////////////////////////////// // BrowserNonClientFrameViewMus, private: mus::Window* BrowserNonClientFrameViewMus::mus_window() { return static_cast<BrowserFrameMus*>(frame()->native_widget())->window(); } void BrowserNonClientFrameViewMus::UpdateClientArea() { std::vector<gfx::Rect> additional_client_area; if (tab_strip_) { gfx::Rect tab_strip_bounds(GetBoundsForTabStrip(tab_strip_)); if (!tab_strip_bounds.IsEmpty() && tab_strip_->max_x()) { tab_strip_bounds.set_width(tab_strip_->max_x()); additional_client_area.push_back(tab_strip_bounds); } } mus_window()->SetClientArea( views::WindowManagerFrameValues::instance().normal_insets, additional_client_area); } void BrowserNonClientFrameViewMus::TabStripMaxXChanged(TabStrip* tab_strip) { UpdateClientArea(); } void BrowserNonClientFrameViewMus::TabStripDeleted(TabStrip* tab_strip) { tab_strip_->RemoveObserver(this); tab_strip_ = nullptr; } bool BrowserNonClientFrameViewMus::DoesIntersectRect( const views::View* target, const gfx::Rect& rect) const { CHECK_EQ(target, this); if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { // |rect| is outside BrowserNonClientFrameViewMus's bounds. return false; } TabStrip* tabstrip = browser_view()->tabstrip(); if (tabstrip && browser_view()->IsTabStripVisible()) { // Claim |rect| only if it is above the bottom of the tabstrip in a non-tab // portion. gfx::RectF rect_in_tabstrip_coords_f(rect); View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f); gfx::Rect rect_in_tabstrip_coords = gfx::ToEnclosingRect(rect_in_tabstrip_coords_f); if (rect_in_tabstrip_coords.y() > tabstrip->height()) return false; return !tabstrip->HitTestRect(rect_in_tabstrip_coords) || tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); } // Claim |rect| if it is above the top of the topmost view in the client area. return rect.y() < GetTopInset(false); } int BrowserNonClientFrameViewMus::GetTabStripLeftInset() const { const gfx::Insets insets(GetLayoutInsets(AVATAR_ICON)); const int avatar_right = avatar_button() ? (insets.left() + browser_view()->GetOTRAvatarIcon().width()) : 0; return avatar_right + insets.right() + frame_values().normal_insets.left(); } int BrowserNonClientFrameViewMus::GetTabStripRightInset() const { const int frame_right_insets = frame_values().normal_insets.right() + frame_values().max_title_bar_button_width; int right_inset = kTabstripRightSpacing + frame_right_insets; #if defined(FRAME_AVATAR_BUTTON) if (new_avatar_button()) { right_inset += kNewAvatarButtonOffset + new_avatar_button()->GetPreferredSize().width(); } #endif return right_inset; } bool BrowserNonClientFrameViewMus::UseImmersiveLightbarHeaderStyle() const { ImmersiveModeController* immersive_controller = browser_view()->immersive_mode_controller(); return immersive_controller->IsEnabled() && !immersive_controller->IsRevealed() && browser_view()->IsTabStripVisible(); } bool BrowserNonClientFrameViewMus::UsePackagedAppHeaderStyle() const { Browser* browser = browser_view()->browser(); // For non tabbed trusted source windows, e.g. Settings, use the packaged // app style frame. if (!browser->is_type_tabbed() && browser->is_trusted_source()) return true; // Use the packaged app style for apps that aren't using the newer WebApp // style. return browser->is_app() && !UseWebAppHeaderStyle(); } bool BrowserNonClientFrameViewMus::UseWebAppHeaderStyle() const { return browser_view()->browser()->SupportsWindowFeature( Browser::FEATURE_WEBAPPFRAME); } void BrowserNonClientFrameViewMus::LayoutAvatar() { DCHECK(avatar_button()); #if !defined(OS_CHROMEOS) // ChromeOS shows avatar on V1 app. DCHECK(browser_view()->IsTabStripVisible()); #endif gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); gfx::Insets avatar_insets = GetLayoutInsets(AVATAR_ICON); int avatar_bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() - avatar_insets.bottom(); int avatar_y = avatar_bottom - incognito_icon.height(); if (!ui::MaterialDesignController::IsModeMaterial() && browser_view()->IsTabStripVisible() && (frame()->IsMaximized() || frame()->IsFullscreen())) { avatar_y = GetTopInset(false) + kContentShadowHeight; } // Hide the incognito icon in immersive fullscreen when the tab light bar is // visible because the header is too short for the icognito icon to be // recognizable. bool avatar_visible = !UseImmersiveLightbarHeaderStyle(); int avatar_height = avatar_visible ? avatar_bottom - avatar_y : 0; gfx::Rect avatar_bounds(avatar_insets.left(), avatar_y, incognito_icon.width(), avatar_height); avatar_button()->SetBoundsRect(avatar_bounds); avatar_button()->SetVisible(avatar_visible); } #if defined(FRAME_AVATAR_BUTTON) void BrowserNonClientFrameViewMus::LayoutNewStyleAvatar() { DCHECK(new_avatar_button()); gfx::Size button_size = new_avatar_button()->GetPreferredSize(); int button_x = width() - caption_button_container_->GetPreferredSize().width() - kNewAvatarButtonOffset - button_size.width(); new_avatar_button()->SetBounds( button_x, 0, button_size.width(), caption_button_container_->GetPreferredSize().height()); } #endif bool BrowserNonClientFrameViewMus::ShouldPaint() const { if (!frame()->IsFullscreen()) return true; // We need to paint when in immersive fullscreen and either: // - The top-of-window views are revealed. // - The lightbar style tabstrip is visible. ImmersiveModeController* immersive_mode_controller = browser_view()->immersive_mode_controller(); return immersive_mode_controller->IsEnabled() && (immersive_mode_controller->IsRevealed() || UseImmersiveLightbarHeaderStyle()); } void BrowserNonClientFrameViewMus::PaintImmersiveLightbarStyleHeader( gfx::Canvas* canvas) {} void BrowserNonClientFrameViewMus::PaintToolbarBackground(gfx::Canvas* canvas) { gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); if (toolbar_bounds.IsEmpty()) return; gfx::Point toolbar_origin(toolbar_bounds.origin()); View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); toolbar_bounds.set_origin(toolbar_origin); int x = toolbar_bounds.x(); int w = toolbar_bounds.width(); int y = toolbar_bounds.y(); int h = toolbar_bounds.height(); const ui::ThemeProvider* tp = GetThemeProvider(); if (ui::MaterialDesignController::IsModeMaterial()) { // Paint the main toolbar image. Since this image is also used to draw the // tab background, we must use the tab strip offset to compute the image // source y position. If you have to debug this code use an image editor // to paint a diagonal line through the toolbar image and ensure it lines up // across the tab and toolbar. gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); canvas->TileImageInt(*theme_toolbar, x + GetThemeBackgroundXInset(), y - GetTopInset(false), x, y, w, theme_toolbar->height()); // Draw the separator line atop the toolbar, on the left and right of the // tabstrip. // TODO(tdanderson): Draw the separator line for non-tabbed windows. if (browser_view()->IsTabStripVisible()) { gfx::Rect separator_rect(x, y, w, 0); gfx::ScopedCanvas scoped_canvas(canvas); gfx::Rect tabstrip_bounds( GetBoundsForTabStrip(browser_view()->tabstrip())); tabstrip_bounds.set_x(GetMirroredXForRect(tabstrip_bounds)); canvas->sk_canvas()->clipRect(gfx::RectToSkRect(tabstrip_bounds), SkRegion::kDifference_Op); separator_rect.set_y(tabstrip_bounds.bottom()); BrowserView::Paint1pxHorizontalLine( canvas, tp->GetColor(ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR), separator_rect, true); } // Draw the content/toolbar separator. toolbar_bounds.Inset(kClientEdgeThickness, 0); BrowserView::Paint1pxHorizontalLine( canvas, tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR), toolbar_bounds, true); } else { // Gross hack: We split the toolbar images into two pieces, since sometimes // (popup mode) the toolbar isn't tall enough to show the whole image. The // split happens between the top shadow section and the bottom gradient // section so that we never break the gradient. // NOTE(pkotwicz): If the computation for |bottom_y| is changed, Layout() // must be changed as well. int split_point = kFrameShadowThickness * 2; int bottom_y = y + split_point; int bottom_edge_height = h - split_point; canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); // Paint the main toolbar image. Since this image is also used to draw the // tab background, we must use the tab strip offset to compute the image // source y position. If you have to debug this code use an image editor // to paint a diagonal line through the toolbar image and ensure it lines up // across the tab and toolbar. gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); canvas->TileImageInt(*theme_toolbar, x + GetThemeBackgroundXInset(), bottom_y - GetTopInset(false), x, bottom_y, w, theme_toolbar->height()); // The pre-material design content area line has a shadow that extends a // couple of pixels above the toolbar bounds. const int kContentShadowHeight = 2; gfx::ImageSkia* toolbar_top = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_TOP); canvas->TileImageInt(*toolbar_top, 0, 0, x, y - kContentShadowHeight, w, split_point + kContentShadowHeight + 1); // Draw the "lightening" shade line around the edges of the toolbar. gfx::ImageSkia* toolbar_left = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_LEFT); canvas->TileImageInt(*toolbar_left, 0, 0, x + kClientEdgeThickness, y + kClientEdgeThickness + kContentShadowHeight, toolbar_left->width(), theme_toolbar->height()); gfx::ImageSkia* toolbar_right = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_RIGHT); canvas->TileImageInt(*toolbar_right, 0, 0, w - toolbar_right->width() - 2 * kClientEdgeThickness, y + kClientEdgeThickness + kContentShadowHeight, toolbar_right->width(), theme_toolbar->height()); // Draw the content/toolbar separator. canvas->FillRect( gfx::Rect(x + kClientEdgeThickness, toolbar_bounds.bottom() - kClientEdgeThickness, w - (2 * kClientEdgeThickness), kClientEdgeThickness), tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR)); } } void BrowserNonClientFrameViewMus::PaintContentEdge(gfx::Canvas* canvas) { DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); const int bottom = frame_values().normal_insets.bottom(); canvas->FillRect( gfx::Rect(0, bottom, width(), kClientEdgeThickness), GetThemeProvider()->GetColor( ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR)); }
[ "1480868058@qq.com" ]
1480868058@qq.com
39f3ec3bf2708f89fe471391f30996ca979e1a81
dd5d0b8fd7cb9769a45760f5b15c73a5146baf17
/src/BSQL/Library.cpp
8965905edce42f1bb488eef6d640c20c62727436
[ "MIT" ]
permissive
praisenarsie/BSQL
7ab71df6fb372478e08f9098ef9b007dce42a990
afaddc94ff27f8d892926867601a3ece6ff38837
refs/heads/master
2020-03-19T10:41:58.230694
2018-06-06T22:36:28
2018-06-06T22:36:28
136,393,766
0
0
null
2018-06-06T22:42:51
2018-06-06T22:42:50
null
UTF-8
C++
false
false
927
cpp
#include "BSQL.h" Library::Library() noexcept : identifierCounter(0) {} Connection* Library::GetConnection(const std::string& identifier) noexcept { auto iter(connections.find(identifier)); if (iter == connections.end()) return nullptr; return iter->second.get(); } bool Library::ReleaseConnection(const std::string& identifier) noexcept { return connections.erase(identifier) > 0; } std::string Library::CreateConnection(Connection::Type type) noexcept { if (identifierCounter < std::numeric_limits<unsigned long long>().max()) { try { auto identifier(std::to_string(++identifierCounter)); switch (type) { case Connection::Type::MySql: connections.emplace(identifier, std::make_unique<MySqlConnection>()); break; case Connection::Type::SqlServer: --identifierCounter; return std::string(); } return identifier; } catch (std::bad_alloc&) { } } return std::string(); }
[ "Cyberboss@users.noreply.github.com" ]
Cyberboss@users.noreply.github.com
5892d4d5447a8577cc5a1f87ac50c994994a958c
a6752e9d5296c5628ba16771bef009b4607c919b
/cpp_src/core/itemimpl.h
540ac34d23f45af1be1959887d3d3e9ff90e8bb5
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
sagpant/reindexer
ae8c8c547a1e4beec4182615e1b4565f9a916bd9
54bf5ad40f3590e9b4dd6287f21e3b4774c8ae2c
refs/heads/master
2022-11-12T22:38:58.310850
2020-06-12T10:50:26
2020-06-12T10:50:26
274,374,431
3
2
null
null
null
null
UTF-8
C++
false
false
3,680
h
#pragma once #include <deque> #include <vector> #include "core/cjson/tagsmatcher.h" #include "core/keyvalue/key_string.h" #include "core/keyvalue/variant.h" #include "core/payload/payloadiface.h" #include "tools/serializer.h" using std::vector; namespace reindexer { struct ItemImplRawData { ItemImplRawData(PayloadValue v) : payloadValue_(v) {} ItemImplRawData() {} ItemImplRawData(const ItemImplRawData &) = delete; ItemImplRawData(ItemImplRawData &&) noexcept; ItemImplRawData &operator=(const ItemImplRawData &) = delete; ItemImplRawData &operator=(ItemImplRawData &&) noexcept; PayloadValue payloadValue_; std::unique_ptr<uint8_t[]> tupleData_; std::unique_ptr<char[]> sourceData_; vector<string> precepts_; std::unique_ptr<std::deque<std::string>> holder_; }; class Namespace; class ItemImpl : public ItemImplRawData { public: // Construct empty item ItemImpl(PayloadType type, const TagsMatcher &tagsMatcher, const FieldsSet &pkFields = {}) : ItemImplRawData(PayloadValue(type.TotalSize(), 0, type.TotalSize() + 0x100)), payloadType_(type), tagsMatcher_(tagsMatcher), pkFields_(pkFields) { tagsMatcher_.clearUpdated(); } // Construct empty item ItemImpl(PayloadType type, const TagsMatcher &tagsMatcher, const FieldsSet &pkFields, ItemImplRawData &&rawData) : ItemImplRawData(std::move(rawData)), payloadType_(type), tagsMatcher_(tagsMatcher), pkFields_(pkFields) {} ItemImpl(PayloadType type, PayloadValue v, const TagsMatcher &tagsMatcher) : ItemImplRawData(v), payloadType_(type), tagsMatcher_(tagsMatcher) { tagsMatcher_.clearUpdated(); } ItemImpl(const ItemImpl &) = delete; ItemImpl(ItemImpl &&) = default; ItemImpl &operator=(const ItemImpl &) = delete; ItemImpl &operator=(ItemImpl &&) noexcept; void ModifyField(string_view jsonPath, const VariantArray &keys, FieldModifyMode mode); void SetField(int field, const VariantArray &krs); void SetField(string_view jsonPath, const VariantArray &keys); void DropField(string_view jsonPath); Variant GetField(int field); FieldsSet PkFields() const { return pkFields_; } VariantArray GetValueByJSONPath(string_view jsonPath); string_view GetJSON(); Error FromJSON(const string_view &slice, char **endp = nullptr, bool pkOnly = false); Error FromCJSON(ItemImpl *other); string_view GetCJSON(bool withTagsMatcher = false); string_view GetCJSON(WrSerializer &ser, bool withTagsMatcher = false); Error FromCJSON(const string_view &slice, bool pkOnly = false); PayloadType Type() { return payloadType_; } PayloadValue &Value() { return payloadValue_; } PayloadValue &RealValue() { return realValue_; } Payload GetPayload() { return Payload(payloadType_, payloadValue_); } TagsMatcher &tagsMatcher() { return tagsMatcher_; } void SetPrecepts(const vector<string> &precepts) { precepts_ = precepts; cjson_ = string_view(); } const vector<string> &GetPrecepts() { return precepts_; } void Unsafe(bool enable) { unsafe_ = enable; } void Clear() { tagsMatcher_ = TagsMatcher(); precepts_.clear(); cjson_ = string_view(); holder_.reset(); sourceData_.reset(); tupleData_.reset(); ser_ = WrSerializer(); GetPayload().Reset(); payloadValue_.SetLSN(-1); unsafe_ = false; ns_.reset(); realValue_ = PayloadValue(); } void SetNamespace(std::shared_ptr<Namespace> ns) { ns_ = std::move(ns); } std::shared_ptr<Namespace> GetNamespace() { return ns_; } protected: // Index fields payload data PayloadType payloadType_; PayloadValue realValue_; TagsMatcher tagsMatcher_; FieldsSet pkFields_; WrSerializer ser_; bool unsafe_ = false; string_view cjson_; std::shared_ptr<Namespace> ns_; }; } // namespace reindexer
[ "ogerasimov@gmail.com" ]
ogerasimov@gmail.com
08aba69e1a1701e6d38445d8444c5d4b74d664ee
bf7d57591ac97669cb44ef752833c5650018dea0
/Assignments/CSC17A_Project 2/Player.cpp
d96eb0f9ac0ac6a236551da36c380f0f4ffa1385
[]
no_license
JMAK13/McIntyreJosh_CSC_17A_Spring2018
681f1765577264893893800deeffc6288da8ab0e
428bf473feb0142d90795d9cbdc3593a6a6c7a4d
refs/heads/master
2021-01-25T09:53:35.133945
2018-11-22T09:54:46
2018-11-22T09:54:46
123,328,090
0
0
null
null
null
null
UTF-8
C++
false
false
1,856
cpp
/* * File: Player.cpp * Author: Josh McIntyre * Created on May 16, 2018, 1:28 PM */ //Included System Libraries #include <iostream> //Included User Libraries #include "Player.h" //Default Player Constructor Player::Player(){ isPl=true; name="Player Name"; inHand=0; hand=new int[52]; for(int i=0; i<52; i++){ hand[i]=-1; } } //Overloaded Player Constructor Player::Player(string s){ isPl=true; name=s; inHand=0; hand=new int[52]; for(int i=0; i<52; i++){ hand[i]=-1; } } //Player Copy Constructor Player::Player(Player &player){ name=player.name; hand=player.hand; inHand=player.inHand; } //Player Destructor Player::~Player(){ delete []hand; } //Index Mutator Member Function void Player::setHand(int i, int v){ if(i>=0) hand[i]=v; else throw Player::BadIndex(); } //Counts Indexes in Player's Array int Player::cntHand(){ int count=0; for(int i=0; i<52; i++){ if(hand[i]>=0)count++; } return count; } //Gets Index at Top of Player's Array int Player::getTop(){ for(int i=0; i<52; i++){ if(getHand(i+1)==-1) return getHand(i); } } //Sets Index at Top of Player's Array to -1 void Player::setTop(){ for(int i=0; i<52; i++){ try{ if(getHand(i+1)==-1) setHand(i,-1); } catch(Player::BadIndex){ std::cout<<"Invalid index has been entered.\n"; } } } //Moves Top Card of Player's Hand to Bottom void Player::toBot(int c){ int tmp,tmp2; for(int i=0; i<52; i++){ if(i==0){ tmp=hand[i]; hand[i]=c; }else{ tmp2=hand[i]; hand[i]=tmp; tmp=tmp2; } } try{ setHand(0,c); }catch(Player::BadIndex){ cout<<"Invalid index has been entered./n"; } }
[ "josh.r.mcintyre13@gmail.com" ]
josh.r.mcintyre13@gmail.com
8e15a8208caa74358c591f72382f150c29ef41b8
ed97fb5c71da7ed89235432e3971bb0ef6064f8b
/algorithms/cpp/383.cpp
9cd9dfaf11dc945d74e8c608d71cb9fad59c6f20
[ "MIT" ]
permissive
viing937/leetcode
8241be4f8bc9234a882b98ada2e5d13b0ebcca68
b07f7ba69f3d2a7e294f915934db302f43c0848f
refs/heads/master
2023-08-31T18:25:06.443397
2023-08-31T15:31:38
2023-08-31T15:31:38
37,374,931
3
0
null
null
null
null
UTF-8
C++
false
false
457
cpp
#include <iostream> #include <vector> using namespace std; class Solution { public: bool canConstruct(string ransomNote, string magazine) { vector<int> cnt1(26, 0), cnt2(26, 0); for (auto ch: ransomNote) cnt1[ch-'a'] += 1; for (auto ch: magazine) cnt2[ch-'a'] += 1; for (int i = 0; i < 26; i++) if (cnt1[i] > cnt2[i]) return false; return true; } }; int main() { return 0; }
[ "viing937@gmail.com" ]
viing937@gmail.com
32a4ca058d6fd719da093eaab40240b2cadd5b99
967a01f1a14e3f6c174d58a431e6a09c79fc34e8
/examples/aura_demo/aura_demo.cc
917ea61ccf4962d62eb93aa5fb16a30c085f16f5
[ "BSD-3-Clause" ]
permissive
PubFork/mojo
98855f148574cde1811d081cc39a28d6188d86f8
950de5bc66e00aeb1f7bdf2987f253986c0a7614
refs/heads/master
2020-05-24T14:24:52.426551
2014-11-25T00:42:39
2014-11-25T01:03:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,876
cc
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <stdio.h> #include <string> #include "base/bind.h" #include "base/macros.h" #include "mojo/application/application_runner_chromium.h" #include "mojo/aura/screen_mojo.h" #include "mojo/aura/window_tree_host_mojo.h" #include "mojo/public/c/system/main.h" #include "mojo/public/cpp/application/application_connection.h" #include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/system/core.h" #include "mojo/services/public/cpp/view_manager/view.h" #include "mojo/services/public/cpp/view_manager/view_manager.h" #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.h" #include "ui/aura/client/default_capture_client.h" #include "ui/aura/client/window_tree_client.h" #include "ui/aura/env.h" #include "ui/aura/window.h" #include "ui/aura/window_delegate.h" #include "ui/base/hit_test.h" #include "ui/gfx/canvas.h" #include "ui/gfx/codec/png_codec.h" namespace examples { // Trivial WindowDelegate implementation that draws a colored background. class DemoWindowDelegate : public aura::WindowDelegate { public: explicit DemoWindowDelegate(SkColor color) : color_(color) {} // Overridden from WindowDelegate: virtual gfx::Size GetMinimumSize() const override { return gfx::Size(); } virtual gfx::Size GetMaximumSize() const override { return gfx::Size(); } virtual void OnBoundsChanged(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) override {} virtual gfx::NativeCursor GetCursor(const gfx::Point& point) override { return gfx::kNullCursor; } virtual int GetNonClientComponent(const gfx::Point& point) const override { return HTCAPTION; } virtual bool ShouldDescendIntoChildForEventHandling( aura::Window* child, const gfx::Point& location) override { return true; } virtual bool CanFocus() override { return true; } virtual void OnCaptureLost() override {} virtual void OnPaint(gfx::Canvas* canvas) override { canvas->DrawColor(color_, SkXfermode::kSrc_Mode); } virtual void OnDeviceScaleFactorChanged(float device_scale_factor) override {} virtual void OnWindowDestroying(aura::Window* window) override {} virtual void OnWindowDestroyed(aura::Window* window) override {} virtual void OnWindowTargetVisibilityChanged(bool visible) override {} virtual bool HasHitTestMask() const override { return false; } virtual void GetHitTestMask(gfx::Path* mask) const override {} private: const SkColor color_; DISALLOW_COPY_AND_ASSIGN(DemoWindowDelegate); }; class DemoWindowTreeClient : public aura::client::WindowTreeClient { public: explicit DemoWindowTreeClient(aura::Window* window) : window_(window) { aura::client::SetWindowTreeClient(window_, this); } virtual ~DemoWindowTreeClient() { aura::client::SetWindowTreeClient(window_, NULL); } // Overridden from aura::client::WindowTreeClient: virtual aura::Window* GetDefaultParent(aura::Window* context, aura::Window* window, const gfx::Rect& bounds) override { if (!capture_client_) { capture_client_.reset( new aura::client::DefaultCaptureClient(window_->GetRootWindow())); } return window_; } private: aura::Window* window_; scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; DISALLOW_COPY_AND_ASSIGN(DemoWindowTreeClient); }; class AuraDemo : public mojo::ApplicationDelegate, public mojo::ViewManagerDelegate { public: AuraDemo() : shell_(nullptr), window1_(NULL), window2_(NULL), window21_(NULL) {} virtual ~AuraDemo() {} private: // Overridden from ViewManagerDelegate: virtual void OnEmbed( mojo::ViewManager* view_manager, mojo::View* root, mojo::ServiceProviderImpl* exported_services, scoped_ptr<mojo::ServiceProvider> imported_services) override { // TODO(beng): this function could be called multiple times! root_ = root; window_tree_host_.reset(new mojo::WindowTreeHostMojo(shell_, root)); window_tree_host_->InitHost(); window_tree_client_.reset( new DemoWindowTreeClient(window_tree_host_->window())); delegate1_.reset(new DemoWindowDelegate(SK_ColorBLUE)); window1_ = new aura::Window(delegate1_.get()); window1_->Init(aura::WINDOW_LAYER_TEXTURED); window1_->SetBounds(gfx::Rect(100, 100, 400, 400)); window1_->Show(); window_tree_host_->window()->AddChild(window1_); delegate2_.reset(new DemoWindowDelegate(SK_ColorRED)); window2_ = new aura::Window(delegate2_.get()); window2_->Init(aura::WINDOW_LAYER_TEXTURED); window2_->SetBounds(gfx::Rect(200, 200, 350, 350)); window2_->Show(); window_tree_host_->window()->AddChild(window2_); delegate21_.reset(new DemoWindowDelegate(SK_ColorGREEN)); window21_ = new aura::Window(delegate21_.get()); window21_->Init(aura::WINDOW_LAYER_TEXTURED); window21_->SetBounds(gfx::Rect(10, 10, 50, 50)); window21_->Show(); window2_->AddChild(window21_); window_tree_host_->Show(); } virtual void OnViewManagerDisconnected( mojo::ViewManager* view_manager) override { base::MessageLoop::current()->Quit(); } virtual void Initialize(mojo::ApplicationImpl* app) override { shell_ = app->shell(); view_manager_client_factory_.reset( new mojo::ViewManagerClientFactory(shell_, this)); aura::Env::CreateInstance(true); screen_.reset(mojo::ScreenMojo::Create()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); } virtual bool ConfigureIncomingConnection( mojo::ApplicationConnection* connection) override { connection->AddService(view_manager_client_factory_.get()); return true; } mojo::Shell* shell_; scoped_ptr<DemoWindowTreeClient> window_tree_client_; scoped_ptr<mojo::ScreenMojo> screen_; scoped_ptr<DemoWindowDelegate> delegate1_; scoped_ptr<DemoWindowDelegate> delegate2_; scoped_ptr<DemoWindowDelegate> delegate21_; aura::Window* window1_; aura::Window* window2_; aura::Window* window21_; mojo::View* root_; scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_; scoped_ptr<aura::WindowTreeHost> window_tree_host_; DISALLOW_COPY_AND_ASSIGN(AuraDemo); }; } // namespace examples MojoResult MojoMain(MojoHandle shell_handle) { mojo::ApplicationRunnerChromium runner(new examples::AuraDemo); return runner.Run(shell_handle); }
[ "jamesr@chromium.org" ]
jamesr@chromium.org
a3ee64fc7c838f005a4c888ced2a5fd156c68870
9dfe52d4f6f828db4e77aa34699df8e560a51e9c
/bits.h
e8bbb5c59232b93d23cd0da8361c65a934aaac66
[]
no_license
jfuentes/CMIB
5200f552ba68868d2f88c4340b9b5b62be5d03aa
3687f4bf57515ef2fd4790f0a19e58e06fbbca10
refs/heads/master
2020-03-25T18:45:39.442810
2018-10-03T07:38:52
2018-10-03T07:38:52
144,046,631
1
0
null
null
null
null
UTF-8
C++
false
false
20,892
h
/* sdsl - succinct data structures library Copyright (C) 2008 Simon Gog This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ . */ /*! \file bits.hpp \brief bits.hpp contains the sdsl::bits class. \author Simon Gog */ //! Namespace for the succinct data structure library. //! A helper class for bitwise tricks on 64 bit words. /*! bits is a helper class for bitwise tricks and techniques. For the basic tricks and techiques we refer to Donald E. Knuth's "The Art of Computer Programming", Volume 4A, Chapter 7.1.3 and the informative website of Sean E. Anderson about the topic: http://www-graphics.stanford.edu/~seander/bithacks.html . We have added new functions like: cnt11 and sel11. All members of this class are static variables or methods. This class cannot be instantiated. \author Simon Gog */ typedef uint32_t size_t; //struct bits { // bits() = delete; //! 64bit mask with all bits set to 1. constexpr static uint64_t all_set{ -1ULL }; //! This constant represents a de Bruijn sequence B(k,n) for k=2 and n=6. /*! Details for de Bruijn sequences see http://en.wikipedia.org/wiki/De_bruijn_sequence deBruijn64 is used in combination with the array lt_deBruijn_to_idx. */ constexpr static uint64_t deBruijn64{ 0x0218A392CD3D5DBFULL }; //! This table maps a 6-bit subsequence S[idx...idx+5] of constant deBruijn64 to idx. /*! \sa deBruijn64 */ //static vector<uint32_t, 64> lt_deBruijn_to_idx; //! Array containing Fibonacci numbers less than \f$2^64\f$. //static vector<uint64_t, 92> lt_fib; //! Lookup table for byte popcounts. //static vector<uint8_t, 256> lt_cnt; //! Lookup table for most significant set bit in a byte. //static vector<uint32_t, 256> lt_hi; //! lo_set[i] is a 64-bit word with the i least significant bits set and the high bits not set. /*! lo_set[0] = 0ULL, lo_set[1]=1ULL, lo_set[2]=3ULL... */ //static vector<uint64_t, 65> lo_set; //! lo_unset[i] is a 64-bit word with the i least significant bits not set and the high bits set. /*! lo_unset[0] = FFFFFFFFFFFFFFFFULL, lo_unset_set[1]=FFFFFFFFFFFFFFFEULL, ... */ //static vector<uint64_t, 65> lo_unset; //! Lookup table for least significant set bit in a byte. //static vector<uint8_t, 256> lt_lo; //! Lookup table for select on bytes. /*! Entry at idx = 256*j + i equals the position of the (j+1)-th set bit in byte i. Positions lie in the range \f$[0..7]\f$. */ //vector<uint8_t, 256*8> lt_sel(_lt_sel); //! Use to help to decide if a prefix sum stored in a byte overflows. //vector<uint64_t, 65> ps_overflow(_ps_overflow); //! Counts the number of set bits in x. /*! \param x 64-bit word \return Number of set bits. */ static uint32_t cnt(vector<uint32_t, SIMD_SIZE> x); //! Position of the most significant set bit the 64-bit word x /*! \param x 64-bit word \return The position (in 0..63) of the most significant set bit in `x` or 0 if x equals 0. \sa sel, lo */ static uint32_t hi(uint32_t x); static uint32_t hi(vector<uint32_t, SIMD_SIZE> x); //! Calculates the position of the rightmost 1-bit in the 64bit integer x if it exists /*! \param x 64 bit integer. \return The position (in 0..63) of the rightmost 1-bit in the 64bit integer x if x>0 and 0 if x equals 0. \sa sel, hi */ static uint32_t lo(uint32_t x); //! Counts the number of 1-bits in the 32bit integer x. /*! This function is a variant of the method cnt. If 32bit multiplication is fast, this method beats the cnt. for 32bit integers. \param x 64bit integer to count the bits. \return The number of 1-bits in x. */ static uint32_t cnt32(uint32_t x); //! Count the number of consecutive and distinct 11 in the 64bit integer x. /*! \param x 64bit integer to count the terminating sequence 11 of a Fibonacci code. \param c Carry equals msb of the previous 64bit integer. */ static uint32_t cnt11(uint64_t x, uint64_t& c); //! Count the number of consecutive and distinct 11 in the 64bit integer x. /*! \param x 64bit integer to count the terminating sequence 11 of a Fibonacci code. */ static uint32_t cnt11(uint64_t x); //! Count 10 bit pairs in the word x. /*! * \param x 64bit integer to count the 10 bit pairs. * \param c Carry equals msb of the previous 64bit integer. */ static uint32_t cnt10(uint64_t x, uint64_t& c); //! Count 01 bit pairs in the word x. /*! * \param x 64bit integer to count the 01 bit pairs. * \param c Carry equals msb of the previous 64bit integer. */ static uint32_t cnt01(uint64_t x, uint64_t& c); //! Map all 10 bit pairs to 01 or 1 if c=1 and the lsb=0. All other pairs are mapped to 00. static uint64_t map10(uint64_t x, uint64_t c = 0); //! Map all 01 bit pairs to 01 or 1 if c=1 and the lsb=0. All other pairs are mapped to 00. static uint64_t map01(uint64_t x, uint64_t c = 1); //! Calculate the position of the i-th rightmost 1 bit in the 64bit integer x /*! \param x 64bit integer. \param i Argument i must be in the range \f$[1..cnt(x)]\f$. \pre Argument i must be in the range \f$[1..cnt(x)]\f$. \sa hi, lo */ static uint32_t sel(uint64_t x, uint32_t i); static uint32_t _sel(uint64_t x, uint32_t i); //! Calculates the position of the i-th rightmost 11-bit-pattern which terminates a Fibonacci coded integer in x. /*! \param x 64 bit integer. \param i Index of 11-bit-pattern. \f$i \in [1..cnt11(x)]\f$ \param c Carry bit from word before \return The position (in 1..63) of the i-th 11-bit-pattern which terminates a Fibonacci coded integer in x if x contains at least i 11-bit-patterns and a undefined value otherwise. \sa cnt11, hi11, sel */ static uint32_t sel11(uint64_t x, uint32_t i, uint32_t c = 0); //! Calculates the position of the leftmost 11-bit-pattern which terminates a Fibonacci coded integer in x. /*! \param x 64 bit integer. \return The position (in 1..63) of the leftmost 1 of the leftmost 11-bit-pattern which terminates a Fibonacci coded integer in x if x contains a 11-bit-pattern and 0 otherwise. \sa cnt11, sel11 */ static uint32_t hi11(uint64_t x); //! Writes value x to an bit position in an array. static void write_int(uint64_t* word, uint64_t x, const uint8_t offset = 0, const uint8_t len = 64); //! Writes value x to an bit position in an array and moves the bit-pointer. static void write_int_and_move(uint64_t*& word, uint64_t x, uint8_t& offset, const uint8_t len); //! Reads a value from a bit position in an array. static uint64_t read_int(const uint64_t* word, uint8_t offset = 0, const uint8_t len = 64); //! Reads a value from a bit position in an array and moved the bit-pointer. static uint64_t read_int_and_move(const uint64_t*& word, uint8_t& offset, const uint8_t len = 64); //! Reads an unary decoded value from a bit position in an array. static uint64_t read_unary(const uint64_t* word, uint8_t offset = 0); //! Reads an unary decoded value from a bit position in an array and moves the bit-pointer. static uint64_t read_unary_and_move(const uint64_t*& word, uint8_t& offset); //! Move the bit-pointer (=uint64_t word and offset) `len` to the right. /*!\param word 64-bit word part of the bit pointer * \param offset Offset part of the bit pointer * \param len Move distance. \f$ len \in [0..64] \f$ * \sa move_left */ static void move_right(const uint64_t*& word, uint8_t& offset, const uint8_t len); //! Move the bit-pointer (=uint64_t word and offset) `len` to the left. /*!\param word 64-bit word part of the bit pointer * \param offset Offset part of the bit pointer * \param len Move distance. \f$ len \in [0..64] \f$ * \sa move_right */ static void move_left(const uint64_t*& word, uint8_t& offset, const uint8_t len); //! Get the first one bit in the interval \f$[idx..\infty )\f$ static uint64_t next(const uint64_t* word, uint64_t idx); //! Get the one bit with the greatest position in the interval \f$[0..idx]\f$ static uint64_t prev(const uint64_t* word, uint64_t idx); //! reverses a given 64 bit word static uint32_t rev(uint32_t x); static vector<uint32_t, SIMD_SIZE> rev(vector<uint32_t, SIMD_SIZE> x); //}; // ============= inline - implementations ================ // see page 11, Knuth TAOCP Vol 4 F1A inline uint32_t cnt(vector<uint32_t, SIMD_SIZE> x) { return cm_sum<uint32_t>(cm_cbit(x)); } inline uint32_t cnt32(uint32_t x) { return cm_cbit(x); } inline uint32_t cnt11(uint64_t x, uint64_t& c) { // extract "11" 2bit blocks uint64_t ex11 = (x&(x >> 1)) & 0x5555555555555555ULL, t; // extract "10" 2bit blocks uint64_t ex10or01 = (ex11 | (ex11 << 1)) ^ x; x = ex11 | ((t = (ex11 | (ex11 << 1)) + (((ex10or01 << 1) & 0x5555555555555555ULL) | c))&(ex10or01 & 0x5555555555555555ULL)); c = (ex10or01 >> 63) | (t < (ex11 | (ex11 << 1))); x = (x & 0x3333333333333333ULL) + ((x >> 2) & 0x3333333333333333ULL); x = (x + (x >> 4)) & 0x0F0F0F0F0F0F0F0FULL; return (0x0101010101010101ULL * x >> 56); } inline uint32_t cnt11(uint64_t x) { // extract "11" 2bit blocks uint64_t ex11 = (x&(x >> 1)) & 0x5555555555555555ULL; // extract "10" 2bit blocks uint64_t ex10or01 = (ex11 | (ex11 << 1)) ^ x; x = ex11 | (((ex11 | (ex11 << 1)) + ((ex10or01 << 1) & 0x5555555555555555ULL))&(ex10or01 & 0x5555555555555555ULL)); x = (x & 0x3333333333333333ULL) + ((x >> 2) & 0x3333333333333333ULL); x = (x + (x >> 4)) & 0x0F0F0F0F0F0F0F0FULL; return (0x0101010101010101ULL * x >> 56); } inline uint32_t cnt10(uint64_t x, uint64_t& c) { uint32_t res = cnt((x ^ ((x << 1) | c)) & (~x)); c = (x >> 63); return res; } inline uint64_t map10(uint64_t x, uint64_t c) { return ((x ^ ((x << 1) | c)) & (~x)); } inline uint32_t cnt01(uint64_t x, uint64_t& c) { uint32_t res = cnt((x ^ ((x << 1) | c)) & x); c = (x >> 63); return res; } inline uint64_t map01(uint64_t x, uint64_t c) { return ((x ^ ((x << 1) | c)) & x); } inline uint32_t sel(uint64_t x, uint32_t i) { #ifdef __BMI2__ // index i is 1-based here, (i-1) changes it to 0-based return __builtin_ctzll(_pdep_u64(1ull << (i - 1), x)); #elif defined(__SSE4_2__) uint64_t s = x, b; s = s - ((s >> 1) & 0x5555555555555555ULL); s = (s & 0x3333333333333333ULL) + ((s >> 2) & 0x3333333333333333ULL); s = (s + (s >> 4)) & 0x0F0F0F0F0F0F0F0FULL; s = 0x0101010101010101ULL * s; // now s contains 8 bytes s[7],...,s[0]; s[j] contains the cumulative sum // of (j+1)*8 least significant bits of s b = (s + ps_overflow[i]) & 0x8080808080808080ULL; // ps_overflow contains a bit mask x consisting of 8 bytes // x[7],...,x[0] and x[j] is set to 128-j // => a byte b[j] in b is >= 128 if cum sum >= j // __builtin_ctzll returns the number of trailing zeros, if b!=0 int byte_nr = __builtin_ctzll(b) >> 3; // byte nr in [0..7] s <<= 8; i -= (s >> (byte_nr << 3)) & 0xFFULL; return (byte_nr << 3) + lt_sel[((i - 1) << 8) + ((x >> (byte_nr << 3)) & 0xFFULL)]; #else return _sel(x, i); #endif } inline uint32_t _sel(uint64_t x, uint32_t i) { #if 0 uint64_t s = x, b; // s = sum s = s - ((s >> 1) & 0x5555555555555555ULL); s = (s & 0x3333333333333333ULL) + ((s >> 2) & 0x3333333333333333ULL); s = (s + (s >> 4)) & 0x0F0F0F0F0F0F0F0FULL; s = 0x0101010101010101ULL * s; b = (s + ps_overflow[i]);//&0x8080808080808080ULL;// add something to the partial sums to cause overflow i = (i - 1) << 8; if (b & 0x0000000080000000ULL) // byte <=3 if (b & 0x0000000000008000ULL) //byte <= 1 if (b & 0x0000000000000080ULL) return lt_sel[(x & 0xFFULL) + i]; else return 8 + lt_sel[(((x >> 8) & 0xFFULL) + i - ((s & 0xFFULL) << 8)) & 0x7FFULL];//byte 1; else//byte >1 if (b & 0x0000000000800000ULL) //byte <=2 return 16 + lt_sel[(((x >> 16) & 0xFFULL) + i - (s & 0xFF00ULL)) & 0x7FFULL];//byte 2; else return 24 + lt_sel[(((x >> 24) & 0xFFULL) + i - ((s >> 8) & 0xFF00ULL)) & 0x7FFULL];//byte 3; else// byte > 3 if (b & 0x0000800000000000ULL) // byte <=5 if (b & 0x0000008000000000ULL) //byte <=4 return 32 + lt_sel[(((x >> 32) & 0xFFULL) + i - ((s >> 16) & 0xFF00ULL)) & 0x7FFULL];//byte 4; else return 40 + lt_sel[(((x >> 40) & 0xFFULL) + i - ((s >> 24) & 0xFF00ULL)) & 0x7FFULL];//byte 5; else// byte >5 if (b & 0x0080000000000000ULL) //byte<=6 return 48 + lt_sel[(((x >> 48) & 0xFFULL) + i - ((s >> 32) & 0xFF00ULL)) & 0x7FFULL];//byte 6; else return 56 + lt_sel[(((x >> 56) & 0xFFULL) + i - ((s >> 40) & 0xFF00ULL)) & 0x7FFULL];//byte 7; return 0; #endif uint32_t pos = 0; while (x) { i -= x & 1; x >>= 1; if (!i) break; ++pos; } return pos; } // using built-in method or // 64-bit version of 32-bit proposal of // http://www-graphics.stanford.edu/~seander/bithacks.html inline uint32_t hi(uint32_t x) { if (x == 0) return 0; return 31 - cm_fbh(x); } inline uint32_t hi(vector<uint32_t, SIMD_SIZE> x) { if ((x == 0).all()) return 0; vector<ushort, SIMD_SIZE> vex = cm_fbh(x); vector<ushort, SIMD_SIZE> result = (vex != 0xFFFF); uint32_t pack = cm_pack_mask(result); return 32 * (31 -cm_fbh(pack)) + (31 - vex[31 - cm_fbh(pack)]); } // details see: http://citeseer.ist.psu.edu/leiserson98using.html // or page 10, Knuth TAOCP Vol 4 F1A inline _GENX_ uint32_t lo(uint32_t x) { if (x == 0) return 0; return cm_fbl(x);; } inline _GENX_ uint32_t lo(vector<uint32_t, SIMD_SIZE> x) { if ((x == 0).all()) return 0; vector<ushort, SIMD_SIZE> vex = cm_fbl(x); vector<ushort, SIMD_SIZE> result = (vex != 0xFFFF); uint32_t pack = cm_pack_mask(result); return 32 * cm_fbl(pack) + vex[cm_fbl(pack)]; } inline uint32_t hi11(uint64_t x) { // extract "11" 2bit blocks uint64_t ex11 = (x&(x >> 1)) & 0x5555555555555555ULL; // extract "10" 2bit blocks uint64_t ex10or01 = (ex11 | (ex11 << 1)) ^ x; // extract "10" 2bit blocks ex11 += (((ex11 | (ex11 << 1)) + ((ex10or01 << 1) & 0x5555555555555555ULL)) & ((ex10or01 & 0x5555555555555555ULL) | ex11)); return hi(ex11); } inline uint32_t sel11(uint64_t x, uint32_t i, uint32_t c) { uint64_t ex11 = (x&(x >> 1)) & 0x5555555555555555ULL; uint64_t ex10or01 = (ex11 | (ex11 << 1)) ^ x; ex11 += (((ex11 | (ex11 << 1)) + (((ex10or01 << 1) & 0x5555555555555555ULL) | c)) & ((ex10or01 & 0x5555555555555555ULL) | ex11)); return sel(ex11, i); } #if 0 inline void bits::write_int(uint64_t* word, uint64_t x, uint8_t offset, const uint8_t len) { x &= bits::lo_set[len]; if (offset + len < 64) { *word &= ((bits::all_set << (offset + len)) | bits::lo_set[offset]); // mask 1..10..01..1 *word |= (x << offset); // *word ^= ((*word ^ x) & (bits::lo_set[len] << offset) ); // surprisingly the above line is slower than the lines above } else { *word &= ((bits::lo_set[offset])); // mask 0....01..1 *word |= (x << offset); if ((offset = (offset + len) & 0x3F)) { // offset+len > 64 *(word + 1) &= (~bits::lo_set[offset]); // mask 1...10..0 // *(word+1) &= bits::lo_unset[offset]; // mask 1...10..0 // surprisingly the above line is slower than the line above *(word + 1) |= (x >> (len - offset)); } } } inline void bits::write_int_and_move(uint64_t*& word, uint64_t x, uint8_t& offset, const uint8_t len) { x &= bits::lo_set[len]; if (offset + len < 64) { *word &= ((bits::all_set << (offset + len)) | bits::lo_set[offset]); // mask 1..10..01..1 *word |= (x << offset); offset += len; } else { *word &= ((bits::lo_set[offset])); // mask 0....01..1 *word |= (x << offset); if ((offset = (offset + len))>64) {// offset+len >= 64 offset &= 0x3F; *(++word) &= (~bits::lo_set[offset]); // mask 1...10..0 *word |= (x >> (len - offset)); } else { offset = 0; ++word; } } } inline uint64_t bits::read_int(const uint64_t* word, uint8_t offset, const uint8_t len) { uint64_t w1 = (*word) >> offset; if ((offset + len) > 64) { // if offset+len > 64 return w1 | // w1 or w2 adepted: ((*(word + 1) & bits::lo_set[(offset + len) & 0x3F]) // set higher bits zero << (64 - offset)); // move bits to the left } else { return w1 & bits::lo_set[len]; } } inline uint64_t bits::read_int_and_move(const uint64_t*& word, uint8_t& offset, const uint8_t len) { uint64_t w1 = (*word) >> offset; if ((offset = (offset + len)) >= 64) { // if offset+len > 64 if (offset == 64) { offset &= 0x3F; ++word; return w1; } else { offset &= 0x3F; return w1 | (((*(++word)) & bits::lo_set[offset]) << (len - offset)); } } else { return w1 & bits::lo_set[len]; } } inline uint64_t bits::read_unary(const uint64_t* word, uint8_t offset) { uint64_t w = *word >> offset; if (w) { return bits::lo(w); } else { if (0 != (w = *(++word))) return bits::lo(w) + 64 - offset; uint64_t cnt = 2; while (0 == (w = *(++word))) ++cnt; return bits::lo(w) + (cnt << 6) - offset; } return 0; } inline uint64_t bits::read_unary_and_move(const uint64_t*& word, uint8_t& offset) { uint64_t w = (*word) >> offset; // temporary variable is good for the performance if (w) { uint8_t r = bits::lo(w); offset = (offset + r + 1) & 0x3F; // we know that offset + r +1 <= 64, so if the new offset equals 0 increase word word += (offset == 0); return r; } else { uint8_t rr = 0; if (0 != (w = *(++word))) { rr = bits::lo(w) + 64 - offset; offset = (offset + rr + 1) & 0x3F; word += (offset == 0); return rr; } else { uint64_t cnt_1 = 1; while (0 == (w = *(++word))) ++cnt_1; rr = bits::lo(w) + 64 - offset; offset = (offset + rr + 1) & 0x3F; word += (offset == 0); return ((cnt_1) << 6) + rr; } } return 0; } inline void bits::move_right(const uint64_t*& word, uint8_t& offset, const uint8_t len) { if ((offset += len) & 0xC0) { // if offset >= 65 offset &= 0x3F; ++word; } } inline void bits::move_left(const uint64_t*& word, uint8_t& offset, const uint8_t len) { if ((offset -= len) & 0xC0) { // if offset-len<0 offset &= 0x3F; --word; } } inline uint64_t bits::next(const uint64_t* word, uint64_t idx) { word += (idx >> 6); if (*word & ~lo_set[idx & 0x3F]) { return (idx & ~((size_t)0x3F)) + lo(*word & ~lo_set[idx & 0x3F]); } idx = (idx & ~((size_t)0x3F)) + 64; ++word; while (*word == 0) { idx += 64; ++word; } return idx + lo(*word); } inline uint64_t bits::prev(const uint64_t* word, uint64_t idx) { word += (idx >> 6); if (*word & lo_set[(idx & 0x3F) + 1]) { return (idx & ~((size_t)0x3F)) + hi(*word & lo_set[(idx & 0x3F) + 1]); } idx = (idx & ~((size_t)0x3F)) - 64; --word; while (*word == 0) { idx -= 64; --word; } return idx + hi(*word); } #endif inline uint32_t rev(uint32_t x) { vector<uint32_t, 1> xx = x; return cm_bf_reverse<uint32_t>(xx)[0]; } inline vector<uint32_t, SIMD_SIZE> rev(vector<uint32_t, SIMD_SIZE> x) { return cm_bf_reverse<uint32_t>(x); }
[ "jfuentes@ubiobio.cl" ]
jfuentes@ubiobio.cl
87f245e635ede3c5b65c53541a1138d5552e5696
fd87b8ceeb80e561475064ea3b5af51278326f2d
/math/vector3.hpp
58e999b0c33c4cc1aeef717863a24e704cf38667
[ "MIT" ]
permissive
fhnmor21/broome
3306d4d83b57b3701c41c444566a5ca7ca035290
aea0ab083f7485b015d742b9fb15d0583a979b0a
refs/heads/master
2023-03-07T14:46:46.783648
2021-02-24T03:58:10
2021-02-24T03:58:10
55,816,416
0
0
null
null
null
null
UTF-8
C++
false
false
3,204
hpp
/** The MIT License (MIT) Copyright (c) 2016 Flavio Moreira Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef VECTOR3_HPP #define VECTOR3_HPP #include "colour_types.hpp" #include "vector2.hpp" namespace Broome { struct Vector3 { enum { eAxis = 3, }; union { struct { Scalar x; Scalar y; Scalar z; }; struct { Scalar width; Scalar height; Scalar depth; }; struct { Scalar pitch; Scalar roll; Scalar yaw; }; struct { Scalar r; Scalar g; Scalar b; }; struct { Scalar h; Scalar s; Scalar v; }; struct { Vector2 hs; Scalar l; }; ColourRGB rgb; ColourHSV hsv; ColourHSL hsl; Scalar data[eAxis]; Vector2 xy; }; static const Vector3 Zero; static const Vector3 Half; static const Vector3 One; inline Scalar& operator[](usize index) { return data[index]; } inline const Scalar& operator[](usize index) const { return data[index]; } }; bool operator==(const Vector3& a, const Vector3& b); bool operator!=(const Vector3& a, const Vector3& b); Vector3 operator-(const Vector3& a); Vector3 operator+(const Vector3& a, const Vector3& b); Vector3 operator-(const Vector3& a, const Vector3& b); Vector3 operator*(const Vector3& a, const f32 scalar); Vector3 operator/(const Vector3& a, const f32 scalar); Vector3 operator*(const Vector3& a, const Vector3& b); Vector3 operator/(const Vector3& a, const Vector3& b); Vector3& operator+=(Vector3& a, const Vector3& b); Vector3& operator-=(Vector3& a, const Vector3& b); Vector3& operator*=(Vector3& a, const f32 scalar); Vector3& operator/=(Vector3& a, const f32 scalar); inline Vector3 operator*(const f32 scalar, Vector3& vector) { return vector * scalar; } inline Vector3 operator/(const f32 scalar, Vector3& vector) { return vector / scalar; } inline Vector3& operator*=(const f32 scalar, Vector3& vector) { return vector * scalar; } inline Vector3& operator/=(const f32 scalar, Vector3& vector) { return vector / scalar; } using Colour3 = Vector3; using Dimension3 = Vector3; using Rotation3 = Vector3; } // end namespace Broome #endif // VECTOR3_HPP
[ "fhnmor21@gmail.com" ]
fhnmor21@gmail.com
d6a73fbdef3cc92ad737190bb839c9d5ba626a9c
5732a7279c9632d1cef13f5fafb6116ee9d15dfb
/engine/Graphic/SDL/sdlrenderer.cpp
7d762651954e6f5d944c7a8e95e22a7acdc3a604
[]
no_license
juanAngel/RPG_Game
dd14f62fb9b0cbaf8ed98b12ec07783bf2266c84
dfae2ad203819cc4a58e65306b0532999c8fd624
refs/heads/master
2020-09-16T06:22:43.774135
2019-11-26T23:10:38
2019-11-26T23:10:38
223,681,813
0
0
null
null
null
null
UTF-8
C++
false
false
840
cpp
#include "sdlrenderer.h" #include <Graphic/SDL/sdlcamera.h> #include <Graphic/SDL/sdltexture.h> #include <Graphic/SDL/sdlengine.h> SDLRenderer::SDLRenderer(SDLCamera* camera){ mRenderer = SDL_CreateRenderer( camera->windows(), -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC ); if (!mRenderer) { //return false; } } SDLRenderer::~SDLRenderer(){ } void SDLRenderer::copy(const Texture &texture, const Rect& srcrect, const Rect& dstrect){ const SDLTexture& tex = *dynamic_cast<const SDLTexture*>(&texture); auto src = recToSDL(srcrect); auto dst = recToSDL(dstrect); SDL_RenderCopy(mRenderer,tex.texture(),&src,&dst); } void SDLRenderer::refresh(){ SDL_RenderPresent(mRenderer); } void SDLRenderer::clear(){ SDL_RenderClear(mRenderer); }
[ "juan@localhost.localdomain" ]
juan@localhost.localdomain
876de52cdfa27db411cf66485a509b78e4bf9c91
92e67b30497ffd29d3400e88aa553bbd12518fe9
/assignment2/part6/Re=20/2.8/U
d1ab0a555beb015c7f9d8351d9c4d5341625c036
[]
no_license
henryrossiter/OpenFOAM
8b89de8feb4d4c7f9ad4894b2ef550508792ce5c
c54b80dbf0548b34760b4fdc0dc4fb2facfdf657
refs/heads/master
2022-11-18T10:05:15.963117
2020-06-28T15:24:54
2020-06-28T15:24:54
241,991,470
0
0
null
null
null
null
UTF-8
C++
false
false
63,627
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 7 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "2.8"; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<vector> 2000 ( (-0.000419518 0.0298003 -3.72132e-21) (0.00373558 0.0670678 0) (0.0132821 0.0931472 0) (0.0248394 0.11231 -2.49674e-20) (0.0374338 0.126998 8.38615e-21) (0.050246 0.138651 1.3932e-22) (0.0626737 0.148186 -1.57068e-20) (0.074284 0.156229 0) (0.0847516 0.163225 0) (0.0937185 0.169464 0) (-0.00249612 0.0281096 0) (-0.00038128 0.0621651 -1.64051e-20) (0.00838904 0.0857646 1.65214e-20) (0.0198534 0.102991 3.33713e-20) (0.032804 0.116261 0) (0.0462757 0.126991 3.23558e-20) (0.05957 0.136087 -3.12512e-20) (0.0721771 0.144184 0) (0.0836908 0.151744 5.89171e-20) (0.0936537 0.159091 -1.21572e-19) (-0.00423521 0.0261652 0) (-0.0034409 0.0566486 1.29114e-19) (0.00523099 0.0775652 0) (0.0171712 0.092719 1.31995e-19) (0.0309342 0.104467 0) (0.0454135 0.114179 -1.27874e-19) (0.0598231 0.122747 0) (0.0735915 0.130817 1.21272e-19) (0.0862532 0.138896 -1.16561e-19) (0.0972232 0.14737 -1.20289e-19) (-0.0055686 0.0239488 -2.9297e-20) (-0.00526159 0.0505677 -6.49002e-20) (0.0040785 0.0687033 -3.26006e-20) (0.017132 0.0817544 -6.58335e-20) (0.032216 0.0919727 -6.47092e-20) (0.0480879 0.100653 6.38739e-20) (0.0638837 0.108654 6.18099e-20) (0.0789862 0.116637 -6.75061e-22) (0.0928979 0.125176 1.15854e-19) (0.104879 0.134751 1.20177e-19) (-0.00641457 0.0214632 -2.87243e-20) (-0.0056514 0.0440069 -6.42592e-20) (0.00519738 0.0593768 -1.30784e-19) (0.0200541 0.0704116 6.49303e-20) (0.0370032 0.0792043 0) (0.0546727 0.0869354 0) (0.0721301 0.0944055 -1.237e-19) (0.0887301 0.102276 -1.19814e-19) (0.103978 0.111206 1.14994e-19) (0.116962 0.121798 3.56104e-19) (-0.00667546 0.0187117 2.87476e-20) (-0.00440766 0.0370654 3.2502e-20) (0.00884328 0.0498114 -1.92042e-19) (0.0262206 0.0590449 3.23929e-19) (0.0455893 0.0666416 -6.38508e-20) (0.0654569 0.0736236 0) (0.084832 0.0806933 0) (0.103059 0.0884821 5.93321e-19) (0.119689 0.0977345 -5.73068e-19) (0.133648 0.109189 1.17892e-19) (-0.00623978 0.0157106 2.23059e-19) (-0.00132799 0.0298736 0) (0.0152417 0.0402681 2.57733e-19) (0.0358525 0.0480433 -2.5865e-19) (0.0581746 0.0548 0) (0.0806089 0.0613581 1.25373e-19) (0.102114 0.0682744 -3.63162e-19) (0.12204 0.0760942 -4.72447e-19) (0.140038 0.0856086 2.26886e-19) (0.154923 0.0976945 2.34679e-19) (-0.00498722 0.0124955 -4.43176e-19) (0.00377635 0.0225972 -6.26236e-20) (0.0245674 0.0310389 -1.26163e-19) (0.0490818 0.0378135 -3.17822e-19) (0.0748355 0.0441982 -1.27028e-19) (0.100143 0.0507777 -1.23322e-19) (0.123921 0.0579221 2.16717e-21) (0.145531 0.0660162 0) (0.164791 0.0758118 0) (0.180558 0.0882641 -1.40522e-22) (-0.00279663 0.00912906 2.20121e-19) (0.0110619 0.0154429 -2.4468e-19) (0.0369187 0.0224413 1.8981e-19) (0.0659212 0.0287579 4.44641e-19) (0.0954947 0.0353112 -1.24587e-19) (0.123905 0.0424441 1.25546e-19) (0.150032 0.0503389 1.20943e-19) (0.173218 0.0591983 0) (0.193441 0.0696707 0) (0.209901 0.0825217 -1.82086e-21) (0.000443375 0.00570574 -2.69505e-20) (0.0206312 0.00865946 3.06165e-19) (0.0522894 0.0148097 -6.18585e-20) (0.0862307 0.0212485 0) (0.119889 0.0285112 0) (0.151564 0.0367147 2.44253e-19) (0.18018 0.0459193 0) (0.205089 0.0562797 -2.29335e-19) (0.226204 0.0684108 -1.38293e-21) (0.24292 0.0823606 2.27262e-19) (0.109552 0.182192 5.356e-21) (0.120316 0.196972 -5.4417e-21) (0.123464 0.212403 -5.5493e-21) (0.117288 0.227473 -5.63244e-21) (0.104572 0.241877 -5.74079e-21) (0.0902806 0.254935 -1.29437e-24) (0.0701443 0.266228 2.89397e-21) (0.0536627 0.27683 8.81702e-21) (0.0298937 0.2866 0) (0.0126795 0.296226 -5.97949e-21) (0.111534 0.175474 2.09728e-20) (0.123772 0.193529 -2.19519e-20) (0.128227 0.21248 3.86289e-20) (0.122513 0.230029 5.63499e-21) (0.109676 0.246043 1.13203e-20) (0.0948636 0.260193 1.72164e-20) (0.0739614 0.272067 -5.81509e-21) (0.0563746 0.283062 -5.86733e-21) (0.0315744 0.29308 1.17315e-20) (0.0130694 0.3028 5.9653e-21) (0.116642 0.167693 0) (0.129029 0.189189 -2.16894e-20) (0.134158 0.211914 -1.10517e-20) (0.128487 0.232192 0) (0.115289 0.250029 -3.39565e-20) (0.0998175 0.265442 1.12725e-20) (0.0780302 0.278028 1.13792e-20) (0.0592979 0.289514 3.46407e-20) (0.0333369 0.299831 -1.16856e-20) (0.0135386 0.309648 2.34465e-20) (0.125236 0.159103 0) (0.136333 0.184116 2.17855e-20) (0.141379 0.210768 0) (0.135278 0.233978 4.45241e-20) (0.121445 0.253821 -4.45906e-20) (0.105162 0.270666 -2.26441e-20) (0.0823644 0.28409 -1.36513e-22) (0.0624462 0.296172 -3.43367e-20) (0.0351945 0.306845 -5.73172e-21) (0.0140931 0.31677 -2.908e-20) (0.137577 0.150002 1.10638e-21) (0.145915 0.178516 -6.36714e-20) (0.149999 0.209123 4.04254e-22) (0.142942 0.23541 -4.38485e-20) (0.128169 0.257412 0) (0.110907 0.275849 -2.24215e-20) (0.0869707 0.290228 -1.1979e-22) (0.0658276 0.303023 4.52257e-20) (0.0371562 0.31411 5.67513e-21) (0.0147372 0.324172 -5.70499e-21) (0.153785 0.140721 -1.68225e-19) (0.157968 0.172642 1.07162e-19) (0.160096 0.207096 4.37263e-20) (0.151517 0.236534 -4.35719e-20) (0.13547 0.260803 -2.19169e-20) (0.117047 0.280978 0) (0.0918424 0.29642 -4.43606e-20) (0.0694397 0.31005 2.20962e-20) (0.0392226 0.321612 2.22758e-20) (0.0154734 0.331858 2.23555e-20) (0.173795 0.131618 -2.07222e-20) (0.172606 0.166796 0) (0.171705 0.204836 0) (0.161003 0.237416 0) (0.143326 0.264008 -2.18972e-20) (0.123548 0.286044 4.35413e-20) (0.0969466 0.302642 4.39044e-20) (0.0732589 0.317236 -6.56677e-20) (0.0413795 0.329337 1.09646e-20) (0.0163005 0.339829 -3.30444e-20) (0.197336 0.122883 1.26114e-19) (0.189831 0.161082 8.7076e-20) (0.184793 0.202348 -8.60784e-20) (0.171347 0.238025 8.68722e-20) (0.151668 0.266972 -1.07502e-19) (0.130326 0.290993 0) (0.102207 0.308838 -2.14575e-20) (0.0772257 0.324541 1.66175e-22) (0.0435884 0.337256 -2.13898e-20) (0.0172115 0.34808 -2.14232e-20) (0.223816 0.114379 -1.0615e-19) (0.2095 0.155076 0) (0.199266 0.199275 -9.74507e-20) (0.182438 0.238068 1.71694e-19) (0.160363 0.269464 -6.3612e-20) (0.137229 0.295654 -1.05984e-20) (0.107483 0.314883 2.12723e-20) (0.0812243 0.331882 4.29838e-23) (0.0457742 0.345316 3.15411e-20) (0.018192 0.356597 3.15555e-20) (0.252207 0.10786 -9.29344e-20) (0.231299 0.149922 9.22314e-20) (0.215002 0.196446 1.16221e-20) (0.194111 0.238123 0) (0.169212 0.271913 0) (0.144011 0.300302 1.12614e-20) (0.112529 0.320936 4.45675e-20) (0.0850423 0.339322 -4.38815e-20) (0.0477996 0.353523 -1.09064e-20) (0.0192179 0.36537 1.08098e-20) (0.313325 0.11336 0) (0.279794 0.154248 0) (0.250653 0.201649 0) (0.220244 0.246951 0) (0.188574 0.284073 0) (0.158241 0.315747 0) (0.122678 0.338258 0) (0.0926243 0.358974 0) (0.0515341 0.374127 0) (0.0216158 0.386733 0) (0.373904 0.170016 0) (0.333824 0.205127 0) (0.296703 0.24579 0) (0.25874 0.28679 0) (0.220374 0.322448 0) (0.183227 0.353487 0) (0.141692 0.376409 0) (0.106571 0.397604 0) (0.058902 0.413336 0) (0.0257395 0.426834 0) (0.417222 0.213844 0) (0.375997 0.249375 0) (0.33656 0.288635 0) (0.295268 0.32827 0) (0.252833 0.3639 0) (0.210595 0.395067 0) (0.163784 0.419241 0) (0.123217 0.440647 0) (0.0686819 0.456804 0) (0.0300963 0.470678 0) (0.455145 0.253212 0) (0.415028 0.29105 0) (0.375387 0.331087 0) (0.33226 0.371254 0) (0.286635 0.408245 0) (0.240026 0.440934 0) (0.18797 0.467382 0) (0.14119 0.490513 0) (0.0789932 0.509804 0) (0.0338566 0.527854 0) (0.495749 0.292755 0) (0.45623 0.333638 0) (0.4163 0.375446 0) (0.37156 0.417275 0) (0.322869 0.456715 0) (0.27195 0.492161 0) (0.214496 0.521568 0) (0.161434 0.545727 0) (0.0916492 0.562796 0) (0.0383028 0.575835 0) (0.537792 0.326731 0) (0.498836 0.372778 0) (0.45889 0.418353 0) (0.4131 0.46375 0) (0.361902 0.507377 0) (0.307363 0.547474 0) (0.24517 0.582149 0) (0.18667 0.613301 0) (0.109785 0.642801 0) (0.0455281 0.671976 0) (0.58847 0.371102 0) (0.549749 0.420173 0) (0.509043 0.468407 0) (0.461773 0.517008 0) (0.406919 0.564824 0) (0.34561 0.609194 0) (0.272799 0.646828 0) (0.199433 0.675151 0) (0.10807 0.692899 0) (0.0415788 0.705577 0) (0.629591 0.386913 0) (0.594237 0.445816 0) (0.554953 0.502608 0) (0.509932 0.560692 0) (0.457799 0.619931 0) (0.400186 0.678466 0) (0.330772 0.733571 0) (0.260185 0.784848 0) (0.162386 0.828011 0) (0.0643565 0.861417 0) (0.669261 0.441286 0) (0.658174 0.508845 0) (0.624845 0.567872 0) (0.574642 0.624604 0) (0.509562 0.681542 0) (0.433384 0.735892 0) (0.342679 0.783702 0) (0.252191 0.821897 0) (0.145837 0.852345 0) (0.0569211 0.878611 0) (0.583284 0.337592 0) (0.637515 0.457594 0) (0.659833 0.566586 0) (0.652012 0.66809 0) (0.614823 0.765743 0) (0.554325 0.859858 0) (0.463982 0.946919 0) (0.358204 1.02282 0) (0.217867 1.08367 0) (0.0810499 1.1279 0) (0.358815 0.105461 8.26041e-20) (0.415095 0.154193 -8.19595e-20) (0.45406 0.194709 8.87759e-21) (0.489901 0.231091 0) (0.528802 0.267593 0) (0.569871 0.297541 5.38568e-21) (0.615724 0.339243 -1.39366e-20) (0.64999 0.347111 1.3705e-20) (0.653859 0.390848 6.31186e-22) (0.532144 0.256674 -6.31356e-22) (0.384574 0.106012 -9.96941e-20) (0.433281 0.153358 0) (0.468216 0.191019 5.49391e-20) (0.502699 0.225197 -1.17489e-19) (0.540695 0.259718 6.67358e-20) (0.581512 0.287983 -5.21434e-21) (0.624567 0.327467 7.68469e-21) (0.654881 0.331613 8.53389e-21) (0.641675 0.36856 -6.81522e-22) (0.507701 0.22157 -1.50499e-21) (0.406592 0.10963 1.15949e-19) (0.449194 0.154588 -6.86344e-20) (0.481303 0.18873 6.78253e-20) (0.514952 0.220251 -5.33987e-20) (0.5523 0.25242 4.04043e-20) (0.592766 0.278904 0) (0.632786 0.315485 -7.75136e-21) (0.658023 0.315584 -3.9241e-22) (0.62714 0.344823 -2.68764e-21) (0.480743 0.185899 1.0482e-21) (0.426448 0.114475 -1.87886e-20) (0.463648 0.155535 0) (0.493729 0.185977 0) (0.526773 0.214808 0) (0.563575 0.244603 3.3239e-20) (0.60341 0.269349 -2.13867e-20) (0.640081 0.302626 1.32779e-21) (0.658941 0.298474 -2.7105e-21) (0.610187 0.319526 -1.93552e-22) (0.450977 0.149939 1.96451e-21) (0.444089 0.119218 -3.77602e-21) (0.476364 0.155298 -5.37557e-20) (0.505043 0.182103 -2.89991e-20) (0.537719 0.208403 2.88919e-20) (0.574094 0.235955 -1.17364e-20) (0.61306 0.259036 0) (0.646045 0.288685 -7.10928e-21) (0.657385 0.280121 7.06386e-21) (0.590796 0.292643 -3.0018e-21) (0.418467 0.114 -1.79717e-21) (0.459139 0.122939 -1.39949e-19) (0.487252 0.153527 2.07132e-20) (0.515149 0.176913 3.28358e-21) (0.54771 0.200935 2.8251e-20) (0.583756 0.226422 0) (0.621594 0.247878 0) (0.650504 0.273585 0) (0.653331 0.260466 3.38848e-21) (0.569278 0.264119 0) (0.383907 0.0785572 0) (0.471422 0.125027 0) (0.496357 0.150128 4.70825e-20) (0.524044 0.170406 -3.09769e-20) (0.556724 0.192434 -2.38663e-20) (0.592493 0.216037 2.38999e-20) (0.628911 0.235847 7.45041e-21) (0.653313 0.257299 -8.82875e-21) (0.646767 0.239471 -1.25093e-20) (0.546147 0.233699 1.38424e-21) (0.348893 0.0444558 3.03767e-21) (0.480903 0.125132 0) (0.50375 0.145148 -1.60688e-20) (0.531727 0.162669 -7.19977e-21) (0.564728 0.182983 0) (0.60023 0.204857 4.21808e-21) (0.634915 0.22294 -1.36306e-20) (0.654344 0.239845 8.38811e-21) (0.637667 0.217097 8.73778e-22) (0.521823 0.200755 -6.40792e-22) (0.313218 0.0131269 -3.22605e-21) (0.487638 0.12312 1.73453e-20) (0.50951 0.138715 1.50173e-20) (0.538199 0.153831 -4.33609e-21) (0.571689 0.172673 3.09875e-21) (0.606901 0.192938 5.27781e-21) (0.639537 0.209172 6.10444e-21) (0.653524 0.221299 -1.39297e-21) (0.626085 0.193374 -6.58099e-22) (0.496257 0.164843 6.43299e-22) (0.266539 -0.0140297 -7.74711e-22) (0.491747 0.119029 -4.0368e-21) (0.51371 0.130995 4.10455e-21) (0.543463 0.144034 -3.5538e-21) (0.577577 0.161597 -3.09677e-21) (0.612455 0.180338 2.25621e-21) (0.642752 0.194581 -4.26072e-21) (0.650867 0.201788 1.89176e-21) (0.612263 0.16854 1.59406e-22) (0.469861 0.127672 0) (0.236487 -0.0379412 7.76244e-22) (0.493387 0.11302 4.04319e-21) (0.516419 0.122162 -4.10649e-21) (0.547519 0.133413 -3.52165e-21) (0.582375 0.149835 -3.03947e-21) (0.61687 0.167109 -2.20981e-21) (0.644579 0.179226 3.27136e-22) (0.646486 0.181459 8.03443e-22) (0.596594 0.142943 1.04387e-21) (0.442644 0.0914594 0) (0.207446 -0.0608791 5.50178e-22) (0.492696 0.105328 0) (0.517715 0.112371 -1.48892e-20) (0.550369 0.122092 2.55313e-20) (0.586065 0.137462 3.03945e-21) (0.620143 0.153307 4.94659e-21) (0.645082 0.163178 5.59878e-21) (0.640579 0.160466 -1.2733e-21) (0.579565 0.116879 -5.69225e-22) (0.415353 0.0565335 3.16635e-22) (0.180826 -0.0837018 -5.48731e-22) (0.489788 0.0962168 0) (0.517665 0.101742 -1.59862e-20) (0.552002 0.110185 -7.06587e-21) (0.588633 0.124548 0) (0.622285 0.13899 -1.35215e-20) (0.644354 0.146518 4.90486e-21) (0.633375 0.13894 3.014e-21) (0.561752 0.0905097 3.71693e-21) (0.389075 0.0227079 -3.1539e-22) (0.15701 -0.106545 -1.5652e-21) (0.484843 0.0859679 0) (0.516209 0.0903675 1.60483e-20) (0.552385 0.0978003 0) (0.59007 0.111163 2.19433e-20) (0.623336 0.124222 -2.19807e-20) (0.642528 0.129335 -5.92522e-21) (0.625085 0.116978 1.22819e-21) (0.543725 0.0638637 -3.28137e-21) (0.363941 -0.0101955 -7.16507e-22) (0.135404 -0.129546 1.67838e-21) (0.478022 0.0748966 1.44411e-19) (0.513338 0.0783513 -5.51961e-20) (0.551566 0.0850092 -4.18596e-21) (0.590449 0.0973773 -2.67457e-20) (0.623438 0.10907 0) (0.639819 0.111738 -5.8209e-21) (0.615936 0.0946536 2.66073e-21) (0.525583 0.037047 5.03496e-21) (0.340045 -0.0421624 -1.11977e-22) (0.11609 -0.152629 1.11351e-22) (0.469504 0.0633156 6.3328e-21) (0.509286 0.0657601 8.81394e-20) (0.54978 0.0718789 2.72068e-20) (0.590005 0.0832592 -2.71174e-20) (0.622851 0.0936065 -9.88083e-21) (0.636501 0.09386 0) (0.606418 0.0721483 -7.41119e-21) (0.507483 0.0101775 3.78551e-21) (0.317613 -0.0731996 9.81412e-22) (0.0990446 -0.175558 -9.45382e-22) (0.459601 0.0515042 -1.97347e-20) (0.504225 0.0526499 0) (0.547131 0.0584793 0) (0.588773 0.0689013 0) (0.621589 0.0779349 -7.15146e-21) (0.632649 0.0757992 1.69302e-20) (0.596761 0.0496161 7.30123e-21) (0.489746 -0.0165828 -6.31497e-21) (0.29653 -0.103328 -1.78671e-22) (0.0841199 -0.198157 1.10998e-21) (0.447985 0.0397934 -4.293e-20) (0.497176 0.0391622 6.75457e-20) (0.542534 0.0449348 -6.67844e-20) (0.58566 0.0544436 4.62898e-20) (0.618695 0.062176 -5.61309e-20) (0.627599 0.0576693 0) (0.586549 0.0271635 -4.29043e-21) (0.472499 -0.0431136 1.19692e-23) (0.276851 -0.132546 -8.21565e-23) (0.0711677 -0.220307 6.67856e-22) (0.433188 0.0289467 -2.09475e-20) (0.486082 0.0256168 0) (0.534181 0.0313985 -6.79266e-20) (0.579191 0.0400043 1.06836e-19) (0.613059 0.0463744 -3.70951e-20) (0.620598 0.0394567 -3.66672e-21) (0.575351 0.00472444 4.25248e-21) (0.455538 -0.0694528 7.64769e-22) (0.258578 -0.160914 1.04785e-21) (0.0600099 -0.241933 -7.91176e-22) (0.418256 0.0201801 -9.75134e-20) (0.474703 0.0123321 9.65616e-20) (0.526239 0.0178866 9.76212e-21) (0.573648 0.0255644 0) (0.60863 0.0304811 0) (0.614753 0.021093 4.34364e-21) (0.565096 -0.0177892 6.92371e-21) (0.439382 -0.0956951 -6.7173e-21) (0.241596 -0.188559 1.24282e-22) (0.050272 -0.26305 -1.19228e-22) (0.405452 0.00373826 0) (0.468326 -0.0181336 0) (0.527532 -0.0146158 0) (0.579461 -0.00935769 0) (0.614859 -0.00794298 0) (0.6139 -0.023115 0) (0.54898 -0.0715927 0) (0.404707 -0.158148 0) (0.203009 -0.253135 0) (0.0294398 -0.312404 0) (0.417831 -0.0719928 0) (0.480268 -0.0839691 0) (0.540677 -0.078916 0) (0.588373 -0.0745983 0) (0.605878 -0.0812699 0) (0.569066 -0.114323 0) (0.460752 -0.185937 0) (0.29309 -0.285145 0) (0.115863 -0.371095 0) (0.00283253 -0.409369 0) (0.414702 -0.139544 0) (0.480522 -0.151301 0) (0.541871 -0.148853 0) (0.582808 -0.150904 0) (0.579332 -0.171206 0) (0.509881 -0.224678 0) (0.374041 -0.313577 0) (0.203912 -0.412828 0) (0.0576582 -0.480702 0) (-0.00669175 -0.501206 0) (0.412393 -0.210598 0) (0.480868 -0.226128 0) (0.540621 -0.2299 0) (0.567862 -0.243357 0) (0.534897 -0.281913 0) (0.430287 -0.355572 0) (0.276231 -0.453819 0) (0.121525 -0.541561 0) (0.0183785 -0.585519 0) (-0.00688878 -0.592157 0) (0.401597 -0.285144 0) (0.471116 -0.308877 0) (0.526227 -0.325052 0) (0.534556 -0.356934 0) (0.47025 -0.41745 0) (0.339509 -0.506402 0) (0.185446 -0.601047 0) (0.0608895 -0.665895 0) (1.00591e-05 -0.686017 0) (-0.00268653 -0.685354 0) (0.379838 -0.363692 0) (0.449136 -0.401646 0) (0.496129 -0.438239 0) (0.48193 -0.494684 0) (0.389736 -0.575976 0) (0.247206 -0.66959 0) (0.111125 -0.746906 0) (0.0252354 -0.783119 0) (-0.00206072 -0.785494 0) (0.00149397 -0.783882 0) (0.343037 -0.444823 0) (0.407231 -0.50396 0) (0.440699 -0.568402 0) (0.404484 -0.652197 0) (0.296821 -0.748512 0) (0.163041 -0.834914 0) (0.0602497 -0.886593 0) (0.0121034 -0.898004 0) (0.00353406 -0.893358 0) (0.00305915 -0.894518 0) (0.279526 -0.523335 0) (0.331224 -0.606069 0) (0.349607 -0.70461 0) (0.301945 -0.81722 0) (0.200548 -0.923772 0) (0.0964465 -0.997423 0) (0.03329 -1.02594 0) (0.0121768 -1.02449 0) (0.00800253 -1.02278 0) (0.00199479 -1.02677 0) (0.182703 -0.577891 0) (0.219829 -0.69446 0) (0.227702 -0.831868 0) (0.185528 -0.973828 0) (0.11231 -1.08649 0) (0.0499291 -1.14676 0) (0.0207059 -1.16174 0) (0.0124306 -1.16138 0) (0.00689718 -1.16695 0) (0.000332887 -1.17113 0) (0.0762543 -0.611942 0) (0.0884648 -0.75437 0) (0.0859398 -0.922806 0) (0.063345 -1.08168 0) (0.0341372 -1.19137 0) (0.0150154 -1.24097 0) (0.00838155 -1.25386 0) (0.00564253 -1.26103 0) (0.00230291 -1.27096 0) (-0.000157268 -1.27355 0) (0.372041 -0.0160678 1.06129e-19) (0.374686 -0.0877871 -1.05249e-19) (0.372957 -0.154168 1.33149e-20) (0.368028 -0.221754 0) (0.354454 -0.289828 0) (0.330561 -0.358674 1.378e-20) (0.292906 -0.425163 -5.68587e-20) (0.236118 -0.48732 5.64137e-20) (0.151128 -0.52291 1.48198e-20) (0.0633085 -0.542911 -1.47221e-20) (0.354644 -0.0297054 -1.2023e-19) (0.355975 -0.098463 0) (0.355136 -0.16219 8.40516e-20) (0.349446 -0.226851 -1.9037e-19) (0.335075 -0.291258 1.18775e-19) (0.310595 -0.355701 -1.2018e-20) (0.272753 -0.416341 2.48094e-20) (0.218626 -0.471543 5.0727e-20) (0.138457 -0.500858 1.341e-20) (0.0578702 -0.515331 1.31378e-20) (0.336321 -0.043578 1.44682e-19) (0.337895 -0.109702 -9.6611e-20) (0.337797 -0.170553 9.54775e-20) (0.331312 -0.231821 -9.72407e-20) (0.31621 -0.29226 7.21493e-20) (0.291248 -0.352139 0) (0.253438 -0.407212 -2.503e-20) (0.201855 -0.455577 1.85419e-22) (0.126472 -0.479727 -2.61427e-20) (0.0526439 -0.489301 -2.64951e-20) (0.317837 -0.0563818 -2.40589e-20) (0.320432 -0.119238 0) (0.320941 -0.177415 0) (0.313743 -0.235374 0) (0.298042 -0.29206 7.46319e-20) (0.272753 -0.34761 -4.95804e-20) (0.235214 -0.397619 -1.93401e-22) (0.18608 -0.439883 -2.63086e-20) (0.115376 -0.459596 -1.33749e-20) (0.0477464 -0.465068 -1.35512e-20) (0.299675 -0.0684425 2.07781e-22) (0.30369 -0.127351 -7.2539e-20) (0.30464 -0.1827 -4.90034e-20) (0.296856 -0.237346 4.88293e-20) (0.280712 -0.290469 -2.48109e-20) (0.255271 -0.341983 0) (0.218209 -0.387455 -2.58468e-20) (0.171437 -0.42447 5.30417e-20) (0.105245 -0.440457 -2.66692e-20) (0.0432185 -0.442654 2.73083e-20) (0.282104 -0.0797739 -1.94835e-19) (0.287748 -0.134368 2.43022e-20) (0.288997 -0.186665 -4.94425e-22) (0.280777 -0.23796 4.92811e-20) (0.26434 -0.287656 0) (0.23892 -0.335404 0) (0.202498 -0.376832 0) (0.157983 -0.409354 2.6743e-20) (0.0960659 -0.422296 0) (0.0390661 -0.421954 0) (0.265327 -0.0902292 0) (0.27265 -0.140324 7.36267e-20) (0.274091 -0.189404 -4.91381e-20) (0.265592 -0.237375 -5.03638e-20) (0.249006 -0.283803 5.04424e-20) (0.223764 -0.328063 2.61669e-20) (0.188103 -0.365913 -2.60511e-20) (0.145719 -0.394612 -9.41942e-20) (0.087784 -0.405111 6.72787e-21) (0.0352809 -0.402863 -2.08831e-20) (0.249528 -0.0997123 0) (0.258426 -0.145226 -2.44486e-20) (0.259972 -0.190971 -1.24395e-20) (0.251345 -0.235709 0) (0.234741 -0.279053 1.29759e-20) (0.209817 -0.320115 -3.89658e-20) (0.175001 -0.35483 4.00241e-20) (0.134609 -0.380315 1.36305e-20) (0.0803261 -0.388891 -1.3795e-20) (0.0318496 -0.385289 2.80106e-20) (0.234887 -0.108176 2.45978e-20) (0.24511 -0.149129 2.47396e-20) (0.246682 -0.191462 -6.17454e-21) (0.238049 -0.23309 6.33666e-21) (0.221538 -0.273547 1.28393e-20) (0.197053 -0.311701 1.9663e-20) (0.163135 -0.343688 -6.69896e-21) (0.124594 -0.366507 -6.80787e-21) (0.0736181 -0.373611 1.38495e-20) (0.0287576 -0.369141 7.01289e-21) (0.22157 -0.115592 -6.14977e-21) (0.232735 -0.152104 6.1921e-21) (0.234254 -0.190998 -6.24308e-21) (0.225699 -0.229665 -6.33543e-21) (0.209372 -0.267434 6.50872e-21) (0.185419 -0.302956 -1.31131e-20) (0.152426 -0.332583 1.00825e-20) (0.115603 -0.353214 3.42817e-21) (0.0675929 -0.359238 0) (0.0259916 -0.354324 -7.02919e-21) (0.209735 -0.121945 6.1737e-21) (0.221343 -0.154222 -6.21969e-21) (0.22272 -0.189711 -6.29902e-21) (0.214279 -0.22558 -6.38568e-21) (0.198201 -0.26086 -6.52606e-21) (0.174849 -0.294008 -4.56877e-23) (0.142791 -0.321602 3.34296e-21) (0.107565 -0.340455 1.02081e-20) (0.0621941 -0.345736 0) (0.0235403 -0.340743 -7.00008e-21) (0.199517 -0.127222 0) (0.210974 -0.155548 -2.50853e-20) (0.212105 -0.187724 4.41429e-20) (0.20377 -0.220971 6.38855e-21) (0.18798 -0.25396 1.30073e-20) (0.165274 -0.284973 1.98074e-20) (0.134144 -0.310821 -6.7124e-21) (0.100413 -0.328238 -6.80571e-21) (0.0573737 -0.333064 1.37701e-20) (0.0213924 -0.3283 6.98347e-21) (0.191021 -0.131418 0) (0.201667 -0.156134 -2.51744e-20) (0.202423 -0.18515 -1.26715e-20) (0.194147 -0.215957 0) (0.178657 -0.246854 -3.91737e-20) (0.156618 -0.275949 1.30588e-20) (0.126398 -0.300304 1.33286e-20) (0.0940767 -0.316568 4.05758e-20) (0.0530868 -0.321181 -1.37163e-20) (0.019536 -0.316895 2.76717e-20) (0.184303 -0.134533 0) (0.193444 -0.15602 2.52858e-20) (0.193674 -0.182091 0) (0.185375 -0.210645 5.17317e-20) (0.170175 -0.239646 -5.18104e-20) (0.148801 -0.267021 -2.64911e-20) (0.119463 -0.290108 -1.52203e-22) (0.0884854 -0.305444 -4.03559e-20) (0.0492881 -0.310043 -6.73951e-21) (0.017958 -0.30643 -3.4332e-20) (0.179358 -0.136576 2.02912e-19) (0.18631 -0.155234 -7.62209e-20) (0.185827 -0.178627 3.48133e-22) (0.177402 -0.205122 -5.1388e-20) (0.162461 -0.232423 0) (0.141733 -0.258259 -2.64051e-20) (0.113246 -0.28028 -2.27778e-22) (0.0835634 -0.294862 5.33882e-20) (0.045929 -0.299606 6.73791e-21) (0.0166442 -0.296808 -6.77348e-21) (0.176105 -0.13756 -8.0664e-23) (0.18023 -0.153789 1.28357e-19) (0.178821 -0.174829 5.16899e-20) (0.170153 -0.199465 -5.15077e-20) (0.155425 -0.22526 -2.60022e-20) (0.135313 -0.249722 0) (0.107644 -0.270858 -5.27785e-20) (0.0792268 -0.284817 2.62889e-20) (0.0429558 -0.289831 2.6524e-20) (0.0155804 -0.287937 2.67168e-20) (0.174371 -0.137526 -2.59114e-20) (0.175127 -0.151709 0) (0.172555 -0.170761 0) (0.163525 -0.193744 0) (0.148955 -0.218225 -2.6185e-20) (0.129417 -0.24146 5.18636e-20) (0.102539 -0.261877 5.23844e-20) (0.075381 -0.275304 -7.84913e-20) (0.04031 -0.280683 1.31337e-20) (0.0147528 -0.279733 -3.95218e-20) (0.17387 -0.136555 -5.23046e-20) (0.17086 -0.149008 1.05149e-19) (0.166888 -0.166453 -1.03932e-19) (0.157377 -0.187984 1.04273e-19) (0.142907 -0.211343 -1.29138e-19) (0.123896 -0.233493 0) (0.0977968 -0.253357 -2.58744e-20) (0.0719164 -0.266316 5.59632e-23) (0.0379268 -0.272134 -2.58104e-20) (0.0141475 -0.272116 -2.58342e-20) (0.174202 -0.134593 -2.67279e-20) (0.167235 -0.145546 0) (0.161637 -0.161756 -1.1843e-19) (0.151529 -0.182055 2.08154e-19) (0.137096 -0.204504 -7.71199e-20) (0.118554 -0.225735 -1.28494e-20) (0.0932441 -0.245253 2.56502e-20) (0.0686958 -0.257818 -2.94332e-23) (0.0357308 -0.264153 3.80864e-20) (0.0137485 -0.265011 3.80881e-20) (0.17489 -0.131166 -1.17061e-19) (0.16397 -0.141206 1.15714e-19) (0.156567 -0.156679 1.42846e-20) (0.145728 -0.176029 0) (0.131261 -0.197764 0) (0.113118 -0.218245 1.37889e-20) (0.0886376 -0.237581 5.4734e-20) (0.0655252 -0.249829 -5.3921e-20) (0.033622 -0.256732 -1.3397e-20) (0.013531 -0.258382 1.32899e-20) (0.175918 -0.122123 0) (0.156845 -0.132675 0) (0.145204 -0.147763 0) (0.13208 -0.165441 0) (0.116994 -0.185293 0) (0.0992802 -0.203655 0) (0.0767682 -0.221808 0) (0.0574053 -0.232763 0) (0.0284596 -0.240645 0) (0.013343 -0.244009 0) (0.162631 -0.103232 0) (0.142746 -0.119474 0) (0.129352 -0.13603 0) (0.115011 -0.152965 0) (0.0998114 -0.17049 0) (0.082876 -0.18678 0) (0.0629365 -0.202263 0) (0.0481278 -0.212756 0) (0.0231056 -0.220547 0) (0.0133181 -0.225049 0) (0.144717 -0.0869829 0) (0.126739 -0.104274 0) (0.113413 -0.1213 0) (0.0992019 -0.138079 0) (0.084555 -0.154828 0) (0.0688138 -0.170677 0) (0.0508724 -0.185154 0) (0.0395047 -0.19657 0) (0.0177885 -0.204287 0) (0.0120846 -0.208873 0) (0.126252 -0.07435 0) (0.110546 -0.0907655 0) (0.0974932 -0.106989 0) (0.083497 -0.123075 0) (0.0692459 -0.139284 0) (0.0545326 -0.15518 0) (0.0378804 -0.169765 0) (0.029273 -0.18276 0) (0.0108273 -0.191368 0) (0.00946812 -0.196338 0) (0.108775 -0.0637283 0) (0.0950599 -0.0786971 0) (0.082139 -0.0936972 0) (0.0680393 -0.108931 0) (0.0536529 -0.124743 0) (0.0394673 -0.141041 0) (0.023268 -0.156486 0) (0.0167689 -0.171705 0) (0.00180113 -0.182782 0) (0.00571401 -0.189352 0) (0.0939635 -0.0538128 0) (0.0817813 -0.0666799 0) (0.0684366 -0.0800854 0) (0.0535398 -0.0943798 0) (0.0381168 -0.109972 0) (0.0235646 -0.127144 0) (0.00674365 -0.144574 0) (0.0011897 -0.163086 0) (-0.0102446 -0.179315 0) (0.000618923 -0.18996 0) (0.0874714 -0.0440606 0) (0.0764364 -0.0540599 0) (0.0615952 -0.0653478 0) (0.0446358 -0.0783474 0) (0.0265702 -0.0935573 0) (0.00955233 -0.111633 0) (-0.0100961 -0.132466 0) (-0.017681 -0.15614 0) (-0.0275094 -0.181573 0) (-0.00705255 -0.201717 0) (0.114544 -0.0327374 0) (0.104235 -0.0393039 0) (0.0862367 -0.0478564 0) (0.0653566 -0.0586674 0) (0.0421034 -0.0724695 0) (0.018018 -0.0903938 0) (-0.0105565 -0.114917 0) (-0.0287552 -0.145302 0) (-0.0483419 -0.184706 0) (-0.0190529 -0.222886 0) (0.257256 -0.016775 0) (0.248154 -0.0206068 0) (0.226858 -0.0258061 0) (0.20237 -0.0325474 0) (0.173074 -0.0420488 0) (0.137737 -0.0560817 0) (0.0930092 -0.0776498 0) (0.0479135 -0.108767 0) (-0.0185414 -0.176281 0) (-0.0276063 -0.299359 0) (0.663487 -0.00380358 0) (0.65902 -0.00587217 0) (0.643842 -0.00792566 0) (0.627088 -0.0109027 0) (0.604474 -0.0159071 0) (0.574151 -0.0244383 0) (0.530165 -0.0389255 0) (0.460431 -0.0650726 0) (0.346859 -0.119621 0) (0.261176 -0.206848 0) (0.185152 -0.110817 1.20327e-19) (0.168306 -0.0885256 -1.18782e-19) (0.148323 -0.0733405 1.45865e-20) (0.129022 -0.0617927 0) (0.111634 -0.0523342 0) (0.0978796 -0.0435699 1.37698e-20) (0.0942616 -0.0349781 -5.41275e-20) (0.127831 -0.0259264 5.353e-20) (0.278311 -0.0143707 1.34279e-20) (0.675688 -0.00344436 -1.36641e-20) (0.188847 -0.104698 -1.31131e-19) (0.169706 -0.0815868 0) (0.148791 -0.0672498 9.02673e-20) (0.129357 -0.0563416 -2.03341e-19) (0.112299 -0.0475306 1.25408e-19) (0.0993356 -0.0393922 -1.23833e-20) (0.0974101 -0.0314278 2.44701e-20) (0.134248 -0.0233267 4.847e-20) (0.287831 -0.0134907 1.20397e-20) (0.681507 -0.00338283 1.18574e-20) (0.191957 -0.0973503 1.54118e-19) (0.170746 -0.0742508 -1.033e-19) (0.148965 -0.06101 1.0214e-19) (0.129495 -0.0508379 -1.0145e-19) (0.112845 -0.0427675 7.53415e-20) (0.100733 -0.0353662 0) (0.100523 -0.0281727 -2.46858e-20) (0.14053 -0.0210445 -6.4611e-24) (0.297083 -0.0127588 -2.43855e-20) (0.687473 -0.00339685 -2.40675e-20) (0.195005 -0.088813 -2.52293e-20) (0.172024 -0.0665413 0) (0.149402 -0.0545743 0) (0.129837 -0.0452521 0) (0.113504 -0.0380268 7.54492e-20) (0.102133 -0.031472 -5.0025e-20) (0.103432 -0.0251677 8.51154e-25) (0.146176 -0.0190395 -2.47607e-20) (0.305383 -0.0121503 -1.23559e-20) (0.693017 -0.00347319 -1.21938e-20) (0.197962 -0.0791281 5.42114e-22) (0.173418 -0.0584393 -7.52031e-20) (0.150005 -0.0478919 -5.05725e-20) (0.130304 -0.0395557 5.04034e-20) (0.11421 -0.0332892 -2.51807e-20) (0.103469 -0.0276856 0) (0.106079 -0.0223616 -2.50365e-20) (0.151155 -0.0172467 4.99695e-20) (0.312677 -0.0116106 -2.49563e-20) (0.698049 -0.00358455 2.46835e-20) (0.200647 -0.0683085 -1.97035e-19) (0.174792 -0.049906 2.43336e-20) (0.150629 -0.04092 -1.57373e-22) (0.130781 -0.0337329 5.02975e-20) (0.114866 -0.0285444 0) (0.104658 -0.0239913 0) (0.108393 -0.0197187 0) (0.155445 -0.0156165 2.51583e-20) (0.318988 -0.011097 0) (0.702613 -0.00370478 0) (0.202918 -0.0563558 0) (0.176129 -0.0409058 7.47713e-20) (0.151189 -0.0336201 -4.99617e-20) (0.131206 -0.0277755 -5.03119e-20) (0.115408 -0.0237831 5.03933e-20) (0.105631 -0.0203727 2.52365e-20) (0.110301 -0.0172065 -2.52865e-20) (0.158984 -0.0141073 -8.85878e-20) (0.324283 -0.010582 6.33821e-21) (0.706712 -0.00381571 -1.88353e-20) (0.204741 -0.0433114 0) (0.177293 -0.0314157 -2.47792e-20) (0.151672 -0.025956 -1.24731e-20) (0.13153 -0.0216837 0) (0.115788 -0.018995 1.26072e-20) (0.106333 -0.0168098 -3.79384e-20) (0.111738 -0.0147913 3.80261e-20) (0.161711 -0.0126795 1.27091e-20) (0.328508 -0.0100447 -1.27447e-20) (0.710311 -0.00390448 2.52803e-20) (0.206075 -0.029283 2.38918e-20) (0.178136 -0.0214296 2.47291e-20) (0.152044 -0.0179479 -6.15684e-21) (0.131707 -0.0154471 6.2711e-21) (0.115959 -0.0141676 1.26122e-20) (0.10672 -0.0132796 1.89912e-20) (0.11266 -0.0124392 -6.34873e-21) (0.163581 -0.0112961 -6.36798e-21) (0.331619 -0.00946663 1.27949e-20) (0.713374 -0.00396096 6.33721e-21) (0.206803 -0.0144025 -6.03394e-21) (0.178648 -0.0109712 6.11355e-21) (0.152221 -0.00962474 -6.21866e-21) (0.131687 -0.00906453 -6.26952e-21) (0.115882 -0.00928863 6.30478e-21) (0.106756 -0.00975757 -1.26679e-20) (0.113033 -0.0101176 9.53174e-21) (0.164568 -0.00992409 3.1881e-21) (0.333589 -0.00883212 0) (0.715864 -0.00397829 -6.35122e-21) (0.206852 0.00117046 6.02782e-21) (0.178795 -9.31612e-05 -6.10714e-21) (0.152138 -0.00102288 -6.21341e-21) (0.13143 -0.00254098 -6.2663e-21) (0.11553 -0.00434562 -6.3042e-21) (0.106421 -0.00621806 1.08528e-24) (0.11284 -0.00779617 3.17818e-21) (0.164662 -0.00853683 9.55964e-21) (0.334406 -0.00812569 0) (0.717749 -0.00394837 -6.33891e-21) (0.206205 0.0172507 0) (0.178523 0.011134 -2.46679e-20) (0.151759 0.00780926 4.34213e-20) (0.130912 0.00411452 6.26878e-21) (0.11489 0.000673212 1.26082e-20) (0.105706 -0.00263582 1.89844e-20) (0.112079 -0.0054472 -6.34532e-21) (0.163865 -0.00711306 -6.36105e-21) (0.334064 -0.00733328 1.27568e-20) (0.719006 -0.00386399 6.32422e-21) (0.204878 0.0336308 0) (0.177794 0.0226296 -2.45784e-20) (0.151069 0.0168125 -1.24556e-20) (0.130127 0.0108894 0) (0.113959 0.00577757 -3.78091e-20) (0.104615 0.00101255 1.2644e-20) (0.110761 -0.00304626 1.26725e-20) (0.162198 -0.00563662 3.80279e-20) (0.332571 -0.00644093 -1.2707e-20) (0.719607 -0.00371731 2.51375e-20) (0.202918 0.0500862 0) (0.176586 0.0343061 2.46874e-20) (0.150073 0.0259185 0) (0.129079 0.0177661 5.02714e-20) (0.112753 0.0109727 -5.03456e-20) (0.103165 0.00474695 -2.52106e-20) (0.108909 -0.000572284 2.35937e-23) (0.159696 -0.00409615 -3.78382e-20) (0.329952 -0.00543415 -6.31865e-21) (0.719531 -0.00349841 -3.12087e-20) (0.200392 0.066376 1.93231e-19) (0.174902 0.0460671 -7.34896e-20) (0.148788 0.03505 4.20076e-22) (0.12779 0.0247184 -5.01549e-20) (0.111294 0.0162569 0) (0.101382 0.00858212 -2.51498e-20) (0.106557 0.00199309 6.25511e-23) (0.156407 -0.00248316 5.0155e-20) (0.32625 -0.00429805 6.25704e-21) (0.718757 -0.0031948 -6.18121e-21) (0.19739 0.0822383 -2.70927e-21) (0.172776 0.0577996 1.2403e-19) (0.147248 0.0441195 5.04067e-20) (0.126291 0.0317075 -5.02225e-20) (0.109619 0.0216182 -2.51812e-20) (0.0993039 0.0125266 0) (0.10375 0.0046674 -4.99494e-20) (0.152401 -0.000788114 2.49353e-20) (0.32153 -0.00301758 2.48078e-20) (0.717269 -0.00279117 2.44456e-20) (0.194042 0.0973754 -2.47066e-20) (0.170289 0.0693586 0) (0.14551 0.0530253 0) (0.124637 0.0386781 0) (0.107775 0.0270326 -2.51696e-20) (0.09698 0.0165819 5.00372e-20) (0.100543 0.00747021 4.96256e-20) (0.147755 0.00100621 -7.3979e-20) (0.315876 -0.00157721 1.22497e-20) (0.715054 -0.00226789 -3.62021e-20) (0.190506 0.111419 -4.75958e-20) (0.167572 0.0805497 1.01999e-19) (0.143668 0.0616482 -1.00794e-19) (0.122914 0.0455561 1.01381e-19) (0.105844 0.0324632 -1.25512e-19) (0.0944836 0.0207444 0) (0.0969901 0.0104314 -2.46813e-20) (0.142496 0.0029382 -5.80763e-24) (0.309306 3.60871e-05 -2.41664e-20) (0.712097 -0.00159709 -2.38067e-20) (0.186521 0.123878 -2.5393e-20) (0.164592 0.0910938 0) (0.141733 0.0698391 -1.15364e-19) (0.121183 0.0522461 2.0269e-19) (0.103904 0.0378605 -7.51252e-20) (0.0918979 0.0250135 -1.24156e-20) (0.0931358 0.0136163 2.44666e-20) (0.136555 0.0051008 4.7922e-23) (0.301615 0.00180793 3.57712e-20) (0.708294 -0.00076341 3.51315e-20) (0.181226 0.134089 -1.10605e-19) (0.160947 0.10053 1.09946e-19) (0.139372 0.0773774 1.39191e-20) (0.11921 0.0586119 0) (0.101807 0.0431519 0) (0.089192 0.0293884 1.3515e-20) (0.0891427 0.0171377 5.30355e-20) (0.130395 0.00767726 -5.2081e-20) (0.293396 0.00364853 -1.25693e-20) (0.703559 0.000133054 1.17931e-20) (0.171785 0.147969 0) (0.152302 0.116561 0) (0.132507 0.0917745 0) (0.112994 0.0718897 0) (0.095451 0.0549538 0) (0.082015 0.0398525 0) (0.0804787 0.0264105 0) (0.120166 0.0151578 0) (0.283408 0.00797146 0) (0.696817 0.00188241 0) (0.135958 0.154751 0) (0.121926 0.131135 0) (0.107088 0.107659 0) (0.0915101 0.0881788 0) (0.0768681 0.0701245 0) (0.0659841 0.0530989 0) (0.0676797 0.0372415 0) (0.111852 0.0229885 0) (0.278509 0.0116101 0) (0.691813 0.00342107 0) (0.110909 0.161983 0) (0.0992235 0.142676 0) (0.0860325 0.12086 0) (0.071938 0.102278 0) (0.0583737 0.0836449 0) (0.0483009 0.0649488 0) (0.0512211 0.0464286 0) (0.0978633 0.0285911 0) (0.268176 0.0130343 0) (0.685241 0.00355391 0) (0.0914902 0.170064 0) (0.0806818 0.154417 0) (0.0673203 0.134174 0) (0.0531458 0.116338 0) (0.0391869 0.0974102 0) (0.0284949 0.0773725 0) (0.0311868 0.0563187 0) (0.0791457 0.0348081 0) (0.253188 0.0148456 0) (0.677218 0.00327186 0) (0.0737942 0.181559 0) (0.0633576 0.167111 0) (0.0494507 0.148243 0) (0.0344581 0.131278 0) (0.0189732 0.112545 0) (0.00631054 0.091676 0) (0.00762536 0.0684008 0) (0.0563338 0.0432338 0) (0.23434 0.0184315 0) (0.667094 0.00352825 0) (0.0593379 0.192022 0) (0.0487139 0.179858 0) (0.0344343 0.163238 0) (0.0186632 0.148004 0) (0.00118646 0.130595 0) (-0.014873 0.10979 0) (-0.0170822 0.0849645 0) (0.0304178 0.0569025 0) (0.211382 0.0264894 0) (0.654912 0.00444122 0) (0.0406917 0.20588 0) (0.0303064 0.193094 0) (0.0159655 0.178427 0) (-0.000847218 0.165895 0) (-0.0205048 0.152159 0) (-0.0405996 0.134862 0) (-0.0477756 0.112531 0) (-0.00297579 0.0858055 0) (0.178724 0.0497865 0) (0.628798 0.0102497 0) (0.0332672 0.21649 0) (0.0240617 0.206281 0) (0.0109755 0.195588 0) (-0.0058449 0.187278 0) (-0.0277177 0.179361 0) (-0.0528336 0.169994 0) (-0.0672104 0.157573 0) (-0.0293598 0.142333 0) (0.144305 0.106849 0) (0.588706 0.025253 0) (0.0129079 0.228361 0) (0.00579316 0.218014 0) (-0.00424543 0.210862 0) (-0.0180442 0.209263 0) (-0.0384514 0.212609 0) (-0.0649462 0.220546 0) (-0.0857048 0.234667 0) (-0.0653031 0.256347 0) (0.0670594 0.240902 0) (0.459501 0.0779719 0) (0.0107122 0.23659 0) (0.00798055 0.227759 0) (0.00380879 0.223943 0) (-0.00201466 0.228714 0) (-0.0109036 0.245465 0) (-0.0225781 0.279747 0) (-0.0295986 0.342425 0) (-0.00939015 0.430843 0) (0.0832658 0.443631 0) (0.356469 0.182648 0) (0.161842 0.170947 1.1151e-19) (0.13168 0.173752 -1.10536e-19) (0.110506 0.177747 1.37468e-20) (0.0927336 0.184209 0) (0.0761059 0.194564 0) (0.0623754 0.204022 1.34242e-20) (0.0444079 0.216654 -5.34842e-20) (0.0361485 0.226217 5.27595e-20) (0.0158135 0.237224 1.31126e-20) (0.0112904 0.245202 -1.30122e-20) (0.156896 0.178607 -1.20187e-19) (0.129592 0.180447 0) (0.110411 0.183327 8.50459e-20) (0.0935068 0.18956 -1.9223e-19) (0.0773046 0.199496 1.19035e-19) (0.0638042 0.208935 -1.19281e-20) (0.0460411 0.220982 2.35817e-20) (0.0373165 0.230456 4.70748e-20) (0.017042 0.241039 1.16801e-20) (0.0114304 0.249125 1.16499e-20) (0.151108 0.184147 1.41007e-19) (0.127458 0.185675 -9.62036e-20) (0.110531 0.188199 9.51114e-20) (0.0946 0.194525 -9.58793e-20) (0.0788292 0.204207 7.10739e-20) (0.0655052 0.213818 0) (0.0478468 0.225305 -2.37902e-20) (0.0385395 0.234857 -1.3269e-22) (0.0183028 0.245014 -2.36875e-20) (0.0115127 0.253303 -2.37318e-20) (0.144625 0.188793 -2.31343e-20) (0.125296 0.190433 0) (0.110851 0.192984 0) (0.0960296 0.199461 0) (0.0807124 0.209079 7.13535e-20) (0.0674916 0.218804 -4.74132e-20) (0.0498476 0.229805 -1.27386e-22) (0.0398622 0.239425 -2.3878e-20) (0.0196002 0.249227 -1.19037e-20) (0.011569 0.257736 -1.18779e-20) (0.137717 0.192316 1.32279e-21) (0.12315 0.19455 -6.89478e-20) (0.111368 0.197524 -4.70236e-20) (0.0977991 0.204321 4.68637e-20) (0.0829605 0.214002 -2.37113e-20) (0.0697814 0.223848 0) (0.0520633 0.234497 -2.38813e-20) (0.041317 0.244158 4.78821e-20) (0.0209381 0.253718 -2.38926e-20) (0.0116213 0.262436 2.41183e-20) (0.130701 0.194439 -1.78972e-19) (0.121133 0.197734 2.18098e-20) (0.11213 0.201599 -4.54999e-22) (0.0999266 0.20898 4.65364e-20) (0.0855812 0.218888 0) (0.0723897 0.228934 0) (0.0545067 0.239361 0) (0.0429302 0.249068 2.38694e-20) (0.0223201 0.258487 0) (0.0116877 0.2674 0) (0.123968 0.195061 0) (0.119418 0.199855 6.8268e-20) (0.113223 0.205104 -4.56931e-20) (0.102441 0.213369 -4.66182e-20) (0.0885813 0.223706 4.6693e-20) (0.0753217 0.234063 2.36899e-20) (0.0571815 0.244396 -2.36069e-20) (0.044716 0.254177 -8.37657e-20) (0.0237458 0.263534 5.99535e-21) (0.011784 0.272629 -1.81181e-20) (0.117984 0.194135 0) (0.118223 0.200855 -2.25453e-20) (0.11476 0.207974 -1.13453e-20) (0.10538 0.217445 0) (0.0919667 0.228436 1.17731e-20) (0.0785757 0.239236 -3.52023e-20) (0.0600852 0.249603 3.5684e-20) (0.0466799 0.2595 1.20583e-20) (0.0252134 0.268866 -1.19818e-20) (0.0119225 0.278125 2.4343e-20) (0.113251 0.191648 2.13949e-20) (0.117799 0.2007 2.23832e-20) (0.116879 0.210161 -5.52154e-21) (0.108792 0.221172 5.70917e-21) (0.0957472 0.233055 1.16222e-20) (0.0821503 0.244445 1.75952e-20) (0.0632136 0.254983 -5.88956e-21) (0.0488236 0.265048 -5.94219e-21) (0.0267237 0.274488 1.2029e-20) (0.0121129 0.283889 6.04033e-21) (0.110277 0.187634 -5.39284e-21) (0.11841 0.199391 5.47743e-21) (0.11973 0.211637 -5.62366e-21) (0.112739 0.224519 -5.70801e-21) (0.0999402 0.237541 5.77835e-21) (0.0860487 0.249681 -1.16499e-20) (0.0665652 0.260528 8.84273e-21) (0.0511493 0.270824 2.99226e-21) (0.028281 0.280401 0) (0.0123629 0.289923 -6.05441e-21) (0.00482422 0.00235273 0) (0.0325151 0.00253378 0) (0.0705453 0.00848643 -2.46209e-19) (0.109682 0.0156111 0) (0.147499 0.0240306 1.23327e-19) (0.18247 0.0336326 -1.19702e-19) (0.213796 0.0444047 0) (0.24134 0.0565909 0) (0.265793 0.0706102 -2.15629e-19) (0.288558 0.0845669 4.38049e-19) (0.0103954 -0.000760227 0) (0.0466417 -0.00260105 -1.77301e-19) (0.0913964 0.00382682 -5.83819e-20) (0.135732 0.0121381 -2.45053e-19) (0.177483 0.0220097 -1.20051e-19) (0.215386 0.0330512 -3.54815e-19) (0.248938 0.0450572 0) (0.278323 0.0580267 0) (0.304339 0.0717202 0) (0.327738 0.0838418 -2.71987e-21) (0.017132 -0.00342344 0) (0.0627887 -0.00638175 -5.76252e-20) (0.114367 0.00117402 1.23389e-19) (0.163631 0.0110815 1.84554e-19) (0.208799 0.0225738 2.324e-21) (0.248925 0.0349879 2.48467e-21) (0.283772 0.0479324 2.26288e-19) (0.313679 0.0612152 -2.17614e-19) (0.33935 0.0744077 4.17046e-19) (0.361166 0.0858964 -4.24306e-19) (0.0249456 -0.00541881 -2.56182e-20) (0.0806171 -0.00846622 1.76305e-19) (0.13885 0.000814222 3.01574e-19) (0.192518 0.0126124 -3.62426e-19) (0.240356 0.0257653 2.38983e-19) (0.281815 0.0393993 2.33588e-19) (0.316957 0.0530179 -1.13852e-19) (0.346284 0.0663785 4.33408e-19) (0.370511 0.0791455 -3.89162e-21) (0.390061 0.0904115 -2.10036e-19) (0.0336745 -0.00653432 -2.60856e-20) (0.0996626 -0.00855847 2.83438e-20) (0.164119 0.00294736 0) (0.221457 0.0167833 3.01227e-19) (0.271077 0.0314825 -5.89364e-20) (0.312934 0.0460553 4.33079e-22) (0.347462 0.059998 -1.11393e-19) (0.375417 0.0731278 -3.19851e-19) (0.397665 0.0853045 -6.33243e-22) (0.414844 0.0961689 3.08788e-19) (0.0430814 -0.00658322 0) (0.119348 -0.00644116 -1.74355e-19) (0.189362 0.00765553 5.89262e-20) (0.249482 0.0235039 -1.78999e-19) (0.29994 0.0394664 5.8572e-20) (0.341304 0.0545555 4.58944e-22) (0.374469 0.0683612 3.64979e-22) (0.400517 0.0808428 2.12169e-19) (0.42055 0.0920877 -3.03232e-19) (0.435455 0.102138 3.0653e-19) (0.0528593 -0.00542424 1.26218e-20) (0.139009 -0.00200611 1.15818e-19) (0.213718 0.0148806 0) (0.275652 0.0325345 1.78747e-19) (0.326025 0.049317 -1.75304e-19) (0.366123 0.0643776 -5.6904e-20) (0.397365 0.077497 1.65128e-19) (0.421203 0.0888395 0) (0.438998 0.0987249 0) (0.45186 0.107484 0) (0.0626365 -0.00297921 -1.29816e-20) (0.157922 0.00472379 -4.39149e-20) (0.236328 0.0244159 5.9402e-20) (0.299098 0.043497 8.92095e-20) (0.348558 0.0605269 8.7841e-20) (0.386786 0.0749334 5.6816e-20) (0.415755 0.0867781 0) (0.437292 0.0964752 1.04442e-19) (0.452997 0.10457 -5.04433e-20) (0.464149 0.111595 0) (0.0719882 0.000751478 0) (0.175342 0.0135809 8.71957e-20) (0.25638 0.0359106 -5.93931e-20) (0.31907 0.0558989 -5.94251e-20) (0.366942 0.0725222 5.51505e-23) (0.402897 0.0856252 -2.84098e-20) (0.429455 0.0956255 2.74077e-20) (0.448786 0.103215 0) (0.462683 0.109149 -4.99436e-20) (0.472525 0.114098 -5.02307e-20) (0.0805176 0.00567422 1.61531e-21) (0.190593 0.0242478 -3.28619e-20) (0.273186 0.0488829 -3.80331e-21) (0.334997 0.0691643 -5.37106e-23) (0.38079 0.0847044 -2.19835e-20) (0.414275 0.0958903 0) (0.438474 0.103549 -2.74046e-20) (0.455842 0.10866 0) (0.468299 0.112164 0) (0.477263 0.114819 0) (0.0880493 0.0116195 -3.28387e-21) (0.203212 0.0362933 0) (0.286281 0.0627638 0) (0.346537 0.082681 -2.27954e-20) (0.389942 0.0964967 7.41589e-21) (0.420942 0.105238 -3.35614e-23) (0.442983 0.110171 -1.38484e-20) (0.458729 0.112548 0) (0.47016 0.113469 0) (0.47867 0.113739 0) (0.0943187 0.0184041 0) (0.212792 0.049292 -1.51217e-20) (0.295334 0.0770074 1.52286e-20) (0.353526 0.0958948 3.03487e-20) (0.394412 0.107413 0) (0.423065 0.113292 2.89816e-20) (0.443254 0.115236 -2.79936e-20) (0.45777 0.114743 0) (0.468591 0.11304 5.03628e-20) (0.477033 0.110943 -5.21374e-20) (0.0988733 0.0257525 0) (0.218837 0.0626828 1.24072e-19) (0.300021 0.0909805 0) (0.355854 0.108219 1.25322e-19) (0.394289 0.116981 0) (0.420874 0.119722 -1.1891e-19) (0.439598 0.118555 0) (0.4533 0.11518 1.0748e-19) (0.463904 0.110913 -1.03311e-19) (0.472607 0.106564 -1.06063e-19) (0.10147 0.0333143 -2.86384e-20) (0.221115 0.0758321 -6.14703e-20) (0.300283 0.104034 -3.17026e-20) (0.353648 0.119101 -6.20327e-20) (0.389843 0.124797 -6.19148e-20) (0.414728 0.124277 5.91291e-20) (0.432395 0.120013 5.7754e-20) (0.445677 0.113851 1.66966e-21) (0.456406 0.107171 1.04993e-19) (0.465644 0.100764 1.06462e-19) (0.101997 0.0407081 -2.93857e-20) (0.219589 0.0881005 -6.45173e-20) (0.296252 0.115559 -1.32216e-19) (0.347192 0.128059 6.45596e-20) (0.381461 0.130533 0) (0.405052 0.126778 0) (0.422056 0.119551 -1.16829e-19) (0.435254 0.110786 -1.11535e-19) (0.446382 0.101898 1.07462e-19) (0.456367 0.093676 -1.06571e-19) (0.100437 0.0475418 3.04427e-20) (0.214384 0.0988755 3.31744e-20) (0.28821 0.125007 -2.0571e-19) (0.336889 0.134685 3.34437e-19) (0.369609 0.133935 -6.47361e-20) (0.392317 0.127103 0) (0.40901 0.117149 0) (0.422383 0.106032 5.71608e-19) (0.43409 0.0951771 -5.41684e-19) (0.444965 0.0854146 -3.35168e-19) (0.0968707 0.053437 2.57209e-19) (0.205777 0.107604 0) (0.276574 0.131913 2.70964e-19) (0.32324 0.138658 -2.68285e-19) (0.354816 0.134818 0) (0.377035 0.125175 1.27474e-19) (0.393709 0.112809 -3.71278e-19) (0.40742 0.099635 -4.63604e-19) (0.41978 0.0870527 2.2339e-19) (0.431643 0.0760125 2.28255e-19) (0.0914786 0.0580539 -5.23852e-19) (0.19418 0.11382 -7.01406e-20) (0.261871 0.135915 -1.45125e-19) (0.306816 0.139745 -3.52266e-19) (0.337648 0.133063 -1.35438e-19) (0.359745 0.120956 -1.3382e-19) (0.376641 0.106547 -5.83939e-21) (0.390765 0.091643 0) (0.403752 0.0775267 0) (0.416623 0.0653682 4.74032e-19) (0.0845296 0.0611148 2.66647e-19) (0.180118 0.11717 -2.93515e-19) (0.244705 0.136761 2.13878e-19) (0.288224 0.137806 4.96933e-19) (0.318684 0.128608 -1.39629e-19) (0.340993 0.114428 1.27272e-19) (0.358344 0.0983754 1.24944e-19) (0.372962 0.0821028 0) (0.386561 0.0666552 0) (0.400311 0.0535159 -2.39981e-19) (0.0763685 0.0624261 -3.51015e-20) (0.164197 0.117434 3.67842e-19) (0.225726 0.134324 -7.47808e-20) (0.268076 0.132798 0) (0.298466 0.121448 0) (0.321273 0.105568 2.71757e-19) (0.339322 0.0881875 0) (0.354633 0.070785 -2.48636e-19) (0.368982 0.0541229 3.44983e-21) (0.383445 0.0403665 2.49848e-19) (0.0673837 0.0618903 0) (0.147058 0.11453 0) (0.205588 0.128605 -3.09673e-19) (0.246956 0.124784 0) (0.277462 0.111674 1.4551e-19) (0.30092 0.0944194 -1.41259e-19) (0.3198 0.0758345 0) (0.335936 0.0570297 0) (0.350958 0.0377702 -2.42282e-19) (0.363923 0.0188076 5.17617e-19) (0.0579524 0.059456 0) (0.12934 0.108484 -2.39564e-19) (0.184945 0.119717 -8.58488e-20) (0.225433 0.113948 -3.10938e-19) (0.256097 0.0995373 -1.52944e-19) (0.28015 0.0813633 -4.34864e-19) (0.299727 0.0620047 0) (0.31647 0.0424638 0) (0.331691 0.0226488 0) (0.343961 0.00347287 4.61284e-21) (0.0484744 0.0551484 0) (0.11172 0.0994493 -8.68679e-20) (0.164469 0.107895 1.53763e-19) (0.204098 0.100574 2.32079e-19) (0.234856 0.0853779 -5.7049e-21) (0.259352 0.066835 -5.45268e-21) (0.279383 0.0472976 2.83526e-19) (0.296375 0.02772 -2.70685e-19) (0.3114 0.00819343 5.12607e-19) (0.323319 -0.0104223 -5.42193e-19) (0.039381 0.049146 -3.9151e-20) (0.0948566 0.0877363 2.43202e-19) (0.144801 0.0934858 4.05591e-19) (0.183526 0.0850117 -4.81734e-19) (0.21426 0.0695368 3.08833e-19) (0.239031 0.0511659 2.97233e-19) (0.259334 0.0320178 -1.39923e-19) (0.276416 0.0129869 5.42778e-19) (0.291242 -0.00574724 3.03854e-21) (0.303057 -0.0235046 -2.76574e-19) (0.0310581 0.0417187 -3.91445e-20) (0.0793366 0.0737689 4.25427e-20) (0.12652 0.0769177 0) (0.164251 0.0676507 4.03347e-19) (0.194799 0.0523462 -7.91114e-20) (0.219668 0.0346129 -1.55708e-21) (0.240085 0.0163075 -1.45839e-19) (0.257152 -0.00176557 -4.16321e-19) (0.271777 -0.0194117 3.22818e-21) (0.283526 -0.0361713 4.22059e-19) (0.0238169 0.0331947 0) (0.0656463 0.0580508 -2.54123e-19) (0.110121 0.0586789 8.46453e-20) (0.146737 0.0489135 -2.47349e-19) (0.17691 0.034144 8.01266e-20) (0.201681 0.0174175 -3.91042e-22) (0.222044 0.00029784 -2.10973e-22) (0.238979 -0.0165305 2.79961e-19) (0.253339 -0.0328955 -4.02864e-19) (0.26495 -0.0485371 4.28352e-19) (0.0178849 0.0239401 2.04303e-20) (0.0541565 0.0411386 1.7006e-19) (0.0959992 0.0392986 0) (0.131366 0.0292487 2.48171e-19) (0.160956 0.0152833 -2.4266e-19) (0.185416 -0.000163732 -7.72611e-20) (0.205545 -0.0158473 2.22549e-19) (0.222208 -0.0312239 0) (0.236197 -0.0461629 0) (0.247551 -0.0605571 0) (0.0134003 0.0143379 -2.01991e-20) (0.0451138 0.0236131 -6.43818e-20) (0.0844381 0.0193281 8.58182e-20) (0.11843 0.00912322 1.25671e-19) (0.147225 -0.0038666 1.20919e-19) (0.171156 -0.0178539 7.83854e-20) (0.190856 -0.0319307 0) (0.20709 -0.0457093 1.4313e-19) (0.220582 -0.0591118 -6.87177e-20) (0.231539 -0.0721367 0) (0.0104132 0.00476691 0) (0.0386393 0.00605318 1.29623e-19) (0.0756099 -0.000678657 -8.58026e-20) (0.108127 -0.0109891 -8.3969e-20) (0.135927 -0.0229242 2.24439e-22) (0.159113 -0.0353576 -3.8916e-20) (0.178187 -0.0477288 3.77988e-20) (0.193827 -0.0598166 0) (0.206689 -0.0716049 -6.88501e-20) (0.217108 -0.0831612 -7.29061e-20) (0.00889082 -0.00442189 2.57726e-21) (0.0347327 -0.0109924 -4.86719e-20) (0.0695754 -0.0201865 -5.29771e-21) (0.100559 -0.0306215 1.02861e-22) (0.127192 -0.0415054 -3.05801e-20) (0.149433 -0.0523686 0) (0.167693 -0.0630007 -3.77898e-20) (0.182579 -0.0733547 0) (0.194683 -0.0834856 0) (0.204426 -0.0935045 0) (0.00873059 -0.0129448 -5.14083e-21) (0.0332873 -0.0270367 0) (0.0662929 -0.0387044 0) (0.0957393 -0.0493338 -3.17127e-20) (0.121074 -0.0592388 1.01388e-20) (0.1422 -0.0685831 -1.20257e-22) (0.159476 -0.0775017 -1.90407e-20) (0.173461 -0.086126 0) (0.18469 -0.0945909 0) (0.193637 -0.103037 0) (0.00977993 -0.0206027 0) (0.0341087 -0.0417086 -2.14844e-20) (0.0656236 -0.0558187 2.16398e-20) (0.0935907 -0.0667367 4.22267e-20) (0.117549 -0.0757823 0) (0.137429 -0.0837119 3.94548e-20) (0.153582 -0.0909921 -3.81108e-20) (0.166538 -0.0979333 0) (0.176795 -0.104758 6.98359e-20) (0.184844 -0.111631 -7.36274e-20) (0.0118574 -0.0272137 0) (0.0369451 -0.0546683 1.71493e-19) (0.0673613 -0.0711481 0) (0.0939678 -0.0824576 1.68093e-19) (0.116528 -0.0907979 0) (0.135077 -0.0974606 -1.57903e-19) (0.15 -0.103223 0) (0.161827 -0.108571 1.45787e-19) (0.171035 -0.113818 -1.40129e-19) (0.178112 -0.119157 -1.47142e-19) (0.014759 -0.0326546 -3.98026e-20) (0.0414952 -0.0656578 -8.56618e-20) (0.0712379 -0.0843828 -4.28708e-20) (0.0966604 -0.0961792 -8.44308e-20) (0.117858 -0.103986 -8.18324e-20) (0.135041 -0.109561 7.9153e-20) (0.148666 -0.113963 7.60569e-20) (0.159291 -0.117844 1.72309e-23) (0.167396 -0.121612 1.40088e-19) (0.173451 -0.12549 1.46918e-19) (0.0182725 -0.0368638 -3.98446e-20) (0.0474273 -0.074509 -8.45566e-20) (0.0769395 -0.0952925 -1.68521e-19) (0.101405 -0.107646 8.37249e-20) (0.121334 -0.115091 0) (0.137164 -0.119772 0) (0.149463 -0.122996 -1.51395e-19) (0.158839 -0.125569 -1.45467e-19) (0.165804 -0.127988 1.3974e-19) (0.170808 -0.130517 -1.46669e-19) (0.0221894 -0.0398325 3.90681e-20) (0.0543973 -0.0811357 4.14457e-20) (0.0841224 -0.103724 -2.51098e-19) (0.107899 -0.116667 4.137e-19) (0.126702 -0.123906 -8.10407e-20) (0.14124 -0.127888 0) (0.15222 -0.130129 0) (0.160327 -0.131575 7.2638e-19) (0.166127 -0.132805 -6.98305e-19) (0.170064 -0.134128 -4.39001e-19) (0.0263148 -0.0415965 3.09577e-19) (0.0620647 -0.0855272 0) (0.0924276 -0.109602 3.35678e-19) (0.115808 -0.123116 -3.30854e-19) (0.133672 -0.130275 0) (0.147022 -0.133738 1.55946e-19) (0.156726 -0.13519 -4.51191e-19) (0.163558 -0.135697 -5.80176e-19) (0.168169 -0.135921 2.78646e-19) (0.171023 -0.136218 2.92265e-19) (0.0304751 -0.0422285 -6.15356e-19) (0.0701063 -0.08774 -8.24568e-20) (0.101496 -0.112921 -1.64294e-19) (0.124784 -0.126935 -4.08196e-19) (0.141929 -0.134099 -1.59964e-19) (0.154233 -0.137197 -1.54427e-19) (0.162735 -0.138032 1.22111e-21) (0.168305 -0.137779 0) (0.171688 -0.137181 0) (0.173417 -0.136666 5.82264e-19) (0.0345236 -0.0418291 3.05785e-19) (0.0782266 -0.0878869 -3.25473e-19) (0.110979 -0.113744 2.48021e-19) (0.134476 -0.128135 5.70074e-19) (0.151141 -0.135344 -1.58985e-19) (0.162575 -0.138191 1.5618e-19) (0.169987 -0.138543 1.50069e-19) (0.174328 -0.137652 0) (0.176409 -0.136352 0) (0.176893 -0.135225 -2.90653e-19) (0.0383463 -0.0405209 -3.75238e-20) (0.0861674 -0.0861265 4.06474e-19) (0.120553 -0.112193 -8.1505e-20) (0.144537 -0.126788 0) (0.160975 -0.134041 0) (0.171749 -0.136719 3.08087e-19) (0.178242 -0.136675 0) (0.181469 -0.135173 -2.87237e-19) (0.182199 -0.133129 -5.31228e-22) (0.181239 -0.131397 2.89229e-19) (0.0418652 -0.0384355 0) (0.0937151 -0.082643 0) (0.12992 -0.108429 -3.2142e-19) (0.154634 -0.12302 0) (0.171088 -0.130289 1.57123e-19) (0.181438 -0.132872 -1.52523e-19) (0.187267 -0.132544 0) (0.189737 -0.130501 0) (0.18957 -0.127695 -2.76253e-19) (0.187628 -0.124636 5.77359e-19) (0.044996 -0.0356756 0) (0.100673 -0.0776139 -2.36464e-19) (0.138806 -0.102634 -7.70722e-20) (0.16444 -0.116992 -3.16313e-19) (0.181119 -0.124231 -1.54495e-19) (0.191234 -0.126816 -4.54444e-19) (0.196542 -0.126443 0) (0.19834 -0.124307 0) (0.197417 -0.121449 0) (0.19456 -0.118263 -9.92908e-22) (0.0476524 -0.0323451 0) (0.106855 -0.0712457 -7.5567e-20) (0.146954 -0.0950302 1.61495e-19) (0.173648 -0.108903 2.37728e-19) (0.190717 -0.11603 2.13335e-21) (0.200739 -0.118663 1.81111e-21) (0.205605 -0.118394 2.92271e-19) (0.206708 -0.116381 -2.8276e-19) (0.204924 -0.113643 5.47106e-19) (0.201049 -0.110483 -5.71861e-19) (0.0498002 -0.0285716 -3.57938e-20) (0.112144 -0.0637717 2.34898e-19) (0.154166 -0.0858651 3.94368e-19) (0.181998 -0.0989779 -4.68229e-19) (0.19958 -0.105865 3.07719e-19) (0.209627 -0.108532 3.00269e-19) (0.214135 -0.10843 -1.46925e-19) (0.21458 -0.106641 5.65575e-19) (0.211938 -0.104117 6.82044e-24) (0.207072 -0.10112 -2.84459e-19) (0.0514295 -0.0244831 -3.54433e-20) (0.116465 -0.0554267 3.85155e-20) (0.160294 -0.0753927 0) (0.189285 -0.0874585 3.89295e-19) (0.207464 -0.0939453 -7.61118e-20) (0.217639 -0.0965853 8.92839e-22) (0.221889 -0.0966625 -1.4455e-19) (0.221774 -0.0951555 -4.2166e-19) (0.218377 -0.0929301 -1.29473e-21) (0.212623 -0.0902348 4.25234e-19) (0.0525516 -0.0201938 0) (0.119775 -0.0464276 -2.28769e-19) (0.165231 -0.0638679 7.71224e-20) (0.195349 -0.0745992 -2.30685e-19) (0.214176 -0.0805012 7.55715e-20) (0.224567 -0.0830176 -5.94461e-23) (0.228667 -0.0832481 -1.25337e-22) (0.228114 -0.0820452 2.80255e-19) (0.224102 -0.0801704 -4.05593e-19) (0.217603 -0.0778815 4.22905e-19) (0.053185 -0.0158005 1.73552e-20) (0.122062 -0.0369776 1.52166e-19) (0.168914 -0.0515412 0) (0.200081 -0.0606611 2.30136e-19) (0.219569 -0.0657814 -2.25255e-19) (0.230249 -0.0680519 -7.39938e-20) (0.234303 -0.0683773 2.15328e-19) (0.233439 -0.0674726 0) (0.228954 -0.0659825 0) (0.221877 -0.0641534 0) (0.0533499 -0.0113858 -1.72392e-20) (0.123337 -0.027264 -5.60999e-20) (0.171316 -0.0386535 7.58139e-20) (0.203412 -0.0459057 1.1372e-19) (0.223545 -0.0500451 1.12928e-19) (0.234564 -0.051931 7.3079e-20) (0.238669 -0.0522675 0) (0.237616 -0.0516279 1.3893e-19) (0.232785 -0.0505333 -6.66796e-20) (0.22526 -0.0491603 0) (0.0530619 -0.00702015 0) (0.123626 -0.017457 1.11946e-19) (0.172433 -0.0254329 -7.58011e-20) (0.205308 -0.0305901 -7.56085e-20) (0.226045 -0.0335574 -2.82404e-22) (0.237435 -0.0349115 -3.68075e-20) (0.241675 -0.0351563 3.54052e-20) (0.240551 -0.0347157 0) (0.235501 -0.0339699 -6.6851e-20) (0.227645 -0.0330435 -6.98789e-20) (0.0523632 -0.00276663 2.11376e-21) (0.122984 -0.00771427 -4.17494e-20) (0.172299 -0.0120967 -4.74146e-21) (0.205775 -0.0149669 -8.54295e-23) (0.227047 -0.0165862 -2.78721e-20) (0.238823 -0.017262 0) (0.24327 -0.0173013 -3.53983e-20) (0.242187 -0.0169743 0) (0.237049 -0.0165108 0) (0.229003 -0.0160059 0) (0.0514295 0.00132889 -4.19975e-21) (0.121579 0.00183209 0) (0.171037 0.00115675 0) (0.204893 0.000721891 -2.77279e-20) (0.226594 0.000602421 9.32135e-21) (0.238739 0.000742586 1.78153e-22) (0.243446 0.00102464 -1.74784e-20) (0.242501 0.001332 0) (0.237395 0.00159095 0) (0.229295 0.00172631 0) (0.0503119 0.00526975 0) (0.119479 0.0111356 -1.83019e-20) (0.168705 0.0142036 1.84322e-20) (0.202702 0.0162948 3.70645e-20) (0.224712 0.0177876 0) (0.237199 0.0188578 3.59955e-20) (0.242207 0.0195655 -3.47682e-20) (0.24149 0.0199429 0) (0.236527 0.0200748 6.60823e-20) (0.228496 0.0199101 -6.86538e-20) (0.0489289 0.00904572 0) (0.116659 0.0201297 1.44531e-19) (0.165316 0.0269126 0) (0.199233 0.0315685 1.4647e-19) (0.221435 0.0347486 0) (0.234236 0.0368378 -1.42082e-19) (0.239584 0.038061 0) (0.239179 0.0385913 1.35764e-19) (0.234462 0.0386708 -1.30494e-19) (0.226613 0.0382844 -1.36964e-19) (0.0472797 0.0126356 -3.3039e-20) (0.113151 0.0287368 -7.24722e-20) (0.160918 0.0391497 -3.6406e-20) (0.194541 0.0463628 -7.30659e-20) (0.216818 0.0512691 -7.17989e-20) (0.2299 0.0544416 7.0863e-20) (0.235622 0.0562546 6.87882e-20) (0.235609 0.0570117 -9.27077e-22) (0.231239 0.0571083 1.2985e-19) (0.223678 0.0565799 1.36993e-19) (0.0453862 0.0160202 -3.27406e-20) (0.109001 0.0368871 -7.18693e-20) (0.155574 0.0507938 -1.4551e-19) (0.188692 0.0605117 7.2241e-20) (0.210926 0.0671479 0) (0.224252 0.071441 0) (0.230379 0.0738996 -1.38264e-19) (0.230838 0.0749452 -1.34489e-19) (0.226915 0.0751193 1.29418e-19) (0.219747 0.074522 -1.38073e-19) (0.043265 0.0191805 3.26484e-20) (0.104251 0.0445156 3.59743e-20) (0.149341 0.0617337 -2.15224e-19) (0.181755 0.0738628 3.60514e-19) (0.20383 0.0821983 -7.09873e-20) (0.217361 0.0876228 0) (0.223918 0.090762 0) (0.224927 0.0921414 6.6633e-19) (0.221557 0.0924393 -6.45691e-19) (0.214894 0.0918321 -4.0886e-19) (0.04093 0.0220966 2.58132e-19) (0.0989426 0.051561 0) (0.142284 0.0718668 2.88161e-19) (0.1738 0.0862762 -2.8795e-19) (0.195602 0.0962492 0) (0.209294 0.10279 1.40106e-19) (0.216304 0.106624 -4.06732e-19) (0.217939 0.108362 -5.3141e-19) (0.215237 0.108807 2.55598e-19) (0.209212 0.108228 2.70149e-19) (0.0383962 0.0247492 -5.14818e-19) (0.0931211 0.0579662 -7.06705e-20) (0.134466 0.0810994 -1.42071e-19) (0.164904 0.0976256 -3.55874e-19) (0.186316 0.109147 -1.41968e-19) (0.200119 0.116768 -1.38598e-19) (0.207589 0.12129 1.51331e-21) (0.209918 0.123387 0) (0.208008 0.123966 0) (0.202787 0.123417 5.37186e-19) (0.0356815 0.0271206 2.5669e-19) (0.0868357 0.0636793 -2.79385e-19) (0.125961 0.0893476 2.1364e-19) (0.15515 0.107799 4.98303e-19) (0.176055 0.120758 -1.39672e-19) (0.1899 0.129407 1.40079e-19) (0.197807 0.134598 1.36068e-19) (0.200841 0.137027 0) (0.199777 0.137642 0) (0.195477 0.137035 -2.67153e-19) (0.0328107 0.0291987 -3.18257e-20) (0.0801441 0.0686558 3.49387e-19) (0.11685 0.0965377 -7.04328e-20) (0.144634 0.116699 0) (0.164916 0.130973 0) (0.178719 0.140603 2.74925e-19) (0.186981 0.146481 0) (0.190592 0.149272 -2.61417e-19) (0.190193 0.149785 -1.98803e-21) (0.186694 0.148927 2.63646e-19) (0.0298106 0.0309794 0) (0.073105 0.0728607 0) (0.107221 0.102605 -2.80645e-19) (0.133463 0.124238 0) (0.15302 0.139694 1.39694e-19) (0.166712 0.150288 -1.356e-19) (0.175261 0.157007 0) (0.17935 0.160645 0) (0.179752 0.161928 -2.52642e-19) (0.177448 0.162328 5.26449e-19) (0.0266886 0.032435 0) (0.0657675 0.0762454 -2.05915e-19) (0.0971634 0.107479 -6.82886e-20) (0.121759 0.130321 -2.79064e-19) (0.140524 0.146798 -1.36821e-19) (0.154096 0.158287 -4.05467e-19) (0.16304 0.165839 0) (0.167961 0.170333 0) (0.16976 0.172437 0) (0.169172 0.173161 -7.30153e-22) (0.0234608 0.0335246 0) (0.0582101 0.078753 -6.74543e-20) (0.0867991 0.11109 1.40764e-19) (0.109674 0.134854 2.09845e-19) (0.127593 0.152156 1.40813e-21) (0.141024 0.164409 1.43908e-21) (0.150393 0.172681 2.62584e-19) (0.156214 0.17784 -2.55295e-19) (0.159304 0.180492 4.97276e-19) (0.160079 0.181342 -5.19728e-19) (0.0201748 0.034243 -3.11208e-20) (0.0505369 0.0803576 2.05238e-19) (0.0762718 0.113391 3.46987e-19) (0.0973772 0.137767 -4.15587e-19) (0.114404 0.155666 2.73054e-19) (0.127651 0.168522 2.67817e-19) (0.137404 0.177384 -1.3232e-19) (0.144056 0.183077 5.11041e-19) (0.148265 0.186157 5.4269e-22) (0.150217 0.187207 -2.57283e-19) (0.0168819 0.0345968 -3.10912e-20) (0.0428611 0.0810508 3.37856e-20) (0.065741 0.114358 0) (0.0850627 0.139016 3.45647e-19) (0.101168 0.157262 -6.77519e-20) (0.114189 0.170541 9.72166e-22) (0.124271 0.179877 -1.29588e-19) (0.131672 0.186044 -3.80365e-19) (0.136879 0.189569 -1.87308e-21) (0.139926 0.190968 3.84396e-19) (0.0136306 0.0345959 0) (0.0353009 0.0808363 -2.0263e-19) (0.055381 0.113984 6.83265e-20) (0.0729499 0.138577 -2.05796e-19) (0.0881387 0.156907 6.74233e-20) (0.100913 0.170421 -2.7085e-22) (0.111278 0.180115 -2.66106e-22) (0.119357 0.186722 2.52503e-19) (0.125473 0.190747 -3.66165e-19) (0.129556 0.192647 3.80644e-19) (0.0104673 0.0342534 1.52864e-20) (0.0279795 0.0797298 1.34762e-19) (0.0453818 0.112281 0) (0.061285 0.136457 2.05455e-19) (0.075607 0.154595 -2.0166e-19) (0.08815 0.168145 -6.63853e-20) (0.0987822 0.178078 1.93285e-19) (0.107497 0.18509 0) (0.11446 0.189669 0) (0.119539 0.192212 0) (0.00743654 0.0335811 -1.5281e-20) (0.0210248 0.0777543 -5.00459e-20) (0.0359474 0.109279 6.77797e-20) (0.050339 0.132686 1.01906e-19) (0.0639008 0.150354 1.01161e-19) (0.0762746 0.163735 6.56033e-20) (0.087199 0.173777 0) (0.0965445 0.18115 1.24837e-19) (0.104334 0.186321 -5.99499e-20) (0.110383 0.189636 0) (0.00458137 0.032589 0) (0.0145699 0.074943 9.97714e-20) (0.0272952 0.105028 -6.77681e-20) (0.040404 0.127326 -6.77598e-20) (0.0533776 0.144251 -2.32629e-22) (0.0657005 0.157254 -3.30301e-20) (0.0769894 0.16727 3.17881e-20) (0.0870022 0.174944 0) (0.0956305 0.180727 -6.00327e-20) (0.102645 0.184927 -6.23041e-20) (0.0019483 0.0312959 1.87309e-21) (0.00875879 0.0713403 -3.72699e-20) (0.0196592 0.0996027 -4.2696e-21) (0.0317946 0.120477 -8.89633e-23) (0.0444214 0.136401 -2.50431e-20) (0.0568705 0.148824 0) (0.0686449 0.158671 -3.17814e-20) (0.0794009 0.166573 0) (0.0889139 0.172971 0) (0.0968985 0.178154 0) ) ; boundaryField { inlet { type uniformFixedValue; uniformValue constant (1 0 0); value uniform (1 0 0); } outlet { type pressureInletOutletVelocity; value nonuniform List<vector> 40 ( (0.583284 0.337592 0) (0.637515 0.457594 0) (0.659833 0.566586 0) (0.652012 0.66809 0) (0.614823 0.765743 0) (0.554325 0.859858 0) (0.463982 0.946919 0) (0.358204 1.02282 0) (0.217867 1.08367 0) (0.0810499 1.1279 0) (0.532144 0.256674 -6.31356e-22) (0.507701 0.22157 -1.50499e-21) (0.480743 0.185899 1.0482e-21) (0.450977 0.149939 1.96451e-21) (0.418467 0.114 -1.79717e-21) (0.383907 0.0785572 0) (0.348893 0.0444558 3.03767e-21) (0.313218 0.0131269 -3.22605e-21) (0 -0.0140297 0) (0 -0.0379412 0) (0 -0.0608791 0) (0 -0.0837018 0) (0 -0.106545 0) (0 -0.129546 0) (0 -0.152629 0) (0 -0.175558 0) (0 -0.198157 0) (0 -0.220307 0) (0 -0.241933 0) (0 -0.26305 0) (0 -0.312404 0) (0 -0.409369 0) (0 -0.501206 0) (0 -0.592157 0) (0 -0.685354 0) (0 -0.783882 0) (0 -0.894518 0) (0 -1.02677 0) (0 -1.17113 0) (0 -1.27355 0) ) ; } cylinder { type fixedValue; value uniform (0 0 0); } top { type symmetryPlane; } bottom { type symmetryPlane; } defaultFaces { type empty; } } // ************************************************************************* //
[ "henry.rossiter@utexas.edu" ]
henry.rossiter@utexas.edu
e8a5856c70f0cceca937f59fd49c4fb7013906a2
41b444116c8431b7e4199f78b0f27f1dc61d190f
/P1616.cpp
72c52afb82862efe3206deb1141560ab933b1cdb
[ "MIT" ]
permissive
lwzhenglittle/NOIP
6caa100b1865c93837deca3283bf43e54c84462f
f256c8d706b3ac985de04a5fae77246f44ba5b23
refs/heads/master
2021-07-12T06:58:37.345212
2020-09-27T12:09:49
2020-09-27T12:09:49
207,077,580
0
0
null
null
null
null
UTF-8
C++
false
false
400
cpp
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int n,V; int c[200010]; int v[200010]; int dp[200010]; int main(){ scanf("%d%d",&V,&n); for(int i=1;i<=n;i++){ scanf("%d%d",&c[i],&v[i]); } for(int i=1;i<=n;i++){ for(int j=c[i];j<=V;j++){ dp[j]=max(dp[j],dp[j-c[i]]+v[i]); } } printf("%d\n",dp[V]); return 0; }
[ "924695205@qq.com" ]
924695205@qq.com
af2a8f6a79fdbb4260d66ef6b643e696029243a0
2f3a946c1ec8ddfe27eded31b0a842ce65ed95b7
/Cpp-C/Ema/TestTools/QATools/Series100Consumer112-PConfig-001/Consumer.cpp
d8cd7b0bd9ae8eccef9e9debc8028eed0f9c8cc8
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-generic-cla", "Apache-2.0" ]
permissive
ahigashinaka/Elektron-SDK
747adc47fe1e939ad69d55775428072510496f8f
46ac8eb3b5b77137018b5fe675a09a8a8d177f09
refs/heads/master
2020-03-21T10:26:32.481433
2018-06-12T16:00:22
2018-06-12T16:00:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,408
cpp
///*|----------------------------------------------------------------------------- // *| This source code is provided under the Apache 2.0 license -- // *| and is provided AS IS with no warranty or guarantee of fit for purpose. -- // *| See the project's LICENSE.md for details. -- // *| Copyright Thomson Reuters 2015. All rights reserved. -- ///*|----------------------------------------------------------------------------- #include "Consumer.h" #include <cstring> using namespace thomsonreuters::ema::access; using namespace std; void AppClient::onRefreshMsg( const RefreshMsg& refreshMsg, const OmmConsumerEvent& ) { cout << refreshMsg << endl; // defaults to refreshMsg.toString() } void AppClient::onUpdateMsg( const UpdateMsg& updateMsg, const OmmConsumerEvent& ) { cout << updateMsg << endl; // defaults to updateMsg.toString() } void AppClient::onStatusMsg( const StatusMsg& statusMsg, const OmmConsumerEvent& ) { cout << statusMsg << endl; // defaults to statusMsg.toString() } //APIQA void createProgramaticConfig(Map& configMap) { Map innerMap; ElementList elementList; elementList.addAscii("DefaultConsumer", "Consumer_3"); innerMap.addKeyAscii("Consumer_3", MapEntry::AddEnum, ElementList() .addAscii("Channel", "Channel_1") .addAscii("Logger", "Logger_2") .addAscii("LibsslName", "libssl.so") .addAscii("LibcryptoName", "libcrypto.so") .addUInt("ItemCountHint", 5000) .addUInt("MsgKeyInUpdates", 1).complete()).complete(); elementList.addMap("ConsumerList", innerMap); elementList.complete(); innerMap.clear(); configMap.addKeyAscii("ConsumerGroup", MapEntry::AddEnum, elementList); elementList.clear(); innerMap.addKeyAscii("Channel_1", MapEntry::AddEnum, ElementList() .addEnum("ChannelType", 1) .addEnum("CompressionType", 0) .addUInt("GuaranteedOutputBuffers", 5000) .addUInt("ConnectionPingTimeout", 50000) .addEnum("SecurityProtocol", 7) .addAscii("Host", "localhost") .addAscii("Port", "14002") .addAscii("ObjectName", "P_ObjectName") .addAscii("ProxyHost", "proxyHostToConnectTo") .addAscii("ProxyPort", "proxyPortToConnectTo") .addUInt("TcpNodelay", 1).complete()).complete(); elementList.addMap("ChannelList", innerMap); elementList.complete(); innerMap.clear(); configMap.addKeyAscii("ChannelGroup", MapEntry::AddEnum, elementList); elementList.clear(); innerMap.addKeyAscii("Logger_2", MapEntry::AddEnum, ElementList() .addEnum("LoggerType", 1) .addAscii("FileName", "logFile") .addEnum("LoggerSeverity", 0).complete()).complete(); elementList.addMap("LoggerList", innerMap); elementList.complete(); innerMap.clear(); configMap.addKeyAscii("LoggerGroup", MapEntry::AddEnum, elementList); elementList.clear(); innerMap.addKeyAscii("Dictionary_1", MapEntry::AddEnum, ElementList() .addEnum("DictionaryType", 1) .addAscii("RdmFieldDictionaryFileName", "./RDMFieldDictionary") .addAscii("EnumTypeDefFileName", "./enumtype.def").complete()).complete(); elementList.addMap("DictionaryList", innerMap); elementList.complete(); configMap.addKeyAscii("DictionaryGroup", MapEntry::AddEnum, elementList); elementList.clear(); configMap.complete(); } //END APIQA int main( int argc, char* argv[] ) { try { AppClient client; //APIQA Map configMap; createProgramaticConfig(configMap); OmmConsumer consumer(OmmConsumerConfig().config(configMap).username("user").consumerName("Consumer_3")); //END APIQA consumer.registerClient( ReqMsg().serviceName( "DIRECT_FEED" ).name( "IBM.N" ), client ); sleep( 3240000 ); // API calls onRefreshMsg(), onUpdateMsg(), or onStatusMsg() } catch ( const OmmException& excp ) { cout << excp << endl; } return 0; }
[ "arthur.yurov@thomsonreuters.com" ]
arthur.yurov@thomsonreuters.com
b9bfc18469af1c16252673c4fc406f881d2c3fa9
1b712a2a6ccdd5a8fd9070749205d2dd97e78299
/练习加考试/photo.cpp
b7f1b98e6f4d36f1a7d1dd7d7b23bef0386945a4
[]
no_license
xsy1996/C_algorithm_codes
b12eff717bbbf19f6872b2da35b532abc8392f37
2e9b8ad99d330de39bc000b8c0fa3dc9242b3147
refs/heads/master
2020-04-13T12:26:46.975699
2018-12-26T17:24:54
2018-12-26T17:24:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,007
cpp
#include<stdio.h> #include<stdlib.h> char map[80][80]; int jd=0,fz=0,s=0,xmax=0,xmin=80,ymax=0,ymin=80,fx[4][2]={{1,0},{0,1},{0,-1},{-1,0}}; void photo(int x,int y){ int i,j,k; map[x][y]='.'; s++; if(x<xmin) xmin=x; if(x>xmax) xmax=x; if(y<ymin) ymin=y; if(y>ymax) ymax=y; for(i=0;i<=3;i++) if(map[x+fx[i][0]][y+fx[i][1]]=='#') photo(x+fx[i][0],y+fx[i][1]); return; } int main(){ int i,j,a,b,m,n; char k; scanf("%d%d",&m,&n); k=getchar(); for(i=1;i<=m;i++,getchar()) for(j=1;j<=n;j++) scanf("%c",&map[i][j]); for(i=1;i<=m;i++) for(j=1;j<=n;j++) if(map[i][j]=='#'){ photo(i,j); if(s==(xmax-xmin+1)*(ymax-ymin+1)) fz++; else jd++; s=0;xmin=80;xmax=0;ymax=0;ymin=80; } printf("%d\n%d\n",fz,jd); system("pause"); return 0; }
[ "Xushiyu1996@gmail.com" ]
Xushiyu1996@gmail.com
bcae832de17b3f5148ce2f0c6a1afaf1931227ad
d606a1fc756efea8875c9c59feccbb54061ef534
/FacetCenterHeatTransferTest/CompareNumericalAndAnalyticalSolutions.cpp
d64c440d74045f73f9cd62bc2fb27c725304edb7
[]
no_license
lucasguesserts/StaggeredLib
8e7a9baf5732adfbf661ac4ba243bb3df7905e64
4ad8729698d67c39c3fd85e0094e668d828f003b
refs/heads/master
2022-11-05T12:22:58.641196
2018-07-01T17:30:00
2018-07-01T17:30:00
241,598,522
1
0
null
null
null
null
UTF-8
C++
false
false
7,096
cpp
#include <array> #include <vector> #define _USE_MATH_DEFINES #include <cmath> #include <boost/filesystem.hpp> #include <stdexcept> #include <iostream> #include <Eigen/Dense> #include <Utils/Test.hpp> #include <Utils/EigenTest.hpp> #include <Utils/RateOfConvergence.hpp> #include <Stencil/ScalarStencil.hpp> #include <Stencil/VectorStencil.hpp> #include <Grid/GridData.hpp> #include <Grid/Grid2DInverseDistanceStencil.hpp> #include <Grid/Boundary.hpp> #include <Grid/DirichletBoundaryCondition.hpp> #include <FacetCenterHeatTransfer/FacetCenterHeatTransfer.hpp> #include <SquareCavityHeatTransfer/SquareCavityHeatTransfer.hpp> #include <Grid/Grid2DWithStaggeredElementsExport.hpp> #include <CgnsInterface/CgnsWriter.hpp> #include <CgnsInterface/CgnsReader/CgnsReader2D.hpp> TestCase("Facet center method - compare numerical and analytical solution - regular grids", "[FacetCenterHeatTransfer]") { const std::string directory = gridDirectory + std::string("SquareCavityHeatTransfer_AnalyticalTest/"); const std::string outputDirectory = gridDirectory + std::string("output/"); const std::vector<std::string> meshFiles = { directory + "3.cgns", directory + "5.cgns", directory + "10.cgns", directory + "15.cgns" }; const std::vector<std::string> resultFiles = { outputDirectory + "facet_center_3.cgns", outputDirectory + "facet_center_5.cgns", outputDirectory + "facet_center_10.cgns", outputDirectory + "facet_center_15.cgns" }; std::vector<double> numericalError, characteristicLength; for(unsigned count=0 ; count<meshFiles.size() ; ++count) { std::string cgnsFileName = meshFiles[count]; std::string resultFileName = resultFiles[count]; FacetCenterHeatTransfer problem(cgnsFileName); problem.insertDirichletBoundaryCondition("bottom boundary",0.0); problem.insertDirichletBoundaryCondition("east boundary",0.0); problem.insertDirichletBoundaryCondition("west boundary",0.0); problem.insertDirichletBoundaryCondition("top boundary", [](Eigen::Vector3d centroid) -> double { return std::sin(M_PI*centroid.x()) * std::sinh(M_PI*centroid.y()) / std::sinh(M_PI); }); // Steady numerical solution problem.addDiffusiveTerm(); problem.applyBoundaryConditions(); problem.linearSystem.computeLU(); Eigen::VectorXd numericalSolution = problem.linearSystem.solve(); // Analytical Eigen::Matrix<double,Eigen::Dynamic,3> staggeredElementsCentroid; staggeredElementsCentroid.resize(problem.grid2D.staggeredElements.size(), Eigen::NoChange); for(auto staggeredElement: problem.grid2D.staggeredElements) { Eigen::Vector3d centroid = staggeredElement.getCentroid(); staggeredElementsCentroid(staggeredElement.getIndex(),0) = centroid(0); staggeredElementsCentroid(staggeredElement.getIndex(),1) = centroid(1); staggeredElementsCentroid(staggeredElement.getIndex(),2) = centroid(2); } Eigen::VectorXd analyticalSolution = SquareCavityHeatTransfer::computeAnalyticalSolution(staggeredElementsCentroid); Eigen::VectorXd difference = numericalSolution - analyticalSolution; double error = difference.lpNorm<Eigen::Infinity>(); numericalError.push_back(error); characteristicLength.push_back(problem.grid2D.getStaggeredCharacteristicLength()); // Export Grid2DWithStaggeredElementsExport::cgns(resultFileName, problem.grid2D); CgnsWriter cgnsWriter(resultFileName, "CellCenter"); cgnsWriter.writePermanentSolution("steadySolution"); cgnsWriter.writePermanentField("Numerical_Temperature", std::vector<double>(&numericalSolution[0], &numericalSolution[0] + numericalSolution.size())); cgnsWriter.writePermanentField("Analytical_Temperature", std::vector<double>(&analyticalSolution[0], &analyticalSolution[0] + analyticalSolution.size())); cgnsWriter.writePermanentField("error", std::vector<double>(&difference[0], &difference[0] + difference.size())); } RateOfConvergence rateOfConvergence(numericalError,characteristicLength); check(rateOfConvergence.converge()); check(rateOfConvergence.order>0.2); } TestCase("Facet center method - compare numerical and analytical solution - irregular grids", "[FacetCenterHeatTransfer]") { const std::string directory = gridDirectory + std::string("gmsh/"); const std::string outputDirectory = gridDirectory + std::string("output/"); const std::vector<std::string> meshFiles = { directory + "01.cgns", directory + "02.cgns", directory + "05.cgns" }; const std::vector<std::string> resultFiles = { outputDirectory + "facet_center_gmsh_1.cgns", outputDirectory + "facet_center_gmsh_2.cgns", outputDirectory + "facet_center_gmsh_5.cgns" }; std::vector<double> numericalError, characteristicLength; for(unsigned count=0 ; count<meshFiles.size() ; ++count) { std::string cgnsFileName = meshFiles[count]; std::string resultFileName = resultFiles[count]; FacetCenterHeatTransfer problem(cgnsFileName); problem.insertDirichletBoundaryCondition("South",0.0); problem.insertDirichletBoundaryCondition("East",0.0); problem.insertDirichletBoundaryCondition("West",0.0); problem.insertDirichletBoundaryCondition("North", [](Eigen::Vector3d centroid) -> double { return std::sin(M_PI*centroid.x()) * std::sinh(M_PI*centroid.y()) / std::sinh(M_PI); }); // Steady numerical solution problem.addDiffusiveTerm(); problem.applyBoundaryConditions(); problem.linearSystem.computeLU(); Eigen::VectorXd numericalSolution = problem.linearSystem.solve(); // Analytical Eigen::Matrix<double,Eigen::Dynamic,3> staggeredElementsCentroid; staggeredElementsCentroid.resize(problem.grid2D.staggeredElements.size(), Eigen::NoChange); for(auto staggeredElement: problem.grid2D.staggeredElements) { Eigen::Vector3d centroid = staggeredElement.getCentroid(); staggeredElementsCentroid(staggeredElement.getIndex(),0) = centroid(0); staggeredElementsCentroid(staggeredElement.getIndex(),1) = centroid(1); staggeredElementsCentroid(staggeredElement.getIndex(),2) = centroid(2); } Eigen::VectorXd analyticalSolution = SquareCavityHeatTransfer::computeAnalyticalSolution(staggeredElementsCentroid); Eigen::VectorXd difference = numericalSolution - analyticalSolution; double error = difference.lpNorm<Eigen::Infinity>(); numericalError.push_back(error); characteristicLength.push_back(problem.grid2D.getStaggeredCharacteristicLength()); // Export Grid2DWithStaggeredElementsExport::cgns(resultFileName, problem.grid2D); CgnsWriter cgnsWriter(resultFileName, "CellCenter"); cgnsWriter.writePermanentSolution("steadySolution"); cgnsWriter.writePermanentField("Numerical_Temperature", std::vector<double>(&numericalSolution[0], &numericalSolution[0] + numericalSolution.size())); cgnsWriter.writePermanentField("Analytical_Temperature", std::vector<double>(&analyticalSolution[0], &analyticalSolution[0] + analyticalSolution.size())); cgnsWriter.writePermanentField("error", std::vector<double>(&difference[0], &difference[0] + difference.size())); } RateOfConvergence rateOfConvergence(numericalError,characteristicLength); check(rateOfConvergence.converge()); check(rateOfConvergence.order>1.0); }
[ "guesser@sinmec.ufsc.br" ]
guesser@sinmec.ufsc.br
bb85d9a4eae0ea12c5e9e4dd542dcb2394674a0e
3296a22298dd31c078bc74f21c85c8cd6e4fff97
/RemoveDuplicates.cpp
1f38c87f6b1e2b1e5defec17753170ce317cc31a
[]
no_license
kritirikhi/DataStructuresAndAlgorithms
355e0ef84af97bbca86dfebcbe6e33325d1e8c21
9bfa3e578ee7fa8464edcfb320afa6cf681f1be0
refs/heads/master
2020-12-23T13:16:54.126714
2020-07-01T13:21:02
2020-07-01T13:21:02
237,164,318
1
1
null
null
null
null
UTF-8
C++
false
false
566
cpp
#include<iostream> using namespace std; void removeDuplicate(char input[],int i,char output[],int j){ // base case if(input[i]=='\0'){ output[j]='\0'; cout<<output; return; } // recursive case if(input[i]==input[i+1]){ output[j]=input[i]; removeDuplicate(input,i+2,output,j+1); } else{ output[j]=input[i]; removeDuplicate(input,i+1,output,j+1); } } int main() { char input[1000]; cin>>input; char output[1000]; removeDuplicate(input,0,output,0); return 0; }
[ "kritirikhi1999@gmail.com" ]
kritirikhi1999@gmail.com
2d1a39a8b21a02de33b7d3e47cd1b88d1527384c
a003802a42e6fb089e8f10486bc45d1037c9711e
/NouveauSensors/nouveau_i2c._base.cpp
625c845beb2515a57662926866d81a51ce62a0d6
[]
no_license
anostra/HWSensors
7c94ab3bf836f05c7b435ddf99b09ec49f8f6c37
e6b2fecd1f1491f746914eee090d272037423a34
refs/heads/master
2021-01-18T06:28:10.255449
2012-12-11T20:33:30
2012-12-11T20:33:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
17,105
cpp
// // nouveau_i2c.cpp // HWSensors // // Created by Kozlek on 11.08.12. // // /* * Copyright 2012 Red Hat Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Authors: Ben Skeggs */ #include "nouveau_i2c.h" #include "nouveau.h" #include "vga.h" #include "nvclock_i2c.h" int nv_rdi2cr(struct nouveau_i2c_port *port, u8 addr, u8 reg) { u8 val; struct i2c_msg msgs[] = { { addr, 0, 1, &reg }, { addr, I2C_M_RD, 1, &val }, }; int ret = i2c_transfer(&port->adapter, msgs, 2); if (ret != 2) return -EIO; return val; } int nv_wri2cr(struct nouveau_i2c_port *port, u8 addr, u8 reg, u8 val) { struct i2c_msg msgs[] = { { addr, 0, 1, &reg }, { addr, 0, 1, &val }, }; int ret = i2c_transfer(&port->adapter, msgs, 2); if (ret != 2) return -EIO; return 0; } bool nv_probe_i2c(struct nouveau_i2c_port *port, u8 addr) { u8 buf = 0; struct i2c_msg msgs[] = { { addr, 0, 1, &addr, }, { addr, I2C_M_RD, 1, &buf, } }; return i2c_transfer(&port->adapter, msgs, 2) == 2; } struct nouveau_i2c_port *nouveau_i2c_find(struct nouveau_i2c *i2c, u8 index) { struct nouveau_device *device = i2c->device; struct nouveau_i2c_port *port; if (index == NV_I2C_DEFAULT(0) || index == NV_I2C_DEFAULT(1)) { u8 ver, hdr, cnt, len; u16 dcb = nouveau_dcb_i2c_table(device, &ver, &hdr, &cnt, &len); if (dcb && ver >= 0x30) { u8 auxidx = nv_ro08(device, dcb + 4); if (index != NV_I2C_DEFAULT(0)) index = (auxidx & 0x0f) >> 0; else index = (auxidx & 0xf0) >> 4; } else { index = 2; } } list_for_each_entry(port, &i2c->ports, head) { if (port->index == index) break; } if (&port->head == &i2c->ports) return NULL; if (device->card_type >= NV_50 && (port->dcb & 0x00000100)) { u32 reg = 0x00e500, val; if (port->type == 6) { reg += port->drive * 0x50; val = 0x2002; } else { reg += ((port->dcb & 0x1e00) >> 9) * 0x50; val = 0xe001; } /* nfi, but neither auxch or i2c work if it's 1 */ nv_mask(device, reg + 0x0c, 0x00000001, 0x00000000); /* nfi, but switches auxch vs normal i2c */ nv_mask(device, reg + 0x00, 0x0000f003, val); } return port; } static int nouveau_i2c_identify(struct nouveau_i2c *i2c, int index, const char *what, struct i2c_board_info *info, bool (*match)(struct nouveau_i2c_port *, struct i2c_board_info *)) { struct nouveau_device *device = i2c->device; struct nouveau_i2c_port *port = nouveau_i2c_find(i2c, index); int i; if (!port) { nv_debug(device, "no bus when probing %s on %d\n", what, index); return -ENODEV; } nv_debug(device, "probing %ss on bus: %d\n", what, port->index); #ifdef CONFIG_NOUVEAU_I2C_NVCLOCK /* Unlock the extended CRTC registers to get i2c working */ nvclock_i2c_lock_unlock(device, 0); /* On NV40 cards the i2c busses can be disabled */ if(device->card_type == NV_40) { volatile unsigned char *PCIO = (volatile unsigned char*)(device->mmio->getVirtualAddress() + 0x00601000); PCIO[0x3d4] = 0x49; PCIO[0x3d5] |= 0x4; /* Unlock the i2c busses */ } I2CBusPtr bus = nvclock_i2c_create_bus_ptr(device, STRDUP(what, (int)strlen(what)), port->drive); #endif for (i = 0; info[i].addr; i++) { #ifdef CONFIG_NOUVEAU_I2C_NVCLOCK info[i].platform_data = (void*)bus; if(xf86I2CProbeAddress(bus, info[i].addr << 1) && (!match || match(port, &info[i]))) { #else if (nv_probe_i2c(port, info[i].addr) && (!match || match(port, &info[i]))) { #endif #ifdef CONFIG_NOUVEAU_I2C_NVCLOCK nvclock_i2c_lock_unlock(device, 1); #endif nv_info(device, "found i2c %s: %s\n", what, info[i].type); return i; } } #ifdef CONFIG_NOUVEAU_I2C_NVCLOCK nvclock_i2c_lock_unlock(device, 1); xf86DestroyI2CBusRec(bus, true, true); #endif nv_debug(device, "no i2c devices found.\n"); return -ENODEV; } void nouveau_i2c_drive_scl(void *data, int state) { struct nouveau_i2c_port *port = (struct nouveau_i2c_port *)data; if (port->type == DCB_I2C_NV04_BIT) { u8 val = nv_rdvgac(port->i2c, 0, port->drive); if (state) val |= 0x20; else val &= 0xdf; nv_wrvgac(port->i2c, 0, port->drive, val | 0x01); } else if (port->type == DCB_I2C_NV4E_BIT) { nv_mask(port->i2c->device, port->drive, 0x2f, state ? 0x21 : 0x01); } else if (port->type == DCB_I2C_NVIO_BIT) { if (state) port->state |= 0x01; else port->state &= 0xfe; nv_wr32(port->i2c->device, port->drive, 4 | port->state); } } void nouveau_i2c_drive_sda(void *data, int state) { struct nouveau_i2c_port *port = (struct nouveau_i2c_port *)data; if (port->type == DCB_I2C_NV04_BIT) { u8 val = nv_rdvgac(port->i2c, 0, port->drive); if (state) val |= 0x10; else val &= 0xef; nv_wrvgac(port->i2c, 0, port->drive, val | 0x01); } else if (port->type == DCB_I2C_NV4E_BIT) { nv_mask(port->i2c->device, port->drive, 0x1f, state ? 0x11 : 0x01); } else if (port->type == DCB_I2C_NVIO_BIT) { if (state) port->state |= 0x02; else port->state &= 0xfd; nv_wr32(port->i2c->device, port->drive, 4 | port->state); } } int nouveau_i2c_sense_scl(void *data) { struct nouveau_i2c_port *port = (struct nouveau_i2c_port *)data; struct nouveau_device *device = port->i2c->device; if (port->type == DCB_I2C_NV04_BIT) { return !!(nv_rdvgac(device, 0, port->sense) & 0x04); } else if (port->type == DCB_I2C_NV4E_BIT) { return !!(nv_rd32(device, port->sense) & 0x00040000); } else if (port->type == DCB_I2C_NVIO_BIT) { if (device->card_type < NV_D0) return !!(nv_rd32(device, port->sense) & 0x01); else return !!(nv_rd32(device, port->sense) & 0x10); } return 0; } int nouveau_i2c_sense_sda(void *data) { struct nouveau_i2c_port *port = (struct nouveau_i2c_port *)data; struct nouveau_device *device = port->i2c->device; if (port->type == DCB_I2C_NV04_BIT) { return !!(nv_rdvgac(device, 0, port->sense) & 0x08); } else if (port->type == DCB_I2C_NV4E_BIT) { return !!(nv_rd32(device, port->sense) & 0x00080000); } else if (port->type == DCB_I2C_NVIO_BIT) { if (device->card_type < NV_D0) return !!(nv_rd32(device, port->sense) & 0x02); else return !!(nv_rd32(device, port->sense) & 0x20); } return 0; } static const u32 nv50_i2c_port[] = { 0x00e138, 0x00e150, 0x00e168, 0x00e180, 0x00e254, 0x00e274, 0x00e764, 0x00e780, 0x00e79c, 0x00e7b8 }; #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) bool nouveau_i2c_create(struct nouveau_device *device) { struct nouveau_i2c_port *port; struct nouveau_i2c *i2c = &device->i2c; struct dcb_i2c_entry info; int ret, i = -1; i2c->device = device; i2c->find = nouveau_i2c_find; i2c->identify = nouveau_i2c_identify; INIT_LIST_HEAD(&i2c->ports); nv_debug(device, "parsing i2c dcb table\n"); while (!nouveau_dcb_i2c_parse(device, ++i, &info)) { if (info.type == DCB_I2C_UNUSED) continue; port = (struct nouveau_i2c_port *)IOMalloc(sizeof(nouveau_i2c_port)); if (!port) { nv_error(device, "failed port memory alloc at %d\n", i); break; } port->type = info.type; switch (port->type) { case DCB_I2C_NV04_BIT: port->drive = info.drive; port->sense = info.sense; break; case DCB_I2C_NV4E_BIT: port->drive = 0x600800 + info.drive; port->sense = port->drive; break; case DCB_I2C_NVIO_BIT: port->drive = info.drive & 0x0f; if (device->card_type < NV_D0) { if (port->drive >= ARRAY_SIZE(nv50_i2c_port)) break; port->drive = nv50_i2c_port[port->drive]; port->sense = port->drive; } else { port->drive = 0x00d014 + (port->drive * 0x20); port->sense = port->drive; } break; case DCB_I2C_NVIO_AUX: port->drive = info.drive & 0x0f; port->sense = port->drive; port->adapter.algo = &nouveau_i2c_aux_algo; break; default: break; } if (!port->adapter.algo && !port->drive) { nv_error(device, "I2C%d: type %d index %x/%x unknown\n", i, port->type, port->drive, port->sense); IOFree(port, sizeof(struct nouveau_i2c_port)); continue; } snprintf(port->adapter.name, sizeof(port->adapter.name), "nouveau-%d-%x-%x-%x-%d", port->type, info.drive, port->drive, port->sense, i); //port->adapter.owner = this; //port->adapter.dev.parent = &device->pdev->dev; port->i2c = i2c; port->index = i; port->dcb = info.data; //i2c_set_adapdata(&port->adapter, i2c); if (port->adapter.algo != &nouveau_i2c_aux_algo) { nouveau_i2c_drive_scl(port, 0); nouveau_i2c_drive_sda(port, 1); nouveau_i2c_drive_scl(port, 1); if (CONFIG_NOUVEAU_I2C_INTERNAL) { port->adapter.algo = &nouveau_i2c_bit_algo; ret = 0; //i2c_add_adapter(&port->adapter); } else { port->adapter.algo_data = &port->bit; port->bit.udelay = 10; port->bit.timeout = 2200; port->bit.data = port; port->bit.setsda = nouveau_i2c_drive_sda; port->bit.setscl = nouveau_i2c_drive_scl; port->bit.getsda = nouveau_i2c_sense_sda; port->bit.getscl = nouveau_i2c_sense_scl; ret = i2c_bit_add_bus(&port->adapter); } } else { port->adapter.algo = &nouveau_i2c_aux_algo; ret = 0; //i2c_add_adapter(&port->adapter); } if (ret) { nv_error(device, "I2C%d: failed register: %d\n", i, ret); IOFree(port, sizeof(struct nouveau_i2c_port)); continue; } nv_debug(device, "adding i2c port %s\n", port->adapter.name); list_add_tail(&port->head, &i2c->ports); } return 0; } static bool probe_monitoring_device(struct nouveau_i2c_port *i2c, struct i2c_board_info *info) { #if CONFIG_NOUVEAU_I2C_NVCLOCK nouveau_device *device = i2c->i2c->device; I2CBusPtr bus = (I2CBusPtr)info->platform_data; I2CSlaveAddr addr = info->addr << 1; I2CDevPtr dev = nvclock_i2c_probe_device(bus, addr, "%1i:%02X", bus, addr); if (dev) { if (!strncmp(info->type, "w83l785ts", sizeof("w83l785ts"))) { if(!w83l785r_detect(dev)) return false; } else if (!strncmp(info->type, "w83781d", sizeof("w83781d"))) { if(!w83781d_detect(dev)) return false; } else if (!strncmp(info->type, "adt7473", sizeof("adt7473"))) { if(!adt7473_detect(dev)) return false; } else if (!strncmp(info->type, "f75375", sizeof("f75375"))) { if(!f75375_detect(dev)) return false; } else if (!strncmp(info->type, "lm99", sizeof("lm99")) || !strncmp(info->type, "lm90", sizeof("lm90")) || !strncmp(info->type, "lm63", sizeof("lm63"))) { if(!lm99_detect(dev)) return false; } } device->nvclock_i2c_sensor = dev; nv_debug(device, "found device: %s\n", device->nvclock_i2c_sensor->chip_name); switch(device->nvclock_i2c_sensor->chip_id) { case LM99: case MAX6559: device->board_temp_get = lm99_get_board_temp; device->core_temp_get = lm99_get_gpu_temp; break; case F75375: device->board_temp_get = f75375_get_board_temp; device->core_temp_get = f75375_get_gpu_temp; device->fan_rpm_get = f75375_get_fanspeed_rpm; device->fan_pwm_get = f75375_get_fanspeed_pwm; break; case W83781D: device->board_temp_get = w83781d_get_board_temp; device->core_temp_get = w83781d_get_gpu_temp; device->fan_rpm_get = w83781d_get_fanspeed_rpm; //device->get_i2c_fanspeed_pwm = w83781d_get_fanspeed_pwm; break; case W83L785R: device->board_temp_get = w83l785r_get_board_temp; device->core_temp_get = w83l785r_get_gpu_temp; device->fan_rpm_get = w83l785r_get_fanspeed_rpm; device->fan_pwm_get = w83l785r_get_fanspeed_pwm; break; case ADT7473: device->board_temp_get = adt7473_get_board_temp; device->core_temp_get = adt7473_get_gpu_temp; device->fan_rpm_get = adt7473_get_fanspeed_rpm; device->fan_pwm_get = adt7473_get_fanspeed_pwm; break; default: break; } return true; #else struct i2c_client *client; request_module("%s%s", I2C_MODULE_PREFIX, info->type); client = i2c_new_device(&i2c->adapter, info); if (!client) return false; if (!client->driver || client->driver->detect(client, info)) { i2c_unregister_device(client); return false; } return true; #endif } #define I2C_BOARD_INFO(dev_type, dev_addr) \ .type = dev_type, .addr = (dev_addr) void nouveau_i2c_probe(struct nouveau_device *device) { struct nouveau_i2c *i2c = &device->i2c; struct nvbios_extdev_func extdev_entry; struct i2c_board_info info[] = { { I2C_BOARD_INFO("w83l785ts", 0x2d) }, { I2C_BOARD_INFO("w83781d", 0x2d) }, { I2C_BOARD_INFO("adt7473", 0x2e) }, { I2C_BOARD_INFO("adt7473", 0x2d) }, { I2C_BOARD_INFO("adt7473", 0x2c) }, { I2C_BOARD_INFO("f75375", 0x2e) }, { I2C_BOARD_INFO("lm99", 0x4c) }, { I2C_BOARD_INFO("lm90", 0x4c) }, { I2C_BOARD_INFO("lm90", 0x4d) }, { I2C_BOARD_INFO("adm1021", 0x18) }, { I2C_BOARD_INFO("adm1021", 0x19) }, { I2C_BOARD_INFO("adm1021", 0x1a) }, { I2C_BOARD_INFO("adm1021", 0x29) }, { I2C_BOARD_INFO("adm1021", 0x2a) }, { I2C_BOARD_INFO("adm1021", 0x2b) }, { I2C_BOARD_INFO("adm1021", 0x4c) }, { I2C_BOARD_INFO("adm1021", 0x4d) }, { I2C_BOARD_INFO("adm1021", 0x4e) }, { I2C_BOARD_INFO("lm63", 0x18) }, { I2C_BOARD_INFO("lm63", 0x4e) }, { } }; if (!nvbios_extdev_find(device, NVBIOS_EXTDEV_LM89, &extdev_entry)) { struct i2c_board_info board[] = { { I2C_BOARD_INFO("lm90", extdev_entry.addr >> 1) }, { } }; if(i2c->identify(i2c, NV_I2C_DEFAULT(0), "monitoring device", board, probe_monitoring_device) >= 0) return; } if (!nvbios_extdev_find(device, NVBIOS_EXTDEV_ADT7473, &extdev_entry)) { struct i2c_board_info board[] = { { I2C_BOARD_INFO("adt7473", extdev_entry.addr >> 1) }, { } }; if(i2c->identify(i2c, NV_I2C_DEFAULT(0), "monitoring device",board, probe_monitoring_device) >= 0) return; } /* The vbios doesn't provide the address of an exisiting monitoring device. Let's try our static list. */ if (i2c->identify(i2c, NV_I2C_DEFAULT(0), "monitoring device", info, probe_monitoring_device) < 0) i2c->identify(i2c, NV_I2C_DEFAULT(1), "monitoring device", info, probe_monitoring_device); // struct i2c_board_info info[] = { // { "w83l785ts", 0x0, 0x2d, NULL, 0 }, // { "w83781d", 0x0, 0x2d, NULL, 0 }, // { "adt7473", 0x0, 0x2e, NULL, 0 }, // { "f75375", 0x0, 0x2e, NULL, 0 }, // { "lm99", 0x0, 0x4c, NULL, 0 }, // { } // }; // // i2c->identify(i2c, NV_I2C_DEFAULT(0), "monitoring device", info, probe_monitoring_device); // i2c->identify(i2c, NV_I2C_DEFAULT(1), "monitoring device", info, probe_monitoring_device); }
[ "natan.zalkin@me.com" ]
natan.zalkin@me.com
bba3698540fcb4b972aae0d1d6342ac0f5310f54
6c1de2d89960559fd19c0674c26b3d79df6afd81
/idlecallback.h
30e0b41040e4ede1576fba9eee9281b5868d0beb
[ "BSD-2-Clause", "BSD-3-Clause", "BSD-4-Clause-UC", "LicenseRef-scancode-other-permissive" ]
permissive
uclmediatools/vic
98cd0a331669596669799abf9aee5b49e77b2e80
6bc8feca6c126924521c840710b95513668d69e8
refs/heads/master
2016-09-05T09:51:26.801101
2006-11-29T05:36:49
2006-11-29T05:36:49
10,332,314
0
2
null
null
null
null
UTF-8
C++
false
false
2,227
h
/* * Copyright (c) 1993-1994 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and the Network Research Group at * Lawrence Berkeley Laboratory. * 4. Neither the name of the University nor of the Laboratory may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#) $Header$ (LBL) */ #ifndef vic_idlecallback_h #define vic_idlecallback_h extern "C" { #include <tk.h> } class IdleCallback { protected: IdleCallback(); public: virtual ~IdleCallback(); void idle_sched(); void idle_cancel(); protected: virtual void idle_callback() = 0; private: static void dispatch(ClientData); int pending_; }; #endif
[ "ucacsva@bc8abe95-590b-0410-a0f3-dc9ed9a1a8fa" ]
ucacsva@bc8abe95-590b-0410-a0f3-dc9ed9a1a8fa
7cbab26f73af6966a86044812757fd0f5d20dbf6
a2156427d674e597f3ecbeb1733974224282a7f1
/test/EeyoreClient.cpp
9bdc9b7daee0f8759e64896851a467244657bacc
[]
no_license
PoohCook/PlusStuff
cdf682aa4b62411c3e5767ce2091c1d23ceec7fa
8becac2dc5cc013209626bccdd97b5813e908010
refs/heads/master
2020-03-29T05:20:37.628446
2018-10-04T03:43:54
2018-10-04T03:43:54
149,578,307
0
0
null
null
null
null
UTF-8
C++
false
false
1,516
cpp
/* * File: EeyoreClient.cpp * Author: Pooh * * Created on October 3, 2018, 4:18 PM */ #include <string> #include <iostream> #include <boost/serialization/vector.hpp> #include <boost/serialization/string.hpp> #include <boost/program_options.hpp> #include "ChannelClient.h" #include "PoohCommand.h" namespace po = boost::program_options; bool running = true; PoohOptions options; class EeyoreHandler{ public: string process( int client_id, PoohCommand command ){ switch(command.type){ case POOH_COMMAND_HELLO: return "Hello Pooh"; case POOH_COMMAND_QUESTION: if( command.arg[0] == "name"){ return "Eeyore"; } else if( command.arg[0] == "secret"){ return options.secret; } else if( command.arg[0] == "client_id"){ return to_string(client_id); } else { return "oh bother"; } case POOH_COMMAND_GOODBYE: running = false; return "Bye now"; default: return "unknown command"; } } }; int main(int argc, const char *argv[]){ if( !options.parse_options( argc, argv)){ return -1; } ChannelClient<PoohCommand,string,EeyoreHandler> myChannel(options.client_id, options.port); while( running ){ sleep(1); } return 0; }
[ "PoohCook@gmail.com" ]
PoohCook@gmail.com
95f60f757c732af60fdb4f0ae0927f96c4d227e3
1521c6c1ed741db06b5f87f1ec0c9cba9931f1b0
/Source/Batiment/Interieur/MurVertical.h
8cf5d3595bb594d7f70f7902e3f3f367cb5c638e
[ "CC-BY-3.0", "MIT", "CC-BY-4.0" ]
permissive
Matthieu-Riou/Kurt-The-Last-Key
15c55be183669e3ac498fed35a8e1fa6227ea1d2
ea59e86963a035748b394ec09154af872a6fa309
refs/heads/master
2016-09-05T13:05:53.523239
2014-09-25T14:41:25
2014-09-25T14:41:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
748
h
#ifndef MURVERTICAL_H #define MURVERTICAL_H /** \file MurVertical.h \brief Représentation d'un mur horizontal \author RIOU, MAUSSION */ #include <SFML/Graphics.hpp> #include <string> #include <sstream> #include <vector> #include <iostream> #include "MurAbstrait.h" #include "../../Espace.h" /** \class MurVertical \brief Classe héritant de MurAbstrait représentant un mur vertical */ class MurVertical : public MurAbstrait { public: MurVertical(sf::Vector2f p,int longueur); virtual ~MurVertical(); virtual bool isVertical() const; virtual bool isHorizontal() const; virtual bool addDoor(sf::Vector2f p1, sf::Vector2f p2); }; #endif // MURVERTICAL_H
[ "matthieu.riou@etu.univ-nantes.fr" ]
matthieu.riou@etu.univ-nantes.fr
c5aea21242758519581db7ba5b38422a7e9a1557
d23d36fd5b4e6851fef68940b15ed625677a576b
/作业3-3/作业3-3/作业3-3View.h
102a45273e6bd5b23b4d1e09719a250bdfaf51b8
[]
no_license
DJQ0926/test
0d5fd731edef513e08b1169578e70fe9139d7d05
e9a755ac66750e14bbb870d211531d91a92fc2ee
refs/heads/master
2021-02-15T23:03:21.681207
2020-07-05T09:51:20
2020-07-05T09:51:20
244,942,227
0
0
null
null
null
null
GB18030
C++
false
false
943
h
// 作业3-3View.h : C作业33View 类的接口 // #pragma once class C作业33View : public CView { protected: // 仅从序列化创建 C作业33View(); DECLARE_DYNCREATE(C作业33View) // 特性 public: C作业33Doc* GetDocument() const; // 操作 public: // 重写 public: virtual void OnDraw(CDC* pDC); // 重写以绘制该视图 virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: // 实现 public: virtual ~C作业33View(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // 生成的消息映射函数 protected: DECLARE_MESSAGE_MAP() public: afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); }; #ifndef _DEBUG // 作业3-3View.cpp 中的调试版本 inline C作业33Doc* C作业33View::GetDocument() const { return reinterpret_cast<C作业33Doc*>(m_pDocument); } #endif
[ "964158009@qq.com" ]
964158009@qq.com
018d01ba70f5016f9ae65b5452f9d0ff2d649ede
63793887b9b848285150f40c4ff141682cfc1f8c
/amit/prime_matrix.cpp
4f285dc1a4331c8e702b21c98f35d08de4ab5153
[]
no_license
akashyap661/Placement-Program
245966c41a440f8ca2f583e571ca0521d2fa0a20
669de910617ebfebac262c984959278aa92ece7c
refs/heads/master
2020-06-08T14:25:42.321230
2019-06-22T14:59:23
2019-06-22T14:59:23
193,243,940
0
0
null
null
null
null
UTF-8
C++
false
false
1,501
cpp
// In this problem we need to count no.of step as if we increase value of elements by 1 in order // to make any row or column prime #include<iostream> #include<bits/stdc++.h> using namespace std; bool prime(int n) { bool a[n+1]; int i,j; memset(a,true,sizeof(a)); for(i=2;i*i<=n;i++) { if(a[i]==true) { for(j=i*i;j<=n;j+=i) a[j]=false; } } return a[n]; } bool check(int *temp,int n) { int i,count1; for(i=0;i<n*n;i++) { if(i%3==0) count1=0; if(prime(temp[i])==true) { count1++; if(count1==3) return true; } } return false; } int main() { int n,step=0; cin>>n; int a[n][n],r[n*n],c[n*n],i,j,x; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cin>>a[i][j]; } } x=0; for(i=0;i<n;i++) { for(j=0;j<n;j++) { r[x]=a[i][j]; } } x=0; for(i=0;i<n;i++) { for(j=0;j<n;j++) { c[x]=a[j][i]; } } while(1) { if(check(r,n)==true || check(c,n)==true) { cout<<step; return 0; } for(int i=0;i<=n*n;i++) { if(prime(r[i])==false) r[i]++; } for(int i=0;i<=n*n;i++) { if(!prime(c[i])==false) c[i]++; } step++; } }
[ "akashyap661@gmail.com" ]
akashyap661@gmail.com
d73e5def4bc72f59f761aef9d9e1736e03480e3f
5495469ae3ed685a40d8afa027a94e6dca44a6d2
/day03/ex02/ClapTrap.cpp
4fb39608e11a49ad9565f15f0915604068193605
[]
no_license
ishtvan-lucor/cpp_pool
4dab3e23fd7f84b68f05eefeb8e435c792baba6f
7cb570d5d2ce82bd596d08c540de446bbaa2ed7c
refs/heads/master
2020-06-09T18:03:31.031485
2019-08-20T14:40:08
2019-08-20T14:40:08
193,480,572
0
0
null
null
null
null
UTF-8
C++
false
false
3,319
cpp
#include "ClapTrap.hpp" ClapTrap::ClapTrap( std::string name ) : _hp(10), _max_hp(10), _ep(10), _max_ep(10), _lvl(1), _name(name), _melee_ad(0), _range_ad(0), _armor_dr(0) { std::cout << "ClapTrap is here!" << std::endl; } ClapTrap::ClapTrap(ClapTrap const &copy) { std::cout << "More ClapTrap copy!" << std::endl; *this = copy; } ClapTrap & ClapTrap::operator=(ClapTrap const &rhs) { this->_hp = rhs.getHp(); this->_max_hp = rhs.getMaxHp(); this->_ep = rhs.getEp(); this->_max_ep = rhs.getMaxEp(); this->_lvl = rhs.getLvl(); this->_name =rhs.getName(); this->_melee_ad = rhs.getMeleeAd(); this->_range_ad = rhs.getRangeAd(); this->_armor_dr = rhs.getArmor_dr(); return (*this); } ClapTrap::~ClapTrap() { std::cout << "The Legion is fall..." << std::endl; } void ClapTrap::setHp(int x) { if (x < 0) this->_hp = 0; else if (x > this->getMaxHp()) this->_hp = this->getMaxHp(); else this->_hp = x; } void ClapTrap::setMaxHp(int x) { if (x < 1) this->_hp = 1; else this->_hp = x; } void ClapTrap::setEp(int x) { if (x < 0) this->_ep = 0; else if (x > this->getMaxEp()) this->_ep = this->getMaxEp(); else this->_ep = x; } void ClapTrap::setMaxEp(int x) { if (x < 1) this->_max_ep = 1; else this->_max_ep = x; } void ClapTrap::setLvl(int x) { if (x < 1) this->_lvl = 1; else this->_lvl = x; } void ClapTrap::setName(std::string name) { this->_name = name; } void ClapTrap::setMeleeAd(int x) { if (x < 0) this->_melee_ad = 0; else this->_melee_ad = x; } void ClapTrap::setRangeAd(int x) { if (x < 0) this->_range_ad = 0; else this->_range_ad = x; } void ClapTrap::setArmorDr(int x) { if (x < 0) this->_armor_dr = 0; else this->_armor_dr = x; } int ClapTrap::getHp() const { return this->_hp; } int ClapTrap::getMaxHp() const { return this->_max_hp; } int ClapTrap::getEp() const { return this->_ep; } int ClapTrap::getMaxEp() const { return this->_max_ep; } int ClapTrap::getLvl() const { return this->_lvl; } std::string ClapTrap::getName() const { return this->_name; } int ClapTrap::getMeleeAd() const { return this->_melee_ad; } int ClapTrap::getRangeAd() const { return this->_range_ad; } int ClapTrap::getArmor_dr() const { return this->_armor_dr; } int ClapTrap::rangedAttack(const std::string &target) { std::cout << "FR4G-TP " << _name << " attack bastard " << target << " at range, causing " << _range_ad << " points of damage !" << std::endl; return 1; } int ClapTrap::meleeAttack(const std::string &target) { std::cout << "FR4G-TP " << _name << " attack bastard " << target << " at melee, causing " << _melee_ad << " points of damage !" << std::endl; return 1; } int ClapTrap::takeDamage(unsigned int amount) { std::cout << "FR4G-TP " << _name; if ((int)amount > _armor_dr) { std::cout << " get " << amount << " point damage! "; this->setHp(_hp - amount); } else std::cout << " dodge all damage =) "; std::cout << "Revenge is neaaaar!" << std::endl; return 1; } int ClapTrap::beRepaired(unsigned int amount) { std::cout << "FR4G-TP " << _name; if ( _hp == _max_hp ) { std::cout << " have no defects." << std::endl; return 1; } setHp(_hp + amount); std::cout << " was repaired!" << std::endl; return 1; }
[ "ishtvan.koloshynsky@gmail.com" ]
ishtvan.koloshynsky@gmail.com
97f3ee981341445396056bcb848cc6fd5805d022
139b1a522a666a62a7e45bc0c6a3ce7c9e910a86
/stira/deconvolve/deconvolve/IterativeDeconvolve.cpp
e3b607360c9b25734be9ddca6acbfb9441592ac9
[ "MIT" ]
permissive
andyTsing/stira
5857c7acc579c918164491459c1c3cc011f57fa5
863bc39ac3a4e5cfb354428965bdb7b93e76855d
refs/heads/master
2021-01-23T23:13:18.375623
2015-04-27T20:20:50
2015-04-27T20:20:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,726
cpp
/*********************************************************************************** * Copyright (C) 2008 by Filip Rooms * * * * Terms and conditions for using this software in any form are provided in the * * file COPYING, which can be found in the root directory of this project. * * * * Contact data: filip.rooms@gmail.com * * http://www.filiprooms.be/ * * * ***********************************************************************************/ #include "IterativeDeconvolve.h" #include "../../common/common/MathUtils.h" namespace stira{ namespace deconvolve{ using namespace std; using namespace common; using namespace image; //-------------------------------------------------------------------------- IterativeDeconvolve::IterativeDeconvolve( image::Image* pDegradedImage, int maxNrOfIterations ) : DeconvolveMaster( pDegradedImage ) { Initialize( maxNrOfIterations ); } //-------------------------------------------------------------------------- IterativeDeconvolve::IterativeDeconvolve( image::Image* pDegradedImage, image::Image* pPSF, int maxNrOfIterations ) : DeconvolveMaster( pDegradedImage, pPSF ) { Initialize( maxNrOfIterations ); } //-------------------------------------------------------------------------- void IterativeDeconvolve::Initialize( int maxNrOfIterations ) { mCurrentIterationNr = 0; mMaximumNrOfIterations = maxNrOfIterations; mpLastEstimate = mpDegradedImage->Clone(); mpNewEstimate = mpDegradedImage->Clone(); mCurrentBandNr = 0; mLambda = 0.001; mStepSize = 1.0; mMaximumNrOfIterations = maxNrOfIterations; mpDegradedGrid=0; mpLastGrid=0; mpNewGrid=0; mpPSFGrid=0; } //-------------------------------------------------------------------------- IterativeDeconvolve::~IterativeDeconvolve() { } //-------------------------------------------------------------------------- int IterativeDeconvolve::GetMaximumNrOfIterations() { return mMaximumNrOfIterations; } //-------------------------------------------------------------------------- void IterativeDeconvolve::SetMaximumNrOfIterations( int nrIter) { mMaximumNrOfIterations = nrIter; } //-------------------------------------------------------------------------- void IterativeDeconvolve::SetLambda(double lambda) { mLambda = lambda; } //-------------------------------------------------------------------------- double IterativeDeconvolve::GetLambda() { return mLambda; } //-------------------------------------------------------------------------- void IterativeDeconvolve::SetStepSize(double stepSize) { mStepSize = stepSize; } //-------------------------------------------------------------------------- double IterativeDeconvolve::GetStepSize() { return mStepSize; } //-------------------------------------------------------------------------- bool IterativeDeconvolve::PrepareCurrentGrids( ) { mpDegradedGrid = mpDegradedImage->GetBands()[ mCurrentBandNr ]; mpLastGrid = mpLastEstimate->GetBands()[ mCurrentBandNr ]; mpNewGrid = mpNewEstimate->GetBands()[ mCurrentBandNr ]; mpPSFGrid = 0; if (mpPSF->GetNumberOfBands() > 1) { mpPSFGrid = mpPSF->GetBands()[ mCurrentBandNr ]; } else { mpPSFGrid = mpPSF->GetBands()[0]; } return true; } } }
[ "filip.rooms@gmail.com" ]
filip.rooms@gmail.com
dc0b7a2f4a15156def72a424fa3d9aa67b67cfa1
a34445105030b0a6bc1e6ea1ed20923e8af6b8b7
/C++/level2/프린터.cpp
03509eb273554ea66d209e3b929fcfd05fde7e3c
[]
no_license
ambacc244/algorithm
e701f37cb541d79716a40cbf89640472f356a0e9
da3b313f913e5c7564f8a17355673d6ee5feec89
refs/heads/master
2023-02-05T13:34:41.477254
2020-12-25T03:43:46
2020-12-25T03:43:46
245,620,194
0
0
null
null
null
null
UTF-8
C++
false
false
788
cpp
#include <string> #include <vector> #include <queue> #include <iostream> using namespace std; int solution(vector<int> priorities, int location) { int answer = 0; bool pass = false; queue<pair<int, int>> queue; priority_queue<int> order; for(int i=0; i<priorities.size(); i++){ queue.push(make_pair(priorities[i], i)); order.push(priorities[i]); } while(!pass && queue.size() != 0){ if(queue.front().first == order.top()){ if(queue.front().second == location) pass = true; order.pop(); queue.pop(); answer++; } else{ queue.push(queue.front()); queue.pop(); } } if(!pass) return -1; return answer; }
[ "leeye@oregonstate.edu" ]
leeye@oregonstate.edu
4835e87f8357521ec9c58aed7f19ff3810d55b84
71501709864eff17c873abbb97ffabbeba4cb5e3
/llvm11.1.0/flang/include/flang/Evaluate/traverse.h
4888946c1a6c3e814804a3dd994b2c01ec1e9565
[ "LLVM-exception", "Apache-2.0" ]
permissive
LEA0317/LLVM-VideoCore4
d08ba6e6f26f7893709d3285bdbd67442b3e1651
7ae2304339760685e8b5556aacc7e9eee91de05c
refs/heads/master
2022-06-22T15:15:52.112867
2022-06-09T08:45:24
2022-06-09T08:45:24
189,765,789
1
0
NOASSERTION
2019-06-01T18:31:29
2019-06-01T18:31:29
null
UTF-8
C++
false
false
10,169
h
//===-- include/flang/Evaluate/traverse.h -----------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef FORTRAN_EVALUATE_TRAVERSE_H_ #define FORTRAN_EVALUATE_TRAVERSE_H_ // A utility for scanning all of the constituent objects in an Expr<> // expression representation using a collection of mutually recursive // functions to compose a function object. // // The class template Traverse<> below implements a function object that // can handle every type that can appear in or around an Expr<>. // Each of its overloads for operator() should be viewed as a *default* // handler; some of these must be overridden by the client to accomplish // its particular task. // // The client (Visitor) of Traverse<Visitor,Result> must define: // - a member function "Result Default();" // - a member function "Result Combine(Result &&, Result &&)" // - overrides for "Result operator()" // // Boilerplate classes also appear below to ease construction of visitors. // See CheckSpecificationExpr() in check-expression.cpp for an example client. // // How this works: // - The operator() overloads in Traverse<> invoke the visitor's Default() for // expression leaf nodes. They invoke the visitor's operator() for the // subtrees of interior nodes, and the visitor's Combine() to merge their // results together. // - Overloads of operator() in each visitor handle the cases of interest. #include "expression.h" #include "flang/Semantics/symbol.h" #include "flang/Semantics/type.h" #include <set> #include <type_traits> namespace Fortran::evaluate { template <typename Visitor, typename Result> class Traverse { public: explicit Traverse(Visitor &v) : visitor_{v} {} // Packaging template <typename A, bool C> Result operator()(const common::Indirection<A, C> &x) const { return visitor_(x.value()); } template <typename A> Result operator()(SymbolRef x) const { return visitor_(*x); } template <typename A> Result operator()(const std::unique_ptr<A> &x) const { return visitor_(x.get()); } template <typename A> Result operator()(const std::shared_ptr<A> &x) const { return visitor_(x.get()); } template <typename A> Result operator()(const A *x) const { if (x) { return visitor_(*x); } else { return visitor_.Default(); } } template <typename A> Result operator()(const std::optional<A> &x) const { if (x) { return visitor_(*x); } else { return visitor_.Default(); } } template <typename... A> Result operator()(const std::variant<A...> &u) const { return std::visit(visitor_, u); } template <typename A> Result operator()(const std::vector<A> &x) const { return CombineContents(x); } // Leaves Result operator()(const BOZLiteralConstant &) const { return visitor_.Default(); } Result operator()(const NullPointer &) const { return visitor_.Default(); } template <typename T> Result operator()(const Constant<T> &x) const { if constexpr (T::category == TypeCategory::Derived) { std::optional<Result> result; for (const StructureConstructorValues &map : x.values()) { for (const auto &pair : map) { auto value{visitor_(pair.second.value())}; result = result ? visitor_.Combine(std::move(*result), std::move(value)) : std::move(value); } } return result ? *result : visitor_.Default(); } else { return visitor_.Default(); } } Result operator()(const Symbol &) const { return visitor_.Default(); } Result operator()(const StaticDataObject &) const { return visitor_.Default(); } Result operator()(const ImpliedDoIndex &) const { return visitor_.Default(); } // Variables Result operator()(const BaseObject &x) const { return visitor_(x.u); } Result operator()(const Component &x) const { return Combine(x.base(), x.GetLastSymbol()); } Result operator()(const NamedEntity &x) const { if (const Component * component{x.UnwrapComponent()}) { return visitor_(*component); } else { return visitor_(x.GetFirstSymbol()); } } template <int KIND> Result operator()(const TypeParamInquiry<KIND> &x) const { return visitor_(x.base()); } Result operator()(const Triplet &x) const { return Combine(x.lower(), x.upper(), x.stride()); } Result operator()(const Subscript &x) const { return visitor_(x.u); } Result operator()(const ArrayRef &x) const { return Combine(x.base(), x.subscript()); } Result operator()(const CoarrayRef &x) const { return Combine( x.base(), x.subscript(), x.cosubscript(), x.stat(), x.team()); } Result operator()(const DataRef &x) const { return visitor_(x.u); } Result operator()(const Substring &x) const { return Combine(x.parent(), x.lower(), x.upper()); } Result operator()(const ComplexPart &x) const { return visitor_(x.complex()); } template <typename T> Result operator()(const Designator<T> &x) const { return visitor_(x.u); } template <typename T> Result operator()(const Variable<T> &x) const { return visitor_(x.u); } Result operator()(const DescriptorInquiry &x) const { return visitor_(x.base()); } // Calls Result operator()(const SpecificIntrinsic &) const { return visitor_.Default(); } Result operator()(const ProcedureDesignator &x) const { if (const Component * component{x.GetComponent()}) { return visitor_(*component); } else if (const Symbol * symbol{x.GetSymbol()}) { return visitor_(*symbol); } else { return visitor_(DEREF(x.GetSpecificIntrinsic())); } } Result operator()(const ActualArgument &x) const { if (const auto *symbol{x.GetAssumedTypeDummy()}) { return visitor_(*symbol); } else { return visitor_(x.UnwrapExpr()); } } Result operator()(const ProcedureRef &x) const { return Combine(x.proc(), x.arguments()); } template <typename T> Result operator()(const FunctionRef<T> &x) const { return visitor_(static_cast<const ProcedureRef &>(x)); } // Other primaries template <typename T> Result operator()(const ArrayConstructorValue<T> &x) const { return visitor_(x.u); } template <typename T> Result operator()(const ArrayConstructorValues<T> &x) const { return CombineContents(x); } template <typename T> Result operator()(const ImpliedDo<T> &x) const { return Combine(x.lower(), x.upper(), x.stride(), x.values()); } Result operator()(const semantics::ParamValue &x) const { return visitor_(x.GetExplicit()); } Result operator()( const semantics::DerivedTypeSpec::ParameterMapType::value_type &x) const { return visitor_(x.second); } Result operator()(const semantics::DerivedTypeSpec &x) const { return CombineContents(x.parameters()); } Result operator()(const StructureConstructorValues::value_type &x) const { return visitor_(x.second); } Result operator()(const StructureConstructor &x) const { return visitor_.Combine(visitor_(x.derivedTypeSpec()), CombineContents(x)); } // Operations and wrappers template <typename D, typename R, typename O> Result operator()(const Operation<D, R, O> &op) const { return visitor_(op.left()); } template <typename D, typename R, typename LO, typename RO> Result operator()(const Operation<D, R, LO, RO> &op) const { return Combine(op.left(), op.right()); } Result operator()(const Relational<SomeType> &x) const { return visitor_(x.u); } template <typename T> Result operator()(const Expr<T> &x) const { return visitor_(x.u); } private: template <typename ITER> Result CombineRange(ITER iter, ITER end) const { if (iter == end) { return visitor_.Default(); } else { Result result{visitor_(*iter++)}; for (; iter != end; ++iter) { result = visitor_.Combine(std::move(result), visitor_(*iter)); } return result; } } template <typename A> Result CombineContents(const A &x) const { return CombineRange(x.begin(), x.end()); } template <typename A, typename... Bs> Result Combine(const A &x, const Bs &... ys) const { if constexpr (sizeof...(Bs) == 0) { return visitor_(x); } else { return visitor_.Combine(visitor_(x), Combine(ys...)); } } Visitor &visitor_; }; // For validity checks across an expression: if any operator() result is // false, so is the overall result. template <typename Visitor, bool DefaultValue, typename Base = Traverse<Visitor, bool>> struct AllTraverse : public Base { explicit AllTraverse(Visitor &v) : Base{v} {} using Base::operator(); static bool Default() { return DefaultValue; } static bool Combine(bool x, bool y) { return x && y; } }; // For searches over an expression: the first operator() result that // is truthful is the final result. Works for Booleans, pointers, // and std::optional<>. template <typename Visitor, typename Result = bool, typename Base = Traverse<Visitor, Result>> class AnyTraverse : public Base { public: explicit AnyTraverse(Visitor &v) : Base{v} {} using Base::operator(); Result Default() const { return default_; } static Result Combine(Result &&x, Result &&y) { if (x) { return std::move(x); } else { return std::move(y); } } private: Result default_{}; }; template <typename Visitor, typename Set, typename Base = Traverse<Visitor, Set>> struct SetTraverse : public Base { explicit SetTraverse(Visitor &v) : Base{v} {} using Base::operator(); static Set Default() { return {}; } static Set Combine(Set &&x, Set &&y) { #if defined __GNUC__ && !defined __APPLE__ && !(CLANG_LIBRARIES) x.merge(y); #else // std::set::merge() not available (yet) for (auto &value : y) { x.insert(std::move(value)); } #endif return std::move(x); } }; } // namespace Fortran::evaluate #endif
[ "kontoshi0317@gmail.com" ]
kontoshi0317@gmail.com