Skip to content

Commit a5744ba

Browse files
author
Niek Wielders
committed
changed w5 and w6 calculation
1 parent cae20e2 commit a5744ba

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

autogalaxy/profiles/mass/stellar/gaussian.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,15 @@ def wofz(self, z, xp=np):
264264
9022.228, 24322.84, 32066.6], dtype=xp.float64)
265265

266266
# Horner form in z^2
267-
num5 = (U5[5] + z2 * (U5[4] + z2 * (U5[3] + z2 * (U5[2] + z2 * (U5[1] + z2 * (U5[0] + z2 * sqrt_pi))))))
267+
num5 = U5[0]
268+
for k in range(1, 6):
269+
num5 = num5 * z2 + U5[k]
270+
num5 = num5 * z2 + sqrt_pi
268271

269-
den5 = (V5[6] + z2 * (V5[5] + z2 * (V5[4] + z2 * (V5[3] + z2 * (V5[2] + z2 * (V5[1] + z2 * (V5[0] + z2)))))))
272+
den5 = V5[0]
273+
for k in range(1, 7):
274+
den5 = den5 * z2 + V5[k]
275+
den5 = den5 * z2 + z2
270276

271277
w5 = xp.exp(-z2) + 1j * z * num5 / den5
272278

@@ -276,12 +282,15 @@ def wofz(self, z, xp=np):
276282
V6 = xp.array([10.479857, 53.992907, 170.35400,
277283
348.70392, 457.33448, 352.73063, 122.60793], dtype=xp.float64)
278284

279-
num6 = (U6[5] - 1j * z * (U6[4] - 1j * z * (U6[3] - 1j * z * (U6[2] - 1j * z * (U6[1] - 1j * z *
280-
(U6[0] - 1j * z * sqrt_pi))))))
281-
282-
den6 = (V6[6] - 1j * z *(V6[5] - 1j * z * (V6[4] - 1j * z * (V6[3] - 1j * z * (V6[2] - 1j * z * (V6[1] - 1j * z *
283-
(V6[0] - 1j * z)))))))
285+
num6 = U6[0]
286+
for k in range(1, 6):
287+
num6 = num6 * (-1j * z) + U6[k]
288+
num6 = num6 * (-1j * z) + sqrt_pi
284289

290+
den6 = V6[0]
291+
for k in range(1, 7):
292+
den6 = den6 * (-1j * z) + V6[k]
293+
den6 = den6 * (-1j * z) + (-1j * z)
285294

286295
w6 = num6 / den6
287296

0 commit comments

Comments
 (0)