QString IncreaseCounterPlugin::processFile( BatchRenamer*, int, const QString & filenameOrToken, EPluginType ) { // Split string into prenum, number and postnum parts QRegExp splitit("(\\D*)(\\d+)(.*)"); // Is there anything to increment ? if( splitit.exactMatch(filenameOrToken) ) { QString prenum = splitit.cap(1); long tmp = splitit.cap(2).toLong(); QString postnum = splitit.cap(3); tmp += m_offset; QString tmpstr; return (prenum + tmpstr.sprintf("%0*li", splitit.cap(2).length(), tmp) + postnum); } return QString::null; }
OneDimensionalDeviate::OneDimensionalDeviate(const FluxDensity& fluxDensity, std::vector<double>& range, bool isRadial, const GSParamsPtr& gsparams) : _fluxDensity(fluxDensity), _positiveFlux(0.), _negativeFlux(0.), _isRadial(isRadial), _gsparams(gsparams) { dbg<<"Start ODD constructor\n"; dbg<<"Input range has "<<range.size()<<" entries\n"; dbg<<"radial? = "<<isRadial<<std::endl; // Typedef for indices of standard containers, which don't like int values typedef std::vector<double>::size_type Index; // First calculate total flux so we know when an interval is a small amt of flux for (Index iRange = 0; iRange < range.size()-1; iRange++) { xdbg<<"range "<<iRange<<" = "<<range[iRange]<<" ... "<<range[iRange+1]<<std::endl; // Integrate total flux (and sign) in each range Interval segment(fluxDensity, range[iRange], range[iRange+1], _isRadial, _gsparams); double rangeFlux = segment.getFlux(); if (rangeFlux >= 0.) _positiveFlux += rangeFlux; else _negativeFlux += std::abs(rangeFlux); } dbg<<"posFlux = "<<_positiveFlux<<std::endl; dbg<<"negFlux = "<<_negativeFlux<<std::endl; double totalAbsoluteFlux = _positiveFlux + _negativeFlux; dbg<<"totFlux = "<<totalAbsoluteFlux<<std::endl; // Now break each range into Intervals for (Index iRange = 0; iRange < range.size()-1; iRange++) { // See if there is an extremum to split this range: double extremum; if (findExtremum(_fluxDensity, range[iRange], range[iRange+1], extremum, _gsparams->range_division_for_extrema)) { xdbg<<"range "<<iRange<<" = "<<range[iRange]<<" ... "<<range[iRange+1]<< " has an extremum at "<<extremum<<std::endl; // Do 2 ranges { Interval splitit(_fluxDensity, range[iRange], extremum, _isRadial, _gsparams); std::list<Interval> leftList = splitit.split( _gsparams->small_fraction_of_flux * totalAbsoluteFlux); xdbg<<"Add "<<leftList.size()<<" intervals on left of extremem\n"; _pt.insert(_pt.end(), leftList.begin(), leftList.end()); } { Interval splitit(_fluxDensity, extremum, range[iRange+1], _isRadial, _gsparams); std::list<Interval> rightList = splitit.split( _gsparams->small_fraction_of_flux * totalAbsoluteFlux); xdbg<<"Add "<<rightList.size()<<" intervals on right of extremem\n"; _pt.insert(_pt.end(), rightList.begin(), rightList.end()); } } else { // Just single Interval in this range, no extremum: Interval splitit( _fluxDensity, range[iRange], range[iRange+1], _isRadial, _gsparams); std::list<Interval> leftList = splitit.split( _gsparams->small_fraction_of_flux * totalAbsoluteFlux); xdbg<<"Add "<<leftList.size()<<" intervals\n"; _pt.insert(_pt.end(), leftList.begin(), leftList.end()); } } dbg<<"Total of "<<_pt.size()<<" intervals\n"; // Build the ProbabilityTree _pt.buildTree(); }
static void zop2(int lines, int op) { register int *split; split = NIL; switch(op) { case EOF: if (addr2 == dol) error("\nAt EOF"); case '+': if (addr2 == dol) error("At EOF"); addr2 += lines * zweight; if (addr2 > dol) error("Hit BOTTOM"); addr2++; default: addr1 = addr2; addr2 += lines-1; dot = addr2; break; case '=': case '.': lines--; lines >>= 1; if (op == '=') lines--; addr1 = addr2-lines; if (op == '=') dot = split = addr2; addr2 += lines; if (op == '.') { markDOT(); dot = addr2; } break; case '^': case '-': addr2 -= lines * zweight; if (addr2 < one) error("Hit TOP"); lines--; addr1 = addr2 - lines; dot = addr2; break; } if (addr1 <= zero) addr1 = one; if (addr2 > dol) addr2 = dol; if (dot > dol) dot = dol; if (addr1 > addr2) return; if (addr2 - addr1 > 1 /* && really wanna do this */) pstart(); if (op == EOF && zhadpr) { ex_getline(*addr1); ex_putchar('\r' | QUOTE); shudclob = 1; } else if (znoclear == 0 && CLEAR) ex_putchar('\032' | QUOTE); if (split) { plines(addr1, split - 1, 0); splitit(); plines(split, split, 0); splitit(); addr1 = split + 1; } plines(addr1, addr2, 0); }