int main() { lcd_init(); init_push_buttons(); shaft_encoder_init(); stepper_init(); while (1) { char prog; lcd_clear(); prog = wait_button("Choose program:"); switch (prog) { case 1: part1(); break; case 2: part2(); break; case 3: part3(); break; default: ; // do nothing } } }
vec LWRRegressor::fitAtPosition(vec pos) { int sampleSize = sampleXs.size(); int basisFunctionCount = designMatrices.at(0).n_cols; double normVal = computeKernelNormValue(); mat part1(basisFunctionCount, basisFunctionCount); vec part2(basisFunctionCount); part1.zeros(); part2.zeros(); for(int i = 0; i < sampleSize; ++i) { vec currentItem = sampleXs.at(i); vec currentfity = sampleTs.at(i); int samplePointCount = sampleTs.at(i).size(); mat currentDesMat = designMatrices.at(i); double kernelVal = kernel->evaluateKernel(pos, currentItem, &normVal); part1 += (kernelVal * currentDesMat.t() * currentDesMat); part2 += (kernelVal * currentDesMat.t() * currentfity); } vec res = solve(part1, part2); return res; }
RandIter _MergeSort(RandIter first, RandIter mid, RandIter last, SortPred pred) { if (first < mid) { // At least two elements // Divide and conquer _MergeSort(first, first + (mid - first) / 2, mid, pred); _MergeSort(mid, mid + (last - mid) / 2, last, pred); // Merge using ValueT = typename std::iterator_traits<RandIter>::value_type; std::vector<ValueT> part1(first, mid); std::vector<ValueT> part2(mid, last); std::merge(part1.begin(), part1.end(), part2.begin(), part2.end(), first, pred); #ifndef NDEBUG std::cout << "[ "; PrintSeq(first, mid, false); std::cout << "]" << " + [ "; PrintSeq(mid, last, false); std::cout << "] --> [ "; PrintSeq(first, last, false); std::cout << "]\n"; #endif } return first; }
void PAN::rotate(Mat image){ //namedWindow("", WINDOW_NORMAL); //imshow("", image); //waitKey(); //namedWindow("", WINDOW_NORMAL); //imshow("", *panimage.img); //waitKey(); cvtColor(image,image, CV_BGR2GRAY); Mat part1(image, Rect(Point((image.cols / 2) - 5, image.rows), Point(image.cols / 2, image.rows))); Mat part2(image, Rect(Point(image.cols - 5, 0), Point(image.cols, image.rows))); adaptiveThreshold(part1, part1, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY,3, 11); adaptiveThreshold(part1, part1, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 3, 11); PAN::Image temp1(&part1, 0, part1.cols, 0, part1.rows, Point(0, 0)); PAN::Image temp2(&part2, 0, part2.cols, 0, part2.rows, Point(0, 0)); cout << "here"; namedWindow("o", WINDOW_NORMAL); imshow("o", *temp1.img); waitKey(); imshow("o", *temp2.img); waitKey(); }
int main() { Company NetEase("NetEasy"); Department part1("在线游戏事业部"); Department part2("盘古游戏部"); Department part3("雷火游戏部"); Department part4("大话&梦幻游戏部"); Company littleCompany("美术子公司"); Department part5("人物原画部"); Department part6("背景原画部"); Department part7("武器原画部"); NetEase.addDepartment(&part1); NetEase.addDepartment(&part2); NetEase.addDepartment(&part3); NetEase.addDepartment(&part4); NetEase.addDepartment(&littleCompany); littleCompany.addDepartment(&part5); littleCompany.addDepartment(&part6); littleCompany.addDepartment(&part7); NetEase.getDescription(std::string("")); NetEase.removeDepartment(&part3); NetEase.removeDepartment(&part4); NetEase.getDescription(std::string("")); return 0; }
//----------------------------------------------------------------------- // note : input must not contain cutting segment void Triangulator::triangulatePolygon(const std::vector<int>& input, const DelaunaySegment& seg, DelaunayTriangleBuffer& tbuffer, const PointList& pointList) { // Find a point which, when associated with seg.i1 and seg.i2, builds a Delaunay triangle std::vector<int>::const_iterator currentPoint = input.begin(); bool found = true; while (!found) { Circle c(pointList[*currentPoint], pointList[seg.i1], pointList[seg.i2]); for (std::vector<int>::const_iterator it = input.begin();it!=input.end();it++) { if (c.isPointInside(pointList[*it]) ) { currentPoint = it; break; } } found = true; } // Insert current triangle Triangle t(&pointList, tbuffer.end()); t.setVertices(*currentPoint, seg.i1, seg.i2); tbuffer.push_back(t); // Recurse std::vector<int> part1(input.begin(), currentPoint-1); if (!part1.empty()) triangulatePolygon(part1, seg, tbuffer, pointList); std::vector<int> part2(currentPoint+1, input.end()); if (!part2.empty()) triangulatePolygon(part2, seg, tbuffer, pointList); }
void Scheduler::addInteractionEvent(const Particle& part, const size_t& id) const { if (part.getID() == id) return; Particle& part1(Sim->particles[part.getID()]); Particle& part2(Sim->particles[id]); Sim->dynamics->updateParticle(part2); sorter->push(Sim->getEvent(part1, part2)); }
int main(int argc, char * argv[]) { if (argc != 2) { std::cout << "Usage: " << argv[0] << " <filename>\n"; return 1; } part1(argv[1]); part2(argv[1]); return 0; }
void print_help(void) { ft_puterror("Usage: ./ft_ls [-lRartTdpuUc] [file ...]\n"); ft_puterror("List information about the FILEs\n"); ft_puterror("(the current directory by default).\n"); ft_puterror("Sort entries alphabetically if -t is not specified.\n\n"); part1(); bonus(); exit(EXIT_SUCCESS); }
int main() { part0(); part1(); part2(); part3(); part4(); part5(); part6(); }
int ft_resolve_path(char *buf) { size_t ilen; ilen = ft_strlen(buf); part1(buf); part2(buf); if (ilen != ft_strlen(buf)) return (1); return (0); }
void CreateRshell (void) { CString root = GetGlobal("Root"); CString config = GetGlobal("CustomizationList"); CString destPath = root + "\\Configs\\" + config + "\\Rshell"; CWnd Mywnd; // Mywnd.MessageBox(CString(iniFilePath),iniFilePath,MB_OK); // Mywnd.MessageBox(CString(customizationPath),customizationPath,MB_OK); ifstream part1("part1.ini"); ifstream part2("part2.ini"); _mkdir (destPath); CString Rsh = destPath + "\\" +"rshell.ini"; // FILE* rshell = theApp.OpenAFile(CDdir +"rshell.ini", "w"); ofstream rshell(Rsh); CString fvalue1=GetGlobal("ShellTitleText"); CString fvalue2=GetGlobal("ShellBgBitmap"); // char *fvalue3=GetGlobal("dialog_title_text"); CString fvalue4=GetGlobal("ShellInstallTextFile"); char jsprefname[200]; if(!part1) { cout << "cannot open the file \n"; } while (!part1.eof()) { part1.getline(jsprefname,200); // fprintf(globs, jsprefname); // fprintf(globs, "\n"); rshell <<jsprefname<<"\n"; } rshell <<"caption="<<fvalue1<<"\n"; rshell <<"bk_bitmap="<<fvalue2<<"\n"; rshell <<"button2_cmdline="<<fvalue4<<"\n"; // rshell <<"dialog_title_txt="<<fvalue3<<"\n"; if(!part2) { cout << "cannot open the file \n"; } while (!part2.eof()) { part2.getline(jsprefname,200); rshell <<jsprefname<<"\n"; } rshell.close(); }
ListNode* mergeKLists(vector<ListNode*>& lists) { if (lists.empty()) return NULL; if (lists.size() == 1) return lists[0]; if (lists.size() == 2) return merge(lists[0], lists[1]); vector<ListNode*>part1(lists.begin(), lists.begin() + lists.size() / 2); vector<ListNode*>part2(lists.begin() + lists.size() / 2, lists.end()); ListNode* l1 = mergeKLists(part1); ListNode* l2 = mergeKLists(part2); return merge(l1, l2); }
/** * Break edge into several straight line * */ void Edge::breakEdge() { cv::Point p0; // = contours[0]; cv::Point pend; // = contours[contours.size() - 1]; if (listOfPoints.size() > 0) { p0 = listOfPoints.at(0); pend = listOfPoints.at(listOfPoints.size() - 1); if (listOfPoints.size() > 2) { Line line(p0, pend); double distance = 0; double maxDistance = 0; // ?????????????????? double imax = 0; for (size_t i = 1; i < listOfPoints.size()-1; i++) { cv::Point pointi = listOfPoints.at(i); distance = abs(line.perpendicularDistance(pointi)); if (distance > maxDistance) { maxDistance = distance; imax = i; } } if (maxDistance > 3) { vector<cv::Point> part1(this->listOfPoints.begin(), this->listOfPoints.begin() + imax + 1); vector<cv::Point> part2(this->listOfPoints.begin() + imax, this->listOfPoints.end()); Edge edge1(part1); Edge edge2(part2); edge1.breakEdge(); edge2.breakEdge(); } } if (!checkPointInList(p0)) breakPoints.push_back(p0); if (!checkPointInList(pend)) breakPoints.push_back(pend); } else { return; } }
void CEnvGen::createUpdateNodeTask(const char* action, IPropertyTree * config, const char* param) { StringBuffer sbParam; StringArray parts; parts.appendList(param, ":"); String part1(parts.item(0)); if (part1.startsWith("spark")) { sbParam.clear().append("pg:buildset#sparkthor"); createUpdateTask(action, config, sbParam.str()); } if (part1.startsWith("thor")) { for ( unsigned i = 1; i < parts.ordinality() ; i++) { sbParam.clear().append("sw:"); StringBuffer sbPart1(part1.str()); sbPart1.append(":instance-").appendf("%s",parts.item(i)); sbParam.appendf("%s", sbPart1.str()); createUpdateTask(action, config, sbParam.str()); } } else { if (part1.startsWith("computer")) sbParam.append("hd:").appendf("%s", part1.str()); else { sbParam.clear().append("sw:"); StringBuffer sbPart1(part1.str()); sbPart1.replaceString("@", ":instance@"); sbParam.appendf("%s", sbPart1.str()); } createUpdateTask(action, config, sbParam.str()); } }
main(int argc,char *argv[]) { int endcnt=0; FILE *f1; unsigned u; int a,b,c,d,e,x,y,x2,y2,y1; dis_partstart(); { _asm mov ax,13h _asm int 10h } waitb(); memset(vram0,15,64000); while(dis_muscode(1)!=1 && !dis_exit()); waitb(); waitb(); waitb(); waitb(); for(x=319;x>=0;x--) { vram0[x+100*320]=0; if(!(x&15)) waitb(); } y1=100; a=100*64; b=0; while(y1<200) { b+=16; a+=b; y2=a/64; if(y2>200) y2=200; for(y=y1;y<y2;y++) { memset(vram0+y*320,0,320); } y1=y2; waitb(); } for(a=0;a<70 && !dis_exit();a++) dis_waitb(); memset(defpal,0,768); loadpal(defpal,768); outp(0x3c0,0x11+0x20); outp(0x3c0,255); memset(vram0+0*320,255,35*320); memset(vram0+35*320,254,1*320); memset(vram0+36*320,0,128*320); memset(vram0+164*320,254,1*320); memset(vram0+165*320,255,35*320); defpal[0*3+0]=0; defpal[0*3+1]=0; defpal[0*3+2]=20; defpal[254*3+0]=45; defpal[254*3+1]=45; defpal[254*3+2]=45; defpal[255*3+0]=0; defpal[255*3+1]=0; defpal[255*3+2]=0; loadpal(defpal,768); for(a=0;a<200;a++) rows[a]=a*320; background=halloc(16384L,4L); memset(background,0,64000); dotspnt=dots1; if(argc==2) { switch(*argv[1]) { case '1' : dotspnt=dots4; break; case '2' : mode=5; break; case '3' : mode=6; break; } for(a=0;a<256;a++) vram0[a]=vram0[a+320]=a; border=1; } x=y=c=0; for(a=0;a<256;a++) vram0[a]=vram0[a+320]=255; border=0; while(!dis_exit() && mode!=-1) { count++; setborder(255); waitb(); if(mode==4 && count>0) loadpal(pal,768); if(mode==5 && count>500-17) loadpal(pal,768-6); if(mode==6 && count>0 && count<20) loadpal(pal,768-6); setborder(0); if(mode<4) dodots(background,vram); else if(mode==4) dodots2(background,vram); switch(mode) { case 0: if(count>32) { NEXTMODE; } break; case 1: if(!count) { x=0; part1init(); } else part1(); break; case 2: { NEXTMODE; if(dotspnt==dots1) { mode=1; dotspnt=dots2; } else if(dotspnt==dots2) { mode=1; dotspnt=dots3; } else if(dotspnt==dots3) { mode=1; dotspnt=dots4; } else for(a=0;a<2048;a++) adddot(0,0,0,0,0); } break; case 3: if(count>40) NEXTMODE; break; case 4: if(count>400) { NEXTMODE; } if(!count) { pal1colp=1; memset(background,0,64000); for(dotsp=a=0;a<2048;a++) { dotsp+=4; switch(dotspnt[dotsp]) { case 1 : case 2 : case 3 : doit2(dotspnt[dotsp+2],dotspnt[dotsp+3],254); break; default : dotsp=0; break; } } for(a=3;a<32*3;a+=3) { pal[a+0]=0; pal[a+1]=0; pal[a+2]=20; } } a=252-pal1colp; d=a+66; if(d>254) d=254; c=63; for(;a<d;a++,c-=4) { if(c<0) c=0; b=c*c/64; pal[a*3+0]=b; pal[a*3+1]=b; pal[a*3+2]=b<20?20:b; } a=(254-65); pal[a*3+0]=63; pal[a*3+1]=63; pal[a*3+2]=63; pal[1*3+0]=63; pal[1*3+1]=63; pal[1*3+2]=63; pal1colp++; if(count>100) { for(a=0;a<2048;a++) adddot(0,0,0,0,0); NEXTMODE; } break; case 5: if(!count) { for(u=0;u<128*320;u++) { if(vram[u]==254-65) vram[u]=1; else vram[u]=0; } part2init(); } else part2(); break; case 6: if(!count) { part3init(); } else part3(); break; case 7: NEXTMODE; if(count>100) { NEXTMODE; } break; default : mode=-1; break; } } if(!dis_indemo()) { _asm mov ax,3h _asm int 10h }
IddUnitString::IddUnitString (const std::string &s) : m_original(s), m_converted(s) { // remove differentiation between kg-H2O and kg-Air (will be kg/kg). // better to add kg-H2O and kg-air as separate SI base units? m_converted = boost::regex_replace(m_converted,boost::regex("-H2O"),""); m_converted = boost::regex_replace(m_converted,boost::regex("-[aA]ir"),""); m_converted = boost::regex_replace(m_converted,boost::regex("Water"),""); m_converted = boost::regex_replace(m_converted,boost::regex("DryAir"),""); // basic replacements m_converted = boost::regex_replace(m_converted,boost::regex("-"),"*"); if (!boost::regex_search(m_converted,boost::regex("H2O"))) { m_converted = boost::regex_replace(m_converted,boost::regex("([2-9]+)"),"^\\1"); } else { m_converted = boost::regex_replace(m_converted,boost::regex("H2O"),"H_{2}O"); } m_converted = boost::regex_replace(m_converted,boost::regex("deltaC"),"K"); m_converted = boost::regex_replace(m_converted,boost::regex("minutes"),"min"); m_converted = boost::regex_replace(m_converted,boost::regex("dimensionless"),""); m_converted = boost::regex_replace(m_converted,boost::regex("Person"),"person"); m_converted = boost::regex_replace(m_converted,boost::regex("Rotations Per Minute"),"rpm"); m_converted = boost::regex_replace(m_converted,boost::regex("ohms"),"ohm"); m_converted = boost::regex_replace(m_converted,boost::regex("VA"),"V*A"); m_converted = boost::regex_replace(m_converted,boost::regex("deltaJ"),"J"); m_converted = boost::regex_replace(m_converted,boost::regex("rev"),"cycle"); m_converted = boost::regex_replace(m_converted,boost::regex("Ah"),"A*h"); // relative temperatures if (!boost::regex_match(m_converted,boost::regex("C|F"))) { m_converted = boost::regex_replace(m_converted,boost::regex("C"),"K"); m_converted = boost::regex_replace(m_converted,boost::regex("F"),"R"); } // Multiple /'s boost::smatch matches; if (boost::regex_match(m_converted,matches,boost::regex("(.*)/\\((.*)/(.*)\\)"))) { std::string part1(matches[1].first, matches[1].second); std::string part2(matches[2].first, matches[2].second); std::string part3(matches[3].first, matches[3].second); m_converted = part1 + "*" + part3 + "/" + part2; } if (boost::regex_match(m_converted,matches,boost::regex("\\((.*)/(.*)\\)/(.*)"))) { std::string part1(matches[1].first, matches[1].second); std::string part2(matches[2].first, matches[2].second); std::string part3(matches[3].first, matches[3].second); m_converted = part1 + "/" + part2 + "*" + part3; } if ((!m_converted.empty()) && boost::regex_search(m_converted,boost::regex("g"))) { Unit temp = parseUnitString(m_converted); // g -> m(kg) int gExp = temp.baseUnitExponent("g"); if (gExp != 0) { temp.setBaseUnitExponent("g",0); temp.setBaseUnitExponent("kg",gExp); bool ok = temp.setScale(-3 * gExp); if (ok) { m_converted = temp.standardString(); } } } if ((!m_converted.empty()) && boost::regex_search(m_converted,boost::regex("micron"))) { Unit temp = parseUnitString(m_converted); int gExp = temp.baseUnitExponent("micron"); if (gExp != 0) { temp.setBaseUnitExponent("micron",0); temp.setBaseUnitExponent("m",gExp); bool ok = temp.setScale(-6 * gExp); if (ok) { m_converted = temp.standardString(); } } } }
void SwitchboardServerConnection::sendInk(std::string image) { this->assertConnectionStateIsAtLeast(SB_READY); if(users.size() == 1) { p2p.sendInk(*this, image); // return; } std::string body("base64:"+image); bool one_packet = false; if(body.size() <= 1202) // if we need more than 1 packet, then use multipacket one_packet = true ; if(one_packet) { std::ostringstream buf_, msg_; msg_ << "MIME-Version: 1.0\r\n"; msg_ << "Content-Type: image/gif\r\n\r\n"; msg_ << body; size_t msg_length = msg_.str().size(); buf_ << "MSG " << this->trID++ << " N " << (int) msg_length << "\r\n" << msg_.str(); write(buf_); return; } else { std::istringstream body_stream(body); std::string messageid = new_branch(); std::vector<std::string> chunks; // spliting the message while(!body_stream.eof()) { char *part = new char[1203]; memset(part,0,1203); body_stream.read((char*)part, 1202); std::string part1(part); chunks.push_back(part1); delete [] part; } // sending the first one std::ostringstream buf_, msg_; msg_ << "MIME-Version: 1.0\r\n"; msg_ << "Content-Type: image/gif\r\n"; msg_ << "Message-ID: " << messageid << "\r\n"; msg_ << "Chunks: " << chunks.size() << "\r\n\r\n"; msg_ << chunks.front(); size_t msg_length = msg_.str().size(); buf_ << "MSG " << this->trID++ << " N " << (int) msg_length << "\r\n" << msg_.str(); write(buf_); std::vector<std::string>::iterator i = chunks.begin(); for(int num=0; i!=chunks.end(); i++, num++) { if(i == chunks.begin()) continue; std::ostringstream buf2_, msg2_; msg2_ << "Message-ID: " << messageid << "\r\n"; msg2_ << "Chunk: " << num << "\r\n\r\n"; msg2_ << (*i); size_t msg_length2 = msg2_.str().size(); buf2_ << "MSG " << this->trID++ << " N " << (int) msg_length2 << "\r\n" << msg2_.str(); write(buf2_); } } }
void MultiSolidAsciiStlReader::operate() { QFileInfo file_info(GuiMainWindow::pointer()->getFilename()); readInputFileName(file_info.completeBaseName() + ".stl"); if (isValid()) { double tol = QInputDialog::getText(NULL, "enter STL tolerance", "tolerance", QLineEdit::Normal, "1e-10").toDouble(); QList<QString> buffer; QList<QString> bc_name; { QFile file(getFileName()); if (!file.open(QFile::ReadOnly)) { EG_ERR_RETURN("unable to open file"); } QTextStream f(&file); QString buf = ""; QString name = "unknown"; while (!f.atEnd()) { QString line = f.readLine(); buf += line + "\n"; // endline?? if (line.left(8) == "endsolid") { buffer.append(buf); buf = ""; bc_name.append(name); } else if (line.left(5) == "solid") { name = line.right(line.size() - 6); } } } bool first = true; int last_bc = 1; foreach (QString buf, buffer) { QString file_name = getFileName() + ".tmp"; { QFile file(file_name); if (!file.open(QFile::WriteOnly)) { EG_ERR_RETURN("unable to open file\"" + file_name + "\" for writing"); } QTextStream f(&file); f << buf << endl; } StlReader stl; stl.setTolerance(tol); stl.setFileName(file_name); EG_VTKSP(vtkUnstructuredGrid, grid); stl.setGrid(grid); stl.setMaximalCleaningIterations(3); stl(); // @todo set boundary names EG_VTKDCC(vtkIntArray, bc, grid, "cell_code"); for (vtkIdType id_cell = 0; id_cell < grid->GetNumberOfCells(); ++id_cell) { bc->SetValue(id_cell, last_bc); } ++last_bc; if (first) { first = false; makeCopy(grid, m_Grid); } else { MeshPartition part1(m_Grid, true); MeshPartition part2(grid, true); part1.addPartition(part2); } } last_bc = 1; GuiMainWindow::pointer()->resetXmlDoc(); GuiMainWindow::pointer()->clearBCs(); foreach (QString name, bc_name) { GuiMainWindow::pointer()->addBC(last_bc, BoundaryCondition(name, "patch")); ++last_bc; }
// this is the real one void AtmosphericDrag::doCompute(UTCTime utc, EarthBody& rb, Spacecraft& sc) { // To consist with STK double omega_e = 7.292115E-05; // IERS 1996 conventions //double omega_e = rb.getSpinRate(utc); Vector<double> r = sc.R(); // satellite position in m Vector<double> v = sc.V(); // satellite velocity in m/s const double cd = sc.getDragCoeff(); const double area = sc.getDragArea(); const double mass = sc.getDryMass(); double rmag = norm(r); double beta = cd * area / mass; // [m^2/kg] // compute the atmospheric density double rho = computeDensity(utc, rb, r, v); // [kg/m^3] // debuging... //rho = 6.3097802844338E-12; // compute the relative velocity vector and magnitude Vector<double> we(3,0.0); we(2)= omega_e; Vector<double> wxr = cross(we,r); Vector<double> vr = v - wxr; double vrmag = norm(vr); // form -1/2 (Cd*A/m) rho double coeff = -0.5 * beta * rho; double coeff2 = coeff * vrmag; // compute the acceleration in ECI frame (km/s^2) a = vr * coeff2; ///////// a // Partial reference: Montenbruck,P248 // form partial of drag wrt v // da_dv = -0.5*Cd*(A/M)*p*(vr*transpose(vr)/vr+vr1) Matrix<double> tr(3,1,0.0); tr(0,0)=vr(0); tr(1,0)=vr(1); tr(2,0)=vr(2); Matrix<double> vrvrt = tr*transpose(tr); vrvrt = vrvrt / vrmag; double eye3[3*3] = {1,0,0,0,1,0,0,0,1}; Matrix<double> vrm(3,3,0.0); vrm = eye3; vrm = vrm * vrmag; da_dv = (vrvrt + vrm) * coeff; //////// da_dv // da_dr // da_dr = -0.5*Cd*(A/M)*vr*dp_dr-da_dv*X(w) da_dr.resize(3,3,0.0); Matrix<double> X(3,3,0.0); X(0,1) = -we(2); // -wz X(0,2) = +we(1); // wy X(1,0) = +we(2); // +wz X(1,2) = -we(0); // -wx X(2,0) = -we(1); // -wy X(2,1) = +we(0); // +wx Matrix<double> part1(3,3,0.0); Matrix<double> part2(3,3,0.0); // Get the J2000 to TOD transformation Matrix<double> N = ReferenceFrames::J2kToTODMatrix(utc); // Transform r from J2000 to TOD Vector<double> r_tod = N * r; Position geoidPos(r_tod(0),r_tod(1),r_tod(3)); // Satellite height double height = geoidPos.getAltitude()/1000.0; // convert to [km] const int n = CIRA_SIZE; ; int bracket = 0; if (height >= h0[n-1]) { bracket = n - 1; } else { for (int i = 0; i < (n-1); i++) { if ((height >= h0[i]) && (height < h0[i+1])) { bracket = i; } } } // End 'if (height >= h0[n-1]) ' double Hh = H[bracket]; double coeff4 = -1.0 / (Hh * rmag); Vector<double> drhodr = r*coeff4; Matrix<double> tr2(3,1,0.0); tr2(0,0) = drhodr(0); tr2(1,0) = drhodr(1); tr2(2,0) = drhodr(2); part1 = tr*transpose(tr2); // //Matrix part1 = vr.outerProduct(drhodr); part1 = part1*coeff2; //part1 = dp_dr*a/rho; part2 =-da_dv*X; da_dr = part1-part2; // form partial of drag wrt cd double coeff3 = coeff2 / cd; this->dadcd = vr*coeff3; //////// da_dcd this->da_dcd(0,0) = dadcd(0); this->da_dcd(1,0) = dadcd(1); this->da_dcd(2,0) = dadcd(2); } // End of method 'AtmosphericDrag::doCompute()'
void main( ) { part1( ); //call the function responsible for part 1 part3( ); //call the functions for part 2 and 3 of the project getchar( ); }
/// combine both path parts and return new path static Path Combine(const CString& cszPart1, const CString& cszPart2) throw() { Path part1(cszPart1); return part1.Combine(cszPart2); }
// // Scans (parses) input external-format schema name. // // This method assumes that the parameter externalSchemaName only // contains the external-format schema name. The syntax of an // schema name is // // [ <catalog-name-part> ] . <schema-name-part> // // A schema name part must be specified; the catalog name part is optional. // // The method returns the number of bytes scanned via the parameter // bytesScanned. If the scanned schema name is illegal, bytesScanned // contains the number of bytes examined when the name is determined // to be invalid. // // If the specified external-format schema name is valid, this method // returns TRUE and saves the parsed ANSI SQL name part into data // members catalogNamePart_ and schemaNamePart_; otherwise, it returns // FALSE and does not changes the contents of the data members. // NABoolean ComSchemaName::scan(const NAString &externalSchemaName, size_t &bytesScanned) { size_t count; size_t externalSchemaNameLen = externalSchemaName.length(); bytesScanned = 0; #define COPY_VALIDATED_STRING(x) \ ComAnsiNamePart(x, ComAnsiNamePart::INTERNAL_FORMAT) if (( SqlParser_Initialized() && SqlParser_NAMETYPE == DF_NSK) || (!SqlParser_Initialized() && *externalSchemaName.data() == '\\')) { ComMPLoc loc(externalSchemaName); switch (loc.getFormat()) { case ComMPLoc::SUBVOL: catalogNamePart_ = COPY_VALIDATED_STRING(loc.getSysDotVol()); schemaNamePart_ = COPY_VALIDATED_STRING(loc.getSubvolName()); bytesScanned = externalSchemaNameLen; return TRUE; case ComMPLoc::FILE: if (!loc.hasSubvolName()) { catalogNamePart_ = ""; schemaNamePart_ = COPY_VALIDATED_STRING(loc.getFileName()); bytesScanned = externalSchemaNameLen; return TRUE; } } } // Each ComAnsiNamePart ctor below must be preceded by "count = 0;" // -- see ComAnsiNamePart.cpp, and for a better scan implementation, // see ComObjectName::scan() + ComObjectName(bytesScanned) ctor. // --------------------------------------------------------------------- // Scan the leftmost ANSI SQL name part. // --------------------------------------------------------------------- count = 0; ComAnsiNamePart part1(externalSchemaName, count); bytesScanned += count; if (NOT part1.isValid()) return FALSE; if (bytesScanned >= externalSchemaNameLen) { ComASSERT(bytesScanned == externalSchemaNameLen); schemaNamePart_ = part1; return TRUE; // "sch" } // Get past the period separator if (NOT ComSqlText.isPeriod(externalSchemaName[bytesScanned++])) return FALSE; // --------------------------------------------------------------------- // Scan the last ANSI SQL name part // --------------------------------------------------------------------- #pragma nowarn(1506) // warning elimination Int32 remainingLen = externalSchemaNameLen - bytesScanned; #pragma warn(1506) // warning elimination NAString remainingName = externalSchemaName(bytesScanned, remainingLen); count = 0; ComAnsiNamePart part2(remainingName, count); bytesScanned += count; if (NOT part2.isValid()) return FALSE; if (bytesScanned == externalSchemaNameLen) { catalogNamePart_ = part1; schemaNamePart_ = part2; return TRUE; // "cat.sch" } // The specified external-format object name contains some extra // trailing characters -- illegal. // return FALSE; } // ComSchemaName::scan()
int main(int argc, char **argv) { // CHECK: in esan::initializeLibrary // CHECK: in esan::initializeCacheFrag // CHECK-NEXT: in esan::processCompilationUnitInit // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit: {{.*}}struct-simple.cpp with 6 class(es)/struct(s) // CHECK-NEXT: Register struct.A#2#11#11: 2 fields // CHECK-NEXT: Register struct.B#2#3#2: 2 fields // CHECK-NEXT: Register union.U#1#3: 1 fields // CHECK-NEXT: Register struct.S#2#11#11: 2 fields // CHECK-NEXT: Register struct.D#3#14#11#11: 3 fields // CHECK-NEXT: Register struct.anon#3#11#11#11: 3 fields // CHECK-NEXT: in esan::processCompilationUnitInit // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit: {{.*}}struct-simple.cpp with 0 class(es)/struct(s) // CHECK-NEXT: in esan::processCompilationUnitInit // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit: {{.*}}struct-simple.cpp with 5 class(es)/struct(s) // CHECK-NEXT: Register class.C#3#14#13#13: 3 fields // CHECK-NEXT: Register struct.anon#2#11#11: 2 fields // CHECK-NEXT: Register union.anon#1#3: 1 fields // CHECK-NEXT: Duplicated struct.S#2#11#11: 2 fields // CHECK-NEXT: Register struct.D#3#11#11#11: 3 fields struct C c[2]; struct S s; struct D d; c[0].cs.x = 0; c[1].cs.y = 1; c[0].cu.f = 0.0; c[1].cu.d = 1.0; c[0].c[2] = 0; s.s1 = 0; d.d1 = 0; d.d2 = 0; part1(); part2(); return 0; // CHECK: in esan::finalizeLibrary // CHECK-NEXT: in esan::finalizeCacheFrag // CHECK-NEXT: in esan::processCompilationUnitExit // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit: {{.*}}struct-simple.cpp with 5 class(es)/struct(s) // CHECK-NEXT: Unregister class.C#3#14#13#13: 3 fields // CHECK-NEXT: {{.*}} class C // CHECK-NEXT: {{.*}} size = 32, count = 5, ratio = 3, array access = 5 // CHECK-NEXT: {{.*}} # 0: offset = 0, size = 8, count = 2, type = %struct.anon = type { i32, i32 } // CHECK-NEXT: {{.*}} # 1: offset = 8, size = 8, count = 2, type = %union.anon = type { double } // CHECK-NEXT: {{.*}} # 2: offset = 16, size = 10, count = 1, type = [10 x i8] // CHECK-NEXT: Unregister struct.anon#2#11#11: 2 fields // CHECK-NEXT: {{.*}} struct anon // CHECK-NEXT: {{.*}} size = 8, count = 2, ratio = 1, array access = 0 // CHECK-NEXT: {{.*}} # 0: offset = 0, size = 4, count = 1, type = i32 // CHECK-NEXT: {{.*}} # 1: offset = 4, size = 4, count = 1, type = i32 // CHECK-NEXT: Unregister union.anon#1#3: 1 fields // CHECK-NEXT: Unregister struct.S#2#11#11: 2 fields // CHECK-NEXT: {{.*}} struct S // CHECK-NEXT: {{.*}} size = 8, count = 2, ratio = 2, array access = 0 // CHECK-NEXT: {{.*}} # 0: count = 2 // CHECK-NEXT: {{.*}} # 1: count = 0 // CHECK-NEXT: Unregister struct.D#3#11#11#11: 3 fields // CHECK-NEXT: {{.*}} struct D // CHECK-NEXT: {{.*}} size = 12, count = 2, ratio = 2, array access = 0 // CHECK-NEXT: {{.*}} # 0: offset = 0, size = 4, count = 1, type = i32 // CHECK-NEXT: {{.*}} # 1: offset = 4, size = 4, count = 1, type = i32 // CHECK-NEXT: {{.*}} # 2: offset = 8, size = 4, count = 0, type = i32 // CHECK-NEXT: in esan::processCompilationUnitExit // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit: {{.*}}struct-simple.cpp with 0 class(es)/struct(s) // CHECK-NEXT: in esan::processCompilationUnitExit // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit: {{.*}}struct-simple.cpp with 6 class(es)/struct(s) // CHECK-NEXT: Unregister struct.A#2#11#11: 2 fields // CHECK-NEXT: {{.*}} struct A // CHECK-NEXT: {{.*}} size = 8, count = 2049, ratio = 2048, array access = 0 // CHECK-NEXT: {{.*}} # 0: count = 2048 // CHECK-NEXT: {{.*}} # 1: count = 1 // CHECK-NEXT: Unregister struct.B#2#3#2: 2 fields // CHECK-NEXT: {{.*}} struct B // CHECK-NEXT: {{.*}} size = 16, count = 2097153, ratio = 2097152, array access = 0 // CHECK-NEXT: {{.*}} # 0: count = 1 // CHECK-NEXT: {{.*}} # 1: count = 2097152 // CHECK-NEXT: Unregister union.U#1#3: 1 fields // CHECK-NEXT: Duplicated struct.S#2#11#11: 2 fields // CHECK-NEXT: Unregister struct.D#3#14#11#11: 3 fields // CHECK-NEXT: {{.*}} struct D // CHECK-NEXT: {{.*}} size = 128, count = 2097153, ratio = 2097153, array access = 0 // CHECK-NEXT: {{.*}} # 0: count = 1 // CHECK-NEXT: {{.*}} # 1: count = 0 // CHECK-NEXT: {{.*}} # 2: count = 2097152 // CHECK-NEXT: Unregister struct.anon#3#11#11#11: 3 fields // CHECK-NEXT: {{.*}} struct anon // CHECK-NEXT: {{.*}} size = 12, count = 2097152, ratio = 4194304, array access = 2097152 // CHECK-NEXT: {{.*}} # 0: count = 0 // CHECK-NEXT: {{.*}} # 1: count = 2097152 // CHECK-NEXT: {{.*}} # 2: count = 0 // CHECK-NEXT: {{.*}}EfficiencySanitizer: total struct field access count = 6293518 }