* Used to calculate the partial power spectrum with feature compression * as described in Darby et al. Currently only for the mu = 1, nu = 1 * compression described in Darby et al. (by far the best performing * alternative that they evaluated). It could be adapted however to * provide other compression alternatives. This compression scheme * scales linearly with the number of elements and is
| 1825 | * used, so that after a possible dot-product the full prefactor is recovered. |
| 1826 | */ |
| 1827 | void getPWithCompression(py::detail::unchecked_mutable_reference<double, 2> &Ps, double* Cs, |
| 1828 | double* CsSummed, int Nt, int lMax, int nMax, int Hs, |
| 1829 | double rCut2, int nFeatures, int nCoeffs, int nCompressionCoeffs) |
| 1830 | { |
| 1831 | // The current index in the final power spectrum array. |
| 1832 | int pIdx = 0; |
| 1833 | |
| 1834 | for (int i = 0; i < Hs; i++) { |
| 1835 | pIdx = 0; |
| 1836 | for (int Z1 = 0; Z1 < Nt; Z1++) { |
| 1837 | for (int l = 0; l < lMax+1; l++) { |
| 1838 | for (int N1 = 0; N1 < nMax; N1++) { |
| 1839 | for (int N2 = 0; N2 < nMax; N2++) { |
| 1840 | double sum = 0; |
| 1841 | for (int m = 0; m < l+1; m++) { |
| 1842 | if (m == 0) { |
| 1843 | sum += Cs[i*nCoeffs+2*Z1*(lMax+1)*(lMax+1)*nMax + 2*(lMax+1)*(lMax+1)*N1 + l*2*(lMax+1)] // m=0 |
| 1844 | *CsSummed[i*nCompressionCoeffs + 2*(lMax+1)*(lMax+1)*N2 + l*2*(lMax+1)]; // m=0 |
| 1845 | } else { |
| 1846 | sum += 2*(Cs[i*nCoeffs+2*Z1*(lMax+1)*(lMax+1)*nMax + 2*(lMax+1)*(lMax+1)*N1 + l*2*(lMax+1) + 2*m] |
| 1847 | *CsSummed[i*nCompressionCoeffs + 2*(lMax+1)*(lMax+1)*N2 + l*2*(lMax+1) + 2*m] |
| 1848 | +Cs[i*nCoeffs+2*Z1*(lMax+1)*(lMax+1)*nMax + 2*(lMax+1)*(lMax+1)*N1 + l*2*(lMax+1) + 2*m + 1] |
| 1849 | *CsSummed[i*nCompressionCoeffs + 2*(lMax+1)*(lMax+1)*N2 + l*2*(lMax+1) + 2*m + 1]); |
| 1850 | } |
| 1851 | } |
| 1852 | Ps(i, pIdx) = PI*sqrt(8.0/(2.0*l+1.0))*39.478417604*rCut2*sum; // Normalization and other constants |
| 1853 | ++pIdx; |
| 1854 | } |
| 1855 | } |
| 1856 | } |
| 1857 | } |
| 1858 | } |
| 1859 | } |
| 1860 | |
| 1861 | |
| 1862 |