Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
YigitElma committed May 26, 2024
1 parent 62d250e commit 33681e3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions zernipax/zernike.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Functions for evaluating Zernike polynomials and their derivatives."""

import functools
from math import factorial

import mpmath

from zernipax.backend import cond, custom_jvp, fori_loop, gammaln, jit, jnp, np, switch


Expand Down Expand Up @@ -2056,13 +2056,15 @@ def polyder_vec(p, m, exact=False):


def _polyder_exact(p, m):
from scipy.special import factorial

m = np.asarray(m, dtype=int) # order of derivative
p = np.atleast_2d(p)
order = p.shape[1] - 1

D = np.arange(order, -1, -1)
num = np.array([factorial(i) for i in D], dtype=object)
den = np.array([factorial(max(i - m, 0)) for i in D], dtype=object)
num = np.array([factorial(i, exact=True) for i in D], dtype=object)
den = np.array([factorial(max(i - m, 0), exact=True) for i in D], dtype=object)
D = (num // den).astype(p.dtype)

p = np.roll(D * p, m, axis=1)
Expand Down Expand Up @@ -2188,9 +2190,9 @@ def zernike_radial_coeffs(l, m, exact=True):
lms, idx = np.unique(lm, return_inverse=True, axis=0)

if exact:
from scipy.special import factorial as scipyFactorial
from scipy.special import factorial

_factorial = scipyFactorial
_factorial = lambda x: factorial(x, exact=True)
else:
_factorial = factorial
npoly = len(lms)
Expand Down

0 comments on commit 33681e3

Please sign in to comment.