/***********************************************************************//** * @brief Integrates PSF for a specific set of parameters * * @param[in] energy Energy (MeV). * @param[in] index Parameter array index. * * Integrates PSF for a specific set of parameters. * * Compile option G_APPROXIMATE_PSF_INTEGRAL: * If defined, a numerical PSF integral is only performed for energies * < 120 MeV, while for larger energies the small angle approximation is * used. In not defined, a numerical PSF integral is performed for all * energies. * This option is kept for comparison with the Fermi/LAT ScienceTools who * select the integration method based on the true photon energy. As the * normalization is only performed once upon loading of the PSF, CPU time * is not really an issue here, and we can afford the more precise numerical * integration. Note that the uncertainties of the approximation at energies * near to 120 MeV reaches 0.1%. * * @todo Implement gcore and gtail checking ***************************************************************************/ double GLATPsfV3::integrate_psf(const double& energy, const int& index) { // Initialise integral double psf = 0.0; // Get energy scaling double scale = scale_factor(energy); // Get parameters double ncore(m_ncore[index]); double ntail(m_ntail[index]); double score(m_score[index] * scale); double stail(m_stail[index] * scale); double gcore(m_gcore[index]); double gtail(m_gtail[index]); // Make sure that gcore and gtail are not negative //if (gcore < 0 || gtail < 0) { //} // Do we need an exact integral? #if defined(G_APPROXIMATE_PSF_INTEGRAL) if (energy < 120) { #endif // Allocate integrand GLATPsfV3::base_integrand integrand(ncore, ntail, score, stail, gcore, gtail); // Allocate integral GIntegral integral(&integrand); // Integrate radially from 0 to 90 degrees psf = integral.romb(0.0, pihalf) * twopi; #if defined(G_APPROXIMATE_PSF_INTEGRAL) } // endif: exact integral was performed // No, so we use the small angle approximation else { // Compute arguments double rc = pihalf / score; double uc = 0.5 * rc * rc; double sc = twopi * score * score; double rt = pihalf / stail; double ut = 0.5 * rt * rt; double st = twopi * stail * stail; // Evaluate PSF integral (from 0 to 90 degrees) psf = ncore * (base_int(uc, gcore) * sc + base_int(ut, gtail) * st * ntail); } #endif // Return PSF integral return psf; }
polygon polygon::createUnion(const std::vector<polygon>& data) { base_int maxDenom = 1; for(auto poly : data) { maxDenom = lcm(maxDenom, poly.highestDenominator()); } maxDenom = std::min(maxDenom, base_int(1000000000L)); //std::cout << "-----" << std::endl; //std::cout << maxDenom << std::endl; polygon base = data[0]; for(unsigned int i = 1; i < data.size(); i++) { ClipperLib::Clipper clipper; clipper.AddPath(base.path(maxDenom), ClipperLib::PolyType::ptSubject, true); clipper.AddPath(data[i].path(maxDenom), ClipperLib::PolyType::ptClip, true); ClipperLib::Paths returnedPaths; clipper.Execute(ClipperLib::ClipType::ctUnion, returnedPaths, ClipperLib::pftNonZero, ClipperLib::pftNonZero); base = polygon::from(returnedPaths, maxDenom)[0]; } return base; }
char *ft_getconv(char *str, va_list *ap, t_add *flags) { initflags(flags, 0); if (*str == '%') ft_putchar(*str, flags); if (*str == '%') return ((char *)++str); ft_getflags(str, flags); if (!*str) return (str); else if (!ft_strchr("idDuUoOfFxXbBZcCsSp", *str)) return (str); else if (ft_strchr("idDuU", *str)) base_int(flags, ap, *str); else if (ft_strchr("poOxXbBZ", *str)) base_oh(flags, ap, *str); else if (ft_strchr("cCsS", *str)) base_char(flags, ap, *str); return ((char *)++str); }