void TestCellSpanInfo::TestConstruction() { ComparisonContext cContext; RTFFileContext context; RTFcell4TCSI cell(&context); cell.m_pCelldef = new RTFformatting(&context); cell.m_iMinColNum = 4; cell.m_pCelldef->SetRBound(1234); cell.m_bIsInVSpan = true; CellSpanInfo csi(&cell); assertTest(csi.m_iMinColumn == 4); assertTest(csi.m_iRBound == 1234); assertTest(csi.m_bIsInVSpan); cell.m_iMinColNum = 0; cell.m_pCelldef->SetRBound(-221); cell.m_bIsInVSpan = false; CellSpanInfo csi2(&cell); assertTest(csi2.m_iMinColumn == 0); assertTest(csi2.m_iRBound == -221); assertTest(!csi2.m_bIsInVSpan); }
bool MBUfactHandler::handleFormal(DFAfact& df, PExprDecl& dd, CFGfunction& parfn, bool interproc) { if(interproc){ //- interprocedural MBUfact& mf = (MBUfact&) df; if(flag_may_be_uninit < 3){ if(dd.getAO().dfa_relevant){ //- skip if not safe (optimize) suco_iterator<PExprCall *> csi(parfn.getCallSites()); while(csi.Iterate()){ PExprArg * arg = csi.Current()->getArg(dd.getArgNo()); if(arg){ //-- process "weak" assignment [dd.ao] = argaos if(mf.intersectsAliases(arg->getDesc().getAOs())){ mf.insertComponentAOs(dd.getAO()); } } else { //-- this arg not included in callsite: set to uninit!? // - note: may want to ignore -- assume PTA imprecision? mf.insertComponentAOs(dd.getAO()); } } return false; } else return true; //- useless } else return true; } else { //- if intraprocedural, treat as declaration return handleDecl(df, dd); } }
int Step::createCsi( QString const &addLine, QStringList const &csiParts, // the partially assembles model QPixmap *pixmap, Meta &meta) { qreal modelScale = meta.LPub.assem.modelScale.value(); int sn = stepNumber.number; // 1 color x y z a b c d e f g h i foo.dat // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 QStringList tokens; split(addLine,tokens); QString orient; if (tokens.size() == 15) { for (int i = 5; i < 14; i++) { orient += "_" + tokens[i]; } } QString key = QString("%1_%2_%3_%4_%5_%6") .arg(csiName()+orient) .arg(sn) .arg(meta.LPub.page.size.valuePixels(0)) .arg(resolution()) .arg(resolutionType() == DPI ? "DPI" : "DPCM") .arg(modelScale); QString fileName = QDir::currentPath() + "/" + Paths::assemDir + "/" + key + ".png"; QFile csi(fileName); bool outOfDate = false; if (csi.exists()) { QDateTime lastModified = QFileInfo(fileName).lastModified(); QStringList stack = submodelStack(); stack << parent->modelName(); if ( ! isOlder(stack,lastModified)) { outOfDate = true; } } if ( ! csi.exists() || outOfDate) { int rc; // render the partially assembled model rc = renderer->renderCsi(addLine,csiParts, fileName, meta); if (rc < 0) { return rc; } } pixmap->load(fileName); csiPlacement.size[0] = pixmap->width(); csiPlacement.size[1] = pixmap->height(); return 0; }
bool MBUc2factHandler::handleFormal(DFAfact& df, PExprDecl& dd, CFGfunction& parfn, bool interproc) { MBUfactHandler::handler.handleFormal(df, dd, parfn, interproc); if(((MBUfact&)df).contains(dd.getAO()) && this->results.hasKey(dd.getAO())){ this->results.addFact(dd.getAO(), &dd, 0, 0); suco_iterator<PExprCall *> csi(parfn.getCallSites()); while(csi.Iterate()){ PExprArg * arg = csi.Current()->getArg(dd.getArgNo()); if(arg) this->results.addFact(dd.getAO(), 0, 0, arg); } } return false; //- not useless }
bool RDAfactHandler::handleFormal(DFAfact& df, PExprDecl& dd, CFGfunction& parfn, bool interproc) { RDAfact& rf = (RDAfact&) df; if(dd.getAO().getTSC() >= AO::TSC_EXPOSED){ //- skip if not safe (optimize) rf.removeFacts(dd.getAO()); //- treat as strong assign rf.addFact(dd.getAO(), &dd, 0, 0); suco_iterator<PExprCall *> csi(parfn.getCallSites()); while(csi.Iterate()){ PExprArg * arg = csi.Current()->getArg(dd.getArgNo()); if(arg) rf.addFact(dd.getAO(), 0, 0, arg); } return false; //- not useless } else return true; //- useless }
void TestCellSpanInfo::TestUpdateCell() { ComparisonContext cContext; RTFFileContext context; RTFcell4TCSI cell(&context); cell.m_pCelldef = new RTFformatting(&context); cell.m_iMinColNum = 4; cell.m_pCelldef->SetRBound(1234); cell.m_bIsInVSpan = true; CellSpanInfo csi(&cell); csi.m_iMinColumn = 6; csi.m_iRBound = 9999; csi.UpdateCell(&cell); assertTest(cell.m_iMinColNum == 6); assertTest(cell.GetCellDef()->GetRBound() == 1234); }
forceinline ModEvent ComplementView<View>::intersect(Space& home, int i, int j) { Iter::Ranges::Singleton si(i,j); RangesCompl<Iter::Ranges::Singleton> csi(si); return me_negateset((x.includeI(home, csi))); }
/** * @brief Reverse the video. */ void CVue::ansiSGR(t_sgr sgr) { fprintf( io(), "%s%dm", csi(), (int)sgr ); }
/** * @brief Erase from the cursor position to the EOL. */ void CVue::ansiEIL(char mode) { fprintf( io(), "%s%cK", csi(), mode ); }
/** * @brief Move the screen cursor to the positiion */ void CVue::ansiCUP(int col, int row) { fprintf( io(), "%s%d;%dH", csi(), row+1, col+1 ); }
/** * @brief Move the screen cursor to the positiion */ void CVue::ansiCUP(CARIBOU::CPoint pos) { fprintf( io(), "%s%d;%dH", csi(), pos.y()+1, pos.x()+1 ); }
int sindexcombined(char *slopefile, char *scaterrainfile, char *scarminroadfile, char* scarmaxroadfile, char *tergridfile, char *terparfile, char *satfile, char* sincombinedfile, double Rminter, double Rmaxter, double *par) { MPI_Init(NULL,NULL);{ FILE *fp; int i, j, mter, err, filetype, index, rno, nx, ny; float ndva, ndvs; short *ndvter; int nor; double X1, X2, cellsat, dx, dy; float rs, rw, g; float tmin, tmax, cmin, cmax, tphimin, tphimax; const double PI = 3.14159265358979; struct calreg{ float tmin; float tmax; float cmin; float cmax; float tphimin; float tphimax; float r; } ; /* this could be malloced or should be checked to ensure fewer than 100 regions */ g=par[0]; rw=par[1]; nor = 0; struct calreg *region; char headers[MAXLN]; // find number of regions fp = fopen(terparfile, "r"); if (fp == NULL)return 15; // Pabitra (9/10/2015): the following code to count the number of lines // handles if the last line does not end with end of line character while ( fgets ( headers, sizeof headers, fp) != NULL) { nor++; } /*while (readline(fp,headers) != EOF) { nor++; }*/ (std::fclose)(fp); // number of regions is total lines in the file minus 1 (for the header text line) nor = nor - 1; region = (calreg*)calloc(nor, sizeof(calreg)); getRegionIndex(terparfile, nor); fp = fopen(terparfile, "r"); readline(fp,headers); // i = -1; DGT 12/31/14 Not needed index = 0; do { j = fscanf(fp,"%i,%f,%f,%f,%f,%f,%f,%f \n", &rno, &tmin, &tmax, &cmin, &cmax, &tphimin, &tphimax, &rs); region[index].tmin = tmin; region[index].tmax = tmax; region[index].cmin = cmin; region[index].cmax = cmax; region[index].tphimin =tphimin * PI/180 ; region[index].tphimax = tphimax * PI/180; region[index].r = rw/rs; index++; }while (index < nor); (std::fclose)(fp); //MPI_Init(NULL,NULL);{ int rank, size; MPI_Comm_rank(MCW, &rank); MPI_Comm_size(MCW, &size); if(rank == 0) printf("SinmapSI version %s\n", TDVERSION); double begin,end; //Begin timer begin = MPI_Wtime(); //Create tiff object, read and store header info tiffIO slp(slopefile, FLOAT_TYPE); long totalX = slp.getTotalX(); long totalY = slp.getTotalY(); dx = slp.getdxA(); dy = slp.getdyA(); tiffIO sca(scaterrainfile, FLOAT_TYPE); tiffIO *sca_min = NULL; if (*scarminroadfile != NULL) { sca_min = new tiffIO(scarminroadfile, FLOAT_TYPE); } tiffIO *sca_max = NULL; if (*scarmaxroadfile != NULL) { sca_max = new tiffIO(scarmaxroadfile, FLOAT_TYPE); } tiffIO cal(tergridfile, SHORT_TYPE); if(rank==0) { float timeestimate=(1e-7*totalX*totalY/pow((double) size,1))/60+1; // Time estimate in minutes fprintf(stderr,"This run may take on the order of %.0f minutes to complete.\n",timeestimate); fprintf(stderr,"This estimate is very approximate. \nRun time is highly uncertain as it depends on the complexity of the input data \nand speed and memory of the computer. This estimate is based on our testing on \na dual quad core Dell Xeon E5405 2.0GHz PC with 16GB RAM.\n"); fflush(stderr); } //Create partition and read data from slope file tdpartition *slpData; slpData = CreateNewPartition(slp.getDatatype(), totalX, totalY, dx, dy, slp.getNodata()); nx = slpData->getnx(); ny = slpData->getny(); ndvs = *(float*)slp.getNodata(); int xstart, ystart; slpData->localToGlobal(0, 0, xstart, ystart); // TODO: put similar comments for the other savedxdyc() function used in this function // for a complete slpData partition would need to run slpData->savedxdyc(slp) to save lat variable cell sizes // here not done as cell size not needed //slpData->savedxdyc(slp); slp.read(xstart, ystart, ny, nx, slpData->getGridPointer()); //Create partition and read data from clibration grid file tdpartition *calData; calData = CreateNewPartition(cal.getDatatype(), totalX, totalY, dx, dy, -1); calData->localToGlobal(0, 0, xstart, ystart); calData->savedxdyc(cal); cal.read(xstart, ystart, ny, nx, calData->getGridPointer()); ndvter = (short*)cal.getNodata(); //Create partition and read data from sca grid file tdpartition *scaData; scaData = CreateNewPartition(sca.getDatatype(), totalX, totalY, dx, dy, sca.getNodata()); scaData->localToGlobal(0, 0, xstart, ystart); scaData->savedxdyc(sca); sca.read(xstart, ystart, ny, nx, scaData->getGridPointer()); //Create partition and read data from sca min grid file tdpartition *scaMinData = NULL; if (sca_min != NULL) { scaMinData = CreateNewPartition(sca_min->getDatatype(), totalX, totalY, dx, dy, sca_min->getNodata()); scaMinData->localToGlobal(0, 0, xstart, ystart); scaMinData->savedxdyc(*sca_min); sca_min->read(xstart, ystart, ny, nx, scaMinData->getGridPointer()); } //Create partition and read data from sca max grid file tdpartition *scaMaxData = NULL; if(sca_max != NULL) { scaMaxData = CreateNewPartition(sca_max->getDatatype(), totalX, totalY, dx, dy, sca_max->getNodata()); scaMaxData->localToGlobal(0, 0, xstart, ystart); scaMaxData->savedxdyc(*sca_max); sca_max->read(xstart, ystart, ny, nx, scaMaxData->getGridPointer()); } short cal_cell_value = 0; float slope_cell_value = 0; float sca_cell_value = 0; float sca_min_cell_value = 0; float sca_max_cell_value = 0; float csi_data = 0; int region_index = 0; //Create empty partition to store csi data tdpartition *csiData; csiData = CreateNewPartition(FLOAT_TYPE, totalX, totalY, dx, dy, -1.0f); //Create empty partition to store sat data tdpartition *satData; satData = CreateNewPartition(FLOAT_TYPE, totalX, totalY, dx, dy, -1.0f); //Share information and set borders to zero slpData->share(); scaData->share(); if(scaMinData != NULL) { scaMinData->share(); } if(scaMaxData != NULL) { scaMaxData->share(); } calData->share(); csiData->clearBorders(); satData->clearBorders(); for(j = 0; j < ny; j++) { for(i = 0; i < nx; i++ ) { calData->getData(i, j, cal_cell_value); slpData->getData(i, j, slope_cell_value); scaData->getData(i, j, sca_cell_value); if(scaMinData != NULL) { scaMinData->getData(i, j, sca_min_cell_value); } if(scaMaxData != NULL) { scaMaxData->getData(i, j, sca_max_cell_value); } region_index = findRegIndex(cal_cell_value, nor, *ndvter); // DGT 12/31/14. Changed the logic below from region_index < *ndvter to region_index < 0 to allow for *ndvter to be positive if (region_index < 0 || sca_cell_value < 0 || sca_min_cell_value < 0 || sca_max_cell_value < 0 || slope_cell_value == ndvs){ csiData->setToNodata(i, j); satData->setToNodata(i, j); } else{ if(Rmaxter != 0 || sca_max_cell_value != 0){ X2 = (sca_cell_value * Rmaxter + sca_max_cell_value)/region[region_index].tmin; X1 = (sca_cell_value * Rminter + sca_min_cell_value)/region[region_index].tmax; csi_data = (float)sindexcell(slope_cell_value, 1, region[region_index].cmin, region[region_index].cmax, region[region_index].tphimin, region[region_index].tphimax, X1, X2, region[region_index].r, &cellsat); csiData->setData(i, j, csi_data); satData->setData(i, j, float(cellsat)); } } } } // DGT 12/31/14 commented passing of borders. This function acts locally so does not need any border sharing //Pass information //csiData->addBorders(); //satData->addBorders(); //Clear out borders //csiData->clearBorders(); //satData->clearBorders(); //Stop timer end = MPI_Wtime(); double compute, temp; compute = end-begin; MPI_Allreduce (&compute, &temp, 1, MPI_DOUBLE, MPI_SUM, MCW); compute = temp/size; if( rank == 0) { printf("Compute time: %f\n",compute); } //Create and write to the csi TIFF file float aNodata = -1.0f; tiffIO csi(sincombinedfile, FLOAT_TYPE, &aNodata, slp); csi.write(xstart, ystart, ny, nx, csiData->getGridPointer()); //Create and write to the sat TIFF file tiffIO sat(satfile, FLOAT_TYPE, &aNodata, slp); sat.write(xstart, ystart, ny, nx, satData->getGridPointer()); }MPI_Finalize(); return 0; }