def modDsN2(x): N = 3 dds = 0 # ds = 0 # UNUSED qx = cudahelpers.getqx() ek = A * (math.sqrt((x[0])**2 + (x[1])**2))**2 + A * (eE0 / hOmg)**2 ekq = A * (math.sqrt((x[0] + qx)**2 + (x[1] + 0)**2))**2 + A * (eE0 / hOmg)**2 xk = 2 * A * eE0 * math.sqrt((x[0])**2 + (x[1])**2) / hOmg**2 xkq = 2 * A * eE0 * math.sqrt((x[0] + qx)**2 + (x[1] + 0)**2) / hOmg**2 singrmatrix = numba.cuda.shared.array((6, N), dtype=numba.types.f8) singzmatrix = numba.cuda.shared.array((4, N), dtype=numba.types.complex128) n = 0 i = -(N - 1) / 2 for n in range(0, N): nu = hOmg * i chi = hOmg / 2 omicron = ek - chi + nu phi = ekq - chi + nu iota = ek + chi + nu kappa = ekq + chi + nu omisq = omicron**2 phisq = phi**2 iotasq = iota**2 kappasq = kappa**2 singrmatrix[0, n] = 2 * math.atan2(Gamm, omicron) singrmatrix[1, n] = 2 * math.atan2(Gamm, phi) singrmatrix[2, n] = 2 * math.atan2(Gamm, iota) singrmatrix[3, n] = 2 * math.atan2(Gamm, kappa) singzmatrix[0, n] = complex(0, 1) * math.log(Gammsq + omisq) singzmatrix[1, n] = complex(0, 1) * math.log(Gammsq + phisq) singzmatrix[2, n] = complex(0, 1) * math.log(Gammsq + iotasq) singzmatrix[3, n] = complex(0, 1) * math.log(Gammsq + kappasq) chinu = chi - nu singrmatrix[4, n] = cudahelpers.my_heaviside(mu - chinu) singrmatrix[5, n] = cudahelpers.my_heaviside(mu + chinu) i = i + 1 size_dbl = 5 # 2N-1 dblrmatrix = numba.cuda.shared.array((5, size_dbl), dtype=numba.types.f8) dblzmatrix = numba.cuda.shared.array((4, size_dbl), dtype=numba.types.complex128) i = -(N - 1) for n in range(0, size_dbl): xi = hOmg * i zeta = ek - mu + xi eta = ekq - mu + xi zetasq = zeta**2 etasq = eta**2 dblrmatrix[0, n] = 2 * math.atan2(Gamm, zeta) dblrmatrix[1, n] = 2 * math.atan2(Gamm, eta) logged1 = math.log(Gammsq + zetasq) logged2 = math.log(Gammsq + etasq) dblzmatrix[0, n] = complex(0, logged1) dblzmatrix[1, n] = complex(0, logged2) dblrmatrix[2, n] = cudahelpers.besselj(i, xk) dblrmatrix[3, n] = cudahelpers.besselj(i, xkq) fac1i = ek - ekq + xi fac2i = complex(fac1i, 2 * Gamm) dblrmatrix[4, n] = fac1i dblzmatrix[2, n] = fac2i dblzmatrix[3, n] = fac2i - ek + ekq i = i + 1 # This is implementing what Mahmoud and I discussed to construct these outside. sdr00 = numba.cuda.shared.array((N, N), dtype=numba.types.f8) sdr20 = numba.cuda.shared.array((N, N), dtype=numba.types.f8) sdr11 = numba.cuda.shared.array((N, N), dtype=numba.types.f8) sdr31 = numba.cuda.shared.array((N, N), dtype=numba.types.f8) sdz00 = numba.cuda.shared.array((N, N), dtype=numba.types.c16) sdz20 = numba.cuda.shared.array((N, N), dtype=numba.types.c16) sdz11 = numba.cuda.shared.array((N, N), dtype=numba.types.c16) sdz31 = numba.cuda.shared.array((N, N), dtype=numba.types.c16) dd11 = numba.cuda.shared.array((N, N), dtype=numba.types.c16) dd00 = numba.cuda.shared.array((N, N), dtype=numba.types.c16) # Now to fill the arrays, we use a dummy variable that will be referenced below by the actual indices. for i in range(0, N): # i will be indexed by s below for j in range( 0, N ): # j will be indexed by alpha, beta, or gamma in the nested loops ij = i + j sdr00[i, j] = singrmatrix[0, j] - dblrmatrix[0, ij] sdr20[i, j] = singrmatrix[2, j] - dblrmatrix[0, ij] sdr11[i, j] = -singrmatrix[1, j] + dblrmatrix[1, ij] sdr31[i, j] = -singrmatrix[3, j] + dblrmatrix[1, ij] sdz00[i, j] = singzmatrix[0, j] + dblzmatrix[0, ij] sdz20[i, j] = singzmatrix[2, j] + dblzmatrix[0, ij] sdz11[i, j] = singzmatrix[1, j] + dblzmatrix[1, ij] sdz31[i, j] = singzmatrix[3, j] + dblzmatrix[1, ij] dd11[i, j] = dblrmatrix[1, ij] - dblzmatrix[1, ij] dd00[i, j] = dblrmatrix[0, ij] + dblzmatrix[0, ij] for n in range(0, N): nmod = n + N - 1 for alpha in range(0, N): for beta in range(0, N): abdiff = alpha - beta + N - 1 for gamma in range(0, N): bgdiff = beta - gamma + N - 1 agdiff = alpha - gamma + N - 1 d1 = -2 * complex(0, 1) * dblrmatrix[ 4, bgdiff] * dblzmatrix[2, agdiff] * dblzmatrix[3, abdiff] d2 = -2 * complex(0, 1) * dblrmatrix[ 4, abdiff] * dblzmatrix[2, agdiff] * dblzmatrix[3, bgdiff] for s in range(0, N): smod = s + N - 1 p1p = dblrmatrix[4, bgdiff] * (sdr00[s, alpha] - sdz00[s, alpha]) p2p = dblzmatrix[2, agdiff] * (singrmatrix[0, beta] - dd00[s, beta] + singzmatrix[0, beta]) p3p = dblzmatrix[3, abdiff] * (sdr11[s, gamma] - sdz11[s, gamma]) p1m = dblrmatrix[4, bgdiff] * (sdr20[s, alpha] - sdz20[s, alpha]) p2m = dblzmatrix[2, agdiff] * (singrmatrix[2, beta] - dd00[s, beta] + singzmatrix[2, beta]) p3m = dblzmatrix[3, abdiff] * (sdr31[s, gamma] - sdz31[s, gamma]) omint1p = singrmatrix[4, s] * ((p1p + p2p + p3p) / d1) omint1m = singrmatrix[5, s] * ((p1m + p2m + p3m) / d1) pp1p = dblrmatrix[4, abdiff] * (sdr11[s, gamma] - sdz11[s, gamma]) pp2p = dblzmatrix[2, agdiff] * (-singrmatrix[1, beta] + dd11[s, beta] + singzmatrix[1, beta]) pp3p = dblzmatrix[3, bgdiff] * (sdr00[s, alpha] - sdz00[s, alpha]) pp1m = dblrmatrix[4, abdiff] * (sdr31[s, gamma] - sdz31[s, gamma]) pp2m = dblzmatrix[2, agdiff] * (-singrmatrix[3, beta] + dd11[s, beta] + singzmatrix[3, beta]) pp3m = dblzmatrix[3, bgdiff] * (sdr20[s, alpha] - sdz20[s, alpha]) omint2p = singrmatrix[4, s] * ( (pp1p + pp2p + pp3p) / d2) omint2m = singrmatrix[5, s] * ( (pp1m + pp2m + pp3m) / d2) for l in range(0, N): lmod = l + N - 1 bess1 = dblrmatrix[3, gamma - nmod] * dblrmatrix[ 3, gamma - lmod] * dblrmatrix[ 2, beta - lmod] * dblrmatrix[ 2, beta - smod] * dblrmatrix[ 2, alpha - smod] * dblrmatrix[2, alpha - nmod] grgl = bess1 * (omint1p - omint1m) bess2 = dblrmatrix[3, gamma - nmod] * dblrmatrix[ 3, gamma - smod] * dblrmatrix[ 3, beta - smod] * dblrmatrix[ 3, beta - lmod] * dblrmatrix[ 2, alpha - lmod] * dblrmatrix[2, alpha - nmod] glga = bess2 * (omint2p - omint2m) dds = dds + Gamm * (grgl + glga) return -4 * dds.real / math.pi**2
def modDsN2(x): N = 3 dds = 0 # ds = 0 # UNUSED qx = cudahelpers.getqx() ek = A * (math.sqrt((x[0])**2 + (x[1])**2))**2 + A * (eE0 / hOmg)**2 ekq = A * (math.sqrt((x[0] + qx)**2 + (x[1] + 0)**2))**2 + A * (eE0 / hOmg)**2 xk = 2 * A * eE0 * math.sqrt((x[0])**2 + (x[1])**2) / hOmg**2 xkq = 2 * A * eE0 * math.sqrt((x[0] + qx)**2 + (x[1] + 0)**2) / hOmg**2 singmatrix = numba.cuda.shared.array((10, N), dtype=numba.types.complex128) n = 0 i = -(N - 1) / 2 while (i < ((N - 1) / 2 + 1)): nu = hOmg * i chi = hOmg / 2 omicron = ek - chi + nu phi = ekq - chi + nu iota = ek + chi + nu kappa = ekq + chi + nu omisq = omicron**2 phisq = phi**2 iotasq = iota**2 kappasq = kappa**2 singmatrix[0, n] = 2 * math.atan2(Gamm, omicron) singmatrix[1, n] = 2 * math.atan2(Gamm, phi) singmatrix[2, n] = 2 * math.atan2(Gamm, iota) singmatrix[3, n] = 2 * math.atan2(Gamm, kappa) singmatrix[4, n] = complex(0, 1) * math.log(Gammsq + omisq) singmatrix[5, n] = complex(0, 1) * math.log(Gammsq + phisq) singmatrix[6, n] = complex(0, 1) * math.log(Gammsq + iotasq) singmatrix[7, n] = complex(0, 1) * math.log(Gammsq + kappasq) chinu = chi - nu singmatrix[8, n] = cudahelpers.my_heaviside(mu - chinu) singmatrix[9, n] = cudahelpers.my_heaviside(mu + chinu) i = i + 1 n = n + 1 #numba.cuda.syncthreads() size_dbl = 5 dblmatrix = numba.cuda.shared.array((9, size_dbl), dtype=numba.types.complex128) n = 0 for i in range(-(N - 1), N, 1): xi = hOmg * i zeta = ek - mu + xi eta = ekq - mu + xi zetasq = zeta**2 etasq = eta**2 dblmatrix[0, n] = 2 * math.atan2(Gamm, zeta) dblmatrix[1, n] = 2 * math.atan2(Gamm, eta) logged1 = math.log(Gammsq + zetasq) logged2 = math.log(Gammsq + etasq) dblmatrix[2, n] = complex(0, logged1) dblmatrix[3, n] = complex(0, logged2) dblmatrix[4, n] = cudahelpers.besselj(i, xk) dblmatrix[5, n] = cudahelpers.besselj(i, xkq) fac1i = ek - ekq + xi fac2i = complex(fac1i, 2 * Gamm) dblmatrix[6, n] = fac1i dblmatrix[7, n] = fac2i dblmatrix[8, n] = fac2i - ek + ekq n = n + 1 #numba.cuda.syncthreads() for n in range(0, N): for alpha in range(0, N): for beta in range(0, N): for gamma in range(0, N): for s in range(0, N): for l in range(0, N): p1p = dblmatrix[6, beta - gamma + N - 1] * ( singmatrix[0, alpha] - dblmatrix[0, s + alpha] - singmatrix[4, alpha] + dblmatrix[2, s + alpha]) p2p = dblmatrix[7, alpha - gamma + N - 1] * ( singmatrix[0, beta] - dblmatrix[0, s + beta] + singmatrix[4, beta] - dblmatrix[2, s + beta]) p3p = dblmatrix[8, alpha - beta + N - 1] * ( -singmatrix[1, gamma] + dblmatrix[1, s + gamma] - singmatrix[5, gamma] + dblmatrix[3, s + gamma]) p1m = dblmatrix[6, beta - gamma + N - 1] * ( singmatrix[2, alpha] - dblmatrix[0, s + alpha] - singmatrix[6, alpha] + dblmatrix[2, s + alpha]) p2m = dblmatrix[7, alpha - gamma + N - 1] * ( singmatrix[2, beta] - dblmatrix[0, s + beta] + singmatrix[6, beta] - dblmatrix[2, s + beta]) p3m = dblmatrix[8, alpha - beta + N - 1] * ( -singmatrix[3, gamma] + dblmatrix[1, s + gamma] - singmatrix[7, gamma] + dblmatrix[3, s + gamma]) d1 = -2 * complex(0, 1) * dblmatrix[ 6, beta - gamma + N - 1] * dblmatrix[7, alpha - gamma + N - 1] * dblmatrix[8, alpha - beta + N - 1] omint1p = singmatrix[8, s] * ( (p1p + p2p + p3p) / d1) omint1m = singmatrix[9, s] * ( (p1m + p2m + p3m) / d1) bess1 = dblmatrix[ 5, gamma - n + N - 1] * dblmatrix[ 5, gamma - l + N - 1] * dblmatrix[ 4, beta - l + N - 1] * dblmatrix[ 4, beta - s + N - 1] * dblmatrix[ 4, alpha - s + N - 1] * dblmatrix[4, alpha - n + N - 1] grgl = bess1 * (omint1p - omint1m) pp1p = dblmatrix[6, alpha - beta + N - 1] * ( -singmatrix[1, gamma] + dblmatrix[1, s + gamma] - singmatrix[5, gamma] + dblmatrix[3, s + gamma]) pp2p = dblmatrix[7, alpha - gamma + N - 1] * ( -singmatrix[1, beta] + dblmatrix[1, s + beta] + singmatrix[5, beta] - dblmatrix[3, s + beta]) pp3p = dblmatrix[8, beta - gamma + N - 1] * ( singmatrix[0, alpha] - dblmatrix[0, s + alpha] - singmatrix[4, alpha] + dblmatrix[2, s + alpha]) pp1m = dblmatrix[6, alpha - beta + N - 1] * ( -singmatrix[3, gamma] + dblmatrix[1, s + gamma] - singmatrix[7, gamma] + dblmatrix[3, s + gamma]) pp2m = dblmatrix[7, alpha - gamma + N - 1] * ( -singmatrix[3, beta] + dblmatrix[1, s + beta] + singmatrix[7, beta] - dblmatrix[3, s + beta]) pp3m = dblmatrix[8, beta - gamma + N - 1] * ( singmatrix[2, alpha] - dblmatrix[0, s + alpha] - singmatrix[6, alpha] + dblmatrix[2, s + alpha]) d2 = -2 * complex(0, 1) * dblmatrix[ 6, alpha - beta + N - 1] * dblmatrix[7, alpha - gamma + N - 1] * dblmatrix[8, beta - gamma + N - 1] omint2p = singmatrix[8, s] * ( (pp1p + pp2p + pp3p) / d2) omint2m = singmatrix[9, s] * ( (pp1m + pp2m + pp3m) / d2) bess2 = dblmatrix[ 5, gamma - n + N - 1] * dblmatrix[ 5, gamma - s + N - 1] * dblmatrix[ 5, beta - s + N - 1] * dblmatrix[ 5, beta - l + N - 1] * dblmatrix[ 4, alpha - l + N - 1] * dblmatrix[4, alpha - n + N - 1] glga = bess2 * (omint2p - omint2m) dds = dds + Gamm * (grgl + glga) return -4 * dds.real / math.pi**2
def modDs_real(x): dds = 0 r = cudahelpers.getr() ek = A * (math.sqrt((x[0])**2 + (x[1])**2))**2 + A * (eE0 / hOmg)**2 ekq = A * (math.sqrt((x[0] + x[2])**2 + (x[1] + 0)**2))**2 + A * (eE0 / hOmg)**2 xk = 2 * A * eE0 * math.sqrt((x[0])**2 + (x[1])**2) / hOmg**2 xkq = 2 * A * eE0 * math.sqrt((x[0] + x[2])**2 + (x[1] + 0)**2) / hOmg**2 ts1 = ek - hOmg / 2 ts2 = ekq - hOmg / 2 ts3 = ek + hOmg / 2 ts4 = ekq + hOmg / 2 arc2ts1 = math.atan2(Gamm, ts1) arc2ts2 = math.atan2(Gamm, ts2) arc2ts3 = math.atan2(Gamm, ts3) arc2ts4 = math.atan2(Gamm, ts4) taninv1kp = 2 * arc2ts1 taninv1kqp = 2 * arc2ts2 taninv1km = 2 * arc2ts3 taninv1kqm = 2 * arc2ts4 squared1 = ek - hOmg / 2 squared2 = ekq - hOmg / 2 squared3 = ek + hOmg / 2 squared4 = ekq + hOmg / 2 logged1 = Gamm**2 + squared1**2 logged2 = Gamm**2 + squared2**2 logged3 = Gamm**2 + squared3**2 logged4 = Gamm**2 + squared4**2 logged1 = Gamm**2 + (ek - hOmg / 2)**2 logged2 = Gamm**2 + (ekq - hOmg / 2)**2 logged3 = Gamm**2 + (ek + hOmg / 2)**2 logged4 = Gamm**2 + (ekq + hOmg / 2)**2 ln1 = math.log(logged1) ln2 = math.log(logged2) ln3 = math.log(logged3) ln4 = math.log(logged4) lg1kp = complex(0, 1) * ln1 lg1kqp = complex(0, 1) * ln2 lg1km = complex(0, 1) * ln3 lg1kqm = complex(0, 1) * ln4 heavi1 = mu - hOmg / 2 heavi2 = mu + hOmg / 2 ferp = cudahelpers.my_heaviside(heavi1) ferm = cudahelpers.my_heaviside(heavi2) taninv2k = 2 * math.atan2(Gamm, ek - mu) taninv2kq = 2 * math.atan2(Gamm, ekq - mu) lg2k = complex(0, 1) * math.log(Gamm**2 + (ek - mu)**2) lg2kq = complex(0, 1) * math.log(Gamm**2 + (ekq - mu)**2) besk = cudahelpers.besselj(0, xk) beskq = cudahelpers.besselj(0, xkq) fac1 = ek - ekq fac2 = fac1 + 2 * complex(0, 1) * Gamm fac3 = fac2 - ek + ekq # NOTE: N = 1 implies all loops below will be evaluated once. p1p = fac1 * (taninv1kp - taninv2k - lg1kp + lg2k) p2p = fac2 * (taninv1kp - taninv2k + lg1kp - lg2k) p3p = fac3 * (-taninv1kqp + taninv2kq - lg1kqp + lg2kq) p1m = fac1 * (taninv1km - taninv2k - lg1km + lg2k) p2m = fac2 * (taninv1km - taninv2k + lg1km - lg2k) p3m = fac3 * (-taninv1kqm + taninv2kq - lg1kqm + lg2kq) d1 = -2 * complex(0, 1) * fac1 * fac2 * fac3 omint1p = ferp * ((p1p + p2p + p3p) / d1) omint1m = ferm * ((p1m + p2m + p3m) / d1) bess1 = beskq * beskq * besk * besk * besk * besk grgl = bess1 * (omint1p - omint1m) pp1p = fac1 * (-taninv1kqp + taninv2kq - lg1kqp + lg2kq) pp2p = fac2 * (-taninv1kqp + taninv2kq + lg1kqp - lg2kq) pp3p = fac3 * (taninv1kp - taninv2k - lg1kp + lg2k) pp1m = fac1 * (-taninv1kqm + taninv2kq - lg1kqm + lg2kq) pp2m = fac2 * (-taninv1kqm + taninv2kq + lg1kqm - lg2kq) pp3m = fac3 * (taninv1km - taninv2k - lg1km + lg2k) d2 = -2 * complex(0, 1) * fac1 * fac2 * fac3 omint2p = ferp * ((pp1p + pp2p + pp3p) / d2) omint2m = ferm * ((pp1m + pp2m + pp3m) / d2) bess2 = beskq * beskq * beskq * beskq * besk * besk glga = bess2 * (omint2p - omint2m) bess0 = cudahelpers.besselj(0, x[2] * r) dds = dds + Gamm * (grgl + glga) * x[2] * bess0 return -2 * dds.real / math.pi**3
def modDsN2(x): N = 1 dds = 0 # ds = 0 # UNUSED qx = helpers.getqx() ek = A * (math.sqrt((x[0])**2 + (x[1])**2))**2 + A * (eE0 / hOmg)**2 ekq = A * (math.sqrt((x[0] + qx)**2 + (x[1] + 0)**2))**2 + A * (eE0 / hOmg)**2 xk = 2 * A * eE0 * math.sqrt((x[0])**2 + (x[1])**2) / hOmg**2 xkq = 2 * A * eE0 * math.sqrt((x[0] + qx)**2 + (x[1] + 0)**2) / hOmg**2 singmatrix = numba.cuda.shared.array((10, N), dtype=numba.types.complex128) n = 0 i = -(N - 1) / 2 while (i < ((N - 1) / 2 + 1)): nu = hOmg * i chi = hOmg / 2 omicron = ek - chi + nu phi = ekq - chi + nu iota = ek + chi + nu kappa = ekq + chi + nu omisq = omicron**2 phisq = phi**2 iotasq = iota**2 kappasq = kappa**2 singmatrix[0, n] = 2 * math.atan2(Gamm, omicron) singmatrix[1, n] = 2 * math.atan2(Gamm, phi) singmatrix[2, n] = 2 * math.atan2(Gamm, iota) singmatrix[3, n] = 2 * math.atan2(Gamm, kappa) singmatrix[4, n] = complex(0, 1) * math.log(Gammsq + omisq) singmatrix[5, n] = complex(0, 1) * math.log(Gammsq + phisq) singmatrix[6, n] = complex(0, 1) * math.log(Gammsq + iotasq) singmatrix[7, n] = complex(0, 1) * math.log(Gammsq + kappasq) chinu = chi - nu singmatrix[8, n] = helpers.my_heaviside(mu - chinu) singmatrix[9, n] = helpers.my_heaviside(mu + chinu) i = i + 1 n = n + 1 size_dbl = 5 dblmatrix = numba.cuda.shared.array((9, size_dbl), dtype=numba.types.complex128) n = 0 for i in range(-(N - 1), N, 1): xi = hOmg * i zeta = ek - mu + xi eta = ekq - mu + xi zetasq = zeta**2 etasq = eta**2 dblmatrix[0, n] = 2 * math.atan2(Gamm, zeta) dblmatrix[1, n] = 2 * math.atan2(Gamm, eta) logged1 = math.log(Gammsq + zetasq) logged2 = math.log(Gammsq + etasq) dblmatrix[2, n] = complex(0, logged1) dblmatrix[3, n] = complex(0, logged2) dblmatrix[4, n] = helpers.besselj(i, xk) dblmatrix[5, n] = helpers.besselj(i, xkq) fac1i = ek - ekq + xi fac2i = complex(fac1i, 2 * Gamm) dblmatrix[6, n] = fac1i dblmatrix[7, n] = fac2i dblmatrix[8, n] = fac2i - ek + ekq n = n + 1 sdr00 = numba.cuda.shared.array((N, N), dtype=numba.types.complex128) sdr42 = numba.cuda.shared.array((N, N), dtype=numba.types.complex128) sdr11 = numba.cuda.shared.array((N, N), dtype=numba.types.complex128) sdr20 = numba.cuda.shared.array((N, N), dtype=numba.types.complex128) sdr53 = numba.cuda.shared.array((N, N), dtype=numba.types.complex128) sdsdr3173 = numba.cuda.shared.array((N, N), dtype=numba.types.complex128) sdr62 = numba.cuda.shared.array((N, N), dtype=numba.types.complex128) for s in range(0, N): for dummy in range(0, N): both = s + dummy sdr00[s, dummy] = singmatrix[0, dummy] - dblmatrix[0, both] sdr42[s, dummy] = singmatrix[4, dummy] + dblmatrix[2, both] sdr11[s, dummy] = -singmatrix[1, dummy] + dblmatrix[1, both] sdr20[s, dummy] = singmatrix[2, dummy] - dblmatrix[0, both] sdr53[s, dummy] = singmatrix[5, dummy] + dblmatrix[3, both] sdsdr3173[s, dummy] = -singmatrix[3, dummy] + dblmatrix[ 1, both] - singmatrix[7, dummy] + dblmatrix[3, both] sdr62[s, dummy] = singmatrix[6, dummy] + dblmatrix[2, both] for n in range(0, N): nmod = n + N - 1 for alpha in range(0, N): for beta in range(0, N): abdiff = alpha - beta + N - 1 d1part = -2 * complex(0, 1) * dblmatrix[8, abdiff] d2part = -2 * complex(0, 1) * dblmatrix[6, abdiff] for gamma in range(0, N): bgdiff = beta - gamma + N - 1 agdiff = alpha - gamma + N - 1 d1 = d1part * dblmatrix[6, bgdiff] * dblmatrix[7, agdiff] d2 = d2part * dblmatrix[7, agdiff] * dblmatrix[8, bgdiff] besspart1 = dblmatrix[5, gamma - nmod] * dblmatrix[4, alpha - nmod] for s in range(0, N): smod = s + N - 1 tau = s + beta p1p = dblmatrix[6, bgdiff] * (sdr00[s, alpha] - sdr42[s, alpha]) p2p = dblmatrix[7, agdiff] * (sdr00[s, beta] + sdr42[s, beta]) p3p = dblmatrix[8, abdiff] * (sdr11[s, gamma] - sdr53[s, gamma]) p1m = dblmatrix[6, bgdiff] * (sdr20[s, alpha] - sdr62[s, alpha]) p2m = dblmatrix[7, agdiff] * (sdr20[s, beta] + singmatrix[6, beta] - dblmatrix[2, tau]) p3m = dblmatrix[8, abdiff] * (sdsdr3173[s, gamma]) pp1p = dblmatrix[6, abdiff] * (sdr11[s, gamma] - sdr53[s, gamma]) pp2p = dblmatrix[7, agdiff] * (sdr11[s, beta] + singmatrix[5, beta] - dblmatrix[3, tau]) pp3p = dblmatrix[8, bgdiff] * (sdr00[s, alpha] - sdr42[s, alpha]) pp1m = dblmatrix[6, abdiff] * (sdsdr3173[s, gamma]) pp2m = dblmatrix[7, agdiff] * ( -singmatrix[3, beta] + dblmatrix[1, tau] + singmatrix[7, beta] - dblmatrix[3, tau]) pp3m = dblmatrix[8, bgdiff] * (sdr20[s, alpha] - sdr62[s, alpha]) omint1p = singmatrix[8, s] * ((p1p + p2p + p3p) / d1) omint1m = singmatrix[9, s] * ((p1m + p2m + p3m) / d1) omint2p = singmatrix[8, s] * ( (pp1p + pp2p + pp3p) / d2) omint2m = singmatrix[9, s] * ( (pp1m + pp2m + pp3m) / d2) bess1part2 = dblmatrix[4, beta - smod] * dblmatrix[ 4, alpha - smod] * besspart1 bess2part2 = dblmatrix[5, gamma - smod] * dblmatrix[ 5, beta - smod] * besspart1 for l in range(0, N): lmod = l + N - 1 bess1 = bess1part2 * dblmatrix[ 5, gamma - lmod] * dblmatrix[4, beta - lmod] grgl = bess1 * (omint1p - omint1m) bess2 = bess2part2 * dblmatrix[ 5, beta - lmod] * dblmatrix[4, alpha - lmod] glga = bess2 * (omint2p - omint2m) dds = dds + Gamm * (grgl + glga) return -4 * dds.real / math.pi**2
def modDsN2(x): N = 3 dds = 0 # ds = 0 # UNUSED qx = cudahelpers.getqx() ek = A * (math.sqrt((x[0])**2 + (x[1])**2))**2 + A * (eE0 / hOmg)**2 ekq = A * (math.sqrt((x[0] + qx)**2 + (x[1] + 0)**2))**2 + A * (eE0 / hOmg)**2 xk = 2 * A * eE0 * math.sqrt((x[0])**2 + (x[1])**2) / hOmg**2 xkq = 2 * A * eE0 * math.sqrt((x[0] + qx)**2 + (x[1] + 0)**2) / hOmg**2 singrmatrix = numba.cuda.shared.array((6, N), dtype=numba.types.f8) singzmatrix = numba.cuda.shared.array((4, N), dtype=numba.types.complex128) n = 0 i = -(N - 1) / 2 for n in range(0, N): nu = hOmg * i chi = hOmg / 2 omicron = ek - chi + nu phi = ekq - chi + nu iota = ek + chi + nu kappa = ekq + chi + nu omisq = omicron**2 phisq = phi**2 iotasq = iota**2 kappasq = kappa**2 singrmatrix[0, n] = 2 * math.atan2(Gamm, omicron) singrmatrix[1, n] = 2 * math.atan2(Gamm, phi) singrmatrix[2, n] = 2 * math.atan2(Gamm, iota) singrmatrix[3, n] = 2 * math.atan2(Gamm, kappa) singzmatrix[0, n] = complex(0, 1) * math.log(Gammsq + omisq) singzmatrix[1, n] = complex(0, 1) * math.log(Gammsq + phisq) singzmatrix[2, n] = complex(0, 1) * math.log(Gammsq + iotasq) singzmatrix[3, n] = complex(0, 1) * math.log(Gammsq + kappasq) chinu = chi - nu singrmatrix[4, n] = cudahelpers.my_heaviside(mu - chinu) singrmatrix[5, n] = cudahelpers.my_heaviside(mu + chinu) i = i + 1 size_dbl = 5 # 2N-1 dblrmatrix = numba.cuda.shared.array((5, size_dbl), dtype=numba.types.f8) dblzmatrix = numba.cuda.shared.array((4, size_dbl), dtype=numba.types.complex128) i = -(N - 1) for n in range(0, size_dbl): xi = hOmg * i zeta = ek - mu + xi eta = ekq - mu + xi zetasq = zeta**2 etasq = eta**2 dblrmatrix[0, n] = 2 * math.atan2(Gamm, zeta) dblrmatrix[1, n] = 2 * math.atan2(Gamm, eta) logged1 = math.log(Gammsq + zetasq) logged2 = math.log(Gammsq + etasq) dblzmatrix[0, n] = complex(0, logged1) dblzmatrix[1, n] = complex(0, logged2) dblrmatrix[2, n] = cudahelpers.besselj(i, xk) dblrmatrix[3, n] = cudahelpers.besselj(i, xkq) fac1i = ek - ekq + xi fac2i = complex(fac1i, 2 * Gamm) dblrmatrix[4, n] = fac1i dblzmatrix[2, n] = fac2i dblzmatrix[3, n] = fac2i - ek + ekq i = i + 1 for n in range(0, N): nmod = n + N - 1 for alpha in range(0, N): for beta in range(0, N): abdiff = alpha - beta + N - 1 for gamma in range(0, N): bgdiff = beta - gamma + N - 1 agdiff = alpha - gamma + N - 1 d1 = -2 * complex(0, 1) * dblrmatrix[ 4, bgdiff] * dblzmatrix[2, agdiff] * dblzmatrix[3, abdiff] d2 = -2 * complex(0, 1) * dblrmatrix[ 4, abdiff] * dblzmatrix[2, agdiff] * dblzmatrix[3, bgdiff] for s in range(0, N): smod = s + N - 1 rho = s + alpha tau = s + beta upsilon = s + gamma sdr00 = singrmatrix[0, alpha] - dblrmatrix[0, rho] sdr20 = singrmatrix[2, alpha] - dblrmatrix[0, rho] sdr11 = -singrmatrix[1, gamma] + dblrmatrix[1, upsilon] sdr31 = -singrmatrix[3, gamma] + dblrmatrix[1, upsilon] sdz00 = singzmatrix[0, alpha] + dblzmatrix[0, rho] sdz20 = singzmatrix[2, alpha] + dblzmatrix[0, rho] sdz11 = singzmatrix[1, gamma] + dblzmatrix[1, upsilon] sdz31 = singzmatrix[3, gamma] + dblzmatrix[1, upsilon] dd11 = dblrmatrix[1, tau] - dblzmatrix[1, tau] dd00 = dblrmatrix[0, tau] + dblzmatrix[0, tau] p1p = dblrmatrix[4, bgdiff] * (sdr00 - sdz00) p2p = dblzmatrix[2, agdiff] * ( singrmatrix[0, beta] - dd00 + singzmatrix[0, beta]) p3p = dblzmatrix[3, abdiff] * (sdr11 - sdz11) p1m = dblrmatrix[4, bgdiff] * (sdr20 - sdz20) p2m = dblzmatrix[2, agdiff] * ( singrmatrix[2, beta] - dd00 + singzmatrix[2, beta]) p3m = dblzmatrix[3, abdiff] * (sdr31 - sdz31) omint1p = singrmatrix[4, s] * ((p1p + p2p + p3p) / d1) omint1m = singrmatrix[5, s] * ((p1m + p2m + p3m) / d1) pp1p = dblrmatrix[4, abdiff] * (sdr11 - sdz11) pp2p = dblzmatrix[2, agdiff] * (-singrmatrix[1, beta] + dd11 + singzmatrix[1, beta]) pp3p = dblzmatrix[3, bgdiff] * (sdr00 - sdz00) pp1m = dblrmatrix[4, abdiff] * (sdr31 - sdz31) pp2m = dblzmatrix[2, agdiff] * (-singrmatrix[3, beta] + dd11 + singzmatrix[3, beta]) pp3m = dblzmatrix[3, bgdiff] * (sdr20 - sdz20) omint2p = singrmatrix[4, s] * ( (pp1p + pp2p + pp3p) / d2) omint2m = singrmatrix[5, s] * ( (pp1m + pp2m + pp3m) / d2) for l in range(0, N): lmod = l + N - 1 bess1 = dblrmatrix[3, gamma - nmod] * dblrmatrix[ 3, gamma - lmod] * dblrmatrix[ 2, beta - lmod] * dblrmatrix[ 2, beta - smod] * dblrmatrix[ 2, alpha - smod] * dblrmatrix[2, alpha - nmod] grgl = bess1 * (omint1p - omint1m) bess2 = dblrmatrix[3, gamma - nmod] * dblrmatrix[ 3, gamma - smod] * dblrmatrix[ 3, beta - smod] * dblrmatrix[ 3, beta - lmod] * dblrmatrix[ 2, alpha - lmod] * dblrmatrix[2, alpha - nmod] glga = bess2 * (omint2p - omint2m) dds = dds + Gamm * (grgl + glga) return -4 * dds.real / math.pi**2