void track_match() { array vecdca; if (glob < 10) return; double p = glob*5; double phi = vecdca.data; ext1 (vecdca.data-glob); ext1 (phi*2); if (1 < p) ++nmuons; }
bool SrtmHgtFile::determineSrtmInfo(const std::string& srtmFilename, std::streamoff size) { // Extract the number of latitude and longitude lines unsigned int num_lat; unsigned int num_lon; // Extract the data intervals for latitude and longitude switch (size) { case 2884802: latSpacing = 3.0 / 3600.0; lonSpacing = 3.0 / 3600.0; num_lat = 1201; num_lon = 1201; break; case 25934402: latSpacing = 1.0 / 3600.0; lonSpacing = 1.0 / 3600.0; num_lat = 3601; num_lon = 3601; break; default: return false; } // valid SRTM file extensions std::string ext1(".hgt"); std::string ext2(".HGT"); if (srtmFilename.substr(7, 4) != ".hgt" && srtmFilename.substr(7, 4) != ".HGT") { return false; } // nXXwXXX.hgt srtm1 srtm3 int swcLatitude = std::atoi(srtmFilename.substr(1, 2).c_str()); int swcLongitude = std::atoi(srtmFilename.substr(4, 3).c_str()); char ns = (char)tolower(srtmFilename[0]); char ew = (char)tolower(srtmFilename[3]); if ((ns != 'n' && ns != 's') || (ew != 'e' && ew != 'w')) { return false; } if (ns == 's') { swcLatitude = -swcLatitude; } if (ew == 'w') { swcLongitude = -swcLongitude; } setLatitudeSW( swcLatitude ); setLongitudeSW( swcLongitude ); setLatitudeNE( swcLatitude + 1 ); setLongitudeNE( swcLongitude + 1 ); nptlat = num_lat; nptlong = num_lon; return true; }
void set_rectangle(T const & src, T & dst, std::size_t x, std::size_t y) { mapnik::box2d<int> ext0(0, 0, dst.width(), dst.height()); mapnik::box2d<int> ext1(x, y, x + src.width(), y + src.height()); if (ext0.intersects(ext1)) { mapnik::box2d<int> box = ext0.intersect(ext1); for (std::size_t pix_y = box.miny(); pix_y < static_cast<std::size_t>(box.maxy()); ++pix_y) { typename T::pixel_type * row_to = dst.get_row(pix_y); typename T::pixel_type const * row_from = src.get_row(pix_y - y); for (std::size_t pix_x = box.minx(); pix_x < static_cast<std::size_t>(box.maxx()); ++pix_x) { row_to[pix_x] = row_from[pix_x - x]; } } } }
bool VCompDialog::legalExt() { MTarget *curtarg; int i = _imagelist->selected(); if( i >= 0 ) { curtarg = (MTarget *)_tgList[i]; WString ext1( curtarg->tgtMask().ext() ); WString ext2( _fn->ext() ); if( ext2.size() == 0 ) { _fn->setExt( ext1 ); return TRUE; } if( ext1 == ext2 ) { return TRUE; } WString n; curtarg->name( n ); WMessageDialog::messagef( this, MsgError, MsgOk, _viperError, "'%s' is not a legal file extension for '%s'", (const char*)ext2, (const char*)n ); } else { WMessageDialog::messagef( this, MsgError, MsgOk, _viperError, "Select an image type." ); } return FALSE; }
void TGV2_3D::IterativeReconstruction(CVector &data_gpu, CVector &x1, CVector &b1_gpu) { if (verbose) TestAdjointness(b1_gpu); unsigned N = width * height * depth; //TODO: compute for dx,dy,dz //ComputeTimeSpaceWeights(params.timeSpaceWeight, params.ds, params.dt); //Log("Setting ds: %.3e, dt: %.3e\n", params.ds, params.dt); Log("Setting Primal-Dual Gap of %.3e as stopping criterion \n", params.stopPDGap); std::vector<CVector> x2; for (unsigned cnt = 0; cnt < 3; cnt++) { x2.push_back(CVector(N)); x2[cnt].assign(N, 0.0); } // primal CVector ext1(N), x1_old(N); std::vector<CVector> ext2, x2_old; for (unsigned cnt = 0; cnt < 3; cnt++) { ext2.push_back(CVector(N)); x2_old.push_back(CVector(N)); } agile::copy(x1, ext1); // dual std::vector<CVector> y1; std::vector<CVector> y1Temp; for (int cnt = 0; cnt < 3; cnt++) { y1.push_back(CVector(N)); y1[cnt].assign(N, 0.0); y1Temp.push_back(CVector(N)); } std::vector<CVector> y2; std::vector<CVector> y2Temp; for (int cnt = 0; cnt < 6; cnt++) { y2.push_back(CVector(N)); y2[cnt].assign(N, 0); y2Temp.push_back(CVector(N)); } CVector z(N * coils); CVector zTemp(N * coils); z.assign(N * coils, 0.0); zTemp.assign(N * coils, 0.0); CVector imgTemp(N); CVector div1Temp(N); std::vector<CVector> div2Temp; for (unsigned cnt = 0; cnt < 3; cnt++) div2Temp.push_back(CVector(N)); unsigned loopCnt = 0; // loop Log("Starting iteration\n"); while (loopCnt < params.maxIt) { // dual ascent step // p utils::Gradient(ext1, y1Temp, width, height, params.dx, params.dy, params.dz); for (unsigned cnt = 0; cnt < 3; cnt++) { agile::subVector(y1Temp[cnt], ext2[cnt], y1Temp[cnt]); agile::addScaledVector(y1[cnt], params.sigma, y1Temp[cnt], y1[cnt]); } // q utils::SymmetricGradient(ext2, y2Temp, width, height, params.dx, params.dy, params.dz); for (unsigned cnt = 0; cnt < 6; cnt++) { agile::addScaledVector(y2[cnt], params.sigma, y2Temp[cnt], y2[cnt]); } mrOp->BackwardOperation(ext1, zTemp, b1_gpu); agile::addScaledVector(z, params.sigma, zTemp, z); // Proximal mapping utils::ProximalMap3(y1, (DType)1.0 / params.alpha1); utils::ProximalMap6(y2, (DType)1.0 / params.alpha0); agile::subScaledVector(z, params.sigma, data_gpu, z); agile::scale((float)(1.0 / (1.0 + params.sigma / params.lambda)), z, z); // primal descent // ext1 mrOp->ForwardOperation(z, imgTemp, b1_gpu); utils::Divergence(y1, div1Temp, width, height, depth, params.dx, params.dy, params.dz); agile::subVector(imgTemp, div1Temp, div1Temp); agile::subScaledVector(x1, params.tau, div1Temp, ext1); // ext2 utils::SymmetricDivergence(y2, div2Temp, width, height, depth, params.dx, params.dy, params.dz); for (unsigned cnt = 0; cnt < 3; cnt++) { agile::addVector(y1[cnt], div2Temp[cnt], div2Temp[cnt]); agile::addScaledVector(x2[cnt], params.tau, div2Temp[cnt], ext2[cnt]); } // save x_n+1 agile::copy(ext1, x1_old); for (unsigned cnt = 0; cnt < 3; cnt++) agile::copy(ext2[cnt], x2_old[cnt]); // extra gradient agile::scale(2.0f, ext1, ext1); agile::subVector(ext1, x1, ext1); // x_n = x_n+1 agile::copy(x1_old, x1); for (unsigned cnt = 0; cnt < 3; cnt++) { agile::scale((DType)2.0, ext2[cnt], ext2[cnt]); agile::subVector(ext2[cnt], x2[cnt], ext2[cnt]); agile::copy(x2_old[cnt], x2[cnt]); } // adapt step size if (loopCnt < 10 || (loopCnt % 50 == 0)) { agile::subVector(ext1, x1, div1Temp); for (unsigned cnt = 0; cnt < 3; cnt++) { agile::subVector(ext2[cnt], x2[cnt], div2Temp[cnt]); } AdaptStepSize(div1Temp, div2Temp, b1_gpu); } // compute PD Gap (export,verbose,stopping) if ( (verbose && (loopCnt < 10 || (loopCnt % 50 == 0)) ) || ((debug) && (loopCnt % debugstep == 0)) || ((params.stopPDGap > 0) && (loopCnt % 20 == 0)) ) { RType pdGap = ComputePDGap(x1, x2, y1, y2, z, data_gpu, b1_gpu); pdGap=pdGap/N; if ( pdGap < params.stopPDGap ) return; pdGapExport.push_back( pdGap ); Log("Normalized Primal-Dual Gap after %d iterations: %.4e\n", loopCnt, pdGap); } /* // adapt step size if (loopCnt < 10 || (loopCnt % 50 == 0)) { CVector temp1(N); agile::subVector(ext1, x1, temp1); std::vector<CVector> temp2; for (unsigned cnt = 0; cnt < 3; cnt++) { temp2.push_back(CVector(N)); agile::subVector(ext2[cnt], x2[cnt], temp2[cnt]); } AdaptStepSize(temp1, temp2, b1_gpu); if (verbose) { RType pdGap = 1.0; RType pdGap = ComputePDGap(x1, x2, y1, y2, z, data_gpu, b1_gpu); Log("Normalized Primal-Dual Gap after %d iterations: %.4e\n", loopCnt, pdGap/N); } } // compute PD Gap for export if ((debug) && (loopCnt % debugstep == 0)) { RType pdGap = ComputePDGap(x1, x2, y1, y2, z, data_gpu, b1_gpu); pdGapExport.push_back( pdGap/N ); } */ loopCnt++; if (loopCnt % 10 == 0) std::cout << "." << std::flush; } std::cout << std::endl; }