本文整理汇总了C++中cp函数的典型用法代码示例。如果您正苦于以下问题:C++ cp函数的具体用法?C++ cp怎么用?C++ cp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalcMPCStats
// preconditions: computer has no book
void CalcMPCStats(CPlayerComputer* computer, int height) {
FILE* cpFile;
CBitBoard bb;
int nbbs[60], i, iPos;
const int iPosMin=159; // start at this line, useful if stopping and restarting
CQPosition pos;
CCalcParams *cpOld=computer->pcp;
CHeightInfo hi(height, 0, false);
CCalcParamsFixedHeight cp(hi);
computer->pcp=&cp;
computer->cd.fsPrint=0;
// header info
std::cout << 3 << " " << height << " " << kStoneValue << "\n";
// clear computer's and params
//computer->cd.iPruneMidgame=computer->cd.iPruneEndgame=0;
// clear position counts and init
for (i=0; i<60; i++)
nbbs[i]=0;
iPos=0;
// read positions from file; analyze if we should
std::string fn(fnBaseDir);
fn+="captured.pos";
if ((cpFile=fopen(fn.c_str(),"rb"))) {
while (bb.Read(cpFile)) {
pos.Initialize(bb, true);
if (nbbs[bb.NEmpty()]++ < kMaxPositions)
if (iPos++>=iPosMin)
AnalyzePosition(computer, pos);
}
fclose(cpFile);
}
// restore computer's book and params
computer->pcp=cpOld;
}
示例2: main
int main(object me, string arg)
{
string src, dst, *dirs;
seteuid(geteuid(me));
if (!arg || sscanf(arg, "%s %s", src, dst)!=2 ) return
notify_fail("指令格式: cp <原档名> <目标档名> \n");
src = resolve_path(me->query("cwd"), src);
dst = resolve_path(me->query("cwd"), dst);
if( file_size(dst)==-2 ) {
dirs = explode(src, "/");
dst += "/" + dirs[sizeof(dirs)-1];
}
if( cp(src, dst) )
write("Ok.\n");
else
write("你没有足够的读写权利。\n");
return 1;
}
示例3: T
void Foam::ThermoParcel<ParcelType>::writeFields(const Cloud<ParcelType>& c)
{
KinematicParcel<ParcelType>::writeFields(c);
label np = c.size();
IOField<scalar> T(c.fieldIOobject("T", IOobject::NO_READ), np);
IOField<scalar> cp(c.fieldIOobject("cp", IOobject::NO_READ), np);
label i = 0;
forAllConstIter(typename Cloud<ParcelType>, c, iter)
{
const ThermoParcel<ParcelType>& p = iter();
T[i] = p.T_;
cp[i] = p.cp_;
i++;
}
T.write();
cp.write();
}
示例4: main
int main(int argc, char* argv[])
{
argc -= handleOpts(argc, argv);
if (argc < 2){
fprintf(stderr, "Usage: %s [config.ini]\n", argv[0]);
exit(1);
}
optClientno = atoi(argv[optind+1]);
ConfigParser cp(argv[optind]);
cp.Parse();
for (auto& section : cp._sections){
if (section.first.find("Workload") != std::string::npos){
std::string workload = section.first;
Config cfg(&cp, workload);
// SYSTEM-SPECIFIC
std::string system_conf;
if (!optServerPort) system_conf = cfg.get<std::string>("yesql", "");
else system_conf = std::string(optServerPort);
std::string dir = cfg.get<std::string>("logdir", ".");
if (dir.back() != '/')
dir.append("/");
dir.append("client-");
dir.append(std::to_string(optClientno));
dir.append("-");
dir.append(workload);
dir.append(".txt");
SetLog(dir.c_str());
LOG("Starting a YESQL expt.\n");
int nthreads = cfg.get<int>("threads", 1);
do_experiment(nthreads, system_conf.c_str(), &cfg, false);
}
}
return 0;
}
示例5: do_tests
void do_tests() {
string foo, mid, all;
ASSERT(cp("/single/master.c", "/testfile"));
rm("/testfile.zerolength");
write_file("/testfile.zerolength", "");
foo = read_file("/testfile.zerolength");
ASSERT_EQ("", foo);
foo = read_bytes("/testfile");
mid = implode(explode(foo, "\n")[9..18], "\n") + "\n";
all = implode(explode(foo, "\n")[9..<1], "\n") + "\n";
ASSERT(!read_file("/single", 10, 10));
ASSERT(foo == read_file("/testfile"));
ASSERT(foo == read_file("/testfile.crlf"));
ASSERT_EQ(mid, read_file("/testfile", 10, 10));
// if we are asking more lines than in the file, return whole file
ASSERT(all == read_file("/testfile", 10, 0x7fffffff));
ASSERT(!read_file("/does_not_exist"));
ASSERT(!read_file("/testfile", 10000, 1));
}
示例6: loadconfig
static bool loadconfig(const char *fn, const char *section)
/* Loads and sets only the general configuration out of the file, named by
* 'fn', using the section 'section' therein. Returns true, if succeeded.
*/
{
CfgParse cp(fn);
if(cp.geterror() == CfgParse::NotFound) // file not found?
return false;
// Define config variables
cp.enum_vars(CONFIG_VARS);
if(!cp.section(section)) // Jump to section, if defined
return false;
do {
switch(cp.peekvar()) {
case 1: opl.setport(cp.readlong()); break;
case 14: oplforce = cp.readbool(); break;
case 23: mydb.load(cp.readstr()); break;
case 26:
if(!stricmp(cp.readstr(), "name"))
filesel.sortby = FileWnd::SortByName;
else if(!stricmp(cp.readstr(), "extension"))
filesel.sortby = FileWnd::SortByExtension;
break;
case 27:
if(!stricmp(cp.readstr(), "nothing")) onsongend = 0;
else if(!stricmp(cp.readstr(), "rewind")) onsongend = 1;
else if(!stricmp(cp.readstr(), "stop")) onsongend = 2;
break;
}
} while(!cp.geterror());
if(cp.geterror() == CfgParse::Invalid) return false; else return true;
}
示例7: cp
vector<int> FormanGradientVector::count_critical_simplexes(){
vector<int> cp(3,0);
for(int i=0; i<mesh->getTopSimplexesNum(); i++){
if(is_face_critical(i))
cp[2]++;
}
for(int i=0; i<mesh->getNumVertex(); i++){
if(is_vertex_critical(i)){
cp[0]++;
}
vector<int> vv = mesh->VV(i);
for(auto v : vv){
if(v < i){
if(is_edge_critical(v,i))
cp[1]++;
}
}
}
return cp;
}
示例8: phip
sp_mat Device1D::qCMatFunct(mat phin, mat phip, bool Equilibrum) {
if ( phin.n_elem != sumPoint || ( phip.n_elem != sumPoint ) )
std::cerr << "Error: input wrong phin/phip size!" << std::endl;
sp_mat cp=speye(sumPoint, sumPoint);
if (Equilibrum == true ) {
for ( int i = 0; i < bandGapArray.size(); i++) {
phip(i) = bandGapArray[i] - phin(i);
}
}
int k=0;
for ( int i=0; i < materialList.size(); i++) {
for ( int j=0; j < nyList[i]; j++) {
if (typeList[i] == Semiconductor) {
cp(k + 1, k + 1) = materialList[i].quantumCapa((double)phin(k), (double)phip(k)); //TODO: why here used to be k+1, then "cp(0, 0) = cp(1, 1);"
} else if (typeList[i]==Dielectric) {
};
k++;
};
};
return ( cp );
}
示例9: rayplane
bool rayplane(float nx,float ny,float nz,float xs,float ys,float zs,float xd,float yd,float zd,coordinate p1,coordinate p2,coordinate p3,coordinate p4,float* dist,coordinate* point) {
float a=xd*nx+yd*ny+zd*nz;
if(a==0)
return false;
float t=((p1.x*nx+p1.y*ny+p1.z*nz-nx*xs-ny*ys-nz*zs)/a);
if(t<0)
return false;
float x=xs+t*xd;
float y=ys+t*yd;
float z=zs+t*zd;
coordinate cp(x,y,z);
if(abs(trianglearea(p1,p3,p4)-trianglearea(p1,p4,cp)-trianglearea(p1,p3,cp)-trianglearea(p3,p4,cp))<0.000001 || abs(trianglearea(p1,p2,p3)-trianglearea(p1,p2,cp)-trianglearea(p2,p3,cp)-trianglearea(p1,p3,cp))<0.000001) {
if(dist!=NULL) {
(*dist)=t;
if(point!=NULL) {
point->x=x;
point->y=y;
point->z=z;
}
}
return true;
}
return false;
}
示例10: main
int main()
{
title("Testing Socket Server", '=');
try
{
std::cout << "\n"<<"All files will be saved in ..\\Reciever\\RecievedFiles" << "\n\n";
std::cout << "\n" << "Please check appropriate Folder to check whether file is uploaded." << "\n";
SocketSystem ss;
SocketListener sl(9080, Socket::IP6);
BlockingQueue<std::string> queue1;
Reciever cp(queue1);
sl.start(cp);
std::cout.flush();
std::cin.get();
}
catch (std::exception& ex)
{
std::cout << ex.what();
/*Verbose::show(" Exception caught:", always);
Verbose::show(std::string("\n ") + ex.what() + "\n\n");*/
}
}
示例11: parallelPlanning
bool parallelPlanning(bool output, enum SPACE_TYPE space, std::vector<enum PLANNER_TYPE> &planners, unsigned int links,
unsigned int chains, struct ConstrainedOptions &c_opt, struct AtlasOptions &a_opt, bool bench)
{
// Create a shared pointer to our constraint.
auto constraint = std::make_shared<ParallelConstraint>(links, chains);
ConstrainedProblem cp(space, constraint->createSpace(), constraint);
cp.setConstrainedOptions(c_opt);
cp.setAtlasOptions(a_opt);
cp.css->registerProjection("parallel", constraint->getProjection(cp.css));
Eigen::VectorXd start, goal;
constraint->getStart(start);
constraint->getGoal(goal);
cp.setStartAndGoalStates(start, goal);
cp.ss->setStateValidityChecker(std::bind(&ParallelConstraint::isValid, constraint, std::placeholders::_1));
if (!bench)
return parallelPlanningOnce(cp, planners[0], output);
else
return parallelPlanningBench(cp, planners);
}
示例12: switch
// A non-NULL pointer is a sprite mask, a NULL pointer means bbox should be used.
void *get_collision_mask(sprite* spr, unsigned char* input_data, collision_type ct) // It is called for every subimage of every sprite loaded.
{
switch (ct)
{
case ct_precise:
{
const unsigned int w = spr->width, h = spr->height;
unsigned char* colldata = new unsigned char[w*h];
for (unsigned int rowindex = 0; rowindex < h; rowindex++)
{
for(unsigned int colindex = 0; colindex < w; colindex++)
{
colldata[rowindex*w + colindex] = (input_data[4*(rowindex*w + colindex) + 3] != 0) ? 1 : 0; // If alpha != 0 then 1 else 0.
}
}
return colldata;
}
case ct_bbox: return 0;
case ct_ellipse:
{
// Create ellipse inside bbox.
const unsigned int w = spr->width, h = spr->height;
unsigned char* colldata = new unsigned char[w*h](); // Initialize all elements to 0.
const bbox_rect_t bbox = spr->bbox;
const unsigned int a = max(bbox.right-bbox.left, bbox.bottom-bbox.top)/2, // Major radius.
b = min(bbox.right-bbox.left, bbox.bottom-bbox.top)/2; // Minor radius.
const unsigned int xc = (bbox.right+bbox.left)/2, // Center of ellipse.
yc = (bbox.bottom+bbox.top)/2;
const long long a_2 = a*a, b_2 = b*b, a_2b_2 = a*a*b*b;
const int minX = max(bbox.left-2, 0),
minY = max(bbox.top-2, 0),
maxX = min(bbox.right+2, w),
maxY = min(bbox.bottom+2, h);
for (int y = minY; y < maxY; y++)
{
for(int x = minX; x < maxX; x++)
{
const int xcp = x-xc, ycp = y-yc; // Center to point.
const bool is_inside_ellipse = b_2*xcp*xcp + a_2*ycp*ycp <= a_2b_2;
colldata[y*w + x] = (is_inside_ellipse ? 1 : 0); // If point inside ellipse, 1, else 0.
}
}
return colldata;
}
case ct_diamond:
{
// Create diamond inside bbox.
const unsigned int w = spr->width, h = spr->height;
unsigned char* colldata = new unsigned char[w*h](); // Initialize all elements to 0.
const bbox_rect_t bbox = spr->bbox;
// Diamond corners.
const int xl = bbox.left, yl = (bbox.top + bbox.bottom)/2,
xr = bbox.right, yr = (bbox.top + bbox.bottom)/2,
xt = (bbox.left + bbox.right)/2, yt = bbox.top,
xb = (bbox.left + bbox.right)/2, yb = bbox.bottom;
const int xlt = xt-xl, ylt = yt-yl, // Left corner to top corner.
xlb = xb-xl, ylb = yb-yl, // Left corner to bottom corner.
xrt = xt-xr, yrt = yt-yr, // Right corner to top corner.
xrb = xb-xr, yrb = yb-yr; // Right corner to bottom corner.
const int minX = max(bbox.left-2, 0),
minY = max(bbox.top-2, 0),
maxX = min(bbox.right+2, w),
maxY = min(bbox.bottom+2, h);
for (int y = minY; y < maxY; y++)
{
for(int x = minX; x < maxX; x++)
{
const int xlp = x-xl, ylp = y-yl; // Left corner to point.
const int xrp = x-xr, yrp = y-yr; // Right corner to point.
const bool is_inside_diamond = cp(xlt, -ylt, xlp, -ylp) <= 0 && // Use cross-product to determine whether inside or outside diamond.
cp(xlb, -ylb, xlp, -ylp) >= 0 &&
cp(xrt, -yrt, xrp, -yrp) >= 0 &&
cp(xrb, -yrb, xrp, -yrp) <= 0;
colldata[y*w + x] = (is_inside_diamond ? 1 : 0); // If point inside diamond, 1, else 0.
}
}
return colldata;
}
case ct_polygon: return 0;
case ct_circle: //NOTE: Not tested.
{
// Create circle fitting inside bbox.
const unsigned int w = spr->width, h = spr->height;
unsigned char* colldata = new unsigned char[w*h](); // Initialize all elements to 0.
const bbox_rect_t bbox = spr->bbox;
const unsigned int r = min(bbox.right-bbox.left, bbox.bottom-bbox.top)/2; // Radius.
const unsigned int xc = (bbox.right+bbox.left)/2, // Center of circle.
yc = (bbox.bottom+bbox.top)/2;
//.........这里部分代码省略.........
示例13: plotSFspec
//.........这里部分代码省略.........
TString effKind =effDataKindString(sfKindLongStr);
TString dataKind=effKind;
TMatrixD *sf=NULL, *sf1ErrLo=NULL, *sf1ErrHi=NULL;
TMatrixD *systRelErr=NULL, sf2ErrLo(nEtBins,nEtaBins), sf2ErrHi(nEtBins,nEtaBins);
TMatrixD *systRelErrTot=NULL, sf3ErrLo(nEtBins,nEtaBins), sf3ErrHi(nEtBins,nEtaBins);
// load the scale factors
if (!loadEGammaEff(fname,"sf",&sf,&sf1ErrLo,&sf1ErrHi)) {
std::cout << "failed to load EGammaSf\n";
return;
}
HERE("load egamma ok");
systRelErr=loadMatrix(fname,"sf_syst_rel_error_egamma",nEtBins,nEtaBins,1);
if (!systRelErr) return;
systRelErrTot=loadMatrix(fname,"sf_syst_rel_error",nEtBins,nEtaBins,1);
if (!systRelErrTot) return;
HERE("add errors");
addInQuadrature(*sf,*sf1ErrLo, *systRelErr, sf2ErrLo);
addInQuadrature(*sf,*sf1ErrHi, *systRelErr, sf2ErrHi);
addInQuadrature(*sf,*sf1ErrLo, *systRelErrTot, sf3ErrLo);
addInQuadrature(*sf,*sf1ErrHi, *systRelErrTot, sf3ErrHi);
HERE("create graphs");
TGraphAsymmErrors* gr1=getAsymGraph(vsEt, etBinSet,etaBinSet,iBin,*sf,*sf1ErrLo,*sf1ErrHi);
gr1->GetXaxis()->SetMoreLogLabels();
gr1->GetXaxis()->SetNoExponent();
gr1->Print("range");
TGraphAsymmErrors* gr2=getAsymGraph(vsEt, etBinSet,etaBinSet,iBin,*sf,sf2ErrLo,sf2ErrHi);
gr2->GetXaxis()->SetMoreLogLabels();
gr2->GetXaxis()->SetNoExponent();
gr2->Print("range");
TGraphAsymmErrors* gr3=getAsymGraph(vsEt, etBinSet,etaBinSet,iBin,*sf,sf3ErrLo,sf3ErrHi);
gr3->GetXaxis()->SetMoreLogLabels();
gr3->GetXaxis()->SetNoExponent();
gr3->Print("range");
double *loc_etBinLimits=DYTools::getEtBinLimits(etBinSet);
double *loc_etaBinLimits=DYTools::getEtaBinLimits(etaBinSet);
int signedEta=DYTools::signedEtaBinning(etaBinSet);
TString binStrForTitle=(vsEt) ? TString(Form(" %5.3lf #leq %s #leq %5.3lf",loc_etaBinLimits[iBin],(signedEta)?"#eta":"abs(#eta)",loc_etaBinLimits[iBin+1])) :
TString(Form(" %2.0lf #leq #it{E}_{T} #leq %2.0lf GeV",loc_etBinLimits[iBin],loc_etBinLimits[iBin+1]));
TString cpTitle=dataKind+ binStrForTitle;
TString xAxisTitle="#it{E}_{T} [GeV]";
if (!vsEt) xAxisTitle=(signedEta) ? "#eta" : "|#eta|";
ComparisonPlot_t cp(ComparisonPlot_t::_ratioPlain,"comp",cpTitle,
xAxisTitle,effKind + TString(" scale factor"),"ratio");
cp.SetRefIdx(-111); // no ratio plot
if (vsEt) cp.SetLogx();
cp.AddLine(10.,1.,500.,1.,kBlack,2);
TCanvas *cx=new TCanvas("cx","cx",600,600);
SetSideSpaces(cx,0.05,0.,0.,0.02);
gr1->GetYaxis()->SetTitleOffset(1.4);
//cp.AddGraph(gr3,label3,"LPE",43); //kRed+3);
cp.AddGraph(gr3,label3,"LPE",kRed); //kRed+3);
cp.AddGraph(gr2,label2,"LPE",38); //kBlue+2);
cp.AddGraph(gr1,label1," PE",kBlack,20); //24
cp.Draw(cx,0,"png",0);
cp.TransLegend(transLegendX, transLegendY);
cp.WidenLegend(0.25,0.);
cx->Update();
// Save file
if (saveFileTag.Length()) {
TString outfname=TString("fig-sf-egamma-") + cpTitle;
outfname.ReplaceAll(" #leq "," ");
outfname.ReplaceAll(" ","_");
outfname.ReplaceAll("(#eta)","Eta");
outfname.ReplaceAll("#eta","eta");
outfname.ReplaceAll(".","_");
outfname.ReplaceAll("#it{E}_{T}","Et");
//fname.Append(".png");
std::cout << "outfname=" << outfname << "\n";
TString locOutDir=TString("plots") + saveFileTag;
if (doSave) {
locOutDir.ReplaceAll("--","");
SaveCanvas(cx,outfname,locOutDir);
}
else {
std::cout << "... canvas not saved, as requested\n";
std::cout << " locOutDir=" << locOutDir << "\n";
}
}
return ;
}
示例14: mv
static int mv(const std::string& src, const std::string& dest)
{
cp(src, dest);
return remove(src.c_str());
}
示例15: VALIDATE_ARG_COUNT
//.........这里部分代码省略.........
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument=0;
r_error.expected=Variant::DICTIONARY;
r_ret=RTR("Not based on a script");
return;
}
GDScript *p = base.ptr();
Vector<StringName> sname;
while(p->_owner) {
sname.push_back(p->name);
p=p->_owner;
}
sname.invert();
if (!p->path.is_resource_file()) {
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument=0;
r_error.expected=Variant::DICTIONARY;
r_ret=Variant();
r_ret=RTR("Not based on a resource file");
return;
}
NodePath cp(sname,Vector<StringName>(),false);
Dictionary d;
d["@subpath"]=cp;
d["@path"]=p->path;
p = base.ptr();
while(p) {
for(Set<StringName>::Element *E=p->members.front();E;E=E->next()) {
Variant value;
if (ins->get(E->get(),value)) {
String k = E->get();
if (!d.has(k)) {
d[k]=value;
}
}
}
p=p->_base;
}
r_ret=d;
}
}
} break;
case DICT2INST: {